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


PHP CRM_Event_Form_ManageEvent::setDefaultValues方法代码示例

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


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

示例1: setDefaultValues

 /**
  * Set default values for the form.
  *
  * For edit/view mode he default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     // in update mode, we need to set custom data subtype to tpl
     if (!empty($defaults['event_type_id'])) {
         $this->assign('customDataSubType', $defaults['event_type_id']);
     }
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     // Show waitlist features or event_full_text if max participants set
     if (!empty($defaults['max_participants'])) {
         $this->_showHide->addShow('id-waitlist');
         if (!empty($defaults['has_waitlist'])) {
             $this->_showHide->addShow('id-waitlist-text');
             $this->_showHide->addHide('id-event_full');
         } else {
             $this->_showHide->addHide('id-waitlist-text');
             $this->_showHide->addShow('id-event_full');
         }
     } else {
         $this->_showHide->addHide('id-event_full');
         $this->_showHide->addHide('id-waitlist');
         $this->_showHide->addHide('id-waitlist-text');
     }
     $this->_showHide->addToTemplate();
     $this->assign('elemType', 'table-row');
     $this->assign('description', CRM_Utils_Array::value('description', $defaults));
     // Provide suggested text for event full and waitlist messages if they're empty
     $defaults['event_full_text'] = CRM_Utils_Array::value('event_full_text', $defaults, ts('This event is currently full.'));
     $defaults['waitlist_text'] = CRM_Utils_Array::value('waitlist_text', $defaults, ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.'));
     list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('start_date', $defaults), 'activityDateTime');
     if (!empty($defaults['end_date'])) {
         list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime');
     }
     return $defaults;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:40,代码来源:EventInfo.php

示例2: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     $parentDefaults = parent::setDefaultValues();
     $eventId = $this->_id;
     $params = array();
     $defaults = array();
     if (isset($eventId)) {
         $params = array('id' => $eventId);
     }
     CRM_Event_BAO_Event::retrieve($params, $defaults);
     $defaults = array_merge($defaults, $parentDefaults);
     $defaults['id'] = $eventId;
     return $defaults;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:22,代码来源:Conference.php

示例3: setDefaultValues

 /**
  * This function sets the default values for the form. 
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $eventId = $this->_id;
     $defaults = parent::setDefaultValues();
     $this->setShowHide($defaults);
     if (isset($eventId)) {
         $params = array('id' => $eventId);
         CRM_Event_BAO_Event::retrieve($params, $defaults);
         require_once 'CRM/Core/BAO/UFJoin.php';
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $eventId);
         list($defaults['custom_pre_id'], $defaults['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         if ($defaults['is_multiple_registrations']) {
             // CRM-4377: set additional participants’ profiles – set to ‘none’ if explicitly unset (non-active)
             $ufJoin = new CRM_Core_DAO_UFJoin();
             $ufJoin->module = 'CiviEvent_Additional';
             $ufJoin->entity_table = 'civicrm_event';
             $ufJoin->entity_id = $eventId;
             $ufJoin->orderBy('weight');
             $ufJoin->find();
             $custom = array(1 => 'additional_custom_pre_id', 2 => 'additional_custom_post_id');
             while ($ufJoin->fetch()) {
                 $defaults[$custom[$ufJoin->weight]] = $ufJoin->is_active ? $ufJoin->uf_group_id : 'none';
             }
         }
     } else {
         $defaults['is_email_confirm'] = 0;
     }
     // provide defaults for required fields if empty (and as a 'hint' for approval message field)
     $defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
     $defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
     $defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
     $defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
     if (CRM_Utils_Array::value('registration_start_date', $defaults)) {
         list($defaults['registration_start_date'], $defaults['registration_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
     }
     if (CRM_Utils_Array::value('registration_end_date', $defaults)) {
         list($defaults['registration_end_date'], $defaults['registration_end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
     }
     return $defaults;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:47,代码来源:Registration.php

示例4: setDefaultValues

 /**
  * Set default values for the form.
  *
  * For edit/view mode the default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $parentDefaults = parent::setDefaultValues();
     $eventId = $this->_id;
     $params = array();
     $defaults = array();
     if (isset($eventId)) {
         $params = array('id' => $eventId);
     }
     CRM_Event_BAO_Event::retrieve($params, $defaults);
     if (isset($eventId)) {
         $price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventId, NULL, 1);
         if ($price_set_id) {
             $defaults['price_set_id'] = $price_set_id;
         } else {
             $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventId, NULL);
             if ($priceSetId) {
                 if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
                     $this->assign('isQuick', $isQuick);
                     $priceField = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id');
                     $options = array();
                     $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($priceField, $options, 'weight', TRUE);
                     $defaults['price_field_id'] = $priceField;
                     $countRow = 0;
                     foreach ($options as $optionId => $optionValue) {
                         $countRow++;
                         $defaults['value'][$countRow] = CRM_Utils_Money::format($optionValue['amount'], NULL, '%a');
                         $defaults['label'][$countRow] = $optionValue['label'];
                         $defaults['name'][$countRow] = $optionValue['name'];
                         $defaults['weight'][$countRow] = $optionValue['weight'];
                         $defaults['price_field_value'][$countRow] = $optionValue['id'];
                         if ($optionValue['is_default']) {
                             $defaults['default'] = $countRow;
                         }
                     }
                 }
             }
         }
     }
     //check if discounted
     $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, 'civicrm_event');
     if (!empty($discountedEvent)) {
         $defaults['is_discount'] = $i = 1;
         $totalLables = $maxSize = $defaultDiscounts = array();
         foreach ($discountedEvent as $optionGroupId) {
             $defaults['discount_price_set'][] = $optionGroupId;
             $name = $defaults["discount_name[{$i}]"] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $optionGroupId, 'title');
             list($defaults["discount_start_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'start_date', 'price_set_id'));
             list($defaults["discount_end_date[{$i}]"]) = CRM_Utils_Date::setDateDefaults(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'end_date', 'price_set_id'));
             $defaultDiscounts[] = CRM_Price_BAO_PriceSet::getSetDetail($optionGroupId);
             $i++;
         }
         //avoid moving up value of lable when some labels don't
         //have a value ,fixed for CRM-3088
         $rowCount = 1;
         foreach ($defaultDiscounts as $val) {
             $discountFields = current($val);
             $discountFields = current($discountFields['fields']);
             foreach ($discountFields['options'] as $discountFieldsval) {
                 $defaults['discounted_label'][$discountFieldsval['weight']] = $discountFieldsval['label'];
                 $defaults['discounted_value'][$discountFieldsval['weight']][$rowCount] = CRM_Utils_Money::format($discountFieldsval['amount'], NULL, '%a');
                 $defaults['discount_option_id'][$rowCount][$discountFieldsval['weight']] = $discountFieldsval['id'];
                 if (!empty($discountFieldsval['is_default'])) {
                     $defaults['discounted_default'] = $discountFieldsval['weight'];
                 }
             }
             $rowCount++;
         }
         //CRM-12970
         ksort($defaults['discounted_value']);
         ksort($defaults['discounted_label']);
         $rowCount = 1;
         foreach ($defaults['discounted_label'] as $key => $value) {
             if ($key != $rowCount) {
                 $defaults['discounted_label'][$rowCount] = $value;
                 $defaults['discounted_value'][$rowCount] = $defaults['discounted_value'][$key];
                 unset($defaults['discounted_value'][$key]);
                 unset($defaults['discounted_label'][$key]);
                 foreach ($defaults['discount_option_id'] as &$optionIds) {
                     if (array_key_exists($key, $optionIds)) {
                         $optionIds[$rowCount] = $optionIds[$key];
                         unset($optionIds[$key]);
                     }
                 }
             }
             $rowCount++;
         }
         $this->set('discountSection', 1);
         $this->buildQuickForm();
     } elseif (!empty($defaults['label'])) {
         //if Regular Fees are present in DB and event fee page is in update mode
         $defaults['discounted_label'] = $defaults['label'];
     } elseif (!empty($this->_submitValues['label'])) {
         //if event is newly created, use submitted values for
         //discount labels
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Fee.php

示例5: setDefaultValues

 /**
  * Set default values for the form.
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     if ($this->_addProfileBottom || $this->_addProfileBottomAdd) {
         return;
     }
     $eventId = $this->_id;
     $defaults = parent::setDefaultValues();
     $this->setShowHide($defaults);
     if (isset($eventId)) {
         $params = array('id' => $eventId);
         CRM_Event_BAO_Event::retrieve($params, $defaults);
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $eventId);
         list($defaults['custom_pre_id'], $defaults['custom_post']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // Get the id for the event registration profile
         $eventRegistrationIdParams = $eventRegistrationIdDefaults = array('name' => 'event_registration');
         CRM_Core_BAO_UFGroup::retrieve($eventRegistrationIdParams, $eventRegistrationIdDefaults);
         // Set event registration as the default profile if none selected
         if (!$defaults['custom_pre_id'] && count($defaults['custom_post']) == 0) {
             $defaults['custom_pre_id'] = CRM_Utils_Array::value('id', $eventRegistrationIdDefaults);
         }
         if (isset($defaults['custom_post']) && is_numeric($defaults['custom_post'])) {
             $defaults['custom_post_id'] = $defaults['custom_post'];
         } elseif (!empty($defaults['custom_post'])) {
             $defaults['custom_post_id'] = $defaults['custom_post'][0];
             unset($defaults['custom_post'][0]);
             $this->_profilePostMultiple = $defaults['custom_post'];
             foreach ($defaults['custom_post'] as $key => $value) {
                 self::buildMultipleProfileBottom($this, $key);
                 $defaults["custom_post_id_multiple[{$key}]"] = $value;
             }
         }
         $this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults));
         if (!empty($defaults['is_multiple_registrations'])) {
             // CRM-4377: set additional participants’ profiles – set to ‘none’ if explicitly unset (non-active)
             $ufJoinAddParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent_Additional', 'entity_id' => $eventId);
             list($defaults['additional_custom_pre_id'], $defaults['additional_custom_post']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinAddParams);
             if (isset($defaults['additional_custom_post']) && is_numeric($defaults['additional_custom_post'])) {
                 $defaults['additional_custom_post_id'] = $defaults['additional_custom_post'];
             } elseif (!empty($defaults['additional_custom_post'])) {
                 $defaults['additional_custom_post_id'] = $defaults['additional_custom_post'][0];
                 unset($defaults['additional_custom_post'][0]);
                 $this->_profilePostMultipleAdd = $defaults['additional_custom_post'];
                 foreach ($defaults['additional_custom_post'] as $key => $value) {
                     self::buildMultipleProfileBottom($this, $key, 'additional_', ts('Profile for Additional Participants'));
                     $defaults["additional_custom_post_id_multiple[{$key}]"] = $value;
                 }
             }
             $this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults));
         }
     } else {
         $defaults['is_email_confirm'] = 0;
     }
     // provide defaults for required fields if empty (and as a 'hint' for approval message field)
     $defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
     $defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
     $defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
     $defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
     if (!empty($defaults['registration_start_date'])) {
         list($defaults['registration_start_date'], $defaults['registration_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
     }
     if (!empty($defaults['registration_end_date'])) {
         list($defaults['registration_end_date'], $defaults['registration_end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
     }
     return $defaults;
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:72,代码来源:Registration.php

示例6: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     if ($this->_cdType) {
         $tempId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this);
         // set template custom data as a default for event, CRM-5596
         if ($tempId && !$this->_id) {
             $defaults = $this->templateCustomDataValues($tempId);
         } else {
             $defaults = CRM_Custom_Form_CustomData::setDefaultValues($this);
         }
         return $defaults;
     }
     $defaults = parent::setDefaultValues();
     // in update mode, we need to set custom data subtype to tpl
     if (CRM_Utils_Array::value('event_type_id', $defaults)) {
         $this->assign('customDataSubType', $defaults["event_type_id"]);
     }
     require_once 'CRM/Core/ShowHideBlocks.php';
     $this->_showHide =& new CRM_Core_ShowHideBlocks();
     // Show waitlist features or event_full_text if max participants set
     if (CRM_Utils_Array::value('max_participants', $defaults)) {
         $this->_showHide->addShow('id-waitlist');
         if (CRM_Utils_Array::value('has_waitlist', $defaults)) {
             $this->_showHide->addShow('id-waitlist-text');
             $this->_showHide->addHide('id-event_full');
         } else {
             $this->_showHide->addHide('id-waitlist-text');
             $this->_showHide->addShow('id-event_full');
         }
     } else {
         $this->_showHide->addHide('id-event_full');
         $this->_showHide->addHide('id-waitlist');
         $this->_showHide->addHide('id-waitlist-text');
     }
     $this->_showHide->addToTemplate();
     $this->assign('elemType', 'table-row');
     $this->assign('description', CRM_Utils_Array::value('description', $defaults));
     // Provide suggested text for event full and waitlist messages if they're empty
     $defaults['event_full_text'] = CRM_Utils_Array::value('event_full_text', $defaults, ts('This event is currently full.'));
     $defaults['waitlist_text'] = CRM_Utils_Array::value('waitlist_text', $defaults, ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.'));
     list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('start_date', $defaults), 'activityDateTime');
     if (CRM_Utils_Array::value('end_date', $defaults)) {
         list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime');
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:53,代码来源:EventInfo.php

示例7: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $parentDefaults = parent::setDefaultValues();
     $eventId = $this->_id;
     $params = array();
     $defaults = array();
     if (isset($eventId)) {
         $params = array('id' => $eventId);
     }
     CRM_Event_BAO_Event::retrieve($params, $defaults);
     if (isset($eventId)) {
         require_once 'CRM/Price/BAO/Set.php';
         $price_set_id = CRM_Price_BAO_Set::getFor('civicrm_event', $eventId);
         if ($price_set_id) {
             $defaults['price_set_id'] = $price_set_id;
         } else {
             require_once 'CRM/Core/OptionGroup.php';
             CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventId}", $defaults);
         }
     }
     //check if discounted
     require_once 'CRM/Core/BAO/Discount.php';
     $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, "civicrm_event");
     if (!empty($discountedEvent)) {
         $defaults['is_discount'] = $i = 1;
         $totalLables = $maxSize = $defaultDiscounts = array();
         foreach ($discountedEvent as $optionGroupId) {
             $name = $defaults["discount_name[{$i}]"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
             $defaults["discount_start_date[{$i}]"] = CRM_Utils_Date::unformat(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'start_date', 'option_group_id'));
             $defaults["discount_end_date[{$i}]"] = CRM_Utils_Date::unformat(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'end_date', 'option_group_id'));
             CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventId}.discount.{$name}", $defaultDiscounts[]);
             $i++;
         }
         //avoid moving up value of lable when some labels don't
         //have a value ,fixed for CRM-3088
         foreach ($defaultDiscounts as $key => $val) {
             $totalLables[$key]['label'] = $val['label'];
             $totalLables[$key]['value'] = $val['value'];
             $totalLables[$key]['amount_id'] = $val['amount_id'];
             foreach ($val['weight'] as $v) {
                 //take array of weight for setdefault
                 $discountWeight[$key][] = $v;
             }
             foreach ($val['value'] as $v) {
                 //take array of available value for particular
                 //discount set
                 $discountValue[$key][] = $v;
             }
             //combining the weight with amount array for set default
             $discountDefualt[] = array_combine($discountWeight[$key], $discountValue[$key]);
             foreach ($discountDefualt[$key] as $k => $v) {
                 $defaults["discounted_value"][$k][$key + 1] = $v;
             }
             $maxSize[$key] = sizeof($val['label']);
         }
         $maxKey = CRM_Utils_Array::key(max($maxSize), $maxSize);
         $defaults["discounted_label"] = $totalLables[$maxKey]['label'];
         $this->set('discountSection', 1);
         $this->buildQuickForm();
     } else {
         if (!empty($defaults['label'])) {
             //if Regular Fees are present in DB and event fee page is in update mode
             $defaults["discounted_label"] = $defaults['label'];
         } else {
             if (CRM_Utils_Array::value('label', $this->_submitValues)) {
                 //if event is newly created, use submitted values for
                 //discount labels
                 if (is_array($this->_submitValues['label'])) {
                     $k = 1;
                     foreach ($this->_submitValues['label'] as $value) {
                         if ($value) {
                             $defaults["discounted_label"][$k] = $value;
                             $k++;
                         }
                     }
                 }
             }
         }
     }
     $defaults = array_merge($defaults, $parentDefaults);
     $defaults['id'] = $eventId;
     if (CRM_Utils_Array::value('value', $defaults)) {
         foreach ($defaults['value'] as $i => $v) {
             if ($defaults['amount_id'][$i] == $defaults['default_fee_id']) {
                 $defaults['default'] = $i;
                 break;
             }
         }
     }
     if (!empty($totalLables)) {
         $maxKey = count($totalLables) - 1;
         if (isset($maxKey) && CRM_Utils_Array::value('value', $totalLables[$maxKey])) {
             foreach ($totalLables[$maxKey]['value'] as $i => $v) {
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Fee.php


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