X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FForm%2FSearch.php;h=1f6b35ca40109b0cefb1bf523eb617a77eac4c91;hb=0e2d8aaf8b8be26c5ea204980d4f696e5cadbd37;hp=7cc862ad434dc421736fb077e87d995e7a2b6a93;hpb=6f2500ee7589360102875df4367568fe87485df6;p=civicrm-core.git diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 7cc862ad43..1f6b35ca40 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -43,43 +43,42 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { /** - * The params that are sent to the query + * The params that are sent to the query. * * @var array */ protected $_queryParams; /** - * Are we restricting ourselves to a single contact + * Are we restricting ourselves to a single contact. * * @var boolean */ protected $_single = FALSE; /** - * Are we restricting ourselves to a single contact + * Are we restricting ourselves to a single contact. * * @var boolean */ protected $_limit = NULL; /** - * Prefix for the controller - * + * Prefix for the controller. */ protected $_prefix = "event_"; protected $_defaults; /** - * The saved search ID retrieved from the GET vars + * The saved search ID retrieved from the GET vars. * * @var int */ protected $_ssID; /** - * Processing needed for buildForm and later + * Processing needed for buildForm and later. * * @return void */ @@ -99,11 +98,11 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { * we allow the controller to set force/reset externally, useful when we are being * driven by the wizard framework */ - $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); - $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); - $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); + $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); + $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); + $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search'); - $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this); + $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this); $this->assign("context", $this->_context); // get user submitted values @@ -164,7 +163,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { } /** - * Build the form object + * Build the form object. * * * @return void @@ -194,18 +193,16 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { if (count($eventIds) == 1) { //convert form values to clause. $seatClause = array(); - // Filter on is_test if specified in search form if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') { $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )"; } if (!empty($this->_formValues['participant_status_id'])) { - $statuses = array_keys($this->_formValues['participant_status_id']); - $seatClause[] = '( participant.status_id IN ( ' . implode(' , ', $statuses) . ' ) )'; + $seatClause[] = '( participant.status_id IN ( ' . implode(' , ', (array) $this->_formValues['participant_status_id']) . ' ) )'; } if (!empty($this->_formValues['participant_role_id'])) { - $roles = array_keys($this->_formValues['participant_role_id']); - $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', $roles) . ' ) )'; + $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', (array) $this->_formValues['participant_role_id']) . ' ) )'; } + // CRM-15379 if (!empty($this->_formValues['participant_fee_id'])) { $participant_fee_id = $this->_formValues['participant_fee_id']; @@ -213,12 +210,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel)); $seatClause[] = "( participant.fee_level LIKE '%$feeLabel%' )"; } - $clause = NULL; - if (!empty($seatClause)) { - $clause = implode(' AND ', $seatClause); - } - $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $clause); + $seatClause = implode(' AND ', $seatClause); + $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause); } $this->assign('participantCount', $participantCount); $this->assign('lineItems', $lineItems); @@ -350,19 +344,21 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { } /** - * This function is used to add the rules (mainly global rules) for form. + * add the rules (mainly global rules) for form. * All local rules are added near the element * * @return void * @see valid_date */ - public function addRules() {} + public function addRules() { + } /** - * Set the default form values + * Set the default form values. * * - * @return array the default array reference + * @return array + * the default array reference */ public function setDefaultValues() { $defaults = array(); @@ -394,14 +390,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 0"); } elseif (is_numeric($status)) { - $status = (int) $status; - $statusTypes = array($status => CRM_Event_PseudoConstant::participantStatus($status)); - } - $status = array(); - foreach ($statusTypes as $key => $value) { - $status[$key] = 1; + $statusTypes = (int) $status; } - $this->_formValues['participant_status_id'] = $status; + $this->_formValues['participant_status_id'] = is_array($statusTypes) ? array_keys($statusTypes) : $statusTypes; } $role = CRM_Utils_Request::retrieve('role', 'String', @@ -416,14 +407,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $roleTypes = CRM_Event_PseudoConstant::participantRole(NULL, "filter = 0"); } elseif (is_numeric($role)) { - $role = (int) $role; - $roleTypes = array($role => CRM_Event_PseudoConstant::participantRole($role)); + $roleTypes = (int) $role; } - $role = array(); - foreach ($roleTypes as $key => $value) { - $role[$key] = 1; - } - $this->_formValues['participant_role_id'] = $role; + $this->_formValues['participant_role_id'] = is_array($roleTypes) ? array_keys($roleTypes) : $roleTypes; } $type = CRM_Utils_Request::retrieve('type', 'Positive', @@ -461,4 +447,5 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { public function getTitle() { return ts('Find Participants'); } + }