コード例 #1
0
ファイル: contribs.php プロジェクト: kairion/customisation-db
    /**
     * 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');
    }
コード例 #2
0
    function main($id, $mode)
    {
        global $phpbb_root_path;
        define('PHPBB_INCLUDED', true);
        define('USE_PHPBB_TEMPLATE', true);
        define('IN_TITANIA', true);
        if (!defined('PHP_EXT')) {
            define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
        }
        require TITANIA_ROOT . 'common.' . PHP_EXT;
        // Need a few hacks to be used from within phpBB
        titania_url::decode_url(titania::$config->phpbb_script_path);
        titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
        titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
        $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp'));
        // Include some files
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool
        $sort = new titania_sort();
        $sort->default_limit = phpbb::$config['topics_per_page'];
        $sort->request();
        // Start initial var setup
        $url = $this->u_action;
        add_form_key('ucp_front_subscription');
        // User wants to unsubscribe?
        if (isset($_POST['unsubscribe'])) {
            if (check_form_key('ucp_front_subscription')) {
                $sections = request_var('sections', array(0 => array(0 => 0)));
                $items = request_var('items', array(0 => array(0 => 0)));
                $subscriptions = $sections + $items;
                if (sizeof($subscriptions)) {
                    foreach ($subscriptions as $type => $type_id) {
                        $object_ids = array_keys($type_id);
                        foreach ($object_ids as $object_id) {
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . '
								AND watch_object_type = ' . $type . '
								AND watch_object_id = ' . $object_id;
                            phpbb::$db->sql_query($sql);
                        }
                    }
                } else {
                    $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED'];
                }
            } else {
                $msg = phpbb::$user->lang['FORM_INVALID'];
            }
            if (isset($msg)) {
                meta_refresh(3, $url);
                $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
                trigger_error($message);
            }
        }
        switch ($mode) {
            case 'subscription_items':
                $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
						AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update
							WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ')
								AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . '
								AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                // Additional tracking for support topics
                titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc');
                titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                // Tracking for contributions
                titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = $rows = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    titania_tracking::store_from_db($row);
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        $user_ids[] = $row['topic_first_post_user_id'];
                        $user_ids[] = $row['topic_last_post_user_id'];
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $user_ids[] = $row['contrib_user_id'];
                        }
                    }
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                foreach ($rows as $row) {
                    $folder_img = $folder_alt = '';
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        if (!$row['topic_id']) {
                            // Topic was deleted
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_object_type = ' . (int) $row['watch_object_type'] . '
									AND watch_object_id = ' . (int) $row['watch_object_id'];
                            phpbb::$db->sql_query($sql);
                            continue;
                        }
                        $topic = new titania_topic();
                        $topic->__set_array($row);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
                        $tpl_block = 'items';
                        $subscription_target = '';
                        if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION'];
                        }
                        if ($row['topic_type'] == TITANIA_QUEUE) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE'];
                        }
                        if ($row['topic_type'] == TITANIA_SUPPORT) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC'];
                        }
                        // Tracking check
                        $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true);
                        $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
                        $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false;
                        // Get the folder image
                        $topic->topic_folder_img($folder_img, $folder_alt);
                        $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true);
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $tpl_block = 'items';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true);
                        }
                    }
                    phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, 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_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'))));
                }
                break;
            case 'subscription_sections':
                $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
					AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ')
								AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    $user_ids[] = $row['contrib_user_id'];
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                if (isset($rows)) {
                    foreach ($rows as $row) {
                        if ($row['watch_object_type'] == TITANIA_SUPPORT) {
                            $tpl_block = 'sections';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support'));
                        } else {
                            if ($row['watch_object_type'] == TITANIA_ATTENTION) {
                                $tpl_block = 'sections';
                                $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention'));
                            } else {
                                if ($row['watch_object_type'] == TITANIA_QUEUE) {
                                    $tpl_block = 'sections';
                                    $queue_id = $row['watch_object_id'];
                                    // Setup the base url we will use
                                    $base_url = titania_url::build_url('manage/queue');
                                    $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url)));
                                }
                            }
                        }
                        phpbb::$template->assign_block_vars($tpl_block, $vars);
                    }
                }
                break;
        }
        phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/'));
        titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']);
        titania::page_footer(true, 'manage/' . $mode . '.html');
    }
コード例 #3
0
ファイル: tracking.php プロジェクト: Gfksx/customisation-db
 /**
  * Figure out the last read mark for an object
  *
  * @param mixed $unread_fields
  * 	array(
  * 		'type' => 0, (the object type to use when getting the tracking data)
  * 		'id' => 0, (the object id to use when getting the tracking data)
  * 		'parent_match' => false, (if isset and true, the 'id' field we search for is the $parent_id sent)
  * 		'type_match' => false, (if isset and true we will only count when the $object_type that is sent matches the type we are requesting from the tracking data)
  *	)
  * @param mixed $object_type
  * @param mixed $parent_id
  *
  * @return int last mark time
  */
 public static function find_last_read_mark($unread_fields, $object_type, $parent_id)
 {
     $last_read_mark = 0;
     foreach ($unread_fields as $field_ary) {
         if (isset($field_ary['type_match']) && $field_ary['type'] != $object_type) {
             continue;
         }
         if (isset($field_ary['parent_match'])) {
             $field_ary['id'] = $parent_id;
         }
         $last_read_mark = max($last_read_mark, titania_tracking::get_track($field_ary['type'], $field_ary['id'], true));
     }
     return $last_read_mark;
 }
コード例 #4
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');
コード例 #5
0
ファイル: posts.php プロジェクト: Noxwizard/customisation-db
    /**
     * Display topic section for support/tracker/etc
     *
     * @param object $topic The topic object
     * @param titania_sort $sort The sort object (includes/tools/sort.php)
     */
    public static function display_topic($topic, $sort = false)
    {
        if ($sort === false) {
            // Setup the sort tool
            $sort = self::build_sort();
        }
        $sort->request();
        $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by());
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'p.post_id')) {
            // No results...no need to query more...
            return;
        }
        $sort->build_pagination($topic->get_url());
        // Get the data
        $post_ids = $user_ids = array();
        $last_post_time = 0;
        // tracking
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            self::$posts[$row['post_id']] = $row;
            self::$posts[$row['post_id']]['attachments'] = array();
            $post_ids[] = $row['post_id'];
            $user_ids[] = $row['post_user_id'];
            $user_ids[] = $row['post_edit_user'];
            $user_ids[] = $row['post_delete_user'];
            $last_post_time = $row['post_time'];
            // to set tracking
        }
        phpbb::$db->sql_freeresult($result);
        // Grab the tracking data
        $last_mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id);
        // Store tracking data
        titania_tracking::track(TITANIA_TOPIC, $topic->topic_id, $last_post_time);
        // load the user data
        users_overlord::load($user_ids);
        phpbb::_include('functions_profile_fields', false, 'custom_profile');
        $cp = new custom_profile();
        $post = new titania_post($topic->topic_type, $topic);
        $attachments = new titania_attachment($topic->topic_type, false);
        // Grab all attachments
        $attachments_set = $attachments->load_attachments_set($post_ids);
        // Loop de loop
        $prev_post_time = 0;
        foreach ($post_ids as $post_id) {
            $post->__set_array(self::$posts[$post_id]);
            $attachments->clear_attachments();
            if (isset($attachments_set[$post_id])) {
                $attachments->store_attachments($attachments_set[$post_id]);
            }
            // Parse attachments before outputting the message
            $message = $post->generate_text_for_display();
            $parsed_attachments = $attachments->parse_attachments($message);
            // Prepare message text for use in javascript
            $message_decoded = censor_text($post->post_text);
            titania_decode_message($message_decoded, $post->post_text_uid);
            $message_decoded = bbcode_nl2br($message_decoded);
            // Build CP Fields
            $cp_row = array();
            if (isset(users_overlord::$cp_fields[$post->post_user_id])) {
                $cp_row = $cp->generate_profile_fields_template('show', false, users_overlord::$cp_fields[$post->post_user_id]);
            }
            $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array();
            // Display edit info
            $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile'));
            $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : '';
            phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => titania_url::append_url($topic->get_url(), array('p' => $post_id, '#p' => $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false)));
            // Output CP Fields
            if (!empty($cp_row['blockrow'])) {
                foreach ($cp_row['blockrow'] as $field_data) {
                    phpbb::$template->assign_block_vars('posts.custom_fields', $field_data);
                }
            }
            //S_IGNORE_POST
            //POST_ICON_IMG
            //MINI_POST_IMG
            foreach ($parsed_attachments as $attachment) {
                phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
            $prev_post_time = $post->post_time;
        }
        unset($post, $attachments);
        // Increment the topic view count
        $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
			SET topic_views = topic_views + 1
			WHERE topic_id = ' . (int) $topic->topic_id;
        phpbb::$db->sql_query($sql);
    }
コード例 #6
0
ファイル: topic.php プロジェクト: kairion/customisation-db
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details()
 {
     // Tracking check
     $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($this->additional_unread_fields, $this->topic_type, $this->parent_id));
     $this->unread = $this->topic_last_post_time > $last_read_mark ? true : false;
     $folder_img = $folder_alt = '';
     $this->topic_folder_img($folder_img, $folder_alt);
     // To find out if we have any posts that need approval
     $approved = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, false));
     $total = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, true));
     $details = array('TOPIC_ID' => $this->topic_id, 'TOPIC_TYPE' => $this->topic_type, 'TOPIC_ACCESS' => $this->topic_access, 'TOPIC_STATUS' => $this->topic_status, 'TOPIC_STICKY' => $this->topic_sticky, 'TOPIC_LOCKED' => $this->topic_locked, 'POSTS_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') && $total > $approved ? false : true, 'TOPIC_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_approved : true, 'TOPIC_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_reported : false, 'TOPIC_ASSIGNED' => $this->topic_assigned, 'TOPIC_REPLIES' => $this->get_postcount() - 1, 'TOPIC_VIEWS' => $this->topic_views, 'TOPIC_SUBJECT' => censor_text($this->topic_subject), 'TOPIC_FIRST_POST_ID' => $this->topic_first_post_id, 'TOPIC_FIRST_POST_USER_ID' => $this->topic_first_post_user_id, 'TOPIC_FIRST_POST_USER_COLOUR' => $this->topic_first_post_user_colour, 'TOPIC_FIRST_POST_USER_FULL' => get_username_string('full', $this->topic_first_post_user_id, $this->topic_first_post_username, $this->topic_first_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_FIRST_POST_TIME' => phpbb::$user->format_date($this->topic_first_post_time), 'TOPIC_LAST_POST_ID' => $this->topic_last_post_id, 'TOPIC_LAST_POST_USER_ID' => $this->topic_last_post_user_id, 'TOPIC_LAST_POST_USER_COLOUR' => $this->topic_last_post_user_colour, 'TOPIC_LAST_POST_USER_FULL' => get_username_string('full', $this->topic_last_post_user_id, $this->topic_last_post_username, $this->topic_last_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_LAST_POST_TIME' => phpbb::$user->format_date($this->topic_last_post_time), 'TOPIC_LAST_POST_SUBJECT' => censor_text($this->topic_last_post_subject), 'U_NEWEST_POST' => $this->unread ? titania_url::append_url($this->get_url(), array('view' => 'unread', '#' => 'unread')) : '', 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($this->get_url(), array('p' => $this->topic_last_post_id, '#p' => $this->topic_last_post_id)), 'S_UNREAD_TOPIC' => $this->unread ? true : false, 'S_ACCESS_TEAMS' => $this->topic_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == TITANIA_ACCESS_AUTHORS ? true : false, '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_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'));
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }