@@ -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