Skip to content

Commit

Permalink
CRM-16201 display permission descriptions in WordPress
Browse files Browse the repository at this point in the history
  • Loading branch information
agh1 committed Mar 31, 2015
1 parent 221b21b commit 56f6522
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions CRM/ACL/Form/WordPress/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function buildQuickForm() {

// 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
Expand Down Expand Up @@ -81,6 +82,13 @@ public function buildQuickForm() {

$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);

Expand Down Expand Up @@ -173,13 +181,16 @@ public function postProcess() {
* 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) {
Expand Down
5 changes: 4 additions & 1 deletion templates/CRM/ACL/Form/WordPress/Permissions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
{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>
Expand Down

0 comments on commit 56f6522

Please sign in to comment.