Skip to content

Commit 5d60444

Browse files
committed
Post approved/denied exts/styles with robot user
1 parent f280410 commit 5d60444

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public function set_default_config()
185185
'31' => array('latest_revision' => '12', 'name' => 'phpBB 3.1.x', 'allow_uploads' => false),
186186
'32' => array('latest_revision' => '11', 'name' => 'phpBB 3.2.x', 'allow_uploads' => false),
187187
'33' => array('latest_revision' => '15', 'name' => 'phpBB 3.3.x', 'allow_uploads' => true),
188+
'40' => array('latest_revision' => '0', 'name' => 'phpBB 4.0.x', 'allow_uploads' => true),
188189
)),
189190

190191
// MPV server(s)

controller/manage/queue/item.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ public function approve()
393393

394394
if ($this->validate('approve'))
395395
{
396-
$this->queue->approve($public_notes);
396+
$robot_user_id = $this->contrib->type->forum_robot;
397+
$this->queue->approve($public_notes, $robot_user_id);
397398

398399
// Reload contribution with new data.
399400
$this->contrib->load();
@@ -433,7 +434,8 @@ public function deny()
433434
{
434435
if ($this->validate('deny'))
435436
{
436-
$this->queue->deny();
437+
$robot_user_id = $this->contrib->type->forum_robot;
438+
$this->queue->deny($robot_user_id);
437439
$this->contrib->type->deny($this->contrib, $this->queue, $this->request);
438440
redirect($this->queue->get_url());
439441
}

includes/objects/queue.php

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ public function update_first_queue_post($post_subject = false)
230230
*
231231
* @param string $message
232232
* @param bool $teams_only true to set to access level of teams
233+
* @param int $post_user_id User ID to use for the post (defaults to current user)
233234
* @return \titania_post Returns post object.
234235
*/
235-
public function topic_reply($message, $teams_only = true)
236+
public function topic_reply($message, $teams_only = true, $post_user_id = 0)
236237
{
237238
$this->user->add_lang_ext('phpbb/titania', 'manage');
238239

@@ -249,6 +250,11 @@ public function topic_reply($message, $teams_only = true)
249250
$post->post_access = access::TEAM_LEVEL;
250251
}
251252

253+
if ($post_user_id)
254+
{
255+
$post->post_user_id = (int) $post_user_id;
256+
}
257+
252258
$post->parent_contrib_type = $this->queue_type;
253259

254260
$post->generate_text_for_storage(true, true, true);
@@ -384,8 +390,9 @@ public function change_tested_mark($mark)
384390
* Approve this revision
385391
*
386392
* @param mixed $public_notes
393+
* @param int $robot_user_id User ID to use for posts/messages (defaults to current user)
387394
*/
388-
public function approve($public_notes)
395+
public function approve($public_notes, $robot_user_id = 0)
389396
{
390397
$this->user->add_lang_ext('phpbb/titania', array('manage', 'contributions'));
391398
$revision = $this->get_revision();
@@ -407,8 +414,8 @@ public function approve($public_notes)
407414
$message = str_replace('[quote][/quote]', '', $message);
408415
}
409416

410-
$this->topic_reply($message, false);
411-
$this->discussion_reply($message);
417+
$this->topic_reply($message, false, $robot_user_id);
418+
$this->discussion_reply($message, false, $robot_user_id);
412419

413420
// Get branch information first
414421
$version_branches = array();
@@ -430,13 +437,13 @@ public function approve($public_notes)
430437
{
431438
// Replying to an already existing topic, use the update message
432439
$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) : '');
433-
$contrib->reply_release_topic($branch, $post_public_notes);
440+
$contrib->reply_release_topic($branch, $post_public_notes, array('poster_id' => $robot_user_id));
434441
}
435442
elseif (!$contrib_release_topic_id && $contrib->type->reply_public)
436443
{
437444
// Replying to a topic that was just made, use the reply message
438445
$post_public_notes = phpbb::$user->lang[$contrib->type->reply_public] . (($public_notes) ? sprintf(phpbb::$user->lang[$contrib->type->reply_public . '_NOTES'], $public_notes) : '');
439-
$contrib->reply_release_topic($branch, $post_public_notes);
446+
$contrib->reply_release_topic($branch, $post_public_notes, array('poster_id' => $robot_user_id));
440447
}
441448
}
442449

@@ -447,7 +454,7 @@ public function approve($public_notes)
447454
$this->submit(false);
448455

449456
// Send notification message
450-
$this->send_approve_deny_notification(true);
457+
$this->send_approve_deny_notification(true, $robot_user_id);
451458

452459
// Subscriptions
453460
$email_vars = array(
@@ -474,7 +481,7 @@ public function close($revision_status)
474481
$this->trash_queue_topic();
475482
}
476483

477-
public function deny()
484+
public function deny($robot_user_id = 0)
478485
{
479486
// Reply to the queue topic and discussion with the message
480487
$this->user->add_lang_ext('phpbb/titania', 'manage');
@@ -490,8 +497,8 @@ public function deny()
490497
$message = str_replace('[quote][/quote]', '', $message);
491498
}
492499

493-
$this->topic_reply($message, false);
494-
$this->discussion_reply($message);
500+
$this->topic_reply($message, false, $robot_user_id);
501+
$this->discussion_reply($message, false, $robot_user_id);
495502

496503
// Update the revision
497504
$revision->change_status(ext::TITANIA_REVISION_DENIED);
@@ -503,15 +510,17 @@ public function deny()
503510
$this->submit(false);
504511

505512
// Send notification message
506-
$this->send_approve_deny_notification(false);
513+
$this->send_approve_deny_notification(false, $robot_user_id);
507514

508515
$this->trash_queue_topic();
509516
}
510517

511518
/**
512519
* Send the approve/deny notification
520+
* @param bool $approve
521+
* @param int $robot_user_id User ID to use as sender (defaults to current user)
513522
*/
514-
private function send_approve_deny_notification($approve = true)
523+
private function send_approve_deny_notification($approve = true, $robot_user_id = 0)
515524
{
516525
$this->user->add_lang_ext('phpbb/titania', 'manage');
517526
phpbb::_include('functions_privmsgs', 'submit_pm');
@@ -560,12 +569,16 @@ private function send_approve_deny_notification($approve = true)
560569
$message_uid = $message_bitfield = $message_options = false;
561570
generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true);
562571

572+
$sender_id = $robot_user_id ?: phpbb::$user->data['user_id'];
573+
$sender_name = users_overlord::get_user($sender_id, 'username', true);
574+
$sender_ip = $robot_user_id ? '' : phpbb::$user->ip;
575+
563576
$data = array(
564577
'address_list' => array('u' => $authors),
565-
'from_user_id' => phpbb::$user->data['user_id'],
566-
'from_username' => phpbb::$user->data['username'],
578+
'from_user_id' => $sender_id,
579+
'from_username' => $sender_name,
567580
'icon_id' => 0,
568-
'from_user_ip' => phpbb::$user->ip,
581+
'from_user_ip' => $sender_ip,
569582
'enable_bbcode' => true,
570583
'enable_smilies' => true,
571584
'enable_urls' => true,

0 commit comments

Comments
 (0)