Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
    /**
     * 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);
    }
Exemplo n.º 4
0
 /**
  * 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);
 }
Exemplo n.º 5
0
 /**
  * New revision submission action.
  *
  * @param string $contrib_type		Contrib type URL identifier.
  * @param string $contrib			Contrib name clean.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function add($contrib_type, $contrib)
 {
     $this->setup($contrib_type, $contrib);
     if (!$this->check_auth()) {
         return $this->helper->needs_auth();
     }
     $this->revisions_in_queue = $this->contrib->in_queue();
     $allowed_branches = $this->get_allowed_branches();
     if (empty($allowed_branches)) {
         return $this->helper->error('REVISION_IN_QUEUE');
     }
     if ($this->use_queue) {
         $this->queue = new \titania_queue();
         $message = $this->get_message();
         $message->display();
     }
     $error = array();
     if ($this->request->is_set_post('new_revision')) {
         $result = $this->process_steps();
         if ($result['complete']) {
             $this->submit();
             if ($this->use_queue) {
                 // Subscriptions
                 $this->queue = $this->revision->get_queue();
                 $email_vars = array('NAME' => $this->user->lang['VALIDATION'] . ' - ' . $this->contrib->contrib_name . ' - ' . $this->revision->revision_version, 'U_VIEW' => $this->queue->get_url());
                 $this->subscriptions->send_notifications(TITANIA_QUEUE, $this->contrib->contrib_type, 'subscribe_notify_forum', $email_vars, $this->user->data['user_id']);
             }
             redirect($this->contrib->get_url());
         } else {
             if (isset($result['response'])) {
                 return $result['response'];
             }
         }
         $error = $result['error'];
     } else {
         if ($this->request->is_set_post('cancel')) {
             $this->cancel();
         }
     }
     $this->assign_common_vars($error, !empty($this->id));
     $this->template->assign_vars(array('S_CAN_SUBSCRIBE' => !$this->is_author_subscribed() && $this->use_queue, 'SUBSCRIBE_AUTHOR' => $this->request->variable('subscribe_author', false), 'S_POST_ACTION' => $this->contrib->get_url('revision')));
     add_form_key('postform');
     return $this->helper->render('contributions/contribution_revision.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['NEW_REVISION']);
 }
Exemplo n.º 6
0
 /**
  * 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);
 }