1. 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

Discussion in 'Closed Suggestions' started by xf_phantom, Aug 10, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    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
     

Share This Page