+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
$orderBy = ' ORDER BY groups.title asc';
if (!empty($params['sort'])) {
$orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String');
+
+ // CRM-16905 - Sort by count cannot be done with sql
+ if (strpos($params['sort'], 'count') === 0) {
+ $orderBy = $limit = '';
+ }
}
$select = $from = $where = "";
'count' => '0',
);
CRM_Core_DAO::storeValues($object, $values[$object->id]);
+ // Wrap with crm-editable. Not an ideal solution.
+ $values[$object->id]['title'] = '<span class="crm-editable crmf-title">' . $values[$object->id]['title'] . '</span>';
+
if ($object->saved_search_id) {
$values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
// check if custom search, if so fix view link
}
}
+ // CRM-16905 - Sort by count cannot be done with sql
+ if (!empty($params['sort']) && strpos($params['sort'], 'count') === 0) {
+ usort($values, function($a, $b) {
+ return $a['count'] - $b['count'];
+ });
+ if (strpos($params['sort'], 'desc')) {
+ $values = array_reverse($values, TRUE);
+ }
+ return array_slice($values, $params['offset'], $params['rowCount']);
+ }
+
return $values;
}