public function _get_contrib_count($category_id) { // Bundle up the children in a nice array $child_list = array($category_id); $sql = 'SELECT left_id, right_id FROM ' . TITANIA_CATEGORIES_TABLE . ' WHERE category_id = ' . (int) $category_id . ' ORDER BY left_id ASC'; $result = phpbb::$db->sql_query($sql); $cat_row = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); if (!$cat_row) { return 0; } $sql = 'SELECT category_id FROM ' . TITANIA_CATEGORIES_TABLE . ' WHERE left_id > ' . $cat_row['left_id'] . ' AND right_id < ' . $cat_row['right_id']; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $child_list[] = $row['category_id']; } phpbb::$db->sql_freeresult($result); $sql_ary = array('SELECT' => 'COUNT(DISTINCT c.contrib_id) AS cnt', 'FROM' => array(TITANIA_CONTRIB_IN_CATEGORIES_TABLE => 'cic', TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => 'cic.contrib_id = c.contrib_id AND ' . phpbb::$db->sql_in_set('cic.category_id', array_map('intval', $child_list)) . ' AND c.contrib_visible = 1'); $validation_free = titania_types::find_validation_free(); if (sizeof($validation_free) && titania::$config->require_validation) { $sql_ary['WHERE'] .= ' AND (' . phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . ' OR ' . phpbb::$db->sql_in_set('c.contrib_type', $validation_free) . ')'; } $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); phpbb::$db->sql_query($sql); $cnt = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); return $cnt; }
/** * Display contributions * * @param string $mode The mode (category, author) * @param int $id The parent id (only show contributions under this category, author, etc) * @param string $blockname The name of the template block to use (contribs by default) */ function display_contribs($mode, $id, $sort = false, $blockname = 'contribs') { titania::add_lang('contributions'); titania::_include('functions_display', 'titania_topic_folder_img'); // Setup the sort tool if not sent, then request if ($sort === false) { $sort = self::build_sort(); } $sort->request(); $select = 'DISTINCT(c.contrib_id), c.contrib_name, c.contrib_name_clean, c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating, c.contrib_rating_count, c.contrib_type, c.contrib_last_update, c.contrib_user_id'; switch ($mode) { case 'author': // Get the contrib_ids this user is an author in (includes as a co-author) $contrib_ids = titania::$cache->get_author_contribs($id); if (!sizeof($contrib_ids)) { return compact('sort'); } $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => phpbb::$db->sql_in_set('c.contrib_id', $contrib_ids) . ' AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; case 'category': $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIB_IN_CATEGORIES_TABLE => 'cic'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => 'cic.contrib_id = c.contrib_id')), 'WHERE' => (is_array($id) && sizeof($id) ? phpbb::$db->sql_in_set('cic.category_id', array_map('intval', $id)) : 'cic.category_id = ' . (int) $id) . ' AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; case 'all': $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => 'c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; } titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id'); // Permissions if (titania::$config->require_validation && !phpbb::$auth->acl_get('u_titania_mod_contrib_mod')) { $sql_ary['LEFT_JOIN'][] = array('FROM' => array(TITANIA_CONTRIB_COAUTHORS_TABLE => 'cc'), 'ON' => 'cc.contrib_id = c.contrib_id AND cc.user_id = ' . phpbb::$user->data['user_id']); $view_unapproved = array(); if (sizeof(titania_types::find_authed('moderate'))) { $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('moderate')); } if (sizeof(titania_types::find_authed('view'))) { $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('view')); } // Find the ones that do not require validation $view_unapproved = array_merge($view_unapproved, titania_types::find_validation_free()); $view_unapproved = array_unique($view_unapproved); $sql_ary['WHERE'] .= ' AND (' . phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . (sizeof($view_unapproved) ? ' OR ' . phpbb::$db->sql_in_set('c.contrib_type', array_map('intval', $view_unapproved)) : '') . ' OR c.contrib_user_id = ' . phpbb::$user->data['user_id'] . ' OR cc.active = 1)'; } // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 'DISTINCT(c.contrib_id)')) { // No results...no need to query more... return compact('sort'); } $sort->build_pagination(titania_url::$current_page, titania_url::$params); $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); $contrib_ids = $user_ids = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { $user_ids[] = $row['contrib_user_id']; $contrib_ids[] = $row['contrib_id']; self::$contribs[$row['contrib_id']] = $row; } phpbb::$db->sql_freeresult($result); // Get user data users_overlord::load_users($user_ids); // Get phpBB versions if (sizeof($contrib_ids)) { $validation_free = titania_types::find_validation_free(); if (sizeof($validation_free) && titania::$config->require_validation) { $sql = 'SELECT rp.contrib_id, rp.phpbb_version_branch, rp.phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_CONTRIBS_TABLE . ' c WHERE ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contrib_ids)) . ' AND c.contrib_id = rp.contrib_id AND (rp.revision_validated = 1 OR ' . phpbb::$db->sql_in_set('c.contrib_type', $validation_free) . ') ORDER BY rp.row_id DESC'; } else { $sql = 'SELECT contrib_id, phpbb_version_branch, phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contrib_ids)) . (titania::$config->require_validation ? ' AND revision_validated = 1' : '') . ' ORDER BY row_id DESC'; } $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { self::$contribs[$row['contrib_id']]['phpbb_versions'][] = $row; } phpbb::$db->sql_freeresult($result); } // Setup some objects we'll use for temps $contrib = new titania_contribution(); $contrib->author = new titania_author(); $versions = titania::$cache->get_phpbb_versions(); $author_contribs = titania::$cache->get_author_contribs(phpbb::$user->data['user_id'], true); // Get the mark all tracking titania_tracking::get_track(TITANIA_CONTRIB, 0); foreach ($contrib_ids as $contrib_id) { $row = self::$contribs[$contrib_id]; $contrib->__set_array($row); $contrib->author->user_id = $contrib->contrib_user_id; $contrib->author->__set_array($row); // Author contrib variables $contrib->is_author = $contrib->contrib_user_id == phpbb::$user->data['user_id'] ? true : false; $contrib->is_active_coauthor = in_array($contrib->contrib_id, $author_contribs) ? true : false; // Store the tracking info we grabbed from the DB titania_tracking::store_from_db($row); // Get the folder image $folder_img = $folder_alt = ''; $last_read_mark = titania_tracking::get_track(TITANIA_CONTRIB, $contrib->contrib_id, true); $last_complete_mark = titania_tracking::get_track(TITANIA_CONTRIB, 0, true); $is_unread = $contrib->contrib_last_update > $last_read_mark && $contrib->contrib_last_update > $last_complete_mark ? true : false; titania_topic_folder_img($folder_img, $folder_alt, 0, $is_unread); // Only get unique phpBB versions supported if (isset($row['phpbb_versions'])) { titania::_include('functions_display', 'order_phpbb_version_list_from_db'); $ordered_phpbb_versions = order_phpbb_version_list_from_db($row['phpbb_versions']); } phpbb::$template->assign_block_vars($blockname, array_merge($contrib->assign_details(true, true), array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'), 'PHPBB_VERSION' => isset($row['phpbb_versions']) && sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : ''))); if (isset($row['phpbb_versions'])) { foreach ($ordered_phpbb_versions as $version_row) { phpbb::$template->assign_block_vars($blockname . '.phpbb_versions', array('NAME' => $version_row)); } } $contrib_type = $row['contrib_type']; } unset($contrib); return compact('sort'); }
*/ if (!defined('IN_TITANIA')) { exit; } // Mark all topics read if (request_var('mark', '') == 'topics') { titania_tracking::track(TITANIA_QUEUE_DISCUSSION, 0); } $queue_type = request_var('queue', ''); // Force the queue_type if we have a queue_id $queue_type = titania_types::type_from_url($queue_type); // Setup the base url we will use $base_url = titania_url::build_url('manage/queue_discussion'); if ($queue_type === false) { // We need to select the queue if they only have one that they can access, else display the list $authed = titania_types::find_authed('queue_discussion'); if (empty($authed)) { titania::needs_auth(); } else { if (sizeof($authed) == 1) { $queue_type = $authed[0]; } else { foreach ($authed as $type_id) { $sql = 'SELECT COUNT(topic_id) AS cnt FROM ' . TITANIA_TOPICS_TABLE . ' WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . ' AND topic_category = ' . (int) $type_id; phpbb::$db->sql_query($sql); $cnt = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); phpbb::$template->assign_block_vars('categories', array('U_VIEW_CATEGORY' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$type_id]->url)), 'CATEGORY_NAME' => titania_types::$types[$type_id]->lang, 'CATEGORY_CONTRIBS' => $cnt)); }
/** * Assign details * * A little different from those in other classes, this one only returns the info ready for output */ public function assign_details($output_text = true) { $details = array('POST_ID' => $this->post_id, 'TOPIC_ID' => $this->topic_id, 'POST_TYPE' => $this->post_type, 'POST_ACCESS' => $this->post_access, 'POST_LOCKED' => $this->post_locked, 'POST_ATTACHMENT' => $this->post_attachment, 'POST_USER_ID' => $this->post_user_id, 'POST_IP' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_ip : false, 'POST_TIME' => phpbb::$user->format_date($this->post_time), 'POST_EDIT_REASON' => censor_text($this->post_edit_reason), 'POST_SUBJECT' => censor_text($this->post_subject), 'POST_TEXT' => $output_text ? $this->generate_text_for_display() : '', 'EDITED_MESSAGE' => $this->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($this->post_edit_user, '_full'), phpbb::$user->format_date($this->post_edited)) : '', 'DELETED_MESSAGE' => $this->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($this->post_delete_user, '_full'), phpbb::$user->format_date($this->post_deleted), $this->get_url('undelete')) : '', 'U_VIEW' => $this->get_url(), 'U_EDIT' => $this->acl_get('edit') ? $this->get_url('edit') : '', 'U_QUICKEDIT' => $this->acl_get('edit') ? $this->get_url('quick_edit') : '', 'U_DELETE' => $this->acl_get('delete') && (!$this->post_deleted || phpbb::$auth->acl_get('u_titania_post_hard_delete')) ? $this->get_url('delete') : '', 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_WARN' => false, 'U_INFO' => phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || sizeof(titania_types::find_authed('moderate')) ? titania_url::build_url('manage/attention', array('type' => TITANIA_POST, 'id' => $this->post_id)) : '', 'U_QUOTE' => $this->acl_get('post') ? $this->get_url('quote') : '', 'S_UNREAD_POST' => $this->unread ? true : false, 'S_POST_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_approved : true, 'S_POST_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_reported : false, 'S_POST_DELETED' => $this->post_deleted != 0 ? true : false, 'S_ACCESS_TEAMS' => $this->post_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->post_access == TITANIA_ACCESS_AUTHORS ? true : false); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this); return $details; }
// Count the number of open attention items $sql = 'SELECT COUNT(attention_id) AS cnt FROM ' . TITANIA_ATTENTION_TABLE . ' WHERE attention_close_time = 0'; phpbb::$db->sql_query($sql); $attention_count = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); /** * Menu Array * * 'filename' => array( * 'title' => 'nav menu title', * 'url' => $page_url, * 'auth' => ($can_see_page) ? true : false, // Not required, always true if missing * ), */ $nav_ary = array('attention' => array('title' => 'ATTENTION', 'url' => titania_url::build_url('manage/attention'), 'auth' => !phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') && !sizeof(titania_types::find_authed('moderate')) ? false : true, 'count' => $attention_count), 'queue' => array('title' => 'VALIDATION_QUEUE', 'url' => titania_url::build_url('manage/queue'), 'auth' => sizeof(titania_types::find_authed('view')) && titania::$config->use_queue ? true : false), 'queue_discussion' => array('title' => 'QUEUE_DISCUSSION', 'url' => titania_url::build_url('manage/queue_discussion'), 'auth' => sizeof(titania_types::find_authed('queue_discussion')) && titania::$config->use_queue ? true : false), 'administration' => array('title' => 'ADMINISTRATION', 'url' => titania_url::build_url('manage/administration'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'match' => array('categories')), 'categories' => array('title' => 'MANAGE_CATEGORIES', 'url' => titania_url::build_url('manage/categories'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'display' => false)); // Display nav menu titania::generate_nav($nav_ary, $page, 'attention'); // Generate the main breadcrumbs titania::generate_breadcrumbs(array(phpbb::$user->lang['MANAGE'] => titania_url::build_url('manage'))); if ($page) { titania::generate_breadcrumbs(array($nav_ary[$page]['title'] => $nav_ary[$page]['url'])); } // And now to load the appropriate page... switch ($page) { case 'queue': case 'queue_discussion': case 'attention': case 'administration': case 'categories': include TITANIA_ROOT . 'manage/' . $page . '.' . PHP_EXT;
$queue_type = request_var('queue', ''); $tag = request_var('tag', 0); // Force the queue_type if we have a queue_id if ($queue_id) { $sql = 'SELECT queue_type FROM ' . TITANIA_QUEUE_TABLE . ' WHERE queue_id = ' . $queue_id; phpbb::$db->sql_query($sql); $queue_type = phpbb::$db->sql_fetchfield('queue_type'); } else { $queue_type = titania_types::type_from_url($queue_type); } // Setup the base url we will use $base_url = titania_url::build_url('manage/queue'); if ($queue_type === false) { // We need to select the queue if they only have one that they can access, else display the list $authed = titania_types::find_authed('view'); if (empty($authed)) { titania::needs_auth(); } else { if (sizeof($authed) == 1) { $queue_type = $authed[0]; } else { foreach ($authed as $type_id) { $sql = 'SELECT COUNT(queue_id) AS cnt FROM ' . TITANIA_QUEUE_TABLE . ' WHERE queue_type = ' . (int) $type_id . ' AND queue_status > 0'; phpbb::$db->sql_query($sql); $cnt = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); phpbb::$template->assign_block_vars('categories', array('U_VIEW_CATEGORY' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$type_id]->url)), 'CATEGORY_NAME' => titania_types::$types[$type_id]->lang, 'CATEGORY_CONTRIBS' => $cnt)); }
/** * Display "forum" like section for support/tracker/etc * * @param string $type The type (support, review, queue, tracker, author_support, author_tracker) author_ for displaying posts from the areas the given author is involved in (either an author/co-author) * @param object|boolean $object The object (for contrib related (support, review, queue, tracker) and author_ modes) * @param object|boolean $sort The sort object (includes/tools/sort.php) * @param array $options Some special options * @param string $contrib_type The type of the support topic list */ public static function display_forums($type, $object = false, $sort = false, $options = array()) { if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $topic_ids = array(); $switch_on_sticky = true; // Display the extra block after stickies end? Not used when not sorting with stickies first $sql_ary = array('SELECT' => 't.*, u.username as topic_first_post_username, u.user_colour as topic_first_post_user_colour, ul.username as topic_last_post_username, ul.user_colour as topic_last_post_user_colour', 'FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'WHERE' => self::sql_permissions('t.', false, true), 'ORDER_BY' => 't.topic_sticky DESC, ' . $sort->get_order_by()); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_first_post_user_id = u.user_id'); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'ul'), 'ON' => 't.topic_last_post_user_id = ul.user_id'); titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id'); // Setup the contribution/topic we will use for parsing the output (before the switch so we are able to do type specific things for it) $topic = new titania_topic(); $contrib = new titania_contribution(); // type specific things switch ($type) { case 'tracker': $page_url = $object->get_url('tracker'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; if (isset($options['category'])) { $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['category']; } break; case 'queue': $page_url = titania_url::build_url('manage/queue'); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE; break; case 'queue_discussion': $page_url = titania_url::build_url('manage/queue_discussion', array('queue' => titania_types::$types[$options['topic_category']]->url)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE_DISCUSSION; // Only display those in which the users are authed $authed = titania_types::find_authed('queue_discussion'); if (!sizeof($authed)) { return compact('sort'); } if (isset($options['topic_category'])) { if (!in_array((int) $options['topic_category'], $authed)) { return compact('sort'); } $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['topic_category']; } else { $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.topic_category', $authed); } // Additional tracking for all queue discussion topics titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); break; case 'author_support': $page_url = $object->get_url('support'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id, true); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); // We also display the queue discussion topic between validators and authors in the support area $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; // Additional tracking for marking items as read in each contribution titania_tracking::get_tracks(TITANIA_SUPPORT, $contrib_ids); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0, 'type_match' => true); // Track the queue discussion too if applicable if (titania_types::find_authed('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'author_tracker': $page_url = $object->get_url('tracker'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; break; case 'all_support': // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); if (isset(titania_types::$types[$options['contrib_type']])) { $page_url = titania_url::build_url('support/' . titania_types::$types[$options['contrib_type']]->url); $sql_ary['WHERE'] .= ' AND contrib.contrib_type = ' . $options['contrib_type']; } else { $page_url = titania_url::build_url('support/all'); } // Additional tracking field (to allow marking all support/discussion as read) $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'support': default: $page_url = $object->get_url('support'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; // We also display the queue discussion topic between validators and authors in the support area if ($object->is_author || $object->is_active_coauthor || titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; } else { $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; } // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, $object->contrib_id, 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Track the queue discussion too if applicable if (titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } break; } // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 't.topic_id')) { // No results...no need to query more... return compact('sort'); } $sort->build_pagination($page_url); $last_was_sticky = false; // Get the data $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); while ($row = phpbb::$db->sql_fetchrow($result)) { // Store the tracking info we grabbed from the DB titania_tracking::store_from_db($row); self::$topics[$row['topic_id']] = $row; $topic->__set_array($row); $contrib->__set_array($row); phpbb::$template->assign_block_vars('topics', array_merge($topic->assign_details(), array('S_TOPIC_TYPE_SWITCH' => $switch_on_sticky && $last_was_sticky && !$topic->topic_sticky ? true : false, 'CONTRIB_TYPE' => isset($row['contrib_type']) && $row['contrib_type'] ? titania_types::$types[$row['contrib_type']]->lang : '', 'TOPIC_CONTRIB_NAME' => isset($row['contrib_name']) && $row['contrib_name'] ? censor_text($row['contrib_name']) : '', 'U_VIEW_TOPIC_CONTRIB' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url() : '', 'U_VIEW_TOPIC_CONTRIB_SUPPORT' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url('support') : ''))); $last_was_sticky = $topic->topic_sticky; } phpbb::$db->sql_freeresult($result); unset($topic); return compact('sort'); }
/** * * @package titania * @version $Id$ * @copyright (c) 2008 phpBB Customisation Database Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** * @ignore */ if (!defined('IN_TITANIA')) { exit; } if (!phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') && !sizeof(titania_types::find_authed('moderate'))) { titania::needs_auth(); } phpbb::$user->add_lang('mcp'); $attention_id = request_var('a', 0); $object_type = request_var('type', 0); $object_id = request_var('id', 0); $close = isset($_POST['close']) ? true : false; $approve = isset($_POST['approve']) ? true : false; $disapprove = isset($_POST['disapprove']) ? true : false; $delete = isset($_POST['delete']) ? true : false; if ($attention_id || $object_type && $object_id) { if ($attention_id) { $row = attention_overlord::load_attention($attention_id); if (!$row) { trigger_error('NO_ATTENTION_ITEM');
} if (sizeof($contrib_tools->error)) { trigger_error(implode('<br />', $contrib_tools->error)); } redirect(titania_url::build_url('manage/queue', array('queue' => titania_types::$types[$queue->queue_type]->url, 'q' => $queue->queue_id))); break; /** * Display all support topics */ /** * Display all support topics */ case 'support': // The type of contribs (mod, style, converter, official_tool, etc.) $type = request_var('type', 'all'); $type_id = titania_types::type_from_url($type); $type = !$type_id ? 'all' : $type; if ($type == 'all') { // Mark all topics read if (request_var('mark', '') == 'topics') { titania_tracking::track(TITANIA_SUPPORT, 0); } // Mark all topics read phpbb::$template->assign_var('U_MARK_TOPICS', titania_url::append_url(titania_url::build_url('support/all'), array('mark' => 'topics'))); } // Generate the main breadcrumbs titania::generate_breadcrumbs(array('ALL_SUPPORT' => titania_url::build_url('support/' . $type . '/'))); $data = topics_overlord::display_forums_complete('all_support', false, array('contrib_type' => $type_id)); // Links to the support topic lists foreach (titania_types::$types as $id => $class) { phpbb::$template->assign_block_vars('support_types', array('U_SUPPORT' => titania_url::build_url('support/' . $class->url . '/'), 'TYPE_SUPPORT' => $class->langs));
/** * Change the status of this contrib item. * YOU MUST USE THIS FUNCTION TO CHANGE THE STATUS ELSE THE AUTHORS CONTRIB COUNT WILL BE INCORRECT! * * @param int $new_status */ public function change_status($new_status) { $new_status = (int) $new_status; $old_status = $this->contrib_status; if ($old_status == $new_status) { return; } $this->contrib_status = $new_status; $sql_ary = array('contrib_status' => $this->contrib_status); // Grab the current authors $author_list = array($this->contrib_user_id); $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . ' WHERE contrib_id = ' . (int) $this->contrib_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $author_list[] = $row['user_id']; } phpbb::$db->sql_freeresult($result); // If validation is required we update the counts (otherwise updated when submitted) if (titania::$config->require_validation && titania_types::$types[$this->contrib_type]->require_validation) { // First we are essentially resetting the contrib and category counts back to "New" switch ($old_status) { case TITANIA_CONTRIB_APPROVED: case TITANIA_CONTRIB_DOWNLOAD_DISABLED: // Decrement the count for the authors $this->change_author_contrib_count($author_list, '-', true); // Decrement the count for this type titania_types::decrement_count($this->contrib_type); // Decrement the category count $this->update_category_count('-', true); break; } // Now, for the new status, if approved, we increment the contrib and category counts switch ($this->contrib_status) { case TITANIA_CONTRIB_APPROVED: case TITANIA_CONTRIB_DOWNLOAD_DISABLED: // Increment the count for the authors $this->change_author_contrib_count($author_list); // Increment the count for this type titania_types::increment_count($this->contrib_type); // Increment the category count $this->update_category_count(); $sql_ary['contrib_last_update'] = titania::$time; break; } } $sql = 'UPDATE ' . $this->sql_table . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Index! $this->index(); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }
/** * Titania page_header * * @param string $page_title * @param bool $display_online_list */ public static function page_header($page_title = '') { if (!empty(titania::$hook) && titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $page_title)) { if (titania::$hook->hook_return(array(__CLASS__, __FUNCTION__))) { return titania::$hook->hook_return_result(array(__CLASS__, __FUNCTION__)); } } if (defined('HEADER_INC')) { return; } define('HEADER_INC', true); // Do the phpBB page header stuff first phpbb::page_header($page_title); phpbb::$template->assign_vars(array('PHPBB_ROOT_PATH' => self::$absolute_board, 'TITANIA_ROOT_PATH' => self::$absolute_path, 'U_BASE_URL' => self::$absolute_path, 'U_SITE_ROOT' => self::$absolute_board, 'U_MANAGE' => sizeof(titania_types::find_authed()) || phpbb::$auth->acl_get('u_titania_mod_contrib_mod') || phpbb::$auth->acl_get('u_titania_mod_post_mod') ? titania_url::build_url('manage') : '', 'U_ALL_CONTRIBUTIONS' => titania_url::build_url('contributions/all'), 'U_ALL_SUPPORT' => titania::$config->support_in_titania ? titania_url::build_url('support/all') : false, 'U_MY_CONTRIBUTIONS' => phpbb::$user->data['is_registered'] && !phpbb::$user->data['is_bot'] ? titania_url::build_url('author/' . htmlspecialchars_decode(phpbb::$user->data['username_clean']) . '/contributions/') : '', 'U_SEARCH' => titania_url::build_url('search'), 'U_FIND_CONTRIBUTION' => titania_url::build_url('find-contribution'), 'U_FAQ' => titania_url::build_url('faq'), 'U_TITANIA_SEARCH_SELF' => titania::$config->support_in_titania && !phpbb::$user->data['is_bot'] && phpbb::$user->data['is_registered'] ? titania_url::build_url('search', array('u' => phpbb::$user->data['user_id'], 'type' => TITANIA_SUPPORT)) : '', 'S_DISPLAY_SEARCH' => true, 'T_TITANIA_TEMPLATE_PATH' => self::$template_path, 'T_TITANIA_THEME_PATH' => self::$theme_path, 'T_TITANIA_IMAGES_PATH' => self::$images_path, 'T_TITANIA_STYLESHEET' => self::$absolute_path . 'style.' . PHP_EXT . '?style=' . self::$config->style, 'T_STYLESHEET_LINK' => !phpbb::$user->theme['theme_storedb'] ? self::$absolute_board . '/styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : self::$absolute_board . 'style.' . PHP_EXT . '?sid=' . phpbb::$user->session_id . '&id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang'], 'T_STYLESHEET_NAME' => phpbb::$user->theme['theme_name'])); // Header hook self::$hook->call_hook('titania_page_header', $page_title); }