[XenMods] Announcements [Deleted]

Daniel Hood

Well-known member
Daniel Hood submitted a new resource:

PHP Help Center Announcements - Make global sticky threads

Announcements (Beta 1 RC)

Want one (or more) of your sticky threads to appear at the top of all your nodes and on the board index (sort of like a notice but as a thread)? This add on gives you that ability.

There's a new page in the admin panel that lists all the sticky threads on your forum and gives you the option to announce them (it also lists all announcements with the option to denounce them).

Admin CP
1.png
...

Read more about this resource...
 
That's a weird error? Try uninstalling and deleting and then trying again. Did you refresh in the middle of the installation or did it error before that so you tried again or something?
 
I just realized an event listener that was supposed to be disabled was left on and made it into the xml file. Uploading a revision in a minute. Thanks for pointing it out.
 
Hi does it works on 1.1.3 version of Xenforo ?
Using RichUsername, got this message when using the addon in Admin :

Code:
Argument 2 passed to RichUsernameEverywhere_Thread::prepareThread() must be an array, boolean given, called in /home/e-smith/files/ibays/forumasus/html/www/library/PHCannouncements/Model/Threads.php on line 42 and defined

    XenForo_Application::handlePhpError() in RichUsernameEverywhere/Thread.php at line 41
    RichUsernameEverywhere_Thread->prepareThread() in PHCannouncements/Model/Threads.php at line 42
    PHCannouncements_Model_Threads->Stickies() in PHCannouncements/ControllerAdmin/Index.php at line 12
    PHCannouncements_ControllerAdmin_Index->actionIndex() in XenForo/FrontController.php at line 310
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
    XenForo_FrontController->run() in /home/e-smith/files/ibays/forumasus/html/www/admin.php at line 13
 
I don't have version 1.1.3 downloaded so I can't see; could you post this section of code (should be one of the first few lines of code) from /upload/library/XenForo/Model/Forum.php

PHP:
public function getForumById($id, array $fetchOptions = array())
{
/*
All this code
*/
}
 
PHP:
public function getForumById($id, array $fetchOptions = array())
    {
        $joinOptions = $this->prepareForumJoinOptions($fetchOptions);

        return $this->_getDb()->fetchRow('
            SELECT node.*, forum.*
                ' . $joinOptions['selectFields'] . '
            FROM xf_forum AS forum
            INNER JOIN xf_node AS node ON (node.node_id = forum.node_id)
            ' . $joinOptions['joinTables'] . '
            WHERE node.node_id = ?
        ', $id);
    }
 
Can you try disabling RichUsernameEverywhere for a second and see if it works? Also, is it possible you have a sticky thread in a node that you deleted?
 
Code:
Argument 2 passed to Dark_PostRating_Model_Thread::prepareThread() must be an array, boolean given, called in /home/e-smith/files/ibays/forumasus/html/www/library/PHCannouncements/Model/Threads.php on line 42 and defined

    XenForo_Application::handlePhpError() in Dark/PostRating/Model/Thread.php at line 35
    Dark_PostRating_Model_Thread->prepareThread() in PHCannouncements/Model/Threads.php at line 42
    PHCannouncements_Model_Threads->Stickies() in PHCannouncements/ControllerAdmin/Index.php at line 12
    PHCannouncements_ControllerAdmin_Index->actionIndex() in XenForo/FrontController.php at line 310
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
    XenForo_FrontController->run() in /home/e-smith/files/ibays/forumasus/html/www/admin.php at line 13
 
Don't know really if i have, i shall browse all my forum ;)
(an addon would be welcome for that purpose lol)
 
Code:
SELECT thread.thread_id, node.title as nodeTitle FROM `xf_thread` thread LEFT JOIN xf_node node on node.node_id = thread.node_id WHERE thread.sticky = 1

if nodeTitle says NULL for any rows, that's the issue.
 
Change in file /upload/library/PHCannouncements/Model/Threads.php

Code:
    function Stickies()
    {      
        $ThreadModel = XenForo_Model::create('XenForo_Model_Thread');
        $ForumModel = XenForo_Model::create('XenForo_Model_Forum');
     
        $_getThreads = $this->_getDb()->fetchAll("SELECT thread.thread_id as thread_id, thread.node_id
            FROM xf_thread as thread
            WHERE thread.sticky = 1
            ORDER BY thread.last_post_date DESC"
        );
     
        $Threads = array();
     
        for ($i = 0; $i < count($_getThreads); $i++)
        {
            $Thread = $ThreadModel->prepareThread($ThreadModel->getThreadById($_getThreads[$i]['thread_id'], array('join' => 17)), $ForumModel->getForumById($_getThreads[$i]['node_id']));
            $Thread['canInlineMod'] = false;
            $Thread['canEditThread'] = false;
            $Threads[] = $Thread;
        }
     
     
        return $Threads;
    }

to

Code:
    function Stickies()
    {      
        $ThreadModel = XenForo_Model::create('XenForo_Model_Thread');
        $ForumModel = XenForo_Model::create('XenForo_Model_Forum');
     
        $_getThreads = $this->_getDb()->fetchAll("SELECT thread.thread_id as thread_id, thread.node_id
            FROM xf_thread as thread
            WHERE thread.sticky = 1
            ORDER BY thread.last_post_date DESC"
        );
     
        $Threads = array();
     
        for ($i = 0; $i < count($_getThreads); $i++)
        {
            var_dump(array('id' => $_getThreads[$i]['node_id'], 'result' => $ForumModel->getForumById($_getThreads[$i]['node_id'])));
            $Thread = $ThreadModel->prepareThread($ThreadModel->getThreadById($_getThreads[$i]['thread_id'], array('join' => 17)), $ForumModel->getForumById($_getThreads[$i]['node_id']));
            $Thread['canInlineMod'] = false;
            $Thread['canEditThread'] = false;
            $Threads[] = $Thread;
        }
     
     
        return $Threads;
    }

and let me know what the page shows
 
Top Bottom