diff --git a/app/src/Controller/PeopleController.php b/app/src/Controller/PeopleController.php index 4577075c6..5d529a590 100644 --- a/app/src/Controller/PeopleController.php +++ b/app/src/Controller/PeopleController.php @@ -32,6 +32,7 @@ // XXX not doing anything with Log yet use Cake\Log\Log; use Cake\ORM\TableRegistry; +use http\QueryString; class PeopleController extends StandardController { public $paginate = [ @@ -49,7 +50,8 @@ class PeopleController extends StandardController { 'sortableFields' => [ 'PrimaryName.given', 'PrimaryName.family' - ] + ], + 'finder' => 'indexed' ]; /** diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 4fa75e2fe..2fe09fc47 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -534,9 +534,13 @@ public function index() { if(!empty($link->attr)) { // If a link attribute is defined but no value is provided, then query // where the link attribute is NULL - $query = $table->find()->where([$table->getAlias().'.'.$link->attr => $link->value]); + // "all" is the default finder. But since we are utilizing the paginator here, we will check the configuration + // for any custom finder. + $query = $table->find( + $this->paginate['finder'] ?? "all" + )->where([$table->getAlias().'.'.$link->attr => $link->value]); } else { - $query = $table->find(); + $query = $table->find($this->paginate['finder'] ?? "all"); } // QueryModificationTrait diff --git a/app/src/Model/Table/PeopleTable.php b/app/src/Model/Table/PeopleTable.php index 5c0ddafa9..36c338a26 100644 --- a/app/src/Model/Table/PeopleTable.php +++ b/app/src/Model/Table/PeopleTable.php @@ -93,6 +93,7 @@ public function initialize(array $config): void { ->setDependent(true) ->setCascadeCallbacks(true); $this->hasMany('GroupOwners') + ->setClassName('GroupMembers') ->setDependent(true) ->setCascadeCallbacks(true); $this->hasMany('HistoryRecords') @@ -249,6 +250,29 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op return true; } + /** + * Customized finder for the Index Population View + * + * @param Query $query Cake ORM Query + * @param array $options Cake ORM Query options + * + * @return CakeORMQuery Cake ORM Query + * @since COmanage Registry v5.0.0 + */ + public function findIndexed(Query $query, array $options): Query { + return $query->select([ + 'People.id', + 'PrimaryName.given', + 'PrimaryName.family', + 'People.status', + 'People.created', + 'People.modified', + 'People.timezone', + 'People.date_of_birth' + ]) + ->distinct(); + } + /** * Table specific logic to generate a display field. * diff --git a/app/templates/element/filter.php b/app/templates/element/filter.php index a748cc452..5ee4f8b92 100644 --- a/app/templates/element/filter.php +++ b/app/templates/element/filter.php @@ -406,6 +406,3 @@ Form->end(); ?> - - -