diff --git a/CRM/Relatedpermissions/Upgrader.php b/CRM/Relatedpermissions/Upgrader.php
index 4c2b2c6..54ed550 100644
--- a/CRM/Relatedpermissions/Upgrader.php
+++ b/CRM/Relatedpermissions/Upgrader.php
@@ -23,7 +23,7 @@ public function create_custom_fields() {
civicrm_api3('OptionValue', 'create', [
'option_group_id' => 'cg_extend_objects',
'name' => 'civicrm_relationship_type',
- 'label' => ts('Relationship Type'),
+ 'label' => E::ts('Relationship Type'),
'value' => 'RelationshipType',
]);
}
@@ -36,22 +36,25 @@ public function create_custom_fields() {
'extends' => 'RelationshipType',
'name' => E::SHORT_NAME,
'title' => E::ts('Related Permissions Settings'),
+ 'is_active' => 1,
+ 'is_reserved' => 1,
]);
}
$customFields = civicrm_api3('CustomField', 'get', [
'custom_group_id' => $customGroups['id'],
]);
if (!$customFields['count']) {
- $newFields[] = civicrm_api3('CustomField', 'create', [
+ civicrm_api3('CustomField', 'create', [
'custom_group_id' => $customGroups['id'],
'name' => 'permission_a_b',
'label' => E::ts('Permission that A has over B'),
'weight' => 1,
'data_type' => 'Int',
'html_type' => 'Radio',
- 'option_values' => CRM_Core_SelectValues::getPermissionedRelationshipOptions(),
+ 'option_values' => $this->getPermissionedRelationshipOptions(),
+ 'is_active' => 1,
]);
- $newFields[] = civicrm_api3('CustomField', 'create', [
+ civicrm_api3('CustomField', 'create', [
'custom_group_id' => $customGroups['id'],
'name' => 'permission_a_b_mode',
'label' => E::ts('Permission A over B mode'),
@@ -62,17 +65,19 @@ public function create_custom_fields() {
'required' => 1,
'default_value' => 0,
'option_values' => [E::ts('Default'), E::ts('Override')],
+ 'is_active' => 1,
]);
- $newFields[] = civicrm_api3('CustomField', 'create', [
+ civicrm_api3('CustomField', 'create', [
'custom_group_id' => $customGroups['id'],
'name' => 'permission_b_a',
'label' => E::ts('Permission that B has over A'),
'weight' => 3,
'data_type' => 'Int',
'html_type' => 'Radio',
- 'option_values' => CRM_Core_SelectValues::getPermissionedRelationshipOptions(),
+ 'option_values' => $this->getPermissionedRelationshipOptions(),
+ 'is_active' => 1,
]);
- $newFields[] = civicrm_api3('CustomField', 'create', [
+ civicrm_api3('CustomField', 'create', [
'custom_group_id' => $customGroups['id'],
'name' => 'permission_b_a_mode',
'label' => E::ts('Permission B over A mode'),
@@ -83,6 +88,7 @@ public function create_custom_fields() {
'required' => 1,
'default_value' => 0,
'option_values' => [E::ts('Default'), E::ts('Override')],
+ 'is_active' => 1,
]);
}
}
@@ -96,4 +102,17 @@ public function upgrade_1502() {
return TRUE;
}
+ /**
+ * See https://github.com/civicrm/civicrm-core/pull/23865
+ *
+ * @return array
+ */
+ private function getPermissionedRelationshipOptions() {
+ return [
+ CRM_Contact_BAO_Relationship::NONE => ts('None'),
+ CRM_Contact_BAO_Relationship::VIEW => ts('View only'),
+ CRM_Contact_BAO_Relationship::EDIT => ts('View and update')
+ ];
+ }
+
}
diff --git a/info.xml b/info.xml
index 68d67fc..5d281b9 100644
--- a/info.xml
+++ b/info.xml
@@ -12,15 +12,19 @@
Eileen McNaughton
eileen@fuzion.co.nz
- 2021-12-29
- 1.9
+ 2022-08-22
+ 1.9.1
stable
- 5.44
+ 5.49
This extension makes the permission flag on a relationship work as a true ACL. In core CiviCRM that flag only allows the user to see the contact dashboard. However, in many cases it is a useful mechanism to give people permission to view contact records and search for contacts.
This version also allows relationship types to be forced to being permissioned (via the relationship config screen)
CRM/Relatedpermissions
+ 22.05.2
+
+ mgd-php@1.0.0
+
diff --git a/relatedpermissions.civix.php b/relatedpermissions.civix.php
index 2ce1e90..873ef44 100644
--- a/relatedpermissions.civix.php
+++ b/relatedpermissions.civix.php
@@ -91,9 +91,9 @@ function _relatedpermissions_civix_civicrm_config(&$config = NULL) {
}
$configured = TRUE;
- $template =& CRM_Core_Smarty::singleton();
+ $template = CRM_Core_Smarty::singleton();
- $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
+ $extRoot = __DIR__ . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';
if (is_array($template->template_dir)) {
@@ -107,19 +107,6 @@ function _relatedpermissions_civix_civicrm_config(&$config = NULL) {
set_include_path($include_path);
}
-/**
- * (Delegated) Implements hook_civicrm_xmlMenu().
- *
- * @param $files array(string)
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
- */
-function _relatedpermissions_civix_civicrm_xmlMenu(&$files) {
- foreach (_relatedpermissions_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
- $files[] = $file;
- }
-}
-
/**
* Implements hook_civicrm_install().
*
@@ -217,136 +204,6 @@ function _relatedpermissions_civix_upgrader() {
}
}
-/**
- * Search directory tree for files which match a glob pattern.
- *
- * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
- * Note: Delegate to CRM_Utils_File::findFiles(), this function kept only
- * for backward compatibility of extension code that uses it.
- *
- * @param string $dir base dir
- * @param string $pattern , glob pattern, eg "*.txt"
- *
- * @return array
- */
-function _relatedpermissions_civix_find_files($dir, $pattern) {
- return CRM_Utils_File::findFiles($dir, $pattern);
-}
-
-/**
- * (Delegated) Implements hook_civicrm_managed().
- *
- * Find any *.mgd.php files, merge their content, and return.
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
- */
-function _relatedpermissions_civix_civicrm_managed(&$entities) {
- $mgdFiles = _relatedpermissions_civix_find_files(__DIR__, '*.mgd.php');
- sort($mgdFiles);
- foreach ($mgdFiles as $file) {
- $es = include $file;
- foreach ($es as $e) {
- if (empty($e['module'])) {
- $e['module'] = E::LONG_NAME;
- }
- if (empty($e['params']['version'])) {
- $e['params']['version'] = '3';
- }
- $entities[] = $e;
- }
- }
-}
-
-/**
- * (Delegated) Implements hook_civicrm_caseTypes().
- *
- * Find any and return any files matching "xml/case/*.xml"
- *
- * Note: This hook only runs in CiviCRM 4.4+.
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
- */
-function _relatedpermissions_civix_civicrm_caseTypes(&$caseTypes) {
- if (!is_dir(__DIR__ . '/xml/case')) {
- return;
- }
-
- foreach (_relatedpermissions_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
- $name = preg_replace('/\.xml$/', '', basename($file));
- if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
- $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
- throw new CRM_Core_Exception($errorMessage);
- }
- $caseTypes[$name] = [
- 'module' => E::LONG_NAME,
- 'name' => $name,
- 'file' => $file,
- ];
- }
-}
-
-/**
- * (Delegated) Implements hook_civicrm_angularModules().
- *
- * Find any and return any files matching "ang/*.ang.php"
- *
- * Note: This hook only runs in CiviCRM 4.5+.
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
- */
-function _relatedpermissions_civix_civicrm_angularModules(&$angularModules) {
- if (!is_dir(__DIR__ . '/ang')) {
- return;
- }
-
- $files = _relatedpermissions_civix_glob(__DIR__ . '/ang/*.ang.php');
- foreach ($files as $file) {
- $name = preg_replace(':\.ang\.php$:', '', basename($file));
- $module = include $file;
- if (empty($module['ext'])) {
- $module['ext'] = E::LONG_NAME;
- }
- $angularModules[$name] = $module;
- }
-}
-
-/**
- * (Delegated) Implements hook_civicrm_themes().
- *
- * Find any and return any files matching "*.theme.php"
- */
-function _relatedpermissions_civix_civicrm_themes(&$themes) {
- $files = _relatedpermissions_civix_glob(__DIR__ . '/*.theme.php');
- foreach ($files as $file) {
- $themeMeta = include $file;
- if (empty($themeMeta['name'])) {
- $themeMeta['name'] = preg_replace(':\.theme\.php$:', '', basename($file));
- }
- if (empty($themeMeta['ext'])) {
- $themeMeta['ext'] = E::LONG_NAME;
- }
- $themes[$themeMeta['name']] = $themeMeta;
- }
-}
-
-/**
- * Glob wrapper which is guaranteed to return an array.
- *
- * The documentation for glob() says, "On some systems it is impossible to
- * distinguish between empty match and an error." Anecdotally, the return
- * result for an empty match is sometimes array() and sometimes FALSE.
- * This wrapper provides consistency.
- *
- * @link http://php.net/glob
- * @param string $pattern
- *
- * @return array
- */
-function _relatedpermissions_civix_glob($pattern) {
- $result = glob($pattern);
- return is_array($result) ? $result : [];
-}
-
/**
* Inserts a navigation menu item at a given place in the hierarchy.
*
@@ -429,18 +286,6 @@ function _relatedpermissions_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $
}
}
-/**
- * (Delegated) Implements hook_civicrm_alterSettingsFolders().
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
- */
-function _relatedpermissions_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
- $settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings';
- if (!in_array($settingsDir, $metaDataFolders) && is_dir($settingsDir)) {
- $metaDataFolders[] = $settingsDir;
- }
-}
-
/**
* (Delegated) Implements hook_civicrm_entityTypes().
*
diff --git a/relatedpermissions.php b/relatedpermissions.php
index 1b8aa67..0b883e5 100644
--- a/relatedpermissions.php
+++ b/relatedpermissions.php
@@ -12,15 +12,6 @@ function relatedpermissions_civicrm_config(&$config) {
_relatedpermissions_civix_civicrm_config($config);
}
-/**
- * Implements hook_civicrm_xmlMenu().
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
- */
-function relatedpermissions_civicrm_xmlMenu(&$files) {
- _relatedpermissions_civix_civicrm_xmlMenu($files);
-}
-
/**
* Implements hook_civicrm_install().
*
@@ -75,54 +66,6 @@ function relatedpermissions_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL)
return _relatedpermissions_civix_civicrm_upgrade($op, $queue);
}
-/**
- * Implements hook_civicrm_managed().
- *
- * Generate a list of entities to create/deactivate/delete when this module
- * is installed, disabled, uninstalled.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
- */
-function relatedpermissions_civicrm_managed(&$entities) {
- _relatedpermissions_civix_civicrm_managed($entities);
-}
-
-/**
- * Implements hook_civicrm_caseTypes().
- *
- * Generate a list of case-types.
- *
- * Note: This hook only runs in CiviCRM 4.4+.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
- */
-function relatedpermissions_civicrm_caseTypes(&$caseTypes) {
- _relatedpermissions_civix_civicrm_caseTypes($caseTypes);
-}
-
-/**
- * Implements hook_civicrm_angularModules().
- *
- * Generate a list of Angular modules.
- *
- * Note: This hook only runs in CiviCRM 4.5+. It may
- * use features only available in v4.6+.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
- */
-function relatedpermissions_civicrm_angularModules(&$angularModules) {
- _relatedpermissions_civix_civicrm_angularModules($angularModules);
-}
-
-/**
- * Implements hook_civicrm_alterSettingsFolders().
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
- */
-function relatedpermissions_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
- _relatedpermissions_civix_civicrm_alterSettingsFolders($metaDataFolders);
-}
-
/**
* Implements hook_civicrm_entityTypes().
*