当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Permission::getAnonymousPermissionsWarnings方法代码示例

本文整理汇总了PHP中CRM_Core_Permission::getAnonymousPermissionsWarnings方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Permission::getAnonymousPermissionsWarnings方法的具体用法?PHP CRM_Core_Permission::getAnonymousPermissionsWarnings怎么用?PHP CRM_Core_Permission::getAnonymousPermissionsWarnings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Permission的用法示例。


在下文中一共展示了CRM_Core_Permission::getAnonymousPermissionsWarnings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 /**
  * Process the form submission.
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $permissionsArray = self::getPermissionArray();
     // Function to get Wordpress roles
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     foreach ($wp_roles->role_names as $role => $name) {
         $roleObj = $wp_roles->get_role($role);
         //Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked
         foreach ($permissionsArray as $key => $capability) {
             $roleObj->remove_cap($key);
         }
         //Add the selected wordpress capabilities for the role
         $rolePermissions = $params[$role];
         if (!empty($rolePermissions)) {
             foreach ($rolePermissions as $key => $capability) {
                 $roleObj->add_cap($key);
             }
         }
         if ($role == 'anonymous_user') {
             // Get the permissions into a format that matches what we get from WP
             $allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings();
             foreach ($allWarningPermissions as $key => $permission) {
                 $allWarningPermissions[$key] = CRM_utils_String::munge(strtolower($permission));
             }
             $warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions));
             $warningPermissionNames = array();
             foreach ($warningPermissions as $permission) {
                 $warningPermissionNames[$permission] = $permissionsArray[$permission];
             }
             if (!empty($warningPermissionNames)) {
                 CRM_Core_Session::setStatus(ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array(1 => $wp_roles->role_names[$role], 2 => implode(', ', $warningPermissionNames))), ts('Unsafe Permission Settings'));
             }
         }
     }
     // FIXME
     // Changed the 'access_civicrm_nav_link' capability in civicrm.php file
     // But for some reason, if i remove 'Access CiviCRM' administrator and save, it is showing
     // 'You do not have sufficient permissions to access this page'
     // which should not happen for Super Admin and Administrators, as checking permissions for Super
     // Admin and Administrators always gives TRUE
     wp_civicrm_capability();
     CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success");
     // rebuild the menus to comply with the new permisssions/capabilites
     CRM_Core_Invoke::rebuildMenuAndCaches();
     CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1');
     CRM_Utils_System::civiExit();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:56,代码来源:Permissions.php


注:本文中的CRM_Core_Permission::getAnonymousPermissionsWarnings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。