Getting data from the Model

Also you are fetching all thread data so I would change the comment to

// get deleted threads

Because you get thread.thread_id as long with thread.title, thread.position ...
 
Thank you, Marcus.

PHP:
<?php

class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XenForo_ControllerPublic_Abstract
{	
	protected function _preDispatch($action)
	{
		if (!XenForo_Visitor::getInstance()->isSuperAdmin())
		{
			throw $this->getNoPermissionResponseException();
		}
	} 
	
	public function actionIndex()
	{				
		//########################################
		// get data
		
		// this is fetching $posts from XenForo_Model_Post 
		// the function getDeletedPosts() is initially not there
		// we extended XenForo_Model_Post with Andy_ShowDeleted_Model_Post
		// all Andy_ShowDeleted_Model_Post functions are now accessible from XenForo_Model_Post		
		
		// get deleted post_id and message data
        $posts = $this->getModelFromCache('XenForo_Model_Post')->getDeletedPosts();	
		
		// the function getThreads is located in library/Xenforo/Model/Thread.php
		// getThreads gets two arrays:
		// array($conditions) and array($fetchOptions)
		
		// get deleted threads
		$threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads(
			array('discussion_state' => 'deleted'),
			array('order' => 'thread_id','limit' => 50)
		); 
				
		//########################################
		// display data		
		
		// $viewParams must be an array
		$viewParams = array('posts' => $posts,'threads' => $threads,
		); 
		
		// send to template for display
		return $this->responseView('Andy_ShowDeleted_ViewPublic_ShowDeleted', 'andy_showdeleted', $viewParams);
	}
}

?>
 
If you enter thread_id, it will not find it in the switch clause and sort for last_post_date. The result will only be like post_date if threads don't have any replies in it changing the last_post_date

PHP:
      switch ($fetchOptions['order'])
       {
         case 'title':
         case 'post_date':
         case 'view_count':
           $orderBy = 'thread.' . $fetchOptions['order'];
           break;

         case 'reply_count':
         case 'first_post_likes':
           $orderBy = 'thread.' . $fetchOptions['order'];
           $orderBySecondary = ', thread.last_post_date DESC';
           break;

         case 'last_post_date':
         default:
           $orderBy = 'thread.last_post_date';
       }
 
This sorts threads for last_post_date
PHP:
  $threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads(
array('discussion_state' => 'deleted'),
array('order','limit' => 50)
);


This sorts threads for post_date (creation time)
PHP:
  $threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads(
array('discussion_state' => 'deleted'),
array('order' => 'post_date','limit' => 50)
);
 
Top Bottom