diff --git a/controller/manage/queue/item.php b/controller/manage/queue/item.php
index f567959b3..6dbf31615 100644
--- a/controller/manage/queue/item.php
+++ b/controller/manage/queue/item.php
@@ -390,10 +390,12 @@ protected function move()
public function approve()
{
$public_notes = $this->request->variable('public_notes', '', true);
+ $post_as_robot = $this->request->variable('post_as_robot', 1);
if ($this->validate('approve'))
{
- $this->queue->approve($public_notes);
+ $robot_user_id = $post_as_robot ? $this->contrib->type->forum_robot : 0;
+ $this->queue->approve($public_notes, $robot_user_id);
// Reload contribution with new data.
$this->contrib->load();
@@ -431,9 +433,12 @@ public function approve()
*/
public function deny()
{
+ $post_as_robot = $this->request->variable('post_as_robot', 1);
+
if ($this->validate('deny'))
{
- $this->queue->deny();
+ $robot_user_id = $post_as_robot ? $this->contrib->type->forum_robot : 0;
+ $this->queue->deny($robot_user_id);
$this->contrib->type->deny($this->contrib, $this->queue, $this->request);
redirect($this->queue->get_url());
}
@@ -474,12 +479,20 @@ protected function validate($action)
$this->contrib->type->display_validation_options($action, $this->request, $this->template);
$this->display_topic_review();
+ $post_as_robot = $this->request->variable('post_as_robot', 1);
+ $has_robot = !empty($this->contrib->type->forum_robot);
+ $robot_name = $has_robot ? \users_overlord::get_user($this->contrib->type->forum_robot, 'username', true) : '';
+
$this->template->assign_vars(array(
'ERROR' => implode('
', $error),
'L_TOPIC_REVIEW' => $this->user->lang['QUEUE_REVIEW'],
'TOPIC_TITLE' => $this->contrib->contrib_name,
'PAGE_TITLE_EXPLAIN' => $this->user->lang[strtoupper($action) . '_QUEUE_CONFIRM'],
'S_CONFIRM_ACTION' => $this->queue->get_url($action),
+ 'S_SHOW_POST_AS_OPTION' => $has_robot && $robot_name,
+ 'POST_AS_ROBOT' => $post_as_robot,
+ 'ROBOT_NAME' => $robot_name,
+ 'POST_AS_LABEL' => $this->user->lang['POST_AS_' . strtoupper($action)],
));
return false;
diff --git a/includes/objects/queue.php b/includes/objects/queue.php
index 89241ea22..daf7d07e9 100644
--- a/includes/objects/queue.php
+++ b/includes/objects/queue.php
@@ -230,9 +230,10 @@ public function update_first_queue_post($post_subject = false)
*
* @param string $message
* @param bool $teams_only true to set to access level of teams
+ * @param int $post_user_id User ID to use for the post (defaults to current user)
* @return \titania_post Returns post object.
*/
- public function topic_reply($message, $teams_only = true)
+ public function topic_reply($message, $teams_only = true, $post_user_id = 0)
{
$this->user->add_lang_ext('phpbb/titania', 'manage');
@@ -249,6 +250,11 @@ public function topic_reply($message, $teams_only = true)
$post->post_access = access::TEAM_LEVEL;
}
+ if ($post_user_id)
+ {
+ $post->post_user_id = (int) $post_user_id;
+ }
+
$post->parent_contrib_type = $this->queue_type;
$post->generate_text_for_storage(true, true, true);
@@ -384,8 +390,9 @@ public function change_tested_mark($mark)
* Approve this revision
*
* @param mixed $public_notes
+ * @param int $robot_user_id User ID to use for posts/messages (defaults to current user)
*/
- public function approve($public_notes)
+ public function approve($public_notes, $robot_user_id = 0)
{
$this->user->add_lang_ext('phpbb/titania', array('manage', 'contributions'));
$revision = $this->get_revision();
@@ -407,8 +414,8 @@ public function approve($public_notes)
$message = str_replace('[quote][/quote]', '', $message);
}
- $this->topic_reply($message, false);
- $this->discussion_reply($message);
+ $this->topic_reply($message, false, $robot_user_id);
+ $this->discussion_reply($message, false, $robot_user_id);
// Get branch information first
$version_branches = array();
@@ -430,13 +437,13 @@ public function approve($public_notes)
{
// Replying to an already existing topic, use the update message
$post_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, $post_public_notes);
+ $contrib->reply_release_topic($branch, $post_public_notes, array('poster_id' => $robot_user_id));
}
elseif (!$contrib_release_topic_id && $contrib->type->reply_public)
{
// Replying to a topic that was just made, use the reply message
$post_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, $post_public_notes);
+ $contrib->reply_release_topic($branch, $post_public_notes, array('poster_id' => $robot_user_id));
}
}
@@ -447,7 +454,7 @@ public function approve($public_notes)
$this->submit(false);
// Send notification message
- $this->send_approve_deny_notification(true);
+ $this->send_approve_deny_notification(true, $robot_user_id);
// Subscriptions
$email_vars = array(
@@ -474,7 +481,7 @@ public function close($revision_status)
$this->trash_queue_topic();
}
- public function deny()
+ public function deny($robot_user_id = 0)
{
// Reply to the queue topic and discussion with the message
$this->user->add_lang_ext('phpbb/titania', 'manage');
@@ -490,8 +497,8 @@ public function deny()
$message = str_replace('[quote][/quote]', '', $message);
}
- $this->topic_reply($message, false);
- $this->discussion_reply($message);
+ $this->topic_reply($message, false, $robot_user_id);
+ $this->discussion_reply($message, false, $robot_user_id);
// Update the revision
$revision->change_status(ext::TITANIA_REVISION_DENIED);
@@ -503,15 +510,17 @@ public function deny()
$this->submit(false);
// Send notification message
- $this->send_approve_deny_notification(false);
+ $this->send_approve_deny_notification(false, $robot_user_id);
$this->trash_queue_topic();
}
/**
* Send the approve/deny notification
+ * @param bool $approve
+ * @param int $robot_user_id User ID to use as sender (defaults to current user)
*/
- private function send_approve_deny_notification($approve = true)
+ private function send_approve_deny_notification($approve = true, $robot_user_id = 0)
{
$this->user->add_lang_ext('phpbb/titania', 'manage');
phpbb::_include('functions_privmsgs', 'submit_pm');
@@ -560,12 +569,16 @@ private function send_approve_deny_notification($approve = true)
$message_uid = $message_bitfield = $message_options = false;
generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true);
+ $sender_id = $robot_user_id ?: phpbb::$user->data['user_id'];
+ $sender_name = users_overlord::get_user($sender_id, 'username', true);
+ $sender_ip = $robot_user_id ? '' : phpbb::$user->ip;
+
$data = array(
'address_list' => array('u' => $authors),
- 'from_user_id' => phpbb::$user->data['user_id'],
- 'from_username' => phpbb::$user->data['username'],
+ 'from_user_id' => $sender_id,
+ 'from_username' => $sender_name,
'icon_id' => 0,
- 'from_user_ip' => phpbb::$user->ip,
+ 'from_user_ip' => $sender_ip,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
diff --git a/language/en/manage.php b/language/en/manage.php
index 7e83d4309..9eec1e0cd 100644
--- a/language/en/manage.php
+++ b/language/en/manage.php
@@ -84,6 +84,9 @@
'OPEN_ITEMS' => 'Open Items',
'PLEASE_WAIT_FOR_TOOL' => 'Please wait for the tool to finish running.',
+ 'POST_AS_APPROVE' => 'Approve as',
+ 'POST_AS_DENY' => 'Deny as',
+ 'POST_AS_SELF' => 'Yourself',
'PUBLIC_NOTES' => 'Public release notes',
'QUEUE_APPROVE' => 'Awaiting Approval',
diff --git a/styles/prosilver/template/manage/queue_validate.html b/styles/prosilver/template/manage/queue_validate.html
index d9b21959b..78af05e8d 100644
--- a/styles/prosilver/template/manage/queue_validate.html
+++ b/styles/prosilver/template/manage/queue_validate.html
@@ -26,6 +26,18 @@
{{ PAGE_TITLE_EXPLAIN }}
+ {% if S_SHOW_POST_AS_OPTION %} + + {% endif %} +