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


PHP CRM_Core_BAO_CustomOption::del方法代码示例

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


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

示例1: crm_delete_option_value

/**
 *
 * delete one or more option values
 *
 * @param $option  object   A valid custom field option object 
 *
 * @return null  if success
 *
 * @access public 
 *
 */
function crm_delete_option_value($option)
{
    _crm_initialize();
    if (!isset($option->id)) {
        return _crm_error("id of the custom option is not set.");
    }
    require_once 'CRM/Core/BAO/CustomOption.php';
    return CRM_Core_BAO_CustomOption::del($option->id);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:20,代码来源:CustomGroup.php

示例2: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues('Option');
     // set values for custom field properties and save
     require_once 'CRM/Core/DAO/OptionValue.php';
     require_once 'CRM/Utils/String.php';
     $customOption =& new CRM_Core_DAO_OptionValue();
     $customOption->label = $params['label'];
     $customOption->name = CRM_Utils_String::titleToVar($params['label']);
     $customOption->weight = $params['weight'];
     $customOption->value = $params['value'];
     $customOption->is_active = CRM_Utils_Array::value('is_active', $params, false);
     if ($this->_action == CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_optionGroupID);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
         CRM_Core_BAO_CustomOption::del($this->_id);
         CRM_Core_Session::setStatus(ts('Your multiple choice option has been deleted', array(1 => $customOption->label)));
         return;
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $customOption->id = $this->_id;
         CRM_Core_BAO_CustomOption::updateCustomValues($params);
     }
     if ($this->_id) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id');
     }
     $fieldValues = array('option_group_id' => $this->_optionGroupID);
     $customOption->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, $params['weight'], $fieldValues);
     $customOption->option_group_id = $this->_optionGroupID;
     $customField =& new CRM_Core_DAO_CustomField();
     $customField->id = $this->_fid;
     if ($customField->find(true) && ($customField->html_type == 'CheckBox' || $customField->html_type == 'AdvMulti-Select' || $customField->html_type == 'Multi-Select')) {
         $defVal = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($customField->default_value, 1, -1));
         if (CRM_Utils_Array::value('default_value', $params)) {
             if (!in_array($customOption->value, $defVal)) {
                 if (empty($defVal[0])) {
                     $defVal = array($customOption->value);
                 } else {
                     $defVal[] = $customOption->value;
                 }
                 $customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $defVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
                 $customField->save();
             }
         } else {
             if (in_array($customOption->value, $defVal)) {
                 $tempVal = array();
                 foreach ($defVal as $v) {
                     if ($v != $customOption->value) {
                         $tempVal[] = $v;
                     }
                 }
                 $customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $tempVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
                 $customField->save();
             }
         }
     } else {
         switch ($customField->data_type) {
             case 'Money':
                 require_once 'CRM/Utils/Rule.php';
                 $customOption->value = CRM_Utils_Rule::cleanMoney($customOption->value);
                 break;
             case 'Int':
                 $customOption->value = intval($customOption->value);
                 break;
             case 'Float':
                 $customOption->value = floatval($customOption->value);
                 break;
         }
         if (CRM_Utils_Array::value('default_value', $params)) {
             $customField->default_value = $customOption->value;
             $customField->save();
         } else {
             if ($customField->find(true) && $customField->default_value == $customOption->value) {
                 // this is the case where this option is the current default value and we have been reset
                 $customField->default_value = 'null';
                 $customField->save();
             }
         }
     }
     $customOption->save();
     CRM_Core_Session::setStatus(ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)));
     $buttonName = $this->controller->getButtonName();
     $session =& CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another option.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/option', 'reset=1&action=add&fid=' . $this->_fid . '&gid=' . $this->_gid));
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:97,代码来源:Option.php

示例3: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues('Option');
     // set values for custom field properties and save
     $customOption =& new CRM_Core_DAO_CustomOption();
     $customOption->label = $params['label'];
     $customOption->weight = $params['weight'];
     $customOption->value = $params['value'];
     $customOption->is_active = CRM_Utils_Array::value('is_active', $params, false);
     if ($this->_action == CRM_CORE_ACTION_DELETE) {
         CRM_Core_BAO_CustomOption::del($this->_id);
         CRM_Core_Session::setStatus(ts('Your multiple choice option has been deleted', array(1 => $customOption->label)));
         return;
     }
     if ($this->_action & CRM_CORE_ACTION_UPDATE) {
         $customOption->id = $this->_id;
         CRM_Core_BAO_CustomOption::updateCustomValues($params);
     }
     // need the FKEY - custom field id
     //$customOption->custom_field_id = $this->_fid;
     $customOption->entity_id = $this->_fid;
     $customOption->entity_table = 'civicrm_custom_field';
     $customField =& new CRM_Core_DAO_CustomField();
     $customField->id = $this->_fid;
     if ($customField->find(true) && ($customField->html_type == 'CheckBox' || $customField->html_type == 'Multi-Select')) {
         $defVal = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $customField->default_value);
         if (CRM_Utils_Array::value('default_value', $params)) {
             if (!in_array($customOption->value, $defVal)) {
                 if (empty($defVal[0])) {
                     $customField->default_value = $customOption->value;
                 } else {
                     $customField->default_value .= CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR . $customOption->value;
                 }
                 $customField->save();
             }
         } else {
             if (in_array($customOption->value, $defVal)) {
                 $tempVal = array();
                 foreach ($defVal as $v) {
                     if ($v != $customOption->value) {
                         $tempVal[] = $v;
                     }
                 }
                 $customField->default_value = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $tempVal);
                 $customField->save();
             }
         }
     } else {
         if (CRM_Utils_Array::value('default_value', $params)) {
             $customField->default_value = $customOption->value;
             $customField->save();
         } else {
             if ($customField->find(true) && $customField->default_value == $customOption->value) {
                 // this is the case where this option is the current default value and we have been reset
                 $customField->default_value = 'null';
                 $customField->save();
             }
         }
     }
     $customOption->save();
     CRM_Core_Session::setStatus(ts('Your multiple choice option "%1" has been saved', array(1 => $customOption->label)));
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:71,代码来源:Option.php


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