adapt PHP code from XF 1.5 for 2.0 (no longer looking)

rebelde

Active member
Job has been filled. No longer looking.


I am hoping to find somebody to convert this code to XF 2.0 PHP style. I am happy to pay pretty well for what the job is.

This code is changes the message sent to our "Reports forum":
  • Puts the forum name in the title
  • Adds some links below the message.
Here is the XF 1.5 code diff:
PHP:
----------------------- library/XenForo/Model/Report.php -----------------------
index 84fcbd3c5..4ca782ae4 100644
@@ -462,6 +462,21 @@ class XenForo_Model_Report extends XenForo_Model
                 }

                $threadTitle = new XenForo_Phrase('reported_thread_title', $params, false);
+                $repTitle = "";
+                if ($contentType=='post')
+                {
+                    //$forum = XenForo_Model::create('XenForo_Model_Forum')->getForumByThreadId($content["thread_id"]);
+                    $repTitle = $contentInfo["node_title"].": '".$contentInfo["thread_title"]."'";                
+                }
+                else if ($contentType=='conversation_message')
+                {
+                    $repTitle = "Conversation message in '".$contentInfo["conversation"]["title"]."'";
+                }
+                else
+                {
+                    $threadTitle = new XenForo_Phrase('reported_thread_title', $params, false);
+                    $repTitle = $threadTitle->render();
+                }

                 /** @var $threadDw XenForo_DataWriter_Discussion_Thread */
                 $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
@@ -469,7 +484,7 @@ class XenForo_Model_Report extends XenForo_Model
                 $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_TRIM_TITLE, true);
                 $threadDw->bulkSet(array(
                     'node_id' => $reportForum['node_id'],
-                    'title' => $threadTitle->render(),
+                    'title' => $repTitle,
                     'user_id' => $viewingUser['user_id'],
                     'username' => $viewingUser['username']
                 ));
@@ -482,7 +497,18 @@ class XenForo_Model_Report extends XenForo_Model
                 $postWriter->set('message', $message->render());
                 $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $reportForum);

-                return $threadDw->save();
+                //hack to get the report thread id
+                $tmpReturn = $threadDw->save();
+                if ($tmpReturn) {
+                    $threadUrl = XenForo_Link::buildPublicLink('canonical:threads', $contentInfo);
+                    $reportThreadUrl = XenForo_Link::buildPublicLink('canonical:threads', array("thread_id" => $threadDw->get('thread_id')));
+                    $dwPost = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
+                    $dwPost->setExistingData($postWriter->get('post_id'));
+                    $dwPost->set('message', $message->render()."\n\n[url='".$threadUrl."edit']Edit Thread[/url]\n[url='".$threadUrl."move']Move Thread[/url]\n[url='".$reportThreadUrl."move']Move Report to Reports Bin[/url]");
+                    $dwPost->save();
+                }
+
+                return $tmpReturn;
             }

             return false;

If you can help me out, please send me a message!
 
Last edited:
Top