<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
/**
- * class constructor
+ * Class constructor
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * contact_id. We'll tweak this function to be more full featured over a period
- * of time. This is the inverse function of create. It also stores all the retrieved
- * values in the default array
+ * Fetch object based on array of properties
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $defaults (reference ) an assoc array to hold the flattened values
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
*
- * @return object CRM_Event_BAO_ManageEvent object
- * @access public
+ * @return CRM_Event_BAO_ManageEvent
* @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$event = new CRM_Event_DAO_Event();
$event->copyValues($params);
if ($event->find(TRUE)) {
}
/**
- * update the is_active flag in the db
+ * Update the is_active flag in the db
*
- * @param int $id id of the database record
- * @param boolean $is_active value we want to set the is_active field
+ * @param int $id
+ * Id of the database record.
+ * @param bool $is_active
+ * Value we want to set the is_active field.
*
- * @return Object DAO object on sucess, null otherwise
+ * @return Object
+ * DAO object on sucess, null otherwise
* @static
*/
- static function setIsActive($id, $is_active) {
+ public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $id, 'is_active', $is_active);
}
/**
- * function to add the event
+ * Add the event
*
- * @param array $params reference array contains the values submitted by the form
+ * @param array $params
+ * Reference array contains the values submitted by the form.
*
- * @access public
* @static
*
* @return object
*/
- static function add(&$params) {
+ public static function add(&$params) {
CRM_Utils_System::flushCache();
$financialTypeId = NULL;
if (!empty($params['id'])) {
}
/**
- * function to create the event
+ * Create the event
*
- * @param array $params reference array contains the values submitted by the form
+ * @param array $params
+ * Reference array contains the values submitted by the form.
*
* @return object
- * @access public
* @static
- *
*/
public static function create(&$params) {
$transaction = new CRM_Core_Transaction();
}
/**
- * Function to delete the event
+ * Delete the event
*
- * @param int $id event id
+ * @param int $id
+ * Event id.
*
* @return mixed|null
- * @access public
* @static
- *
*/
- static function del($id) {
+ public static function del($id) {
if (!$id) {
return NULL;
}
foreach ($groupTree as $values) {
$query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
- $params = array(1 => array($values['table_name'], 'string'),
+ $params = array(
+ 1 => array($values['table_name'], 'string'),
2 => array($id, 'integer'),
);
}
/**
- * Function to delete the location block associated with an event,
+ * Delete the location block associated with an event,
* if not being used by any other event.
*
* @param $locBlockId
- * @param null $eventId
- *
- * @internal param int $loc_block_id location block id to be deleted
- * @internal param int $eventid event id with which loc block is associated
+ * Location block id to be deleted.
+ * @param int $eventId
+ * Event with which loc block is associated.
*
- * @access public
* @static
*/
- static function deleteEventLocBlock($locBlockId, $eventId = NULL) {
+ public static function deleteEventLocBlock($locBlockId, $eventId = NULL) {
$query = "SELECT count(ce.id) FROM civicrm_event ce WHERE ce.loc_block_id = $locBlockId";
if ($eventId) {
}
/**
- * Function to get current/future Events
+ * Get current/future Events
*
- * @param $all int 0 returns current and future events
+ * @param int $all
+ * 0 returns current and future events.
* 1 if events all are required
* 2 returns events since 3 months ago
- * @param bool|int $id int id of a specific event to return
- * @param $isActive boolean true if you need only active events
- * @param $checkPermission boolean true if you need to check permission else false
+ * @param bool|int $id int id of a specific event to return
+ * @param bool $isActive
+ * true if you need only active events.
+ * @param bool $checkPermission
+ * true if you need to check permission else false.
*
* @return array
* @static
*/
- static function getEvents($all = 0,
- $id = FALSE,
- $isActive = TRUE,
+ static function getEvents(
+ $all = 0,
+ $id = FALSE,
+ $isActive = TRUE,
$checkPermission = TRUE
) {
$query = "
}
/**
- * Function to get events Summary
+ * Get events Summary
*
* @static
*
- * @return array Array of event summary values
+ * @return array
+ * Array of event summary values
*/
- static function getEventSummary() {
+ public static function getEventSummary() {
$eventSummary = $eventIds = array();
$config = CRM_Core_Config::singleton();
}
// Get the event summary display preferences
$show_max_events = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
- 'show_events'
+ 'show_events'
);
// default to 10 if no option is set
if (is_null($show_max_events)) {
$statusCount = self::eventTotalSeats($dao->id, "( participant.status_id = {$statusId} )");
if ($statusCount) {
$urlString = "reset=1&force=1&event={$dao->id}&status=$statusId";
- $statusInfo = array('url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
+ $statusInfo = array(
+ 'url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
'name' => $statusValue['name'],
'label' => $statusValue['label'],
'count' => $statusCount,
}
/**
- * Function to get participant count
- *
- * @param $eventId
- * @param boolean $considerStatus consider status for participant count.
- * @param boolean $status consider counted participant.
- * @param boolean $considerRole consider role for participant count.
- * @param boolean $role consider counted( is filter role) participant.
+ * Get participant count
*
- * @internal param array $eventIds consider participants from given events.
- * @internal param bool $countWithStatus retrieve participant count w/ each participant status.
+ * @param int $eventId
+ * @param bool $considerStatusConsider status for participant count.
+ * Consider status for participant count.
+ * @param bool $statusConsider counted participant.
+ * Consider counted participant.
+ * @param bool $considerRoleConsider role for participant count.
+ * Consider role for participant count.
+ * @param bool $roleConsider counted( is filter role) participant.
+ * Consider counted( is filter role) participant.
*
- * @access public
*
- * @return array array with count of participants for each event based on status/role
+ * @return array
+ * array with count of participants for each event based on status/role
*/
- public static function getParticipantCount($eventId,
+ public static function getParticipantCount(
+ $eventId,
$considerStatus = TRUE,
- $status = TRUE,
- $considerRole = TRUE,
- $role = TRUE
+ $status = TRUE,
+ $considerRole = TRUE,
+ $role = TRUE
) {
// consider both role and status for counted participants, CRM-4924.
}
/**
- * function to get the information to map a event
+ * Get the information to map a event
*
- * @param $id
+ * @param int $id
+ * For which we want map info.
*
- * @internal param array $ids the list of ids for which we want map info
- *
- * @return null|string title of the event
+ * @return null|string
+ * title of the event
* @static
- * @access public
*/
- static function &getMapInfo(&$id) {
+ public static function &getMapInfo(&$id) {
$sql = "
SELECT
$params = array('entity_id' => $id, 'entity_table' => 'civicrm_event');
$addressValues = CRM_Core_BAO_Location::getValues($params, TRUE);
- $location['address'] = str_replace(array("\r", "\n"), '', addslashes(nl2br($addressValues['address'][1]['display_text'])));
+ $location['address'] = str_replace(array(
+ "\r",
+ "\n",
+ ), '', addslashes(nl2br($addressValues['address'][1]['display_text'])));
$location['url'] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id);
$location['location_type'] = $dao->location_type;
}
/**
- * function to get the complete information for one or more events
- *
- * @param date $start get events with start date >= this date
- * @param integer $type get events on the a specific event type (by event_type_id)
- * @param integer $eventId return a single event - by event id
- * @param date $end also get events with end date >= this date
- * @param boolean $onlyPublic include public events only, default TRUE
+ * Get the complete information for one or more events
+ *
+ * @param date $start
+ * Get events with start date >= this date.
+ * @param int $typeGet events on the a specific event type (by event_type_id).
+ * Get events on the a specific event type (by event_type_id).
+ * @param int $eventIdReturn a single event - by event id.
+ * Return a single event - by event id.
+ * @param date $end
+ * Also get events with end date >= this date.
+ * @param bool $onlyPublicInclude public events only, default TRUE.
+ * Include public events only, default TRUE.
*
- * @return array $all array of all the events that are searched
+ * @return array
+ * array of all the events that are searched
* @static
- * @access public
*/
static function &getCompleteInfo(
$start = NULL,
}
$query .= " ORDER BY civicrm_event.start_date ASC";
-
$params = array(1 => array($optionGroupId, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $all = array();
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
+ $all = array();
$config = CRM_Core_Config::singleton();
$baseURL = parse_url($config->userFrameworkBaseURL);
$enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
'enable_cart'
);
- if ($enable_cart) {}
+ if ($enable_cart) {
+ }
while ($dao->fetch()) {
if (!empty($permissions) && in_array($dao->event_id, $permissions)) {
$info = array();
}
/**
- * This function is to make a copy of a Event, including
+ * make a copy of a Event, including
* all the fields in the event Wizard
*
- * @param int $id the event id to copy
- * obj $newEvent object of CRM_Event_DAO_Event
+ * @param int $id
+ * The event id to copy.
* boolean $afterCreate call to copy after the create function
* @param null $newEvent
* @param bool $afterCreate
*
- * @return void
- * @access public
+ * @return CRM_Event_DAO_Event
*/
- static function copy($id, $newEvent = NULL, $afterCreate = FALSE) {
+ public static function copy($id, $newEvent = NULL, $afterCreate = FALSE) {
- $defaults = $eventValues = array();
+ $eventValues = array();
//get the require event values.
$eventParams = array('id' => $id);
- $returnProperties = array('loc_block_id', 'is_show_location', 'default_fee_id', 'default_discount_fee_id', 'is_template');
+ $returnProperties = array(
+ 'loc_block_id',
+ 'is_show_location',
+ 'default_fee_id',
+ 'default_discount_fee_id',
+ 'is_template',
+ );
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $eventParams, $eventValues, $returnProperties);
// since the location is sharable, lets use the same loc_block_id.
$locBlockId = CRM_Utils_Array::value('loc_block_id', $eventValues);
- $fieldsFix = ($afterCreate) ? array( ) : array('prefix' => array('title' => ts('Copy of') . ' '));
+ $fieldsFix = ($afterCreate) ? array() : array('prefix' => array('title' => ts('Copy of') . ' '));
if (empty($eventValues['is_show_location'])) {
$fieldsFix['prefix']['is_show_location'] = 0;
}
if (!isset($copyEvent)) {
$copyEvent = &CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event',
array('id' => $id),
- array(
- 'loc_block_id' =>
+ array(
+ 'loc_block_id' =>
($locBlockId) ? $locBlockId : NULL,
- ),
- $fieldsFix
- );
+ ),
+ $fieldsFix
+ );
}
CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id);
$copyUF = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin',
}
foreach ($table as $tableName => $tableColumns) {
- $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
+ $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
$tableColumns[0] = $copyEvent->id;
- $select = 'SELECT ' . implode(', ', $tableColumns);
- $from = ' FROM ' . $tableName;
- $where = " WHERE {$tableName}.entity_id = {$id}";
- $query = $insert . $select . $from . $where;
- $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
+ $select = 'SELECT ' . implode(', ', $tableColumns);
+ $from = ' FROM ' . $tableName;
+ $where = " WHERE {$tableName}.entity_id = {$id}";
+ $query = $insert . $select . $from . $where;
+ $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
}
}
* This is sometimes called in a loop (during event search)
* hence we cache the values to prevent repeated calls to the db
*/
- static function isMonetary($id) {
+ public static function isMonetary($id) {
static $isMonetary = array();
if (!array_key_exists($id, $isMonetary)) {
$isMonetary[$id] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
* This is sometimes called in a loop (during event search)
* hence we cache the values to prevent repeated calls to the db
*/
- static function usesPriceSet($id) {
+ public static function usesPriceSet($id) {
static $usesPriceSet = array();
if (!array_key_exists($id, $usesPriceSet)) {
$usesPriceSet[$id] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
/**
* Process that send e-mails
*
- * @param $contactID
+ * @param int $contactID
* @param $values
- * @param $participantId
+ * @param int $participantId
* @param bool $isTest
* @param bool $returnMessageText
*
* @return void
- * @access public
*/
- static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) {
+ public static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) {
$template = CRM_Core_Smarty::singleton();
$gIds = array(
foreach ($gIds as $key => $gIdValues) {
if ($gIdValues) {
if (!is_array($gIdValues)) {
- $gIdValues = array( $gIdValues );
+ $gIdValues = array($gIdValues);
}
foreach ($gIdValues as $gId) {
- $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
- if ($email) {
- //get values of corresponding profile fields for notification
- list($profileValues) = self::buildCustomDisplay($gId,
- NULL,
- $contactID,
- $template,
- $participantId,
- $isTest,
- TRUE,
- $participantParams
- );
- list($profileValues) = $profileValues;
- $val = array(
- 'id' => $gId,
- 'values' => $profileValues,
- 'email' => $email,
- );
- CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
+ $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
+ if ($email) {
+ //get values of corresponding profile fields for notification
+ list($profileValues) = self::buildCustomDisplay($gId,
+ NULL,
+ $contactID,
+ $template,
+ $participantId,
+ $isTest,
+ TRUE,
+ $participantParams
+ );
+ list($profileValues) = $profileValues;
+ $val = array(
+ 'id' => $gId,
+ 'values' => $profileValues,
+ 'email' => $email,
+ );
+ CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
+ }
}
}
}
}
- }
if ($values['event']['is_email_confirm'] || $returnMessageText) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
$postProfileID = CRM_Utils_Array::value('custom_post_id', $values);
if (!empty($values['params']['additionalParticipant'])) {
- $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID );
- $postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID );
+ $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID);
+ $postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID);
}
self::buildCustomDisplay($preProfileID,
$sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);
$tplParams = array_merge($values, $participantParams, array(
- 'email' => $email,
- 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']),
- 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']),
- 'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars),
- 'participantID' => $participantId,
- 'conference_sessions' => $sessions,
- 'credit_card_number' =>
- CRM_Utils_System::mungeCreditCard(
- CRM_Utils_Array::value('credit_card_number', $participantParams)),
- 'credit_card_exp_date' =>
- CRM_Utils_Date::mysqlToIso(
- CRM_Utils_Date::format(
- CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
- ));
+ 'email' => $email,
+ 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']),
+ 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']),
+ 'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars),
+ 'participantID' => $participantId,
+ 'conference_sessions' => $sessions,
+ 'credit_card_number' =>
+ CRM_Utils_System::mungeCreditCard(
+ CRM_Utils_Array::value('credit_card_number', $participantParams)),
+ 'credit_card_exp_date' =>
+ CRM_Utils_Date::mysqlToIso(
+ CRM_Utils_Date::format(
+ CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
+ ));
// CRM-13890 : NOTE wait list condition need to be given so that
// wait list message is shown properly in email i.e. WRT online event registration template
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id');
$tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($statusId, NULL, 'label');
}
+ //CRM-15754 - if participant_status contains status ID
+ elseif (CRM_Utils_Rule::integer($tplParams['participant_status'])) {
+ $tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($tplParams['participant_status'], NULL, 'label');
+ }
$sendTemplateParams = array(
'groupName' => 'msg_tpl_workflow_event',
'contactId' => $contactID,
'isTest' => $isTest,
'tplParams' => $tplParams,
- 'PDFFilename' => ts('confirmation').'.pdf',
+ 'PDFFilename' => ts('confirmation') . '.pdf',
);
// address required during receipt processing (pdf and email receipt)
// check if additional prticipant, if so filter only to relevant ones
// CRM-9902
if (!empty($values['params']['additionalParticipant'])) {
- $ownLineItems = array( );
- foreach ( $lineItem as $liKey => $liValue ) {
- $firstElement = array_pop( $liValue );
- if ( $firstElement['entity_id'] == $participantId ) {
+ $ownLineItems = array();
+ foreach ($lineItem as $liKey => $liValue) {
+ $firstElement = array_pop($liValue);
+ if ($firstElement['entity_id'] == $participantId) {
$ownLineItems[0] = $lineItem[$liKey];
break;
}
}
- if ( ! empty( $ownLineItems ) ) {
+ if (!empty($ownLineItems)) {
$sendTemplateParams['tplParams']['lineItem'] = $ownLineItems;
}
}
$values['event']
);
// append invoice pdf to email
- $template = CRM_Core_Smarty::singleton( );
+ $template = CRM_Core_Smarty::singleton();
$taxAmt = $template->get_template_vars('totalTaxAmount');
$prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
- if ($taxAmt && (isset($invoicing) && isset($prefixValue['is_email_pdf'])) ) {
- $sendTemplateParams['isEmailPdf'] = True;
+ if ($taxAmt && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
+ $sendTemplateParams['isEmailPdf'] = TRUE;
$sendTemplateParams['contributionId'] = $values['contributionId'];
}
CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
/**
- * Function to add the custom fields OR array of participant's
+ * Add the custom fields OR array of participant's
* profile info
*
- * @param $id
- * @param $name
- * @param $cid
+ * @param int $id
+ * @param string $name
+ * @param int $cid
* @param $template
- * @param $participantId
+ * @param int $participantId
* @param $isTest
* @param bool $isCustomProfile
* @param array $participantParams
*
* @return void
- * @access public
*/
- static function buildCustomDisplay($id,
+ static function buildCustomDisplay(
+ $id,
$name,
$cid,
&$template,
//add participant id
$fields['participant_id'] = array(
'name' => 'participant_id',
- 'title' => 'Participant Id',
+ 'title' => ts('Participant ID'),
);
//check whether its a text drive
if ($isTest) {
if (!empty($grpIds)) {
//get the group titles.
$grpTitles = array();
- $query = 'SELECT title FROM civicrm_group where id IN ( ' . implode(',', $grpIds) . ' )';
- $grp = CRM_Core_DAO::executeQuery($query);
+ $query = 'SELECT title FROM civicrm_group where id IN ( ' . implode(',', $grpIds) . ' )';
+ $grp = CRM_Core_DAO::executeQuery($query);
while ($grp->fetch()) {
$grpTitles[] = $grp->title;
}
}
/**
- * Function to build the array for display the profile fields
- *
- * @param array $params key value.
- * @param int $gid profile Id
- * @param array $groupTitle Profile Group Title.
- * @param array $values formatted array of key value
+ * Build the array for display the profile fields
+ *
+ * @param array $params
+ * Key value.
+ * @param int $gid
+ * Profile Id.
+ * @param array $groupTitle
+ * Profile Group Title.
+ * @param array $values
+ * Formatted array of key value.
*
* @param array $profileFields
*
* @return void
- * @access public
* @static
*/
- static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array()) {
+ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array()) {
if ($gid) {
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
break;
}
}
- $customVal = '';
- $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
+ $customVal = '';
+ $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
//start of code to set the default values
foreach ($fields as $name => $field) {
$skip = FALSE;
$values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $params[$name]);
}
elseif (in_array($name, array(
- 'addressee', 'email_greeting', 'postal_greeting'))) {
+ 'addressee',
+ 'email_greeting',
+ 'postal_greeting',
+ ))) {
$filterCondition = array('greeting_type' => $name);
- $greeting = CRM_Core_PseudoConstant::greeting($filterCondition);
- $values[$index] = $greeting[$params[$name]];
+ $greeting = CRM_Core_PseudoConstant::greeting($filterCondition);
+ $values[$index] = $greeting[$params[$name]];
}
elseif ($name === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
- $compref = array();
- $pref = $params[$name];
+ $compref = array();
+ $pref = $params[$name];
if (is_array($pref)) {
foreach ($pref as $k => $v) {
if ($v) {
}
elseif ($name == 'tag') {
$entityTags = $params[$name];
- $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $title = array();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
+ $title = array();
if (is_array($entityTags)) {
foreach ($entityTags as $tagId => $dontCare) {
$title[] = $allTags[$tagId];
list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2);
$detailName = str_replace(' ', '_', $name);
if (in_array($fieldName, array(
- 'state_province', 'country', 'county'))) {
+ 'state_province',
+ 'country',
+ 'county',
+ ))) {
$values[$index] = $params[$detailName];
- $idx = $detailName . '_id';
+ $idx = $detailName . '_id';
$values[$index] = $params[$idx];
}
elseif ($fieldName == 'im') {
) {
$v = $params[$name];
if (!CRM_Utils_System::isNull($v)) {
- $customVal = (int)$v;
+ $customVal = (int) $v;
}
}
elseif ($dao->data_type == 'Float') {
- $customVal = (float )($params[$name]);
+ $customVal = (float ) ($params[$name]);
}
elseif ($dao->data_type == 'Date') {
//@todo note the currently we are using default date time formatting. Since you can select/set
}
//take the custom field options
$returnProperties = array($name => 1);
- $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
- $options = &$query->_options;
+ $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
+ $options = &$query->_options;
if (!$skip) {
- $displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
+ $displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
}
//Hack since we dont have function to check empty.
//FIXME in 2.3 using crmIsEmptyArray()
$values[$index] = "<a href=\"$url\">{$params[$name]}</a>";
}
elseif (in_array($name, array(
- 'birth_date', 'deceased_date', 'participant_register_date'))) {
+ 'birth_date',
+ 'deceased_date',
+ 'participant_register_date',
+ ))) {
$values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name]));
}
else {
}
/**
- * Function to build the array for Additional participant's information array of priamry and additional Ids
+ * Build the array for Additional participant's information array of priamry and additional Ids
*
- * @param int $participantId id of Primary participant
- * @param array $values key/value event info
- * @param int $contactId contact id of Primary participant
- * @param boolean $isTest whether test or live transaction
- * @param boolean $isIdsArray to return an array of Ids
+ * @param int $participantId
+ * Id of Primary participant.
+ * @param array $values
+ * Key/value event info.
+ * @param int $contactId
+ * Contact id of Primary participant.
+ * @param bool $isTest
+ * Whether test or live transaction.
+ * @param bool $isIdsArray
+ * To return an array of Ids.
*
* @param bool $skipCancel
*
- * @return array $customProfile array of Additional participant's info OR array of Ids.
- * @access public
+ * @return array
+ * array of Additional participant's info OR array of Ids.
*/
- static function buildCustomProfile($participantId,
+ static function buildCustomProfile(
+ $participantId,
$values,
- $contactId = NULL,
- $isTest = FALSE,
+ $contactId = NULL,
+ $isTest = FALSE,
$isIdsArray = FALSE,
$skipCancel = TRUE
) {
//hack to skip cancelled participants, CRM-4320
$where = "participant.registered_by_id={$participantId}";
if ($skipCancel) {
- $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}";
}
$query = "
$template = CRM_Core_Smarty::singleton();
$isCustomProfile = TRUE;
- $i = 1;
- $title = $groupTitles = array();
+ $i = 1;
+ $title = $groupTitles = array();
foreach ($additionalIDs as $pId => $cId) {
//get the params submitted by participant.
$participantParams = CRM_Utils_Array::value($pId, $values['params'], array());
/* Function to retrieve all events those having location block set.
*
- * @return array $events array of all events.
+ * @return array
+ * array of all events.
*/
/**
* @return array
*/
- static function getLocationEvents() {
+ public static function getLocationEvents() {
$events = array();
$query = "
-SELECT CONCAT_WS(' :: ' , ca.name, ca.street_address, ca.city, sp.name) title, ce.loc_block_id
+SELECT CONCAT_WS(' :: ' , ca.name, ca.street_address, ca.city, sp.name, ca.supplemental_address_1, ca.supplemental_address_2) title, ce.loc_block_id
FROM civicrm_event ce
INNER JOIN civicrm_loc_block lb ON ce.loc_block_id = lb.id
INNER JOIN civicrm_address ca ON lb.address_id = ca.id
}
/**
- * @param $locBlockId
+ * @param int $locBlockId
*
* @return int|null|string
*/
- static function countEventsUsingLocBlockId($locBlockId) {
+ public static function countEventsUsingLocBlockId($locBlockId) {
if (!$locBlockId) {
return 0;
}
* Check if event registration is valid according to permissions AND Dates
*
* @param array $values
- * @param integer $eventID
+ * @param int $eventID
* @return boolean
*/
- static function validRegistrationRequest($values, $eventID) {
+ public static function validRegistrationRequest($values, $eventID) {
// check that the user has permission to register for this event
$hasPermission = CRM_Core_Permission::event(CRM_Core_Permission::EDIT,
$eventID, 'register for events'
*
* @return bool
*/
- static function validRegistrationDate(&$values) {
+ public static function validRegistrationDate(&$values) {
// make sure that we are between registration start date and registration end date
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
- $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
- $eventEnd = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
- $now = time();
+ $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
+ $eventEnd = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
+ $now = time();
$validDate = TRUE;
if ($startDate && $startDate >= $now) {
$validDate = FALSE;
/* Function to Show - Hide the Registration Link.
*
- * @param array $values key/value event info
- * @return boolean true if allow registration otherwise false
- * @access public
+ * @param array $values
+ * Key/value event info.
+ * @return boolean
+ * true if allow registration otherwise false
*/
/**
* @param $values
*
* @return bool
*/
- static function showHideRegistrationLink($values) {
+ public static function showHideRegistrationLink($values) {
- $session = CRM_Core_Session::singleton();
- $contactID = $session->get('userID');
+ $session = CRM_Core_Session::singleton();
+ $contactID = $session->get('userID');
$alreadyRegistered = FALSE;
if ($contactID) {
/* Function to check if given contact is already registered.
*
- * @param array $params key/value participant info
- * @return boolean $alreadyRegistered true/false
- * @access public
+ * @param array $params
+ * Key/value participant info.
+ * @return boolean
*/
/**
- * @param $params
+ * @param array $params
*
* @return bool
*/
- static function checkRegistration($params) {
+ public static function checkRegistration($params) {
$alreadyRegistered = FALSE;
if (empty($params['contact_id'])) {
return $alreadyRegistered;
}
/**
- * make sure that the user has permission to access this event
+ * Make sure that the user has permission to access this event
*
- * @param null $eventId
+ * @param int $eventId
* @param int $type
*
- * @internal param int $id the id of the event
- * @internal param int $name the name or title of the event
- *
- * @return string the permission that the user has (or null)
- * @access public
+ * @return string
+ * the permission that the user has (or null)
* @static
*/
- static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
+ public static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
static $permissions = NULL;
if (empty($permissions)) {
* Build From Email as the combination of all the email ids of the logged in user,
* the domain email id and the email id configured for the event
*
- * @param int $eventId the id of the event
+ * @param int $eventId
+ * The id of the event.
*
- * @return array an array of email ids
- * @access public
+ * @return array
+ * an array of email ids
* @static
*/
- static function getFromEmailIds($eventId = NULL) {
+ public static function getFromEmailIds($eventId = NULL) {
$fromEmailValues['from_email_id'] = CRM_Core_BAO_Email::getFromEmail();
if ($eventId) {
// add the email id configured for the event
- $params = array('id' => $eventId);
+ $params = array('id' => $eventId);
$returnProperties = array('confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm');
- $eventEmail = array();
+ $eventEmail = array();
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $eventEmail, $returnProperties);
if (!empty($eventEmail['confirm_from_name']) && !empty($eventEmail['confirm_from_email'])) {
$eventEmailId = "{$eventEmail['confirm_from_name']} <{$eventEmail['confirm_from_email']}>";
$fromEmailValues['from_email_id'][$eventEmailId] = htmlspecialchars($eventEmailId);
- $fromEmailId = array('cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
+ $fromEmailId = array(
+ 'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventEmail),
);
$fromEmailValues = array_merge($fromEmailValues, $fromEmailId);
}
/**
- * Function to calculate event total seats occupied.
+ * Calculate event total seats occupied.
*
- * @param int $eventId event id.
- * @param sting $extraWhereClause extra filter on participants.
+ * @param int $eventId
+ * Event id.
+ * @param sting $extraWhereClause
+ * Extra filter on participants.
*
- * @return int event total seats w/ given criteria.
- * @access public
+ * @return int
+ * event total seats w/ given criteria.
* @static
*/
- static function eventTotalSeats($eventId, $extraWhereClause = NULL) {
+ public static function eventTotalSeats($eventId, $extraWhereClause = NULL) {
if (empty($eventId)) {
return 0;
}
{$extraWhereClause}
GROUP BY participant.event_id";
- return (int)CRM_Core_DAO::singleValueQuery($query, array(1 => array($eventId, 'Positive')));
+ return (int) CRM_Core_DAO::singleValueQuery($query, array(1 => array($eventId, 'Positive')));
}
- /*
+ /**
* Retrieve event template default values to be set
* as default values for current new event.
*
- * @params int $templateId event template id.
- *
- * @return $defaults an array of custom data defaults.
- */
- /**
- * @param $templateId
+ * @param int $templateId
+ * Event template id.
*
* @return array
+ * Array of custom data defaults.
*/
- static function getTemplateDefaultValues($templateId) {
+ public static function getTemplateDefaultValues($templateId) {
$defaults = array();
if (!$templateId) {
return $defaults;
}
/**
- * @param $event_id
+ * @param int $event_id
*
* @return object
*/
- static function get_sub_events($event_id) {
+ public static function get_sub_events($event_id) {
$params = array('parent_event_id' => $event_id);
$defaults = array();
return CRM_Event_BAO_Event::retrieve($params, $defaults);
}
- /*
+ /**
* Update the Campaign Id of all the participants of the given event
*
- * @params int $eventID event id.
- * @params int $eventCampaignID campaign id of that event
- *
+ * @param int $eventID
+ * Event id.
+ * @param int $eventCampaignID
+ * Campaign id of that event.
*/
- /**
- * @param $eventID
- * @param $eventCampaignID
- */
- static function updateParticipantCampaignID($eventID, $eventCampaignID) {
+ public static function updateParticipantCampaignID($eventID, $eventCampaignID) {
$params = array();
$params[1] = array($eventID, 'Integer');
- if(empty($eventCampaignID)) {
+ if (empty($eventCampaignID)) {
$query = "UPDATE civicrm_participant SET campaign_id = NULL WHERE event_id = %1";
}
else {
* 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
*/
case 'financial_type_id':
// Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get
return CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
+
break;
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);