Documentation TYPO3 par Ameos

bookmark.lib.php

00001 <?php
00002 /* $Id: bookmark.lib.php,v 2.12.6.1 2005/10/21 02:23:50 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00019 function PMA_getBookmarksParam()
00020 {
00021     global $server;
00022 
00023     $cfgBookmark = '';
00024 
00025     // No server selected -> no bookmark table
00026     if ($server == 0) {
00027         return '';
00028     }
00029 
00030     $cfgBookmark['user']  = $GLOBALS['cfg']['Server']['user'];
00031     $cfgBookmark['db']    = $GLOBALS['cfg']['Server']['pmadb'];
00032     $cfgBookmark['table'] = $GLOBALS['cfg']['Server']['bookmarktable'];
00033 
00034     return $cfgBookmark;
00035 } // end of the 'PMA_getBookmarksParam()' function
00036 
00037 
00050 function PMA_listBookmarks($db, $cfgBookmark)
00051 {
00052     global $dbh;
00053 
00054     $query  = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00055             . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
00056             . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00057             . '      OR user = \'\')'
00058             . ' ORDER BY label';
00059     $result = PMA_DBI_query($query, $dbh, PMA_DBI_QUERY_STORE);
00060 
00061     // There are some bookmarks -> store them
00062     // use the unique id as the key
00063     if ($result && PMA_DBI_num_rows($result) > 0) {
00064         while ($row = PMA_DBI_fetch_row($result)) {
00065             $bookmark_list[$row[1]] = $row[0];
00066         } // end while
00067         return $bookmark_list;
00068     }
00069     // No bookmarks for the current database
00070     else {
00071         return FALSE;
00072     }
00073 } // end of the 'PMA_listBookmarks()' function
00074 
00075 
00091 function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bookmark_all = FALSE)
00092 {
00093     global $dbh;
00094 
00095     if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
00096         return '';
00097     }
00098 
00099     $query          = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00100                     . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
00101                     . ($action_bookmark_all? '' : ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00102                     . '      OR user = \'\')' )
00103                     . ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
00104     $result = PMA_DBI_try_query($query, $dbh);
00105     if (!$result) return FALSE;
00106     list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
00107 
00108     return $bookmark_query;
00109 } // end of the 'PMA_queryBookmarks()' function
00110 
00111 
00125 function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
00126 {
00127     global $dbh;
00128     $bookmarks = array();
00129 
00130     if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
00131         return $bookmarks;
00132     }
00133 
00134     $search_for = array();
00135     foreach($table_array AS $table => $table_sortkey) {
00136         $search_for[] = "'" . PMA_sqlAddslashes($table) . "'";
00137     }
00138 
00139     $query          = 'SELECT label, query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00140                     . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
00141                     . (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
00142     $result = PMA_DBI_try_query($query, $dbh, PMA_DBI_QUERY_STORE);
00143     if (!$result || PMA_DBI_num_rows($result) < 1) return $bookmarks;
00144     while ($row = PMA_DBI_fetch_assoc($result)) {
00145         $bookmarks[$row['label']] = $row['query'];
00146     }
00147 
00148     return $bookmarks;
00149 } // end of the 'PMA_queryBookmarks()' function
00150 
00164 function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
00165 {
00166     global $dbh;
00167 
00168     $query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00169            . ' (id, dbase, user, query, label) VALUES (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
00170     $result   = PMA_DBI_query($query, $dbh);
00171 
00172     return TRUE;
00173 } // end of the 'PMA_addBookmarks()' function
00174 
00175 
00187 function PMA_deleteBookmarks($db, $cfgBookmark, $id)
00188 {
00189     global $dbh;
00190 
00191     $query  = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00192             . ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00193             . '        OR user = \'\')'
00194             . ' AND id = ' . $id;
00195     $result = PMA_DBI_try_query($query, $dbh);
00196 } // end of the 'PMA_deleteBookmarks()' function
00197 
00198 
00202 $cfg['Bookmark'] = PMA_getBookmarksParam();
00203 
00204 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6