From 3ed13c606cbc421b93905590a4b8375411ea2cd8 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Fri, 17 Jan 2020 10:09:25 +0000 Subject: [PATCH] Convert Manage PCP page to short array syntax --- CRM/PCP/Page/PCP.php | 60 +++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/CRM/PCP/Page/PCP.php b/CRM/PCP/Page/PCP.php index 2d72a6611c8c..c6f9d04bd3b8 100644 --- a/CRM/PCP/Page/PCP.php +++ b/CRM/PCP/Page/PCP.php @@ -13,7 +13,6 @@ * * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing - * $Id$ * */ @@ -50,45 +49,45 @@ public function &links() { // helper variable for nicer formatting $deleteExtra = ts('Are you sure you want to delete this Campaign Page ?'); - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/pcp/info', 'qs' => 'action=update&reset=1&id=%%id%%&context=dashboard', 'title' => ts('Edit Personal Campaign Page'), - ), - CRM_Core_Action::RENEW => array( + ], + CRM_Core_Action::RENEW => [ 'name' => ts('Approve'), 'url' => 'civicrm/admin/pcp', 'qs' => 'action=renew&id=%%id%%', 'title' => ts('Approve Personal Campaign Page'), - ), - CRM_Core_Action::REVERT => array( + ], + CRM_Core_Action::REVERT => [ 'name' => ts('Reject'), 'url' => 'civicrm/admin/pcp', 'qs' => 'action=revert&id=%%id%%', 'title' => ts('Reject Personal Campaign Page'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/pcp', 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete Personal Campaign Page'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'url' => 'civicrm/admin/pcp', 'qs' => 'action=enable&id=%%id%%', 'title' => ts('Enable'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'url' => 'civicrm/admin/pcp', 'qs' => 'action=disable&id=%%id%%', 'title' => ts('Disable'), - ), - ); + ], + ]; } return self::$_links; } @@ -100,9 +99,8 @@ public function &links() { * type of action and executes that action. * Finally it calls the parent's run method. * - * @param - * - * @return void + * @return mixed|null + * @throws \CRM_Core_Exception */ public function run() { $id = $this->getIdAndAction(); @@ -140,10 +138,9 @@ public function run() { /** * Browse all custom data groups. * + * @param int $action * - * @param null $action - * - * @return void + * @throws \CRM_Core_Exception */ public function browse($action = NULL) { CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); @@ -160,32 +157,32 @@ public function browse($action = NULL) { $status = CRM_PCP_BAO_PCP::buildOptions('status_id', 'create'); - $pcpSummary = $params = array(); + $pcpSummary = $params = []; $whereClause = NULL; if (!empty($_POST) || !empty($_GET['page_type'])) { if (!empty($_POST['status_id'])) { $whereClause = ' AND cp.status_id = %1'; - $params['1'] = array($_POST['status_id'], 'Integer'); + $params['1'] = [$_POST['status_id'], 'Integer']; } if (!empty($_POST['page_type'])) { $whereClause .= ' AND cp.page_type = %2'; - $params['2'] = array($_POST['page_type'], 'String'); + $params['2'] = [$_POST['page_type'], 'String']; } elseif (!empty($_GET['page_type'])) { $whereClause .= ' AND cp.page_type = %2'; - $params['2'] = array($_GET['page_type'], 'String'); + $params['2'] = [$_GET['page_type'], 'String']; } if (!empty($_POST['page_id'])) { $whereClause .= ' AND cp.page_id = %4 AND cp.page_type = "contribute"'; - $params['4'] = array($_POST['page_id'], 'Integer'); + $params['4'] = [$_POST['page_id'], 'Integer']; } if (!empty($_POST['event_id'])) { $whereClause .= ' AND cp.page_id = %5 AND cp.page_type = "event"'; - $params['5'] = array($_POST['event_id'], 'Integer'); + $params['5'] = [$_POST['event_id'], 'Integer']; } if ($whereClause) { @@ -226,7 +223,7 @@ public function browse($action = NULL) { $pages['event'][$epages->id]['end_date'] = $epages->registration_end_date; } - $params = $this->get('params') ? $this->get('params') : array(); + $params = $this->get('params') ? $this->get('params') : []; $title = '1'; if ($this->_sortByCharacter !== NULL) { @@ -289,7 +286,7 @@ public function browse($action = NULL) { $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/register', 'reset=1&id=' . $pcp->page_id); } - $pcpSummary[$pcp->id] = array( + $pcpSummary[$pcp->id] = [ 'id' => $pcp->id, 'start_date' => $pages[$page_type][$page_id]['start_date'], 'end_date' => $pages[$page_type][$page_id]['end_date'], @@ -301,11 +298,11 @@ public function browse($action = NULL) { 'page_url' => $pageUrl, 'page_type' => $page_type, 'action' => CRM_Core_Action::formLink(self::links(), $action, - array('id' => $pcp->id), ts('more'), FALSE, 'contributionpage.pcp.list', 'PCP', $pcp->id + ['id' => $pcp->id], ts('more'), FALSE, 'contributionpage.pcp.list', 'PCP', $pcp->id ), 'title' => $pcp->title, 'class' => $class, - ); + ]; } $this->search(); @@ -323,7 +320,6 @@ public function browse($action = NULL) { } public function search() { - if ($this->_action & CRM_Core_Action::DELETE) { return; }