public function submit() { // Subscriptions if (!$this->attention_id) { $u_view = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => $this->attention_type, 'id' => $this->attention_object_id)); $email_vars = array('NAME' => $this->attention_title, 'U_VIEW' => $this->path_helper->strip_url_params($u_view, 'sid')); $this->subscriptions->send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify', $email_vars, $this->attention_poster_id); } parent::submit(); }
/** * Send notification for new post. * * @param \titania_post $post New post * @param string $mode Post mode: post|reply */ protected function send_notifications(\titania_post $post, $mode) { $is_support_topic = $post->post_type == TITANIA_SUPPORT && is_object($this->contrib) && $this->contrib->contrib_id == $post->topic->parent_id && $this->contrib->contrib_name; $template = 'subscribe_notify'; $topic_params = array(); $email_vars = array('NAME' => htmlspecialchars_decode($post->topic->topic_subject)); if ($is_support_topic) { $email_vars['CONTRIB_NAME'] = $this->contrib->contrib_name; } if ($mode == 'reply') { $object_type = array(TITANIA_TOPIC); $object_id = array($post->topic_id); $topic_params = array('view' => 'unread', '#' => 'unread'); if ($is_support_topic) { // Support topic reply $object_id[] = $post->topic->parent_id; $object_type[] = TITANIA_SUPPORT; $template .= '_contrib'; } } else { $object_type = $post->post_type; $object_id = $post->topic->parent_id; $template .= $is_support_topic ? '_forum_contrib' : '_forum'; } $email_vars['U_VIEW'] = $post->topic->get_url(false, $topic_params); $this->subscriptions->send_notifications($object_type, $object_id, $template, $email_vars, $post->post_user_id); }
/** * 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'); }
/** * Display attention item list. * * @return \Symfony\Component\HttpFoundation\Response */ public function display_list() { $this->user->add_lang('mcp'); if (!$this->check_auth()) { return $this->helper->needs_auth(); } $type = $this->request->variable('type', ''); $closed = $this->request->variable('closed', false); $open = $this->request->variable('open', false) || !$closed; switch ($type) { case 'reported': $type = TITANIA_ATTENTION_REPORTED; break; case 'unapproved': $type = TITANIA_ATTENTION_UNAPPROVED; break; default: $type = false; break; } $options = array('attention_type' => $type, 'display_closed' => $closed, 'only_closed' => !$open && $closed); \attention_overlord::display_attention_list($options); $this->template->assign_vars(array('S_ACTION' => $this->helper->route('phpbb.titania.manage.attention'), 'S_OPEN_CHECKED' => $open, 'S_CLOSED_CHECKED' => $closed)); // Subscriptions $this->subscriptions->handle_subscriptions(TITANIA_ATTENTION, 0, $this->helper->route('phpbb.titania.manage.attention')); $this->display->assign_global_vars(); $this->generate_navigation('attention'); return $this->helper->render('manage/attention.html', $this->user->lang['ATTENTION']); }
/** * Display queue. * * @return \Symfony\Component\HttpFoundation\Response */ public function display_queue($queue_type) { $this->set_type($this->types->type_from_url($queue_type)); if (!$this->type->acl_get('view')) { return $this->helper->needs_auth(); } $tag = $this->request->variable('tag', 0); // Subscriptions if (!$tag) { $this->subscriptions->handle_subscriptions(TITANIA_QUEUE, $this->type->id, $this->helper->get_current_url(), 'SUBSCRIBE_QUEUE'); } else { $this->subscriptions->handle_subscriptions(TITANIA_QUEUE_TAG, $tag, $this->helper->get_current_url(), 'SUBSCRIBE_CATEGORY'); } \queue_overlord::display_queue($this->type->id, $tag); \queue_overlord::display_categories($this->type->id, $tag); $this->display->assign_global_vars(); $this->generate_navigation('queue'); // Add to Breadcrumbs $this->display->generate_breadcrumbs(array($this->type->lang => $this->get_queue_url($this->type->id))); return $this->helper->render('manage/queue.html', 'VALIDATION_QUEUE'); }
/** * Subscribe new coauthors to contrib support section. * * @param array $old_coauthors Value of contrib's "coauthors" property * @param array $new_coauthors Array of new active coauthors */ protected function subscribe_new_coauthors(array $old_coauthors, array $new_coauthors) { $old_active = array(); foreach ($old_coauthors as $id => $data) { if ($data['active']) { $old_active[] = (int) $id; } } $subscribe = array_diff($new_coauthors, $old_active); foreach ($subscribe as $user_id) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $this->contrib->contrib_id, $user_id); } }
/** * Check whether the author is subscribed to the queue discussion topic. * * @return bool */ protected function is_author_subscribed() { if ($this->use_queue) { $this->queue->contrib_id = $this->contrib->contrib_id; // Get queue discussion topic id if it exists $this->queue->get_queue_discussion_topic(true); if (!empty($this->queue->queue_discussion_topic_id)) { // Is the author subscribed already? return $this->subscriptions->is_subscribed(TITANIA_TOPIC, $this->queue->queue_discussion_topic_id); } } return false; }
/** * Handle some stuff we need when submitting a revision */ public function submit() { if (!$this->revision_id) { // Update the contrib_last_update if required here if (!titania::$config->require_validation || !$this->contrib->type->require_validation) { $this->contrib->contrib_last_update = titania::$time; $sql_ary = array('contrib_last_update' => $this->contrib->contrib_last_update); $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Subscriptions $email_vars = array('NAME' => $this->contrib->contrib_name, 'U_VIEW' => $this->contrib->get_url()); $this->subscriptions->send_notifications(TITANIA_CONTRIB, $this->contrib_id, 'subscribe_notify', $email_vars); } } else { if (sizeof($this->phpbb_versions)) { $sql = 'DELETE FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' WHERE revision_id = ' . (int) $this->revision_id; phpbb::$db->sql_query($sql); } } parent::submit(); // Add phpBB versions supported if (sizeof($this->phpbb_versions)) { $versions = titania::$cache->get_phpbb_versions(); $sql_ary = array(); foreach ($this->phpbb_versions as $row) { if (!is_array($row)) { $row = array('phpbb_version_branch' => (int) $row); } if (!isset($row['phpbb_version_branch']) || !isset(titania::$config->phpbb_versions[$row['phpbb_version_branch']])) { continue; } // OMG, it's not in our cache! if (!isset($versions[$row['phpbb_version_branch'] . titania::$config->phpbb_versions[$row['phpbb_version_branch']]['latest_revision']])) { titania::$cache->destroy('_titania_phpbb_versions'); } $sql_ary[] = array('revision_id' => $this->revision_id, 'contrib_id' => $this->contrib_id, 'revision_validated' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'phpbb_version_branch' => $row['phpbb_version_branch'], 'phpbb_version_revision' => $this->get_real_phpbb_version(isset($row['phpbb_version_revision']) ? $row['phpbb_version_revision'] : titania::$config->phpbb_versions[$row['phpbb_version_branch']]['latest_revision'])); } if (sizeof($sql_ary)) { phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary); } } // Update the release topic if ($this->revision_status == TITANIA_REVISION_APPROVED) { $this->contrib->update_release_topic(); } // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }
/** * Approve this revision * * @param mixed $public_notes */ public function approve($public_notes) { $this->user->add_lang_ext('phpbb/titania', array('manage', 'contributions')); $revision = $this->get_revision(); $contrib = new titania_contribution(); if (!$contrib->load($this->contrib_id) || !$contrib->is_visible()) { return false; } $revision->contrib = $contrib; $revision->load_phpbb_versions(); $branch = (int) $revision->phpbb_versions[0]['phpbb_version_branch']; $contrib_release_topic_id = $contrib->get_release_topic_id($branch); $notes = $this->validation_notes; message::decode($notes, $this->validation_notes_uid); $message = sprintf(phpbb::$user->lang['QUEUE_REPLY_APPROVED'], $revision->revision_version, $notes); // Replace empty quotes if there are no notes if (!$notes) { $message = str_replace('[quote][/quote]', '', $message); } $this->topic_reply($message, false); $this->discussion_reply($message); // Update the revisions $revision->change_status(TITANIA_REVISION_APPROVED); $revision->submit(); // Reply to the release topic if ($contrib_release_topic_id && $contrib->type->update_public) { // Replying to an already existing topic, use the update message $public_notes = sprintf(phpbb::$user->lang[$contrib->type->update_public], $revision->revision_version) . ($public_notes ? sprintf(phpbb::$user->lang[$contrib->type->update_public . '_NOTES'], $public_notes) : ''); $contrib->reply_release_topic($branch, $public_notes); } elseif (!$contrib_release_topic_id && $contrib->type->reply_public) { // Replying to a topic that was just made, use the reply message $public_notes = phpbb::$user->lang[$contrib->type->reply_public] . ($public_notes ? sprintf(phpbb::$user->lang[$contrib->type->reply_public . '_NOTES'], $public_notes) : ''); $contrib->reply_release_topic($branch, $public_notes); } // Self-updating $this->queue_status = TITANIA_QUEUE_APPROVED; $this->queue_close_time = titania::$time; $this->queue_close_user = phpbb::$user->data['user_id']; $this->submit(false); // Send notification message $this->send_approve_deny_notification(true); // Subscriptions $email_vars = array('NAME' => $contrib->contrib_name, 'U_VIEW' => $contrib->get_url()); $this->subscriptions->send_notifications(TITANIA_CONTRIB, $this->contrib_id, 'subscribe_notify', $email_vars); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }
/** * Details page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function details() { $this->contrib->get_download(); $this->contrib->get_revisions(); $this->contrib->get_screenshots(); $this->contrib->get_rating(); $this->contrib->assign_details(); if (!$this->user->data['is_bot']) { $this->contrib->increase_view_counter(); } // Set tracking $this->tracking->track(TITANIA_CONTRIB, $this->contrib->contrib_id); // Subscriptions $this->subscriptions->handle_subscriptions(TITANIA_CONTRIB, $this->contrib->contrib_id, $this->contrib->get_url(), 'SUBSCRIBE_CONTRIB'); // Canonical URL $this->template->assign_var('U_CANONICAL', $this->contrib->get_url()); return $this->helper->render('contributions/contribution_details.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['CONTRIB_DETAILS']); }
/** * Display support page. * * @param string $contrib_type Contrib type URL identifier. * @param string $contrib Contrib name clean. * * @return \Symfony\Component\HttpFoundation\Response */ public function display_support($contrib_type, $contrib) { $this->load_contrib($contrib_type, $contrib); if (!$this->check_auth()) { return $this->helper->needs_auth(); } $this->user->add_lang('viewforum'); // Subscriptions $this->subscriptions->handle_subscriptions(TITANIA_SUPPORT, $this->contrib->contrib_id, $this->contrib->get_url('support'), 'SUBSCRIBE_SUPPORT'); // Mark all topics read if ($this->request->variable('mark', '') == 'topics') { $this->tracking->track(TITANIA_SUPPORT, $this->contrib->contrib_id); } $can_post_topic = $this->ext_config->support_in_titania && $this->auth->acl_get('u_titania_topic'); $data = \topics_overlord::display_forums_complete('support', $this->contrib); $data['sort']->set_url($this->contrib->get_url('support')); $this->template->assign_vars(array('U_POST_TOPIC' => $can_post_topic ? $this->contrib->get_url('posting') : '', 'U_MARK_TOPICS' => $this->contrib->get_url('support', array('mark' => 'topics')), 'U_CANONICAL' => $data['sort']->build_canonical(), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => $this->helper->route('phpbb.titania.search.results'), 'SEARCH_HIDDEN_FIELDS' => build_hidden_fields(array('type' => TITANIA_SUPPORT, 'contrib' => $this->contrib->contrib_id)))); $this->assign_vars(); return $this->helper->render('contributions/contribution_support.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['CONTRIB_SUPPORT']); }
/** * Send notifications. * * @param int|array $object_type * @param int|array $object_id * @param string $email_template * @param array $message_vars */ public function send_notifications($object_type, $object_id, $email_template, $message_vars) { $this->load_contrib_object(); $message_vars = array_merge($message_vars, array('NAME' => $this->post->topic->topic_subject, 'CONTRIB_NAME' => $this->contrib->contrib_name)); $this->subscriptions->send_notifications($object_type, $object_id, $email_template, $message_vars, $this->post->post_user_id); }