|
From: Jon O. <jon...@us...> - 2006-07-08 16:26:07
|
Update of /cvsroot/mxbb/mx_linkdb/linkdb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13965/modules/mx_linkdb/linkdb/includes Modified Files: functions_admin.php functions_linkdb.php Log Message: moved functions Index: functions_admin.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions_admin.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions_admin.php 8 Jul 2006 10:22:38 -0000 1.1 --- functions_admin.php 8 Jul 2006 16:26:04 -0000 1.2 *************** *** 43,46 **** --- 43,369 ---- } + /** + * 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; + + // + // Permissions + // + $view_level = intval( $_POST['auth_view'] ); + $post_level = intval( $_POST['auth_post'] ); + $rate_level = intval( $_POST['auth_rate'] ); + $comment_level = intval( $_POST['auth_comment'] ); + $edit_level = intval( $_POST['auth_edit'] ); + $delete_level = intval( $_POST['auth_delete'] ); + $approval_level = intval( $_POST['auth_approval'] ); + $approval_edit_level = intval( $_POST['auth_approval_edit'] ); + + 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 ' . LINK_CATEGORIES_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, auth_view, auth_post, auth_rate, auth_comment, auth_edit, auth_delete, auth_approval, auth_approval_edit) + 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, $view_level, $post_level, $rate_level, $comment_level, $edit_level, $delete_level, $approval_level, $approval_edit_level)"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t add a new category', '', __LINE__, __FILE__, $sql ); + } + } + else + { + $sql = 'UPDATE ' . LINK_CATEGORIES_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, auth_view = $view_level, auth_post = $post_level, auth_rate = $rate_level, auth_comment = $comment_level, auth_edit = $edit_level, auth_delete = $delete_level, auth_approval = $approval_level, auth_approval_edit = $approval_edit_level + 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 ' . LINK_CATEGORIES_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_links( $cat_id, 'category' ); + } + else + { + $this->move_links( $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_links( $from_cat, $to_cat ) + { + global $db; + + $sql = 'UPDATE ' . LINKS_TABLE . " + SET link_catid = $to_cat + WHERE link_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 ' . LINK_CATEGORIES_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_links( $sub_cat_id, 'category' ); + } + else + { + $this->move_links( $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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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(); + } } ?> \ No newline at end of file Index: functions_linkdb.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions_linkdb.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** functions_linkdb.php 8 Jul 2006 10:22:38 -0000 1.14 --- functions_linkdb.php 8 Jul 2006 16:26:04 -0000 1.15 *************** *** 1406,1808 **** * 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; - - // - // Permissions - // - $view_level = intval( $_POST['auth_view'] ); - $post_level = intval( $_POST['auth_post'] ); - $rate_level = intval( $_POST['auth_rate'] ); - $comment_level = intval( $_POST['auth_comment'] ); - $edit_level = intval( $_POST['auth_edit'] ); - $delete_level = intval( $_POST['auth_delete'] ); - $approval_level = intval( $_POST['auth_approval'] ); - $approval_edit_level = intval( $_POST['auth_approval_edit'] ); - - 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 ' . LINK_CATEGORIES_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, auth_view, auth_post, auth_rate, auth_comment, auth_edit, auth_delete, auth_approval, auth_approval_edit) - 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, $view_level, $post_level, $rate_level, $comment_level, $edit_level, $delete_level, $approval_level, $approval_edit_level)"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t add a new category', '', __LINE__, __FILE__, $sql ); - } - } - else - { - $sql = 'UPDATE ' . LINK_CATEGORIES_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, auth_view = $view_level, auth_post = $post_level, auth_rate = $rate_level, auth_comment = $comment_level, auth_edit = $edit_level, auth_delete = $delete_level, auth_approval = $approval_level, auth_approval_edit = $approval_edit_level - 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 ' . LINK_CATEGORIES_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_links( $cat_id, 'category' ); - } - else - { - $this->move_links( $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_links( $id, $mode = 'file' ) - { - global $db, $phpbb_root_path, $linkdb_functions; - - if ( $mode == 'category' ) - { - $file_ids = array(); - $files_data = array(); - $sql = 'SELECT link_id - FROM ' . LINKS_TABLE . " - WHERE link_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['link_id']; - $files_data[] = $row; - } - - $where_sql = "WHERE link_catid = $id"; - } - else - { - $sql = 'SELECT link_id - FROM ' . LINKS_TABLE . " - WHERE link_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 link_id = $id"; - } - - $sql = 'DELETE FROM ' . LINKS_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 ' . LINK_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 ); - } - - if ( $mode == 'file' ) - { - $this->modified( true ); - } - - return; - } - - /** - * Enter description here... - * - * @param unknown_type $from_cat - * @param unknown_type $to_cat - */ - function move_links( $from_cat, $to_cat ) - { - global $db; - - $sql = 'UPDATE ' . LINKS_TABLE . " - SET link_catid = $to_cat - WHERE link_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 ' . LINK_CATEGORIES_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_links( $sub_cat_id, 'category' ); - } - else - { - $this->move_links( $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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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 ' . LINK_CATEGORIES_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 --- 1406,1409 ---- *************** *** 2008,2011 **** --- 1609,1687 ---- * Enter description here... * + * @param unknown_type $id + * @param unknown_type $mode + */ + function delete_links( $id, $mode = 'file' ) + { + global $db, $phpbb_root_path, $linkdb_functions; + + if ( $mode == 'category' ) + { + $file_ids = array(); + $files_data = array(); + $sql = 'SELECT link_id + FROM ' . LINKS_TABLE . " + WHERE link_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['link_id']; + $files_data[] = $row; + } + + $where_sql = "WHERE link_catid = $id"; + } + else + { + $sql = 'SELECT link_id + FROM ' . LINKS_TABLE . " + WHERE link_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 link_id = $id"; + } + + $sql = 'DELETE FROM ' . LINKS_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 ' . LINK_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 ); + } + + if ( $mode == 'file' ) + { + $this->modified( true ); + } + + return; + } + + /** + * Enter description here... + * * @param unknown_type $mode * @param unknown_type $link_id |