Skip to content

Commit

Permalink
61-split-edit-message-templates-permission: Code refactor and jenkins…
Browse files Browse the repository at this point in the history
… build failure resolution
  • Loading branch information
ajesamson committed Apr 16, 2018
1 parent e86f2eb commit 2665aa1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 3 additions & 2 deletions CRM/Admin/Form/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,12 @@ public function buildQuickForm() {
private function checkUserPermission($workflowId) {
if (isset($workflowId)) {
$canView = CRM_Core_Permission::check('edit system workflow message templates');
} else {
}
else {
$canView = CRM_Core_Permission::check('edit user-driven message templates');
}

if (! $canView && ! CRM_Core_Permission::check('edit message templates')) {
if (!$canView && !CRM_Core_Permission::check('edit message templates')) {
CRM_Core_Session::setStatus(ts('You do not have permission to view requested page.'), ts('Access Denied'));
$url = CRM_Utils_System::url('civicrm/admin/messageTemplates', "reset=1");
CRM_Utils_System::redirect($url);
Expand Down
3 changes: 3 additions & 0 deletions CRM/Admin/Page/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ public function browse() {
);

$this->assign('rows', $rows);
$this->assign('canEditSystemTemplates', CRM_Core_Permission::check('edit system workflow message templates'));
$this->assign('canEditMessageTemplates', CRM_Core_Permission::check('edit message templates'));
$this->assign('canEditUserDrivenMessageTemplates', CRM_Core_Permission::check('edit user-driven message templates'));
}

}
17 changes: 5 additions & 12 deletions templates/CRM/Admin/Page/MessageTemplates.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@
<div class="crm-content-block crm-block">
<div id='mainTabContainer'>
<ul>
{if call_user_func(array('CRM_Core_Permission','check'), 'edit user-driven message templates')
or call_user_func(array('CRM_Core_Permission','check'), 'edit message templates')}
{if $canEditUserDrivenMessageTemplates or $canEditMessageTemplates}
<li id='tab_user'> <a href='#user' title='{ts}User-driven Messages{/ts}'> {ts}User-driven Messages{/ts} </a></li>
{/if}
{if call_user_func(array('CRM_Core_Permission','check'), 'edit system workflow message templates')
or call_user_func(array('CRM_Core_Permission','check'), 'edit message templates')}
{if $canEditSystemTemplates or $canEditMessageTemplates}
<li id='tab_workflow'><a href='#workflow' title='{ts}System Workflow Messages{/ts}'>{ts}System Workflow Messages{/ts}</a></li>
{/if}
</ul>
Expand All @@ -104,14 +102,9 @@
{include file="CRM/common/jsortable.tpl"}
{foreach from=$rows item=template_row key=type}
{if (
$type ne 'userTemplates' and (
call_user_func(array('CRM_Core_Permission','check'), 'edit system workflow message templates')
or call_user_func(array('CRM_Core_Permission','check'), 'edit message templates'))
) or
(
$type eq 'userTemplates'and (
call_user_func(array('CRM_Core_Permission','check'), 'edit user-driven message templates')
or call_user_func(array('CRM_Core_Permission','check'), 'edit message templates'))
$type ne 'userTemplates' and ($canEditSystemTemplates or $canEditMessageTemplates)
) or (
$type eq 'userTemplates'and ($canEditUserDrivenMessageTemplates or $canEditMessageTemplates)
)}
<div id="{if $type eq 'userTemplates'}user{else}workflow{/if}" class='ui-tabs-panel ui-widget-content ui-corner-bottom'>
<div class="help">
Expand Down

0 comments on commit 2665aa1

Please sign in to comment.