if (empty($record["contact_id_$ab"]) && !empty($record['id'])) {
$record["contact_id_$ab"] = CRM_Core_DAO::getFieldValue(__CLASS__, $record['id'], "contact_id_$ab");
}
- if (!\Civi\Api4\Utils\CoreUtil::checkAccessDelegated('Contact', 'update', ['id' => $record["contact_id_$ab"]], $userID)) {
+ if (!empty($record["contact_id_$ab"]) && !\Civi\Api4\Utils\CoreUtil::checkAccessDelegated('Contact', 'update', ['id' => $record["contact_id_$ab"]], $userID)) {
return FALSE;
}
}
if (!$this->getCheckPermissions()) {
return;
}
- $allowedApiActions = $this->getAllowedEntityActions();
foreach ($links as $index => $link) {
- if (!in_array($link['api_action'], $allowedApiActions, TRUE)) {
+ if (!$this->isActionAllowed($link['entity'], $link['api_action'])) {
unset($links[$index]);
continue;
}
}
}
- private function getAllowedEntityActions(): array {
+ private function isActionAllowed(string $entityName, string $actionName): bool {
+ $allowedApiActions = $this->getAllowedEntityActions($entityName);
+ return in_array($actionName, $allowedApiActions, TRUE);
+ }
+
+ private function getAllowedEntityActions(string $entityName): array {
$uid = \CRM_Core_Session::getLoggedInContactID();
- $entityName = $this->getEntityName();
if (!isset(\Civi::$statics[__CLASS__]['actions'][$entityName][$uid])) {
\Civi::$statics[__CLASS__]['actions'][$entityName][$uid] = civicrm_api4($entityName, 'getActions', ['checkPermissions' => TRUE])->column('name');
}
// 1st link is to a quickform-based action
$this->assertArrayNotHasKey('task', $result[0]['columns'][1]['links'][0]);
$this->assertStringContainsString('id=' . $relationships[0]['id'], $result[0]['columns'][1]['links'][0]['url']);
- // 2nd link is to the native SK bulk-delete task
- $this->assertArrayNotHasKey('url', $result[0]['columns'][1]['links'][1]);
- $this->assertEquals('delete', $result[0]['columns'][1]['links'][1]['task']);
+ // 2nd link is to delete
$this->assertEquals('fa-trash', $result[0]['columns'][1]['links'][1]['icon']);
// Ensure "empty" titles are still returned
$this->assertEquals('0', $result[0]['columns'][1]['links'][1]['title']);