From 9d9922e715d8f941465f61fa2206bc3867a99f01 Mon Sep 17 00:00:00 2001 From: kurund Date: Wed, 14 Aug 2013 04:16:44 +0530 Subject: [PATCH] notices fixes and whitespace fixes --- CRM/PCP/BAO/PCP.php | 101 ++++++++++++++++++++---------------- CRM/PCP/Form/PCPAccount.php | 2 +- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index 4966d3981c..511a7aee20 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -41,6 +41,7 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP { * @static */ static $_pcpLinks = NULL; + function __construct() { parent::__construct(); } @@ -49,7 +50,7 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP { * function to add or update either a Personal Campaign Page OR a PCP Block * * @param array $params reference array contains the values submitted by the form - * @param bool $pcpBlock if true, create or update PCPBlock, else PCP + * @param bool $pcpBlock if true, create or update PCPBlock, else PCP * @access public * @static * @@ -75,8 +76,8 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP { // set currency for CRM-1496 if (!isset($dao->currency)) { - $config = &CRM_Core_Config::singleton(); - $dao->currency = $config->defaultCurrency; + $config = & CRM_Core_Config::singleton(); + $dao->currency = $config->defaultCurrency; } $dao->save(); @@ -86,7 +87,7 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP { /** * function to get the Display name of a contact for a PCP * - * @param int $id id for the PCP + * @param int $id id for the PCP * * @return null|string Dispaly name of the contact if found * @static @@ -122,15 +123,15 @@ ORDER BY page_type, page_id"; $params = array(1 => array($contactId, 'Integer')); - $pcpInfoDao = CRM_Core_DAO::executeQuery($query, $params); - $pcpInfo = array(); - $hide = $mask = array_sum(array_keys($links['all'])); + $pcpInfoDao = CRM_Core_DAO::executeQuery($query, $params); + $pcpInfo = array(); + $hide = $mask = array_sum(array_keys($links['all'])); $contactPCPPages = array(); - $event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); + $event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $contribute = CRM_Contribute_PseudoConstant::contributionPage(); - $pcpStatus = CRM_Contribute_PseudoConstant::pcpStatus(); - $approved = CRM_Utils_Array::key('Approved', $pcpStatus); + $pcpStatus = CRM_Contribute_PseudoConstant::pcpStatus(); + $approved = CRM_Utils_Array::key('Approved', $pcpStatus); while ($pcpInfoDao->fetch()) { $mask = $hide; @@ -158,7 +159,7 @@ ORDER BY page_type, page_id"; else { $mask -= CRM_Core_Action::DISABLE; } - $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace); + $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace); $component = $pcpInfoDao->page_type; $pageTitle = CRM_Utils_Array::value($pcpInfoDao->page_id, $$component); @@ -194,8 +195,8 @@ GROUP BY block.id ORDER BY target_entity_type, target_entity_id "; $pcpBlockDao = CRM_Core_DAO::executeQuery($query); - $pcpBlock = array(); - $mask = 0; + $pcpBlock = array(); + $mask = 0; while ($pcpBlockDao->fetch()) { if ($links) { @@ -204,10 +205,10 @@ ORDER BY target_entity_type, target_entity_id 'pageComponent' => $pcpBlockDao->target_entity_type, ); } - $pcpLink = $links['add']; - $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace); - $component = $pcpBlockDao->target_entity_type; - $pageTitle = CRM_Utils_Array::value($pcpBlockDao->target_entity_id, $$component); + $pcpLink = $links['add']; + $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace); + $component = $pcpBlockDao->target_entity_type; + $pageTitle = CRM_Utils_Array::value($pcpBlockDao->target_entity_id, $$component); $pcpBlock[] = array( 'pageId' => $pcpBlockDao->target_entity_id, 'pageTitle' => $pageTitle, @@ -281,7 +282,8 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $deleteExtra = ts('Are you sure you want to delete this Personal Campaign Page?') . '\n' . ts('This action cannot be undone.'); self::$_pcpLinks['add'] = array( - CRM_Core_Action::ADD => array('name' => ts('Create a Personal Campaign Page'), + CRM_Core_Action::ADD => array( + 'name' => ts('Create a Personal Campaign Page'), 'url' => 'civicrm/contribute/campaign', 'qs' => 'action=add&reset=1&pageId=%%pageId%%&component=%%pageComponent%%', 'title' => ts('Configure'), @@ -289,32 +291,38 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; ); self::$_pcpLinks['all'] = array( - CRM_Core_Action::UPDATE => array('name' => ts('Edit Your Page'), + CRM_Core_Action::UPDATE => array( + 'name' => ts('Edit Your Page'), 'url' => 'civicrm/pcp/info', 'qs' => 'action=update&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Configure'), ), - CRM_Core_Action::DETACH => array('name' => ts('Tell Friends'), + CRM_Core_Action::DETACH => array( + 'name' => ts('Tell Friends'), 'url' => 'civicrm/friend', 'qs' => 'eid=%%pcpId%%&blockId=%%pcpBlock%%&reset=1&pcomponent=pcp&component=%%pageComponent%%', 'title' => ts('Tell Friends'), ), - CRM_Core_Action::BROWSE => array('name' => ts('Update Contact Information'), + CRM_Core_Action::BROWSE => array( + 'name' => ts('Update Contact Information'), 'url' => 'civicrm/pcp/info', 'qs' => 'action=browse&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Update Contact Information'), ), - CRM_Core_Action::ENABLE => array('name' => ts('Enable'), + CRM_Core_Action::ENABLE => array( + 'name' => ts('Enable'), 'url' => 'civicrm/pcp', 'qs' => 'action=enable&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Enable'), ), - CRM_Core_Action::DISABLE => array('name' => ts('Disable'), + CRM_Core_Action::DISABLE => array( + 'name' => ts('Disable'), 'url' => 'civicrm/pcp', 'qs' => 'action=disable&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Disable'), ), - CRM_Core_Action::DELETE => array('name' => ts('Delete'), + CRM_Core_Action::DELETE => array( + 'name' => ts('Delete'), 'url' => 'civicrm/pcp', 'qs' => 'action=delete&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', @@ -363,13 +371,16 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $form->addElement('checkbox', 'is_approval_needed', ts('Approval required')); - $profile = array(); + $profile = array(); $isUserRequired = NULL; - $config = CRM_Core_Config::singleton(); + $config = CRM_Core_Config::singleton(); if ($config->userFramework != 'Standalone') { $isUserRequired = 2; } - CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array('title', 'is_active')); + CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array( + 'title', + 'is_active' + )); if (!empty($profiles)) { foreach ($profiles as $key => $value) { if ($value['is_active']) { @@ -379,7 +390,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $form->assign('profile', $profile); } - $form->add('select', 'supporter_profile_id', ts('Supporter profile'), array('' => ts('- select -')) + $profile, true); + $form->add('select', 'supporter_profile_id', ts('Supporter profile'), array('' => ts('- select -')) + $profile, TRUE); $form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);")); @@ -425,9 +436,9 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );") ); $extraOption = array('onclick' => "return pcpAnonymous( );"); - $elements = array(); - $elements[] = &$page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); - $elements[] = &$page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption); + $elements = array(); + $elements[] = & $page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); + $elements[] = & $page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption); $page->addGroup($elements, 'pcp_is_anonymous', NULL, '   '); $page->_defaults['pcp_is_anonymous'] = 0; @@ -442,9 +453,9 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; /* * Process a PCP contribution/ */ - function handlePcp($pcpId, $component, $entity) { + public static function handlePcp($pcpId, $component, $entity) { - $entity_table = self::getPcpEntityTable($component); + self::getPcpEntityTable($component); if (!$pcpId) { return FALSE; @@ -461,7 +472,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $pcpBlock); $params = array('id' => $pcpInfo['page_id']); - $now = time(); + $now = time(); if ($component == 'event') { // figure out where to redirect if an exception occurs below based on target entity @@ -469,21 +480,17 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; // ignore startDate for events - PCP's can be active long before event start date $startDate = 0; - $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $entity)); + $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $entity)); } - elseif ($component == 'contribute') { $urlBase = 'civicrm/contribute/transact'; //start and end date of the contribution page $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $entity)); - $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $entity)); + $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $entity)); } // define redirect url back to contrib page or event if needed - $url = CRM_Utils_System::url($urlBase, - "reset=1&id={$pcpBlock['entity_id']}", - FALSE, NULL, FALSE, TRUE - ); + $url = CRM_Utils_System::url($urlBase, "reset=1&id={$pcpBlock['entity_id']}", FALSE, NULL, FALSE, TRUE ); if ($pcpBlock['target_entity_id'] != $entity['id']) { $statusMessage = ts('This page is not related to the Personal Campaign Page you have just visited. However you can still make a contribution here.'); @@ -524,7 +531,8 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; ); $statusMessage = ts('The event linked to the Personal Campaign Page you have just visited is over (as of %1).', array(1 => $customEndDate)); CRM_Core_Error::statusBounce($statusMessage, $url); - } else { + } + else { $statusMessage = ts('The Personal Campaign Page you have just visited is no longer active (as of %1). However you can still support the campaign here.', array(1 => $customEndDate)); CRM_Core_Error::statusBounce($statusMessage, $url); } @@ -561,13 +569,16 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; CRM_Core_DAO::setFieldValue('CRM_PCP_DAO_PCP', $id, 'status_id', $is_active); - $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $id, 'title'); - $pcpPageType = CRM_Core_DAO::getFieldValue( 'CRM_PCP_DAO_PCP', $id, 'page_type' ); + $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $id, 'title'); + $pcpPageType = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $id, 'page_type'); $pcpStatus = CRM_Core_OptionGroup::values("pcp_status"); $pcpStatus = $pcpStatus[$is_active]; - CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", array(1 => $pcpTitle, 2 => $pcpStatus)), 'Status Updated', 'success'); + CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", array( + 1 => $pcpTitle, + 2 => $pcpStatus + )), 'Status Updated', 'success'); // send status change mail $result = self::sendStatusUpdate($id, $is_active, FALSE, $pcpPageType); diff --git a/CRM/PCP/Form/PCPAccount.php b/CRM/PCP/Form/PCPAccount.php index 7de81d9b28..9708f33b55 100644 --- a/CRM/PCP/Form/PCPAccount.php +++ b/CRM/PCP/Form/PCPAccount.php @@ -295,7 +295,7 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { if ($ids) { $this->_contactID = $ids['0']; } - $contactID = &CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_contactID); + $contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_contactID); $this->set('contactID', $contactID); if (!empty($params['email'])) { -- 2.25.1