|
From: Jon O. <jon...@us...> - 2006-06-17 20:11:27
|
Update of /cvsroot/mxbb/mx_kb/kb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21631/modules/mx_kb/kb/includes Modified Files: functions.php functions_admin.php functions_comment.php functions_kb.php Log Message: Finalizing this module Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions.php 7 Jun 2006 20:28:54 -0000 1.5 --- functions.php 17 Jun 2006 20:11:23 -0000 1.6 *************** *** 784,787 **** --- 784,793 ---- define('MX_DELETED_NOTIFICATION' , 14); + // + // Includes + // + include_once( $phpbb_root_path . 'includes/bbcode.'.$phpEx); + include_once( $phpbb_root_path . 'includes/functions_post.' . $phpEx ); + /** * mx_kb_notification. *************** *** 834,843 **** global $db, $lang, $mx_kb_custom_field, $module_root_path, $phpbb_root_path, $phpEx, $mx_kb, $userdata; - // - // Includes - // - include_once( $phpbb_root_path . 'includes/bbcode.'.$phpEx); - include_once( $phpbb_root_path . 'includes/functions_post.' . $phpEx ); - $mx_kb->debug('notification->init (id='.$item_id.')', basename( __FILE__ )); --- 840,843 ---- *************** *** 1008,1095 **** $this->smilies_on = $smilies_on; ! // ! // Compose Subject ! // ! if (empty($subject)) ! { ! // ! // Auto generated subject ! // ! switch ( $action ) ! { ! case MX_NEW_NOTIFICATION: ! $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_new']; ! break; ! ! case MX_EDITED_NOTIFICATION: ! $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_edited']; ! break; ! ! case MX_APPROVED_NOTIFICATION: ! $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_approved']; ! break; ! ! case MX_UNAPPROVED_NOTIFICATION: ! $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_unapproved']; ! break; ! ! case MX_DELETED_NOTIFICATION: ! $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_deleted']; ! break; ! ! default: ! mx_message_die(GENERAL_ERROR, 'Bad notify action'); ! } ! } ! else ! { ! // ! // Custom subject ! // ! $this->subject = $subject; ! } // ! // Compose Message // ! if (empty($message)) { - // - // Auto generated message - // $this->_compose_auto_note($action); - - switch ( $action ) - { - case MX_NEW_NOTIFICATION: - $this->message = $this->langs['notify_new_body'] . '\n\n' . $this->auto_message; - break; - - case MX_EDITED_NOTIFICATION: - $this->message = $this->langs['notify_edited_body'] . '\n\n' . $this->auto_message_update . '\n' . $this->auto_message; - break; - - case MX_APPROVED_NOTIFICATION: - $this->message = $this->langs['notify_approved_body'] . '\n\n' . $this->auto_message; - break; - - case MX_UNAPPROVED_NOTIFICATION: - $this->message = $this->langs['notify_unapproved_body'] . '\n\n' . $this->auto_message; - break; - - case MX_DELETED_NOTIFICATION: - $this->message = $this->langs['notify_deleted_body'] . '\n\n' . $this->auto_message; - break; - - default: - mx_message_die(GENERAL_ERROR, 'Bad notify action'); - } - } - else - { - // - // Custom message - // - $this->message = $message; } --- 1008,1020 ---- $this->smilies_on = $smilies_on; ! $this->subject = $subject; ! $this->message = $message; // ! // Compose Subject // ! if (empty($this->subject) || empty($this->message)) { $this->_compose_auto_note($action); } *************** *** 1174,1178 **** } ! $privmsg_message = prepare_message($this->message, $this->html_on, $this->bbcode_on, $this->smilies_on, $bbcode_uid); $privmsg_message = str_replace('\\\n', '\n', $privmsg_message); } --- 1099,1103 ---- } ! $privmsg_message = prepare_message(addslashes($this->message), $this->html_on, $this->bbcode_on, $this->smilies_on, $bbcode_uid); $privmsg_message = str_replace('\\\n', '\n', $privmsg_message); } *************** *** 1406,1421 **** $mx_kb->debug('notification->_compose_auto_note', basename( __FILE__ )); - $search = array ( "'&(quot|#34);'i", // Replace HTML entities - "'&(amp|#38);'i", - "'&(lt|#60);'i", - "'&(gt|#62);'i" - ); - - $replace = array ( "\"", - "&", - "<", - ">" - ); - // // Compose phpBB post header --- 1331,1334 ---- *************** *** 1423,1429 **** $temp_url = PORTAL_URL . this_kb_mxurl("mode=" . "article&k=" . $this->data['item_id'], false, true); ! $this->auto_message = "[b]" . $this->langs['item_title'] . ":[/b] " . preg_replace( $search, $replace, $this->data['item_title'] ) . "\n"; $this->auto_message .= "[b]" . $this->langs['author'] . ":[/b] " . $this->data['item_author'] . "\n"; ! $this->auto_message .= "[b]" . $this->langs['item_description'] . ":[/b] [i]" . preg_replace( $search, $replace, $this->data['item_desc'] ) . "[/i]\n\n"; //$this->auto_message .= "[b]" . $this->langs['category'] . ":[/b] " . $this->data['item_category_name'] . "\n"; --- 1336,1342 ---- $temp_url = PORTAL_URL . this_kb_mxurl("mode=" . "article&k=" . $this->data['item_id'], false, true); ! $this->auto_message = "[b]" . $this->langs['item_title'] . ":[/b] " . $this->data['item_title'] . "\n"; $this->auto_message .= "[b]" . $this->langs['author'] . ":[/b] " . $this->data['item_author'] . "\n"; ! $this->auto_message .= "[b]" . $this->langs['item_description'] . ":[/b] [i]" . $this->data['item_desc'] . "[/i]\n\n"; //$this->auto_message .= "[b]" . $this->langs['category'] . ":[/b] " . $this->data['item_category_name'] . "\n"; *************** *** 1441,1444 **** --- 1354,1391 ---- // $this->auto_message_update = "[i]" . $this->langs['edited_item_info'] . $this->data['item_editor'] . "[/i]" . "\n\n"; + + // + // Auto generated subject and message + // + switch ( $action ) + { + case MX_NEW_NOTIFICATION: + $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_new']; + $this->message = $this->langs['notify_new_body'] . "\n\n" . $this->auto_message; + break; + + case MX_EDITED_NOTIFICATION: + $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_edited']; + $this->message = $this->langs['notify_edited_body'] . "\n\n" . $this->auto_message_update . $this->auto_message; + break; + + case MX_APPROVED_NOTIFICATION: + $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_approved']; + $this->message = $this->langs['notify_approved_body'] . "\n\n". $this->auto_message; + break; + + case MX_UNAPPROVED_NOTIFICATION: + $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_unapproved']; + $this->message = $this->langs['notify_unapproved_body'] . "\n\n" . $this->auto_message; + break; + + case MX_DELETED_NOTIFICATION: + $this->subject = $this->langs['module_title'] . ' - ' . $this->langs['notify_subject_deleted']; + $this->message = $this->langs['notify_deleted_body'] . "\n\n" . $this->auto_message; + break; + + default: + mx_message_die(GENERAL_ERROR, 'Bad notify action'); + } } *************** *** 1661,1663 **** --- 1608,1684 ---- $mx_kb_cache->unload(); } + + /** + * url rewrites. + * + * @param unknown_type $args + * @param unknown_type $force_standalone_mode + * @param unknown_type $non_html_amp + * @return unknown + */ + function this_kb_mxurl( $args = '', $force_standalone_mode = false, $non_html_amp = false ) + { + global $mx_root_path, $module_root_path, $page_id, $phpEx, $is_block; + + if ( !MXBB_MODULE ) + { + $mxurl = $module_root_path . 'kb.' . $phpEx . ( $args == '' ? '' : '?' . $args ); + return $mxurl; + } + + if ( $force_standalone_mode || !$is_block ) + { + $mxurl = $mx_root_path . 'modules/mx_kb/kb.' . $phpEx . ( $args == '' ? '' : '?' . $args ); + } + else + { + $mxurl = $mx_root_path . 'index.' . $phpEx; + if ( is_numeric( $page_id ) ) + { + $mxurl .= '?page=' . $page_id . ( $args == '' ? '' : ( $non_html_amp ? '&' : '&' ) . $args ); + } + else + { + $mxurl .= ( $args == '' ? '' : '?' . $args ); + } + } + return $mxurl; + } + + /** + * Enter description here... + * + * @param unknown_type $args + * @param unknown_type $force_standalone_mode + * @param unknown_type $non_html_amp + * @return unknown + */ + function this_kb_mxurl_search( $args = '', $force_standalone_mode = false, $non_html_amp = false ) + { + global $mx_root_path, $module_root_path, $page_id, $phpEx, $is_block; + + if ( !MXBB_MODULE ) + { + $mxurl = $module_root_path . 'kb_search.' . $phpEx . ( $args == '' ? '' : '?' . $args ); + return $mxurl; + } + + if ( $force_standalone_mode || !$is_block ) + { + $mxurl = $mx_root_path . 'modules/mx_kb/kb_search.' . $phpEx . ( $args == '' ? '' : '?' . $args ); + } + else + { + $mxurl = $mx_root_path . 'index.' . $phpEx; + if ( is_numeric( $page_id ) ) + { + $mxurl .= '?page=' . $page_id . ( $args == '' ? '' : ( $non_html_amp ? '&' : '&' ) . $args ); + } + else + { + $mxurl .= ( $args == '' ? '' : '?' . $args ); + } + } + return $mxurl; + } ?> \ No newline at end of file Index: functions_admin.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_admin.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions_admin.php 7 Jun 2006 20:28:54 -0000 1.5 --- functions_admin.php 17 Jun 2006 20:11:23 -0000 1.6 *************** *** 74,82 **** * * @param unknown_type $sel_id * @return unknown */ ! function get_forums( $sel_id = 0 ) { ! global $db; $sql = "SELECT forum_id, forum_name --- 74,84 ---- * * @param unknown_type $sel_id + * @param unknown_type $use_default_option + * @param unknown_type $select_name * @return unknown */ ! function get_forums( $sel_id = 0, $use_default_option = false, $select_name = 'forum_id' ) { ! global $db, $lang; $sql = "SELECT forum_id, forum_name *************** *** 88,96 **** } ! $forumlist = '<select name="forum_id">'; if ( $sel_id == 0 ) { ! $forumlist .= '<option value="0" selected > Select a Forum !</option>'; } --- 90,104 ---- } ! $forumlist = '<select name="'.$select_name.'">'; if ( $sel_id == 0 ) { ! $forumlist .= '<option value="0" selected >'.$lang['Select_topic_id'].'</option>'; ! } ! ! if ( $use_default_option ) ! { ! $status = $sel_id == "-1" ? "selected" : ""; ! $forumlist .= '<option value="-1" '.$status.' >::'.$lang['Use_default'].'::</option>'; } *************** *** 112,114 **** --- 120,159 ---- return $forumlist; } + + /** + * Enter description here... + * + * @param unknown_type $id + * @param unknown_type $select + * @return unknown + */ + function get_list_kb( $id, $select ) + { + global $db; + + $idfield = 'id'; + $namefield = 'type'; + + $sql = "SELECT * + FROM " . KB_TYPES_TABLE; + + if ( $select == 0 ) + { + $sql .= " WHERE $idfield <> $id"; + } + + if ( !$result = $db->sql_query( $sql ) ) + { + mx_message_die( GENERAL_ERROR, "Couldn't get list of types", "", __LINE__, __FILE__, $sql ); + } + + $typelist = ""; + + while ( $row = $db->sql_fetchrow( $result ) ) + { + $typelist .= "<option value=\"$row[$idfield]\"$s>" . $row[$namefield] . "</option>\n"; + } + + return( $typelist ); + } ?> \ No newline at end of file Index: functions_comment.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_comment.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions_comment.php 7 Jun 2006 20:28:54 -0000 1.5 --- functions_comment.php 17 Jun 2006 20:11:23 -0000 1.6 *************** *** 92,96 **** // This is specific for pafileDB // ! $this->forum_id = $mx_kb->modules[$mx_kb->module_name]->cat_rowset[$this->cat_id]['comments_forum_id']; $this->auth['auth_view'] = $mx_kb->modules[$mx_kb->module_name]->auth_user[$this->cat_id]['auth_comment']; --- 92,96 ---- // This is specific for pafileDB // ! $this->forum_id = $mx_kb->modules[$mx_kb->module_name]->comments[$this->cat_id]['comments_forum_id']; $this->auth['auth_view'] = $mx_kb->modules[$mx_kb->module_name]->auth_user[$this->cat_id]['auth_comment']; *************** *** 186,190 **** // Get all comments // ! $this->get_internal_comments(); $ranksrow = array(); --- 186,190 ---- // Get all comments // ! $result = $this->get_internal_comments(); $ranksrow = array(); *************** *** 424,428 **** // Get all comments // ! $this->get_phpbb_comments(); $ranksrow = array(); --- 424,428 ---- // Get all comments // ! $result = $this->get_phpbb_comments(); $ranksrow = array(); *************** *** 731,734 **** --- 731,736 ---- )); } + + return $result; } *************** *** 778,781 **** --- 780,785 ---- )); } + + return $result; } *************** *** 1323,1327 **** --- 1327,1355 ---- mx_message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); } + } + /** + * Enter description here... + * + * @param unknown_type $topic_id + */ + function delete_phpbb_topic($topic_id) + { + global $board_config, $lang, $db, $phpbb_root_path, $phpEx; + global $userdata, $user_ip; + + $sql = "SELECT * + FROM " . POSTS_TABLE . " + WHERE topic_id = '$topic_id'"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, "Could not obtain topic data", '', __LINE__, __FILE__, $sql ); + } + + while( $row = $db->sql_fetchrow( $result ) ) + { + $this->delete_phpbb_post($row['forum_id'], $row['topic_id'], $row['post_id']); + } } *************** *** 1386,1389 **** --- 1414,1422 ---- switch ($mode) { + case 'delete_all': + $return_data = $this->delete_phpbb_topic($this->topic_id ); + $this->validate_topic_id(); + break; + case 'delete': $return_data = $this->delete_phpbb_post($this->forum_id, $this->topic_id, $cid ); Index: functions_kb.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_kb.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions_kb.php 7 Jun 2006 20:28:54 -0000 1.5 --- functions_kb.php 17 Jun 2006 20:11:23 -0000 1.6 *************** *** 137,145 **** $this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] = $cat_rowset[$i]['internal_comments'] == -1 ? ($kb_config['internal_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['internal_comments'] == 1 ? true : false ); // phpBB or internal comments $this->comments[$cat_rowset[$i]['category_id']]['autogenerate_comments'] = $cat_rowset[$i]['autogenerate_comments'] == -1 ? ($kb_config['autogenerate_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['autogenerate_comments'] == 1 ? true : false ); // autocreate comments when updated ! $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id'] = $cat_rowset[$i]['comments_forum_id'] == -1 ? ($kb_config['comments_forum_id'] == 1 ? true : false ) : ( $cat_rowset[$i]['comments_forum_id'] == 1 ? true : false ); // phpBB target forum (only used for phpBB comments) if (!$this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] && intval($this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']) < 1) { ! //mx_message_die(GENERAL_ERROR, 'Init Failure, phpBB comments with no target forum_id :('); } --- 137,145 ---- $this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] = $cat_rowset[$i]['internal_comments'] == -1 ? ($kb_config['internal_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['internal_comments'] == 1 ? true : false ); // phpBB or internal comments $this->comments[$cat_rowset[$i]['category_id']]['autogenerate_comments'] = $cat_rowset[$i]['autogenerate_comments'] == -1 ? ($kb_config['autogenerate_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['autogenerate_comments'] == 1 ? true : false ); // autocreate comments when updated ! $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id'] = $cat_rowset[$i]['comments_forum_id'] < 1 ? ( intval($kb_config['comments_forum_id']) ) : ( intval($cat_rowset[$i]['comments_forum_id']) ); // phpBB target forum (only used for phpBB comments) if (!$this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] && intval($this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']) < 1) { ! mx_message_die(GENERAL_ERROR, 'Init Failure, phpBB comments with no target forum_id :(<br> Category: ' . $cat_rowset[$i]['category_name'] . ' Forum_id: ' . $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']); } *************** *** 1295,1319 **** * * @param unknown_type $article_id ! * @return unknown */ ! function get_cat_id($article_id) { global $db; ! $this->debug('mx_kb->get_cat_id', basename( __FILE__ )); ! $sql = "SELECT article_category_id ! FROM " . KB_ARTICLES_TABLE . " ! WHERE article_id = $article_id"; ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); ! } ! $kb_row = $db->sql_fetchrow( $result ); ! $category_id = $kb_row['article_category_id']; ! return $category_id; } --- 1295,1382 ---- * * @param unknown_type $article_id ! * @param unknown_type $cat_id ! * @param unknown_type $mode_notification */ ! function update_add_article_notify( $article_id = false, $mode_notification = 'edit' ) { global $db; ! if ( in_array( $mode_notification, array( 'add', 'edit', 'approve', 'unapprove', 'delete' ) ) ) ! { ! if (!$article_id) ! { ! die('bad update_add_article_notify arg'); ! } ! if (is_array( $article_id ) && !empty( $article_id )) ! { ! $articleIdsArray = $article_id; ! } ! else ! { ! $articleIdsArray[] = $article_id; ! } ! foreach($articleIdsArray as $articleId) ! { ! $sql = "SELECT article_category_id ! FROM " . KB_ARTICLES_TABLE . " ! WHERE article_id = '" . $articleId . "'"; ! if ( !$result = $db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldn\'t get article info', '', __LINE__, __FILE__, $sql ); ! } ! $row = $db->sql_fetchrow( $result ); ! $catId = $row['article_category_id']; ! ! // ! // Notification ! // ! if ( $this->notification[$catId]['activated'] > 0 ) // -1, 0, 1, 2 ! { ! // ! // Instatiate notification ! // ! $mx_kb_notification = new mx_kb_notification(); ! $mx_kb_notification->init( $articleId ); ! ! // ! // 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 'approve': ! $mx_notification_action = MX_APPROVED_NOTIFICATION; ! break; ! case '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_kb_notification->notify( $mx_notification_mode, $mx_notification_action ); ! ! if ( $this->notification[$cat_id]['notify_group'] > 0 ) ! { ! $mx_kb_notification->notify( $mx_notification_mode, $mx_notification_action, - intval($this->notification[$catId]['notify_group']) ); ! } ! } ! } ! } } *************** *** 1332,1336 **** function update_add_comment($article_data = '', $item_id, $cid, $subject = '', $message = '', $html_on = false, $bbcode_on = true, $smilies_on = false) { ! global $template, $mx_kb_functions, $lang, $board_config, $phpEx, $kb_config, $db, $images, $userdata, $_POST; global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars; --- 1395,1399 ---- function update_add_comment($article_data = '', $item_id, $cid, $subject = '', $message = '', $html_on = false, $bbcode_on = true, $smilies_on = false) { ! global $template, $mx_kb_functions, $lang, $board_config, $phpEx, $kb_config, $db, $images, $userdata; global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars; *************** *** 1455,1458 **** --- 1518,1548 ---- } } + + /** + * Enter description here... + * + * @param unknown_type $article_id + * @return unknown + */ + function get_cat_id($article_id) + { + global $db; + + $this->debug('mx_kb->get_cat_id', basename( __FILE__ )); + + $sql = "SELECT article_category_id + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = $article_id"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); + } + + $kb_row = $db->sql_fetchrow( $result ); + $category_id = $kb_row['article_category_id']; + + return $category_id; + } } |