/** * Set variables up before form is built. * * @return void */ public function preProcess() { parent::preProcess(); $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0); $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id); if ($reminderList && is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as &$format) { $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; if ($format['is_active']) { $action += CRM_Core_Action::DISABLE; } else { $action += CRM_Core_Action::ENABLE; } $scheduleReminder = new CRM_Admin_Page_ScheduleReminders(); $links = $scheduleReminder->links(); $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}"; $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}"; $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $this->_id); } } $this->assign('rows', $reminderList); $this->assign('setTab', $setTab); $this->assign('component', 'event'); // Update tab "disabled" css class $this->ajaxResponse['tabValid'] = is_array($reminderList) && count($reminderList) > 0; $this->setPageTitle(ts('Scheduled Reminder')); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->_mappingID = $mappingID = NULL; $providersCount = CRM_SMS_BAO_Provider::activeProviderCount(); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); //CRM-16777: Don't provide access to administer schedule reminder page, with user that does not have 'administer CiviCRM' permission if (empty($this->_context) && !CRM_Core_Permission::check('administer CiviCRM')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } else { $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); if (!CRM_Event_BAO_Event::checkPermission($this->_compId, CRM_Core_Permission::EDIT)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } } if ($this->_action & CRM_Core_Action::DELETE) { $reminderName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'title'); if ($this->_context == 'event') { $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); } $this->assign('reminderName', $reminderName); return; } elseif ($this->_action & CRM_Core_Action::UPDATE) { $this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'mapping_id'); if ($this->_context == 'event') { $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); } } elseif (!empty($this->_context)) { if ($this->_context == 'event') { $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_compId, 'is_template'); $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); if ($mapping) { $this->_mappingID = $mapping->getId(); } else { CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.'); } } } if (!empty($_POST) && !empty($_POST['entity']) && empty($this->_context)) { $mappingID = $_POST['entity'][0]; } elseif ($this->_mappingID) { $mappingID = $this->_mappingID; } $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'title'), TRUE); $mappings = CRM_Core_BAO_ActionSchedule::getMappings(); $selectedMapping = $mappings[$mappingID ? $mappingID : 1]; $entityRecipientLabels = $selectedMapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients(); $this->assign('entityMapping', json_encode(CRM_Utils_Array::collectMethod('getEntity', $mappings))); $this->assign('recipientMapping', json_encode(array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels)))); if (empty($this->_context)) { $sel =& $this->add('hierselect', 'entity', ts('Entity'), array('name' => 'entity[0]', 'style' => 'vertical-align: top;')); $sel->setOptions(array(CRM_Utils_Array::collectMethod('getLabel', $mappings), CRM_Core_BAO_ActionSchedule::getAllEntityValueLabels(), CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels())); if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) { // make second selector a multi-select - $sel->_elements[1]->setMultiple(TRUE); $sel->_elements[1]->setSize(5); } if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) { // make third selector a multi-select - $sel->_elements[2]->setMultiple(TRUE); $sel->_elements[2]->setSize(5); } } else { // Dig deeper - this code is sublimely stupid. $allEntityStatusLabels = CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels(); $options = $allEntityStatusLabels[$this->_mappingID][0]; $attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]); unset($options[0]); $this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes); $this->assign('context', $this->_context); } //get the frequency units. $this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits(); $numericOptions = CRM_Core_SelectValues::getNumericOptions(0, 30); //reminder_interval $this->add('select', 'start_action_offset', ts('When'), $numericOptions); $isActive = ts('Send email'); $recordActivity = ts('Record activity for automated email'); if ($providersCount) { $this->assign('sms', $providersCount); $isActive = ts('Send email or SMS'); $recordActivity = ts('Record activity for automated email or SMS'); $options = CRM_Core_OptionGroup::values('msg_mode'); $this->add('select', 'mode', ts('Send as'), $options); $providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc'); $providerSelect = array(); foreach ($providers as $provider) { $providerSelect[$provider['id']] = $provider['title']; } $this->add('select', 'sms_provider_id', ts('SMS Provider'), $providerSelect, TRUE); } foreach ($this->_freqUnits as $val => $label) { $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label)); } $this->addDate('absolute_date', ts('Start Date'), FALSE, array('formatType' => 'mailing')); //reminder_frequency $this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE); $condition = array('before' => ts('before'), 'after' => ts('after')); //reminder_action $this->add('select', 'start_action_condition', ts('Action Condition'), $condition); $this->add('select', 'start_action_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE); $this->addElement('checkbox', 'record_activity', $recordActivity); $this->addElement('checkbox', 'is_repeat', ts('Repeat'), NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);")); $this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay); $this->add('select', 'repetition_frequency_interval', ts('every'), $numericOptions); $this->add('select', 'end_frequency_unit', ts('until'), $freqUnitsDisplay); $this->add('select', 'end_frequency_interval', ts('until'), $numericOptions); $this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE); $this->add('select', 'end_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE); $this->add('text', 'from_name', ts('From Name')); $this->add('text', 'from_email', ts('From Email')); $recipientListingOptions = array(); if ($mappingID) { $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $mappingID))); } $limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include')); $recipientLabels = array('activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients')); $this->assign('recipientLabels', $recipientLabels); $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);")); $this->add('select', 'recipient', $recipientLabels['other'], $entityRecipientLabels, FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")); if (!empty($this->_submitValues['recipient_listing'])) { if (!empty($this->_context)) { $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_mappingID, $this->_submitValues['recipient']); } else { $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($_POST['entity'][0], $_POST['recipient']); } } elseif (!empty($this->_values['recipient_listing'])) { $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']); } $this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE)); $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE)); $this->add('select', 'group_id', ts('Group'), CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, array('class' => 'crm-select2 huge')); // multilingual only options $multilingual = CRM_Core_I18n::isMultilingual(); if ($multilingual) { $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('multilingual', $multilingual); $languages = CRM_Core_I18n::languages(TRUE); $languageFilter = $languages + array(CRM_Core_I18n::NONE => ts('Contacts with no preferred language')); $element = $this->add('select', 'filter_contact_language', ts('Recipients language'), $languageFilter, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE)); $communicationLanguage = array('' => ts('System default language'), CRM_Core_I18n::AUTO => ts('Follow recipient preferred language')); $communicationLanguage = $communicationLanguage + $languages; $this->add('select', 'communication_language', ts('Communication language'), $communicationLanguage); } CRM_Mailing_BAO_Mailing::commonCompose($this); $this->add('text', 'subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'subject')); $this->add('checkbox', 'is_active', $isActive); $this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'), $this); $this->setPageTitle(ts('Scheduled Reminder')); }
/** * Browse all events. * * @return void */ public function browse() { Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0); if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) { $this->_sortByCharacter = ''; $this->set('sortByCharacter', ''); } $this->_force = $this->_searchResult = NULL; $this->search(); $params = array(); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); $whereClause = $this->whereClause($params, FALSE, $this->_force); $this->pagerAToZ($whereClause, $params); $params = array(); $whereClause = $this->whereClause($params, TRUE, $this->_force); // because is_template != 1 would be to simple $whereClause .= ' AND (is_template = 0 OR is_template IS NULL)'; $this->pager($whereClause, $params); list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); // get all custom groups sorted by weight $manageEvent = array(); $query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}"; $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event'); $permissions = CRM_Event_BAO_Event::checkPermission(); //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); // get the list of active event pcps $eventPCPS = array(); $pcpDao = new CRM_PCP_DAO_PCPBlock(); $pcpDao->entity_table = 'civicrm_event'; $pcpDao->find(); while ($pcpDao->fetch()) { $eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id; } // check if we're in shopping cart mode for events $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); $this->assign('eventCartEnabled', $enableCart); $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $eventType = CRM_Core_OptionGroup::values('event_type'); while ($dao->fetch()) { if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) { $manageEvent[$dao->id] = array(); $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event'); $manageEvent[$dao->id]['repeat'] = ''; if ($repeat) { $manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); } CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) { $action -= CRM_Core_Action::DELETE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) { $action -= CRM_Core_Action::UPDATE; } $manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), TRUE, 'event.manage.list', 'Event', $dao->id); $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1); $defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); $manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params); if (isset($defaults['location']['address'][1]['city'])) { $manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city']; } if (isset($defaults['location']['address'][1]['state_province_id'])) { $manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']); } //show campaigns on selector. $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId()); $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS); $manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); $manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id'); // allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id)); } } $manageEvent['tab'] = self::tabs($enableCart); $this->assign('rows', $manageEvent); $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); }
/** * make a copy of a Event, including * all the fields in the event Wizard * * @param int $id * The event id to copy. * boolean $afterCreate call to copy after the create function * @param null $newEvent * @param bool $afterCreate * * @return CRM_Event_DAO_Event */ public static function copy($id, $newEvent = NULL, $afterCreate = FALSE) { $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'); 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') . ' ')); if (empty($eventValues['is_show_location'])) { $fieldsFix['prefix']['is_show_location'] = 0; } if ($newEvent && is_a($newEvent, 'CRM_Event_DAO_Event')) { $copyEvent = $newEvent; } if (!isset($copyEvent)) { $copyEvent =& CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', array('id' => $id), array('loc_block_id' => $locBlockId ? $locBlockId : NULL), $fieldsFix); } CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id); $copyUF =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id)); $copyTellFriend =& CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id)); $copyPCP =& CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id), array('replace' => array('target_entity_id' => $copyEvent->id))); $oldMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $eventValues['is_template'] ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $copyMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $copyEvent->is_template == 1 ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $copyReminder =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', array('entity_value' => $id, 'mapping_id' => $oldMapping->getId()), array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->getId())); if (!$afterCreate) { //copy custom data $extends = array('event'); $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends); if ($groupTree) { foreach ($groupTree as $groupID => $group) { $table[$groupTree[$groupID]['table_name']] = array('entity_id'); foreach ($group['fields'] as $fieldID => $field) { $table[$groupTree[$groupID]['table_name']][] = $groupTree[$groupID]['fields'][$fieldID]['column_name']; } } foreach ($table as $tableName => $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); } } } $copyEvent->save(); CRM_Utils_System::flushCache(); if (!$afterCreate) { CRM_Utils_Hook::copy('Event', $copyEvent); } return $copyEvent; }
/** * @param int $mappingID * @param $recipientType * * @return array */ public static function getRecipientListing($mappingID, $recipientType) { if (!$mappingID) { return array(); } /** @var \Civi\ActionSchedule\Mapping $mapping */ $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $mappingID))); return $mapping->getRecipientListing($recipientType); }
/** * @param CRM_Event_Form_ManageEvent $form * * @return array * @throws Exception */ public static function process(&$form) { if ($form->getVar('_id') <= 0) { return NULL; } $default = array('link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE, 'class' => 'ajaxForm'); $tabs = array(); $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default; $tabs['location'] = array('title' => ts('Event Location')) + $default; $tabs['fee'] = array('title' => ts('Fees')) + $default; $tabs['registration'] = array('title' => ts('Online Registration')) + $default; if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) { $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') + $default; } $tabs['conference'] = array('title' => ts('Conference Slots')) + $default; $tabs['friend'] = array('title' => ts('Tell a Friend')) + $default; $tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default; $tabs['repeat'] = array('title' => ts('Repeat')) + $default; // Repeat tab must refresh page when switching repeat mode so js & vars will get set-up if (!$form->_isRepeatingEvent) { unset($tabs['repeat']['class']); } // check if we're in shopping cart mode for events $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); if (!$enableCart) { unset($tabs['conference']); } $eventID = $form->getVar('_id'); if ($eventID) { // disable tabs based on their configuration status $eventNameMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $sql = "\nSELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder, re.id as is_repeating_event\nFROM civicrm_event e\nLEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )\nLEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )\nLEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = %2 AND sch.entity_value = %1 )\nLEFT JOIN civicrm_recurring_entity re ON ( e.id = re.entity_id AND re.entity_table = 'civicrm_event' )\nWHERE e.id = %1\n"; //Check if repeat is configured $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event'); $params = array(1 => array($eventID, 'Integer'), 2 => array($eventNameMapping->getId(), 'Integer')); $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { CRM_Core_Error::fatal(); } if (!$dao->is_location) { $tabs['location']['valid'] = FALSE; } if (!$dao->is_online_registration) { $tabs['registration']['valid'] = FALSE; } if (!$dao->is_monetary) { $tabs['fee']['valid'] = FALSE; } if (!$dao->is_active) { $tabs['friend']['valid'] = FALSE; } if (!$dao->is_pcp) { $tabs['pcp']['valid'] = FALSE; } if (!$dao->is_reminder) { $tabs['reminder']['valid'] = FALSE; } if (!$dao->is_repeating_event) { $tabs['repeat']['valid'] = FALSE; } } // see if any other modules want to add any tabs // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation. CRM_Utils_Hook::tabset('civicrm/event/manage', $tabs, array('event_id' => $eventID)); $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); $new = ''; // hack for special cases. switch ($className) { case 'Event': $attributes = $form->getVar('_attributes'); $class = strtolower(basename(CRM_Utils_Array::value('action', $attributes))); break; case 'EventInfo': $class = 'settings'; break; case 'ScheduleReminders': $class = 'reminder'; break; default: $class = strtolower($className); break; } if (array_key_exists($class, $tabs)) { $tabs[$class]['current'] = TRUE; $qfKey = $form->get('qfKey'); if ($qfKey) { $tabs[$class]['qfKey'] = "&qfKey={$qfKey}"; } } if ($eventID) { $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { $tabs[$key]['qfKey'] = NULL; } $action = 'update'; if ($key == 'reminder') { $action = 'browse'; } $link = "civicrm/event/manage/{$key}"; $query = "{$reset}action={$action}&id={$eventID}&component=event{$tabs[$key]['qfKey']}"; $tabs[$key]['link'] = isset($value['link']) ? $value['link'] : CRM_Utils_System::url($link, $query); } } return $tabs; }