/** * @param CRM_Core_Form $form * * @return array */ public static function process(&$form) { if ($form->getVar('_surveyId') <= 0) { return NULL; } $tabs = array('main' => array('title' => ts('Main Information'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'questions' => array('title' => ts('Questions'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'results' => array('title' => ts('Results'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE)); $surveyID = $form->getVar('_surveyId'); $class = $form->getVar('_name'); $class = CRM_Utils_String::getClassName($class); $class = strtolower($class); if (array_key_exists($class, $tabs)) { $tabs[$class]['current'] = TRUE; $qfKey = $form->get('qfKey'); if ($qfKey) { $tabs[$class]['qfKey'] = "&qfKey={$qfKey}"; } } if ($surveyID) { $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { $tabs[$key]['qfKey'] = NULL; } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/survey/configure/{$key}", "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}"); $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } } return $tabs; }
/** * @param CRM_Core_Form $form * * @return array */ public static function process(&$form) { if ($form->getVar('_id') <= 0) { return NULL; } $tabs = array('settings' => array('title' => ts('Title'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'amount' => array('title' => ts('Amounts'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'membership' => array('title' => ts('Memberships'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'thankyou' => array('title' => ts('Receipt'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'friend' => array('title' => ts('Tell a Friend'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'custom' => array('title' => ts('Profiles'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'premium' => array('title' => ts('Premiums'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'widget' => array('title' => ts('Widgets'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'pcp' => array('title' => ts('Personal Campaigns'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE)); $contribPageId = $form->getVar('_id'); CRM_Utils_Hook::tabset('civicrm/admin/contribute', $tabs, array('contribution_page_id' => $contribPageId)); $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); // Hack for special cases. switch ($className) { case 'Contribute': $attributes = $form->getVar('_attributes'); $class = strtolower(basename(CRM_Utils_Array::value('action', $attributes))); break; case 'MembershipBlock': $class = 'membership'; 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 ($contribPageId) { $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { $tabs[$key]['qfKey'] = NULL; } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/admin/contribute/{$key}", "{$reset}action=update&id={$contribPageId}{$tabs[$key]['qfKey']}"); $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } //get all section info. $contriPageInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo(array($contribPageId)); foreach ($contriPageInfo[$contribPageId] as $section => $info) { if (!$info) { $tabs[$section]['valid'] = FALSE; } } } return $tabs; }
static function process(&$form) { if ($form->getVar('_id') <= 0) { return null; } $tabs = array('eventInfo' => array('title' => ts('Info and Settings'), 'link' => null, 'valid' => false, 'active' => false, 'current' => false), 'location' => array('title' => ts('Event Location'), 'link' => null, 'valid' => false, 'active' => false, 'current' => false), 'fee' => array('title' => ts('Fees'), 'link' => null, 'valid' => false, 'active' => false, 'current' => false), 'registration' => array('title' => ts('Online Registration'), 'link' => null, 'valid' => false, 'active' => false, 'current' => false), 'friend' => array('title' => ts('Tell a Friend'), 'link' => null, 'valid' => false, 'active' => false, 'current' => false)); $eventID = $form->getVar('_id'); $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); $class = strtolower($className); // hack for tell a friend, since class name is different if ($className == 'Event') { $class = 'friend'; } elseif ($className == 'EventInfo') { $class = 'eventInfo'; } if (array_key_exists($class, $tabs)) { $tabs[$class]['current'] = true; } if ($eventID) { $reset = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; //add qf key $qfKey = $form->get('qfKey'); $form->assign('qfKey', $qfKey); foreach ($tabs as $key => $value) { $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action=update&snippet=4&id={$eventID}&qfKey={$qfKey}"); $tabs[$key]['active'] = $tabs[$key]['valid'] = true; } // retrieve info about paid event, tell a friend and online reg $sql = "\nSELECT e.is_online_registration, e.is_monetary, taf.is_active\nFROM civicrm_event e\nLEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )\nWHERE e.id = %1\n"; $params = array(1 => array($eventID, 'Integer')); $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { CRM_Core_Error::fatal(); } 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; } } return $tabs; }
/** * @return string */ public function getTemplateFileName() { if ($this->controller->getPrint() || $this->getVar('_id') <= 0 || $this->_action & CRM_Core_Action::DELETE || CRM_Utils_String::getClassName($this->_name) == 'AddProduct') { return parent::getTemplateFileName(); } else { // hack lets suppress the form rendering for now self::$_template->assign('isForm', FALSE); return 'CRM/Contribute/Form/ContributionPage/Tab.tpl'; } }
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}")); } } }
/** * Constructor for the basic form page * * We should not use QuickForm directly. This class provides a lot * of default convenient functions, rules and buttons * * @param object $state State associated with this form * @param enum $action The mode the form is operating in (None/Create/View/Update/Delete) * * @return object * @access public */ function CRM_Core_Form($state = null, $action = CRM_CORE_ACTION_NONE, $method = 'post') { $this->_name = CRM_Utils_String::getClassName(CRM_Utils_System::getClassName($this)); $this->HTML_QuickForm_Page($this->_name, $method); $this->_state = $state; $this->_action = $action; $this->registerRules(); // let the constructor initialize this, should happen only once if (!isset($GLOBALS['_CRM_CORE_FORM']['_template'])) { $GLOBALS['_CRM_CORE_FORM']['_template'] =& CRM_Core_Smarty::singleton(); } }
/** * @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 $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_mapping map ON ( map.entity_value = 'civicrm_event' )\nLEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id 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')); $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'; } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action={$action}&id={$eventID}&component=event{$tabs[$key]['qfKey']}"); } } return $tabs; }
/** * Constructor for the basic form page. * * We should not use QuickForm directly. This class provides a lot * of default convenient functions, rules and buttons * * @param object $state * State associated with this form. * @param \const|\enum|int $action The mode the form is operating in (None/Create/View/Update/Delete) * @param string $method * The type of http method used (GET/POST). * @param string $name * The name of the form if different from class name. * * @return \CRM_Core_Form */ public function __construct($state = NULL, $action = CRM_Core_Action::NONE, $method = 'post', $name = NULL) { if ($name) { $this->_name = $name; } else { // CRM-15153 - FIXME this name translates to a DOM id and is not always unique! $this->_name = CRM_Utils_String::getClassName(CRM_Utils_System::getClassName($this)); } $this->HTML_QuickForm_Page($this->_name, $method); $this->_state =& $state; if ($this->_state) { $this->_state->setName($this->_name); } $this->_action = (int) $action; $this->registerRules(); // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); } // Workaround for CRM-15153 - give each form a reasonably unique css class $this->addClass(CRM_Utils_System::getClassName($this)); $this->assign('snippet', CRM_Utils_Array::value('snippet', $_GET)); }
/** * add pages to the controller. Note that the controller does not really care * the order in which the pages are added * * @param object $stateMachine the state machine object * @param int $action the mode in which the state machine is operating * typicaly this will be add/view/edit * * @return void * @access public * */ function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) { $pages = $stateMachine->getPages(); foreach ($pages as $name => $value) { $className = CRM_Utils_Array::value('className', $value, $name); $title = CRM_Utils_Array::value('title', $value); $options = CRM_Utils_Array::value('options', $value); $stateName = CRM_Utils_String::getClassName($className); if (CRM_Utils_Array::value('className', $value)) { $formName = $name; } else { $formName = CRM_Utils_String::getClassName($name); } $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionClass($className)) { require_once $ext->classToPath($className); } else { require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; } ${$stateName} = new $className($stateMachine->find($className), $action, 'post', $formName); if ($title) { ${$stateName}->setTitle($title); } if ($options) { ${$stateName}->setOptions($options); } $this->addPage(${$stateName}); $this->addAction($stateName, new HTML_QuickForm_Action_Direct()); //CRM-6342 -we need kill the reference here, //as we have deprecated reference object creation. unset(${$stateName}); } }
/** * add pages to the controller. Note that the controller does not really care * the order in which the pages are added * * @param object $stateMachine the state machine object * @param int $action the mode in which the state machine is operating * typicaly this will be add/view/edit * * @return void * @access public * */ function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) { $pages = $stateMachine->getPages(); foreach ($pages as $name => $value) { $className = CRM_Utils_Array::value('className', $value, $name); $title = CRM_Utils_Array::value('title', $value); $options = CRM_Utils_Array::value('options', $value); $stateName = CRM_Utils_String::getClassName($className); if (CRM_Utils_Array::value('className', $value)) { $formName = $name; } else { $formName = CRM_Utils_String::getClassName($name); } require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; ${$stateName} =& new $className($stateMachine->find($className), $action, 'post', $formName); if ($title) { ${$stateName}->setTitle($title); } if ($options) { ${$stateName}->setOptions($options); } $this->addPage(${$stateName}); $this->addAction($stateName, new HTML_QuickForm_Action_Direct()); } }
/** * add pages to the controller. Note that the controller does not really care * the order in which the pages are added * * @param object $stateMachine the state machine object * @param int $action the mode in which the state machine is operating * typicaly this will be add/view/edit * * @return void * @access public * */ function addPages($stateMachine, $action = CRM_CORE_ACTION_NONE) { $pages = $stateMachine->getPages(); foreach ($pages as $classPath) { $stateName = CRM_Utils_String::getClassName($classPath); require_once str_replace('_', DIRECTORY_SEPARATOR, $classPath) . '.php'; ${$stateName} =& new $classPath($stateMachine->find($classPath), $action); $this->addPage(${$stateName}); $this->addAction($stateName, new HTML_QuickForm_Action_Direct()); } }
/** * addSequentialStates: meta level function to create a simple * wizard for a state machine that is completely sequential. * * @access public * * @param array $states states is an array of arrays. Each element * of the top level array describes a state. Each state description * includes the name, the display name and the class name * * @param int $action mode of form operation. * * @return void */ function addSequentialPages(&$pages, $action) { $this->_pages =& $pages; $numPages = count($pages); for ($i = 0; $i < $numPages; $i++) { $name = CRM_Utils_String::getClassName($pages[$i]); $classPath = str_replace('_', '/', $pages[$i]) . '.php'; require_once $classPath; $title = eval(sprintf("return %s::getTitle( );", $pages[$i])); if ($numPages == 1) { $prev = $next = null; $type = CRM_CORE_STATE_START | CRM_CORE_STATE_FINISH; } else { if ($i == 0) { // start state $prev = null; $next = CRM_Utils_String::getClassName($pages[$i + 1]); $type = CRM_CORE_STATE_START; } else { if ($i == $numPages - 1) { // finish state $prev = CRM_Utils_String::getClassName($pages[$i - 1]); $next = null; $type = CRM_CORE_STATE_FINISH; } else { // in between simple state $prev = CRM_Utils_String::getClassName($pages[$i - 1]); $next = CRM_Utils_String::getClassName($pages[$i + 1]); $type = CRM_CORE_STATE_SIMPLE; } } } $this->addState($name, $title, $type, $prev, $next); } }
/** * Constructor for the basic form page * * We should not use QuickForm directly. This class provides a lot * of default convenient functions, rules and buttons * * @param object $state State associated with this form * @param enum $action The mode the form is operating in (None/Create/View/Update/Delete) * @param string $method The type of http method used (GET/POST) * @param string $name The name of the form if different from class name * * @return object * @access public */ function __construct($state = null, $action = CRM_Core_Action::NONE, $method = 'post', $name = null) { if ($name) { $this->_name = $name; } else { $this->_name = CRM_Utils_String::getClassName(CRM_Utils_System::getClassName($this)); } $this->HTML_QuickForm_Page($this->_name, $method); $this->_state = $state; $this->_action = (int) $action; $this->registerRules(); // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); } }
function getTemplateFileName() { if ($this->controller->getPrint() == CRM_Core_Smarty::PRINT_NOFORM || $this->getVar('_id') <= 0 || $this->_action & CRM_Core_Action::DELETE || CRM_Utils_String::getClassName($this->_name) == 'AddProduct') { return parent::getTemplateFileName(); } else { return 'CRM/Contribute/Form/ContributionPage/Tab.tpl'; } }
/** * Constructor for the basic form page * * We should not use QuickForm directly. This class provides a lot * of default convenient functions, rules and buttons * * @param object $state State associated with this form * @param enum $action The mode the form is operating in (None/Create/View/Update/Delete) * @param string $method The type of http method used (GET/POST) * @param string $name The name of the form if different from class name * * @return object * @access public */ function __construct($state = NULL, $action = CRM_Core_Action::NONE, $method = 'post', $name = NULL) { if ($name) { $this->_name = $name; } else { $this->_name = CRM_Utils_String::getClassName(CRM_Utils_System::getClassName($this)); } $this->HTML_QuickForm_Page($this->_name, $method); $this->_state =& $state; if ($this->_state) { $this->_state->setName($this->_name); } $this->_action = (int) $action; $this->registerRules(); // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); } $this->assign('snippet', (int) CRM_Utils_Array::value('snippet', $_REQUEST)); }
/** * Return the form name of the task. This is * * @return string */ public function getTaskFormName() { return CRM_Utils_String::getClassName('CRM_Tournament_Player_Form_Task_AddToGroup'); }
/** * Return the form name of the task. * * @return string */ public function getTaskFormName() { if (is_array($this->_task)) { // return first page return CRM_Utils_String::getClassName($this->_task[0]); } else { return CRM_Utils_String::getClassName($this->_task); } }
/** * return the form name of the task. This is * * @return string * @access public */ function getTaskFormName() { return CRM_Utils_String::getClassName('CRM_Contact_Form_Task_AddToGroup'); }
/** * Add sequential pages. * * Meta level function to create a simple wizard for a state machine that is completely sequential. * * @param array $pages * (reference ) the array of page objects. */ public function addSequentialPages(&$pages) { $this->_pages =& $pages; $numPages = count($pages); $this->_pageNames = array(); foreach ($pages as $tempName => $value) { if (!empty($value['className'])) { $this->_pageNames[] = $tempName; } else { $this->_pageNames[] = CRM_Utils_String::getClassName($tempName); } } $i = 0; foreach ($pages as $tempName => $value) { $name = $this->_pageNames[$i]; $className = CRM_Utils_Array::value('className', $value, $tempName); $classPath = str_replace('_', '/', $className) . '.php'; if ($numPages == 1) { $prev = $next = NULL; $type = CRM_Core_State::START | CRM_Core_State::FINISH; } elseif ($i == 0) { // start state $prev = NULL; $next = $this->_pageNames[$i + 1]; $type = CRM_Core_State::START; } elseif ($i == $numPages - 1) { // finish state $prev = $this->_pageNames[$i - 1]; $next = NULL; $type = CRM_Core_State::FINISH; } else { // in between simple state $prev = $this->_pageNames[$i - 1]; $next = $this->_pageNames[$i + 1]; $type = CRM_Core_State::SIMPLE; } $this->addState($name, $type, $prev, $next); $i++; } }
static function process(&$form) { if ($form->getVar('_id') <= 0) { return NULL; } $tabs = array('settings' => array('title' => ts('Info and Settings'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'location' => array('title' => ts('Event Location'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'fee' => array('title' => ts('Fees'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'registration' => array('title' => ts('Online Registration'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'reminder' => array('title' => ts('Schedule Reminders'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'conference' => array('title' => ts('Conference Slots'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'friend' => array('title' => ts('Tell a Friend'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'pcp' => array('title' => ts('Personal Campaigns'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE)); // 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'); $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 'ScheduleReminders': $class = 'reminder'; $new = CRM_Utils_Array::value('new', $_GET) ? '&new=1' : ''; break; default: $class = strtolower($className); break; } if (array_key_exists($class, $tabs)) { $tabs[$class]['current'] = TRUE; } if ($eventID) { $reset = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; //add qf key $qfKey = $form->get('qfKey'); $form->assign('qfKey', $qfKey); foreach ($tabs as $key => $value) { $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action=update&snippet=4&id={$eventID}&qfKey={$qfKey}&component=event{$new}"); $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } // retrieve info about paid event, tell a friend and online reg $sql = "\nSELECT e.is_online_registration, e.is_monetary, taf.is_active\nFROM civicrm_event e\nLEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )\nWHERE e.id = %1\n"; $params = array(1 => array($eventID, 'Integer')); $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { CRM_Core_Error::fatal(); } 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; } //calculate if the reminder has been configured for this event } return $tabs; }
static function process(&$form) { if ($form->getVar('_id') <= 0) { return NULL; } $tabs = array('settings' => array('title' => ts('Info and Settings'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'location' => array('title' => ts('Event Location'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'fee' => array('title' => ts('Fees'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'registration' => array('title' => ts('Online Registration'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'reminder' => array('title' => ts('Schedule Reminders'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'conference' => array('title' => ts('Conference Slots'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'friend' => array('title' => ts('Tell a Friend'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE), 'pcp' => array('title' => ts('Personal Campaigns'), 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE)); // 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 $sql = "\nSELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder\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_mapping map ON ( map.entity_value = 'civicrm_event' )\nLEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )\nWHERE e.id = %1\n"; $params = array(1 => array($eventID, '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; } } // 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 'ScheduleReminders': $class = 'reminder'; $new = CRM_Utils_Array::value('new', $_GET) ? '&new=1' : ''; 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 = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { $tabs[$key]['qfKey'] = NULL; } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action=update&snippet=5&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"); } } return $tabs; }
function endPostProcess() { // make submit buttons keep the current working tab opened. if ($this->_action & CRM_Core_Action::UPDATE) { $className = CRM_Utils_String::getClassName($this->_name); // hack for special cases. switch ($className) { case 'Event': $attributes = $this->getVar('_attributes'); $subPage = strtolower(basename(CRM_Utils_Array::value('action', $attributes))); break; case 'EventInfo': $subPage = 'settings'; break; case 'ScheduleReminders': $subPage = 'reminder'; break; default: $subPage = strtolower($className); break; } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $subPage == 'friend' ? 'Friend' : $className))); $this->postProcessHook(); if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { if ($this->_isTemplate) { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); } else { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); } } else { CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/event/manage/{$subPage}", "action=update&reset=1&id={$this->_id}")); } } }
public function endPostProcess() { // make submit buttons keep the current working tab opened. if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { $tabTitle = $className = CRM_Utils_String::getClassName($this->_name); if ($tabTitle == 'Main') { $tabTitle = 'Main settings'; } $subPage = strtolower($className); CRM_Core_Session::setStatus(ts("'%1' have been saved.", array(1 => $tabTitle)), ts('Saved'), 'success'); $this->postProcessHook(); if ($this->_action & CRM_Core_Action::ADD) { CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/survey/configure/questions", "action=update&reset=1&id={$this->_surveyId}")); } if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey')); } elseif ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_next") { $subPage = CRM_Campaign_Form_Survey_TabHeader::getNextTab($this); CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/survey/configure/{$subPage}", "action=update&reset=1&id={$this->_surveyId}")); } else { CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/survey/configure/{$subPage}", "action=update&reset=1&id={$this->_surveyId}")); } } }
public function endPostProcess() { // make submit buttons keep the current working tab opened. if ($this->_action & CRM_Core_Action::UPDATE) { $className = CRM_Utils_String::getClassName($this->_name); // hack for special cases. switch ($className) { case 'Event': $attributes = $this->getVar('_attributes'); $subPage = strtolower(basename(CRM_Utils_Array::value('action', $attributes))); break; case 'EventInfo': $subPage = 'settings'; break; case 'ScheduleReminders': $subPage = 'reminder'; break; default: $subPage = strtolower($className); break; } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className))), ts('Saved'), 'success'); $config = CRM_Core_Config::singleton(); if (in_array('CiviCampaign', $config->enableComponents)) { $values = $this->controller->exportValues($this->_name); $newCampaignID = CRM_Utils_Array::value('campaign_id', $values); $eventID = CRM_Utils_Array::value('id', $values); if ($eventID && $this->_campaignID != $newCampaignID) { CRM_Event_BAO_Event::updateParticipantCampaignID($eventID, $newCampaignID); } } $this->postProcessHook(); if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { if ($this->_isTemplate) { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); } else { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); } } else { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url("civicrm/event/manage/{$subPage}", "action=update&reset=1&id={$this->_id}")); } } }
/** * return the form name of the task * * @return string * @access public */ function getTaskFormName() { return CRM_Utils_String::getClassName($this->_task); }
function endPostProcess() { // make submit buttons keep the current working tab opened. if ($this->_action & CRM_Core_Action::UPDATE) { $className = CRM_Utils_String::getClassName($this->_name); if ($className == 'EventInfo') { $subPage = 'eventInfo'; } elseif ($className == 'Event') { $subPage = 'friend'; } else { $subPage = strtolower($className); } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $subPage == 'friend' ? 'Friend' : $className))); // 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); if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { if ($this->_isTemplate) { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); } else { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); } } else { CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/event/manage/{$subPage}", "action=update&reset=1&id={$this->_id}")); } } }