original_string: 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);
              }
          }
      }
code: 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);
              }
          }
      }
code_tokens: 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 ) ; } } }
docstring: calc_used_date has special sort, see bugs 108 and 127
  
  @param \MUtil_Model_ModelAbstract $model
docstring_tokens: calc_used_date has special sort see bugs 108 and 127