コード例 #1
0
ファイル: topics.php プロジェクト: kairion/customisation-db
 /**
  * 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');
 }
コード例 #2
0
ファイル: faq.php プロジェクト: kairion/customisation-db
            $faqs = array();
            $sql_ary = array('SELECT' => 'f.*', 'FROM' => array(TITANIA_CONTRIB_FAQ_TABLE => 'f'), 'WHERE' => 'f.contrib_id = ' . titania::$contrib->contrib_id . '
						AND f.faq_access >= ' . titania::$access_level, 'ORDER_BY' => 'f.left_id ASC');
            // Main SQL Query
            $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
            // Handle pagination
            if ($sort->sql_count($sql_ary, 'faq_id')) {
                $sort->build_pagination($faq->get_url());
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $faqs[$row['faq_id']] = $row;
                }
                phpbb::$db->sql_freeresult($result);
                // Grab the tracking info
                titania_tracking::get_tracks(TITANIA_FAQ, array_keys($faqs));
            }
            // Output
            foreach ($faqs as $id => $row) {
                // @todo probably should setup an edit time or something for better read tracking in case it was edited
                $folder_img = $folder_alt = '';
                $unread = titania_tracking::get_track(TITANIA_FAQ, $id, true) === 0 ? true : false;
                titania_topic_folder_img($folder_img, $folder_alt, 0, $unread);
                phpbb::$template->assign_block_vars('faqlist', array('U_FAQ' => $faq->get_url('', $row['faq_id']), 'SUBJECT' => $row['faq_subject'], 'VIEWS' => $row['faq_views'], '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'), 'U_MOVE_UP' => phpbb::$auth->acl_get('u_titania_mod_faq_mod') || titania::$contrib->is_author || titania::$contrib->is_active_coauthor ? $faq->get_url('move_up', $row['faq_id']) : false, 'U_MOVE_DOWN' => phpbb::$auth->acl_get('u_titania_mod_faq_mod') || titania::$contrib->is_author || titania::$contrib->is_active_coauthor ? $faq->get_url('move_down', $row['faq_id']) : false, 'U_EDIT' => phpbb::$auth->acl_get('u_titania_mod_faq_mod') || phpbb::$auth->acl_get('u_titania_faq_edit') && (titania::$contrib->is_author || titania::$contrib->is_active_coauthor) ? $faq->get_url('edit', $row['faq_id']) : false, 'U_DELETE' => phpbb::$auth->acl_get('u_titania_mod_faq_mod') || phpbb::$auth->acl_get('u_titania_faq_delete') && (titania::$contrib->is_author || titania::$contrib->is_active_coauthor) ? $faq->get_url('delete', $row['faq_id']) : false, 'S_ACCESS_TEAMS' => $row['faq_access'] == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $row['faq_access'] == TITANIA_ACCESS_AUTHORS ? true : false));
            }
            phpbb::$template->assign_vars(array('ICON_MOVE_UP' => '<img src="' . titania::$images_path . 'icon_up.gif" alt="' . phpbb::$user->lang['MOVE_UP'] . '" title="' . phpbb::$user->lang['MOVE_UP'] . '" />', 'ICON_MOVE_UP_DISABLED' => '<img src="' . titania::$images_path . 'icon_up_disabled.gif" alt="' . phpbb::$user->lang['MOVE_UP'] . '" title="' . phpbb::$user->lang['MOVE_UP'] . '" />', 'ICON_MOVE_DOWN' => '<img src="' . titania::$images_path . 'icon_down.gif" alt="' . phpbb::$user->lang['MOVE_DOWN'] . '" title="' . phpbb::$user->lang['MOVE_DOWN'] . '" />', 'ICON_MOVE_DOWN_DISABLED' => '<img src="' . titania::$images_path . 'icon_down_disabled.gif" alt="' . phpbb::$user->lang['MOVE_DOWN'] . '" title="' . phpbb::$user->lang['MOVE_DOWN'] . '" />', 'ICON_EDIT' => '<img src="' . titania::$images_path . 'icon_edit.gif" alt="' . phpbb::$user->lang['EDIT'] . '" title="' . phpbb::$user->lang['EDIT'] . '" />', 'ICON_EDIT_DISABLED' => '<img src="' . titania::$images_path . 'icon_edit_disabled.gif" alt="' . phpbb::$user->lang['EDIT'] . '" title="' . phpbb::$user->lang['EDIT'] . '" />', 'ICON_DELETE' => '<img src="' . titania::$images_path . 'icon_delete.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />', 'ICON_DELETE_DISABLED' => '<img src="' . titania::$images_path . 'icon_delete_disabled.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />', 'S_LIST' => true, 'U_CREATE_FAQ' => phpbb::$auth->acl_get('u_titania_mod_faq_mod') || phpbb::$auth->acl_get('u_titania_faq_create') && (titania::$contrib->is_author || titania::$contrib->is_active_coauthor) ? $faq->get_url('create') : false, 'U_CANONICAL' => $sort->build_canonical()));
        }
        break;
}
phpbb::$template->assign_vars(array('CONTRIB_NAME' => titania::$contrib->contrib_name));
titania::page_footer(false, 'contributions/contribution_faq.html');