• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest States in XenForo_Model::prepareStateLimitFromConditions

xf_phantom

Well-known member
#1
It would be nice, if you would create a empty function in xenforo_model (prepareStates) and call it inside prepareStateLimitFromConditions

PHP:
public function prepareStateLimitFromConditions(array $fetchOptions, $table = '', $stateField = 'message_state', $userField = 'user_id')
   {
     $fetchOptions = array_merge(
       array(
         'deleted' => false,
         'moderated' => false
       ), $fetchOptions
     );

     $stateRef = ($table ? "$table.$stateField" : $stateField);
     $userRef = ($table ? "$table.$userField" : $userField);

     $states = array("'visible'");
     $moderatedLimit = '';

     if ($fetchOptions['deleted'])
     {
       $states[] = "'deleted'";
     }

     if ($fetchOptions['moderated'])
     {
       if ($fetchOptions['moderated'] === true)
       {
         $states[] = "'moderated'";
       }
       else
       {
         $moderatedLimit = " OR ($stateRef = 'moderated' AND $userRef = " . intval($fetchOptions['moderated']) . ')';
       }
     }
$this->prepareStates($fetchOptions, $states);
     return "$stateRef IN (" . implode(',', $states) . ")$moderatedLimit";
   }

protected function prepareStates($fetchOptions, &$states){

}
OR
anything else, which would allow addon creators, to add own states (if needed) to the returned string


With this addition we could use the method for own elements with more states