Skip to content
Snippets Groups Projects
Commit 67586e26 authored by jaapjansma's avatar jaapjansma
Browse files

added permissions

parent 1ab985a7
No related branches found
No related tags found
No related merge requests found
......@@ -91,6 +91,9 @@
$formProcessorInstance->$key = $value;
}
}
if (!$formProcessorInstance->permission) {
$formProcessorInstance->permission = '';
}
if (!isset($formProcessorInstance->name) || empty($formProcessorInstance->name)) {
if (isset($formProcessorInstance->title)) {
$formProcessorInstance->name = CRM_FormProcessor_BAO_FormProcessorInstance::buildNameFromLabel($formProcessorInstance->title);
......@@ -182,5 +185,21 @@
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? false : true;
}
/**
* Returns the permission for the form processor. When no permission is required
* return an empty string.
*
* @param string $formProcessorName
* The name of the form processor.
* @return string
* The required permission.
*/
public static function getPermission($formProcessorName) {
$sql = "SELECT `permission` FROM `civicrm_form_processor_instance` WHERE `name` = %1";
$params[1] = array($formProcessorName, 'String');
$permission = CRM_Core_DAO::singleValueQuery($sql, $params);
return $permission;
}
}
......@@ -99,6 +99,13 @@ class CRM_FormProcessor_DAO_FormProcessorInstance extends CRM_Core_DAO {
'type' => CRM_Utils_Type::T_INT,
'FKApiName' => 'Contact',
),
'permission' => array(
'name' => 'permission',
'title' => E::ts('Permission'),
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 255,
'required' => false,
) ,
);
}
return self::$_fields;
......@@ -126,6 +133,7 @@ class CRM_FormProcessor_DAO_FormProcessorInstance extends CRM_Core_DAO {
'created_user_id' => 'created_user_id',
'modified_date' => 'modified_date',
'modified_user_id' => 'modified_user_id',
'permission' => 'permission',
);
}
return self::$_fieldKeys;
......
......@@ -40,5 +40,6 @@ return array (
'defaultOutputHandler' => \Civi::service('form_processor_output_handler_factory')->getDefaultHandler()->toArray(),
'actionTypes' => $action_provider->getActions(),
'defaultDataActionTypes' => $default_data_action_provider->getActions(),
'permissions' => CRM_Core_Permission::basicPermissions(),
),
);
......@@ -54,6 +54,7 @@
$scope.deletedDefaultDataInputs = [];
$scope.deletedDefaultDataActions = [];
$scope.default_data_fields = [];
$scope.permissions = CRM.form_processor.permissions;
$scope.actionTypes = CRM.form_processor.actionTypes;
$scope.defaultDataActionTypes = CRM.form_processor.defaultDataActionTypes;
......
......@@ -35,5 +35,16 @@
<div crm-ui-field="{title: ts('Enabled?')}">
<input name="is_active" type="checkbox" ng-model="formProcessor.is_active" ng-true-value="'1'" ng-false-value="'0'"/>
</div>
<div crm-ui-field="{name: 'formProcessorDetailForm.permission', title: ts('Permission')}">
<select
crm-ui-id="formProcessorDetailForm.permission"
name="permission"
ui-jq="select2"
ui-options="{dropdownAutoWidth : true, allowClear: true}"
ng-model="formProcessor.permission"
ng-options="key as value for (key, value) in permissions">
<option value="">{{ts('- No permission -')}}</option>
</select>
</div>
</div>
\ No newline at end of file
......@@ -58,6 +58,11 @@ function _civicrm_api3_form_processor_instance_create_spec(&$spec) {
'type' => CRM_Utils_Type::T_TEXT,
'api.required' => false
);
$spec['permission'] = array(
'title' => E::ts('Permission'),
'type' => CRM_Utils_Type::T_STRING,
'api.required' => true
);
}
/**
......
......@@ -76,6 +76,10 @@ function form_processor_civicrm_alterAPIPermissions($entity, $action, &$params,
if ($entity == 'form_processor' && !in_array($action, array('getactions', 'getfields'))) {
$permissions['form_processor'][$action] = array();
$formProcessorPermission = CRM_FormProcessor_BAO_FormProcessorInstance::getPermission($action);
if (!empty($formProcessorPermission)) {
$permissions['form_processor'][$action][] = $formProcessorPermission;
}
}
}
......
......@@ -12,6 +12,7 @@ CREATE TABLE IF NOT EXISTS `civicrm_form_processor_instance` (
`created_user_id` INT NULL,
`modified_date` DATE NULL,
`modified_user_id` INT NULL,
`permission` VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE INDEX `name_UNIQUE` (`name` ASC)
) ENGINE = InnoDB;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment