/** * 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 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); }
/** * * @package titania * @version $Id$ * @copyright (c) 2008 phpBB Customisation Database Team * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * */ /** * @ignore */ if (!defined('IN_TITANIA')) { exit; } titania::_include('functions_posting', 'generate_type_select'); load_contrib(); // Used later when submitting $contrib_clone = clone titania::$contrib; if (!((titania::$contrib->is_author || titania::$contrib->is_active_coauthor) && phpbb::$auth->acl_get('u_titania_post_edit_own') && !in_array(titania::$contrib->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate'))) { titania::needs_auth(); } // Set some main vars up $submit = isset($_POST['submit']) ? true : false; $change_owner = request_var('change_owner', '', true); // Blame Nathan, he said this was okay $contrib_categories = request_var('contrib_category', array(0)); $contrib_demo = utf8_normalize_nfc(request_var('demo_url', '', true)); $active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true)); $nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true)); $error = array();
* * 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();
public function display($tpl_block = 'revisions', $show_queue = false) { titania::_include('functions_display', 'order_phpbb_version_list_from_db'); $ordered_phpbb_versions = order_phpbb_version_list_from_db($this->phpbb_versions); // Get rid of the day of the week if it exists in the dateformat $old_date_format = phpbb::$user->date_format; phpbb::$user->date_format = str_replace('D ', '', phpbb::$user->date_format); phpbb::$template->assign_block_vars($tpl_block, array('REVISION_ID' => $this->revision_id, 'CREATED' => phpbb::$user->format_date($this->revision_time), 'NAME' => $this->revision_name ? censor_text($this->revision_name) : ($this->contrib ? $this->contrib->contrib_name . ' ' . $this->revision_version : ''), 'VERSION' => $this->revision_version, 'VALIDATED_DATE' => $this->validation_date ? phpbb::$user->format_date($this->validation_date) : phpbb::$user->lang['NOT_VALIDATED'], 'REVISION_QUEUE' => $show_queue && $this->revision_queue_id ? titania_url::build_url('manage/queue', array('q' => $this->revision_queue_id)) : '', 'PHPBB_VERSION' => sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'REVISION_LICENSE' => $this->revision_license ? censor_text($this->revision_license) : ($this->contrib && sizeof(titania_types::$types[$this->contrib->contrib_type]->license_options) ? phpbb::$user->lang['UNKNOWN'] : ''), 'U_DOWNLOAD' => $this->get_url(), 'U_EDIT' => $this->contrib && ($this->contrib->is_author || $this->contrib->is_active_coauthor || titania_types::$types[$this->contrib->contrib_type]->acl_get('moderate')) ? $this->contrib->get_url('revision_edit', array('revision' => $this->revision_id)) : '', 'U_VIEW_INSTALL' => titania_types::$types[$this->contrib->contrib_type]->display_install_file && file_exists(titania::$config->modx_storage_path . $this->revision_id) ? titania_url::build_url('view-install', array('id' => $this->revision_id)) : '', 'S_USE_QUEUE' => titania::$config->use_queue && titania_types::$types[$this->contrib->contrib_type]->use_queue ? true : false, 'S_NEW' => $this->revision_status == TITANIA_REVISION_NEW ? true : false, 'S_APPROVED' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'S_DENIED' => $this->revision_status == TITANIA_REVISION_DENIED ? true : false, 'S_PULLED_SECURITY' => $this->revision_status == TITANIA_REVISION_PULLED_SECURITY ? true : false, 'S_PULLED_OTHER' => $this->revision_status == TITANIA_REVISION_PULLED_OTHER ? true : false, 'S_REPACKED' => $this->revision_status == TITANIA_REVISION_REPACKED ? true : false, 'S_RESUBMITTED' => $this->revision_status == TITANIA_REVISION_RESUBMITTED ? true : false)); phpbb::$user->date_format = $old_date_format; // Output phpBB versions foreach ($ordered_phpbb_versions as $version) { phpbb::$template->assign_block_vars($tpl_block . '.phpbb_versions', array('VERSION' => $version)); } // Output translations if (sizeof($this->translations)) { $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id); $translations->store_attachments($this->translations); foreach ($translations->parse_attachments($message = false) as $attachment) { phpbb::$template->assign_block_vars($tpl_block . '.translations', array('DISPLAY_ATTACHMENT' => $attachment)); } } phpbb::$template->assign_var('ICON_EDIT', '<img src="' . titania::$images_path . 'icon_edit.gif" alt="' . phpbb::$user->lang['EDIT'] . '" title="' . phpbb::$user->lang['EDIT'] . '" />'); // Hooks titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $this, $tpl_block); }
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'); $path_helper = phpbb::$container->get('path_helper'); $post_text = $post_object->post_text; phpbb_com_handle_attachments($post_object, $post_text); message::decode($post_text, $post_object->post_text_uid); $post_text .= "\n\n" . $path_helper->strip_url_params($post_object->get_url(), 'sid'); $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text); phpbb_posting('edit', $options); }
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'); }
/** * 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)); } }
// increase a FAQ views counter $faq->increase_views_counter(); // tracking titania_tracking::track(TITANIA_FAQ, $faq_id); $message = $faq->generate_text_for_display(); // Grab attachments $attachments = new titania_attachment(TITANIA_FAQ, $faq->faq_id); $attachments->load_attachments(); $parsed_attachments = $attachments->parse_attachments($message); phpbb::$template->assign_vars(array('FAQ_SUBJECT' => $faq->faq_subject, 'FAQ_TEXT' => $message, 'FAQ_VIEWS' => $faq->faq_views, 'S_DETAILS' => true, 'S_ACCESS_TEAMS' => $faq->faq_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $faq->faq_access == TITANIA_ACCESS_AUTHORS ? true : false, 'U_EDIT_FAQ' => titania::$contrib->is_author || phpbb::$auth->acl_get('u_titania_faq_edit') ? $faq->get_url('edit') : false, 'U_CANONICAL' => $faq->get_url())); foreach ($parsed_attachments as $attachment) { phpbb::$template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } else { titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['FAQ_LIST']); titania::_include('functions_display', 'titania_topic_folder_img'); // Setup the sort tool $sort = new titania_sort(); $sort->set_url(titania::$contrib->get_url('faq')); $sort->set_defaults(phpbb::$config['topics_per_page']); $sort->request(); $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);
case 4: if (!titania_types::$types[titania::$contrib->contrib_type]->validate_translation) { $step = 5; $try_again = true; continue; } $revision = new titania_revision(titania::$contrib, $revision_id); if (!$revision->load()) { trigger_error('NO_REVISION'); } $revision_attachment = new titania_attachment(TITANIA_CONTRIB); $revision_attachment->attachment_id = $revision->attachment_id; if (!$revision_attachment->load()) { trigger_error('ERROR_NO_ATTACHMENT'); } titania::_include('library/translations/translation_validation'); $zip_file = titania::$config->upload_path . '/' . utf8_basename($revision_attachment->attachment_directory) . '/' . utf8_basename($revision_attachment->physical_filename); $new_dir_name = titania::$contrib->contrib_name_clean . '_' . preg_replace('#[^0-9a-z]#', '_', strtolower($revision->revision_version)); $validation_tools = new translation_validation($zip_file, $new_dir_name); $sql = 'SELECT row_id, phpbb_version_branch, phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' WHERE revision_id = ' . $revision->revision_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision']; $reference_filepath = $validation_tools->automod_phpbb_files($version_string); // path to files against which we will validate the package } $errors = $validation_tools->check_package($reference_filepath); if (!empty($errors)) { trigger_error(implode('<br /><br />', $errors)); }
} } $error = array(); if ($submit) { // In run_tool do whatever is required. If there is an error, put it into the array and the display options will be ran again $tool->run_tool($error); } if (!$submit || !empty($error)) { /* * Instead of building a page yourself you may return an array with the options you want to show. This is outputted similar to how the acp_board is. * You may also send back a string if you just want a confirm box shown with that string used for the title */ $options = $tool->display_options(); if (is_array($options) && isset($options['vars'])) { titania::page_header($options['title']); titania::_include('functions_manage', 'use_lang'); // Go through each error and see if the key exists in the phpbb::$user->lang. If it does, use that. if (!empty($error)) { array_walk($error, 'use_lang'); } phpbb::$template->assign_vars(array('L_TITLE' => phpbb::$user->lang[$options['title']], 'L_TITLE_EXPLAIN' => isset(phpbb::$user->lang[$options['title'] . '_EXPLAIN']) ? phpbb::$user->lang[$options['title'] . '_EXPLAIN'] : '', 'S_ERROR' => !empty($error) ? true : false, 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : '')); foreach ($options['vars'] as $name => $vars) { if (!is_array($vars) && strpos($name, 'legend') === false) { continue; } if (strpos($name, 'legend') !== false) { phpbb::$template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset(phpbb::$user->lang[$vars]) ? phpbb::$user->lang[$vars] : $vars)); continue; } $type = explode(':', $vars['type']); $l_explain = '';
/** * Generate topic status */ public function topic_folder_img(&$folder_img, &$folder_alt) { titania::_include('functions_display', 'titania_topic_folder_img'); titania_topic_folder_img($folder_img, $folder_alt, $this->get_postcount(), $this->unread, $this->topic_posted, $this->topic_sticky, $this->topic_locked); }
/** * Generate topic status */ public static function folder_img($is_unread, &$folder_img, &$folder_alt, $replies = 0) { titania::_include('functions_display', 'titania_topic_folder_img'); titania_topic_folder_img($folder_img, $folder_alt, $replies, $is_unread); }
/** * Reply to the release topic * * @param int $branch Specific branch release topic to reply to * @param string $reply Message to reply to the topic with * @param array $options Any additional options for the reply */ public function reply_release_topic($branch, $reply, $options = array()) { $release_topic_id = $this->get_release_topic_id($branch); if (!$release_topic_id) { return; } titania::_include('functions_posting', 'phpbb_posting'); $options_reply = array_merge($options, array('topic_id' => $release_topic_id, 'topic_title' => 'Re: ' . $this->contrib_name, 'post_text' => $reply)); phpbb_posting('reply', $options_reply); }
} else { if ($action_contribs == 'move' && !empty($contribs_to_id)) { $error = array_merge($error, $category_object->move_category_content($contribs_to_id)); } } if (!sizeof($error)) { // Delete category $category_object->delete(); // Redirect back to the previous category redirect(titania_url::build_url('manage/categories', array('c' => $parent_id))); } } phpbb::$template->assign_vars(array('S_DELETE_CATEGORY' => true, 'U_ACTION' => titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'delete')), 'U_BACK' => 'c_' . $category_object->parent_id, 'CATEGORY' => $category_id, 'CATEGORY_NAME' => isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name, 'SECTION_NAME' => phpbb::$user->lang['DELETE_CATEGORY'] . ' - ' . (isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name), 'S_HAS_SUBCATS' => $category_object->right_id - $category_object->left_id > 1 ? true : false, 'S_MOVE_CATEGORY_OPTIONS' => generate_category_select($category_object->parent_id, true), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); break; default: titania::_include('functions_display', 'titania_display_categories'); titania_display_categories($category_id, 'categories', true); if ($category_id != 0) { // Breadcrumbs $category_object = new titania_category(); $categories_ary = titania::$cache->get_categories(); // 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
/** * 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); }
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; }
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(); }
if (titania::$config->support_in_titania) { $search_types = array_merge($search_types, array(TITANIA_SUPPORT => 'CONTRIB_SUPPORT')); } $mode = request_var('mode', ''); $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); $user_id = request_var('u', 0); $contrib_id = request_var('contrib', 0); $search_fields = request_var('sf', ''); $search_type = request_var('type', 0); $categories = request_var('c', array(0)); $search_subcategories = request_var('sc', 0); $phpbb_versions = request_var('versions', array('')); // Display the advanced search page if (!$keywords && !$user_id && !$contrib_id && !isset($_POST['submit'])) { if ($mode == 'find-contribution') { titania::_include('functions_posting', 'generate_category_select'); titania::add_lang('contributions'); phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('find-contribution'))); // Display the list of phpBB versions available foreach (titania::$cache->get_phpbb_versions() as $version => $name) { $template->assign_block_vars('phpbb_versions', array('VERSION' => $name)); } generate_category_select($categories, false, false); titania::page_header('SEARCH'); titania::page_footer(true, 'find_contribution.html'); } // Output search types foreach ($search_types as $value => $name) { phpbb::$template->assign_block_vars('types', array('NAME' => isset(phpbb::$user->lang[$name]) ? phpbb::$user->lang[$name] : $name, 'VALUE' => $value)); } phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('search')));
/** * 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'); }
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * */ /** * @ignore */ if (!defined('IN_TITANIA')) { exit; } // Include library in include path (for Zend) if (titania::$config->search_backend == 'zend') { set_include_path(get_include_path() . PATH_SEPARATOR . realpath(TITANIA_ROOT . 'includes/library/')); titania::_include('library/Zend/Search/Lucene', false, 'Zend_Search_Lucene'); } // Using the phpBB ezcomponents loader titania::_include('library/ezcomponents/loader', false, 'phpbb_ezcomponents_loader'); phpbb_ezcomponents_loader::load_component('search'); class titania_search { /** * Path to store (for the Zend Search index files) */ const store_path = 'store/search/'; /** * Holds the indexer */ private static $index = false; /** * Forcefully set the indexer to not index anything * * @var bool