fix version in header
[civicrm-core.git] / CRM / ACL / Form / WordPress / Permissions.php
index 47d3d79da2c9372b41a3217b125ccd1a21a719e1..7daa22c7b0d528ee970f3bdb04e4ecbd1794d5b3 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
   +--------------------------------------------------------------------+
-  | CiviCRM version 4.5                                                |
+  | CiviCRM version 4.6                                                |
   +--------------------------------------------------------------------+
   | Copyright CiviCRM LLC (c) 2004-2014                                |
   +--------------------------------------------------------------------+
@@ -40,7 +40,7 @@
 class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
 
   /**
-   * Function to build the form
+   * Build the form object
    *
    * @access public
    * @return void
@@ -99,7 +99,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
   }
 
   /**
-   * Function to process the form
+   * Process the form submission
    *
    * @access public
    * @return void
@@ -129,6 +129,25 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
           $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
@@ -170,4 +189,3 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
     return $perms_array;
   }
 }
-