CONST AUTH_SRC_UNKNOWN = 0, AUTH_SRC_CHECKSUM = 1, AUTH_SRC_SITEKEY = 2, AUTH_SRC_LOGIN = 4;
/**
- * get the current permission of this user
+ * Get the current permission of this user
*
* @return string the permission of the user (edit or view or null)
*/
}
/**
- * given a permission string or array, check for access requirements
+ * Given a permission string or array, check for access requirements
* @param mixed $permissions the permission to check as an array or string -see examples
* arrays
*
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 int $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) {
}
}
+ /**
+ * @param int $type
+ * @param int $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 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
+ * 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
}
}
+ /**
+ * @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;
return $permissions;
}
+ /**
+ * @return array
+ */
static function getAnonymousPermissionsWarnings() {
static $permissions = array();
if (empty($permissions)) {
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(
}
/**
- * Function to get component name from given permission.
+ * Get component name from given permission.
*
* @param string $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'