|
From: Jon O. <jon...@us...> - 2006-07-08 16:28:50
|
Update of /cvsroot/mxbb/mx_pafiledb/pafiledb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15070/modules/mx_pafiledb/pafiledb/includes Modified Files: functions_admin.php functions_pafiledb.php Log Message: moved functions and removed files Index: functions_admin.php =================================================================== RCS file: /cvsroot/mxbb/mx_pafiledb/pafiledb/includes/functions_admin.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions_admin.php 8 Jul 2006 10:23:34 -0000 1.5 --- functions_admin.php 8 Jul 2006 16:28:46 -0000 1.6 *************** *** 45,54 **** function admin_display_cat_auth( $cat_parent = 0, $depth = 0 ) { ! global $pafiledb, $phpbb_root_path, $pafiledb_template, $phpEx; global $cat_auth_fields, $cat_auth_const, $cat_auth_levels, $lang; $pre = str_repeat( ' ', $depth ); ! if ( isset( $pafiledb->subcat_rowset[$cat_parent] ) ) { ! foreach( $pafiledb->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( --- 45,54 ---- function admin_display_cat_auth( $cat_parent = 0, $depth = 0 ) { ! global $phpbb_root_path, $pafiledb_template, $phpEx; global $cat_auth_fields, $cat_auth_const, $cat_auth_levels, $lang; $pre = str_repeat( ' ', $depth ); ! if ( isset( $this->subcat_rowset[$cat_parent] ) ) { ! foreach( $this->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( *************** *** 56,60 **** 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true, 'PRE' => $pre, ! 'U_CAT' => append_sid( "admin_pa_catauth.$phpEx?cat_parent=$sub_cat_id" ) )); --- 56,60 ---- 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true, 'PRE' => $pre, ! 'U_CAT' => append_sid( "admin_pafiledb.$phpEx?action=catauth_manage&cat_parent=$sub_cat_id" ) )); *************** *** 72,76 **** $pafiledb_template->assign_block_vars( 'cat_row.cat_auth_data', array( 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j] ) ); } ! admin_display_cat_auth( $sub_cat_id, $depth + 1 ); } return; --- 72,76 ---- $pafiledb_template->assign_block_vars( 'cat_row.cat_auth_data', array( 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j] ) ); } ! $this->admin_display_cat_auth( $sub_cat_id, $depth + 1 ); } return; *************** *** 81,90 **** function admin_display_cat_auth_ug( $cat_parent = 0, $depth = 0 ) { ! global $pafiledb, $phpbb_root_path, $pafiledb_template, $phpEx; global $cat_auth_fields, $optionlist_mod, $optionlist_acl_adv; $pre = str_repeat( ' ', $depth ); ! if ( isset( $pafiledb->subcat_rowset[$cat_parent] ) ) { ! foreach( $pafiledb->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( --- 81,90 ---- function admin_display_cat_auth_ug( $cat_parent = 0, $depth = 0 ) { ! global $phpbb_root_path, $pafiledb_template, $phpEx; global $cat_auth_fields, $optionlist_mod, $optionlist_acl_adv; $pre = str_repeat( ' ', $depth ); ! if ( isset( $this->subcat_rowset[$cat_parent] ) ) { ! foreach( $this->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( *************** *** 92,96 **** 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true, 'PRE' => $pre, ! 'U_CAT' => append_sid( "admin_pa_catauth.$phpEx?cat_id=$sub_cat_id" ), 'S_MOD_SELECT' => $optionlist_mod[$sub_cat_id] )); --- 92,96 ---- 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true, 'PRE' => $pre, ! 'U_CAT' => append_sid( "admin_pafiledb.$phpEx?action=catauth&cat_id=$sub_cat_id" ), 'S_MOD_SELECT' => $optionlist_mod[$sub_cat_id] )); *************** *** 100,104 **** $pafiledb_template->assign_block_vars( 'cat_row.aclvalues', array( 'S_ACL_SELECT' => $optionlist_acl_adv[$sub_cat_id][$j] ) ); } ! admin_display_cat_auth_ug( $sub_cat_id, $depth + 1 ); } return; --- 100,104 ---- $pafiledb_template->assign_block_vars( 'cat_row.aclvalues', array( 'S_ACL_SELECT' => $optionlist_acl_adv[$sub_cat_id][$j] ) ); } ! $this->admin_display_cat_auth_ug( $sub_cat_id, $depth + 1 ); } return; *************** *** 109,131 **** function admin_cat_main( $cat_parent = 0, $depth = 0 ) { ! global $pafiledb, $phpbb_root_path, $pafiledb_template, $phpEx; $pre = str_repeat( ' ', $depth ); ! if ( isset( $pafiledb->subcat_rowset[$cat_parent] ) ) { ! foreach( $pafiledb->subcat_rowset[$cat_parent] as $subcat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] == PA_CAT_ALLOW_FILE ) ? false : true, ! 'U_CAT' => append_sid( 'admin_pa_category.php?cat_id=' . $subcat_id ), ! 'U_CAT_EDIT' => append_sid( "admin_pa_category.$phpEx?mode=edit&cat_id=$subcat_id" ), ! 'U_CAT_DELETE' => append_sid( "admin_pa_category.$phpEx?mode=delete&cat_id=$subcat_id" ), ! 'U_CAT_MOVE_UP' => append_sid( "admin_pa_category.$phpEx?mode=cat_order&move=-15&cat_id_other=$subcat_id" ), ! 'U_CAT_MOVE_DOWN' => append_sid( "admin_pa_category.$phpEx?mode=cat_order&move=15&cat_id_other=$subcat_id" ), ! 'U_CAT_RESYNC' => append_sid( "admin_pa_category.$phpEx?mode=sync&cat_id_other=$subcat_id" ), 'CAT_NAME' => $cat_data['cat_name'], 'PRE' => $pre )); ! admin_cat_main( $subcat_id, $depth + 1 ); } return; --- 109,131 ---- function admin_cat_main( $cat_parent = 0, $depth = 0 ) { ! global $phpbb_root_path, $pafiledb_template, $phpEx; $pre = str_repeat( ' ', $depth ); ! if ( isset( $this->subcat_rowset[$cat_parent] ) ) { ! foreach( $this->subcat_rowset[$cat_parent] as $subcat_id => $cat_data ) { $pafiledb_template->assign_block_vars( 'cat_row', array( 'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] == PA_CAT_ALLOW_FILE ) ? false : true, ! 'U_CAT' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&cat_id=$subcat_id" ), ! 'U_CAT_EDIT' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&mode=edit&cat_id=$subcat_id" ), ! 'U_CAT_DELETE' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&mode=delete&cat_id=$subcat_id" ), ! 'U_CAT_MOVE_UP' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&mode=cat_order&move=-15&cat_id_other=$subcat_id" ), ! 'U_CAT_MOVE_DOWN' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&mode=cat_order&move=15&cat_id_other=$subcat_id" ), ! 'U_CAT_RESYNC' => append_sid( "admin_pafiledb.$phpEx?action=cat_manage&mode=sync&cat_id_other=$subcat_id" ), 'CAT_NAME' => $cat_data['cat_name'], 'PRE' => $pre )); ! $this->admin_cat_main( $subcat_id, $depth + 1 ); } return; *************** *** 259,262 **** --- 259,585 ---- return ( $is_mod = ( $db->sql_fetchrow( $result ) ) ? 1 : 0 ); } + + /** + * Enter description here... + * + * @param unknown_type $cat_id + * @return unknown + */ + function update_add_cat( $cat_id = false ) + { + global $db, $_POST, $lang; + + $cat_name = ( isset( $_POST['cat_name'] ) ) ? htmlspecialchars( $_POST['cat_name'] ) : ''; + $cat_desc = ( isset( $_POST['cat_desc'] ) ) ? htmlspecialchars( $_POST['cat_desc'] ) : ''; + $cat_parent = ( isset( $_POST['cat_parent'] ) ) ? intval( $_POST['cat_parent'] ) : 0; + $cat_allow_file = ( isset( $_POST['cat_allow_file'] ) ) ? intval( $_POST['cat_allow_file'] ) : 0; + + $cat_use_comments = ( isset( $_POST['cat_allow_comments'] ) ) ? intval( $_POST['cat_allow_comments'] ) : 0; + $cat_internal_comments = ( isset( $_POST['internal_comments'] ) ) ? intval( $_POST['internal_comments'] ) : 0; + $cat_autogenerate_comments = ( isset( $_POST['autogenerate_comments'] ) ) ? intval( $_POST['autogenerate_comments'] ) : 0; + $comments_forum_id = intval( $_POST['comments_forum_id'] ); + + $cat_show_pretext = ( isset( $_POST['show_pretext'] ) ) ? intval( $_POST['show_pretext'] ) : 0; + + $cat_use_ratings = ( isset( $_POST['cat_allow_ratings'] ) ) ? intval( $_POST['cat_allow_ratings'] ) : 0; + + $cat_notify = ( isset( $_POST['notify'] ) ) ? intval( $_POST['notify'] ) : 0; + $cat_notify_group = ( isset( $_POST['notify_group'] ) ) ? intval( $_POST['notify_group'] ) : 0; + + if ( empty( $cat_name ) ) + { + $this->error[] = $lang['Cat_name_missing']; + } + + if ( $cat_parent ) + { + if ( !$this->cat_rowset[$cat_parent]['cat_allow_file'] && !$cat_allow_file ) + { + $this->error[] = $lang['Cat_conflict']; + } + } + + if ( sizeof( $this->error ) ) + { + return; + } + + $cat_name = str_replace( "\'", "''", $cat_name ); + $cat_desc = str_replace( "\'", "''", $cat_desc ); + + if ( !$cat_id ) + { + $cat_order = 0; + if ( !empty( $this->subcat_rowset[$cat_parent] ) ) + { + foreach( $this->subcat_rowset[$cat_parent] as $cat_data ) + { + if ( $cat_order < $cat_data['cat_order'] ) + { + $cat_order = $cat_data['cat_order']; + } + } + } + + $cat_order += 10; + + $sql = 'INSERT INTO ' . PA_CATEGORY_TABLE . " (cat_name, cat_desc, cat_parent, cat_order, cat_allow_file, cat_allow_ratings, cat_allow_comments, internal_comments, autogenerate_comments, comments_forum_id, show_pretext, notify, notify_group) + VALUES('$cat_name', '$cat_desc', $cat_parent, $cat_order, $cat_allow_file, $cat_use_ratings, $cat_use_comments, $cat_internal_comments, $cat_autogenerate_comments, $comments_forum_id, $cat_show_pretext, $cat_notify, $cat_notify_group)"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t add a new category', '', __LINE__, __FILE__, $sql ); + } + } + else + { + $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " + SET cat_name = '$cat_name', cat_desc = '$cat_desc', cat_parent = $cat_parent, cat_allow_file = $cat_allow_file, cat_allow_ratings = $cat_use_ratings, cat_allow_comments = $cat_use_comments, internal_comments = $cat_internal_comments, autogenerate_comments = $cat_autogenerate_comments, comments_forum_id = $comments_forum_id, show_pretext = $cat_show_pretext, notify = $cat_notify, notify_group = $cat_notify_group + WHERE cat_id = $cat_id"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t Edit this category', '', __LINE__, __FILE__, $sql ); + } + + if ( $cat_parent != $this->cat_rowset[$cat_id]['cat_parent'] ) + { + $this->reorder_cat( $this->cat_rowset[$cat_id]['cat_parent'] ); + $this->reorder_cat( $cat_parent ); + } + $this->modified( true ); + } + + if ( $cat_id ) + { + return $cat_id; + } + else + { + return $db->sql_nextid(); + } + } + + /** + * Enter description here... + * + * @param unknown_type $cat_id + */ + function delete_cat( $cat_id = false ) + { + global $db, $_POST, $lang; + + $file_to_cat_id = ( isset( $_POST['file_to_cat_id'] ) ) ? intval( $_POST['file_to_cat_id'] ) : ''; + $subcat_to_cat_id = ( isset( $_POST['subcat_to_cat_id'] ) ) ? intval( $_POST['subcat_to_cat_id'] ) : ''; + $file_mode = ( isset( $_POST['file_mode'] ) ) ? htmlspecialchars( $_POST['file_mode'] ) : 'move'; + $subcat_mode = ( isset( $_POST['subcat_mode'] ) ) ? htmlspecialchars( $_POST['subcat_mode'] ) : 'move'; + + if ( empty( $cat_id ) ) + { + $this->error[] = $lang['Cdelerror']; + } + else + { + if ( ( $file_to_cat_id == -1 || empty( $file_to_cat_id ) ) && $file_mode == 'move' ) + { + $this->error[] = $lang['Cdelerror']; + } + + if ( $subcat_mode == 'move' && empty( $subcat_to_cat_id ) ) + { + $this->error[] = $lang['Cdelerror']; + } + + if ( sizeof( $this->error ) ) + { + return; + } + + $sql = 'DELETE FROM ' . PA_CATEGORY_TABLE . " + WHERE cat_id = $cat_id"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query Info', '', __LINE__, __FILE__, $sql ); + } + + $this->reorder_cat( $this->cat_rowset[$cat_id]['cat_parent'] ); + + if ( $file_mode == 'delete' ) + { + $this->delete_files( $cat_id, 'category' ); + } + else + { + $this->move_files( $cat_id, $file_to_cat_id ); + } + + if ( $subcat_mode == 'delete' ) + { + $this->delete_subcat( $cat_id, $file_mode, $file_to_cat_id ); + } + else + { + $this->move_subcat( $cat_id, $subcat_to_cat_id ); + } + $this->modified( true ); + } + } + + /** + * Enter description here... + * + * @param unknown_type $from_cat + * @param unknown_type $to_cat + */ + function move_files( $from_cat, $to_cat ) + { + global $db; + + $sql = 'UPDATE ' . PA_FILES_TABLE . " + SET file_catid = $to_cat + WHERE file_catid = $from_cat"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt move files', '', __LINE__, __FILE__, $sql ); + } + + $this->modified( true ); + return; + } + + /** + * Enter description here... + * + * @param unknown_type $cat_id + * @param unknown_type $file_mode + * @param unknown_type $to_cat + */ + function delete_subcat( $cat_id, $file_mode = 'delete', $to_cat = false ) + { + global $db; + + if ( empty( $this->subcat_rowset[$cat_id] ) || count( $this->subcat_rowset[$cat_id] ) <= 0 ) + { + return; + } + + foreach( $this->subcat_rowset[$cat_id] as $sub_cat_id => $subcat_data ) + { + $this->delete_subcat( $sub_cat_id, $file_mode, $to_cat ); + + $sql = 'DELETE FROM ' . PA_CATEGORY_TABLE . " + WHERE cat_id = $sub_cat_id"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query Info', '', __LINE__, __FILE__, $sql ); + } + + if ( $file_mode == 'delete' ) + { + $this->delete_files( $sub_cat_id, 'category' ); + } + else + { + $this->move_files( $sub_cat_id, $to_cat ); + } + } + $this->modified( true ); + return; + } + + /** + * Enter description here... + * + * @param unknown_type $from_cat + * @param unknown_type $to_cat + */ + function move_subcat( $from_cat, $to_cat ) + { + global $db; + + $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " + SET cat_parent = $to_cat + WHERE cat_parent = $from_cat"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt move Sub Category', '', __LINE__, __FILE__, $sql ); + } + $this->modified( true ); + return; + } + + /** + * Enter description here... + * + * @param unknown_type $cat_parent + */ + function reorder_cat( $cat_parent ) + { + global $db; + + $sql = 'SELECT cat_id, cat_order + FROM ' . PA_CATEGORY_TABLE . " + WHERE cat_parent = $cat_parent + ORDER BY cat_order ASC"; + + if ( !$result = $db->sql_query( $sql ) ) + { + mx_message_die( GENERAL_ERROR, 'Could not get list of Categories', '', __LINE__, __FILE__, $sql ); + } + + $i = 10; + while ( $row = $db->sql_fetchrow( $result ) ) + { + $cat_id = $row['cat_id']; + + $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " + SET cat_order = $i + WHERE cat_id = $cat_id"; + if ( !$db->sql_query( $sql ) ) + { + mx_message_die( GENERAL_ERROR, 'Could not update order fields', '', __LINE__, __FILE__, $sql ); + } + $i += 10; + } + } + + /** + * Enter description here... + * + * @param unknown_type $cat_id + */ + function order_cat( $cat_id ) + { + global $db, $_GET; + + $move = ( isset( $_GET['move'] ) ) ? intval( $_GET['move'] ) : 15; + $cat_parent = $this->cat_rowset[$cat_id]['cat_parent']; + + $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " + SET cat_order = cat_order + $move + WHERE cat_id = $cat_id"; + + if ( !$result = $db->sql_query( $sql ) ) + { + mx_message_die( GENERAL_ERROR, 'Could not change category order', '', __LINE__, __FILE__, $sql ); + } + + $this->reorder_cat( $cat_parent ); + $this->init(); + } + + /** + * Enter description here... + * + * @return unknown + */ + function file_mainenance() + { + return false; + } } ?> \ No newline at end of file Index: functions_pafiledb.php =================================================================== RCS file: /cvsroot/mxbb/mx_pafiledb/pafiledb/includes/functions_pafiledb.php,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** functions_pafiledb.php 8 Jul 2006 10:23:34 -0000 1.35 --- functions_pafiledb.php 8 Jul 2006 16:28:46 -0000 1.36 *************** *** 1869,2287 **** * Enter description here... * - * @param unknown_type $cat_id - * @return unknown - */ - function update_add_cat( $cat_id = false ) - { - global $db, $_POST, $lang; - - $cat_name = ( isset( $_POST['cat_name'] ) ) ? htmlspecialchars( $_POST['cat_name'] ) : ''; - $cat_desc = ( isset( $_POST['cat_desc'] ) ) ? htmlspecialchars( $_POST['cat_desc'] ) : ''; - $cat_parent = ( isset( $_POST['cat_parent'] ) ) ? intval( $_POST['cat_parent'] ) : 0; - $cat_allow_file = ( isset( $_POST['cat_allow_file'] ) ) ? intval( $_POST['cat_allow_file'] ) : 0; - - $cat_use_comments = ( isset( $_POST['cat_allow_comments'] ) ) ? intval( $_POST['cat_allow_comments'] ) : 0; - $cat_internal_comments = ( isset( $_POST['internal_comments'] ) ) ? intval( $_POST['internal_comments'] ) : 0; - $cat_autogenerate_comments = ( isset( $_POST['autogenerate_comments'] ) ) ? intval( $_POST['autogenerate_comments'] ) : 0; - $comments_forum_id = intval( $_POST['comments_forum_id'] ); - - $cat_show_pretext = ( isset( $_POST['show_pretext'] ) ) ? intval( $_POST['show_pretext'] ) : 0; - - $cat_use_ratings = ( isset( $_POST['cat_allow_ratings'] ) ) ? intval( $_POST['cat_allow_ratings'] ) : 0; - - $cat_notify = ( isset( $_POST['notify'] ) ) ? intval( $_POST['notify'] ) : 0; - $cat_notify_group = ( isset( $_POST['notify_group'] ) ) ? intval( $_POST['notify_group'] ) : 0; - - if ( empty( $cat_name ) ) - { - $this->error[] = $lang['Cat_name_missing']; - } - - if ( $cat_parent ) - { - if ( !$this->cat_rowset[$cat_parent]['cat_allow_file'] && !$cat_allow_file ) - { - $this->error[] = $lang['Cat_conflict']; - } - } - - if ( sizeof( $this->error ) ) - { - return; - } - - $cat_name = str_replace( "\'", "''", $cat_name ); - $cat_desc = str_replace( "\'", "''", $cat_desc ); - - if ( !$cat_id ) - { - $cat_order = 0; - if ( !empty( $this->subcat_rowset[$cat_parent] ) ) - { - foreach( $this->subcat_rowset[$cat_parent] as $cat_data ) - { - if ( $cat_order < $cat_data['cat_order'] ) - { - $cat_order = $cat_data['cat_order']; - } - } - } - - $cat_order += 10; - - $sql = 'INSERT INTO ' . PA_CATEGORY_TABLE . " (cat_name, cat_desc, cat_parent, cat_order, cat_allow_file, cat_allow_ratings, cat_allow_comments, internal_comments, autogenerate_comments, comments_forum_id, show_pretext, notify, notify_group) - VALUES('$cat_name', '$cat_desc', $cat_parent, $cat_order, $cat_allow_file, $cat_use_ratings, $cat_use_comments, $cat_internal_comments, $cat_autogenerate_comments, $comments_forum_id, $cat_show_pretext, $cat_notify, $cat_notify_group)"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t add a new category', '', __LINE__, __FILE__, $sql ); - } - } - else - { - $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " - SET cat_name = '$cat_name', cat_desc = '$cat_desc', cat_parent = $cat_parent, cat_allow_file = $cat_allow_file, cat_allow_ratings = $cat_use_ratings, cat_allow_comments = $cat_use_comments, internal_comments = $cat_internal_comments, autogenerate_comments = $cat_autogenerate_comments, comments_forum_id = $comments_forum_id, show_pretext = $cat_show_pretext, notify = $cat_notify, notify_group = $cat_notify_group - WHERE cat_id = $cat_id"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t Edit this category', '', __LINE__, __FILE__, $sql ); - } - - if ( $cat_parent != $this->cat_rowset[$cat_id]['cat_parent'] ) - { - $this->reorder_cat( $this->cat_rowset[$cat_id]['cat_parent'] ); - $this->reorder_cat( $cat_parent ); - } - $this->modified( true ); - } - - if ( $cat_id ) - { - return $cat_id; - } - else - { - return $db->sql_nextid(); - } - } - - /** - * Enter description here... - * - * @param unknown_type $cat_id - */ - function delete_cat( $cat_id = false ) - { - global $db, $_POST, $lang; - - $file_to_cat_id = ( isset( $_POST['file_to_cat_id'] ) ) ? intval( $_POST['file_to_cat_id'] ) : ''; - $subcat_to_cat_id = ( isset( $_POST['subcat_to_cat_id'] ) ) ? intval( $_POST['subcat_to_cat_id'] ) : ''; - $file_mode = ( isset( $_POST['file_mode'] ) ) ? htmlspecialchars( $_POST['file_mode'] ) : 'move'; - $subcat_mode = ( isset( $_POST['subcat_mode'] ) ) ? htmlspecialchars( $_POST['subcat_mode'] ) : 'move'; - - if ( empty( $cat_id ) ) - { - $this->error[] = $lang['Cdelerror']; - } - else - { - if ( ( $file_to_cat_id == -1 || empty( $file_to_cat_id ) ) && $file_mode == 'move' ) - { - $this->error[] = $lang['Cdelerror']; - } - - if ( $subcat_mode == 'move' && empty( $subcat_to_cat_id ) ) - { - $this->error[] = $lang['Cdelerror']; - } - - if ( sizeof( $this->error ) ) - { - return; - } - - $sql = 'DELETE FROM ' . PA_CATEGORY_TABLE . " - WHERE cat_id = $cat_id"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt Query Info', '', __LINE__, __FILE__, $sql ); - } - - $this->reorder_cat( $this->cat_rowset[$cat_id]['cat_parent'] ); - - if ( $file_mode == 'delete' ) - { - $this->delete_files( $cat_id, 'category' ); - } - else - { - $this->move_files( $cat_id, $file_to_cat_id ); - } - - if ( $subcat_mode == 'delete' ) - { - $this->delete_subcat( $cat_id, $file_mode, $file_to_cat_id ); - } - else - { - $this->move_subcat( $cat_id, $subcat_to_cat_id ); - } - $this->modified( true ); - } - } - - /** - * Enter description here... - * - * @param unknown_type $id - * @param unknown_type $mode - */ - function delete_files( $id, $mode = 'file' ) - { - global $db, $phpbb_root_path, $pafiledb_functions; - - if ( $mode == 'category' ) - { - $file_ids = array(); - $files_data = array(); - - $sql = 'SELECT file_id, unique_name, file_dir - FROM ' . PA_FILES_TABLE . " - WHERE file_catid = $id"; - - if ( !( $result = $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt select files', '', __LINE__, __FILE__, $sql ); - } - - while ( $row = $db->sql_fetchrow( $result ) ) - { - $file_ids[] = $row['file_id']; - $files_data[] = $row; - } - - $where_sql = "WHERE file_catid = $id"; - } - else - { - $sql = 'SELECT file_id, unique_name, file_dir - FROM ' . PA_FILES_TABLE . " - WHERE file_id = $id"; - - if ( !( $result = $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt select files', '', __LINE__, __FILE__, $sql ); - } - - $file_data = $db->sql_fetchrow( $result ); - - $where_sql = "WHERE file_id = $id"; - } - - $sql = 'DELETE FROM ' . PA_FILES_TABLE . " - $where_sql"; - - unset( $where_sql ); - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt delete files', '', __LINE__, __FILE__, $sql ); - } - - $where_sql = ( $mode != 'file' && !empty( $file_ids ) ) ? ' IN (' . implode( ', ', $file_ids ) . ') ' : " = $id"; - - $sql = 'DELETE FROM ' . PA_CUSTOM_DATA_TABLE . " - WHERE customdata_file$where_sql"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt delete custom data', '', __LINE__, __FILE__, $sql ); - } - - $sql = 'DELETE FROM ' . PA_MIRRORS_TABLE . " - WHERE file_id$where_sql"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt delete mirror for this file', '', __LINE__, __FILE__, $sql ); - } - - if ( $mode == 'category' ) - { - foreach( $files_data as $file_data ) - { - if ( !empty( $file_data['unique_name'] ) ) - { - $pafiledb_functions->pafiledb_unlink( $phpbb_root_path . $file_data['file_dir'] . $file_data['unique_name'] ); - } - } - } - else - { - if ( !empty( $file_data['unique_name'] ) ) - { - $pafiledb_functions->pafiledb_unlink( $phpbb_root_path . $file_data['file_dir'] . $file_data['unique_name'] ); - } - } - - if ( $mode == 'file' ) - { - $this->modified( true ); - } - - return; - } - - /** - * Enter description here... - * - * @param unknown_type $from_cat - * @param unknown_type $to_cat - */ - function move_files( $from_cat, $to_cat ) - { - global $db; - - $sql = 'UPDATE ' . PA_FILES_TABLE . " - SET file_catid = $to_cat - WHERE file_catid = $from_cat"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt move files', '', __LINE__, __FILE__, $sql ); - } - - $this->modified( true ); - return; - } - - /** - * Enter description here... - * - * @param unknown_type $cat_id - * @param unknown_type $file_mode - * @param unknown_type $to_cat - */ - function delete_subcat( $cat_id, $file_mode = 'delete', $to_cat = false ) - { - global $db; - - if ( empty( $this->subcat_rowset[$cat_id] ) || count( $this->subcat_rowset[$cat_id] ) <= 0 ) - { - return; - } - - foreach( $this->subcat_rowset[$cat_id] as $sub_cat_id => $subcat_data ) - { - $this->delete_subcat( $sub_cat_id, $file_mode, $to_cat ); - - $sql = 'DELETE FROM ' . PA_CATEGORY_TABLE . " - WHERE cat_id = $sub_cat_id"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt Query Info', '', __LINE__, __FILE__, $sql ); - } - - if ( $file_mode == 'delete' ) - { - $this->delete_files( $sub_cat_id, 'category' ); - } - else - { - $this->move_files( $sub_cat_id, $to_cat ); - } - } - $this->modified( true ); - return; - } - - /** - * Enter description here... - * - * @param unknown_type $from_cat - * @param unknown_type $to_cat - */ - function move_subcat( $from_cat, $to_cat ) - { - global $db; - - $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " - SET cat_parent = $to_cat - WHERE cat_parent = $from_cat"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt move Sub Category', '', __LINE__, __FILE__, $sql ); - } - $this->modified( true ); - return; - } - - /** - * Enter description here... - * - * @param unknown_type $cat_parent - */ - function reorder_cat( $cat_parent ) - { - global $db; - - $sql = 'SELECT cat_id, cat_order - FROM ' . PA_CATEGORY_TABLE . " - WHERE cat_parent = $cat_parent - ORDER BY cat_order ASC"; - - if ( !$result = $db->sql_query( $sql ) ) - { - mx_message_die( GENERAL_ERROR, 'Could not get list of Categories', '', __LINE__, __FILE__, $sql ); - } - - $i = 10; - while ( $row = $db->sql_fetchrow( $result ) ) - { - $cat_id = $row['cat_id']; - - $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " - SET cat_order = $i - WHERE cat_id = $cat_id"; - if ( !$db->sql_query( $sql ) ) - { - mx_message_die( GENERAL_ERROR, 'Could not update order fields', '', __LINE__, __FILE__, $sql ); - } - $i += 10; - } - } - - /** - * Enter description here... - * - * @param unknown_type $cat_id - */ - function order_cat( $cat_id ) - { - global $db, $_GET; - - $move = ( isset( $_GET['move'] ) ) ? intval( $_GET['move'] ) : 15; - $cat_parent = $this->cat_rowset[$cat_id]['cat_parent']; - - $sql = 'UPDATE ' . PA_CATEGORY_TABLE . " - SET cat_order = cat_order + $move - WHERE cat_id = $cat_id"; - - if ( !$result = $db->sql_query( $sql ) ) - { - mx_message_die( GENERAL_ERROR, 'Could not change category order', '', __LINE__, __FILE__, $sql ); - } - - $this->reorder_cat( $cat_parent ); - $this->init(); - } - - /** - * Enter description here... - * * @param unknown_type $file_id * @return unknown --- 1869,1872 ---- *************** *** 2581,2584 **** --- 2166,2271 ---- * Enter description here... * + * @param unknown_type $id + * @param unknown_type $mode + */ + function delete_files( $id, $mode = 'file' ) + { + global $db, $phpbb_root_path, $pafiledb_functions; + + if ( $mode == 'category' ) + { + $file_ids = array(); + $files_data = array(); + + $sql = 'SELECT file_id, unique_name, file_dir + FROM ' . PA_FILES_TABLE . " + WHERE file_catid = $id"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt select files', '', __LINE__, __FILE__, $sql ); + } + + while ( $row = $db->sql_fetchrow( $result ) ) + { + $file_ids[] = $row['file_id']; + $files_data[] = $row; + } + + $where_sql = "WHERE file_catid = $id"; + } + else + { + $sql = 'SELECT file_id, unique_name, file_dir + FROM ' . PA_FILES_TABLE . " + WHERE file_id = $id"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt select files', '', __LINE__, __FILE__, $sql ); + } + + $file_data = $db->sql_fetchrow( $result ); + + $where_sql = "WHERE file_id = $id"; + } + + $sql = 'DELETE FROM ' . PA_FILES_TABLE . " + $where_sql"; + + unset( $where_sql ); + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt delete files', '', __LINE__, __FILE__, $sql ); + } + + $where_sql = ( $mode != 'file' && !empty( $file_ids ) ) ? ' IN (' . implode( ', ', $file_ids ) . ') ' : " = $id"; + + $sql = 'DELETE FROM ' . PA_CUSTOM_DATA_TABLE . " + WHERE customdata_file$where_sql"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt delete custom data', '', __LINE__, __FILE__, $sql ); + } + + $sql = 'DELETE FROM ' . PA_MIRRORS_TABLE . " + WHERE file_id$where_sql"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt delete mirror for this file', '', __LINE__, __FILE__, $sql ); + } + + if ( $mode == 'category' ) + { + foreach( $files_data as $file_data ) + { + if ( !empty( $file_data['unique_name'] ) ) + { + $pafiledb_functions->pafiledb_unlink( $phpbb_root_path . $file_data['file_dir'] . $file_data['unique_name'] ); + } + } + } + else + { + if ( !empty( $file_data['unique_name'] ) ) + { + $pafiledb_functions->pafiledb_unlink( $phpbb_root_path . $file_data['file_dir'] . $file_data['unique_name'] ); + } + } + + if ( $mode == 'file' ) + { + $this->modified( true ); + } + + return; + } + + /** + * Enter description here... + * * @param unknown_type $file_id * @param unknown_type $file_upload *************** *** 2710,2723 **** * Enter description here... * - * @return unknown - */ - function file_mainenance() - { - return false; - } - - /** - * Enter description here... - * * @param unknown_type $mode * @param unknown_type $file_id --- 2397,2400 ---- |