/** * @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; }
/** * @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; }
/** * 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); }
/** * View summary details of a contact. */ public function view() { // Add js for tabs, in-place editing, and jstree for tags CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')->addSetting(array('summaryPrint' => array('mode' => $this->_print), 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')))); $this->assign('summaryPrint', $this->_print); $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId); $session->pushUserContext($url); $params = array(); $defaults = array(); $ids = array(); $params['id'] = $params['contact_id'] = $this->_contactId; $params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE); // Let summary page know if outbound mail is disabled so email links can be built conditionally $mailingBackend = Civi::settings()->get('mailing_backend'); $this->assign('mailingOutboundOption', $mailingBackend['outBound_option']); $communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type', 'daoName' => 'CRM_Core_DAO_Phone', 'fieldName' => 'phone_type_id'), 'im' => array('type' => 'IMProvider', 'id' => 'provider', 'daoName' => 'CRM_Core_DAO_IM', 'fieldName' => 'provider_id'), 'website' => array('type' => 'websiteType', 'id' => 'website_type', 'daoName' => 'CRM_Core_DAO_Website', 'fieldName' => 'website_type_id'), 'address' => array('skip' => TRUE, 'customData' => 1), 'email' => array('skip' => TRUE), 'openid' => array('skip' => TRUE)); foreach ($communicationType as $key => $value) { if (!empty($defaults[$key])) { foreach ($defaults[$key] as &$val) { CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')), FALSE); if (empty($value['skip'])) { $daoName = $value['daoName']; $pseudoConst = $daoName::buildOptions($value['fieldName'], 'get'); CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, FALSE); } } if (isset($value['customData'])) { foreach ($defaults[$key] as $blockId => $blockVal) { $idValue = $blockVal['id']; if ($key == 'address') { if (!empty($blockVal['master_id'])) { $idValue = $blockVal['master_id']; } } $groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), $this, $idValue); // we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var. $defaults[$key][$blockId]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_"); } // reset template variable since that won't be of any use, and could be misleading $this->assign("dnc_viewCustomData", NULL); } } } if (!empty($defaults['gender_id'])) { $defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id']); } $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'); if (!empty($communicationStyle)) { if (!empty($defaults['communication_style_id'])) { $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)]; } else { // Make sure the field is displayed as long as it is active, even if it is unset for this contact. $defaults['communication_style_display'] = ''; } } // to make contact type label available in the template - $contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type']; $defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $contactType, ', '); // get contact tags $contactTags = CRM_Core_BAO_EntityTag::getContactTags($this->_contactId); if (!empty($contactTags)) { $defaults['contactTag'] = implode(', ', $contactTags); } $defaults['privacy_values'] = CRM_Core_SelectValues::privacy(); //Show blocks only if they are visible in edit form $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options'); foreach ($this->_editOptions as $blockName => $value) { $varName = '_show' . $blockName; $this->{$varName} = $value; $this->assign(substr($varName, 1), $this->{$varName}); } // get contact name of shared contact names $sharedAddresses = array(); $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']); foreach ($defaults['address'] as $key => $addressValue) { if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) { $sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']); } } $this->assign('sharedAddresses', $sharedAddresses); //get the current employer name if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') { if ($contact->employer_id && $contact->organization_name) { $defaults['current_employer'] = $contact->organization_name; $defaults['current_employer_id'] = $contact->employer_id; } //for birthdate format with respect to birth format set $this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat())); } $defaults['external_identifier'] = $contact->external_identifier; $this->assign($defaults); // FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query // also assign the last modifed details $lastModified = CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact'); $this->assign_by_ref('lastModified', $lastModified); $allTabs = array(); $weight = 10; $this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE); // show the tabs only if user has generic access to CiviCRM $accessCiviCRM = CRM_Core_Permission::check('access CiviCRM'); $changeLog = $this->_viewOptions['log']; $this->assign_by_ref('changeLog', $changeLog); $components = CRM_Core_Component::getEnabledComponents(); foreach ($components as $name => $component) { if (!empty($this->_viewOptions[$name]) && CRM_Core_Permission::access($component->name)) { $elem = $component->registerTab(); // FIXME: not very elegant, probably needs better approach // allow explicit id, if not defined, use keyword instead if (array_key_exists('id', $elem)) { $i = $elem['id']; } else { $i = $component->getKeyword(); } $u = $elem['url']; //appending isTest to url for test soft credit CRM-3891. //FIXME: hack ajax url. $q = "reset=1&force=1&cid={$this->_contactId}"; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { $q .= "&isTest=1"; } $allTabs[] = array('id' => $i, 'url' => CRM_Utils_System::url("civicrm/contact/view/{$u}", $q), 'title' => $elem['title'], 'weight' => $elem['weight'], 'count' => CRM_Contact_BAO_Contact::getCountComponent($u, $this->_contactId), 'class' => 'livePage'); // make sure to get maximum weight, rest of tabs go after // FIXME: not very elegant again if ($weight < $elem['weight']) { $weight = $elem['weight']; } } } $rest = array('activity' => array('title' => ts('Activities'), 'class' => 'livePage'), 'rel' => array('title' => ts('Relationships'), 'class' => 'livePage'), 'group' => array('title' => ts('Groups'), 'class' => 'ajaxForm'), 'note' => array('title' => ts('Notes'), 'class' => 'livePage'), 'tag' => array('title' => ts('Tags')), 'log' => array('title' => ts('Change Log'))); foreach ($rest as $k => $v) { if ($accessCiviCRM && !empty($this->_viewOptions[$k])) { $allTabs[] = $v + array('id' => $k, 'url' => CRM_Utils_System::url("civicrm/contact/view/{$k}", "reset=1&cid={$this->_contactId}"), 'weight' => $weight, 'count' => CRM_Contact_BAO_Contact::getCountComponent($k, $this->_contactId)); $weight += 10; } } // now add all the custom tabs $entityType = $this->get('contactType'); $activeGroups = CRM_Core_BAO_CustomGroup::getActiveGroups($entityType, 'civicrm/contact/view/cd', $this->_contactId); foreach ($activeGroups as $group) { $id = "custom_{$group['id']}"; $allTabs[] = array('id' => $id, 'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&selectedChild={$id}"), 'title' => $group['title'], 'weight' => $weight, 'count' => CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $group['table_name']), 'hideCount' => !$group['is_multiple'], 'class' => 'livePage'); $weight += 10; } $context = array('contact_id' => $this->_contactId); // see if any other modules want to add any tabs CRM_Utils_Hook::tabs($allTabs, $this->_contactId); CRM_Utils_Hook::tabset('civicrm/contact/view', $allTabs, $context); $allTabs[] = array('id' => 'summary', 'url' => '#contact-summary', 'title' => ts('Summary'), 'weight' => 0); // now sort the tabs based on weight usort($allTabs, array('CRM_Utils_Sort', 'cmpFunc')); $this->assign('allTabs', $allTabs); // hook for contact summary // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW; CRM_Utils_Hook::summary($this->_contactId, $content, $contentPlacement); if ($content) { $this->assign_by_ref('hookContent', $content); $this->assign('hookContentPlacement', $contentPlacement); } }
/** * Get the configure action links for this page. * * @return array */ public function &configureActionLinks() { // check if variable _actionsLinks is populated if (!isset(self::$_configureActionLinks)) { $urlString = 'civicrm/admin/contribute/'; $urlParams = 'reset=1&action=update&id=%%id%%'; self::$_configureActionLinks = array(CRM_Core_Action::ADD => array('name' => ts('Title and Settings'), 'title' => ts('Title and Settings'), 'url' => $urlString . 'settings', 'qs' => $urlParams, 'uniqueName' => 'settings'), CRM_Core_Action::UPDATE => array('name' => ts('Contribution Amounts'), 'title' => ts('Contribution Amounts'), 'url' => $urlString . 'amount', 'qs' => $urlParams, 'uniqueName' => 'amount'), CRM_Core_Action::VIEW => array('name' => ts('Membership Settings'), 'title' => ts('Membership Settings'), 'url' => $urlString . 'membership', 'qs' => $urlParams, 'uniqueName' => 'membership'), CRM_Core_Action::EXPORT => array('name' => ts('Thank-you and Receipting'), 'title' => ts('Thank-you and Receipting'), 'url' => $urlString . 'thankyou', 'qs' => $urlParams, 'uniqueName' => 'thankyou'), CRM_Core_Action::BASIC => array('name' => ts('Tell a Friend'), 'title' => ts('Tell a Friend'), 'url' => $urlString . 'friend', 'qs' => $urlParams, 'uniqueName' => 'friend'), CRM_Core_Action::PROFILE => array('name' => ts('Include Profiles'), 'title' => ts('Include Profiles'), 'url' => $urlString . 'custom', 'qs' => $urlParams, 'uniqueName' => 'custom'), CRM_Core_Action::MAP => array('name' => ts('Contribution Widget'), 'title' => ts('Contribution Widget'), 'url' => $urlString . 'widget', 'qs' => $urlParams, 'uniqueName' => 'widget'), CRM_Core_Action::FOLLOWUP => array('name' => ts('Premiums'), 'title' => ts('Premiums'), 'url' => $urlString . 'premium', 'qs' => $urlParams, 'uniqueName' => 'premium'), CRM_Core_Action::ADVANCED => array('name' => ts('Personal Campaign Pages'), 'title' => ts('Personal Campaign Pages'), 'url' => $urlString . 'pcp', 'qs' => $urlParams, 'uniqueName' => 'pcp')); $context = array('urlString' => $urlString, 'urlParams' => $urlParams); CRM_Utils_Hook::tabset('civicrm/admin/contribute', self::$_configureActionLinks, $context); } return self::$_configureActionLinks; }
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; }