roam/aweber/20210914143542-sites_subscriber_search.org
2021-09-14 23:50:54 -04:00

2.2 KiB

Sites Subscriber Search

Sorting

Added: [2020-04-14 Tue 13:34]

The current sites search code includes the following functioning code for setting a sort order on a search based on form input:

52d1d94485/aweber_app/controllers/queries_controller.php (L386-402)

  // Look up the column for the order by clause.  There are no SQL column name values passed publicly.
  if (!empty($this->data['SearchOrder']['SearchInput'])){
     $this->SearchInput->recursive = -1;
     if ($time = $this->SearchMutex->lock($aId, '6')) {
         $orderCol = $this->SearchInput->find(array('SearchInput.id' => $this->data['SearchOrder']['SearchInput']));
         $this->SearchMutex->unlock($aId, '6', $time);
     }
     if (!empty($orderCol['SearchInput']['column'])){
       //Case-insensitive text sorting.
       // Lower text fields so that ordering is case insensitive. SearchInputs 5, 23, and 24 are actually integers, despite
       // having a text search input. refs #3275
       if($orderCol['SearchInput']['input_type'] == 'text' && !in_array($orderCol['SearchInput']['id'], array(5,23,24))) {
         $orderCol['SearchInput']['column'] = 'lower('.$orderCol['SearchInput']['column'].')';
       }
        $this->data['SearchOrder']['column'] = $orderCol['SearchInput']['column'];
     }
  }