当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_ShowHideBlocks::addHide方法代码示例

本文整理汇总了PHP中CRM_Core_ShowHideBlocks::addHide方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_ShowHideBlocks::addHide方法的具体用法?PHP CRM_Core_ShowHideBlocks::addHide怎么用?PHP CRM_Core_ShowHideBlocks::addHide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_ShowHideBlocks的用法示例。


在下文中一共展示了CRM_Core_ShowHideBlocks::addHide方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param array   $defaults the array of default values
  * @param boolean $force    should we set show hide based on input defaults
  *
  * @return void
  */
 function setShowHide(&$defaults)
 {
     require_once 'CRM/Core/ShowHideBlocks.php';
     $this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
     if (empty($defaults)) {
         $this->_showHide->addShow('registration_screen_show');
         $this->_showHide->addShow('confirm_show');
         $this->_showHide->addShow('mail_show');
         $this->_showHide->addShow('thankyou_show');
         $this->_showHide->addHide('registration');
         $this->_showHide->addHide('registration_screen');
         $this->_showHide->addHide('confirm');
         $this->_showHide->addHide('mail');
         $this->_showHide->addHide('thankyou');
         $this->_showHide->addHide('additional_profile_pre');
         $this->_showHide->addHide('additional_profile_post');
         $this->_showHide->addHide('id-approval-text');
     } else {
         $this->_showHide->addShow('confirm');
         $this->_showHide->addShow('mail');
         $this->_showHide->addShow('thankyou');
         $this->_showHide->addHide('registration_screen_show');
         $this->_showHide->addHide('confirm_show');
         $this->_showHide->addHide('mail_show');
         $this->_showHide->addHide('thankyou_show');
         if (!$defaults['is_multiple_registrations']) {
             $this->_showHide->addHide('additional_profile_pre');
             $this->_showHide->addHide('additional_profile_post');
         }
         if (!CRM_Utils_Array::value('requires_approval', $defaults)) {
             $this->_showHide->addHide('id-approval-text');
         }
     }
     $this->_showHide->addToTemplate();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:43,代码来源:Registration.php

示例2: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param array $defaults
  *   The array of default values.
  *
  * @return void
  */
 public function setShowHide($defaults)
 {
     $this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
     if (empty($defaults)) {
         $this->_showHide->addHide('registration');
         $this->_showHide->addHide('id-approval-text');
     } else {
         if (empty($defaults['requires_approval'])) {
             $this->_showHide->addHide('id-approval-text');
         }
     }
     $this->assign('defaultsEmpty', empty($defaults));
     $this->_showHide->addToTemplate();
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:22,代码来源:Registration.php

示例3: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param    array    array of Group Titles
  * @param    array    array of Group Collapse Display 
  *
  * @return   
  *
  * @access   protected
  */
 function setShowHide(&$groupTitle, &$groupCollapseDisplay)
 {
     if (empty($groupTitle)) {
         return;
     }
     $this->_showHide =& new CRM_Core_ShowHideBlocks('', '');
     foreach ($groupTitle as $key => $title) {
         $showBlocks = $title . '[show]';
         $hideBlocks = $title;
         if ($groupCollapseDisplay[$key]) {
             $this->_showHide->addShow($showBlocks);
             $this->_showHide->addHide($hideBlocks);
         } else {
             $this->_showHide->addShow($hideBlocks);
             $this->_showHide->addHide($showBlocks);
         }
     }
     $this->_showHide->addToTemplate();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:29,代码来源:CustomData.php

示例4: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param array   $defaults the array of default values
  * @param boolean $force    should we set show hide based on input defaults
  *
  * @return void
  */
 function setShowHide($defaults)
 {
     $this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
     if (empty($defaults)) {
         $this->_showHide->addHide('registration');
         $this->_showHide->addHide('additional_profile_pre');
         $this->_showHide->addHide('additional_profile_post');
         $this->_showHide->addHide('id-approval-text');
     } else {
         if (!CRM_Utils_Array::value('is_multiple_registrations', $defaults)) {
             $this->_showHide->addHide('additional_profile_pre');
             $this->_showHide->addHide('additional_profile_post');
         }
         if (!CRM_Utils_Array::value('requires_approval', $defaults)) {
             $this->_showHide->addHide('id-approval-text');
         }
     }
     $this->assign('defaultsEmpty', empty($defaults));
     $this->_showHide->addToTemplate();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:28,代码来源:Registration.php

示例5: setDefaultValues

 /**
  * Set default values for the form.
  */
 public function setDefaultValues()
 {
     $defaults = array();
     // check if there is a widget already created
     if ($this->_widget) {
         CRM_Core_DAO::storeValues($this->_widget, $defaults);
     } else {
         foreach ($this->_fields as $name => $val) {
             $defaults[$name] = $val[3];
         }
         foreach ($this->_colorFields as $name => $val) {
             $defaults[$name] = $val[3];
         }
         $defaults['about'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'intro_text');
     }
     $showHide = new CRM_Core_ShowHideBlocks();
     $showHide->addHide('id-colors');
     $showHide->addToTemplate();
     return $defaults;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:23,代码来源:Widget.php

示例6: setDefaultValues

 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     // check that the user has permission to access mailing id
     CRM_Mailing_BAO_Mailing::checkPermission($mailingID);
     $defaults = array();
     if ($mailingID) {
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $mailingID;
         $mailing->addSelect('name', 'campaign_id');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $mailingID);
         }
         $defaults['campaign_id'] = $mailing->campaign_id;
         $defaults['dedupe_email'] = $mailing->dedupe_email;
         $dao = new CRM_Mailing_DAO_Group();
         $mailingGroups = array();
         $dao->mailing_id = $mailingID;
         $dao->find();
         while ($dao->fetch()) {
             $mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         $defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
         $defaults['excludeMailings'] = $mailingGroups['civicrm_mailing']['Exclude'];
     }
     //when the context is search hide the mailing recipients.
     $showHide = new CRM_Core_ShowHideBlocks();
     $showGroupSelector = TRUE;
     if ($this->_searchBasedMailing) {
         $showGroupSelector = FALSE;
         $formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
         $formValues = $this->controller->exportValues($this->_name);
         foreach ($formElements as $element) {
             if (!empty($formValues[$element])) {
                 $showGroupSelector = TRUE;
                 break;
             }
         }
     }
     if ($showGroupSelector) {
         $showHide->addShow("id-additional");
         $showHide->addHide("id-additional-show");
     } else {
         $showHide->addShow("id-additional-show");
         $showHide->addHide("id-additional");
     }
     $showHide->addToTemplate();
     return $defaults;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:65,代码来源:Group.php

示例7: formRule


//.........这里部分代码省略.........
                 if ($fields['option_value'][$i]) {
                     $errors['option_label[' . $i . ']'] = ts('Option label cannot be empty');
                     $_flagOption = 1;
                 } else {
                     $_emptyRow = 1;
                 }
             } else {
                 if (!strlen(trim($fields['option_value'][$i]))) {
                     if (!$fields['option_value'][$i]) {
                         $errors['option_value[' . $i . ']'] = ts('Option value cannot be empty');
                         $_flagOption = 1;
                     }
                 }
             }
             if ($fields['option_value'][$i] && $dataType != 'String') {
                 if ($dataType == 'Int') {
                     if (!CRM_Utils_Rule::integer($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid integer.');
                     }
                 } elseif ($dataType == 'Money') {
                     if (!CRM_Utils_Rule::money($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid money value.');
                     }
                 } else {
                     if (!CRM_Utils_Rule::numeric($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid number.');
                     }
                 }
             }
             $showBlocks = 'optionField_' . $i;
             if ($_flagOption) {
                 $_showHide->addShow($showBlocks);
                 $_rowError = 1;
             }
             if (!empty($_emptyRow)) {
                 $_showHide->addHide($showBlocks);
             } else {
                 $_showHide->addShow($showBlocks);
             }
             if ($i == self::NUM_OPTION) {
                 $hideBlock = 'additionalOption';
                 $_showHide->addHide($hideBlock);
             }
             $_flagOption = $_emptyRow = 0;
         }
     } elseif (isset($dataField) && in_array($dataField, $optionFields) && !in_array($dataType, array('Boolean', 'Country', 'StateProvince'))) {
         if (!$fields['option_group_id']) {
             $errors['option_group_id'] = ts('You must select a Multiple Choice Option set if you chose Reuse an existing set.');
         } else {
             $query = "\nSELECT count(*)\nFROM   civicrm_custom_field\nWHERE  data_type != %1\nAND    option_group_id = %2";
             $params = array(1 => array(self::$_dataTypeKeys[$fields['data_type'][0]], 'String'), 2 => array($fields['option_group_id'], 'Integer'));
             $count = CRM_Core_DAO::singleValueQuery($query, $params);
             if ($count > 0) {
                 $errors['option_group_id'] = ts('The data type of the multiple choice option set you\'ve selected does not match the data type assigned to this field.');
             }
         }
     }
     $assignError = new CRM_Core_Page();
     if ($_rowError) {
         $_showHide->addToTemplate();
         $assignError->assign('optionRowError', $_rowError);
     } else {
         if (isset($fields['data_type'][1])) {
             switch (self::$_dataToHTML[$fields['data_type'][0]][$fields['data_type'][1]]) {
                 case 'Radio':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 case 'Checkbox':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 case 'Select':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 default:
                     $_fieldError = 0;
                     $assignError->assign('fieldError', $_fieldError);
             }
         }
         for ($idx = 1; $idx <= self::NUM_OPTION; $idx++) {
             $showBlocks = 'optionField_' . $idx;
             if (!empty($fields['option_label'][$idx])) {
                 $_showHide->addShow($showBlocks);
             } else {
                 $_showHide->addHide($showBlocks);
             }
         }
         $_showHide->addToTemplate();
     }
     // we can not set require and view at the same time.
     if (CRM_Utils_Array::value('is_required', $fields) && CRM_Utils_Array::value('is_view', $fields)) {
         $errors['is_view'] = ts('Can not set this field Required and View Only at the same time.');
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Field.php

示例8: preProcessOrderBy

 /**
  * Check for empty order_by configurations and remove them.
  *
  * Also set template to hide them.
  *
  * @param array $formValues
  */
 public function preProcessOrderBy(&$formValues)
 {
     // Object to show/hide form elements
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     $_showHide->addShow('optionField_1');
     // Cycle through order_by options; skip any empty ones, and hide them as well
     $n = 1;
     if (!empty($formValues['order_bys'])) {
         foreach ($formValues['order_bys'] as $order_by) {
             if ($order_by['column'] && $order_by['column'] != '-') {
                 $_showHide->addShow('optionField_' . $n);
                 $orderBys[$n] = $order_by;
                 $n++;
             }
         }
     }
     for ($i = $n; $i <= 5; $i++) {
         if ($i > 1) {
             $_showHide->addHide('optionField_' . $i);
         }
     }
     // overwrite order_by options with modified values
     if (!empty($orderBys)) {
         $formValues['order_bys'] = $orderBys;
     } else {
         $formValues['order_bys'] = array(1 => array('column' => '-'));
     }
     // assign show/hide data to template
     $_showHide->addToTemplate();
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:37,代码来源:Form.php

示例9: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param CRM_Core_Form $form
  *
  * @return array
  *   if errors then list of errors to be posted back to the form,
  *                  true otherwise
  */
 public static function formRule($fields, $files, $form)
 {
     // all option fields are of type "money"
     $errors = array();
     /** Check the option values entered
      *  Appropriate values are required for the selected datatype
      *  Incomplete row checking is also required.
      */
     if (($form->_action & CRM_Core_Action::ADD || $form->_action & CRM_Core_Action::UPDATE) && $fields['html_type'] == 'Text' && $fields['price'] == NULL) {
         $errors['price'] = ts('Price is a required field');
     }
     if (($form->_action & CRM_Core_Action::ADD || $form->_action & CRM_Core_Action::UPDATE) && $fields['html_type'] == 'Text' && $fields['financial_type_id'] == '') {
         $errors['financial_type_id'] = ts('Financial Type is a required field');
     }
     //avoid the same price field label in Within PriceSet
     $priceFieldLabel = new CRM_Price_DAO_PriceField();
     $priceFieldLabel->label = $fields['label'];
     $priceFieldLabel->price_set_id = $form->_sid;
     $dupeLabel = FALSE;
     if ($priceFieldLabel->find(TRUE) && $form->_fid != $priceFieldLabel->id) {
         $dupeLabel = TRUE;
     }
     if ($dupeLabel) {
         $errors['label'] = ts('Name already exists in Database.');
     }
     if (is_numeric(CRM_Utils_Array::value('count', $fields)) && CRM_Utils_Array::value('count', $fields) == 0 && CRM_Utils_Array::value('html_type', $fields) == 'Text') {
         $errors['count'] = ts('Participant Count must be greater than zero.');
     }
     if ($form->_action & CRM_Core_Action::ADD) {
         if ($fields['html_type'] != 'Text') {
             $countemptyrows = 0;
             $_flagOption = $_rowError = 0;
             $_showHide = new CRM_Core_ShowHideBlocks('', '');
             for ($index = 1; $index <= self::NUM_OPTION; $index++) {
                 $noLabel = $noAmount = $noWeight = 1;
                 if (!empty($fields['option_label'][$index])) {
                     $noLabel = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_label'][$index], $fields['option_label']);
                     if (!($duplicateIndex === FALSE) && !($duplicateIndex == $index)) {
                         $errors["option_label[{$index}]"] = ts('Duplicate label value');
                         $_flagOption = 1;
                     }
                 }
                 if ($form->_useForMember) {
                     if (!empty($fields['membership_type_id'][$index])) {
                         $memTypesIDS[] = $fields['membership_type_id'][$index];
                     }
                 }
                 // allow for 0 value.
                 if (!empty($fields['option_amount'][$index]) || strlen($fields['option_amount'][$index]) > 0) {
                     $noAmount = 0;
                 }
                 if (!empty($fields['option_weight'][$index])) {
                     $noWeight = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_weight'][$index], $fields['option_weight']);
                     if (!($duplicateIndex === FALSE) && !($duplicateIndex == $index)) {
                         $errors["option_weight[{$index}]"] = ts('Duplicate weight value');
                         $_flagOption = 1;
                     }
                 }
                 if (!$noLabel && !$noAmount && !empty($fields['option_financial_type_id']) && $fields['option_financial_type_id'][$index] == '' && $fields['html_type'] != 'Text') {
                     $errors["option_financial_type_id[{$index}]"] = ts('Financial Type is a Required field.');
                 }
                 if ($noLabel && !$noAmount) {
                     $errors["option_label[{$index}]"] = ts('Label cannot be empty.');
                     $_flagOption = 1;
                 }
                 if (!$noLabel && $noAmount) {
                     $errors["option_amount[{$index}]"] = ts('Amount cannot be empty.');
                     $_flagOption = 1;
                 }
                 if ($noLabel && $noAmount) {
                     $countemptyrows++;
                     $_emptyRow = 1;
                 } elseif (!empty($fields['option_max_value'][$index]) && !empty($fields['option_count'][$index]) && $fields['option_count'][$index] > $fields['option_max_value'][$index]) {
                     $errors["option_max_value[{$index}]"] = ts('Participant count can not be greater than max participants.');
                     $_flagOption = 1;
                 }
                 $showBlocks = 'optionField_' . $index;
                 if ($_flagOption) {
                     $_showHide->addShow($showBlocks);
                     $_rowError = 1;
                 }
                 if (!empty($_emptyRow)) {
                     $_showHide->addHide($showBlocks);
                 } else {
                     $_showHide->addShow($showBlocks);
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Field.php

示例10: formRule

 /**
  * global validation rules for the form
  *
  * @param array  $fields   (referance) posted values of the form
  *
  * @return array    if errors then list of errors to be posted back to the form,
  *                  true otherwise
  * @static
  * @access public
  */
 static function formRule($fields, $files, $form)
 {
     // all option fields are of type "money"
     $errors = array();
     /** Check the option values entered
      *  Appropriate values are required for the selected datatype
      *  Incomplete row checking is also required.
      */
     if (($form->_action & CRM_Core_Action::ADD || $form->_action & CRM_Core_Action::UPDATE) && $fields['html_type'] == 'Text' && $fields['price'] == NULL) {
         $errors['price'] = ts('Price is a required field');
     }
     //avoid the same price field label in Within PriceSet
     $priceFieldLabel = new CRM_Price_DAO_Field();
     $priceFieldLabel->label = $fields['label'];
     $priceFieldLabel->price_set_id = $form->_sid;
     $dupeLabel = false;
     if ($priceFieldLabel->find(true) && $form->_fid != $priceFieldLabel->id) {
         $dupeLabel = true;
     }
     if ($dupeLabel) {
         $errors['label'] = ts('Name already exists in Database.');
     }
     if (is_numeric(CRM_Utils_Array::value('count', $fields)) && CRM_Utils_Array::value('count', $fields) == 0 && CRM_Utils_Array::value('html_type', $fields) == 'Text') {
         $errors['count'] = ts('Participant Count must be greater than zero.');
     }
     if ($form->_action & CRM_Core_Action::ADD) {
         if ($fields['html_type'] != 'Text') {
             $countemptyrows = 0;
             $_flagOption = $_rowError = 0;
             $_showHide = new CRM_Core_ShowHideBlocks('', '');
             for ($index = 1; $index <= self::NUM_OPTION; $index++) {
                 $noLabel = $noAmount = $noWeight = 1;
                 if (!empty($fields['option_label'][$index])) {
                     $noLabel = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_label'][$index], $fields['option_label']);
                     if (!($duplicateIndex === false) && !($duplicateIndex == $index)) {
                         $errors["option_label[{$index}]"] = ts('Duplicate label value');
                         $_flagOption = 1;
                     }
                 }
                 // allow for 0 value.
                 if (!empty($fields['option_amount'][$index]) || strlen($fields['option_amount'][$index]) > 0) {
                     $noAmount = 0;
                 }
                 if (!empty($fields['option_weight'][$index])) {
                     $noWeight = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_weight'][$index], $fields['option_weight']);
                     if (!($duplicateIndex === false) && !($duplicateIndex == $index)) {
                         $errors["option_weight[{$index}]"] = ts('Duplicate weight value');
                         $_flagOption = 1;
                     }
                 }
                 if ($noLabel && !$noAmount) {
                     $errors["option_label[{$index}]"] = ts('Label cannot be empty.');
                     $_flagOption = 1;
                 }
                 if (!$noLabel && $noAmount) {
                     $errors["option_amount[{$index}]"] = ts('Amount cannot be empty.');
                     $_flagOption = 1;
                 }
                 if ($noLabel && $noAmount) {
                     $countemptyrows++;
                     $_emptyRow = 1;
                 } else {
                     if (!empty($fields['option_max_value'][$index]) && !empty($fields['option_count'][$index]) && $fields['option_count'][$index] > $fields['option_max_value'][$index]) {
                         $errors["option_max_value[{$index}]"] = ts('Participant count can not be greater than max participants.');
                         $_flagOption = 1;
                     }
                 }
                 $showBlocks = 'optionField_' . $index;
                 if ($_flagOption) {
                     $_showHide->addShow($showBlocks);
                     $_rowError = 1;
                 }
                 if (!empty($_emptyRow)) {
                     $_showHide->addHide($showBlocks);
                 } else {
                     $_showHide->addShow($showBlocks);
                 }
                 if ($index == self::NUM_OPTION) {
                     $hideBlock = 'additionalOption';
                     $_showHide->addHide($hideBlock);
                 }
                 $_flagOption = $_emptyRow = 0;
             }
             $_showHide->addToTemplate();
             if ($countemptyrows == 11) {
                 $errors["option_label[1]"] = $errors["option_amount[1]"] = ts('Label and value cannot be empty.');
                 $_flagOption = 1;
             }
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Field.php

示例11: formRule

 /**
  * global validation rules for the form
  *
  */
 static function formRule($fields, $files, $form)
 {
     $errors = array();
     if (CRM_Utils_Array::value('option_label', $fields) && CRM_Utils_Array::value('option_value', $fields) && count(array_filter($fields['option_label'])) == 0 && count(array_filter($fields['option_value'])) == 0) {
         $errors['option_label[1]'] = ts('Enter atleast one response option.');
         return $errors;
     } else {
         if (!CRM_Utils_Array::value('option_label', $fields) && !CRM_Utils_Array::value('option_value', $fields)) {
             return $errors;
         }
     }
     if ($fields['option_type'] == 2 && !CRM_Utils_Array::value('option_group_id', $fields)) {
         $errors['option_group_id'] = ts("Please select Survey Response set.");
         return $errors;
     }
     $_flagOption = $_rowError = 0;
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     //capture duplicate Custom option values
     if (!empty($fields['option_value'])) {
         $countValue = count($fields['option_value']);
         $uniqueCount = count(array_unique($fields['option_value']));
         if ($countValue > $uniqueCount) {
             $start = 1;
             while ($start < self::NUM_OPTION) {
                 $nextIndex = $start + 1;
                 while ($nextIndex <= self::NUM_OPTION) {
                     if ($fields['option_value'][$start] == $fields['option_value'][$nextIndex] && !empty($fields['option_value'][$nextIndex])) {
                         $errors['option_value[' . $start . ']'] = ts('Duplicate Option values');
                         $errors['option_value[' . $nextIndex . ']'] = ts('Duplicate Option values');
                         $_flagOption = 1;
                     }
                     $nextIndex++;
                 }
                 $start++;
             }
         }
     }
     //capture duplicate Custom Option label
     if (!empty($fields['option_label'])) {
         $countValue = count($fields['option_label']);
         $uniqueCount = count(array_unique($fields['option_label']));
         if ($countValue > $uniqueCount) {
             $start = 1;
             while ($start < self::NUM_OPTION) {
                 $nextIndex = $start + 1;
                 while ($nextIndex <= self::NUM_OPTION) {
                     if ($fields['option_label'][$start] == $fields['option_label'][$nextIndex] && !empty($fields['option_label'][$nextIndex])) {
                         $errors['option_label[' . $start . ']'] = ts('Duplicate Option label');
                         $errors['option_label[' . $nextIndex . ']'] = ts('Duplicate Option label');
                         $_flagOption = 1;
                     }
                     $nextIndex++;
                 }
                 $start++;
             }
         }
     }
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         if (!$fields['option_label'][$i]) {
             if ($fields['option_value'][$i]) {
                 $errors['option_label[' . $i . ']'] = ts('Option label cannot be empty');
                 $_flagOption = 1;
             } else {
                 $_emptyRow = 1;
             }
         } else {
             if (!strlen(trim($fields['option_value'][$i]))) {
                 if (!$fields['option_value'][$i]) {
                     $errors['option_value[' . $i . ']'] = ts('Option value cannot be empty');
                     $_flagOption = 1;
                 }
             }
         }
         if (CRM_Utils_Array::value($i, $fields['option_interval']) && !CRM_Utils_Rule::integer($fields['option_interval'][$i])) {
             $_flagOption = 1;
             $errors['option_interval[' . $i . ']'] = ts('Please enter a valid integer.');
         }
         $showBlocks = 'optionField_' . $i;
         if ($_flagOption) {
             $_showHide->addShow($showBlocks);
             $_rowError = 1;
         }
         if (!empty($_emptyRow)) {
             $_showHide->addHide($showBlocks);
         } else {
             $_showHide->addShow($showBlocks);
         }
         if ($i == self::NUM_OPTION) {
             $hideBlock = 'additionalOption';
             $_showHide->addHide($hideBlock);
         }
         $_flagOption = $_emptyRow = 0;
     }
     $_showHide->addToTemplate();
     return empty($errors) ? true : $errors;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:100,代码来源:Survey.php

示例12: setDefaultValues

 /**
  * Set default values for the form.
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     $defaults = array();
     $defaults['dedupe_email'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'dedupe_email_default', NULL, FALSE);
     if ($this->_mailingID) {
         // check that the user has permission to access mailing id
         CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingID);
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $this->_mailingID;
         $mailing->addSelect('name', 'campaign_id');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $this->_mailingID);
         }
         $defaults['campaign_id'] = $mailing->campaign_id;
         $defaults['dedupe_email'] = $mailing->dedupe_email;
         $defaults['location_type_id'] = $mailing->location_type_id;
         $defaults['email_selection_method'] = $mailing->email_selection_method;
         $dao = new CRM_Mailing_DAO_MailingGroup();
         $mailingGroups = array('civicrm_group' => array(), 'civicrm_mailing' => array());
         $dao->mailing_id = $this->_mailingID;
         $dao->find();
         while ($dao->fetch()) {
             // account for multi-lingual
             // CRM-11431
             $entityTable = 'civicrm_group';
             if (substr($dao->entity_table, 0, 15) == 'civicrm_mailing') {
                 $entityTable = 'civicrm_mailing';
             }
             $mailingGroups[$entityTable][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_group']);
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         if (!empty($mailingGroups['civicrm_mailing'])) {
             $defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
             $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_mailing']);
         }
     }
     //when the context is search hide the mailing recipients.
     $showHide = new CRM_Core_ShowHideBlocks();
     $showGroupSelector = TRUE;
     if ($this->_searchBasedMailing) {
         $showGroupSelector = FALSE;
         $formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
         $formValues = $this->controller->exportValues($this->_name);
         foreach ($formElements as $element) {
             if (!empty($formValues[$element])) {
                 $showGroupSelector = TRUE;
                 break;
             }
         }
     }
     if ($showGroupSelector) {
         $showHide->addShow("id-additional");
         $showHide->addHide("id-additional-show");
     } else {
         $showHide->addShow("id-additional-show");
         $showHide->addHide("id-additional");
     }
     $showHide->addToTemplate();
     return $defaults;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:74,代码来源:Group.php

示例13: updateShowHideSubBlocks

 /**
  * function to show/hide the block
  *
  * @param CRM_Core_ShowHideBlocks $showHide the showHide object
  *
  * @access public
  */
 function updateShowHideSubBlocks(&$showHide, $name, $prefix, &$values)
 {
     if (empty($values)) {
         return;
     }
     $blockKeys = array_keys($values);
     foreach ($blockKeys as $blockId) {
         /* if ( empty( $values[$blockId] ) ) {
                continue;
            }*/
         $blocks = $values[$blockId];
         $blockFlag = false;
         foreach ($blocks as $block) {
             if ($block != '') {
                 $blockFlag = true;
             }
         }
         if (!$blockFlag) {
             continue;
         }
         // blockId 1 is always shows
         if ($blockId == 1) {
             continue;
         }
         $showHide->addShow("{$prefix}[{$name}][{$blockId}]");
         $showHide->addHide("{$prefix}[{$name}][{$blockId}][show]");
         if ($blockId < CRM_CONTACT_FORM_LOCATION_BLOCKS) {
             $nextBlockId = $blockId + 1;
             $showHide->addShow("{$prefix}[{$name}][{$nextBlockId}][show]");
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:39,代码来源:Location.php

示例14: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param array   $defaults the array of default values
  * @param boolean $force    should we set show hide based on input defaults
  *
  * @return void
  */
 function setShowHide(&$defaults, $force)
 {
     $this->_showHide =& new CRM_Core_ShowHideBlocks(array('commPrefs' => 1), '');
     if ($this->_contactType == 'Individual') {
         $this->_showHide->addShow('demographics[show]');
         $this->_showHide->addHide('demographics');
     }
     // first do the defaults showing
     CRM_Contact_Form_Location::setShowHideDefaults($this->_showHide, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS);
     if ($this->_action & CRM_CORE_ACTION_ADD) {
         // notes are only included in the template for New Contact
         $this->_showHide->addShow('notes[show]');
         $this->_showHide->addHide('notes');
     }
     //add group and tags
     $contactGroup = $contactTag = array();
     if ($this->_contactId) {
         $contactGroup =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
         $contactTag =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $this->_contactId);
     }
     if (empty($contactGroup) || empty($contactTag)) {
         $this->_showHide->addShow('group[show]');
         $this->_showHide->addHide('group');
     } else {
         $this->_showHide->addShow('group');
         $this->_showHide->addHide('group[show]');
     }
     // is there any demographics data?
     if (CRM_Utils_Array::value('gender_id', $defaults) || CRM_Utils_Array::value('is_deceased', $defaults) || CRM_Utils_Array::value('birth_date', $defaults)) {
         $this->_showHide->addShow('demographics');
         $this->_showHide->addHide('demographics[show]');
     }
     if ($force) {
         $locationDefaults = CRM_Utils_Array::value('location', $defaults);
         CRM_Contact_Form_Location::updateShowHide($this->_showHide, $locationDefaults, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS);
     }
     $this->_showHide->addToTemplate();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:46,代码来源:Edit.php

示例15: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $this->addYesNo('is_monetary', ts('Paid Event'), NULL, NULL, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);"));
     //add currency element.
     $this->addCurrency('currency', ts('Currency'), FALSE);
     $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor();
     $this->assign('paymentProcessor', $paymentProcessor);
     $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, array('&nbsp;&nbsp;', '&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>'));
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
     // add pay later options
     $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);"));
     $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), FALSE);
     $this->addElement('textarea', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'), FALSE);
     $this->add('text', 'fee_label', ts('Fee Label'));
     $price = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviEvent');
     if (CRM_Utils_System::isNull($price)) {
         $this->assign('price', FALSE);
     } else {
         $this->assign('price', TRUE);
     }
     $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, NULL, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"));
     $default = array();
     $this->add('hidden', "price_field_id", '', array('id' => "price_field_id"));
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         // label
         $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'));
         $this->add('hidden', "price_field_value[{$i}]", '', array('id' => "price_field_value[{$i}]"));
         // value
         $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'));
         $this->addRule("value[{$i}]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
         // default
         $default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
     }
     $this->addGroup($default, 'default');
     $this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL, array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);"));
     $discountSection = $this->get('discountSection');
     $this->assign('discountSection', $discountSection);
     // form fields of Discount sets
     $defaultOption = array();
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) {
         //the show hide blocks
         $showBlocks = 'discount_' . $i;
         if ($i > 2) {
             $_showHide->addHide($showBlocks);
         } else {
             $_showHide->addShow($showBlocks);
         }
         //Increment by 1 of start date of previous end date.
         if (is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i + 1]) && isset($this->_submitValues['discount_end_date']) && isset($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) {
             $end_date = CRM_Utils_Date::processDate($this->_submitValues['discount_end_date'][$i]);
             if (!empty($this->_submitValues['discount_end_date'][$i + 1]) && empty($this->_submitValues['discount_start_date'][$i + 1])) {
                 list($this->_submitValues['discount_start_date'][$i + 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("+1 days {$end_date}")));
             }
         }
         //Decrement by 1 of end date from next start date.
         if ($i > 1 && is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i - 1]) && isset($this->_submitValues['discount_start_date']) && isset($this->_submitValues['discount_start_date'][$i])) {
             $start_date = CRM_Utils_Date::processDate($this->_submitValues['discount_start_date'][$i]);
             if (!empty($this->_submitValues['discount_start_date'][$i]) && empty($this->_submitValues['discount_end_date'][$i - 1])) {
                 list($this->_submitValues['discount_end_date'][$i - 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("-1 days {$start_date}")));
             }
         }
         //discount name
         $this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'title'));
         $this->add('hidden', "discount_price_set[{$i}]", '', array('id' => "discount_price_set[{$i}]"));
         // add a rule to ensure that discount name is not more than 24 characters to prevent overflow
         // in option group name, CRM-7915
         // 24 characters will make the option group name less than 64 characters
         $this->addRule("discount_name[{$i}]", ts('Discount Name cannot be more than 24 characters'), 'maxlength', 24);
         //discount start date
         $this->addDate('discount_start_date[' . $i . ']', ts('Discount Start Date'), FALSE, array('formatType' => 'activityDate'));
         //discount end date
         $this->addDate('discount_end_date[' . $i . ']', ts('Discount End Date'), FALSE, array('formatType' => 'activityDate'));
     }
     $_showHide->addToTemplate();
     $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'form-submit'));
     $this->buildAmountLabel();
     parent::buildQuickForm();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:85,代码来源:Fee.php


注:本文中的CRM_Core_ShowHideBlocks::addHide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。