/** * Load revision's parent contribution. * * @throws \Exception Throws exception if no contrib found. * @return null */ protected function load_contrib() { $this->contrib = new \titania_contribution(); if (!$this->contrib->load($this->revision->contrib_id) || !$this->contrib->is_visible()) { throw new \Exception($this->user->lang['CONTRIB_NOT_FOUND']); } $this->revision->contrib = $this->contrib; }
/** * Approve action. * * @return \Symfony\Component\HttpFoundation\Response */ public function approve() { $public_notes = $this->request->variable('public_notes', '', true); if ($this->validate('approve')) { $this->queue->approve($public_notes); // Reload contribution with new data. $this->contrib->load(); $this->contrib->type->approve($this->contrib, $this->queue, $this->request); $this->cache->destroy('sql', TITANIA_CONTRIBS_TABLE); redirect($this->queue->get_url()); } if ($this->contrib->type->update_public) { $this->template->assign_vars(array('PUBLIC_MESSAGE' => $public_notes, 'S_PUBLIC_NOTES' => true)); if ($this->request->is_set_post('preview')) { $this->template->assign_vars(array('PUBLIC_PREVIEW_SUBJECT' => 'Re: ' . $this->contrib->contrib_name, 'PUBLIC_PREVIEW_MESSAGE' => $this->get_public_notes_preview($public_notes))); } } return $this->helper->render('manage/queue_validate.html', $this->user->lang['APPROVE_QUEUE'] . ' - ' . $this->contrib->contrib_name); }
/** * Assign navigation tabs. * * @param string $page Current active page. * @return null */ protected function generate_navigation($page) { // Count the number of FAQ items to display $flags = count::get_flags($this->access->get_level()); $faq_count = count::from_db($this->contrib->contrib_faq_count, $flags); $is_disabled = in_array($this->contrib->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)); /** * 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('details' => array('title' => 'CONTRIB_DETAILS', 'url' => $this->contrib->get_url()), 'faq' => array('title' => 'CONTRIB_FAQ', 'url' => $this->contrib->get_url('faq'), 'auth' => !$this->access->is_public() || $faq_count, 'count' => $faq_count), 'support' => array('title' => 'CONTRIB_SUPPORT', 'url' => $this->contrib->get_url('support'), 'auth' => $this->ext_config->support_in_titania || $this->access->get_level() < access::PUBLIC_LEVEL), 'demo' => array('title' => 'CONTRIB_DEMO', 'url' => '', 'auth' => !empty($this->contrib->contrib_demo)), 'manage' => array('title' => 'CONTRIB_MANAGE', 'url' => $this->contrib->get_url('manage'), 'auth' => $this->is_author && $this->auth->acl_get('u_titania_post_edit_own') && !$is_disabled || $this->auth->acl_get('u_titania_mod_contrib_mod') || $this->contrib->type->acl_get('moderate'))); if ($this->contrib->contrib_demo) { $demo_menu = array(); $allowed_branches = $this->contrib->type->get_allowed_branches(true); krsort($allowed_branches); $is_external = $this->contrib->contrib_status != TITANIA_CONTRIB_APPROVED || !$this->contrib->options['demo']; foreach ($allowed_branches as $branch => $name) { $demo_url = $this->contrib->get_demo_url($branch, !$is_external); if ($demo_url) { $demo_menu[] = array('url' => $demo_url, 'title' => $name, 'external' => $is_external); } } if (sizeof($demo_menu) == 1) { $nav_ary['demo']['url'] = $demo_menu[0]['url']; $nav_ary['demo']['external'] = $demo_menu[0]['external']; } else { if (!empty($demo_menu)) { $nav_ary['demo']['sub_menu'] = $demo_menu; } else { unset($nav_ary['demo']); } } } $this->display->generate_nav($nav_ary, $page, 'details'); }
$email_template = $post->post_id == $post->topic->topic_first_post_id && $post->post_id == $post->topic->topic_last_post_id ? 'topic_approved' : 'post_approved'; $messenger->template($email_template, users_overlord::get_user($post->post_user_id, 'user_lang')); $messenger->to(users_overlord::get_user($post->post_user_id, 'user_email'), users_overlord::get_user($post->post_user_id, '_username')); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($post->post_user_id, '_username')), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post->post_subject)), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post->topic->topic_subject)), 'U_VIEW_TOPIC' => titania_url::append_url($post->topic->get_url()), 'U_VIEW_POST' => titania_url::append_url($post->get_url()))); $messenger->send(); phpbb::$user->set_custom_lang_path($lang_path); } redirect(titania_url::build_url(titania_url::$current_page)); } users_overlord::load_users(array($post->post_user_id, $post->post_edit_user, $post->post_delete_user)); users_overlord::assign_details($post->post_user_id, 'POSTER_', true); phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($post->post_subject), 'POST_DATE' => phpbb::$user->format_date($post->post_time), 'POST_TEXT' => $post->generate_text_for_display(), 'EDITED_MESSAGE' => $post->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($post->post_edit_user, '_full'), phpbb::$user->format_date($post->post_edited)) : '', 'DELETED_MESSAGE' => $post->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($post->post_delete_user, '_full'), phpbb::$user->format_date($post->post_deleted), $post->get_url('undelete')) : '', 'POST_EDIT_REASON' => censor_text($post->post_edit_reason), 'U_VIEW' => $post->get_url(), 'U_EDIT' => $post->get_url('edit'), 'SECTION_NAME' => '<a href="' . $post->get_url() . '">' . censor_text($post->post_subject) . '</a> - ' . phpbb::$user->lang['ATTENTION'])); $title = censor_text($post->post_subject); break; case TITANIA_CONTRIB: $contrib = new titania_contribution(); if (!$contrib->load((int) $object_id)) { $attention_object->delete(); trigger_error('NO_CONTRIB'); } // Close the report if ($close) { redirect(titania_url::build_url(titania_url::$current_page)); } users_overlord::load_users(array($contrib->contrib_user_id)); users_overlord::assign_details($contrib->contrib_user_id, 'POSTER_', true); phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($contrib->contrib_name), 'POST_DATE' => phpbb::$user->format_date($contrib->contrib_last_update), 'POST_TEXT' => $contrib->generate_text_for_display(), 'U_VIEW' => $contrib->get_url(), 'U_EDIT' => $contrib->get_url('manage'), 'SECTION_NAME' => '<a href="' . $contrib->get_url() . '">' . censor_text($contrib->contrib_name) . '</a> - ' . phpbb::$user->lang['ATTENTION'])); $title = censor_text($contrib->contrib_name); break; default: trigger_error('NO_ATTENTION_TYPE');
/** * Display "forum" like section for support/tracker/etc * * @param string $type The type (support, review, queue, tracker, author_support, author_tracker) author_ for displaying posts from the areas the given author is involved in (either an author/co-author) * @param object|boolean $object The object (for contrib related (support, review, queue, tracker) and author_ modes) * @param object|boolean $sort The sort object (includes/tools/sort.php) * @param array $options Some special options * @param string $contrib_type The type of the support topic list */ public static function display_forums($type, $object = false, $sort = false, $options = array()) { if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $topic_ids = array(); $switch_on_sticky = true; // Display the extra block after stickies end? Not used when not sorting with stickies first $sql_ary = array('SELECT' => 't.*, u.username as topic_first_post_username, u.user_colour as topic_first_post_user_colour, ul.username as topic_last_post_username, ul.user_colour as topic_last_post_user_colour', 'FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'WHERE' => self::sql_permissions('t.', false, true), 'ORDER_BY' => 't.topic_sticky DESC, ' . $sort->get_order_by()); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_first_post_user_id = u.user_id'); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'ul'), 'ON' => 't.topic_last_post_user_id = ul.user_id'); titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id'); // Setup the contribution/topic we will use for parsing the output (before the switch so we are able to do type specific things for it) $topic = new titania_topic(); $contrib = new titania_contribution(); // type specific things switch ($type) { case 'tracker': $page_url = $object->get_url('tracker'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; if (isset($options['category'])) { $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['category']; } break; case 'queue': $page_url = titania_url::build_url('manage/queue'); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE; break; case 'queue_discussion': $page_url = titania_url::build_url('manage/queue_discussion', array('queue' => titania_types::$types[$options['topic_category']]->url)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE_DISCUSSION; // Only display those in which the users are authed $authed = titania_types::find_authed('queue_discussion'); if (!sizeof($authed)) { return compact('sort'); } if (isset($options['topic_category'])) { if (!in_array((int) $options['topic_category'], $authed)) { return compact('sort'); } $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['topic_category']; } else { $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.topic_category', $authed); } // Additional tracking for all queue discussion topics titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); break; case 'author_support': $page_url = $object->get_url('support'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id, true); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); // We also display the queue discussion topic between validators and authors in the support area $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; // Additional tracking for marking items as read in each contribution titania_tracking::get_tracks(TITANIA_SUPPORT, $contrib_ids); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0, 'type_match' => true); // Track the queue discussion too if applicable if (titania_types::find_authed('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'author_tracker': $page_url = $object->get_url('tracker'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; break; case 'all_support': // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); if (isset(titania_types::$types[$options['contrib_type']])) { $page_url = titania_url::build_url('support/' . titania_types::$types[$options['contrib_type']]->url); $sql_ary['WHERE'] .= ' AND contrib.contrib_type = ' . $options['contrib_type']; } else { $page_url = titania_url::build_url('support/all'); } // Additional tracking field (to allow marking all support/discussion as read) $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'support': default: $page_url = $object->get_url('support'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; // We also display the queue discussion topic between validators and authors in the support area if ($object->is_author || $object->is_active_coauthor || titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; } else { $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; } // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, $object->contrib_id, 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Track the queue discussion too if applicable if (titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } break; } // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 't.topic_id')) { // No results...no need to query more... return compact('sort'); } $sort->build_pagination($page_url); $last_was_sticky = false; // Get the data $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); while ($row = phpbb::$db->sql_fetchrow($result)) { // Store the tracking info we grabbed from the DB titania_tracking::store_from_db($row); self::$topics[$row['topic_id']] = $row; $topic->__set_array($row); $contrib->__set_array($row); phpbb::$template->assign_block_vars('topics', array_merge($topic->assign_details(), array('S_TOPIC_TYPE_SWITCH' => $switch_on_sticky && $last_was_sticky && !$topic->topic_sticky ? true : false, 'CONTRIB_TYPE' => isset($row['contrib_type']) && $row['contrib_type'] ? titania_types::$types[$row['contrib_type']]->lang : '', 'TOPIC_CONTRIB_NAME' => isset($row['contrib_name']) && $row['contrib_name'] ? censor_text($row['contrib_name']) : '', 'U_VIEW_TOPIC_CONTRIB' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url() : '', 'U_VIEW_TOPIC_CONTRIB_SUPPORT' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url('support') : ''))); $last_was_sticky = $topic->topic_sticky; } phpbb::$db->sql_freeresult($result); unset($topic); return compact('sort'); }
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'); }
/** * Build the quick moderation actions for output for this topic * * @param mixed $topic */ public static function build_quick_actions($topic) { // Auth check $is_authed = $is_moderator = false; if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) { $is_authed = $is_moderator = true; } else { if (phpbb::$auth->acl_get('u_titania_post_mod_own')) { if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) { $is_authed = true; } else { if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic->parent_id) { $contrib = new titania_contribution(); $contrib->load((int) $topic->parent_id); if ($contrib->is_author || $contrib->is_active_coauthor) { $is_authed = true; } } } } } if (!$is_authed) { return; } $actions = array('MAKE_NORMAL' => $topic->topic_sticky ? $topic->get_url('unsticky_topic') : false, 'MAKE_STICKY' => !$topic->topic_sticky ? $topic->get_url('sticky_topic') : false, 'LOCK_TOPIC' => !$topic->topic_locked ? $topic->get_url('lock_topic') : false, 'UNLOCK_TOPIC' => $topic->topic_locked ? $topic->get_url('unlock_topic') : false, 'SPLIT_TOPIC' => $is_moderator && $topic->topic_type == TITANIA_SUPPORT ? $topic->get_url('split_topic') : false, 'MERGE_POSTS' => $is_moderator && $topic->topic_type == TITANIA_SUPPORT ? $topic->get_url('move_posts') : false, 'SOFT_DELETE_TOPIC' => $topic->get_url('delete_topic'), 'UNDELETE_TOPIC' => $topic->get_url('undelete_topic')); if (phpbb::$auth->acl_get('u_titania_post_hard_delete')) { $actions = array_merge($actions, array('HARD_DELETE_TOPIC' => $topic->get_url('hard_delete_topic'))); } foreach ($actions as $title => $link) { if (!$link) { continue; } phpbb::$template->assign_block_vars('quickmod', array('TITLE' => phpbb::$user->lang($title), 'LINK' => $link)); } }
/** * Get contribution. * * @param int $contrib_id * @return \titania_contribution */ protected function get_contrib($contrib_id) { $contrib = $this->contrib; // Load the contrib parent if not loaded. if (!is_object($contrib) || !$contrib->contrib_id == $contrib_id && $contrib_id) { $contrib = new \titania_contribution(); $contrib->load((int) $contrib_id); } return $contrib; }
/** * 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)); } }
/** * Generate report message for a change in description. * * @return string */ protected function get_description_change($old_settings) { $contrib = new \titania_contribution(); $contrib->__set_array($old_settings); $old_description = $contrib->generate_text_for_edit(); $old_description = $old_description['text']; $description = $this->contrib->generate_text_for_edit(); $description = $description['text']; return $old_description !== $description ? "{$old_description}>>>>>>>>>>{$description}" : ''; }
if (!defined('PHP_EXT')) { define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); } require TITANIA_ROOT . 'common.' . PHP_EXT; titania::add_lang('manage'); if (!class_exists('titania_type_translation')) { require TITANIA_ROOT . 'includes/types/translation.php'; } // Give founders access to run this if (phpbb::$user->data['user_type'] != USER_FOUNDER) { titania::needs_auth(); } // Hopefully this helps @set_time_limit(0); // Delete all translations $contrib = new titania_contribution(); $sql = 'SELECT * FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE contrib_type = ' . TITANIA_TYPE_TRANSLATION; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $contrib->__set_array($row); $contrib->delete(); } phpbb::$db->sql_freeresult($result); // All the language packs we'll need, we wont transfer inactive ones, they need to be cleaned up anyways $sql = 'SELECT * FROM lang_packs WHERE display > 0 AND version = 3'; $result = $db->sql_query($sql); // All the authors we'll need $sql2 = 'SELECT * FROM lang_packs_authors WHERE lang_id IN ( SELECT lang_id FROM lang_packs WHERE display > 0 ) '; $authors = $db->sql_fetchrowset($db->sql_query($sql2)); $i = 0; while ($row = $db->sql_fetchrow($result)) {
phpbb::$db->sql_freeresult($result); if (!$attachment || $attachment['object_type'] != TITANIA_CONTRIB) { clr_error('ERROR_NO_ATTACHMENT'); } if ((int) $attachment['object_type'] != TITANIA_CONTRIB || $attachment['is_orphan'] || $attachment['attachment_access'] < titania::$access_level) { clr_error('ERROR_NO_ATTACHMENT'); } /** * Get revision and contribution */ $sql = 'SELECT revision_id, contrib_id, revision_status, revision_clr_options FROM ' . TITANIA_REVISIONS_TABLE . ' WHERE attachment_id = ' . $attachment['attachment_id']; $result = phpbb::$db->sql_query($sql); $revision = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); $contrib = new titania_contribution(); if (!$contrib->load((int) $revision['contrib_id']) || $revision['revision_status'] != TITANIA_REVISION_APPROVED) { clr_error('SORRY_AUTH_VIEW_ATTACH'); } if (!$contrib->has_colorizeit()) { clr_error('CLR_ERROR_NOSAMPLE'); } /** * Get file options */ if (!strlen($revision['revision_clr_options'])) { $zip_file = titania::$config->upload_path . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']); if (!@file_exists($zip_file)) { clr_error('ERROR_NO_ATTACHMENT'); } $new_dir_name = md5(serialize($_SERVER)) . '_' . microtime();
/** * Check if user can download the requested revision. * * @return int Returns HTTP status code. */ protected function check_revision_auth() { $sql = 'SELECT contrib_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . ' WHERE attachment_id = ' . (int) $this->id; $result = $this->db->sql_query($sql); $revision = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $contrib = new \titania_contribution(); if (!$revision || !$contrib->load((int) $revision['contrib_id']) || !$contrib->is_visible(true)) { return self::NOT_FOUND; } if ($this->type == 'composer' && !$contrib->type->create_composer_packages) { return self::NOT_FOUND; } $is_author = $contrib->is_author || $contrib->is_active_coauthor; $can_download_hidden = $is_author || $contrib->type->acl_get('view') || $contrib->type->acl_get('moderate'); $use_queue = $this->ext_config->require_validation && $contrib->type->require_validation; $is_unvalidated = $revision['revision_status'] != TITANIA_REVISION_APPROVED && $use_queue; $is_disabled = $contrib->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED; if (!$can_download_hidden && !$this->is_auto_validator() && ($is_unvalidated || $is_disabled)) { return self::NOT_FOUND; } // Set access Level if ($is_author) { $this->access->set_level(access::AUTHOR_LEVEL); } return self::OK; }
/** * Display a single queue item * * @param int $queue_id * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic) */ public static function display_queue_item($queue_id) { titania::add_lang('contributions'); $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . ' AND r.revision_id = q.revision_id AND t.topic_id = q.queue_topic_id'); // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); $result = phpbb::$db->sql_query($sql); $row = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); if (!$row) { trigger_error('NO_QUEUE_ITEM'); } self::$queue[$queue_id] = $row; // Load the contribution $contrib = new titania_contribution(); $contrib->load((int) $row['contrib_id']); $contrib->get_download($row['revision_id']); $contrib->get_revisions(); $contrib->get_screenshots(); $contrib->assign_details(); // Load the topic (with the already selected data) $topic = new titania_topic(); $topic->__set_array($row); // Bit of a hack for the posting $_REQUEST['t'] = $topic->topic_id; // Some quick-actions $quick_actions = array(); if ($row['queue_status'] > 0) { if ($row['queue_progress'] == phpbb::$user->data['user_id']) { $quick_actions['MARK_NO_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'no_progress')), 'class' => 'queue_progress'); } else { if (!$row['queue_progress']) { $quick_actions['MARK_IN_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'in_progress')), 'class' => 'queue_progress'); } } $tags = titania::$cache->get_tags(TITANIA_QUEUE); unset($tags[$row['queue_status']]); $quick_actions['CHANGE_STATUS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'move')), 'class' => 'change_status', 'tags' => $tags); if (titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) { $quick_actions['REPACK'] = array('url' => titania_url::append_url($contrib->get_url('revision'), array('repack' => $row['revision_id'])), 'class' => 'repack'); } // This allows you to alter the author submitted notes to the validation team, not really useful as the field's purpose was changed, so commenting out /*$quick_actions['ALTER_NOTES'] = array( 'url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'notes')), );*/ // Misc actions $subactions = array(); if (titania_types::$types[$contrib->contrib_type]->mpv_test) { $subactions['RETEST_MPV'] = array('url' => titania_url::build_url('', array('action' => 'mpv', 'revision' => $row['revision_id']))); } if (titania_types::$types[$contrib->contrib_type]->automod_test) { $subactions['RETEST_AUTOMOD'] = array('url' => titania_url::build_url('', array('action' => 'automod', 'revision' => $row['revision_id']))); } $subactions['REBUILD_FIRST_POST'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'rebuild'))); $quick_actions['CAT_MISC'] = array('subactions' => $subactions, 'class' => 'misc'); // Validation if (titania_types::$types[$contrib->contrib_type]->acl_get('validate')) { $quick_actions['APPROVE'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'approve', 'start' => '*destroy*')), 'class' => 'approve'); $quick_actions['DENY'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'deny', 'start' => '*destroy*')), 'class' => 'deny'); } } foreach ($quick_actions as $lang_key => $data) { phpbb::$template->assign_block_vars('queue_actions', array('NAME' => isset(phpbb::$user->lang[$lang_key]) ? phpbb::$user->lang[$lang_key] : $lang_key, 'CLASS' => isset($data['class']) ? $data['class'] : '', 'U_VIEW' => isset($data['url']) ? $data['url'] : '')); if (isset($data['tags'])) { foreach ($data['tags'] as $tag_id => $tag_row) { phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => isset(phpbb::$user->lang[$tag_row['tag_field_name']]) ? phpbb::$user->lang[$tag_row['tag_field_name']] : $tag_row['tag_field_name'], 'U_ACTION' => titania_url::append_url($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions'))))); } } if (isset($data['subactions'])) { foreach ($data['subactions'] as $sublang_key => $subdata) { phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => isset(phpbb::$user->lang[$sublang_key]) ? phpbb::$user->lang[$sublang_key] : $sublang_key, 'U_ACTION' => $subdata['url'])); } } } if ($row['queue_status'] == -2) { $current_status = phpbb::$user->lang['REVISION_DENIED']; } else { if ($row['queue_status'] == -1) { $current_status = phpbb::$user->lang['REVISION_APPROVED']; } else { $current_status = titania_tags::get_tag_name($row['queue_status']); } } phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'reply', 't' => $topic->topic_id)), 'U_NEW_REVISION' => false)); // Subscriptions titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, titania_url::$current_page_url); return compact('row', 'contrib', 'topic'); }
/** * Rerun the MPV or Automod test for the queue */ /** * Rerun the MPV or Automod test for the queue */ case 'mpv': case 'automod': $revision_id = request_var('revision', 0); titania::add_lang('contributions'); // Get the revision, contribution, attachment, and queue $revision = new titania_revision(false, $revision_id); if (!$revision->load()) { trigger_error('NO_REVISION'); } $contrib = new titania_contribution(); if (!$contrib->load($revision->contrib_id)) { trigger_error('CONTRIB_NOT_FOUND'); } $revision->contrib = $contrib; if (!titania_types::$types[$contrib->contrib_type]->acl_get('view')) { titania::needs_auth(); } $revision_attachment = new titania_attachment(TITANIA_CONTRIB); $revision_attachment->attachment_id = $revision->attachment_id; if (!$revision_attachment->load()) { trigger_error('ERROR_NO_ATTACHMENT'); } $queue = $revision->get_queue(); $zip_file = titania::$config->upload_path . '/' . utf8_basename($revision_attachment->attachment_directory) . '/' . utf8_basename($revision_attachment->physical_filename); $download_package = titania_url::build_url('download', array('id' => $revision_attachment->attachment_id));
/** * Display a single queue item * * @param int $queue_id * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic) */ public static function display_queue_item($queue_id) { phpbb::$user->add_lang_ext('phpbb/titania', 'contributions'); $controller_helper = phpbb::$container->get('phpbb.titania.controller.helper'); $path_helper = phpbb::$container->get('path_helper'); $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . ' AND r.revision_id = q.revision_id AND t.topic_id = q.queue_topic_id'); // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); $result = phpbb::$db->sql_query($sql); $row = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); if (!$row) { trigger_error('NO_QUEUE_ITEM'); } self::$queue[$queue_id] = $row; $queue = self::get_queue_object($queue_id); // Load the contribution $contrib = new titania_contribution(); $contrib->load((int) $row['contrib_id']); $contrib->get_download($row['revision_id']); $contrib->get_revisions(); $contrib->get_screenshots(); $contrib->assign_details(); // Load the topic (with the already selected data) $topic = new titania_topic(); $topic->__set_array($row); // Bit of a hack for the posting phpbb::$request->overwrite('t', $topic->topic_id); $is_moderator = $contrib->type->acl_get('moderate'); $is_validator = $contrib->type->acl_get('validate'); $hash = array('hash' => generate_link_hash('queue_tool')); // Misc actions $misc_actions = array(array('RETEST_PV', $queue->get_tool_url('mpv', $row['revision_id'], $hash), $contrib->type->mpv_test), array('RETEST_PV', $queue->get_tool_url('epv', $row['revision_id'], $hash), $contrib->type->epv_test), array('RETEST_AUTOMOD', $queue->get_tool_url('automod', $row['revision_id'], $hash), $contrib->type->automod_test)); // Some quick-actions $quick_actions = array(); $hash = array('hash' => generate_link_hash('queue_action')); if ($row['queue_status'] > 0) { $misc_actions = array_merge($misc_actions, array(array('REBUILD_FIRST_POST', $queue->get_url('rebuild', $hash), true), array('ALLOW_AUTHOR_REPACK', $queue->get_url('allow_author_repack'), $is_moderator && !$row['allow_author_repack']), array('MARK_TESTED', $queue->get_url('tested', $hash), !$row['queue_tested']), array('MARK_UNTESTED', $queue->get_url('not_tested', $hash), $row['queue_tested']))); $tags = titania::$cache->get_tags(TITANIA_QUEUE); unset($tags[$row['queue_status']]); $quick_actions = array(array('MARK_NO_PROGRESS', $queue->get_url('no_progress', $hash), $row['queue_progress'] == phpbb::$user->data['user_id'], 'queue_progress'), array('MARK_IN_PROGRESS', $queue->get_url('in_progress', $hash), !$row['queue_progress'], 'queue_progress'), array('CHANGE_STATUS', $queue->get_url('move'), true, 'change_status', $tags), array('REPACK', $contrib->get_url('revision', array('page' => 'repack', 'id' => $row['revision_id'])), $is_moderator, 'repack'), array('CAT_MISC', '', true, 'misc', '', $misc_actions), array('APPROVE', $queue->get_url('approve'), $is_validator, 'approve'), array('DENY', $queue->get_url('deny'), $is_validator, 'deny')); } if (empty($quick_actions) && !empty($misc_actions)) { $quick_actions = array(array('CAT_MISC', '', true, 'misc', '', $misc_actions)); } foreach ($quick_actions as $data) { $properties = array('name', 'url', 'auth', 'class', 'tags', 'subactions'); $data = array_pad($data, sizeof($properties), ''); $data = array_combine($properties, $data); if (!$data['auth']) { continue; } phpbb::$template->assign_block_vars('queue_actions', array('NAME' => phpbb::$user->lang($data['name']), 'CLASS' => $data['class'], 'U_VIEW' => $data['url'])); if ($data['tags']) { foreach ($data['tags'] as $tag_id => $tag_row) { phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => phpbb::$user->lang($tag_row['tag_field_name']), 'U_ACTION' => $path_helper->append_url_params($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions'))))); } } if ($data['subactions']) { foreach ($data['subactions'] as $subdata) { $subdata = array_pad($subdata, sizeof($properties), ''); $subdata = array_combine($properties, $subdata); if (!$subdata['auth']) { continue; } phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => phpbb::$user->lang($subdata['name']), 'U_ACTION' => $subdata['url'])); } } } if ($row['queue_status'] == -3) { $current_status = phpbb::$user->lang('QUEUE_CLOSED'); } else { if ($row['queue_status'] == -2) { $current_status = phpbb::$user->lang['REVISION_DENIED']; } else { if ($row['queue_status'] == -1) { $current_status = phpbb::$user->lang['REVISION_APPROVED']; } else { $current_status = phpbb::$container->get('phpbb.titania.tags')->get_tag_name($row['queue_status']); } } } phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => $queue->get_url('reply'), 'U_NEW_REVISION' => false)); // Subscriptions phpbb::$container->get('phpbb.titania.subscriptions')->handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, $controller_helper->get_current_url(), 'SUBSCRIBE_TOPIC'); return compact('row', 'contrib', 'topic'); }
$revision->change_status(TITANIA_REVISION_PULLED_OTHER); } $revision->revision_queue_id = 0; $revision->submit(); // Delete the queue $queue->delete(); redirect(titania_url::append_url($base_url)); } else { titania::confirm_box(false, 'DELETE_QUEUE'); } break; case 'approve': case 'deny': $queue = queue_overlord::get_queue_object($queue_id, true); // Load the contribution $contrib = new titania_contribution(); $contrib->load((int) $queue->contrib_id); // Do not allow to approve your own contributions, except for founders... if (!titania::$config->allow_self_validation && phpbb::$user->data['user_type'] != USER_FOUNDER && $action == 'approve' && ($contrib->is_author || $contrib->is_active_coauthor || $contrib->is_coauthor)) { titania::needs_auth(); } if (!titania_types::$types[$contrib->contrib_type]->acl_get('validate')) { titania::needs_auth(); } // Load the message object for the validation reason $queue->message_fields_prefix = 'message_validation'; $message_object = new titania_message($queue); $message_object->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'))); $message_object->set_settings(array('display_subject' => false)); $error = array(); $public_notes = utf8_normalize_nfc(request_var('public_notes', '', true));
$sql = 'SELECT * FROM ' . TITANIA_ATTACHMENTS_TABLE . "\n\tWHERE attachment_id = {$download_id}"; $result = phpbb::$db->sql_query_limit($sql, 1); $attachment = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); if (!$attachment) { trigger_error('ERROR_NO_ATTACHMENT'); } // Don't allow downloads of revisions for TITANIA_CONTRIB_DOWNLOAD_DISABLED items unless on the team or an author. if ($attachment['object_type'] == TITANIA_CONTRIB) { $sql = 'SELECT contrib_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . ' WHERE attachment_id = ' . $attachment['attachment_id']; $result = phpbb::$db->sql_query($sql); $revision = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); $contrib = new titania_contribution(); if (!$contrib->load((int) $revision['contrib_id'])) { trigger_error('NO_ATTACHMENT_SELECTED'); } if (($revision['revision_status'] != TITANIA_REVISION_APPROVED && titania::$config->require_validation && titania_types::$types[$contrib->contrib_type]->require_validation || $contrib->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED) && !$contrib->is_author && !$contrib->is_active_coauthor && !titania_types::$types[$contrib->contrib_type]->acl_get('view') && !titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) { // Is it the MPV server requesting the file? If so we allow non-approved file downloads $is_mpv_server = false; foreach (titania::$config->mpv_server_list as $data) { $dns_ipv4 = dns_get_record($data['host'], DNS_A); $dns_ipv6 = dns_get_record($data['host'], DNS_AAAA); if (isset($dns_ipv4[0]) && isset($dns_ipv4[0]['ip']) && phpbb::$user->ip == $dns_ipv4[0]['ip'] || isset($dns_ipv6[0]) && isset($dns_ipv6[0]['ip']) && phpbb::$user->ip == $dns_ipv6[0]['ip']) { $is_mpv_server = true; break; } } if (!$is_mpv_server) {
/** * Display new contribution page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function create() { if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) { return $this->helper->needs_auth(); } $this->user->add_lang_ext('phpbb/titania', 'contributions'); $contrib = new \titania_contribution(); $contrib->contrib_user_id = $this->user->data['user_id']; $contrib->author = $this->author; $contrib->get_options(); // Set some main vars up $message = $this->setup_message($contrib); $submit = $this->request->is_set_post('submit'); $preview = $this->request->is_set_post('preview'); $error = array(); $settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true)); if ($preview || $submit) { $contrib->post_data($message); $contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1)); } if ($preview) { $message->preview(); } else { if ($submit) { $authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive'])); $authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']); $error = $contrib->validate($settings['categories'], $authors, $settings['custom']); if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { $contrib->set_type($contrib->contrib_type); $contrib->set_custom_fields($settings['custom']); $contrib->contrib_categories = implode(',', $settings['categories']); $contrib->contrib_creation_time = time(); $contrib->submit(); $contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true); // Create relations $contrib->put_contrib_in_categories($settings['categories']); if ($this->ext_config->support_in_titania) { $active_authors = array_merge($authors['author'], $authors['active_coauthors']); foreach ($active_authors as $author) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author); } } redirect($contrib->get_url('revision')); } } } // Generate some stuff $this->display->generate_type_select($contrib->contrib_type); $this->display->generate_category_select($settings['categories']); $contrib->assign_details(); $message->display(); foreach ($this->types->get_all() as $type) { $this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id); } $this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive'])); return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION'); }
/** * Assign variables to the template */ public function assign_details() { if (!sizeof($this->styles)) { return false; } // Get siblings $prev = $this->sibling($this->default_style, 'prev'); $next = $this->sibling($this->default_style, 'next'); $this->template->assign_vars(array('U_PREV' => $prev['url'], 'PREV_ID' => $prev['id'], 'U_NEXT' => $next['url'], 'NEXT_ID' => $next['id'])); $category = ''; $style = new \titania_contribution(); $style->set_type(TITANIA_TYPE_STYLE); $style->options = array('demo' => true); foreach ($this->styles as $id => $data) { $style->__set_array(array('contrib_id' => $id, 'contrib_name_clean' => $data['contrib_name_clean'], 'contrib_demo' => $data['contrib_demo'])); $preview_img = false; if (isset($data['thumb_id'])) { $parameters = array('id' => $data['thumb_id']); if ($data['thumbnail']) { $parameters += array('mode' => 'view', 'thumb' => 1); } $preview_img = $this->controller_helper->route('phpbb.titania.download', $parameters); } $authors = $this->get_author_profile(array('username_clean' => $data['username_clean'], 'username' => $data['username'], 'user_id' => $data['contrib_user_id'], 'user_colour' => $data['user_colour'])); $authors .= $data['coauthors']; $data['category_name'] = $this->user->lang($data['category_name']); $phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $data['phpbb_versions']['revision']; $current_phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $this->ext_config->phpbb_versions[$data['phpbb_versions']['branch']]['latest_revision']; $vars = array('AUTHORS' => $authors, 'CATEGORY' => $category != $data['category_name'] ? $data['category_name'] : false, 'ID' => $id, 'IFRAME' => $style->get_demo_url($this->phpbb_branch), 'LICENSE' => $data['revision_license'] ? $data['revision_license'] : $this->user->lang['UNKNOWN'], 'NAME' => $data['contrib_name'], 'PHPBB_VERSION' => $phpbb_version, 'PREVIEW' => $preview_img, 'S_OUTDATED' => phpbb_version_compare($phpbb_version, $current_phpbb_version, '<'), 'U_DEMO' => $style->get_demo_url($this->phpbb_branch, true), 'U_DOWNLOAD' => $this->controller_helper->route('phpbb.titania.download', array('id' => $data['attachment_id'])), 'U_VIEW' => $style->get_url()); if ($this->default_style == $id) { $this->template->assign_vars($vars); } $category = $data['category_name']; $this->template->assign_block_vars('stylerow', $vars); unset($this->styles[$id], $vars, $this->coauthors[$id]); } }
/** * Send the approve/deny notification */ private function send_approve_deny_notification($approve = true) { $this->user->add_lang_ext('phpbb/titania', 'manage'); phpbb::_include('functions_privmsgs', 'submit_pm'); // Need some stuff $contrib = new titania_contribution(); $contrib->load((int) $this->contrib_id); $revision = new titania_revision($contrib, $this->revision_id); $revision->load(); // Generate the authors list to send it to $authors = array($contrib->contrib_user_id => 'to'); $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . ' WHERE contrib_id = ' . (int) $this->contrib_id . ' AND active = 1'; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $authors[$row['user_id']] = 'to'; } phpbb::$db->sql_freeresult($result); // Subject $subject = sprintf(phpbb::$user->lang[$contrib->type->validation_subject], $contrib->contrib_name, $revision->revision_version); // Message $notes = $this->validation_notes; message::decode($notes, $this->validation_notes_uid); if ($approve) { $message = $contrib->type->validation_message_approve; } else { $message = $contrib->type->validation_message_deny; } $message = sprintf(phpbb::$user->lang[$message], $notes); // Replace empty quotes if there are no notes if (!$notes) { $message = str_replace('[quote][/quote]', phpbb::$user->lang['NO_NOTES'], $message); } // Parse the message $message_uid = $message_bitfield = $message_options = false; generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true); $data = array('address_list' => array('u' => $authors), 'from_user_id' => phpbb::$user->data['user_id'], 'from_username' => phpbb::$user->data['username'], 'icon_id' => 0, 'from_user_ip' => phpbb::$user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $message, 'bbcode_bitfield' => $message_bitfield, 'bbcode_uid' => $message_uid); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $data, $this); // Submit Plz submit_pm('post', $subject, $data, true); }
/** * Build the quick moderation actions for output for this topic * * @param mixed $topic */ public static function build_quick_actions($topic) { // Auth check $is_authed = false; if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) { $is_authed = true; } else { if (phpbb::$auth->acl_get('u_titania_post_mod_own')) { if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) { $is_authed = true; } else { if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic->parent_id) { $contrib = new titania_contribution(); $contrib->load((int) $topic->parent_id); if ($contrib->is_author || $contrib->is_active_coauthor) { $is_authed = true; } } } } } if (!$is_authed) { return; } $actions = array('MAKE_NORMAL' => $topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unsticky_topic')) : false, 'MAKE_STICKY' => !$topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'sticky_topic')) : false, 'LOCK_TOPIC' => !$topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'lock_topic')) : false, 'UNLOCK_TOPIC' => $topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unlock_topic')) : false, 'SOFT_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'delete_topic')), 'UNDELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'undelete_topic'))); if (phpbb::$auth->acl_get('u_titania_post_hard_delete')) { $actions = array_merge($actions, array('HARD_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'hard_delete_topic')))); } phpbb::$template->assign_var('TOPIC_QUICK_ACTIONS', titania::build_quick_actions($actions)); }
/** * Copy new posts for queue discussion, queue to the forum */ function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object) { if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) { return; } // First we copy over the queue discussion topic if required $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . ' WHERE parent_id = ' . $queue_object->contrib_id . ' AND topic_type = ' . TITANIA_QUEUE_DISCUSSION; $result = phpbb::$db->sql_query($sql); $topic_row = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); // Do we need to create the queue discussion topic or not? if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) { $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION); $temp_post = new titania_post(); // Go through any posts in the queue discussion topic and copy them $topic_id = false; $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id']; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $temp_post->__set_array($row); $post_text = $row['post_text']; titania_decode_message($post_text, $row['post_text_uid']); $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url()); $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text); titania::_include('functions_posting', 'phpbb_posting'); if ($topic_id) { $options = array_merge($options, array('topic_id' => $topic_id)); phpbb_posting('reply', $options); } else { switch ($topic_row['topic_category']) { case TITANIA_TYPE_MOD: $options['poster_id'] = titania::$config->forum_mod_robot; break; case TITANIA_TYPE_STYLE: $options['poster_id'] = titania::$config->forum_style_robot; break; } $topic_id = phpbb_posting('post', $options); } } phpbb::$db->sql_freeresult($result); if ($topic_id) { $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET phpbb_topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_row['topic_id']; phpbb::$db->sql_query($sql); } unset($temp_post); } // Does a queue topic already exist? If so, don't repost. $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . ' WHERE topic_id = ' . $queue_object->queue_topic_id; phpbb::$db->sql_query($sql); $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id'); phpbb::$db->sql_freeresult(); if ($phpbb_topic_id) { return; } $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type); if (!$forum_id) { return; } $post_object->submit(); titania::_include('functions_posting', 'phpbb_posting'); // Need some stuff titania::add_lang('contributions'); $contrib = new titania_contribution(); $contrib->load((int) $queue_object->contrib_id); $revision = $queue_object->get_revision(); $contrib->get_download($revision->revision_id); switch ($post_object->topic->topic_category) { case TITANIA_TYPE_MOD: $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot; $lang_var = 'MOD_QUEUE_TOPIC'; break; case TITANIA_TYPE_STYLE: $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot; $lang_var = 'STYLE_QUEUE_TOPIC'; break; default: return; break; } $description = $contrib->contrib_desc; titania_decode_message($description, $contrib->contrib_desc_uid); $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']); $post_text .= "\n\n" . $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('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text); $topic_id = phpbb_posting('post', $options); $post_object->topic->phpbb_topic_id = $topic_id; $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET phpbb_topic_id = ' . (int) $topic_id . ' WHERE topic_id = ' . $post_object->topic->topic_id; phpbb::$db->sql_query($sql); }
/** * Get contrib object. * * @param array $data Contribution data * @return \titania_contribution */ protected function get_contrib($data) { $contrib = new \titania_contribution(); $contrib->__set_array($data); $contrib->set_type($data['contrib_type']); return $contrib; }
/** * Set version check info for composer.json * * @param array $data composer.json data * @param \titania_contribution $contrib * @return array Returns $data array with version check info set */ protected function set_version_check(array $data, \titania_contribution $contrib) { $data['extra'] = isset($data['extra']) && is_array($data['extra']) ? $data['extra'] : array(); unset($data['extra']['version_check']); $version_check_url = $contrib->get_url('version_check'); $parts = parse_url($version_check_url); if ($parts !== false) { $directory = substr($parts['path'], 0, strrpos($parts['path'], '/')); $data['extra']['version-check'] = array('host' => $parts['host'], 'directory' => $directory, 'filename' => substr($parts['path'], strlen($directory) + 1)); } return $data; }
/** * Update contrib release topics. * * @param array $row Contrib data array */ protected function update_contrib(array $row) { \users_overlord::$users[$row['user_id']] = $row; $contrib = new \titania_contribution(); $contrib->__set_array($row); $contrib->set_type($row['contrib_type']); $contrib->author = new \titania_author(); $contrib->author->__set_array($row); // Update the release topic $contrib->update_release_topic(); }
public function queue($mode, $queue_id = false) { switch ($mode) { case 'update_first_queue_post': $queue = new titania_queue(); $contrib = new titania_contribution(); $sql = 'SELECT * FROM ' . TITANIA_QUEUE_TABLE . ' q, ' . TITANIA_CONTRIBS_TABLE . ' c WHERE c.contrib_id = q.contrib_id' . ($queue_id ? ' AND queue_id = ' . (int) $queue_id : ''); $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $contrib->__set_array($row); $queue->__set_array($row); $queue->update_first_queue_post(false, $contrib); } phpbb::$db->sql_freeresult($result); unset($queue); break; case 'revision_queue_id': $sql = 'SELECT queue_id, revision_id FROM ' . TITANIA_QUEUE_TABLE; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $sql = 'UPDATE ' . TITANIA_REVISIONS_TABLE . ' SET revision_queue_id = ' . (int) $row['queue_id'] . ' WHERE revision_id = ' . (int) $row['revision_id']; phpbb::$db->sql_query($sql); } phpbb::$db->sql_freeresult($result); break; } }
/** * Sync queue * * @param string $mode * @param int|bool $queue_id (Optional) Queue id to limit to. Defaults to false. */ public function queue($mode, $queue_id = false) { switch ($mode) { case 'update_first_queue_post': $queue = new \titania_queue(); $contrib = new \titania_contribution(); $sql = 'SELECT * FROM ' . $this->queue_table . ' q, ' . $this->contribs_table . ' c WHERE c.contrib_id = q.contrib_id' . ($queue_id ? ' AND queue_id = ' . (int) $queue_id : ''); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $contrib->__set_array($row); $contrib->set_type($row['contrib_type']); $queue->__set_array($row); $queue->update_first_queue_post(false, $contrib); } $this->db->sql_freeresult($result); unset($queue); break; case 'revision_queue_id': $sql = 'SELECT queue_id, revision_id FROM ' . $this->queue_table; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $sql = 'UPDATE ' . $this->revisions_table . ' SET revision_queue_id = ' . (int) $row['queue_id'] . ' WHERE revision_id = ' . (int) $row['revision_id']; $this->db->sql_query($sql); } $this->db->sql_freeresult($result); break; } }
/** * 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'); }
/** * Undelete a topic * * @param int $topic_id */ public function undelete_topic($topic_id) { titania::add_lang('posting'); phpbb::$user->add_lang('mcp'); // Load the stuff we need $topic_object = $this->load_topic($topic_id); // Auth check $is_authed = false; if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) { $is_authed = true; } else { if (phpbb::$auth->acl_get('u_titania_post_mod_own')) { if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic_object->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) { $is_authed = true; } else { if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic_object->parent_id) { $contrib = new titania_contribution(); $contrib->load((int) $topic_object->parent_id); if ($contrib->is_author || $contrib->is_active_coauthor) { $is_authed = true; } } } } } // Check permissions if (!$is_authed) { titania::needs_auth(); } if (titania::confirm_box(true)) { $topic_object->undelete(); redirect($topic_object->get_url()); } else { titania::confirm_box(false, 'UNDELETE_TOPIC'); } redirect($topic_object->get_url()); }