|
From: Jon O. <jon...@us...> - 2006-07-04 18:00:42
|
Update of /cvsroot/mxbb/mx_linkdb/linkdb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23430/modules/mx_linkdb/linkdb/includes Modified Files: functions.php functions_linkdb.php Log Message: working... Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** functions.php 3 Jul 2006 20:11:30 -0000 1.9 --- functions.php 4 Jul 2006 18:00:33 -0000 1.10 *************** *** 18,22 **** function set_config( $config_name, $config_value ) { ! global $db, $linkdb_config; $sql = "UPDATE " . LINK_CONFIG_TABLE . " SET --- 18,22 ---- function set_config( $config_name, $config_value ) { ! global $linkdb_cache, $db, $linkdb_config; $sql = "UPDATE " . LINK_CONFIG_TABLE . " SET *************** *** 40,43 **** --- 40,45 ---- $linkdb_config[$config_name] = $config_value; + $linkdb_cache->destroy( 'config' ); + } *************** *** 1527,1531 **** $template->assign_vars( array( 'L_JUMP' => $lang['Jump'], ! 'JUMPMENU' => $linkdb->modules[$linkdb->module_name]->generate_jumpbox(), 'S_JUMPBOX_ACTION' => append_sid( linkdb_this_mxurl() ), 'MX_PAGE' => $page_id, --- 1529,1533 ---- $template->assign_vars( array( 'L_JUMP' => $lang['Jump'], ! 'JUMPMENU' => $linkdb->modules[$linkdb->module_name]->generate_jumpbox( 0, 0, array( $_GET['cat_id'] => 1 ) ), 'S_JUMPBOX_ACTION' => append_sid( linkdb_this_mxurl() ), 'MX_PAGE' => $page_id, Index: functions_linkdb.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions_linkdb.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** functions_linkdb.php 3 Jul 2006 20:11:30 -0000 1.11 --- functions_linkdb.php 4 Jul 2006 18:00:33 -0000 1.12 *************** *** 275,279 **** $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_links = '-1' cat_last_link_id = '0', cat_last_link_name = '', --- 275,279 ---- $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_links = '-1', cat_last_link_id = '0', cat_last_link_name = '', *************** *** 589,603 **** function new_file_in_cat( $cat_id ) { ! global $linkdb_config, $board_config, $db, $_COOKIE; $cat_array = explode(',', $this->gen_cat_ids( $cat_id )); $files_new = 0; - $time = time() - ( $linkdb_config['settings_newdays'] * 24 * 60 * 60 ); foreach ( $cat_array as $key => $cat_id ) { ! if ( $this->auth_user[$cat_id]['auth_view'] && $this->cat_rowset[$cat_id]['cat_last_link_time'] > $time) { $files_new++; --- 589,602 ---- function new_file_in_cat( $cat_id ) { ! global $linkdb_config, $board_config, $db; $cat_array = explode(',', $this->gen_cat_ids( $cat_id )); $files_new = 0; $time = time() - ( $linkdb_config['settings_newdays'] * 24 * 60 * 60 ); foreach ( $cat_array as $key => $cat_id ) { ! if ( $this->auth_user[$cat_id]['auth_read'] && $this->cat_rowset[$cat_id]['cat_last_link_time'] > $time) { $files_new++; *************** *** 616,632 **** function last_file_in_cat( $cat_id, &$file_info ) { ! if ( ( empty( $this->cat_rowset[$cat_id]['cat_last_file_id'] ) && empty( $this->cat_rowset[$cat_id]['cat_last_file_name'] ) && empty( $this->cat_rowset[$cat_id]['cat_last_file_time'] ) ) || $this->modified ) { global $db; ! $sql = 'SELECT file_time, file_id, file_name, file_catid FROM ' . LINKS_TABLE . " ! WHERE file_approved = '1' ! AND file_catid IN (" . $this->gen_cat_ids( $cat_id ) . ") ! ORDER BY file_time DESC"; if ( !( $result = $db->sql_query( $sql, 300 ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); } --- 615,631 ---- function last_file_in_cat( $cat_id, &$file_info ) { ! if ( ( empty( $this->cat_rowset[$cat_id]['cat_last_link_id'] ) && empty( $this->cat_rowset[$cat_id]['cat_last_link_name'] ) && empty( $this->cat_rowset[$cat_id]['cat_last_link_time'] ) ) || $this->modified ) { global $db; ! $sql = 'SELECT link_time, link_id, link_name, link_catid FROM ' . LINKS_TABLE . " ! WHERE link_approved = '1' ! AND link_catid IN (" . $this->gen_cat_ids( $cat_id ) . ") ! ORDER BY link_time DESC"; if ( !( $result = $db->sql_query( $sql, 300 ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query links info', '', __LINE__, __FILE__, $sql ); } *************** *** 640,651 **** { $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_last_file_id = " . intval( $file_info['file_id'] ) . ", ! cat_last_file_name = '" . addslashes( $file_info['file_name'] ) . "', ! cat_last_file_time = " . intval( $file_info['file_time'] ) . " WHERE cat_id = $cat_id"; if ( !( $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); } } --- 639,650 ---- { $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_last_link_id = " . intval( $file_info['link_id'] ) . ", ! cat_last_link_name = '" . addslashes( $file_info['link_name'] ) . "', ! cat_last_link_time = " . intval( $file_info['link_time'] ) . " WHERE cat_id = $cat_id"; if ( !( $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query links info', '', __LINE__, __FILE__, $sql ); } } *************** *** 653,659 **** else { ! $file_info['file_id'] = $this->cat_rowset[$cat_id]['cat_last_file_id']; ! $file_info['file_name'] = $this->cat_rowset[$cat_id]['cat_last_file_name']; ! $file_info['file_time'] = $this->cat_rowset[$cat_id]['cat_last_file_time']; } } --- 652,658 ---- else { ! $file_info['link_id'] = $this->cat_rowset[$cat_id]['cat_last_link_id']; ! $file_info['link_name'] = $this->cat_rowset[$cat_id]['cat_last_link_name']; ! $file_info['link_time'] = $this->cat_rowset[$cat_id]['cat_last_link_time']; } } *************** *** 691,695 **** { global $db, $template, $lang, $userdata, $phpEx, $images; ! global $linkdb_config, $board_config, $debug, $phpbb_root_path; if ( $this->cat_empty() ) --- 690,694 ---- { global $db, $template, $lang, $userdata, $phpEx, $images; ! global $linkdb_config, $board_config, $debug; if ( $this->cat_empty() ) *************** *** 712,750 **** // ! // output the root level category // if ( isset( $this->subcat_rowset[$cat_id] ) ) { ! // ! // Separate link categories into $catcol columns, script by CRLin ! // ! $catnum = count( $this->subcat_rowset[$cat_id] ); ! $catcol = $linkdb_config['cat_col']; ! $num = intval( $catnum / $catcol ); ! if ( $catnum % $catcol ) $num++; $template->assign_vars( array( 'LINK_WIDTH' => 100 / $catcol ) ); ! for( $i = 0;$i < $num; $i++ ) { ! $template->assign_block_vars( 'CAT_PARENT.catcol', array() ); ! if ( ( $catnum % $catcol ) && ( $i == $num-1 ) ) $catcol = $catnum % $catcol; ! for( $j = 0;$j < $catcol; $j++ ) { ! list( $subcat_id, $subcat_row ) = each ( $this->subcat_rowset[$cat_id] ); ! $sub_cat = $this->get_sub_cat( $subcat_id ); ! $template->assign_block_vars( 'CAT_PARENT.catcol.no_cat_parent', array( ! 'U_CAT' => append_sid( linkdb_this_mxurl( 'action=category&cat_id=' . $subcat_id ) ), ! 'SUB_CAT' => ( !empty( $sub_cat ) ) ? " $sub_cat" : "", ! 'CAT_IMAGE' => $images['linkdb_folder'], ! 'CAT_NAME' => $subcat_row['cat_name'], ! 'FILECAT' => $this->file_in_cat( $subcat_id ) ) ! ); } } } } function display_files( $sort_method, $sort_order, $start, $show_file_message, $cat_id = false ) { --- 711,782 ---- // ! // Output the categories // if ( isset( $this->subcat_rowset[$cat_id] ) ) { ! $catnum = count($this->subcat_rowset[$cat_id]); ! $catcol = $linkdb_config['cat_col'] > 0 ? $linkdb_config['cat_col'] : 1; ! $num_of_rows = intval( $catnum / $catcol ); ! ! if ( $catnum % $catcol ) ! { ! $num_of_rows++; ! } $template->assign_vars( array( 'LINK_WIDTH' => 100 / $catcol ) ); ! $i = 0; ! foreach( $this->subcat_rowset[$cat_id] as $subcat_id => $subcat_row ) { ! if ( $i == 0 || $i == $catcol) { ! $template->assign_block_vars( 'CAT_PARENT.catcol', array() ); ! $i = 0; ! } ! $i++; ! $last_file_info = array(); ! $this->last_file_in_cat( $subcat_id, $last_file_info ); ! ! if ( !empty( $last_file_info['file_id'] ) && $this->auth[$subcat_id]['auth_read'] ) ! { ! $last_file_time = create_date( $board_config['default_dateformat'], $last_file_info['file_time'], $board_config['board_timezone'] ); ! $last_file = $last_file_time . '<br />'; ! $last_file_name = ( strlen( stripslashes( $last_file_info['file_name'] ) ) > 20 ) ? substr( stripslashes( $last_file_info['file_name'] ), 0, 20 ) . '...' : stripslashes( $last_file_info['file_name'] ); ! $last_file .= '<a href="' . append_sid( linkdb_this_mxurl( 'action=file&file_id=' . $last_file_info['file_id'] ) ) . '" alt="' . stripslashes( $last_file_info['file_name'] ) . '" title="' . stripslashes( $last_file_info['file_name'] ) . '">' . $last_file_name . '</a> '; ! $last_file .= '<a href="' . append_sid( linkdb_this_mxurl( 'action=file&file_id=' . $last_file_info['file_id'] ) ) . '"><img src="' . $images['pa_icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_file'] . '" title="' . $lang['View_latest_file'] . '" /></a>'; ! } ! else ! { ! $last_file = $lang['No_file']; ! } ! ! $is_new = false; ! if ( $this->new_file_in_cat( $subcat_id ) ) ! { ! $is_new = true; } + + $sub_cat = $this->get_sub_cat( $subcat_id ); + $template->assign_block_vars( 'CAT_PARENT.catcol.no_cat_parent', array( + 'U_CAT' => append_sid( linkdb_this_mxurl( 'action=category&cat_id=' . $subcat_id ) ), + 'SUB_CAT' => ( !empty( $sub_cat ) ) ? " $sub_cat" : "", + 'CAT_IMAGE' => ( $is_new ) ? $images['linkdb_folder_new'] : $images['linkdb_folder'], + 'CAT_NAME' => $subcat_row['cat_name'], + 'FILECAT' => $this->file_in_cat( $subcat_id ) ) + ); } } } + /** + * Enter description here... + * + * @param unknown_type $sort_method + * @param unknown_type $sort_order + * @param unknown_type $start + * @param unknown_type $show_file_message + * @param unknown_type $cat_id + */ function display_files( $sort_method, $sort_order, $start, $show_file_message, $cat_id = false ) { *************** *** 752,755 **** --- 784,789 ---- global $images, $lang, $phpEx, $linkdb_functions, $phpbb_root_path; + $filelist = false; + if ( empty( $cat_id ) ) { *************** *** 796,800 **** while ( $row = $db->sql_fetchrow( $result ) ) { ! $file_rowset[] = $row; } --- 830,837 ---- while ( $row = $db->sql_fetchrow( $result ) ) { ! if ( $this->auth_user[$row['link_catid']]['auth_view'] ) ! { ! $file_rowset[] = $row; ! } } *************** *** 802,806 **** $where_sql = ( !empty( $cat_id ) ) ? "AND link_catid = $cat_id" : ''; ! $sql = "SELECT COUNT(link_id) as total_file FROM " . LINKS_TABLE . " WHERE link_approved='1' --- 839,843 ---- $where_sql = ( !empty( $cat_id ) ) ? "AND link_catid = $cat_id" : ''; ! $sql = "SELECT COUNT(link_id) as total_links FROM " . LINKS_TABLE . " WHERE link_approved='1' *************** *** 815,825 **** $db->sql_freeresult( $result ); ! $total_file = $row['total_file']; unset( $row ); ! if ( count( $file_rowset ) ) { $template->assign_block_vars( 'FILELIST', array() ); $action = ( empty( $cat_id ) ) ? 'viewall' : 'category&cat_id=' . $cat_id; $template->assign_vars( array( --- 852,937 ---- $db->sql_freeresult( $result ); ! $total_file = $row['total_links']; unset( $row ); ! if (count( $file_rowset ) > 0) { $template->assign_block_vars( 'FILELIST', array() ); + if ( !$linkdb_config['split_links'] ) + { + $template->assign_block_vars( "FILELIST.no_split_links", array() ); + } + $filelist = true; + } + + for ( $i = 0; $i < count( $file_rowset ); $i++ ) + { + // + // Format the date for the given file + // + $date = create_date( $board_config['default_dateformat'], $file_rowset[$i]['link_time'], $board_config['board_timezone'] ); + //$date_updated = create_date( $board_config['default_dateformat'], $file_rowset[$i]['link_update_time'], $board_config['board_timezone'] ); + // =================================================== + // Get rating for the file and format it + // =================================================== + $file_rating = ( $file_rowset[$i]['rating'] != 0 ) ? round( $file_rowset[$i]['rating'], 2 ) . '/10' : $lang['Not_rated']; + // + // If the file is new then put a new image in front of it + // + $is_new = FALSE; + if (time() - ($linkdb_config['settings_newdays'] * 24 * 60 * 60) < $file_rowset[$i]['link_time']) + { + $is_new = TRUE; + } + + $cat_name = ( empty( $cat_id ) ) ? $this->cat_rowset[$file_rowset[$i]['link_catid']]['cat_name'] : ''; + $cat_url = append_sid( linkdb_this_mxurl( 'action=category&cat_id=' . $file_rowset[$i]['link_catid'] ) ); + + // + // Poster + // + $file_poster = ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid( $phpbb_root_path . 'profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $file_rowset[$i]['user_id'] ) . '" target=_blank>' : ''; + $file_poster .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? $file_rowset[$i]['username'] : $file_rowset[$i]['post_username'] . '(' . $lang['Guest'] . ')'; + $file_poster .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; + + // + // Assign Vars + // + $template->assign_block_vars( "FILELIST.file_rows", array( + 'L_NEW_FILE' => $lang['New_file'], + 'PIN_IMAGE' => $this->display_banner( $file_rowset[$i], $row ), + 'FILE_NAME' => $file_rowset[$i]['link_name'], + 'FILE_DESC' => $file_rowset[$i]['link_longdesc'], + 'DATE' => $date, + 'FILE_DLS' => $file_rowset[$i]['link_hits'], + 'FILE_VOTES' => $file_rowset[$i]['total_votes'], + 'L_RATING' => '<a href="' . append_sid( linkdb_this_mxurl( 'action=rate&link_id=' . $file_rowset[$i]['link_id'] ) ) . '">' . $lang['LinkRating'] . '</a>', + 'RATING' => $file_rating, + + 'CAT_NAME' => $cat_name, + 'IS_NEW_FILE' => $is_new, + + 'U_CAT' => $cat_url, + 'U_FILE' => append_sid( linkdb_this_mxurl( 'action=link&link_id=' . $file_rowset[$i]['link_id'] ) ), + + 'POSTER' => $file_poster, + 'FILE_NEW_IMAGE' => $images['linkdb_link_new'], + 'COLOR' => ( $linkdb_config['split_links'] ) ? "row1" : ( ( $i % 2 ) ? "row2" : "row1" ), + )); + + if ( $this->ratings[$file_rowset[$i]['link_catid']]['activated'] ) + { + $template->assign_block_vars( "FILELIST.file_rows.LINK_VOTE", array() ); + } + + if ( $linkdb_config['split_links'] ) + { + $template->assign_block_vars( "FILELIST.file_rows.split_links", array() ); + } + } + + if ( $filelist ) + { $action = ( empty( $cat_id ) ) ? 'viewall' : 'category&cat_id=' . $cat_id; $template->assign_vars( array( *************** *** 854,919 **** 'S_ACTION_SORT' => append_sid( linkdb_this_mxurl( "action=$action" ) ) ) ); - - if ( !$linkdb_config['split_links'] ) - { - $template->assign_block_vars( "FILELIST.no_split_links", array() ); - } - for ( $i = 0; $i < count( $file_rowset ); $i++ ) - { - // - // Format the date for the given file - // - $date = create_date( $board_config['default_dateformat'], $file_rowset[$i]['link_time'], $board_config['board_timezone'] ); - - // - // If the file is new then put a new image in front of it - // - /*$is_new = FALSE; - if (time() - ($linkdb_config['settings_newdays'] * 24 * 60 * 60) < $file_rowset[$i]['link_time']) - { - $is_new = TRUE; - }*/ - - $cat_name = ( empty( $cat_id ) ) ? $this->cat_rowset[$file_rowset[$i]['link_catid']]['cat_name'] : ''; - $cat_url = append_sid( linkdb_this_mxurl( 'action=category&cat_id=' . $file_rowset[$i]['link_catid'] ) ); - - $file_poster = ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid( $phpbb_root_path . 'profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $file_rowset[$i]['user_id'] ) . '" target=_blank>' : ''; - $file_poster .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? $file_rowset[$i]['username'] : $file_rowset[$i]['post_username'] . '(' . $lang['Guest'] . ')'; - $file_poster .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; - $file_rating = ( $file_rowset[$i]['rating'] != 0 ) ? round( $file_rowset[$i]['rating'], 2 ) . '/10' : $lang['Not_rated']; - - // Assign Vars - - $template->assign_block_vars( "FILELIST.file_rows", array( - 'COLOR' => ( $linkdb_config['split_links'] ) ? "row1" : ( ( $i % 2 ) ? "row2" : "row1" ), - 'L_NEW_FILE' => $lang['New_file'], - - 'PIN_IMAGE' => $this->display_banner( $file_rowset[$i], $row ), - 'FILE_NEW_IMAGE' => $images['linkdb_link_new'], - 'FILE_NAME' => $file_rowset[$i]['link_name'], - 'FILE_DESC' => $file_rowset[$i]['link_longdesc'], - 'DATE' => $date, - 'POSTER' => $file_poster, - 'FILE_DLS' => $file_rowset[$i]['link_hits'], - 'FILE_VOTES' => $file_rowset[$i]['total_votes'], - 'L_RATING' => '<a href="' . append_sid( linkdb_this_mxurl( 'action=rate&link_id=' . $file_rowset[$i]['link_id'] ) ) . '">' . $lang['LinkRating'] . '</a>', - 'RATING' => $file_rating, - - 'CAT_NAME' => $cat_name, - 'IS_NEW_FILE' => $is_new, - - 'U_CAT' => $cat_url, - 'U_FILE' => append_sid( linkdb_this_mxurl( 'action=link&link_id=' . $file_rowset[$i]['link_id'] ) ) ) - ); - - if ( UPDATEUPDATE ) - { - $template->assign_block_vars( "FILELIST.file_rows.LINK_VOTE", array() ); - } - if ( $linkdb_config['split_links'] ) - { - $template->assign_block_vars( "FILELIST.file_rows.split_links", array() ); - } - } } else --- 966,969 ---- *************** *** 928,931 **** --- 978,988 ---- } + /** + * Enter description here... + * + * @param unknown_type $link_rowset + * @param unknown_type $row + * @return unknown + */ function display_banner( $link_rowset, $row ) { *************** *** 954,959 **** } ! // Admin and mod functions ! function update_add_cat( $cat_id = false ) { --- 1011,1020 ---- } ! /** ! * Enter description here... ! * ! * @param unknown_type $cat_id ! * @return unknown ! */ function update_add_cat( $cat_id = false ) { *************** *** 1063,1066 **** --- 1124,1132 ---- } + /** + * Enter description here... + * + * @param unknown_type $cat_id + */ function delete_cat( $cat_id = false ) { *************** *** 1124,1127 **** --- 1190,1199 ---- } + /** + * Enter description here... + * + * @param unknown_type $id + * @param unknown_type $mode + */ function delete_links( $id, $mode = 'file' ) { *************** *** 1193,1196 **** --- 1265,1274 ---- } + /** + * Enter description here... + * + * @param unknown_type $from_cat + * @param unknown_type $to_cat + */ function move_links( $from_cat, $to_cat ) { *************** *** 1209,1217 **** } function delete_subcat( $cat_id, $file_mode = 'delete', $to_cat = false ) { global $db; ! if ( empty( $this->subcat_rowset[$cat_id] ) ) return; foreach( $this->subcat_rowset[$cat_id] as $sub_cat_id => $subcat_data ) { --- 1287,1306 ---- } + /** + * 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 ) { *************** *** 1239,1242 **** --- 1328,1337 ---- } + /** + * Enter description here... + * + * @param unknown_type $from_cat + * @param unknown_type $to_cat + */ function move_subcat( $from_cat, $to_cat ) { *************** *** 1255,1258 **** --- 1350,1358 ---- } + /** + * Enter description here... + * + * @param unknown_type $cat_parent + */ function reorder_cat( $cat_parent ) { *************** *** 1285,1288 **** --- 1385,1393 ---- } + /** + * Enter description here... + * + * @param unknown_type $cat_id + */ function order_cat( $cat_id ) { *************** *** 1305,1332 **** } function update_add_link( $file_id = false ) { ! global $db, $phpbb_root_path, $db, $_POST, $userdata, $linkdb_config, $_FILES, $_REQUEST, $linkdb_functions, $user_ip; $link_poster = ( !empty( $_POST['post_username'] ) ) ? $_POST['post_username'] : ''; $file_remote_url = ( !empty( $_POST['download_url'] ) ) ? $_POST['download_url'] : ''; $link_logo_src = ( !empty( $_POST['link_logo_src'] ) ) ? $_POST['link_logo_src'] : ''; - if ( substr( $link_logo_src, -17 ) == 'weblink_88x31.png' ) $link_logo_src = ''; - $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; - $file_name = ( isset( $_POST['name'] ) ) ? htmlspecialchars( $_POST['name'] ) : ''; - - $file_long_desc = ( isset( $_POST['long_desc'] ) ) ? $_POST['long_desc'] : ''; ! if ( UPDATEUPDATE ) ! { ! $file_approved = ( isset( $_POST['approved'] ) ) ? intval( $_POST['approved'] ) : 0; ! } ! else { ! $file_approved = 1; } ! $file_dls = ( isset( $_POST['file_download'] ) ) ? intval( $_POST['file_download'] ) : 0; $file_time = time(); --- 1410,1437 ---- } + /** + * Enter description here... + * + * @param unknown_type $file_id + * @return unknown + */ function update_add_link( $file_id = false ) { ! global $db, $phpbb_root_path, $db, $userdata, $linkdb_config, $_FILES, $linkdb_functions, $user_ip; $link_poster = ( !empty( $_POST['post_username'] ) ) ? $_POST['post_username'] : ''; $file_remote_url = ( !empty( $_POST['download_url'] ) ) ? $_POST['download_url'] : ''; $link_logo_src = ( !empty( $_POST['link_logo_src'] ) ) ? $_POST['link_logo_src'] : ''; ! if ( substr( $link_logo_src, -17 ) == 'weblink_88x31.png' ) { ! $link_logo_src = ''; } ! $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; ! $file_name = ( isset( $_POST['name'] ) ) ? htmlspecialchars( $_POST['name'] ) : ''; ! $file_long_desc = ( isset( $_POST['long_desc'] ) ) ? $_POST['long_desc'] : ''; + $file_dls = ( isset( $_POST['file_download'] ) ) ? intval( $_POST['file_download'] ) : 0; $file_time = time(); *************** *** 1351,1354 **** --- 1456,1491 ---- } + if ( $file_id ) + { + $sql = 'SELECT * + FROM ' . LINKS_TABLE . " + WHERE link_id = '$file_id'"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt query Download URL', '', __LINE__, __FILE__, $sql ); + } + + $file_data = $db->sql_fetchrow( $result ); + + $db->sql_freeresult( $result ); + } + + if ( $linkdb->modules[$linkdb->module_name]->auth_user[$cat_id]['auth_approval'] || ( $linkdb->modules[$linkdb->module_name]->auth_user[$cat_id]['auth_mod'] && $userdata['session_logged_in'] ) ) + { + if ( !$file_id ) + { + $file_approved = 1; + } + else + { + $file_approved = isset( $file_data['file_approved'] ) && !( $linkdb->modules[$linkdb->module_name]->auth_user[$cat_id]['auth_mod'] && $userdata['session_logged_in'] ) ? $file_data['file_approved'] : 1; + } + } + else + { + $file_approved = 0; + } + if ( !$file_id ) { *************** *** 1386,1389 **** --- 1523,1622 ---- } + /** + * Enter description here... + * + * @param unknown_type $file_id + * @param unknown_type $cat_id + * @param unknown_type $mode_notification + */ + function update_add_link_notify( $file_id = false, $mode_notification = 'edit' ) + { + global $db; + + if ( in_array( $mode_notification, array( 'add', 'edit', 'do_approve', 'do_unapprove', 'delete' ) ) ) + { + if (!$file_id) + { + die('bad update_add_file_notify arg'); + } + + if (is_array( $file_id ) && !empty( $file_id )) + { + $fileIdsArray = $file_id; + } + else + { + $fileIdsArray[] = $file_id; + } + + foreach($fileIdsArray as $fileId) + { + $sql = "SELECT link_catid + FROM " . LINKS_TABLE . " + WHERE link_id = '" . $fileId . "'"; + + if ( !$result = $db->sql_query( $sql ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t get link info', '', __LINE__, __FILE__, $sql ); + } + + $row = $db->sql_fetchrow( $result ); + $catId = $row['link_catid']; + + // + // Notification + // + if ( $this->notification[$catId]['activated'] > 0 ) // -1, 0, 1, 2 + { + // + // Instatiate notification + // + $mx_link_notification = new mx_link_notification(); + $mx_link_notification->init( $fileId ); + + // + // Now send notification + // + $mx_notification_mode = $this->notification[$catId]['activated'] == 1 ? MX_PM_MODE : MX_MAIL_MODE; + + switch ( $mode_notification ) + { + case 'add': + $mx_notification_action = MX_NEW_NOTIFICATION; + break; + case 'edit': + $mx_notification_action = MX_EDITED_NOTIFICATION; + break; + case 'do_approve': + $mx_notification_action = MX_APPROVED_NOTIFICATION; + break; + case 'do_unapprove': + $mx_notification_action = MX_UNAPPROVED_NOTIFICATION; + break; + case 'delete': + $mx_notification_action = MX_DELETED_NOTIFICATION; + break; + } + + $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + $html_entities_replace = array('&', '<', '>', '"'); + + $mx_link_notification->notify( $mx_notification_mode, $mx_notification_action ); + + if ( $this->notification[$cat_id]['notify_group'] > 0 ) + { + $mx_link_notification->notify( $mx_notification_mode, $mx_notification_action, - intval($this->notification[$catId]['notify_group']) ); + } + } + } + } + } + + /** + * Enter description here... + * + * @param unknown_type $mode + * @param unknown_type $link_id + */ function link_approve( $mode = 'do_approve', $link_id ) { *************** *** 1556,1560 **** global $lang; ! $this->auth_can_list = '<br />' . ( ( $this->auth[$cat_id]['auth_upload'] ) ? $lang['PA_Rules_upload_can'] : $lang['PA_Rules_upload_cannot'] ) . '<br />'; $this->auth_can_list .= ( ( $this->auth_user[$cat_id]['auth_view_file'] ) ? $lang['PA_Rules_view_file_can'] : $lang['PA_Rules_view_file_cannot'] ) . '<br />'; $this->auth_can_list .= ( ( $this->auth_user[$cat_id]['auth_edit_file'] ) ? $lang['PA_Rules_edit_file_can'] : $lang['PA_Rules_edit_file_cannot'] ) . '<br />'; --- 1789,1793 ---- global $lang; ! $this->auth_can_list = '<br />' . ( ( $this->auth_user[$cat_id]['auth_upload'] ) ? $lang['PA_Rules_upload_can'] : $lang['PA_Rules_upload_cannot'] ) . '<br />'; $this->auth_can_list .= ( ( $this->auth_user[$cat_id]['auth_view_file'] ) ? $lang['PA_Rules_view_file_can'] : $lang['PA_Rules_view_file_cannot'] ) . '<br />'; $this->auth_can_list .= ( ( $this->auth_user[$cat_id]['auth_edit_file'] ) ? $lang['PA_Rules_edit_file_can'] : $lang['PA_Rules_edit_file_cannot'] ) . '<br />'; |