/** * Class constructor. * * @param array $queryParams * Array of parameters for query. * @param \const|int $action - action of search basic or advanced. * @param string $eventClause * If the caller wants to further restrict the search (used in participations). * @param bool $single * Are we dealing only with one contact?. * @param int $limit * How many participations do we want returned. * * @param string $context * @param null $compContext * * @return \CRM_Event_Selector_Search */ public function __construct(&$queryParams, $action = CRM_Core_Action::NONE, $eventClause = NULL, $single = FALSE, $limit = NULL, $context = 'search', $compContext = NULL) { // submitted form values $this->_queryParams =& $queryParams; $this->_single = $single; $this->_limit = $limit; $this->_context = $context; $this->_compContext = $compContext; $this->_eventClause = $eventClause; // type of selector $this->_action = $action; $this->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT); $this->_query->_distinctComponentClause = " civicrm_participant.id"; $this->_query->_groupByComponentClause = " GROUP BY civicrm_participant.id "; }
/** * Retrieve a specific participant, given a set of input params * If more than one matching participant exists, return an error, unless * the client has requested to return the first found contact * * @param array $params (reference ) input parameters * * @return array (reference ) array of properties, if error an array with an error id and error message * {@getfields participant_get} * @access public */ function civicrm_api3_participant_get($params) { $options = _civicrm_api3_get_options_from_params($params, TRUE, 'participant', 'get'); $sort = CRM_Utils_Array::value('sort', $options, NULL); $offset = CRM_Utils_Array::value('offset', $options); $rowCount = CRM_Utils_Array::value('limit', $options); $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params); $inputParams = CRM_Utils_Array::value('input_params', $options, array()); $returnProperties = CRM_Utils_Array::value('return', $options, NULL); if (empty($returnProperties)) { $returnProperties = CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT); } $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams); $query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT); list($select, $from, $where, $having) = $query->query(); $sql = "{$select} {$from} {$where} {$having}"; if (!empty($sort)) { $sql .= " ORDER BY {$sort} "; } $sql .= " LIMIT {$offset}, {$rowCount} "; $dao = CRM_Core_DAO::executeQuery($sql); $participant = array(); while ($dao->fetch()) { $participant[$dao->participant_id] = $query->store($dao); _civicrm_api3_custom_data_get($participant[$dao->participant_id], 'Participant', $dao->participant_id, NULL); } return civicrm_api3_create_success($participant, $params, 'participant', 'get', $dao); }
/** * process the form after the input has been submitted and validated * * @access public * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $config = CRM_Core_Config::singleton(); require_once 'CRM/Event/BAO/Query.php'; require_once 'CRM/Contact/BAO/Query.php'; $returnProperties =& CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT); $additionalFields = array('first_name', 'last_name', 'middle_name', 'current_employer'); foreach ($additionalFields as $field) { $returnProperties[$field] = 1; } if ($this->_single) { $queryParams = null; } else { $queryParams = $this->get('queryParams'); } $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, null, false, false, CRM_Contact_BAO_Query::MODE_EVENT); list($select, $from, $where) = $query->query(); if (empty($where)) { $where = "WHERE {$this->_componentClause}"; } else { $where .= " AND {$this->_componentClause}"; } $queryString = "{$select} {$from} {$where}"; $dao = CRM_Core_DAO::executeQuery($queryString); $rows = array(); while ($dao->fetch()) { $rows[$dao->participant_id] = array(); foreach ($returnProperties as $key => $dontCare) { $rows[$dao->participant_id][$key] = isset($dao->{$key}) ? $dao->{$key} : null; } } // get the class name from the participantListingID require_once 'CRM/Core/OptionGroup.php'; $className = CRM_Core_OptionGroup::getValue('event_badge', $params['badge_id'], 'value', 'Integer', 'name'); $classFile = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $error = (include_once $classFile); if ($error == false) { CRM_Core_Error::fatal('Event Badge code file: ' . $classFile . ' does not exist. Please verify your custom event badge settings in CiviCRM administrative panel.'); } eval("\$eventBadgeClass = new {$className}( );"); $eventBadgeClass->run($rows); }
/** * Get contact participant record. * * This api is used for finding an existing participant record. * * @param array $params an associative array of name/value property values of civicrm_participant * * @return participant property values. * @access public */ function &civicrm_participant_search(&$params) { if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } $inputParams = array(); $returnProperties = array(); $otherVars = array('sort', 'offset', 'rowCount'); $sort = null; $offset = 0; $rowCount = 25; foreach ($params as $n => $v) { if (substr($n, 0, 7) == 'return.') { $returnProperties[substr($n, 7)] = $v; } elseif (in_array($n, $otherVars)) { ${$n} = $v; } else { $inputParams[$n] = $v; } } // add is_test to the clause if not present if (!array_key_exists('participant_test', $inputParams)) { $inputParams['participant_test'] = 0; } require_once 'CRM/Contact/BAO/Query.php'; require_once 'CRM/Event/BAO/Query.php'; if (empty($returnProperties)) { $returnProperties = CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT); } $newParams =& CRM_Contact_BAO_Query::convertFormValues($params); $query =& new CRM_Contact_BAO_Query($newParams, $returnProperties, null); list($select, $from, $where) = $query->query(); $sql = "{$select} {$from} {$where}"; if (!empty($sort)) { $sql .= " ORDER BY {$sort} "; } $sql .= " LIMIT {$offset}, {$rowCount} "; $dao =& CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray); $participant = array(); while ($dao->fetch()) { $participant[$dao->participant_id] = $query->store($dao); } $dao->free(); return $participant; }