Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFC Convert Manage PCP page to short array syntax #16320

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions CRM/PCP/Page/PCP.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/

Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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');
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'],
Expand All @@ -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();
Expand All @@ -323,7 +320,6 @@ public function browse($action = NULL) {
}

public function search() {

if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
Expand Down