X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FBAO%2FParticipant.php;h=d324b1e9e998267969619f63e52ae6f011e44f14;hb=04d2e082924ee167fa35b78dfaacfaef07c8cd8a;hp=7f0c43d7d14c9b7bf46f89a9f8e6bf12e9d30a04;hpb=e9aca61e8b08d5ae372621c4397108b8f2ec28ba;p=civicrm-core.git
diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php
index 7f0c43d7d1..d324b1e9e9 100644
--- a/CRM/Event/BAO/Participant.php
+++ b/CRM/Event/BAO/Participant.php
@@ -24,7 +24,7 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
@@ -40,7 +40,6 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* Static field for all the participant information that we can potentially import
*
* @var array
- * @static
*/
static $_importableFields = NULL;
@@ -48,7 +47,6 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* Static field for all the participant information that we can potentially export
*
* @var array
- * @static
*/
static $_exportableFields = NULL;
@@ -56,7 +54,6 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* Static array for valid status transitions rules
*
* @var array
- * @static
*/
static $_statusTransitionsRules = array(
'Pending from pay later' => array('Registered', 'Cancelled'),
@@ -68,7 +65,6 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
);
/**
- *
*/
public function __construct() {
parent::__construct();
@@ -81,10 +77,10 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* participant object. the params array could contain additional unused name/value
* pairs
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
- * @return CRM_Event_BAO_Participant object
- * @static
+ * @return CRM_Event_BAO_Participant
*/
public static function &add(&$params) {
@@ -110,10 +106,14 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
// ensure that role ids are encoded as a string
if (isset($params['role_id']) && is_array($params['role_id'])) {
+ if (in_array(key($params['role_id']), CRM_Core_DAO::acceptedSQLOperators())) {
+ $op = key($params['role_id']);
+ $params['role_id'] = $params['role_id'][$op];
+ }
$params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
}
- $participantBAO = new CRM_Event_BAO_Participant;
+ $participantBAO = new CRM_Event_BAO_Participant();
if (!empty($params['id'])) {
$participantBAO->id = CRM_Utils_Array::value('id', $params);
$participantBAO->find(TRUE);
@@ -157,13 +157,14 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
- * @param array $params input parameters to find object
- * @param array $values output values of the object
+ * @param array $params
+ * Input parameters to find object.
+ * @param array $values
+ * Output values of the object.
*
* @param $ids
*
* @return CRM_Event_BAO_Participant|null the found object or null
- * @static
*/
public static function getValues(&$params, &$values, &$ids) {
if (empty($params)) {
@@ -184,10 +185,10 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
/**
* Takes an associative array and creates a participant object
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
- * @return CRM_Event_BAO_Participant object
- * @static
+ * @return CRM_Event_BAO_Participant
*/
public static function create(&$params) {
@@ -239,7 +240,9 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
$noteValue = NULL;
$hasNoteField = FALSE;
foreach (array(
- 'note', 'participant_note') as $noteFld) {
+ 'note',
+ 'participant_note',
+ ) as $noteFld) {
if (array_key_exists($noteFld, $params)) {
$noteValue = $params[$noteFld];
$hasNoteField = TRUE;
@@ -335,17 +338,21 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
* Check whether the event is full for participation and return as
* per requirements.
*
- * @param int $eventId event id.
- * @param boolean $returnEmptySeats are we require number if empty seats.
- * @param boolean $includeWaitingList consider waiting list in event full
+ * @param int $eventId
+ * Event id.
+ * @param bool $returnEmptySeats
+ * Are we require number if empty seats.
+ * @param bool $includeWaitingList
+ * Consider waiting list in event full.
* calculation or not. (it is for cron job purpose)
*
* @param bool $returnWaitingCount
* @param bool $considerTestParticipant
*
- * @return bool|int|null|string 1. false => If event having some empty spaces.@static
+ * @return bool|int|null|string
+ * 1. false => If event having some empty spaces.
*/
- static function eventFull(
+ public static function eventFull(
$eventId,
$returnEmptySeats = FALSE,
$includeWaitingList = TRUE,
@@ -363,9 +370,9 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
// It might be case there are some empty spaces and still event
// is full, as waitlist might represent group require spaces > empty.
- $participantRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
- $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
- $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
+ $participantRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
+ $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
+ $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
$onWaitlistStatusId = array_search('On waitlist', $waitingStatuses);
//when we do require only waiting count don't consider counted.
@@ -387,8 +394,8 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
if ($includeWaitingList && $onWaitlistStatusId) {
//build the where clause.
- $whereClause = ' WHERE ' . implode(' AND ', $where);
- $whereClause .= " AND participant.status_id = $onWaitlistStatusId ";
+ $whereClause = ' WHERE ' . implode(' AND ', $where);
+ $whereClause .= " AND participant.status_id = $onWaitlistStatusId ";
$eventSeatsWhere = implode(' AND ', $where) . " AND ( participant.status_id = $onWaitlistStatusId )";
$query = "
@@ -412,8 +419,8 @@ INNER JOIN civicrm_event event ON ( event.id = participant.event_id )
}
//consider only counted participants.
- $where[] = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
- $whereClause = ' WHERE ' . implode(' AND ', $where);
+ $where[] = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
+ $whereClause = ' WHERE ' . implode(' AND ', $where);
$eventSeatsWhere = implode(' AND ', $where);
$query = "
@@ -426,7 +433,7 @@ INNER JOIN civicrm_event event ON ( event.id = participant.event_id )
$eventMaxSeats = NULL;
$eventFullText = ts('This event is full.');
- $participants = CRM_Core_DAO::executeQuery($query, $eventParams);
+ $participants = CRM_Core_DAO::executeQuery($query, $eventParams);
while ($participants->fetch()) {
if ($participants->event_full_text) {
$eventFullText = $participants->event_full_text;
@@ -478,16 +485,18 @@ SELECT event.event_full_text,
* Return the array of all price set field options,
* with total participant count that field going to carry.
*
- * @param int $eventId event id.
- * @param array $skipParticipantIds an array of participant ids those we should skip.
+ * @param int $eventId
+ * Event id.
+ * @param array $skipParticipantIds
+ * An array of participant ids those we should skip.
* @param bool $considerCounted
* @param bool $considerWaiting
* @param bool $considerTestParticipants
*
- * @return array $optionsCount an array of each option id and total count
- * @static
+ * @return array
+ * an array of each option id and total count
*/
- static function priceSetOptionsCount(
+ public static function priceSetOptionsCount(
$eventId,
$skipParticipantIds = array(),
$considerCounted = TRUE,
@@ -559,10 +568,11 @@ INNER JOIN civicrm_price_field field ON ( value.price_field_id = field.id
* Get the empty spaces for event those we can allocate
* to pending participant to become confirm.
*
- * @param int $eventId event id.
+ * @param int $eventId
+ * Event id.
*
- * @return int $spaces Number of Empty Seats/null.
- * @static
+ * @return int
+ * $spaces Number of Empty Seats/null.
*/
public static function pendingToConfirmSpaces($eventId) {
$emptySeats = 0;
@@ -610,8 +620,8 @@ GROUP BY participant.event_id
* @param bool $status
* @param bool $onlyParticipant
*
- * @return array array of importable Fields
- * @static
+ * @return array
+ * array of importable Fields
*/
public static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE) {
if (!self::$_importableFields) {
@@ -634,7 +644,8 @@ GROUP BY participant.event_id
'title' => ts('Participant Note'),
'name' => 'participant_note',
'headerPattern' => '/(participant.)?note$/i',
- ));
+ ),
+ );
// Split status and status id into 2 fields
// Fixme: it would be better to leave as 1 field and intelligently handle both during import
@@ -643,7 +654,8 @@ GROUP BY participant.event_id
'title' => ts('Participant Status'),
'name' => 'participant_status',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpFields['participant_status_id']['title'] = ts('Participant Status Id');
// Split role and role id into 2 fields
@@ -653,7 +665,8 @@ GROUP BY participant.event_id
'title' => ts('Participant Role'),
'name' => 'participant_role',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpFields['participant_role_id']['title'] = ts('Participant Role Id');
$eventType = array(
@@ -661,17 +674,18 @@ GROUP BY participant.event_id
'title' => ts('Event Type'),
'name' => 'event_type',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpContactField = $contactFields = array();
- $contactFields = array( );
+ $contactFields = array();
if (!$onlyParticipant) {
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
$ruleParams = array(
'contact_type' => $contactType,
- 'used' => 'Unsupervised',
+ 'used' => 'Unsupervised',
);
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
@@ -698,11 +712,9 @@ GROUP BY participant.event_id
$extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
if ($extIdentifier) {
$tmpContactField['external_identifier'] = $extIdentifier;
- $tmpContactField['external_identifier']['title'] =
- CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
+ $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
}
- $tmpFields['participant_contact_id']['title'] =
- $tmpFields['participant_contact_id']['title'] . ' (match to contact)';
+ $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)';
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
@@ -718,8 +730,8 @@ GROUP BY participant.event_id
/**
* Combine all the exportable fields from the lower levels object
*
- * @return array array of exportable Fields
- * @static
+ * @return array
+ * array of exportable Fields
*/
public static function &exportableFields() {
if (!self::$_exportableFields) {
@@ -730,34 +742,34 @@ GROUP BY participant.event_id
$fields = array();
$participantFields = CRM_Event_DAO_Participant::export();
+ $eventFields = CRM_Event_DAO_Event::export();
$noteField = array(
- 'participant_note' => array('title' => 'Participant Note',
+ 'participant_note' => array(
+ 'title' => 'Participant Note',
'name' => 'participant_note',
- ));
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
+ );
$participantStatus = array(
- 'participant_status' => array('title' => 'Participant Status',
+ 'participant_status' => array(
+ 'title' => 'Participant Status',
'name' => 'participant_status',
- ));
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
+ );
$participantRole = array(
- 'participant_role' => array('title' => 'Participant Role',
+ 'participant_role' => array(
+ 'title' => 'Participant Role',
'name' => 'participant_role',
- ));
-
- //CRM-13595 add event id to participant export
- $eventid = array(
- 'event_id' => array('title' => 'Event ID',
- 'name' => 'event_id',
- ));
- $eventtitle = array(
- 'event_title' => array('title' => 'Event Title',
- 'name' => 'event_title',
- ));
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
+ );
- $discountFields = CRM_Core_DAO_Discount::export();
+ $discountFields = CRM_Core_DAO_Discount::export();
- $fields = array_merge($participantFields, $participantStatus, $participantRole, $eventid, $eventtitle, $noteField, $discountFields);
+ $fields = array_merge($participantFields, $participantStatus, $participantRole, $eventFields, $noteField, $discountFields);
// add custom data
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant'));
@@ -770,11 +782,11 @@ GROUP BY participant.event_id
/**
* Get the event name/sort name for a particular participation / participant
*
- * @param int $participantId id of the participant
-
+ * @param int $participantId
+ * Id of the participant.
*
- * @return array $name associated array with sort_name and event title
- * @static
+ * @return array
+ * associated array with sort_name and event title
*/
public static function participantDetails($participantId) {
$query = "
@@ -788,9 +800,9 @@ WHERE civicrm_participant.id = {$participantId}
$details = array();
while ($dao->fetch()) {
- $details['name'] = $dao->name;
+ $details['name'] = $dao->name;
$details['title'] = $dao->title;
- $details['cid'] = $dao->cid;
+ $details['cid'] = $dao->cid;
}
return $details;
@@ -799,11 +811,12 @@ WHERE civicrm_participant.id = {$participantId}
/**
* Get the values for pseudoconstants for name->value and reverse.
*
- * @param array $defaults (reference) the default values, some of which need to be resolved.
- * @param boolean $reverse true if we want to resolve the values in the reverse direction (value -> name)
+ * @param array $defaults
+ * (reference) the default values, some of which need to be resolved.
+ * @param bool $reverse
+ * True if we want to resolve the values in the reverse direction (value -> name).
*
* @return void
- * @static
*/
public static function resolveDefaults(&$defaults, $reverse = FALSE) {
self::lookupValue($defaults, 'event', CRM_Event_PseudoConstant::event(), $reverse);
@@ -812,7 +825,7 @@ WHERE civicrm_participant.id = {$participantId}
}
/**
- * This function is used to convert associative array names to values
+ * convert associative array names to values
* and vice-versa.
*
* This function is used by both the web form layer and the api. Note that
@@ -843,10 +856,10 @@ WHERE civicrm_participant.id = {$participantId}
/**
* Delete the record that are associated with this participation
*
- * @param int $id id of the participation to delete
+ * @param int $id
+ * Id of the participation to delete.
*
* @return void
- * @static
*/
public static function deleteParticipant($id) {
CRM_Utils_Hook::pre('delete', 'Participant', $id, CRM_Core_DAO::$_nullArray);
@@ -869,8 +882,8 @@ WHERE civicrm_participant.id = {$participantId}
CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
// cleanup line items.
- $participantsId = array();
- $participantsId = self::getAdditionalParticipantIds($id);
+ $participantsId = array();
+ $participantsId = self::getAdditionalParticipantIds($id);
$participantsId[] = $id;
CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
@@ -903,12 +916,13 @@ WHERE civicrm_participant.id = {$participantId}
/**
* Checks duplicate participants
*
- * @param array $duplicates (reference ) an assoc array of name/value pairs
- * @param array $input an assosiative array of name /value pairs
- * from other function
+ * @param array $input
+ * An assosiative array of name /value pairs.
+ * from other function
+ * @param array $duplicates
+ * (reference ) an assoc array of name/value pairs.
*
- * @return CRM_Contribute_BAO_Contribution object
- * @static
+ * @return CRM_Contribute_BAO_Contribution
*/
public static function checkDuplicate($input, &$duplicates) {
$eventId = CRM_Utils_Array::value('event_id', $input);
@@ -933,8 +947,8 @@ WHERE civicrm_participant.id = {$participantId}
$clause = implode(' AND ', $clause);
- $query = "SELECT id FROM civicrm_participant WHERE $clause";
- $dao = CRM_Core_DAO::executeQuery($query, $input);
+ $query = "SELECT id FROM civicrm_participant WHERE $clause";
+ $dao = CRM_Core_DAO::executeQuery($query, $input);
$result = FALSE;
while ($dao->fetch()) {
$duplicates[] = $dao->id;
@@ -950,9 +964,9 @@ WHERE civicrm_participant.id = {$participantId}
* separated string. We need to change that string to comma
* separated string before using fee_level in view mode.
*
- * @param string $eventLevel event_leval string from db
+ * @param string $eventLevel
+ * Event_leval string from db.
*
- * @static
*
* @return void
*/
@@ -968,26 +982,27 @@ WHERE civicrm_participant.id = {$participantId}
}
elseif ((substr($eventLevel, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
$eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($eventLevel, 0, 1)
- ));
+ substr($eventLevel, 0, 1)
+ ));
}
elseif ((substr($eventLevel, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
$eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($eventLevel, 0, -1)
- ));
+ substr($eventLevel, 0, -1)
+ ));
}
}
/**
* Get the additional participant ids.
*
- * @param int $primaryParticipantId primary partycipant Id
- * @param boolean $excludeCancel do not include participant those are cancelled.
+ * @param int $primaryParticipantId
+ * Primary partycipant Id.
+ * @param bool $excludeCancel
+ * Do not include participant those are cancelled.
*
* @param int $oldStatusId
*
- * @return array $additionalParticipantIds
- * @static
+ * @return array
*/
public static function getAdditionalParticipantIds($primaryParticipantId, $excludeCancel = TRUE, $oldStatusId = NULL) {
$additionalParticipantIds = array();
@@ -997,9 +1012,9 @@ WHERE civicrm_participant.id = {$participantId}
$where = "participant.registered_by_id={$primaryParticipantId}";
if ($excludeCancel) {
- $cancelStatusId = 0;
+ $cancelStatusId = 0;
$negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
- $cancelStatusId = array_search('Cancelled', $negativeStatuses);
+ $cancelStatusId = array_search('Cancelled', $negativeStatuses);
$where .= " AND participant.status_id != {$cancelStatusId}";
}
@@ -1023,11 +1038,12 @@ WHERE civicrm_participant.id = {$participantId}
* Get the event fee info for given participant ids
* either from line item table / participant table.
*
- * @param array $participantIds participant ids.
- * @param boolean $hasLineItems do fetch from line items.
+ * @param array $participantIds
+ * Participant ids.
+ * @param bool $hasLineItems
+ * Do fetch from line items.
*
- * @return array $feeDetails
- * @static
+ * @return array
*/
public function getFeeDetails($participantIds, $hasLineItems = FALSE) {
$feeDetails = array();
@@ -1063,12 +1079,20 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
$where = 'WHERE participant.id IN ( ' . implode(', ', $participantIds) . ' )';
$query = "$select $from $where";
- $feeInfo = CRM_Core_DAO::executeQuery($query);
- $feeProperties = array('fee_level', 'fee_amount');
+ $feeInfo = CRM_Core_DAO::executeQuery($query);
+ $feeProperties = array('fee_level', 'fee_amount');
$lineProperties = array(
- 'lineId', 'label', 'qty', 'unit_price',
- 'line_total', 'field_title', 'html_type',
- 'price_field_id', 'participant_count', 'price_field_value_id', 'description',
+ 'lineId',
+ 'label',
+ 'qty',
+ 'unit_price',
+ 'line_total',
+ 'field_title',
+ 'html_type',
+ 'price_field_id',
+ 'participant_count',
+ 'price_field_value_id',
+ 'description',
);
while ($feeInfo->fetch()) {
if ($hasLineItems) {
@@ -1077,7 +1101,9 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
}
}
else {
- foreach ($feeProperties as $property) $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
+ foreach ($feeProperties as $property) {
+ $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
+ }
}
}
@@ -1088,10 +1114,11 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
* Retrieve additional participants display-names and URL to view their participant records.
* (excludes cancelled participants automatically)
*
- * @param int $primaryParticipantID id of primary participant record
+ * @param int $primaryParticipantID
+ * Id of primary participant record.
*
- * @return array $additionalParticipants $displayName => $viewUrl
- * @static
+ * @return array
+ * $displayName => $viewUrl
*/
public static function getAdditionalParticipants($primaryParticipantID) {
$additionalParticipantIDs = array();
@@ -1116,17 +1143,17 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
/**
* Function for update primary and additional participant status
*
- * @param int $participantID primary participant's id
+ * @param int $participantID
+ * Primary participant's id.
* @param int $oldStatusID
* @param int $newStatusID
* @param bool $updatePrimaryStatus
*
- * @return bool|void
- * @static
+ * @return bool|NULL
*/
public static function updateParticipantStatus($participantID, $oldStatusID, $newStatusID = NULL, $updatePrimaryStatus = FALSE) {
if (!$participantID || !$oldStatusID) {
- return;
+ return NULL;
}
if (!$newStatusID) {
@@ -1151,13 +1178,14 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
/**
* Function for update status for given participant ids
*
- * @param int $participantIds array of participant ids
- * @param int $statusId status id for participant
+ * @param int $participantIds
+ * Array of participant ids.
+ * @param int $statusId
+ * Status id for participant.
* @param bool $updateRegisterDate
*
* @return void
*
- * @static
*/
public static function updateStatus($participantIds, $statusId, $updateRegisterDate = FALSE) {
if (!is_array($participantIds) || empty($participantIds) || !$statusId) {
@@ -1187,22 +1215,23 @@ UPDATE civicrm_participant
* update status from $fromStatusId to $toStatusId
* and send mail + create activities.
*
- * @param array $participantIds participant ids.
- * @param int $toStatusId update status id.
- * @param int $fromStatusId from status id
- *
- * return void
+ * @param array $participantIds
+ * Participant ids.
+ * @param int $toStatusId
+ * Update status id.
+ * @param int $fromStatusId
+ * From status id.
* @param bool $returnResult
* @param bool $skipCascadeRule
*
- * @return array
- * @static
+ * @return array|NULL
*/
- static function transitionParticipants($participantIds, $toStatusId,
+ public static function transitionParticipants(
+ $participantIds, $toStatusId,
$fromStatusId = NULL, $returnResult = FALSE, $skipCascadeRule = FALSE
) {
if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) {
- return;
+ return NULL;
}
//thumb rule is if we triggering primary participant need to triggered additional
@@ -1234,9 +1263,9 @@ UPDATE civicrm_participant
$contactIds = $eventIds = $participantDetails = array();
- $statusTypes = CRM_Event_PseudoConstant::participantStatus();
+ $statusTypes = CRM_Event_PseudoConstant::participantStatus();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
- $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL,
+ $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL,
"class = 'Pending'"
);
@@ -1271,7 +1300,8 @@ UPDATE civicrm_participant
if (empty($domainValues)) {
// making all tokens available to templates.
$domain = CRM_Core_BAO_Domain::getDomain();
- $tokens = array('domain' => array('name', 'phone', 'address', 'email'),
+ $tokens = array(
+ 'domain' => array('name', 'phone', 'address', 'email'),
'contact' => CRM_Core_SelectValues::contactTokens(),
);
@@ -1312,8 +1342,8 @@ UPDATE civicrm_participant
//now we are ready w/ all required data.
//take a decision as per statuses.
- $emailType = NULL;
- $toStatus = $statusTypes[$toStatusId];
+ $emailType = NULL;
+ $toStatus = $statusTypes[$toStatusId];
$fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes);
switch ($toStatus) {
@@ -1417,19 +1447,22 @@ UPDATE civicrm_participant
* Send mail and create activity
* when participant status changed.
*
- * @param int $participantId participant id.
- * @param array $participantValues participant detail values. status id for participants
- * @param array $eventDetails required event details
- * @param array $contactDetails required contact details
- * @param array $domainValues required domain values.
- * @param string $mailType (eg 'approval', 'confirm', 'expired' )
- *
- * return void
+ * @param int $participantId
+ * Participant id.
+ * @param array $participantValues
+ * Participant detail values. status id for participants.
+ * @param array $eventDetails
+ * Required event details.
+ * @param array $contactDetails
+ * Required contact details.
+ * @param array $domainValues
+ * Required domain values.
+ * @param string $mailType
+ * (eg 'approval', 'confirm', 'expired' ).
*
* @return bool
- * @static
*/
- static function sendTransitionParticipantMail(
+ public static function sendTransitionParticipantMail(
$participantId,
$participantValues,
$eventDetails,
@@ -1497,8 +1530,8 @@ UPDATE civicrm_participant
// 3. create activity record.
if ($mailSent) {
- $now = date('YmdHis');
- $activityType = 'Event Registration';
+ $now = date('YmdHis');
+ $activityType = 'Event Registration';
$activityParams = array(
'subject' => $subject,
'source_contact_id' => $contactId,
@@ -1546,11 +1579,11 @@ UPDATE civicrm_participant
array_key_exists($processedId, $results['mailedParticipants'])
) {
$statusMsg .= '
' . ts("Participant status has been updated to '%1'. An email has been sent to %2.",
- array(
- 1 => $allStatuses[$statusChangeTo],
- 2 => $results['mailedParticipants'][$processedId],
- )
- );
+ array(
+ 1 => $allStatuses[$statusChangeTo],
+ 2 => $results['mailedParticipants'][$processedId],
+ )
+ );
}
}
}
@@ -1588,7 +1621,8 @@ UPDATE civicrm_participant
if (is_string($emptySeats) && $emptySeats !== NULL) {
$maxParticipants = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'max_participants');
$eventfullMsg = ts("This event currently has the maximum number of participants registered (%1). However, you can still override this limit and register additional participants using this form.", array(
- 1 => $maxParticipants)) . '
';
+ 1 => $maxParticipants,
+ )) . '
';
}
$hasWaiting = FALSE;
@@ -1625,7 +1659,8 @@ UPDATE civicrm_participant
*
* @param int $participantId
*
- * @return true if participant is primary
+ * @return bool
+ * true if participant is primary
*/
public static function isPrimaryParticipant($participantId) {
@@ -1641,11 +1676,15 @@ UPDATE civicrm_participant
/**
* Get additional participant Ids for cascading with primary participant status
*
- * @param int $participantId participant id.
- * @param int $oldStatusId previous status
- * @param int $newStatusId new status
+ * @param int $participantId
+ * Participant id.
+ * @param int $oldStatusId
+ * Previous status.
+ * @param int $newStatusId
+ * New status.
*
- * @return true if allowed
+ * @return bool
+ * true if allowed
*/
public static function getValidAdditionalIds($participantId, $oldStatusId, $newStatusId) {
@@ -1671,8 +1710,8 @@ UPDATE civicrm_participant
*
* @param int $contactID
*
- * @return int count of participant records
- * @static
+ * @return int
+ * count of participant records
*/
public static function getContactParticipantCount($contactID) {
$query = "SELECT count(*)
@@ -1685,11 +1724,12 @@ WHERE civicrm_participant.contact_id = {$contactID} AND
/**
* Get participant ids by contribution id
*
- * @param int $contributionId Contribution Id
- * @param bool $excludeCancelled Exclude cancelled additional participant
+ * @param int $contributionId
+ * Contribution Id.
+ * @param bool $excludeCancelled
+ * Exclude cancelled additional participant.
*
- * @return array $participantsId
- * @static
+ * @return array
*/
public static function getParticipantIds($contributionId, $excludeCancelled = FALSE) {
@@ -1705,9 +1745,10 @@ WHERE civicrm_participant.contact_id = {$contactID} AND
// get additional participant ids (including cancelled)
if ($participantId) {
$ids = array_merge(array(
- $participantId), self::getAdditionalParticipantIds($participantId,
- $excludeCancelled
- ));
+ $participantId,
+ ), self::getAdditionalParticipantIds($participantId,
+ $excludeCancelled
+ ));
}
return $ids;
@@ -1716,14 +1757,15 @@ WHERE civicrm_participant.contact_id = {$contactID} AND
/**
* Get additional Participant edit & view url .
*
- * @param array $participantIds an array of additional participant ids.
+ * @param array $participantIds
+ * An array of additional participant ids.
*
- * @return array of Urls.
- * @static
+ * @return array
+ * Array of Urls.
*/
public static function getAdditionalParticipantUrl($participantIds) {
foreach ($participantIds as $value) {
- $links = array();
+ $links = array();
$details = self::participantDetails($value);
$viewUrl = CRM_Utils_System::url('civicrm/contact/view/participant',
"action=view&reset=1&id={$value}&cid={$details['cid']}"
@@ -1738,40 +1780,45 @@ WHERE civicrm_participant.contact_id = {$contactID} AND
}
/**
- * To create trxn entry if an event has discount.
+ * create trxn entry if an event has discount.
*
- * @param int $eventID event id
- * @param array $contributionParams contribution params.
+ * @param int $eventID
+ * Event id.
+ * @param array $contributionParams
+ * Contribution params.
*
* @param $feeLevel
*
- * @static
*/
public static function createDiscountTrxn($eventID, $contributionParams, $feeLevel) {
// CRM-11124
- $checkDiscount = CRM_Core_BAO_Discount::findSet($eventID,'civicrm_event');
+ $checkDiscount = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (!empty($checkDiscount)) {
$feeLevel = current($feeLevel);
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL);
$query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv
LEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id
WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
- $params = array(1 => array($priceSetId, 'Integer'),
- 2 => array($feeLevel, 'String'));
+ $params = array(
+ 1 => array($priceSetId, 'Integer'),
+ 2 => array($feeLevel, 'String'),
+ );
$mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
$contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType(
$contributionParams['contribution']->financial_type_id, $relationTypeId);
if (!empty($contributionParams['trxnParams']['from_financial_account_id'])) {
$contributionParams['trxnParams']['total_amount'] = $mainAmount - $contributionParams['total_amount'];
- $contributionParams['trxnParams']['payment_processor_id'] = $contributionParams['trxnParams']['payment_instrument_id'] =
- $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] =
- $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
+ $contributionParams['trxnParams']['payment_processor_id'] = NULL;
+ $contributionParams['trxnParams']['payment_instrument_id'] = NULL;
+ $contributionParams['trxnParams']['check_number'] = NULL;
+ $contributionParams['trxnParams']['trxn_id'] = NULL;
+ $contributionParams['trxnParams']['net_amount'] = NULL;
+ $contributionParams['trxnParams']['fee_amount'] = NULL;
CRM_Core_BAO_FinancialTrxn::create($contributionParams['trxnParams']);
}
}
- return;
}
/**
@@ -1779,9 +1826,9 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
*
* CRM-12155
*
- * @param integer $contactId contact id
+ * @param int $contactId
+ * Contact id.
*
- * @static
*/
public static function deleteContactParticipant($contactId) {
$participant = new CRM_Event_DAO_Participant();
@@ -1828,7 +1875,8 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
unset($insertLines[$previousLineItem['price_field_value_id']]);
// for updating the line items i.e. use-case - once deselect-option selecting again
if (($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']) ||
- ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)) {
+ ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)
+ ) {
$updateLines[$previousLineItem['price_field_value_id']] = $submittedLineItems[$previousLineItem['price_field_value_id']];
$updateLines[$previousLineItem['price_field_value_id']]['id'] = $id;
}
@@ -1873,11 +1921,11 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
// if not submitted and difference is not 0 make it negative
if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
// INSERT negative financial_items
- $updateFinancialItemInfoValues['amount'] = - $updateFinancialItemInfoValues['amount'];
+ $updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
// INSERT negative financial_items for tax amount
if ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']) {
- $updateFinancialItemInfoValues['amount'] = - ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
+ $updateFinancialItemInfoValues['amount'] = -($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
$updateFinancialItemInfoValues['description'] = $taxTerm;
if ($updateFinancialItemInfoValues['financial_type_id']) {
$updateFinancialItemInfoValues['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
@@ -1903,7 +1951,7 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
}
}
}
- elseif (empty($submittedFields) && empty($submittedFieldValues)){
+ elseif (empty($submittedFields) && empty($submittedFieldValues)) {
$updateLineItem = "UPDATE civicrm_line_item li
INNER JOIN civicrm_financial_item fi
ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')
@@ -1987,8 +2035,8 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
$partUpdateFeeAmt['id'] = $participantId;
foreach ($lineItems as $lineValue) {
if ($lineValue['price_field_value_id']) {
- $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - '. $lineValue['qty'];
- }
+ $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - ' . $lineValue['qty'];
+ }
}
$partUpdateFeeAmt['fee_level'] = implode(', ', $line);
@@ -2039,8 +2087,11 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
$ftDetail = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
// adjusted amount financial_trxn creation
if (empty($ftDetail['trxn_id'])) {
- $updatedContribution =
- CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
+ $updatedContribution = CRM_Contribute_BAO_Contribution::getValues(
+ array('id' => $contributionId),
+ CRM_Core_DAO::$_nullArray,
+ CRM_Core_DAO::$_nullArray
+ );
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
@@ -2052,7 +2103,7 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
'payment_instrument_id' => $updatedContribution->payment_instrument_id,
'contribution_id' => $updatedContribution->id,
'trxn_date' => date('YmdHis'),
- 'currency' => $updatedContribution->currency
+ 'currency' => $updatedContribution->currency,
);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
}
@@ -2113,11 +2164,13 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
* Get options for a given field.
* @see CRM_Core_DAO::buildOptions
*
- * @param String $fieldName
- * @param String $context : @see CRM_Core_DAO::buildOptionsContext
- * @param Array $props : whatever is known about this dao object
+ * @param string $fieldName
+ * @param string $context
+ * @see CRM_Core_DAO::buildOptionsContext
+ * @param array $props
+ * whatever is known about this dao object.
*
- * @return Array|bool
+ * @return array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
$params = array('condition' => array());
@@ -2132,4 +2185,5 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
+
}