diff --git a/app/config/schema/schema.json b/app/config/schema/schema.json index 4b0880a7b..de84a8e43 100644 --- a/app/config/schema/schema.json +++ b/app/config/schema/schema.json @@ -521,8 +521,8 @@ "history_records": { "columns": { "id": {}, - "action": { "type": "string", "size": 4 }, - "comment": { "type": "string", "size": 256 }, + "action": {}, + "comment": {}, "person_id": {}, "person_role_id": {}, "external_identity_id": {}, @@ -542,6 +542,62 @@ } }, + "message_templates": { + "columns": { + "id": {}, + "co_id": {}, + "description": {}, + "status": {}, + "context": {}, + "format": { "type": "string", "size": 4 }, + "subject": { "type": "string", "size": 256 }, + "body_text": { "type": "text" }, + "body_html": { "type": "text" }, + "cc": { "type": "string", "size": 256 }, + "bcc": { "type": "string", "size": 256 }, + "reply_to": { "type": "string", "size": 256 } + }, + "indexes": { + "message_templates_i1": { "columns": [ "co_id" ] } + } + }, + + "notifications": { + "columns": { + "id": {}, + "subject_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "subject_group_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "actor_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "recipient_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "recipient_group_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "resolver_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, + "action": { + "comment": "revert this to use the library definition after feature-cfm31 merge", + "type": "string", "size": 4 + }, + "comment": {}, + "message_template_id": { "type": "integer", "foreignkey": { "table": "message_templates", "column": "id" } }, + "source": { "type": "text" }, + "email_subject": { "type": "string", "size": 256 }, + "email_body_text": { "type": "text" }, + "email_body_html": { "type": "text" }, + "resolution_subject": { "type": "string", "size": 256 }, + "resolution_body": { "type": "text" }, + "status": {}, + "notification_time": { "type": "datetime" }, + "resolution_time": { "type": "datetime" } + }, + "indexes": { + "notifications_i1": { "columns": [ "subject_person_id" ] }, + "notifications_i2": { "columns": [ "subject_group_id" ] }, + "notifications_i3": { "columns": [ "recipient_person_id" ] }, + "notifications_i4": { "columns": [ "recipient_group_id" ] }, + "notifications_i5": { "columns": [ "source" ] }, + "notifications_i6": { "needed": false, "columns": [ "actor_person_id" ] }, + "notifications_i7": { "needed": false, "columns": [ "resolver_person_id" ] } + } + }, + "enrollment_flows": { "columns": { "id": {}, @@ -627,62 +683,6 @@ } }, - "message_templates": { - "columns": { - "id": {}, - "co_id": {}, - "description": {}, - "status": {}, - "context": {}, - "format": { "type": "string", "size": 4 }, - "subject": { "type": "string", "size": 256 }, - "body_text": { "type": "text" }, - "body_html": { "type": "text" }, - "cc": { "type": "string", "size": 256 }, - "bcc": { "type": "string", "size": 256 }, - "reply_to": { "type": "string", "size": 256 } - }, - "indexes": { - "message_templates_i1": { "columns": [ "co_id" ] } - } - }, - - "notifications": { - "columns": { - "id": {}, - "subject_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "subject_group_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "actor_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "recipient_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "recipient_group_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "resolver_person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } }, - "action": { - "comment": "revert this to use the library definition after feature-cfm31 merge", - "type": "string", "size": 4 - }, - "comment": {}, - "message_template_id": { "type": "integer", "foreignkey": { "table": "message_templates", "column": "id" } }, - "source": { "type": "text" }, - "email_subject": { "type": "string", "size": 256 }, - "email_body_text": { "type": "text" }, - "email_body_html": { "type": "text" }, - "resolution_subject": { "type": "string", "size": 256 }, - "resolution_body": { "type": "text" }, - "status": {}, - "notification_time": { "type": "datetime" }, - "resolution_time": { "type": "datetime" } - }, - "indexes": { - "notifications_i1": { "columns": [ "subject_person_id" ] }, - "notifications_i2": { "columns": [ "subject_group_id" ] }, - "notifications_i3": { "columns": [ "recipient_person_id" ] }, - "notifications_i4": { "columns": [ "recipient_group_id" ] }, - "notifications_i5": { "columns": [ "source" ] }, - "notifications_i6": { "needed": false, "columns": [ "actor_person_id" ] }, - "notifications_i7": { "needed": false, "columns": [ "resolver_person_id" ] } - } - }, - "jobs": { "columns": { "id": {}, diff --git a/app/src/Model/Table/IdentifiersTable.php b/app/src/Model/Table/IdentifiersTable.php index 3bd5beb27..6092c69a1 100644 --- a/app/src/Model/Table/IdentifiersTable.php +++ b/app/src/Model/Table/IdentifiersTable.php @@ -243,6 +243,32 @@ public function lookupPersonByLogin(int $coId, string $identifier): int { return $id->person_id; } + /** + * Lookup a Person ID from a login identifier. Only active Identifiers can + * be used for lookups. + * + * @since COmanage Registry v5.0.0 + * @param string $identifier Identifier + * @param int $coId CO ID + * @return int Person ID or null + */ + + public function lookupPersonForLogin(string $identifier, int $coId): ?int { + $id = $this->find() + ->where([ + 'Identifiers.identifier' => $identifier, + 'Identifiers.status' => SuspendableStatusEnum::Active, + 'Identifiers.login' => true, + 'Identifiers.person_id IS NOT NULL' + ]) + ->matching('People', function ($q) use ($coId) { + return $q->where(['People.co_id' => $coId]); + }) + ->firstOrFail(); + + return $id->person_id ?? null; + } + /** * Perform a keyword search. * diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index b9e9f7f9c..b253337ae 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -270,11 +270,11 @@ $actionOrderDefault = $this->Menu->getMenuOrder('Default'); foreach ($rowActions as $a) { $ok = false; - if (!empty($a['controller'])) { - $tableName = Inflector::camelize($a['controller']); + if (!empty($a['controller']) && $a['controller'] != $tableName) { + $relTableName = Inflector::camelize($a['controller']); - if (isset($vv_permission_set[$entity->id][$tableName][$a['action']])) { - $ok = $vv_permission_set[$entity->id][$tableName][$a['action']]; + if (isset($vv_permission_set[$entity->id][$relTableName][$a['action']])) { + $ok = $vv_permission_set[$entity->id][$relTableName][$a['action']]; } } else { $ok = $vv_permission_set[$entity->id][$a['action']]; @@ -295,7 +295,7 @@ $actionUrl = ['action' => $a['action'], $entity->id]; $actionLabel = !empty($a['label']) ? $a['label'] : __d('operation', $a['action']); - if (!empty($a['controller'])) { + if (!empty($a['controller']) && $a['controller'] != $tableName) { // We're linking into a related controller $actionLabel = !empty($a['label']) ? $a['label'] : __d('controller', Inflector::camelize(Inflector::pluralize($a['controller'])), [99]); $actionUrl = [ @@ -386,10 +386,11 @@ } // Output the row actions if present - if($isFirstLink && !empty($rowActions)) { + if($isFirstLink && !empty($action_args['vv_actions'])) { + // todo check if needed print '
'; print '
'; - print $this->element('menuAction', $action_args); + print $this->element('menuAction', $action_args); print '
'; }