Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 /**
  * 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)));
 }
Ejemplo n.º 5
0
 /**
  * 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);
 }
Ejemplo n.º 6
0
 /**
  * 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();
 }
Ejemplo n.º 7
0
 /**
  * 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'));
 }
Ejemplo n.º 8
0
 /**
  * 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();
 }