示例#1
0
 /**
  * Initialize the Search
  */
 public static function initialize()
 {
     if (self::$index === false) {
         // Initialize the ezc/Zend Search class
         if (titania::$config->search_backend == 'zend') {
             if (!is_writable(TITANIA_ROOT . self::store_path)) {
                 throw new exception(self::store_path . ' must be writable to use the Zend Lucene Search');
             }
             $handler = new ezcSearchZendLuceneHandler(TITANIA_ROOT . self::store_path);
         } else {
             if (titania::$config->search_backend == 'solr') {
                 $handler = new ezcSearchSolrHandler(titania::$config->search_backend_ip, titania::$config->search_backend_port);
                 // In case Solr would happen to go down..
                 if (!$handler->connection) {
                     // Log this as an error
                     titania::log(TITANIA_ERROR, 'Solr Server not responding');
                     self::$do_not_index = true;
                     return false;
                 }
             } else {
                 throw new exception('We need a proper search backend selected');
             }
         }
         $manager = new ezcSearchEmbeddedManager();
         self::$index = new ezcSearchSession($handler, $manager);
         return true;
     }
 }
示例#2
0
 /**
  * Load the types into the $types array
  */
 public static function load_types()
 {
     $dh = @opendir(TITANIA_ROOT . 'includes/types/');
     if (!$dh) {
         trigger_error('Could not open the types directory');
     }
     while (($fname = readdir($dh)) !== false) {
         if (strpos($fname, '.' . PHP_EXT) && substr($fname, 0, 1) != '_' && $fname != 'base.' . PHP_EXT) {
             include TITANIA_ROOT . 'includes/types/' . $fname;
             $class_name = 'titania_type_' . substr($fname, 0, strpos($fname, '.' . PHP_EXT));
             titania::add_lang('types/' . substr($fname, 0, strpos($fname, '.' . PHP_EXT)));
             $class = new $class_name();
             $class->auto_install();
             self::$types[$class->id] = $class;
         }
     }
     closedir($dh);
     ksort(self::$types);
 }
示例#3
0
 /**
  * Get the appropriate attention object for the attention item
  *
  * @param mixed $attention_id
  * @param mixed $object_type
  * @param mixed $object_id
  */
 public static function get_attention_object($attention_id, $object_type = false, $object_id = false)
 {
     $data = self::load_attention($attention_id, $object_type, $object_id);
     if (!$data) {
         return false;
     }
     switch ($data['attention_object_type']) {
         case TITANIA_POST:
             titania::_include('objects/attention_types/post', false, 'titania_attention_post');
             $object = new titania_attention_post();
             break;
         case TITANIA_CONTRIB:
             titania::_include('objects/attention_types/contribution', false, 'titania_attention_contribution');
             $object = new titania_attention_contribution();
             break;
         default:
             $object = new titania_attention();
     }
     $object->__set_array($data);
     return $object;
 }
 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');
     titania::$hook->register('titania_generate_text_for_display', 'titania_outside_generate_text_for_display', 'standalone');
     titania::add_lang('manage');
     $this->p_master->assign_tpl_vars(phpbb::append_sid('mcp'));
     phpbb::$template->assign_vars(array('L_TITLE' => phpbb::$user->lang['ATTENTION'], 'L_EXPLAIN' => ''));
     include TITANIA_ROOT . 'manage/attention.' . PHP_EXT;
 }
示例#5
0
* This file is part of the phpBB Customisation Database package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
 * @ignore
 */
if (!defined('IN_PHPBB')) {
    exit;
}
global $phpbb_container;
$ext_root_path = $phpbb_container->getParameter('phpbb.titania.root_path');
$php_ext = $phpbb_container->getParameter('core.php_ext');
// Include core classes
require $ext_root_path . 'includes/core/phpbb.' . $php_ext;
require $ext_root_path . 'includes/core/titania.' . $php_ext;
titania::configure($phpbb_container->get('phpbb.titania.config'), $ext_root_path, $php_ext);
// Set up our auto-loader
spl_autoload_register(array('titania', 'autoload'));
// Include the dynamic constants (after reading the Titania config file, but before loading the phpBB common file)
titania::_include('dynamic_constants');
// Initialise phpBB
phpbb::initialise();
// Initialise Titania
titania::initialise();
示例#6
0
/**
 * Error and message handler, call with trigger_error
 */
function titania_msg_handler($errno, $msg_text, $errfile, $errline)
{
    global $msg_title, $msg_long_text;
    // Do not display notices if we suppress them via @
    if (error_reporting() == 0) {
        return;
    }
    // Message handler is stripping text. In case we need it, we are possible to define long text...
    if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
        $msg_text = $msg_long_text;
    }
    switch ($errno) {
        case E_NOTICE:
        case E_WARNING:
            // Check the error reporting level and return if the error level does not match
            // If DEBUG is defined the default level is E_ALL
            if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) {
                return;
            }
            if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) {
                // flush the content, else we get a white page if output buffering is on
                if ((int) @ini_get('output_buffering') === 1 || strtolower(@ini_get('output_buffering')) === 'on') {
                    @ob_flush();
                }
                // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;)
                if (!empty(phpbb::$config['gzip_compress'])) {
                    if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level()) {
                        @ob_flush();
                    }
                }
                // remove complete path to installation, with the risk of changing backslashes meant to be there
                $errfile = str_replace(array(phpbb_realpath(PHPBB_ROOT_PATH), '\\'), array('', '/'), $errfile);
                $msg_text = str_replace(array(phpbb_realpath(PHPBB_ROOT_PATH), '\\'), array('', '/'), $msg_text);
                echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
                // echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n";
            }
            return;
            break;
        case E_USER_ERROR:
            if (!empty(phpbb::$user) && !empty(phpbb::$user->lang)) {
                $msg_text = !empty(phpbb::$user->lang[$msg_text]) ? phpbb::$user->lang[$msg_text] : $msg_text;
                $msg_title = !isset($msg_title) ? phpbb::$user->lang['GENERAL_ERROR'] : (!empty(phpbb::$user->lang[$msg_title]) ? phpbb::$user->lang[$msg_title] : $msg_title);
                $l_return_index = sprintf(phpbb::$user->lang['RETURN_INDEX'], '<a href="' . titania::$absolute_path . '">', '</a>');
                $l_notify = '';
                if (!empty(phpbb::$config['board_contact'])) {
                    $l_notify = '<p>' . sprintf(phpbb::$user->lang['NOTIFY_ADMIN_EMAIL'], phpbb::$config['board_contact']) . '</p>';
                }
            } else {
                $msg_title = 'General Error';
                $l_return_index = '<a href="' . titania::$absolute_path . '">Return to index page</a>';
                $l_notify = '';
                if (!empty(phpbb::$config['board_contact'])) {
                    $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . phpbb::$config['board_contact'] . '">' . phpbb::$config['board_contact'] . '</a></p>';
                }
            }
            garbage_collection();
            // Try to not call the adm page data...
            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
            echo '<head>';
            echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
            echo '<title>' . $msg_title . '</title>';
            echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
            echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
            echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
            echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
            echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } ';
            echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
            echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
            echo "\n" . '/* ]]> */' . "\n";
            echo '</style>';
            echo '</head>';
            echo '<body id="errorpage">';
            echo '<div id="wrap">';
            echo '	<div id="page-header">';
            echo '		' . $l_return_index;
            echo '	</div>';
            echo '	<div id="acp">';
            echo '	<div class="panel">';
            echo '		<div id="content">';
            echo '			<h1>' . $msg_title . '</h1>';
            echo '			<div>' . $msg_text . '</div>';
            echo '			<div>' . get_backtrace() . '</div>';
            echo $l_notify;
            echo '		</div>';
            echo '	</div>';
            echo '	</div>';
            echo '	<div id="page-footer">';
            echo '		Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
            echo '	</div>';
            echo '</div>';
            echo '</body>';
            echo '</html>';
            exit_handler();
            // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
            exit;
            break;
        case E_USER_WARNING:
        case E_USER_NOTICE:
            define('IN_ERROR_HANDLER', true);
            if (empty(phpbb::$user->data)) {
                phpbb::$user->session_begin();
            }
            // We re-init the auth array to get correct results on login/logout
            phpbb::$auth->acl(phpbb::$user->data);
            if (empty(phpbb::$user->lang)) {
                phpbb::$user->setup();
            }
            $msg_text = !empty(phpbb::$user->lang[$msg_text]) ? phpbb::$user->lang[$msg_text] : $msg_text;
            $msg_title = !isset($msg_title) ? phpbb::$user->lang['INFORMATION'] : (!empty(phpbb::$user->lang[$msg_title]) ? phpbb::$user->lang[$msg_title] : $msg_title);
            if (!defined('HEADER_INC')) {
                if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']) {
                    adm_page_header($msg_title);
                } else {
                    titania::page_header($msg_title);
                }
            }
            phpbb::$template->set_filenames(array('body' => 'common/message_body.html'));
            phpbb::$template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text . titania_backtrace(), 'S_USER_WARNING' => $errno == E_USER_WARNING ? true : false, 'S_USER_NOTICE' => $errno == E_USER_NOTICE ? true : false));
            // We do not want the cron script to be called on error messages
            define('IN_CRON', true);
            if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']) {
                adm_page_footer();
            } else {
                titania::page_footer(false);
            }
            exit_handler();
            break;
    }
    // If we notice an error not handled here we pass this back to PHP by returning false
    // This may not work for all php versions
    return false;
}
    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');
    }
示例#8
0
    }
    titania::add_lang('posting');
    phpbb::$user->add_lang('mcp');
    if (titania::confirm_box(true)) {
        $message = utf8_normalize_nfc(request_var('report_text', '', true));
        titania::$contrib->report($message);
        // Notifications
        redirect(titania::$contrib->get_url());
    } else {
        //phpbb::$template->assign_var('S_CAN_NOTIFY', ((phpbb::$user->data['is_registered']) ? true : false));
        titania::confirm_box(false, 'REPORT_CONTRIBUTION', '', array(), 'posting/report_body.html');
    }
    redirect(titania::$contrib->get_url());
}
titania::$contrib->get_download();
titania::$contrib->get_revisions();
titania::$contrib->get_screenshots();
titania::$contrib->get_rating();
titania::$contrib->assign_details();
if (!phpbb::$user->data['is_bot']) {
    titania::$contrib->increase_view_counter();
}
// Set tracking
titania_tracking::track(TITANIA_CONTRIB, titania::$contrib->contrib_id);
// Subscriptions
titania_subscriptions::handle_subscriptions(TITANIA_CONTRIB, titania::$contrib->contrib_id, titania::$contrib->get_url());
// Canonical URL
phpbb::$template->assign_var('U_CANONICAL', titania::$contrib->get_url());
titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['CONTRIB_DETAILS']);
titania::page_footer(true, 'contributions/contribution_details.html');
示例#9
0
if ($topic_id) {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic_id, $topic->get_url());
    // Check access level
    if ($topic->topic_access < titania::$access_level || $topic->topic_type == TITANIA_QUEUE_DISCUSSION && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('queue_discussion')) {
        titania::needs_auth();
    }
    posts_overlord::display_topic_complete($topic);
    titania::page_header(censor_text($topic->topic_subject) . ' - ' . titania::$contrib->contrib_name);
    if (phpbb::$auth->acl_get('u_titania_post')) {
        phpbb::$template->assign_var('U_POST_REPLY', titania_url::append_url($topic->get_url(), array('action' => 'reply')));
    }
    // Canonical URL
    phpbb::$template->assign_var('U_CANONICAL', $topic->get_url());
} else {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_SUPPORT, titania::$contrib->contrib_id, titania::$contrib->get_url('support'));
    // Mark all topics read
    if (request_var('mark', '') == 'topics') {
        titania_tracking::track(TITANIA_SUPPORT, titania::$contrib->contrib_id);
    }
    $data = topics_overlord::display_forums_complete('support', titania::$contrib);
    titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['CONTRIB_SUPPORT']);
    if (phpbb::$auth->acl_get('u_titania_topic') && titania::$config->support_in_titania) {
        phpbb::$template->assign_var('U_POST_TOPIC', titania_url::append_url(titania::$contrib->get_url('support'), array('action' => 'post')));
    }
    $data['sort']->set_url(titania::$contrib->get_url('support'));
    phpbb::$template->assign_vars(array('U_MARK_TOPICS' => titania_url::append_url(titania::$contrib->get_url('support'), array('mark' => 'topics')), 'U_CANONICAL' => $data['sort']->build_canonical(), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('search', array('type' => TITANIA_SUPPORT, 'contrib' => titania::$contrib->contrib_id))));
}
titania::page_footer(true, 'contributions/contribution_support.html');
示例#10
0
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $contrib_categories[] = $row['category_id'];
        }
        phpbb::$db->sql_freeresult($result);
        $active_coauthors = $nonactive_coauthors = array();
        foreach (titania::$contrib->coauthors as $row) {
            // User does not exist anymore...
            if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) {
                continue;
            }
            if ($row['active']) {
                $active_coauthors[] = users_overlord::get_user($row['user_id'], 'username');
            } else {
                $nonactive_coauthors[] = users_overlord::get_user($row['user_id'], 'username');
            }
        }
        $active_coauthors = implode("\n", $active_coauthors);
        $nonactive_coauthors = implode("\n", $nonactive_coauthors);
    }
}
// Generate some stuff
generate_category_select($contrib_categories);
titania::$contrib->assign_details();
$message->display();
foreach ($status_list as $status => $row) {
    phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == titania::$contrib->contrib_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row]));
}
phpbb::$template->assign_vars(array('S_POST_ACTION' => titania::$contrib->get_url('manage'), 'S_EDIT_SUBJECT' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_DELETE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'S_IS_OWNER' => titania::$contrib->is_author ? true : false, 'S_IS_MODERATOR' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? true : false, 'CONTRIB_PERMALINK' => $permalink, 'SCREENSHOT_UPLOADER' => $screenshot->parse_uploader('posting/attachments/simple.html'), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0));
titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['MANAGE_CONTRIBUTION']);
titania::page_footer(true, 'contributions/contribution_manage.html');
示例#11
0
                $queue->move($new_tag);
            } else {
                // Generate the list of tags we can move it to
                $extra = '<select name="id">';
                foreach ($tags as $tag_id => $row) {
                    $extra .= '<option value="' . $tag_id . '">' . (isset(phpbb::$user->lang[$row['tag_field_name']]) ? phpbb::$user->lang[$row['tag_field_name']] : $row['tag_field_name']) . '</option>';
                }
                $extra .= '</select>';
                phpbb::$template->assign_var('CONFIRM_EXTRA', $extra);
                titania::confirm_box(false, 'MOVE_QUEUE');
            }
            redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id)));
            break;
    }
    // Display the main queue item
    $data = queue_overlord::display_queue_item($queue_id);
    // Handle replying/editing/etc
    $posting_helper = new titania_posting();
    $posting_helper->act('manage/queue_post.html');
    // Display the posts in the queue (after the posting helper acts)
    posts_overlord::display_topic_complete($data['topic']);
    titania::page_header(queue_overlord::$queue[$queue_id]['topic_subject']);
} else {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_QUEUE, $queue_type, titania_url::$current_page_url);
    queue_overlord::display_queue($queue_type, $tag);
    queue_overlord::display_categories($queue_type, $tag);
    titania::page_header('VALIDATION_QUEUE');
}
titania::page_footer(true, 'manage/queue.html');
示例#12
0
 /**
  * Load the requested tool
  *
  * @param String $tool_name The name of this tool
  * @param Boolean $return Specify whether an object of this tool will be returned
  * @return The object of the requested tool if $return is set to true else this method will return true
  */
 function load_tool($tool_name, $return = true)
 {
     global $user;
     static $tools_loaded = array();
     if (isset($tools_loaded[$tool_name])) {
         return $return ? $tools_loaded[$tool_name] : true;
     }
     $tool_path = $this->tool_box_path . $tool_name . '.' . PHP_EXT;
     if (false === @(include $tool_path)) {
         trigger_error(sprintf($user->lang['TOOL_INCLUTION_NOT_FOUND'], $tool_path), E_USER_ERROR);
     }
     if (!class_exists($tool_name)) {
         trigger_error(sprintf($user->lang['INCORRECT_CLASS'], $tool_name, PHP_EXT), E_USER_ERROR);
     }
     // Construct the class
     $tools_loaded[$tool_name] = new $tool_name();
     // Add the language file
     titania::add_lang('manage_tools/' . $tool_name);
     // Return
     return $return ? $tools_loaded[$tool_name] : true;
 }
示例#13
0
/**
* 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;
        break;
    default:
        include TITANIA_ROOT . 'manage/queue.' . PHP_EXT;
        exit;
        break;
}
示例#14
0
            if (!isset($versions[(int) $revision_phpbb_version[0] . (int) $revision_phpbb_version[2] . substr($revision_phpbb_version, 4)])) {
                // Have we added some new phpBB version that does not exist?  We need to purge the cache then
                titania::$cache->destroy('_titania_phpbb_versions');
            }
            // Update the list of phpbb_versions for the revision to update
            $revision->phpbb_versions[] = array('phpbb_version_branch' => (int) $revision_phpbb_version[0] . (int) $revision_phpbb_version[2], 'phpbb_version_revision' => substr($revision_phpbb_version, 4));
        }
        // Submit the translations
        $translation->submit();
        $revision->submit();
        redirect(titania::$contrib->get_url());
    }
}
// Output the available license options
foreach (titania_types::$types[titania::$contrib->contrib_type]->license_options as $option) {
    phpbb::$template->assign_block_vars('license_options', array('NAME' => $option, 'VALUE' => $option));
}
// Display the list of phpBB versions available
foreach ($phpbb_versions as $version => $name) {
    $template->assign_block_vars('phpbb_versions', array('VERSION' => $name, 'S_SELECTED' => in_array($name, $revision_phpbb_versions) ? true : false));
}
// Display the status list
foreach ($status_list as $status => $row) {
    phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == $revision_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row]));
}
// Display the rest of the page
phpbb::$template->assign_vars(array('ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'REVISION_NAME' => $revision->revision_name, 'REVISION_LICENSE' => $revision->revision_license, 'REVISION_CUSTOM_LICENSE' => !in_array($revision->revision_license, titania_types::$types[titania::$contrib->contrib_type]->license_options) ? $revision->revision_license : '', 'TRANSLATION_UPLOADER' => titania_types::$types[titania::$contrib->contrib_type]->extra_upload ? $translation->parse_uploader('posting/attachments/simple.html') : '', 'S_IS_MODERATOR' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_POST_ACTION' => titania::$contrib->get_url('revision_edit', array('revision' => $revision_id)), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'S_CUSTOM_LICENSE' => !in_array($revision->revision_license, titania_types::$types[titania::$contrib->contrib_type]->license_options) ? true : false, 'S_ALLOW_CUSTOM_LICENSE' => titania_types::$types[titania::$contrib->contrib_type]->license_allow_custom ? true : false));
add_form_key('postform');
titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['EDIT_REVISION']);
titania::page_footer(true, 'contributions/contribution_revision_edit.html');
示例#15
0
    /*$close = (isset($_POST['close'])) ? true : false;
    	$id_list = request_var('id_list', array(0));
    
    	if ($close && sizeof($id_list))
    	{
    		$attention_object = new titania_attention;
    		foreach ($id_list as $attention_id)
    		{
    			$attention_object->attention_id = $attention_id;
    			$attention_object->load();
    		}
    	}*/
    switch ($type) {
        case 'reported':
            $type = TITANIA_ATTENTION_REPORTED;
            break;
        case 'unapproved':
            $type = TITANIA_ATTENTION_UNAPPROVED;
            break;
        default:
            $type = false;
            break;
    }
    $options = array('attention_type' => $type, 'display_closed' => $closed, 'only_closed' => !$open && $closed ? true : false);
    attention_overlord::display_attention_list($options);
    phpbb::$template->assign_vars(array('S_ACTION' => titania_url::build_url('manage/attention'), 'S_OPEN_CHECKED' => $open, 'S_CLOSED_CHECKED' => $closed));
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_ATTENTION, 0, titania_url::build_url('manage/attention'));
    titania::page_header('ATTENTION');
    titania::page_footer(true, 'manage/attention.html');
}
示例#16
0
 private function common_delete($post_id, $undelete = false)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('posting');
     // Load the stuff we need
     $post_object = $this->load_post($post_id);
     // Check permissions
     if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) {
         titania::needs_auth();
     }
     if (titania::confirm_box(true)) {
         if (!$undelete) {
             $redirect_post_id = false;
             // Delete the post
             if (isset($_POST['hard_delete']) || $post_object->post_deleted) {
                 if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
                     titania::needs_auth();
                 }
                 $post_object->hard_delete();
                 // Try to redirect to the next or previous post
                 $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                 if ($redirect_post_id) {
                     redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                 }
                 redirect(titania_url::build_url($post_object->topic->topic_url));
             } else {
                 $post_object->soft_delete();
                 if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
                     // They can see the post, redirect back to it
                     redirect($post_object->get_url());
                 } else {
                     // They cannot see the post, try to redirect to the next or previous post
                     $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                     if ($redirect_post_id) {
                         redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                     }
                 }
             }
             redirect($post_object->topic->get_url());
         } else {
             $post_object->undelete();
             redirect($post_object->get_url());
         }
     } else {
         phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false);
         titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html');
     }
     redirect($post_object->get_url());
 }
 function pva_generate_category_select()
 {
     titania::_include('functions_posting', 'generate_category_select');
     phpbb::$template->destroy_block_vars('category_select');
     generate_category_select();
     phpbb::$template->set_filenames(array('generate_category_select' => 'manage/generate_category_select.html'));
     $select = phpbb::$template->assign_display('generate_category_select');
     return $select;
 }
            $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));
            }
            phpbb::$template->assign_vars(array('S_QUEUE_LIST' => true));
            titania::page_header('QUEUE_DISCUSSION');
            titania::page_footer(true, 'manage/queue.html');
        }
    }
} else {
    if (!titania_types::$types[$queue_type]->acl_get('queue_discussion')) {
        titania::needs_auth();
    }
}
// Add the queue type to the base url
$base_url = titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_type]->url));
// Add to Breadcrumbs
titania::generate_breadcrumbs(array(titania_types::$types[$queue_type]->lang => $base_url));
topics_overlord::display_forums_complete('queue_discussion', false, array('topic_category' => $queue_type));
// Mark all topics read
phpbb::$template->assign_var('U_MARK_TOPICS', titania_url::append_url($base_url, array('mark' => 'topics')));
titania::page_header('QUEUE_DISCUSSION');
titania::page_footer(true, 'manage/queue_discussion.html');
示例#19
0
                        phpbb::$db->sql_freeresult($result);
                        break;
                }
                if ($contrib !== false) {
                    if ($contrib['contrib_user_id'] == phpbb::$user->data['user_id']) {
                        // Main author
                        titania::$access_level = TITANIA_ACCESS_AUTHORS;
                    } else {
                        // Coauthor
                        $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . '
				WHERE contrib_id = ' . $contrib['contrib_id'] . '
					AND user_id = ' . phpbb::$user->data['user_id'] . '
					AND active = 1';
                        $result = phpbb::$db->sql_query($sql);
                        if (phpbb::$db->sql_fetchrow($result)) {
                            titania::$access_level = TITANIA_ACCESS_AUTHORS;
                        }
                        phpbb::$db->sql_freeresult($result);
                    }
                }
                // Still not authorised?
                if ($attachment['attachment_access'] < titania::$access_level) {
                    header('HTTP/1.0 403 Forbidden');
                    trigger_error('SORRY_AUTH_VIEW_ATTACH');
                }
            }
        }
    }
}
/*
* Can not currently be done with the way extensions are setup... @todo?
示例#20
0
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
require TITANIA_ROOT . 'common.' . PHP_EXT;
titania::add_lang('faq', false, true);
/**
* From phpBB faq.php
*/
// Pull the array data from the lang pack
$switch_column = $found_switch = false;
$help_blocks = array();
foreach (phpbb::$user->help as $help_ary) {
    if ($help_ary[0] == '--') {
        if ($help_ary[1] == '--') {
            $switch_column = true;
            $found_switch = true;
            continue;
        }
        phpbb::$template->assign_block_vars('faq_block', array('BLOCK_TITLE' => $help_ary[1], 'SWITCH_COLUMN' => $switch_column));
        if ($switch_column) {
            $switch_column = false;
        }
        continue;
    }
    phpbb::$template->assign_block_vars('faq_block.faq_row', array('FAQ_QUESTION' => $help_ary[0], 'FAQ_ANSWER' => $help_ary[1]));
}
// Lets build a page ...
phpbb::$template->assign_vars(array('L_FAQ_TITLE' => phpbb::$user->lang['FAQ_EXPLAIN'], 'L_BACK_TO_TOP' => phpbb::$user->lang['BACK_TO_TOP'], 'SWITCH_COLUMN_MANUALLY' => !$found_switch ? true : false));
titania::page_header('FAQ_EXPLAIN');
titania::page_footer(true, 'faq_body.html');
示例#21
0
function phpbb_com_titania_post_edit($hook, &$post_object)
{
    if (defined('IN_TITANIA_CONVERT') || !$post_object->phpbb_post_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->post_type);
    if (!$forum_id) {
        return;
    }
    titania::_include('functions_posting', 'phpbb_posting');
    $post_text = $post_object->post_text;
    titania_decode_message($post_text, $post_object->post_text_uid);
    $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url());
    $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text);
    phpbb_posting('edit', $options);
}
 /**
  * Run common initial tasks.
  *
  * @return null
  */
 protected function setup()
 {
     $this->user->add_lang('acp/common');
     // Setup the plugin manager
     \titania::_include('manage_tools/manage_plugin', false, 'manage_plugin');
     $this->plugin = new \manage_plugin($this->helper);
 }
示例#23
0
 public function extract($archive, $target, $check_minimum_directory = true)
 {
     if (!file_exists($archive)) {
         trigger_error(sprintf(phpbb::$user->lang['FILE_NOT_EXIST'], basename($archive)));
     }
     // Some simple file protection to prevent getting out of the titania root
     if ($check_minimum_directory) {
         if (!$this->check_filesystem_path($archive)) {
             return false;
         }
         if (!$this->check_filesystem_path($target)) {
             return false;
         }
     }
     // Clear out old stuff if there is anything here...
     $this->rmdir_recursive($target);
     // Using the phpBB ezcomponents loader
     titania::_include('library/ezcomponents/loader', false, 'phpbb_ezcomponents_loader');
     phpbb_ezcomponents_loader::load_component('archive');
     // ezcomponents archive handler
     $ezcarchive = ezcArchive::open($archive, ezcArchive::ZIP);
     $ezcarchive->extract($target);
     $ezcarchive->close();
 }
示例#24
0
            // Parents
            foreach (array_reverse(titania::$cache->get_category_parents($category_id)) as $row) {
                $category_object->__set_array($categories_ary[$row['category_id']]);
                titania::generate_breadcrumbs(array(isset(phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']]) ? phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']] : $categories_ary[$row['category_id']]['category_name'] => titania_url::build_url('manage/categories', array('c' => $row['category_id']))));
            }
            // Self
            $category_object->__set_array($categories_ary[$category_id]);
            titania::generate_breadcrumbs(array(isset(phpbb::$user->lang[$categories_ary[$category_id]['category_name']]) ? phpbb::$user->lang[$categories_ary[$category_id]['category_name']] : $categories_ary[$category_id]['category_name'] => titania_url::build_url('manage/categories', array('c' => $category_id))));
            // Second set of breadcrumbs for category navigation
            // Parents
            foreach (array_reverse(titania::$cache->get_category_parents($category_id)) as $row) {
                $category_object->__set_array($categories_ary[$row['category_id']]);
                titania::generate_breadcrumbs(array(isset(phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']]) ? phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']] : $categories_ary[$row['category_id']]['category_name'] => titania_url::build_url('manage/categories', array('c' => $row['category_id']))), $block = 'nav_categories');
            }
            // Self
            $category_object->__set_array($categories_ary[$category_id]);
            titania::generate_breadcrumbs(array(isset(phpbb::$user->lang[$categories_ary[$category_id]['category_name']]) ? phpbb::$user->lang[$categories_ary[$category_id]['category_name']] : $categories_ary[$category_id]['category_name'] => titania_url::build_url('manage/categories', array('c' => $category_id))), $block = 'nav_categories');
            unset($categories_ary, $category_object);
        }
        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'] . '" />', 'SECTION_NAME' => '<a href="' . titania_url::build_url('manage/categories') . '">' . phpbb::$user->lang['MANAGE_CATEGORIES'] . '</a>', 'U_CREATE_CATEGORY' => titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'add')), 'U_MANAGE_CATEGORIES' => titania_url::build_url('manage/categories'), 'S_MANAGE' => true));
        break;
}
function trigger_back($message)
{
    $message = isset(phpbb::$user->lang[$message]) ? phpbb::$user->lang[$message] : $message;
    $message .= '<br /><br /><a href="' . titania_url::build_url('manage/categories') . '">' . phpbb::$user->lang['BACK'] . '</a>';
    trigger_error($message);
}
titania::page_header('MANAGE_CATEGORIES');
titania::page_footer(true, 'manage/categories.html');
    /**
     * Run the tool
     */
    function run_tool()
    {
        // Define some vars that we'll need
        $start = request_var('start', 0);
        $limit = 100;
        // Create topic if it does not exist?
        $create_topic = true;
        titania::_include('functions_posting', 'phpbb_posting');
        titania::add_lang('contributions');
        $types = array();
        foreach (titania_types::$types as $id => $class) {
            if ($class->forum_robot && $class->forum_database) {
                $types[] = $id;
            }
        }
        if (!sizeof($types)) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        }
        $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
        phpbb::$db->sql_query($sql);
        $total = phpbb::$db->sql_fetchfield('cnt');
        phpbb::$db->sql_freeresult();
        // Grab our batch
        $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
				t.topic_first_post_id,
				u.user_id, u.username, u.username_clean, u.user_colour', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c', USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 't.topic_id = c.contrib_release_topic_id')), 'GROUP_BY' => 'c.contrib_id', 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND u.user_id = c.contrib_user_id
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types), 'ORDER_BY' => 'c.contrib_id DESC');
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Grab the revisions
            $revisions = array();
            $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
				FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
				WHERE r.contrib_id = ' . $row['contrib_id'] . '
					AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
					AND a.attachment_id = r.attachment_id';
            $rev_result = phpbb::$db->sql_query($sql);
            while ($rev_row = phpbb::$db->sql_fetchrow($rev_result)) {
                $revisions[$rev_row['revision_version']] = $rev_row;
            }
            phpbb::$db->sql_freeresult($rev_result);
            // Sort the revisions by their version, put the newest one in $revision
            uksort($revisions, 'reverse_version_compare');
            if (!sizeof($revisions)) {
                continue;
            }
            $revision = array_shift($revisions);
            users_overlord::$users[$row['user_id']] = $row;
            $contrib = new titania_contribution();
            $contrib->__set_array($row);
            $contrib->download = $row;
            // Update the release topic
            $contrib->update_release_topic();
        }
        phpbb::$db->sql_freeresult($result);
        if ($start + $limit >= $total) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        } else {
            meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
            trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', $start + $limit, $total));
        }
    }
示例#26
0
 /**
  * Generate login box or verify password
  */
 function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
 {
     self::_include('captcha/captcha_factory', 'phpbb_captcha_factory');
     self::$user->add_lang('ucp');
     $err = '';
     // Make sure user->setup() has been called
     if (empty(self::$user->lang)) {
         self::$user->setup();
     }
     // Print out error if user tries to authenticate as an administrator without having the privileges...
     if ($admin && !self::$auth->acl_get('a_')) {
         // Not authd
         // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
         if (self::$user->data['is_registered']) {
             add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
         }
         trigger_error('NO_AUTH_ADMIN');
     }
     if (isset($_POST['login'])) {
         // Get credential
         if ($admin) {
             $credential = request_var('credential', '');
             if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) {
                 if (self::$user->data['is_registered']) {
                     add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
                 }
                 trigger_error('NO_AUTH_ADMIN');
             }
             $password = request_var('password_' . $credential, '', true);
         } else {
             $password = request_var('password', '', true);
         }
         $username = request_var('username', '', true);
         $autologin = !empty($_POST['autologin']) ? true : false;
         $viewonline = !empty($_POST['viewonline']) ? 0 : 1;
         $admin = $admin ? 1 : 0;
         $viewonline = $admin ? self::$user->data['session_viewonline'] : $viewonline;
         // Check if the supplied username is equal to the one stored within the database if re-authenticating
         if ($admin && utf8_clean_string(self::$username) != utf8_clean_string(self::$user->data['username'])) {
             // We log the attempt to use a different username...
             add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
             trigger_error('NO_AUTH_ADMIN_USER_DIFFER');
         }
         // If authentication is successful we redirect user to previous page
         $result = self::$auth->login($username, $password, $autologin, $viewonline, $admin);
         // If admin authentication and login, we will log if it was a success or not...
         // We also break the operation on the first non-success login - it could be argued that the user already knows
         if ($admin) {
             if ($result['status'] == LOGIN_SUCCESS) {
                 add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS');
             } else {
                 // Only log the failed attempt if a real user tried to.
                 // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
                 if (self::$user->data['is_registered']) {
                     add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
                 }
             }
         }
         // The result parameter is always an array, holding the relevant information...
         if ($result['status'] == LOGIN_SUCCESS) {
             $redirect = request_var('redirect', '');
             if ($redirect) {
                 $redirect = titania_url::unbuild_url($redirect);
                 $base = $append = false;
                 titania_url::split_base_params($base, $append, $redirect);
                 redirect(titania_url::build_url($base, $append));
             } else {
                 redirect(titania_url::build_url(titania_url::$current_page, titania_url::$params));
             }
         }
         // Something failed, determine what...
         if ($result['status'] == LOGIN_BREAK) {
             trigger_error($result['error_msg']);
         }
         // Special cases... determine
         switch ($result['status']) {
             case LOGIN_ERROR_ATTEMPTS:
                 $captcha = phpbb_captcha_factory::get_instance(self::$config['captcha_plugin']);
                 $captcha->init(CONFIRM_LOGIN);
                 // $captcha->reset();
                 // Parse the captcha template
                 self::reset_template();
                 self::$template->set_filenames(array('captcha' => $captcha->get_template()));
                 // Correct confirm image link
                 self::$template->assign_var('CONFIRM_IMAGE_LINK', self::append_sid('ucp', 'mode=confirm&amp;confirm_id=' . $captcha->confirm_id . '&amp;type=' . $captcha->type));
                 self::$template->assign_display('captcha', 'CAPTCHA', false);
                 titania::set_custom_template();
                 $err = self::$user->lang[$result['error_msg']];
                 break;
             case LOGIN_ERROR_PASSWORD_CONVERT:
                 $err = sprintf(self::$user->lang[$result['error_msg']], self::$config['email_enable'] ? '<a href="' . self::append_sid('ucp', 'mode=sendpassword') . '">' : '', self::$config['email_enable'] ? '</a>' : '', self::$config['board_contact'] ? '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">' : '', self::$config['board_contact'] ? '</a>' : '');
                 break;
                 // Username, password, etc...
             // Username, password, etc...
             default:
                 $err = self::$user->lang[$result['error_msg']];
                 // Assign admin contact to some error messages
                 if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') {
                     $err = !self::$config['board_contact'] ? sprintf(self::$user->lang[$result['error_msg']], '', '') : sprintf(self::$user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">', '</a>');
                 }
                 break;
         }
     }
     // Assign credential for username/password pair
     $credential = $admin ? md5(unique_id()) : false;
     $s_hidden_fields = array('sid' => self::$user->session_id);
     if ($redirect) {
         $s_hidden_fields['redirect'] = $redirect;
     }
     if ($admin) {
         $s_hidden_fields['credential'] = $credential;
     }
     $s_hidden_fields = build_hidden_fields($s_hidden_fields);
     titania::page_header('LOGIN');
     self::$template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => self::$config['email_enable'] ? self::append_sid('ucp', 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => self::$config['require_activation'] == USER_ACTIVATION_SELF && self::$config['email_enable'] ? self::append_sid('ucp', 'mode=resend_act') : '', 'U_TERMS_USE' => self::append_sid('ucp', 'mode=terms'), 'U_PRIVACY' => self::append_sid('ucp', 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? self::$user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password'));
     titania::page_footer(true, 'login_body.html');
 }
示例#27
0
 /**
  * Display the message box
  */
 public function display()
 {
     $for_edit = $this->post_object->generate_text_for_edit();
     // Initialize our post options class
     $post_options = new post_options();
     $post_options->set_auth($this->auth['bbcode'], $this->auth['smilies'], true, true, true);
     $post_options->set_status($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']);
     // Setup the attachments!
     $this->setup_attachments();
     if ($this->auth['polls']) {
         $this->posting_panels['poll-panel'] = 'POLL';
     }
     // Add the forum key
     add_form_key($this->settings['form_name']);
     // Generate smiley listing
     if ($post_options->get_status('smilies')) {
         phpbb::_include('functions_posting', 'generate_smilies');
         generate_smilies('inline', false);
     }
     // Build custom bbcodes array
     if ($post_options->get_status('bbcode')) {
         phpbb::_include('functions_display', 'display_custom_bbcodes');
         display_custom_bbcodes();
     }
     // Display the Captcha if required
     if ($this->settings['display_captcha']) {
         phpbb::_include('captcha/captcha_factory', false, 'phpbb_captcha_factory');
         $captcha =& phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']);
         $captcha->init(CONFIRM_POST);
         if ($captcha->validate($this->request_data()) !== false) {
             phpbb::reset_template();
             // Parse the captcha template
             phpbb::$template->set_filenames(array('captcha' => $captcha->get_template()));
             // Correct confirm image link
             phpbb::$template->assign_var('CONFIRM_IMAGE_LINK', phpbb::append_sid('ucp', 'mode=confirm&amp;confirm_id=' . $captcha->confirm_id . '&amp;type=' . $captcha->type));
             phpbb::$template->assign_display('captcha', 'CAPTCHA', false);
             titania::set_custom_template();
         }
         $this->s_hidden_fields = array_merge($this->s_hidden_fields, $captcha->get_hidden_fields());
     }
     $post_options->set_in_template();
     // Save the opened panel to show again
     $default_panel = request_var('open_panel', 'options-panel');
     $default_panel = isset($this->posting_panels[$default_panel]) ? $default_panel : 'options-panel';
     phpbb::$template->assign_vars(array('ACCESS_OPTIONS' => titania_access_select(isset($for_edit['access']) ? $for_edit['access'] : TITANIA_ACCESS_PUBLIC), 'EDIT_REASON' => isset($for_edit['edit_reason']) ? $for_edit['edit_reason'] : '', 'POSTING_FORM_NAME' => $this->settings['form_name'], 'POSTING_TEXT_NAME' => $this->settings['text_name'], 'POSTING_SUBJECT_NAME' => $this->settings['subject_name'], 'POSTING_PANELS_DEFAULT' => $default_panel, 'POSTING_TEXT' => $this->settings['text_default_override'] !== false ? $this->settings['text_default_override'] : $for_edit['text'], 'SUBJECT' => $this->settings['subject_default_override'] !== false ? $this->settings['subject_default_override'] : (isset($for_edit['subject']) ? $for_edit['subject'] : ''), 'S_ENHANCED_EDITOR' => phpbb::$user->data['titania_enhanced_editor'], 'S_DISPLAY_ERROR' => $this->settings['display_error'], 'S_DISPLAY_SUBJECT' => $this->settings['display_subject'], 'S_STICKY_TOPIC_ALLOWED' => $this->auth['sticky_topic'], 'S_STICKY_TOPIC_CHECKED' => isset($for_edit['topic_sticky']) ? $for_edit['topic_sticky'] : false, 'S_LOCK_TOPIC_ALLOWED' => $this->auth['lock_topic'], 'S_LOCK_TOPIC_CHECKED' => isset($for_edit['topic_locked']) ? $for_edit['topic_locked'] : false, 'S_LOCK_POST_ALLOWED' => $this->auth['lock'], 'S_LOCK_POST_CHECKED' => isset($for_edit['locked']) ? $for_edit['locked'] : false, 'S_EDIT_REASON' => $this->settings['display_edit_reason'], 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields)));
     if ($this->attachments) {
         phpbb::$template->assign_vars(array('UPLOADER' => $this->attachments->parse_uploader($this->settings['attachment_tpl']), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"'));
     }
     $this->display_panels();
 }
示例#28
0
				$url_params = substr($url_base, (strrpos($url_base, '/') + 1));
				$url_base = substr($url_base, 0, (strrpos($url_base, '/') + 1));
			}

			phpbb::$template->assign_block_vars('searchresults', array(
				'TOPIC_TITLE'		=> censor_text($document->title),

				'TOPIC_AUTHOR_FULL'	=> users_overlord::get_user($document->author, '_full'),
				'FIRST_POST_TIME'	=> phpbb::$user->format_date($document->date),

				'U_VIEW_TOPIC'		=> titania_url::build_url($url_base, $url_params),

				'S_TOPIC_REPORTED'		=> ($document->reported) ? true : false,
				//'S_TOPIC_UNAPPROVED'	=> (!$document->approved) ? true : false,
			));
		}
	break;

	default : */
foreach ($results['documents'] as $document) {
    $url_base = $url_params = '';
    titania_url::split_base_params($url_base, $url_params, $document->url);
    phpbb::$template->assign_block_vars('searchresults', array('POST_SUBJECT' => censor_text($document->title), 'MESSAGE' => titania_generate_text_for_display($document->text, $document->text_uid, $document->text_bitfield, $document->text_options), 'POST_AUTHOR_FULL' => $document->author ? users_overlord::get_user($document->author, '_full') : false, 'POST_DATE' => $document->date ? phpbb::$user->format_date($document->date) : false, 'U_VIEW_POST' => titania_url::build_url($url_base, $url_params), 'S_POST_REPORTED' => $document->reported ? true : false));
}
/*	break;
}*/
$sort->build_pagination(titania_url::$current_page, titania_url::$params);
titania::page_header('SEARCH');
phpbb::$template->assign_vars(array('SEARCH_WORDS' => $keywords, 'SEARCH_MATCHES' => $sort->total == 1 ? sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCH'], $sort->total) : sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCHES'], $sort->total), 'U_SEARCH_WORDS' => titania_url::build_url(titania_url::$current_page, titania_url::$params), 'U_SEARCH' => titania_url::build_url($mode == 'find-contribution' ? 'find-contribution' : 'search'), 'S_IN_SEARCH' => true, 'S_SEARCH_ACTION' => titania_url::$current_page_url));
titania::page_footer(true, 'search_results.html');
示例#29
0
    /**
     * 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');
    }
示例#30
0
    /**
     * Repack a revision
     *
     * @param titania_revision $old_revision titania_revision object
     */
    public function repack($old_revision)
    {
        if (!$this->revision_id) {
            throw new exception('Submit the revision before repacking');
        }
        titania::add_lang('manage');
        // Get the old and new queue objects
        $old_queue = $old_revision->get_queue();
        $queue = $this->get_queue();
        if ($old_queue === false) {
            throw new exception('Old queue missing. Revision ID: ' . $old_revision->revision_id);
        }
        // Reply to the queue topic to say that it's been repacked and have the old mpv/automod results listed in it as well
        $repack_message = phpbb::$user->lang['REVISION_REPACKED'] . "\n\n";
        // Add the MPV results
        if ($old_queue->mpv_results) {
            $mpv_results = $old_queue->mpv_results;
            titania_decode_message($mpv_results, $old_queue->mpv_results_uid);
            $repack_message .= '[quote=&quot;' . phpbb::$user->lang['OLD_VALIDATION_MPV'] . '&quot;]' . $mpv_results . "[/quote]\n";
        }
        // Add the Automod results
        if ($old_queue->automod_results) {
            $repack_message .= '[quote=&quot;' . phpbb::$user->lang['OLD_VALIDATION_AUTOMOD'] . '&quot;]' . $old_queue->automod_results . "[/quote]\n";
        }
        // Reply
        $old_queue->topic_reply($repack_message);
        // Update the old queue with the new results
        $old_queue->revision_id = $queue->revision_id;
        $old_queue->mpv_results = $queue->mpv_results;
        $old_queue->mpv_results_bitfield = $queue->mpv_results_bitfield;
        $old_queue->mpv_results_uid = $queue->mpv_results_uid;
        $old_queue->automod_results = $queue->automod_results;
        $old_queue->submit();
        // Delete the new queue we made for this revision
        $queue->delete();
        // Unlink the old queue_id from the old revision and set it to repacked
        $old_revision->change_status(TITANIA_REVISION_REPACKED);
        $old_revision->revision_queue_id = 0;
        $old_revision->submit();
        // Update the queue_id for this revision to point to the old queue_id
        $this->revision_queue_id = $old_queue->queue_id;
        $this->submit();
        // Move any translations
        $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . '
			SET object_id = ' . $this->revision_id . '
			WHERE object_type = ' . TITANIA_TRANSLATION . '
				AND object_id = ' . $old_revision->revision_id;
        phpbb::$db->sql_query($sql);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
    }