Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions controller/manage/queue/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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('<br />', $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;
Expand Down
43 changes: 28 additions & 15 deletions includes/objects/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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));
}
}

Expand All @@ -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(
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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');
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions language/en/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 12 additions & 0 deletions styles/prosilver/template/manage/queue_validate.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ <h3>{{ lang('PREVIEW') ~ lang('COLON') }} {{ PUBLIC_PREVIEW_SUBJECT }}</h3>
<h2>{{ PAGE_TITLE }}</h2>
<p>{{ PAGE_TITLE_EXPLAIN }}</p>

{% if S_SHOW_POST_AS_OPTION %}
<fieldset>
<dl>
<dt style="width: auto"><label>{{ POST_AS_LABEL ~ lang('COLON') }}</label></dt>
<dd style="margin: 0 0 12px 10%">
<label><input type="radio" name="post_as_robot" value="1"{% if POST_AS_ROBOT %} checked="checked"{% endif %} />{{ ROBOT_NAME }}</label>
<label><input type="radio" name="post_as_robot" value="0"{% if not POST_AS_ROBOT %} checked="checked"{% endif %} />{{ lang('POST_AS_SELF') }}</label>
</dd>
</dl>
</fieldset>
{% endif %}

<fieldset>
{% if S_STYLE_DEMO_INSTALL %}
<dl>
Expand Down