heres what im thinking.
Admin sets the tripal_hq_permission. Linking a user to a given record (im split if that should be a chado or entity id). So this would link admin A to project X.
A user submits a request to create analysis Y in project X. tripal_hq checks the permissions based on the project field, reads the rule in tripal_hq_permissions linking admin A to project X, and therefore assigns them to analysis Y in tripal_hq_submission_permissions.
longwinded/insane? maybe...
<?php
/**
* Implements hook_schema.
*
* @return array
*/
function tripal_hq_permissions_schema() {
$schema['tripal_hq_permissions'] = [
'description' => 'Link users to specific chado records. These are set by the site admin, and determine which submissions the admin listed here will be able to view.',
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'uid' => [
'description' => "Drupal user ID of admin.",
'type' => 'int',
'not null' => TRUE,
],
'bundle_id' => [
'description' => 'The bundle id. Foreign key to `tripal_bundle.id`.',
'type' => 'int',
'not null' => TRUE,
],
'entity_id' => [
'description' => 'the entity id. Users admin permission based on this entity.',
'type' => 'int',
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
];
$schema['tripal_hq_submission_permissions'] = [
'description' => 'Submissions that a given admin has admin rights to.',
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'hq_permission_id' => [
'type' => 'int',
'not null' => TRUE,
'description' => 'The tripal_hq_permission id. This is the general Chado permission set which is responsible for this child permission.'
],
'submission_id' => [
'type' => 'int',
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
'foreign keys' => [
'submission_id' => [
'table' => 'tripal_hq_submission',
'columns' => [
'submission_id' => 'id',
],
],
],
];
return $schema;
}
/**
* Uninstall the module.
*/
function tripal_hq_permissions_uninstall() {
if (db_table_exists('tripal_hq_permissions')) {
db_drop_table('tripal_hq_permissions');
}
}