CRM-16201 display permission descriptions in WordPress
authorAndrew Hunt <andrew@aghstrategies.com>
Mon, 30 Mar 2015 16:37:05 +0000 (12:37 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Tue, 31 Mar 2015 16:04:17 +0000 (12:04 -0400)
CRM/ACL/Form/WordPress/Permissions.php
templates/CRM/ACL/Form/WordPress/Permissions.tpl

index b3dc310ad13ae8331b13a21a45fff315eb843090..1f4721cbc441255bc54c9c26a994f3d7929f158f 100644 (file)
@@ -49,6 +49,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
 
     // Get the core permissions array
     $permissionsArray = self::getPermissionArray();
+    $permissionsDesc = self::getPermissionArray(TRUE);
 
     // Get the wordpress roles, default capabilities and assign to the form
     // TODO: Create a new wordpress role (Anonymous user) and define capabilities in Wordpress Access Control
@@ -81,6 +82,13 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
 
     $this->setDefaults($defaults);
 
+    $descArray = array();
+    foreach ($permissionsDesc as $perm => $attr) {
+      if (count($attr) > 1) {
+        $descArray[$perm] = $attr[1];
+      }
+    }
+    $this->assign('permDesc', $descArray);
     $this->assign('rolePerms', $rolePerms);
     $this->assign('roles', $roles);
 
@@ -173,13 +181,16 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
    * This function should be shared from a similar one in
    * distmaker/utils/joomlaxml.php
    *
+   * @param bool $descriptions
+   *   Whether to return permission descriptions
+   *
    * @return array
    *   civicrm permissions
    */
-  public static function getPermissionArray() {
+  public static function getPermissionArray($descriptions = FALSE) {
     global $civicrm_root;
 
-    $permissions = CRM_Core_Permission::basicPermissions();
+    $permissions = CRM_Core_Permission::basicPermissions(FALSE, $descriptions);
 
     $perms_array = array();
     foreach ($permissions as $perm => $title) {
index c700e53c4ea14194c8ce354bdcdce12b406cd94c..f1f383d89e0a2b099445a773f704ab74f14fc266 100644 (file)
             {else}
                 <tr style="background-color: #FFFFFF;">
             {/if}
-                <td style="height:30px;">
+                <td style="height:3em;">
                 {if $i eq 1}
                   {$form.$role_name.$name.label}
+                  {if $permDesc.$name}
+                    <br/><span class="description">{$permDesc.$name}</span>
+                  {/if}
                 {/if}
                 </td>
                 <td align="center">{$form.$role_name.$name.html}<br /></td>