mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-27 00:37:18 +02:00
Can access entities in SK, begun new admin page
This commit is contained in:
parent
06fec5daf7
commit
4978eeb828
8 changed files with 189 additions and 191 deletions
63
Civi/Api4/Action/ContactCategoryDefinition/Get.php
Normal file
63
Civi/Api4/Action/ContactCategoryDefinition/Get.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
namespace Civi\Api4\Action\ContactCategoryDefinition;
|
||||
|
||||
use Civi\Api4\Generic\DAOGetAction;
|
||||
use Civi\Api4\Generic\Result;
|
||||
use Civi\Api4\Group;
|
||||
use Civi\Api4\SavedSearch;
|
||||
|
||||
class Get extends DAOGetAction {
|
||||
|
||||
/**
|
||||
* Whether to look up and return extra data, helpful for presentations.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $withLabels = FALSE;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function _run(Result $result) {
|
||||
parent::_run($result);
|
||||
|
||||
$groupIDs = $searchIDs = [];
|
||||
foreach ($result as $idx => $row) {
|
||||
if ($row['search_type'] === 'group') {
|
||||
$groupIDs[] = $row['search_data']['group_id'] ?? NULL;
|
||||
}
|
||||
elseif ($row['search_type'] === 'search') {
|
||||
$searchIDs[] = $row['search_data']['saved_search_id'] ?? NULL;
|
||||
}
|
||||
}
|
||||
$groupIDs = array_filter($groupIDs);
|
||||
$searchIDs = array_filter($searchIDs);
|
||||
if ($groupIDs) {
|
||||
$groupNames = Group::get()
|
||||
->addWhere('id', 'IN', $groupIDs)
|
||||
->addSelect('title')
|
||||
->execute()->indexBy('id')->column('title');
|
||||
}
|
||||
if ($searchIDs) {
|
||||
$searchNames = SavedSearch::get()
|
||||
->addWhere('id', 'IN', $searchIDs)
|
||||
->addSelect('label')
|
||||
->execute()->indexBy('id')->column('label');
|
||||
}
|
||||
if ($searchNames || $groupNames) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['search_type'] === 'group'
|
||||
&& !empty($groupNames[$row['search_data']['group_id'] ?? ''])
|
||||
) {
|
||||
$row['search_source'] = $groupNames[$row['search_data']['group_id'] ?? ''];
|
||||
}
|
||||
elseif (($row['search_type'] === 'search')
|
||||
&& !empty($searchNames[$row['search_data']['saved_search_id'] ?? ''])
|
||||
) {
|
||||
$row['search_source'] = $searchNames[$row['search_data']['saved_search_id'] ?? ''];
|
||||
}
|
||||
}
|
||||
}
|
||||
$result[$idx] = $row;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace Civi\Api4;
|
||||
|
||||
use Civi\Api4\Action\ContactCategoryDefinition\Get;
|
||||
|
||||
/**
|
||||
* ContactCategoryDefinition entity.
|
||||
*
|
||||
|
@ -10,4 +12,13 @@ namespace Civi\Api4;
|
|||
*/
|
||||
class ContactCategoryDefinition extends Generic\DAOEntity {
|
||||
|
||||
/**
|
||||
* @param bool $checkPermissions
|
||||
* @return DAOGetAction
|
||||
*/
|
||||
public static function get($checkPermissions = TRUE) {
|
||||
return (new Get(static::getEntityName(), __FUNCTION__))
|
||||
->setCheckPermissions($checkPermissions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue