* Get all groups from database, filtered by permissions
* for this user
*
- * @param string $groupType type of group(Access/Mailing)
- * @param boolen $excludeHidden exclude hidden groups.
+ * @param string $groupType type of group(Access/Mailing)
+ * @param bool|\boolen $excludeHidden exclude hidden groups.
*
* @access public
* @static
*
* @return array - array reference of all groups.
- *
*/
public static function group($groupType, $excludeHidden = TRUE) {
$config = CRM_Core_Config::singleton();
return $config->userPermissionClass->group($groupType, $excludeHidden);
}
+ /**
+ * @return bool
+ */
public static function customGroupAdmin() {
$admin = FALSE;
return FALSE;
}
+ /**
+ * @param int $type
+ * @param bool $reset
+ *
+ * @return array
+ */
public static function customGroup($type = CRM_Core_Permission::VIEW, $reset = FALSE) {
$customGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id',
array('fresh' => $reset));
return CRM_ACL_API::group($type, NULL, 'civicrm_custom_group', $customGroups, $defaultGroups);
}
+ /**
+ * @param int $type
+ * @param null $prefix
+ * @param bool $reset
+ *
+ * @return string
+ */
static function customGroupClause($type = CRM_Core_Permission::VIEW, $prefix = NULL, $reset = FALSE) {
if (self::customGroupAdmin()) {
return ' ( 1 ) ';
}
}
+ /**
+ * @param $gid
+ * @param int $type
+ *
+ * @return bool
+ */
public static function ufGroupValid($gid, $type = CRM_Core_Permission::VIEW) {
if (empty($gid)) {
return TRUE;
}
$groups = self::ufGroup($type);
- return in_array($gid, $groups) ? TRUE : FALSE;
+ return !empty($groups) && in_array($gid, $groups) ? TRUE : FALSE;
}
+ /**
+ * @param int $type
+ *
+ * @return array
+ */
public static function ufGroup($type = CRM_Core_Permission::VIEW) {
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
return CRM_ACL_API::group($type, NULL, 'civicrm_uf_group', $ufGroups);
}
+ /**
+ * @param int $type
+ * @param null $prefix
+ * @param bool $returnUFGroupIds
+ *
+ * @return array|string
+ */
static function ufGroupClause($type = CRM_Core_Permission::VIEW, $prefix = NULL, $returnUFGroupIds = FALSE) {
$groups = self::ufGroup($type);
if ($returnUFGroupIds) {
}
}
- public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL) {
+ /**
+ * @param int $type
+ * @param null $eventID
+ * @param string $context
+ *
+ * @return array|null
+ */
+ public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL, $context = '') {
+ if(!empty($context)) {
+ if(CRM_Core_Permission::check($context)) {
+ return TRUE;
+ }
+ }
$events = CRM_Event_PseudoConstant::event(NULL, TRUE);
$includeEvents = array();
return NULL;
}
+ /**
+ * @param int $type
+ * @param null $prefix
+ *
+ * @return string
+ */
static function eventClause($type = CRM_Core_Permission::VIEW, $prefix = NULL) {
$events = self::event($type);
if (empty($events)) {
}
}
+ /**
+ * @param $module
+ * @param bool $checkPermission
+ *
+ * @return bool
+ */
static function access($module, $checkPermission = TRUE) {
$config = CRM_Core_Config::singleton();
* check permissions for delete and edit actions
*
* @param string $module component name.
- * @param $action action to be check across component
+ * @param integer $action action to be check across component
*
- **/
+ *
+ * @return bool
+ */
static function checkActionPermission($module, $action) {
//check delete related permissions.
if ($action & CRM_Core_Action::DELETE) {
}
}
+ /**
+ * @param $args
+ * @param string $op
+ *
+ * @return bool
+ */
static function checkMenu(&$args, $op = 'and') {
if (!is_array($args)) {
return $args;
return ($op == 'or') ? FALSE : TRUE;
}
+ /**
+ * @param $item
+ *
+ * @return bool|mixed
+ * @throws Exception
+ */
static function checkMenuItem(&$item) {
if (!array_key_exists('access_callback', $item)) {
CRM_Core_Error::backtrace();
}
}
+ /**
+ * @param bool $all
+ *
+ * @return array
+ */
static function &basicPermissions($all = FALSE) {
static $permissions = NULL;
if (!$permissions) {
+ $config = CRM_Core_Config::singleton();
$prefix = ts('CiviCRM') . ': ';
$permissions = self::getCorePermissions();
$permissions['administer Multiple Organizations'] = $prefix . ts('administer Multiple Organizations');
}
- $config = CRM_Core_Config::singleton();
-
if (!$all) {
$components = CRM_Core_Component::getEnabledComponents();
}
}
// Add any permissions defined in hook_civicrm_permission implementations.
- $config = CRM_Core_Config::singleton();
$module_permissions = $config->userPermissionClass->getAllModulePermissions();
$permissions = array_merge($permissions, $module_permissions);
}
return $permissions;
}
+ /**
+ * @return array
+ */
+ static function getAnonymousPermissionsWarnings() {
+ static $permissions = array();
+ if (empty($permissions)) {
+ $permissions = array(
+ 'administer CiviCRM'
+ );
+ $components = CRM_Core_Component::getComponents();
+ foreach ($components as $comp) {
+ if (!method_exists($comp, 'getAnonymousPermissionWarnings')) {
+ continue;
+ }
+ $permissions = array_merge($permissions, $comp->getAnonymousPermissionWarnings());
+ }
+ }
+ return $permissions;
+ }
+
+ /**
+ * @param $anonymous_perms
+ *
+ * @return array
+ */
+ static function validateForPermissionWarnings($anonymous_perms) {
+ return array_intersect($anonymous_perms, self::getAnonymousPermissionsWarnings());
+ }
+
+ /**
+ * @return array
+ */
static function getCorePermissions() {
$prefix = ts('CiviCRM') . ': ';
$permissions = array(
* @param string $permission
*
* return string $componentName the name of component.
+ *
+ * @return int|null|string
* @static
*/
static function getComponentName($permission) {
return $config->userRoleClass->roleEmails($roleName);
}
+ /**
+ * @return bool
+ */
static function isMultisiteEnabled() {
return CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
'is_enabled'