From fed95fdf999b02803fae387d86fa73a6e78af3bb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 1 Dec 2021 10:56:00 +1300 Subject: [PATCH] [Smarty variables] Consistently assign isAdmin at php layer --- CRM/Contact/Form/Task/EmailTrait.php | 4 +--- CRM/Contact/Form/Task/SMS.php | 4 +--- CRM/Contribute/Form/Task/Invoice.php | 4 +--- CRM/Contribute/Page/DashBoard.php | 6 +----- CRM/SMS/Form/Group.php | 5 +---- templates/CRM/Admin/Form/MessageTemplates.tpl | 3 --- templates/CRM/Admin/Form/ScheduleReminders.tpl | 3 --- 7 files changed, 5 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/Form/Task/EmailTrait.php b/CRM/Contact/Form/Task/EmailTrait.php index c4d6501507..b62a8c5163 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -125,9 +125,7 @@ trait CRM_Contact_Form_Task_EmailTrait { } $this->setContactIDs(); $this->assign('single', $this->_single); - if (CRM_Core_Permission::check('administer CiviCRM')) { - $this->assign('isAdmin', 1); - } + $this->assign('isAdmin', CRM_Core_Permission::check('administer CiviCRM')); } /** diff --git a/CRM/Contact/Form/Task/SMS.php b/CRM/Contact/Form/Task/SMS.php index 2c795fe8c5..274aab6564 100644 --- a/CRM/Contact/Form/Task/SMS.php +++ b/CRM/Contact/Form/Task/SMS.php @@ -48,9 +48,7 @@ class CRM_Contact_Form_Task_SMS extends CRM_Contact_Form_Task { } $this->assign('single', $this->_single); - if (CRM_Core_Permission::check('administer CiviCRM')) { - $this->assign('isAdmin', 1); - } + $this->assign('isAdmin', CRM_Core_Permission::check('administer CiviCRM')); } /** diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index a3d5adab71..cf238c902e 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -135,9 +135,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { */ public function buildQuickForm() { $this->preventAjaxSubmit(); - if (CRM_Core_Permission::check('administer CiviCRM')) { - $this->assign('isAdmin', 1); - } + $this->assign('isAdmin', CRM_Core_Permission::check('administer CiviCRM')); $this->add('select', 'from_email_address', ts('From'), $this->_fromEmails, TRUE); if ($this->_selectedOutput != 'email') { diff --git a/CRM/Contribute/Page/DashBoard.php b/CRM/Contribute/Page/DashBoard.php index 6e2c59c8a8..b7df27e2f7 100644 --- a/CRM/Contribute/Page/DashBoard.php +++ b/CRM/Contribute/Page/DashBoard.php @@ -75,11 +75,7 @@ class CRM_Contribute_Page_DashBoard extends CRM_Core_Page { } // Check for admin permission to see if we should include the Manage Contribution Pages action link - $isAdmin = 0; - if (CRM_Core_Permission::check('administer CiviCRM')) { - $isAdmin = 1; - } - $this->assign('isAdmin', $isAdmin); + $this->assign('isAdmin', CRM_Core_Permission::check('administer CiviCRM')); } /** diff --git a/CRM/SMS/Form/Group.php b/CRM/SMS/Form/Group.php index 5dad9206a1..b79064ee96 100644 --- a/CRM/SMS/Form/Group.php +++ b/CRM/SMS/Form/Group.php @@ -30,10 +30,7 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $session = CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1&sms=1')); - - if (CRM_Core_Permission::check('administer CiviCRM')) { - $this->assign('isAdmin', 1); - } + $this->assign('isAdmin', CRM_Core_Permission::check('administer CiviCRM')); } /** diff --git a/templates/CRM/Admin/Form/MessageTemplates.tpl b/templates/CRM/Admin/Form/MessageTemplates.tpl index d00fb30478..cb42f4139d 100644 --- a/templates/CRM/Admin/Form/MessageTemplates.tpl +++ b/templates/CRM/Admin/Form/MessageTemplates.tpl @@ -8,9 +8,6 @@ +--------------------------------------------------------------------+ *} {* this template is used for adding/editing/deleting Message Templates *} -{if !isset($isAdmin)} - {assign var="isAdmin" value="0"} -{/if} {if $action neq 8}
{ts}Use this form to add or edit re-usable message templates.{/ts} {help id="id-intro" file="CRM/Admin/Page/MessageTemplates.hlp"} diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index 6ab425a5c0..95d5cefe17 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -7,9 +7,6 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{if !isset($isAdmin)} - {assign var="isAdmin" value="0"} -{/if} {* This template is used for adding/scheduling reminders. *}
{include file="CRM/common/formButtons.tpl" location="top"}
-- 2.25.1