AndyB
Well-known member
I'm creating this add-on which queries the database. I'm told this isn't the proper way and I should use the Model instead.
This is my directory structure at this point.
library
--Andy
----ShowDeleted
------ControllerPublic
--------ShowDeleted.php
----Route
------Prefix
--------ShowDeleted.php
library/ShowDeleted/ControllerPublic/ShowDeleted.php
This is my directory structure at this point.
library
--Andy
----ShowDeleted
------ControllerPublic
--------ShowDeleted.php
----Route
------Prefix
--------ShowDeleted.php
library/ShowDeleted/ControllerPublic/ShowDeleted.php
PHP:
<?php
class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XenForo_ControllerPublic_Abstract
{
public function actionIndex()
{
// if you are not a super admin, return
if (!XenForo_Visitor::getInstance()->isSuperAdmin())
{
return;
}
//########################################
// get data
$db = XenForo_Application::getDb();
$posts = $db->fetchAll("
SELECT *
FROM xf_post
WHERE message_state = 'deleted'
ORDER BY post_id DESC
LIMIT 50");
$threads = $db->fetchAll("
SELECT *
FROM xf_thread
WHERE discussion_state='deleted'
ORDER BY thread_id DESC
LIMIT 50");
//########################################
// prepare output
$viewParams = array('posts' => $posts,'threads' => $threads,
);
return $this->responseView('Andy_ShowDeleted_ViewPublic_ShowDeleted', 'andy_showdeleted', $viewParams);
}
}
?>