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


PHP CRM_Utils_Weight::delWeight方法代码示例

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


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

示例1: deleteParticipantStatusType

 /**
  * @param int $id
  *
  * @return bool
  */
 public static function deleteParticipantStatusType($id)
 {
     // return early if there are participants with this status
     $participant = new CRM_Event_DAO_Participant();
     $participant->status_id = $id;
     if ($participant->find()) {
         return FALSE;
     }
     CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->id = $id;
     $dao->find(TRUE);
     $dao->delete();
     return TRUE;
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:20,代码来源:ParticipantStatusType.php

示例2: deleteParticipantStatusType

 static function deleteParticipantStatusType($id)
 {
     // return early if there are participants with this status
     require_once 'CRM/Event/DAO/Participant.php';
     $participant = new CRM_Event_DAO_Participant();
     $participant->status_id = $id;
     if ($participant->find()) {
         return false;
     }
     require_once 'CRM/Utils/Weight.php';
     CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->id = $id;
     $dao->find(true);
     $dao->delete();
     return true;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:17,代码来源:ParticipantStatusType.php

示例3: postProcess

 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $ids = array('uf_group' => $this->_gid);
     if ($this->_action & CRM_Core_Action::DELETE) {
         $fieldValues = array('uf_group_id' => $this->_gid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_UFField', $this->_id, $fieldValues);
         $deleted = CRM_Core_BAO_UFField::del($this->_id);
         //update group_type every time. CRM-3608
         if ($this->_gid && $deleted) {
             //get the profile type.
             $groupType = 'null';
             $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($this->_gid);
             if (!empty($fieldsType)) {
                 $groupType = implode(',', $fieldsType);
             }
             //set group type
             CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'group_type', $groupType);
         }
         CRM_Core_Session::setStatus(ts('Selected Profile Field has been deleted.'));
         return;
     }
     // store the submitted values in an array
     $params = $this->controller->exportValues('Field');
     if ($params['visibility'] == 'User and User Admin Only') {
         $params['is_searchable'] = 0;
         $params['in_selector'] = 0;
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $ids['uf_field'] = $this->_id;
     }
     //check for duplicate fields
     if (CRM_Core_BAO_UFField::duplicateField($params, $ids)) {
         CRM_Core_Session::setStatus(ts('The selected field was not added. It already exists in this profile.'));
         return;
     } else {
         $ufField = CRM_Core_BAO_UFField::add($params, $ids);
         $name = $this->_selectFields[$ufField->field_name];
         //reset other field is searchable and in selector settings, CRM-4363
         if ($this->_hasSearchableORInSelector && in_array($ufField->field_type, array('Participant', 'Contribution', 'Membership'))) {
             CRM_Core_BAO_UFField::resetInSelectorANDSearchable($this->_gid);
         }
         $config =& CRM_Core_Config::singleton();
         $showBestResult = false;
         if (in_array($ufField->field_name, array('country', 'state_province')) && count($config->countryLimit) > 1) {
             // get state or country field weight if exists
             $field = 'state_province';
             if ($ufField->field_name == 'state_province') {
                 $field = 'country';
             }
             $ufFieldDAO =& new CRM_Core_DAO_UFField();
             $ufFieldDAO->field_name = $field;
             $ufFieldDAO->location_type_id = $ufField->location_type_id;
             $ufFieldDAO->uf_group_id = $ufField->uf_group_id;
             if ($ufFieldDAO->find(true)) {
                 if ($field == 'country' && $ufFieldDAO->weight > $ufField->weight) {
                     $showBestResult = true;
                 } elseif ($field == 'state_province' && $ufFieldDAO->weight < $ufField->weight) {
                     $showBestResult = true;
                 }
             }
         }
         //update group_type every time. CRM-3608
         if ($this->_gid && is_a($ufField, 'CRM_Core_DAO_UFField')) {
             //get the profile type.
             $groupType = 'null';
             $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($this->_gid);
             if (!empty($fieldsType)) {
                 $groupType = implode(',', $fieldsType);
             }
             //set group type
             CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'group_type', $groupType);
         }
         CRM_Core_Session::setStatus(ts('Your CiviCRM Profile Field \'%1\' has been saved.', array(1 => $name)));
     }
     $buttonName = $this->controller->getButtonName();
     $session =& CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another profile field.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=add&gid={$this->_gid}&sbr={$showBestResult}"));
     } else {
         $session->set('showBestResult', $showBestResult);
     }
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:89,代码来源:Field.php

示例4: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_gid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
         if (CRM_Core_BAO_OptionValue::del($this->_id)) {
             if ($this->_gName == 'phone_type') {
                 CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues));
             }
             CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName)));
         } else {
             CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)));
             CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
         }
     } else {
         $params = $ids = array();
         $params = $this->exportValues();
         // allow multiple defaults within group.
         $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address');
         if (in_array($this->_gName, $allowMultiDefaults)) {
             if ($this->_gName == 'from_email_address') {
                 $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID());
             } elseif ($filter = CRM_Utils_Array::value('contactOptions', $params)) {
                 $params['filter'] = $filter;
                 $params['reset_default_for'] = array('filter' => "0, " . $params['filter']);
             }
             //make sure we should has to have space, CRM-6977
             if ($this->_gName == 'from_email_address') {
                 $params['label'] = str_replace('"<', '" <', $params['label']);
             }
         }
         // set db value of filter in params if filter is non editable
         if ($this->_id && !array_key_exists('filter', $params) && !$this->_gName == 'participant_role') {
             $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id');
         }
         $groupParams = array('name' => $this->_gName);
         $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
         CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label)));
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:47,代码来源:Options.php

示例5: postProcess

 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action == CRM_Core_Action::DELETE) {
         $fieldValues = array('price_field_id' => $this->_fid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Price_DAO_PriceFieldValue', $this->_oid, $fieldValues);
         $label = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, 'label', 'id');
         if (CRM_Price_BAO_PriceFieldValue::del($this->_oid)) {
             CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label)), ts('Record Deleted'), 'success');
         }
         return NULL;
     } else {
         $params = $ids = array();
         $params = $this->controller->exportValues('Option');
         $fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'label');
         $params['amount'] = CRM_Utils_Rule::cleanMoney(trim($params['amount']));
         $params['price_field_id'] = $this->_fid;
         $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
         $ids = array();
         if ($this->_oid) {
             $ids['id'] = $this->_oid;
         }
         $optionValue = CRM_Price_BAO_PriceFieldValue::create($params, $ids);
         CRM_Core_Session::setStatus(ts("The option '%1' has been saved.", array(1 => $params['label'])), ts('Value Saved'), 'success');
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:Option.php

示例6: del

 /**
  * Delete a PDF Page Format.
  *
  * @param int $id
  *   ID of the PDF Page Format to be deleted.
  *
  */
 public static function del($id)
 {
     if ($id) {
         $dao = new CRM_Core_DAO_OptionValue();
         $dao->id = $id;
         if ($dao->find(TRUE)) {
             if ($dao->option_group_id == self::_getGid()) {
                 $filter = array('option_group_id' => self::_getGid());
                 CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter);
                 $dao->delete();
                 return;
             }
         }
     }
     CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
 }
开发者ID:kidaa30,项目名称:yes,代码行数:23,代码来源:PdfFormat.php

示例7: del

 /**
  * Delete membership Types.
  *
  * @param int $membershipStatusId
  *
  * @throws CRM_Core_Exception
  */
 public static function del($membershipStatusId)
 {
     //check dependencies
     //checking if membership status is present in some other table
     $check = FALSE;
     $dependency = array('Membership', 'MembershipLog');
     foreach ($dependency as $name) {
         $baoString = 'CRM_Member_BAO_' . $name;
         $dao = new $baoString();
         $dao->status_id = $membershipStatusId;
         if ($dao->find(TRUE)) {
             throw new CRM_Core_Exception(ts('This membership status cannot be deleted as memberships exist with this status'));
         }
     }
     CRM_Utils_Weight::delWeight('CRM_Member_DAO_MembershipStatus', $membershipStatusId);
     //delete from membership Type table
     $membershipStatus = new CRM_Member_DAO_MembershipStatus();
     $membershipStatus->id = $membershipStatusId;
     $membershipStatus->delete();
     $membershipStatus->free();
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:28,代码来源:MembershipStatus.php

示例8: 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

示例9: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     require_once 'CRM/Core/OptionValue.php';
     if ($this->_action == CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_ogId);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_oid, $fieldValues);
         $label = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $this->_oid, 'label', 'id');
         if (CRM_Core_BAO_OptionValue::del($this->_oid)) {
             CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label)));
         }
         return;
     } else {
         $params = $ids = array();
         $params = $this->controller->exportValues('Option');
         $fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $this->_fid, 'label');
         $params['description'] = $fieldLabel . ' - ' . $params['label'];
         $params['value'] = CRM_Utils_Rule::cleanMoney(trim($params['value']));
         $groupParams = array('id' => $this->_ogId);
         // make name value consistant.
         $params['name'] = $params['value'];
         $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_oid);
         CRM_Core_Session::setStatus(ts('The option \'%1\' has been saved.', array(1 => $params['label'])));
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:32,代码来源:Option.php

示例10: deleteField

 /**
  * Delete the price set field.
  *
  * @param   int   $id    Field Id 
  * 
  * @return  boolean
  *
  * @access public
  * @static
  *
  */
 public static function deleteField($id)
 {
     $field = new CRM_Price_DAO_Field();
     $field->id = $id;
     if ($field->find(true)) {
         // delete the options for this field
         require_once 'CRM/Price/BAO/FieldValue.php';
         CRM_Price_BAO_FieldValue::deleteValues($id);
         // reorder the weight before delete
         $fieldValues = array('price_set_id' => $field->price_set_id);
         require_once 'CRM/Utils/Weight.php';
         CRM_Utils_Weight::delWeight('CRM_Price_DAO_Field', $field->id, $fieldValues);
         // now delete the field
         return $field->delete();
     }
     return null;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:28,代码来源:Field.php

示例11: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     require_once 'CRM/Member/BAO/MembershipStatus.php';
     if ($this->_action & CRM_Core_Action::DELETE) {
         $wt = CRM_Utils_Weight::delWeight('CRM_Member_DAO_MembershipStatus', $this->_id);
         CRM_Member_BAO_MembershipStatus::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected membership status has been deleted.'));
     } else {
         $params = $ids = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['membershipStatus'] = $this->_id;
         }
         if ($this->_id) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $this->_id, 'weight', 'id');
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Member_DAO_MembershipStatus', $oldWeight, $params['weight']);
         // only for add mode, set label to name.
         if ($this->_action & CRM_Core_Action::ADD) {
             $params['name'] = $params['label'];
         }
         $membershipStatus = CRM_Member_BAO_MembershipStatus::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The membership status \'%1\' has been saved.', array(1 => $membershipStatus->label)));
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:MembershipStatus.php

示例12: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_gid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
         if (CRM_Core_BAO_OptionValue::del($this->_id)) {
             if ($this->_gName == 'phone_type') {
                 require_once 'CRM/Core/BAO/Phone.php';
                 CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues));
             }
             CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName)));
         } else {
             CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)));
             CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
         }
     } else {
         $params = $ids = array();
         $params = $this->exportValues();
         // allow multiple defaults within group.
         $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address');
         if (CRM_Utils_Array::value('is_default', $params) && in_array($this->_gName, $allowMultiDefaults)) {
             if ($this->_gName == 'from_email_address') {
                 $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID());
             } else {
                 if ($filter = CRM_Utils_Array::value('contactOptions', $params)) {
                     $params['filter'] = $filter;
                     $params['reset_default_for'] = array('filter' => "0, " . $params['filter']);
                 }
             }
         }
         $groupParams = array('name' => $this->_gName);
         require_once 'CRM/Core/OptionValue.php';
         $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
         CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label)));
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:42,代码来源:Options.php

示例13: deleteField

 /**
  * Delete the price set field.
  *
  * @param   int   $id    Field Id 
  * 
  * @return  boolean
  *
  * @access public
  * @static
  *
  */
 public static function deleteField($id)
 {
     $field =& new CRM_Price_DAO_Field();
     $field->id = $id;
     if ($field->find(true)) {
         // delete the options for this field
         require_once 'CRM/Core/OptionGroup.php';
         CRM_Core_OptionGroup::deleteAssoc("civicrm_price_field.amount.{$id}");
         // reorder the weight before delete
         $fieldValues = array('price_set_id' => $field->price_set_id);
         require_once 'CRM/Utils/Weight.php';
         CRM_Utils_Weight::delWeight('CRM_Price_DAO_Field', $field->id, $fieldValues);
         // now delete the field
         return $field->delete();
     }
     return null;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:28,代码来源:Field.php

示例14: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $fieldValues = array('option_group_id' => $this->_gid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
         if (CRM_Core_BAO_OptionValue::del($this->_id)) {
             if ($this->_gName == 'phone_type') {
                 require_once 'CRM/Core/BAO/Phone.php';
                 CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues));
             }
             CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName)));
         } else {
             CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)));
             CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
         }
     } else {
         $params = $ids = array();
         $params = $this->exportValues();
         //set defaultGreeting option in params as per contact type
         if (CRM_Utils_Array::value('contactOptions', $params)) {
             $params['filter'] = CRM_Utils_Array::value('contactOptions', $params);
             $params['defaultGreeting'] = 1;
         }
         $groupParams = array('name' => $this->_gName);
         require_once 'CRM/Core/OptionValue.php';
         $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
         CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label)));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:35,代码来源:Options.php

示例15: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     require_once 'CRM/Member/BAO/MembershipType.php';
     if ($this->_action & CRM_Core_Action::DELETE) {
         $wt = CRM_Utils_Weight::delWeight('CRM_Member_DAO_MembershipType', $this->_id);
         CRM_Member_BAO_MembershipType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected membership type has been deleted.'));
     } else {
         $params = $ids = array();
         $params = $this->exportValues();
         $this->set('searchDone', 0);
         if (CRM_Utils_Array::value('_qf_MembershipType_refresh', $_POST)) {
             $this->search($params);
             $this->set('searchDone', 1);
             return;
         }
         $params['minimum_fee'] = CRM_Utils_Rule::cleanMoney($params['minimum_fee']);
         if (CRM_Utils_Array::value('relationship_type_id', $params)) {
             $relationId = explode('_', $params['relationship_type_id']);
             $params['relationship_type_id'] = $relationId[0];
             $params['relationship_direction'] = $relationId[1] . '_' . $relationId[2];
         }
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['membershipType'] = $this->_id;
         }
         if ($params['duration_unit'] == 'lifetime' and empty($params['duration_interval'])) {
             $params['duration_interval'] = 1;
         }
         $config =& CRM_Core_Config::singleton();
         $periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
         foreach ($periods as $per) {
             if ($params[$per][$config->dateformatMonthVar] && $params[$per]['d']) {
                 $mon = $params[$per][$config->dateformatMonthVar];
                 $dat = $params[$per]['d'];
                 $mon = $mon < 9 ? '0' . $mon : $mon;
                 $dat = $dat < 9 ? '0' . $dat : $dat;
                 $params[$per] = $mon . $dat;
             } else {
                 $params[$per] = 'null';
             }
         }
         $oldWeight = null;
         $ids['memberOfContact'] = CRM_Utils_Array::value('contact_check', $params);
         if ($this->_id) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_id, 'weight', 'id');
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Member_DAO_MembershipType', $oldWeight, $params['weight']);
         $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The membership type \'%1\' has been saved.', array(1 => $membershipType->name)));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:57,代码来源:MembershipType.php


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