+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
* 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 int|array $id single int event id or array of multiple event ids to return
* @param bool $isActive
* true if you need only active events.
* @param bool $checkPermission
* true if you need to check permission else false.
+ * @param bool $titleOnly
+ * true if you need only title not appended with start date
*
* @return array
*/
public static function getEvents(
$all = 0,
- $id = FALSE,
+ $id = NULL,
$isActive = TRUE,
- $checkPermission = TRUE
+ $checkPermission = TRUE,
+ $titleOnly = FALSE
) {
$query = "
SELECT `id`, `title`, `start_date`
FROM `civicrm_event`
WHERE ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )";
- if ($id) {
- $query .= " AND `id` = {$id}";
+ if (!empty($id)) {
+ if (is_array($id)) {
+ $query .= " AND `id` IN (" . implode(',', $id) . ")";
+ }
+ else {
+ $query .= " AND `id` = {$id}";
+ }
}
elseif ($all == 0) {
// find only events ending in the future
) &&
$dao->title
) {
- $events[$dao->id] = $dao->title . ' - ' . CRM_Utils_Date::customFormat($dao->start_date);
+ $events[$dao->id] = $dao->title;
+ if (!$titleOnly) {
+ $events[$dao->id] .= ' - ' . CRM_Utils_Date::customFormat($dao->start_date);
+ }
}
}
$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']))) {
+ if (isset($invoicing) && isset($prefixValue['is_email_pdf'])) {
$sendTemplateParams['isEmailPdf'] = TRUE;
$sendTemplateParams['contributionId'] = $values['contributionId'];
}
$profileIds = $id;
}
+ $val = $groupTitles = NULL;
foreach ($profileIds as $gid) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid)) {
$values = array();
$values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name]));
}
else {
- $values[$index] = $params[$name];
+ $values[$index] = CRM_Utils_Array::value($name, $params);
}
}
}
$permissions[CRM_Core_Permission::EDIT] = array_keys($allEvents);
}
else {
- $permissions[CRM_Core_Permission::EDIT] = &CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ $permissions[CRM_Core_Permission::EDIT] = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
if (CRM_Core_Permission::check('edit all events')) {
// at the same time also allow any hook to override if needed.
$createdEvents = array_keys($allEvents);
}
- $permissions[CRM_Core_Permission::VIEW] = &CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ $permissions[CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
$permissions[CRM_Core_Permission::DELETE] = array();