From 5d6d010436f70d3cc89562c9f89f1a95d777210d Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Tue, 28 Mar 2017 15:37:36 -0400 Subject: [PATCH 1/2] CRM-20351 ACL: Don't repeat stuff in the page run() method --- CRM/ACL/Page/ACL.php | 64 ++++----- CRM/ACL/Page/ACLBasic.php | 20 +-- CRM/ACL/Page/EntityRole.php | 24 +--- CRM/Contact/Page/DedupeRules.php | 17 +-- CRM/Contribute/Page/ManagePremiums.php | 19 +-- CRM/Core/Page/Basic.php | 50 ++++--- CRM/Financial/Page/FinancialAccount.php | 24 ---- CRM/Financial/Page/FinancialBatch.php | 11 +- CRM/Financial/Page/FinancialType.php | 24 ---- CRM/Member/Page/MembershipStatus.php | 33 ----- CRM/PCP/Page/PCP.php | 18 +-- tests/phpunit/CRM/Core/Page/HookTest.php | 160 +++++++++++++++++++++++ 12 files changed, 252 insertions(+), 212 deletions(-) create mode 100644 tests/phpunit/CRM/Core/Page/HookTest.php diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index b8c45390fe7f..a17e4bc09012 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -90,23 +90,9 @@ public function &links() { /** * Run the page. * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. + * Set the breadcrumb before beginning the standard page run. */ public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - // set breadcrumb to append to admin/access $breadCrumb = array( array( @@ -117,24 +103,6 @@ public function run() { ), ); CRM_Utils_System::appendBreadCrumb($breadCrumb); - // what action to take ? - if ($action & (CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { - $this->edit($action, $id); - } - - if ($action & (CRM_Core_Action::UPDATE)) { - $this->edit($action, $id); - - if (isset($id)) { - $aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id); - CRM_Utils_System::setTitle(ts('Edit ACL - %1', array(1 => $aclName))); - } - } - - // finally browse the acl's - if ($action & CRM_Core_Action::BROWSE) { - $this->browse(); - } // parent run return parent::run(); @@ -193,22 +161,22 @@ public function browse() { switch ($acl[$dao->id]['object_table']) { case 'civicrm_saved_search': - $acl[$dao->id]['object'] = $group[$acl[$dao->id]['object_id']]; + $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $group); $acl[$dao->id]['object_name'] = ts('Group'); break; case 'civicrm_uf_group': - $acl[$dao->id]['object'] = $ufGroup[$acl[$dao->id]['object_id']]; + $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $ufGroup); $acl[$dao->id]['object_name'] = ts('Profile'); break; case 'civicrm_custom_group': - $acl[$dao->id]['object'] = $customGroup[$acl[$dao->id]['object_id']]; + $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $customGroup); $acl[$dao->id]['object_name'] = ts('Custom Group'); break; case 'civicrm_event': - $acl[$dao->id]['object'] = $event[$acl[$dao->id]['object_id']]; + $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $event); $acl[$dao->id]['object_name'] = ts('Event'); break; } @@ -269,4 +237,26 @@ public function userContext($mode = NULL) { return 'civicrm/acl'; } + /** + * Edit an ACL. + * + * @param int $mode + * What mode for the form ?. + * @param int $id + * Id of the entity (for update, view operations). + * @param bool $imageUpload + * Not used in this case, but extended from CRM_Core_Page_Basic. + * @param bool $pushUserContext + * Not used in this case, but extended from CRM_Core_Page_Basic. + */ + public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) { + if ($mode & (CRM_Core_Action::UPDATE)) { + if (isset($id)) { + $aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id); + CRM_Utils_System::setTitle(ts('Edit ACL – %1', array(1 => $aclName))); + } + } + parent::edit($mode, $id, $imageUpload, $pushUserContext); + } + } diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index c536917e2b1a..758705e31494 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -83,17 +83,7 @@ public function &links() { * Finally it calls the parent's run method. */ public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); + $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access $breadCrumb = array( @@ -105,15 +95,15 @@ public function run() { CRM_Utils_System::appendBreadCrumb($breadCrumb); // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { - $this->edit($action, $id); + if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { + $this->edit($this->_action, $id); } // finally browse the acl's $this->browse(); - // parent run - return parent::run(); + // This replaces parent run, but do parent's parent run + return CRM_Core_Page::run(); } /** diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 32a67e4bc555..7a1b510a6ec2 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -95,17 +95,7 @@ public function &links() { * Finally it calls the parent's run method. */ public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); + $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access $breadCrumb = array( @@ -120,21 +110,21 @@ public function run() { CRM_Utils_System::setTitle(ts('Assign Users to Roles')); // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { - $this->edit($action, $id); + if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { + $this->edit($this->_action, $id); } // reset cache if enabled/disabled - if ($action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE)) { + if ($this->_action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE)) { CRM_ACL_BAO_Cache::resetCache(); } // finally browse the acl's - if ($action & CRM_Core_Action::BROWSE) { + if ($this->_action & CRM_Core_Action::BROWSE) { } - // parent run - return parent::run(); + // This replaces parent run, but do parent's parent run + return CRM_Core_Page::run(); } /** diff --git a/CRM/Contact/Page/DedupeRules.php b/CRM/Contact/Page/DedupeRules.php index 151dcdf58eaa..01d420d714d9 100644 --- a/CRM/Contact/Page/DedupeRules.php +++ b/CRM/Contact/Page/DedupeRules.php @@ -99,12 +99,7 @@ public function &links() { * method. */ public function run() { - // get the requested action, default to 'browse' - $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); + $id = $this->getIdAndAction(); $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE); if ($context == 'nonDupe') { @@ -116,18 +111,18 @@ public function run() { $this->assign('hasperm_merge_duplicate_contacts', CRM_Core_Permission::check('merge duplicate contacts')); // which action to take? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $this->edit($action, $id); + if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { + $this->edit($this->_action, $id); } - if ($action & CRM_Core_Action::DELETE) { + if ($this->_action & CRM_Core_Action::DELETE) { $this->delete($id); } // browse the rules $this->browse(); - // parent run - return parent::run(); + // This replaces parent run, but do parent's parent run + return CRM_Core_Page::run(); } /** diff --git a/CRM/Contribute/Page/ManagePremiums.php b/CRM/Contribute/Page/ManagePremiums.php index a5dc049dcbbc..69d204e9aa11 100644 --- a/CRM/Contribute/Page/ManagePremiums.php +++ b/CRM/Contribute/Page/ManagePremiums.php @@ -105,28 +105,17 @@ public function &links() { * Finally it calls the parent's run method. */ public function run() { - - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); + $id = $this->getIdAndAction(); // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::PREVIEW)) { - $this->edit($action, $id, TRUE); + if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::PREVIEW)) { + $this->edit($this->_action, $id, TRUE); } // finally browse the custom groups $this->browse(); // parent run - return parent::run(); + return CRM_Core_Page::run(); } /** diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index 069ba23782e6..b0b7934adbdb 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -141,19 +141,7 @@ public function run() { $sort = ($n > 2) ? func_get_arg(2) : NULL; // what action do we want to perform ? (store it for smarty too.. :) - $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); - $this->assign('action', $this->_action); - - // get 'id' if present - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); - - require_once str_replace('_', DIRECTORY_SEPARATOR, $this->getBAOName()) . ".php"; - - if ($id) { - if (!$this->checkPermission($id, NULL)) { - CRM_Core_Error::fatal(ts('You do not have permission to make changes to the record')); - } - } + $id = $this->getIdAndAction(); if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::ADD | @@ -175,6 +163,33 @@ public function run() { return parent::run(); } + /** + * Retrieve the action and ID from the request. + * + * Action is assigned to the template while we're at it. This is pulled from + * the `run()` method above. + * + * @return int + * The ID if present, or 0. + */ + public function getIdAndAction() { + $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); + $this->assign('action', $this->_action); + + // get 'id' if present + $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); + + require_once str_replace('_', DIRECTORY_SEPARATOR, $this->getBAOName()) . ".php"; + + if ($id) { + if (!$this->checkPermission($id, NULL)) { + CRM_Core_Error::fatal(ts('You do not have permission to make changes to the record')); + } + } + + return $id; + } + /** * @return string */ @@ -288,11 +303,10 @@ public function action(&$object, $action, &$values, &$links, $permission, $force $hasDelete = $hasDisable = TRUE; if (!empty($values['name']) && in_array($values['name'], array( - 'encounter_medium', - 'case_type', - 'case_status', - )) - ) { + 'encounter_medium', + 'case_type', + 'case_status', + ))) { static $caseCount = NULL; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE); diff --git a/CRM/Financial/Page/FinancialAccount.php b/CRM/Financial/Page/FinancialAccount.php index 3bfe8862a2b6..0d4718b6e288 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -90,30 +90,6 @@ public function &links() { return self::$_links; } - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - */ - public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // default to 'browse' - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); - - // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $this->edit($action, $id); - } - - // parent run - return parent::run(); - } - /** * Browse all custom data groups. */ diff --git a/CRM/Financial/Page/FinancialBatch.php b/CRM/Financial/Page/FinancialBatch.php index 17b9cf84b7ef..6ce5833a5fc2 100644 --- a/CRM/Financial/Page/FinancialBatch.php +++ b/CRM/Financial/Page/FinancialBatch.php @@ -76,21 +76,20 @@ public function &links() { public function run() { $context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->set("context", $context); - // assign vars to templates - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); - $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // default to 'browse' + + $id = $this->getIdAndAction(); // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | + if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::CLOSE | CRM_Core_Action::REOPEN | CRM_Core_Action::EXPORT) ) { - $this->edit($action, $id); + $this->edit($this->_action, $id); } // parent run - return parent::run(); + return CRM_Core_Page::run(); } diff --git a/CRM/Financial/Page/FinancialType.php b/CRM/Financial/Page/FinancialType.php index 7d3ff037d802..53d31b84b674 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -96,30 +96,6 @@ public function &links() { return self::$_links; } - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - */ - public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // default to 'browse' - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); - - // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $this->edit($action, $id); - } - - // parent run - return parent::run(); - } - /** * Browse all financial types. */ diff --git a/CRM/Member/Page/MembershipStatus.php b/CRM/Member/Page/MembershipStatus.php index 415aae7bcf74..aa9732200190 100644 --- a/CRM/Member/Page/MembershipStatus.php +++ b/CRM/Member/Page/MembershipStatus.php @@ -93,39 +93,6 @@ public function &links() { return self::$_links; } - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - * - * @return void - */ - public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $this->edit($action, $id); - } - // finally browse the custom groups - $this->browse(); - - // parent run - return parent::run(); - } - /** * Browse all custom data groups. * diff --git a/CRM/PCP/Page/PCP.php b/CRM/PCP/Page/PCP.php index e090829e0e06..c7255ffb5fc3 100644 --- a/CRM/PCP/Page/PCP.php +++ b/CRM/PCP/Page/PCP.php @@ -121,25 +121,19 @@ public function &links() { * @return void */ public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - $this, FALSE, - 'browse' - ); - if ($action & CRM_Core_Action::REVERT) { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); + $id = $this->getIdAndAction(); + + if ($this->_action & CRM_Core_Action::REVERT) { CRM_PCP_BAO_PCP::setIsActive($id, 0); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1')); } - elseif ($action & CRM_Core_Action::RENEW) { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); + elseif ($this->_action & CRM_Core_Action::RENEW) { CRM_PCP_BAO_PCP::setIsActive($id, 1); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1')); } - elseif ($action & CRM_Core_Action::DELETE) { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); + elseif ($this->_action & CRM_Core_Action::DELETE) { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); $controller = new CRM_Core_Controller_Simple('CRM_PCP_Form_PCP', @@ -156,7 +150,7 @@ public function run() { $this->browse(); // parent run - parent::run(); + CRM_Core_Page::run(); } /** diff --git a/tests/phpunit/CRM/Core/Page/HookTest.php b/tests/phpunit/CRM/Core/Page/HookTest.php new file mode 100644 index 000000000000..ce905772f0e9 --- /dev/null +++ b/tests/phpunit/CRM/Core/Page/HookTest.php @@ -0,0 +1,160 @@ +skip)) { + continue; + } + if (is_subclass_of($class, 'CRM_Core_Page_Basic')) { + $this->basicPages[] = $class; + } + } + parent::setUp(); + } + + /** + * Make sure form hooks are only invoked once. + */ + public function testFormsCallBuildFormOnce() { + CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_buildForm', array($this, 'onBuildForm')); + CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_preProcess', array($this, 'onPreProcess')); + $_REQUEST = array('action' => 'add'); + foreach ($this->basicPages as $pageName) { + // Reset the counters + $this->hookCount = array( + 'buildForm' => array(), + 'preProcess' => array(), + ); + $page = new $pageName(); + ob_start(); + $page->run(); + ob_end_clean(); + $this->runTestAssert($pageName); + } + } + + /** + * Go through the record of hook invocation and make sure that each hook has + * run once and no more than once per class. + * + * @param string $pageName + * The page/form evaluated. + */ + private function runTestAssert($pageName) { + foreach ($this->hookCount as $hook => $hookUsage) { + $ran = FALSE; + foreach ($hookUsage as $class => $count) { + $ran = TRUE; + // The hook should have run once and only once. + $this->assertEquals(1, $count, "Checking $pageName: $hook invoked multiple times with $class"); + } + $this->assertTrue($ran, "$hook never invoked for $pageName"); + } + } + + /** + * Make sure pageRun hook is only invoked once. + */ + public function testPagesCallPageRunOnce() { + CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_pageRun', array($this, 'onPageRun')); + $_REQUEST = array('action' => 'browse'); + foreach ($this->basicPages as $pageName) { + // Reset the counters + $this->hookCount = array('pageRun' => array()); + $page = new $pageName(); + ob_start(); + $page->run(); + ob_end_clean(); + $this->runTestAssert($pageName); + } + } + + /** + * Implements hook_civicrm_buildForm(). + * + * Increment the count of uses of this hook per formName. + */ + public function onBuildForm($formName, &$form) { + $this->incrementHookCount('buildForm', $formName); + } + + public function onPreProcess($formName, &$form) { + $this->incrementHookCount('preProcess', $formName); + } + + /** + * Implements hook_civicrm_pageRun(). + * + * Increment the count of uses of this hook per page class. + */ + public function onPageRun(&$page) { + $this->incrementHookCount('pageRun', get_class($page)); + } + + /** + * Increment the count of uses of a hook in a class. + * + * @param string $hook + * The hook being used. + * @param string $class + * The class name of the page or form. + */ + private function incrementHookCount($hook, $class) { + if (empty($this->hookCount[$hook][$class])) { + $this->hookCount[$hook][$class] = 0; + } + $this->hookCount[$hook][$class]++; + } + +} From 28c645354fbe96702fd428e55af390601adfa2da Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 4 May 2017 23:24:43 +0530 Subject: [PATCH 2/2] fix test failures --- CRM/Contact/Page/DedupeFind.php | 2 +- CRM/Event/BAO/Participant.php | 3 +-- CRM/PCP/Page/PCP.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/Page/DedupeFind.php b/CRM/Contact/Page/DedupeFind.php index 012529f882ed..0646f0f7f7b3 100644 --- a/CRM/Contact/Page/DedupeFind.php +++ b/CRM/Contact/Page/DedupeFind.php @@ -61,7 +61,7 @@ public function run() { $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0); $context = CRM_Utils_Request::retrieve('context', 'String', $this); $limit = CRM_Utils_Request::retrieve('limit', 'Integer', $this); - $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive'); + $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this); $urlQry = array( 'reset' => 1, 'rgid' => $rgid, diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 492ece8ccb0e..eb6fc33e74e1 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -2209,8 +2209,7 @@ public static function addActivityForSelection($participantId, $activityType) { $date = CRM_Utils_Date::currentDBDate(); $event = CRM_Event_BAO_Event::getEvents(0, $eventId); - $eventTitle = $event[$eventId]; - $subject = "Registration selections changed for $eventTitle"; + $subject = sprintf("Registration selections changed for %s", CRM_Utils_Array::value($eventId, $event)); $targetCid = $contactId; $srcRecId = $participantId; diff --git a/CRM/PCP/Page/PCP.php b/CRM/PCP/Page/PCP.php index c7255ffb5fc3..e3512ee7c353 100644 --- a/CRM/PCP/Page/PCP.php +++ b/CRM/PCP/Page/PCP.php @@ -214,7 +214,7 @@ public function browse($action = NULL) { } } - $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name'); + $approvedId = CRM_Core_PseudoConstant::getKey('CRM_PCP_BAO_PCP', 'status_id', 'Approved'); //check for delete CRM-4418 $allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');