diff --git a/CRM/ACL/Form/WordPress/Permissions.php b/CRM/ACL/Form/WordPress/Permissions.php index 5273969e0ab1..6ec23020fd18 100644 --- a/CRM/ACL/Form/WordPress/Permissions.php +++ b/CRM/ACL/Form/WordPress/Permissions.php @@ -41,20 +41,19 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { */ public function buildQuickForm() { - CRM_Utils_System::setTitle('Wordpress Access Control'); + CRM_Utils_System::setTitle('WordPress Access Control'); // 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 + // Get the WordPress roles, default capabilities and assign to the form global $wp_roles; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } foreach ($wp_roles->role_names as $role => $name) { - // Dont show the permissions options for administrator, as they have all permissions + // Don't show the permissions options for administrator, as they have all permissions if ($role !== 'administrator') { $roleObj = $wp_roles->get_role($role); if (!empty($roleObj->capabilities)) { @@ -84,7 +83,36 @@ public function buildQuickForm() { $descArray[$perm] = $attr[1]; } } - $this->assign('permDesc', $descArray); + + // build table rows by merging role perms + $rows = array(); + foreach ($rolePerms as $role => $perms) { + foreach ($perms as $name => $title) { + $rows[$name] = $title; + } + } + + // Build array keyed by permission + $table = array(); + foreach ($rows as $perm => $label) { + + // Init row with permission label + $table[$perm] = array( + 'label' => $label, + 'roles' => array(), + ); + + // Add permission description and role names + foreach ($roles as $key => $label) { + if (isset($descArray[$perm])) { + $table[$perm]['desc'] = $descArray[$perm]; + } + $table[$perm]['roles'][] = $key; + } + + } + + $this->assign('table', $table); $this->assign('rolePerms', $rolePerms); $this->assign('roles', $roles); diff --git a/templates/CRM/ACL/Form/WordPress/Permissions.tpl b/templates/CRM/ACL/Form/WordPress/Permissions.tpl index 89bfb4b11fe3..d6772743dae0 100644 --- a/templates/CRM/ACL/Form/WordPress/Permissions.tpl +++ b/templates/CRM/ACL/Form/WordPress/Permissions.tpl @@ -23,52 +23,56 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{* this template is used for adding/editing Wordpress Access Control *} +{* this template is used for adding/editing WordPress Access Control *}
-

{ts}Use this form to Grant access to CiviCRM components and other CiviCRM permissions to WordPress roles.{/ts}

- {ts}NOTE: Super Admin and Administrator roles will have all permissions in CiviCRM.{/ts} -

+

{ts}Use this form to Grant access to CiviCRM components and other CiviCRM permissions to WordPress roles.{/ts}

+

{ts}NOTE: Super Admin and Administrator roles will have all permissions in CiviCRM.{/ts}

+
-
{include file="CRM/common/formButtons.tpl" location="top"}
- - - {assign var="i" value=1} - {foreach from=$roles key=role_name item=role_value } - - {assign var="i" value=$i+1} + +
{include file="CRM/common/formButtons.tpl" location="top"}
+ +
- - - - - - {assign var="j" value=0} - {foreach from=$rolePerms.$role_name key=name item=value } - {if $j mod 2 eq 1} - - {else} - - {/if} - - - - {assign var="j" value=$j+1} - {/foreach} -
 {$role_value}
- {if $i eq 1} - {$form.$role_name.$name.label} - {if $permDesc.$name} -
{$permDesc.$name} - {/if} - {/if} -
{$form.$role_name.$name.html}
-
+ + + + {assign var="num" value=0} + {foreach from=$roles key=role_name item=role_value} + + {assign var="num" value=$num+1} {/foreach} - -
 {$role_value}
+ -
- {include file="CRM/common/formButtons.tpl" location="bottom"} -
+ {assign var="x" value=0} + {foreach from=$table key=perm_name item=row} + {if $x mod 2 eq 1} + + {else} + + {/if} + + + {$row.label} + {if $row.desc} +
{$row.desc} + {/if} + + + {foreach from=$row.roles key=index item=role_name} + + {$form.$role_name.$perm_name.html} + + {/foreach} + + + {assign var="x" value=$x+1} + {/foreach} + + + +
+ {include file="CRM/common/formButtons.tpl" location="bottom"} +