/**
  * calc_used_date has special sort, see bugs 108 and 127
  *
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function sortCalcDateCheck(\MUtil_Model_ModelAbstract $model)
 {
     $sort = $model->getSort();
     if (isset($sort['calc_used_date'])) {
         $add = true;
         $resultSort = array();
         foreach ($sort as $key => $asc) {
             if ('calc_used_date' === $key) {
                 if ($add) {
                     $resultSort['is_completed'] = $asc;
                     $resultSort['gto_completion_time'] = $asc == SORT_ASC ? SORT_DESC : SORT_ASC;
                     $resultSort['calc_valid_from'] = $asc;
                     $add = false;
                     // We can add this only once
                 }
             } else {
                 $resultSort[$key] = $asc;
             }
         }
         if (!$add) {
             $model->setSort($resultSort);
         }
     }
 }
 /**
  * Overrule to implement snippet specific filtering and sorting.
  *
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
 {
     $model->setFilter(array('gr2t_id_track' => $this->trackId, 'gr2t_id_user' => $this->respondentId, 'gr2t_id_organization' => $this->organizationId));
     if ($this->respondentTrackId) {
         $model->addFilter(array(sprintf('gr2t_id_respondent_track != %d', intval($this->respondentTrackId))));
     }
     $model->setSort(array('gr2t_created' => SORT_DESC));
 }