/** * 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); }