public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); if ($this->_surveyId) { $this->_single = TRUE; $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); $this->_surveyTitle = $surveyInfo['title']; $this->assign('surveyTitle', $this->_surveyTitle); CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle))); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->set('type', 'Event'); $this->set('entityId', $this->_surveyId); CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel')); CRM_Campaign_Form_Survey_TabHeader::build($this); }
/** * Spot check a few fields that should appear in schema */ function testGetSchema() { $schema = CRM_UF_Page_ProfileEditor::getSchema(array('IndividualModel', 'ActivityModel')); foreach ($schema as $entityName => $entityDef) { foreach ($entityDef['schema'] as $fieldName => $fieldDef) { $this->assertNotEmpty($fieldDef['type']); $this->assertNotEmpty($fieldDef['title']); $this->assertNotEmpty($fieldDef['civiFieldType']); } } $this->assertEquals('Individual', $schema['IndividualModel']['schema']['first_name']['civiFieldType']); $this->assertTrue(empty($schema['IndividualModel']['schema']['first_name']['civiIsLocation'])); $this->assertTrue(empty($schema['IndividualModel']['schema']['first_name']['civiIsPhone'])); $this->assertEquals('Contact', $schema['IndividualModel']['schema']['street_address']['civiFieldType']); $this->assertNotEmpty($schema['IndividualModel']['schema']['street_address']['civiIsLocation']); $this->assertTrue(empty($schema['IndividualModel']['schema']['street_address']['civiIsPhone'])); $this->assertEquals('Contact', $schema['IndividualModel']['schema']['phone_and_ext']['civiFieldType']); $this->assertNotEmpty($schema['IndividualModel']['schema']['phone_and_ext']['civiIsLocation']); $this->assertNotEmpty($schema['IndividualModel']['schema']['phone_and_ext']['civiIsPhone']); $this->assertEquals('Activity', $schema['ActivityModel']['schema']['activity_subject']['civiFieldType']); $this->assertTrue(empty($schema['ActivityModel']['schema']['activity_subject']['civiIsLocation'])); $this->assertTrue(empty($schema['ActivityModel']['schema']['activity_subject']['civiIsPhone'])); // don't mix up contacts and activities $this->assertTrue(empty($schema['IndividualModel']['schema']['activity_subject'])); $this->assertTrue(empty($schema['ActivityModel']['schema']['street_address'])); }
/** * Register entity schemas for use in the editor's palette * * @param array $entityTypes * Strings, e.g. "IndividualModel", "ActivityModel". */ public static function registerSchemas($entityTypes) { // TODO in cases where registerSchemas is called multiple times for same entity, be more efficient CRM_Core_Resources::singleton()->addSettingsFactory(function () use($entityTypes) { return array('civiSchema' => CRM_UF_Page_ProfileEditor::getSchema($entityTypes)); }); }
/** * @param $form * * @return array */ static function build(&$form) { $tabs = $form->get('tabHeader'); if (!$tabs || empty($_GET['reset'])) { $tabs = self::process($form); $form->set('tabHeader', $tabs); } $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')->addSetting(array('tabSettings' => array('active' => self::getCurrentTab($tabs)))); // Preload libraries required by Online Registration Include Profiles $schemas = array('IndividualModel', 'ParticipantModel'); if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) { $schemas[] = 'MembershipModel'; } CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas($schemas); return $tabs; }
function run() { $wid = CRM_Utils_Request::retrieve('wid', 'Positive', $this, false, 0); if ($wid) { $wsql = "SELECT * FROM civicrm_workflow WHERE id = {$wid} LIMIT 1"; $dao =& CRM_Core_DAO::executeQuery($wsql); if (!$dao->fetch()) { $workflow = null; } else { $workflow = (array) $dao; } $dsql = "SELECT * FROM civicrm_workflow_detail WHERE workflow_id = {$wid} ORDER BY `order`"; $dao =& CRM_Core_DAO::executeQuery($dsql); $details = array(); while ($dao->fetch()) { $details[$dao->order] = (array) $dao; if ($dao->entity_table == "Profile") { $result = civicrm_api3('UFGroup', 'get', array('sequential' => 1, 'return' => "title", 'id' => $dao->entity_id)); $details[$dao->order]['name'] = $result['values'][0]['title']; } if ($dao->entity_table == "Page") { $result = civicrm_api3('ContributionPage', 'get', array('sequential' => 1, 'return' => "title", 'id' => $dao->entity_id)); $details[$dao->order]['name'] = $result['values'][0]['title']; } } CRM_Utils_System::setTitle(ts("Details for " . $workflow['name'] . ":")); } else { $workflow = null; $details = array(); } $result = civicrm_api3('ContributionPage', 'get', array('sequential' => 1, 'return' => array("id", "title"))); $pages = $result['values']; $this->assign("pages", $pages); $this->assign('workflow', $workflow); $this->assign('details', $details); //Add Stylesheet CRM_Core_Resources::singleton()->addStyleFile('org.botany.workflow', 'workflow_profiles.css'); CRM_UF_Page_ProfileEditor::registerProfileScripts(); parent::run(); }
public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); if ($this->_surveyId) { $this->_single = TRUE; $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); $this->_surveyTitle = $surveyInfo['title']; $this->assign('surveyTitle', $this->_surveyTitle); CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle))); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel')); CRM_Campaign_Form_Survey_TabHeader::build($this); }
/** * Add a widget for selecting/editing/creating/copying a profile form * * @param string $name * HTML form-element name. * @param string $label * Printable label. * @param string $allowCoreTypes * Only present a UFGroup if its group_type includes a subset of $allowCoreTypes; e.g. 'Individual', 'Activity'. * @param string $allowSubTypes * Only present a UFGroup if its group_type is compatible with $allowSubypes. * @param array $entities * @param bool $default * //CRM-15427. */ public function addProfileSelector($name, $label, $allowCoreTypes, $allowSubTypes, $entities, $default = FALSE, $usedFor = NULL) { // Output widget // FIXME: Instead of adhoc serialization, use a single json_encode() CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(CRM_Utils_Array::collect('entity_type', $entities)); $this->add('text', $name, $label, array('class' => 'crm-profile-selector', 'data-group-type' => CRM_Core_BAO_UFGroup::encodeGroupType($allowCoreTypes, $allowSubTypes, ';;'), 'data-entities' => json_encode($entities), 'data-default' => $default, 'data-usedfor' => json_encode($usedFor))); }
/** * Set variables up before form is built. * * @return void */ public function preProcess() { // current contribution page id $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'REQUEST'); $this->assign('contributionPageID', $this->_id); // get the requested action $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // setting title and 3rd level breadcrumb for html page if contrib page exists if ($this->_id) { $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title'); if ($this->_action == CRM_Core_Action::UPDATE) { $this->_single = TRUE; } } // CRM-16776 - show edit/copy/create buttons on Profiles Tab if user has required permission. if (CRM_Core_Permission::check('administer CiviCRM')) { $this->assign('perm', TRUE); } // set up tabs CRM_Contribute_Form_ContributionPage_TabHeader::build($this); if ($this->_action == CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Configure Page - %1', array(1 => $title))); } elseif ($this->_action == CRM_Core_Action::VIEW) { CRM_Utils_System::setTitle(ts('Preview Page - %1', array(1 => $title))); } elseif ($this->_action == CRM_Core_Action::DELETE) { CRM_Utils_System::setTitle(ts('Delete Page - %1', array(1 => $title))); } //cache values. $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if (isset($this->_id) && $this->_id) { $params = array('id' => $this->_id); CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values); } $this->set('values', $this->_values); } // Preload libraries required by the "Profiles" tab $schemas = array('IndividualModel', 'OrganizationModel', 'ContributionModel'); if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) { $schemas[] = 'MembershipModel'; } CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas($schemas); }
/** * Build the form object. */ public function buildQuickForm() { $this->_first = TRUE; $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage'); // financial Type $this->addSelect('financial_type_id', array(), TRUE); // name $this->add('text', 'title', ts('Title'), $attributes['title'], TRUE); //CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); $this->add('wysiwyg', 'intro_text', ts('Introductory Message'), $attributes['intro_text']); $this->add('wysiwyg', 'footer_text', ts('Footer Message'), $attributes['footer_text']); //Register schema which will be used for OnBehalOf and HonorOf profile Selector CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel', 'HouseholdModel')); // is on behalf of an organization ? $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);")); //CRM-15787 - If applicable, register 'membership_1' $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); $coreTypes = array('Contact', 'Organization'); $entities[] = array('entity_name' => array('contact_1'), 'entity_type' => 'OrganizationModel'); if ($member && $member['is_active']) { $coreTypes[] = 'Membership'; $entities[] = array('entity_name' => array('membership_1'), 'entity_type' => 'MembershipModel'); } $allowCoreTypes = array_merge($coreTypes, CRM_Contact_BAO_ContactType::subTypes('Organization')); $allowSubTypes = array(); $this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities); $options = array(); $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1); $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2); $this->addGroup($options, 'is_for_organization', ''); $this->add('textarea', 'for_organization', ts('On behalf of Label'), array('rows' => 2, 'cols' => 50)); // collect goal amount $this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12)); $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // is confirmation page enabled? $this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?')); // is this page shareable through social media ? $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); // is this page active ? $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?')); // should the honor be enabled $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()")); $this->add('text', 'honor_block_title', ts('Honoree Section Title'), array('maxlength' => 255, 'size' => 45)); $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), array('rows' => 2, 'cols' => 50)); $this->addSelect('soft_credit_types', array('label' => ts('Honor Types'), 'entity' => 'ContributionSoft', 'field' => 'soft_credit_type_id', 'multiple' => TRUE, 'class' => 'huge')); $entities = array(array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel')); $allowCoreTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $allowSubTypes = array(); $this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities); if (!empty($this->_submitValues['honor_block_is_active'])) { $this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required'); $this->addRule('honoree_profile', ts('Please select a profile used for honoree'), 'required'); } // add optional start and end dates $this->addDateTime('start_date', ts('Start Date')); $this->addDateTime('end_date', ts('End Date')); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'), $this); parent::buildQuickForm(); }
/** * Pre-load libraries required by Online Registration Profile fields */ public static function addProfileEditScripts() { CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ParticipantModel')); }
<?php CRM_UF_Page_ProfileEditor::registerProfileScripts();
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $this->_first = TRUE; $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage'); // financial Type $this->addSelect('financial_type_id', array(), TRUE); // name $this->add('text', 'title', ts('Title'), $attributes['title'], TRUE); //CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); $this->addWysiwyg('intro_text', ts('Introductory Message'), $attributes['intro_text']); $this->addWysiwyg('footer_text', ts('Footer Message'), $attributes['footer_text']); // is on behalf of an organization ? $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);")); $required = array('Contact', 'Organization'); $optional = array('Contribution', 'Membership'); $profiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional); //Check profiles for Organization subtypes $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); foreach ($contactSubType as $type) { $required = array('Contact', $type); $subTypeProfiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional); foreach ($subTypeProfiles as $profileId => $profileName) { $profiles[$profileId] = $profileName; } } $requiredProfileFields = array('organization_name', 'email'); if (!empty($profiles)) { foreach ($profiles as $id => $dontCare) { $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($id, $requiredProfileFields); if (!$validProfile) { unset($profiles[$id]); } } } if (empty($profiles)) { $invalidProfiles = TRUE; $this->assign('invalidProfiles', $invalidProfiles); } $this->add('select', 'onbehalf_profile_id', ts('Organization Profile'), array('' => ts('- select -')) + $profiles); $options = array(); $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1); $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2); $this->addGroup($options, 'is_for_organization', ts('')); $this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']); // collect goal amount $this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12)); $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // is confirmation page enabled? $this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?')); // is this page shareable through social media ? $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); // is this page active ? $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?')); // should the honor be enabled $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()")); $this->add('text', 'honor_block_title', ts('Honoree Section Title'), array('maxlength' => 255, 'size' => 45)); $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), array('rows' => 2, 'cols' => 50)); $softCreditTypes =& $this->add('select', 'soft_credit_types', ts('Honor Types'), CRM_Core_OptionGroup::values("soft_credit_type", FALSE), FALSE, array('id' => 'soft_credit_types', 'multiple' => 'multiple', 'class' => 'crm-select2')); $entities = array(array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel')); $allowCoreTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $allowSubTypes = array(); $this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities); CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel', 'HouseholdModel')); if (!empty($this->_submitValues['honor_block_is_active'])) { $this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required'); $this->addRule('honoree_profile', ts('Please select a profile used for honoree'), 'required'); } // add optional start and end dates $this->addDateTime('start_date', ts('Start Date')); $this->addDateTime('end_date', ts('End Date')); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'), $this); parent::buildQuickForm(); }