From: <vb...@us...> - 2002-09-19 21:51:04
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv10100/core Modified Files: html_api.php note_api.php page_api.php Log Message: - Added url field into page table. - Added code to auto-set the url when the page is viewed. - Some updates to the installation document (still needs a lot of work). - Added some images to the phpnet theme (previous, next, spacer) - Started working on the support for previous / next page. - Started the implementation of the Manage Notes page. - Removed the admin menu link to the admin_pending.php (will be removed soon). - Removed theme_note_add_page.php (never used) - Removed theme_note_preview_page.php (never used) Index: html_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/html_api.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- html_api.php 18 Sep 2002 13:17:40 -0000 1.7 +++ html_api.php 19 Sep 2002 21:51:01 -0000 1.8 @@ -113,9 +113,9 @@ } ### -------------------- function print_admin_menu() { - global $g_logout, $g_admin_index_files, $g_admin_pending, $g_admin_change_password, + global $g_logout, $g_admin_index_files, $g_admin_change_password, $g_admin_manage_notes, $g_admin_manage_users, - $s_logout_link, $s_index_files, $s_view_queue, $s_change_password, + $s_logout_link, $s_index_files, $s_change_password, $s_manage_notes, $s_manage_users, $g_user_home_page; $queue_count = note_queue_count(); @@ -126,13 +126,10 @@ echo "<a href=\"$g_admin_index_files\">$s_index_files</a> :: "; } if ( access_check_action( ACTION_NOTES_MODERATE ) ) { - echo "<a href=\"$g_admin_manage_notes\">$s_manage_notes</a> :: "; + echo "<a href=\"$g_admin_manage_notes\">$s_manage_notes</a> [$queue_count] :: "; } if ( access_check_action( ACTION_USERS_MANAGE ) ) { echo "<a href=\"$g_admin_manage_users\">$s_manage_users</a> :: "; - } - if ( access_check_action( ACTION_NOTES_MODERATE ) ) { - echo "<a href=\"$g_admin_pending\">$s_view_queue</a> [$queue_count] :: "; } if ( access_check_action( ACTION_USERS_EDIT_OWN ) ) { echo "<a href=\"$g_admin_change_password\">$s_change_password</a> :: "; Index: note_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/note_api.php,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- note_api.php 19 Sep 2002 05:15:47 -0000 1.18 +++ note_api.php 19 Sep 2002 21:51:01 -0000 1.19 @@ -107,6 +107,13 @@ } ### -------------------- function note_print_all( $p_page_name, $p_url ) { + $c_id = page_get_id( $p_page_name ); + if ( false === page_valid_id( $c_id ) ) { + return; + } + + page_update_url( $c_id, $p_url ); + $c_page_name = db_prepare_string( $p_page_name ); $query = "SELECT * Index: page_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/page_api.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- page_api.php 19 Sep 2002 04:15:48 -0000 1.10 +++ page_api.php 19 Sep 2002 21:51:02 -0000 1.11 @@ -9,28 +9,79 @@ # -------------------------------------------------------- ### -------------------- - function page_get_id( $p_file ) { - $c_file = db_prepare_string( $p_file ); - - $query = "SELECT id + function page_where_url_exists() { + return ("(url <> '')"); + } + ### -------------------- + function page_where_id_equals( $p_page_id ) { + $c_page_id = db_prepare_int( $p_page_id ); + return ("(id='$c_page_id')"); + } + ### -------------------- + function page_where_all() { + return ("(1=1)"); + } + ### -------------------- + function page_where_page_equals( $p_page ) { + $c_page_id = db_prepare_string( $p_page ); + return ("(page='$c_page_id')"); + } + ### -------------------- + # $p_where is constructed by page_where* and hence does not need to be cleaned. + function page_get_info ( $p_where, $p_field = null ) { + $query = "SELECT * FROM " . config_get( 'phpWN_page_table' ) . " - WHERE page='$c_file' + WHERE $p_where LIMIT 1"; $result = db_query( $query ); if ( db_num_rows( $result) > 0 ) { - return db_result( $result, 0, 0 ); + $t_info = db_fetch_array( $result ); + + if ( null === $p_field ) { + return $t_info; + } else { + #echo "$p_field\n"; var_dump($t_info); exit; + return $t_info["$p_field"]; + } } return false; } ### -------------------- + # $p_where is constructed by page_where* and hence does not need to be cleaned. + function page_get_array ( $p_where, $p_order = null ) { + if ( null !== $p_order ) { + $p_order = 'ORDER BY ' . $p_order; + $c_order = db_prepare_string( $p_order ); + } else { + $c_order = ''; + } + + $query = "SELECT * + FROM " . config_get( 'phpWN_page_table' ) . " + WHERE $p_where + $c_order"; + + $t_array = array(); + $result = db_query( $query ); + while ( $row = db_fetch_array( $result ) ) { + $t_array[] = $row; + } + + return $t_array; + } + ### -------------------- + function page_get_id( $p_page ) { + return ( page_get_info( page_where_page_equals( $p_page ), 'id' ) ); + } + ### -------------------- function page_valid_id( $p_page_id ) { return ( false !== $p_page_id ); } ### -------------------- - function page_is_indexed( $p_file ) { - return ( page_valid_id( page_get_id( $p_file ) ) ); + function page_is_indexed( $p_page ) { + return ( page_valid_id( page_get_id( $p_page ) ) ); } ### -------------------- function page_visible_notes_count( $p_page_id ) { @@ -67,6 +118,21 @@ } return false; + } + ### -------------------- + function page_update_url( $p_page_id, $p_url ) { + $t_url = page_get_info( page_where_id_equals( $p_page_id ), 'url' ); + if ( $t_url === $p_url ) { + return; + } + + $c_page_id = db_prepare_int( $p_page_id ); + $c_url = db_prepare_string( $p_url ); + + $query = "UPDATE " . config_get( 'phpWN_page_table' ) . " + SET url='$c_url' + WHERE id='$c_page_id' LIMIT 1"; + $result = db_query( $query ); } ### -------------------- ### Allows for path navigation to choose base dir |