/** * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. * @param int $offset * The row number to start from. * @param int $rowCount * The number of rows to return. * @param string $sort * The sql string that describes the sort order. * @param string $output * What should the result set include (web/email/csv). * * @return array * rows in the given offset and rowCount */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause); // process the result of the query $rows = array(); //lets handle view, edit and delete separately. CRM-4418 $permissions = array(CRM_Core_Permission::VIEW); if (CRM_Core_Permission::check('edit event participants')) { $permissions[] = CRM_Core_Permission::EDIT; } if (CRM_Core_Permission::check('delete in CiviEvent')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $sep = CRM_Core_DAO::VALUE_SEPARATOR; //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } //carry campaign on selectors. $row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns); $row['campaign_id'] = $result->participant_campaign_id; // gross hack to show extra information for pending status $statusClass = NULL; if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) { $statusClass = $statusClasses[$statusId]; } $row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE; if (!empty($row['participant_is_test'])) { $row['participant_status'] .= ' (' . ts('test') . ')'; } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $links = self::links($this->_key, $this->_context, $this->_compContext); if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment')); } if ($statusTypes[$row['participant_status_id']] == 'Pending refund') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund')); } $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id); $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id); $row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']); if (!empty($row['participant_fee_level'])) { CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']); } if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) { // add line item details if applicable $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']); } if (!empty($row['participant_role_id'])) { $viewRoles = array(); foreach (explode($sep, $row['participant_role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } $row['participant_role_id'] = implode(', ', $viewRoles); } $rows[] = $row; } CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems); return $rows; }
/** * returns all the rows in the given offset and rowCount * * @param enum $action the action being performed * @param int $offset the row number to start from * @param int $rowCount the number of rows to return * @param string $sort the sql string that describes the sort order * @param enum $output what should the result set include (web/email/csv) * * @return array rows in the given offset and rowCount */ function &getRows($action, $offset, $rowCount, $sort, $output = null) { $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_eventClause); // process the result of the query $rows = array(); //lets handle view, edit and delete separately. CRM-4418 $permissions = array(CRM_Core_Permission::VIEW); if (CRM_Core_Permission::check('edit event participants')) { $permissions[] = CRM_Core_Permission::EDIT; } if (CRM_Core_Permission::check('delete in CiviEvent')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); require_once 'CRM/Event/BAO/Event.php'; require_once 'CRM/Event/PseudoConstant.php'; $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } // gross hack to show extra information for pending status $statusClass = null; if ($statusId = array_search($row['participant_status_id'], $statusTypes)) { $statusClass = $statusClasses[$statusId]; } $extraInfo = array(); $row['showConfirmUrl'] = false; if ($statusClass == 'Pending') { $row['showConfirmUrl'] = true; } if (CRM_Utils_Array::value('participant_is_test', $row)) { $extraInfo[] = ts('test'); } if ($extraInfo) { $row['participant_status_id'] .= ' (' . implode(', ', $extraInfo) . ')'; } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $row['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context)); require_once 'CRM/Contact/BAO/Contact/Utils.php'; $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type); $row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']); if (CRM_Utils_Array::value('participant_fee_level', $row)) { CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']); } if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) { // add line item details if applicable require_once 'CRM/Price/BAO/LineItem.php'; $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']); } $rows[] = $row; } CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems); return $rows; }