/** * Set variables up before form is built. * * @return void */ public function preProcess() { $config = CRM_Core_Config::singleton(); if (in_array('CiviEvent', $config->enableComponents)) { $this->assign('CiviEvent', TRUE); } CRM_Core_Form_RecurringEntity::preProcess('civicrm_event'); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->assign('action', $this->_action); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET'); if ($this->_id) { $this->_isRepeatingEvent = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event'); $this->assign('eventId', $this->_id); if (!empty($this->_addBlockName) && empty($this->_addProfileBottom) && empty($this->_addProfileBottomAdd)) { $this->add('hidden', 'id', $this->_id); } $this->_single = TRUE; $params = array('id' => $this->_id); CRM_Event_BAO_Event::retrieve($params, $eventInfo); // its an update mode, do a permission check if (!CRM_Event_BAO_Event::checkPermission($this->_id, CRM_Core_Permission::EDIT)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } $participantListingID = CRM_Utils_Array::value('participant_listing_id', $eventInfo); //CRM_Core_DAO::getFieldValue( 'CRM_Event_DAO_Event', $this->_id, 'participant_listing_id' ); if ($participantListingID) { $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', "reset=1&id={$this->_id}", TRUE, NULL, TRUE, TRUE); $this->assign('participantListingURL', $participantListingURL); } $this->assign('isOnlineRegistration', CRM_Utils_Array::value('is_online_registration', $eventInfo)); $this->assign('id', $this->_id); } // figure out whether we’re handling an event or an event template if ($this->_id) { $this->_isTemplate = CRM_Utils_Array::value('is_template', $eventInfo); } elseif ($this->_action & CRM_Core_Action::ADD) { $this->_isTemplate = CRM_Utils_Request::retrieve('is_template', 'Boolean', $this); } $this->assign('isTemplate', $this->_isTemplate); if ($this->_id) { if ($this->_isTemplate) { $title = CRM_Utils_Array::value('template_title', $eventInfo); CRM_Utils_System::setTitle(ts('Edit Event Template') . " - {$title}"); } else { $configureText = ts('Configure Event'); $title = CRM_Utils_Array::value('title', $eventInfo); //If it is a repeating event change title if ($this->_isRepeatingEvent) { $configureText = 'Configure Repeating Event'; } CRM_Utils_System::setTitle($configureText . " - {$title}"); } $this->assign('title', $title); } elseif ($this->_action & CRM_Core_Action::ADD) { if ($this->_isTemplate) { $title = ts('New Event Template'); CRM_Utils_System::setTitle($title); } else { $title = ts('New Event'); CRM_Utils_System::setTitle($title); } $this->assign('title', $title); } if (CRM_Core_Permission::check('view event participants') && CRM_Core_Permission::check('view all contacts')) { $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1', 'label'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0', 'label'); $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); } $this->_templateId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this); //Is a repeating event if ($this->_isRepeatingEvent) { $isRepeatingEntity = TRUE; $this->assign('isRepeatingEntity', $isRepeatingEntity); } // CRM-16776 - show edit/copy/create buttons for Profiles if user has required permission. $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); $ufCreate = CRM_ACL_API::group(CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups); $ufEdit = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups); $checkPermission = array(array('administer CiviCRM', 'manage event profiles')); if (CRM_Core_Permission::check($checkPermission) || !empty($ufCreate) || !empty($ufEdit)) { $this->assign('perm', TRUE); } // also set up tabs CRM_Event_Form_ManageEvent_TabHeader::build($this); // Set Done button URL and breadcrumb. Templates go back to Manage Templates, // otherwise go to Manage Event for new event or ManageEventEdit if event if exists. $breadCrumb = array(); if (!$this->_isTemplate) { if ($this->_id) { $this->_doneUrl = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "action=update&reset=1&id={$this->_id}"); } else { $this->_doneUrl = CRM_Utils_System::url('civicrm/event/manage', 'reset=1'); $breadCrumb = array(array('title' => ts('Manage Events'), 'url' => $this->_doneUrl)); } } else { $this->_doneUrl = CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'); $breadCrumb = array(array('title' => ts('Manage Event Templates'), 'url' => $this->_doneUrl)); } CRM_Utils_System::appendBreadCrumb($breadCrumb); }
function endPostProcess() { // make submit buttons keep the current working tab opened. if ($this->_action & CRM_Core_Action::UPDATE) { $subPage = CRM_Utils_Request::retrieve('subPage', 'String', $this); if ($subPage) { $title = CRM_Event_Form_ManageEvent_TabHeader::getSubPageInfo($this, $subPage); } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $title))); // we need to call the hook manually here since we redirect and never // go back to CRM/Core/Form.php // A better way might have been to setUserContext so the framework does the rediret CRM_Utils_Hook::postProcess(get_class($this), $this); $className = CRM_Utils_String::getClassName($this->_name); if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { CRM_Utils_System::redirect($this->_doneUrl); } else { CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), "action=update&reset=1&id={$this->_id}&subPage={$subPage}")); } } }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { $config = CRM_Core_Config::singleton(); if (in_array("CiviEvent", $config->enableComponents)) { $this->assign('CiviEvent', true); } $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add', 'REQUEST'); $this->assign('action', $this->_action); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false); if ($this->_id) { $this->assign('eventId', $this->_id); $this->add('hidden', 'id', $this->_id); $this->_single = true; $params = array('id' => $this->_id); require_once 'CRM/Event/BAO/Event.php'; CRM_Event_BAO_Event::retrieve($params, $eventInfo); // its an update mode, do a permission check require_once 'CRM/Event/BAO/Event.php'; if (!CRM_Event_BAO_Event::checkPermission($this->_id, CRM_Core_Permission::EDIT)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } $participantListingID = CRM_Utils_Array::value('participant_listing_id', $eventInfo); //CRM_Core_DAO::getFieldValue( 'CRM_Event_DAO_Event', $this->_id, 'participant_listing_id' ); if ($participantListingID) { $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', "reset=1&id={$this->_id}", true, null, true, true); $this->assign('participantListingURL', $participantListingURL); } $this->assign('isOnlineRegistration', CRM_Utils_Array::value('is_online_registration', $eventInfo)); $this->assign('id', $this->_id); } // figure out whether we’re handling an event or an event template if ($this->_id) { $this->_isTemplate = CRM_Utils_Array::value('is_template', $eventInfo); } elseif ($this->_action & CRM_Core_Action::ADD) { $this->_isTemplate = CRM_Utils_Request::retrieve('is_template', 'Boolean', $this); } $this->assign('isTemplate', $this->_isTemplate); if ($this->_id) { if ($this->_isTemplate) { $title = CRM_Utils_Array::value('template_title', $eventInfo); CRM_Utils_System::setTitle(ts('Edit Event Template') . " - {$title}"); } else { $title = CRM_Utils_Array::value('title', $eventInfo); CRM_Utils_System::setTitle(ts('Configure Event') . " - {$title}"); } $this->assign('title', $title); } else { if ($this->_action & CRM_Core_Action::ADD) { if ($this->_isTemplate) { $title = ts('New Event Template'); CRM_Utils_System::setTitle($title); } else { $title = ts('New Event'); CRM_Utils_System::setTitle($title); } $this->assign('title', $title); } } require_once 'CRM/Event/PseudoConstant.php'; $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); $this->_templateId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this); // also set up tabs require_once 'CRM/Event/Form/ManageEvent/TabHeader.php'; CRM_Event_Form_ManageEvent_TabHeader::build($this); // Set Done button URL and breadcrumb. Templates go back to Manage Templates, // otherwise go to Manage Event for new event or ManageEventEdit if event if exists. $breadCrumb = array(); if (!$this->_isTemplate) { if ($this->_id) { $this->_doneUrl = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "action=update&reset=1&id={$this->_id}"); } else { $this->_doneUrl = CRM_Utils_System::url('civicrm/event/manage', 'reset=1'); $breadCrumb = array(array('title' => ts('Manage Events'), 'url' => $this->_doneUrl)); } } else { $this->_doneUrl = CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'); $breadCrumb = array(array('title' => ts('Manage Event Templates'), 'url' => $this->_doneUrl)); } CRM_Utils_System::appendBreadCrumb($breadCrumb); }