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


PHP CRM_Utils_Weight::updateOtherWeights方法代码示例

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


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

示例1: create

 /**
  * Creates a new entry in the database.
  *
  * @param array $params (reference), array $ids
  *
  * @return object CRM_Price_DAO_FieldValue object
  * @access public
  * @static
  */
 static function create(&$params, $ids)
 {
     if (!is_array($params) || empty($params)) {
         return;
     }
     if ($id = CRM_Utils_Array::value('id', $ids)) {
         if (isset($params['name'])) {
             unset($params['name']);
         }
         $oldWeight = null;
         if ($id) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $id, 'weight', 'id');
         }
         $fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_FieldValue', $oldWeight, $params['weight'], $fieldValues);
     } else {
         if (!CRM_Utils_Array::value('name', $params)) {
             $params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
         }
         $params['weight'] = 1;
     }
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
     return self::add($params, $ids);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:33,代码来源:FieldValue.php

示例2: postProcess

 /**
  * Process the form.
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues('Field');
     $params['is_display_amounts'] = CRM_Utils_Array::value('is_display_amounts', $params, FALSE);
     $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE);
     if (isset($params['active_on'])) {
         $params['active_on'] = CRM_Utils_Date::processDate($params['active_on'], CRM_Utils_Array::value('active_on_time', $params), TRUE);
     }
     if (isset($params['expire_on'])) {
         $params['expire_on'] = CRM_Utils_Date::processDate($params['expire_on'], CRM_Utils_Array::value('expire_on_time', $params), TRUE);
     }
     $params['visibility_id'] = CRM_Utils_Array::value('visibility_id', $params, FALSE);
     $params['count'] = CRM_Utils_Array::value('count', $params, FALSE);
     // need the FKEY - price set id
     $params['price_set_id'] = $this->_sid;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('price_set_id' => $this->_sid);
         $oldWeight = NULL;
         if ($this->_fid) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id');
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', $oldWeight, $params['weight'], $fieldValues);
     }
     // make value <=> name consistency.
     if (isset($params['option_name'])) {
         $params['option_value'] = $params['option_name'];
     }
     $params['is_enter_qty'] = CRM_Utils_Array::value('is_enter_qty', $params, FALSE);
     if ($params['html_type'] == 'Text') {
         // if html type is Text, force is_enter_qty on
         $params['is_enter_qty'] = 1;
         // modify params values as per the option group and option
         // value
         $params['option_amount'] = array(1 => $params['price']);
         $params['option_label'] = array(1 => $params['label']);
         $params['option_count'] = array(1 => $params['count']);
         $params['option_max_value'] = array(1 => CRM_Utils_Array::value('max_value', $params));
         //$params['option_description']  = array( 1 => $params['description'] );
         $params['option_weight'] = array(1 => $params['weight']);
         $params['option_financial_type_id'] = array(1 => $params['financial_type_id']);
     }
     if ($this->_fid) {
         $params['id'] = $this->_fid;
     }
     $params['membership_num_terms'] = !empty($params['membership_type_id']) ? CRM_Utils_Array::value('membership_num_terms', $params, 1) : NULL;
     $priceField = CRM_Price_BAO_PriceField::create($params);
     if (!is_a($priceField, 'CRM_Core_Error')) {
         CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', array(1 => $priceField->label)), ts('Saved'), 'success');
     }
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
     if ($buttonName == $this->getButtonName('next', 'new')) {
         CRM_Core_Session::setStatus(ts(' You can add another price set field.'), '', 'info');
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=add&sid=' . $this->_sid));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:64,代码来源:Field.php

示例3: autoWeight

 /**
  * Automatically determine one weight and modify others.
  *
  * @param array $params
  *   UFField record, e.g. with 'weight', 'uf_group_id', and 'field_id'.
  * @return int
  */
 public static function autoWeight($params)
 {
     // fix for CRM-316
     $oldWeight = NULL;
     if (!empty($params['field_id'])) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $params['field_id'], 'weight', 'id');
     }
     $fieldValues = array('uf_group_id' => $params['group_id']);
     return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, CRM_Utils_Array::value('weight', $params, 0), $fieldValues);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:17,代码来源:UFField.php

示例4: postProcess

 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         try {
             CRM_Member_BAO_MembershipType::del($this->_id);
         } catch (CRM_Core_Exception $e) {
             CRM_Core_Error::statusBounce($e->getMessage(), NULL, ts('Membership Type Not Deleted'));
         }
         CRM_Core_Session::setStatus(ts('Selected membership type has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $buttonName = $this->controller->getButtonName();
         $submitted = $this->controller->exportValues($this->_name);
         $fields = array('name', 'weight', 'is_active', 'member_of_contact_id', 'visibility', 'period_type', 'minimum_fee', 'description', 'auto_renew', 'duration_unit', 'duration_interval', 'financial_type_id', 'fixed_period_start_day', 'fixed_period_rollover_day', 'month_fixed_period_rollover_day', 'max_related');
         $params = $ids = array();
         foreach ($fields as $fld) {
             $params[$fld] = CRM_Utils_Array::value($fld, $submitted, 'NULL');
         }
         //clean money.
         if ($params['minimum_fee']) {
             $params['minimum_fee'] = CRM_Utils_Rule::cleanMoney($params['minimum_fee']);
         }
         $hasRelTypeVal = FALSE;
         if (!CRM_Utils_System::isNull($submitted['relationship_type_id'])) {
             // To insert relation ids and directions with value separator
             $relTypeDirs = $submitted['relationship_type_id'];
             $relIds = $relDirection = array();
             foreach ($relTypeDirs as $key => $value) {
                 $relationId = explode('_', $value);
                 if (count($relationId) == 3 && is_numeric($relationId[0])) {
                     $relIds[] = $relationId[0];
                     $relDirection[] = $relationId[1] . '_' . $relationId[2];
                 }
             }
             if (!empty($relIds)) {
                 $hasRelTypeVal = TRUE;
                 $params['relationship_type_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $relIds);
                 $params['relationship_direction'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $relDirection);
             }
         }
         if (!$hasRelTypeVal) {
             $params['relationship_type_id'] = $params['relationship_direction'] = $params['max_related'] = 'NULL';
         }
         if ($params['duration_unit'] == 'lifetime' && empty($params['duration_interval'])) {
             $params['duration_interval'] = 1;
         }
         $periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
         foreach ($periods as $per) {
             if (!empty($params[$per]['M']) && !empty($params[$per]['d'])) {
                 $mon = $params[$per]['M'];
                 $dat = $params[$per]['d'];
                 $mon = $mon < 10 ? '0' . $mon : $mon;
                 $dat = $dat < 10 ? '0' . $dat : $dat;
                 $params[$per] = $mon . $dat;
             } elseif ($per == 'fixed_period_rollover_day' && !empty($params['month_fixed_period_rollover_day'])) {
                 $params['fixed_period_rollover_day'] = $params['month_fixed_period_rollover_day']['d'];
                 unset($params['month_fixed_period_rollover_day']);
             } else {
                 $params[$per] = 'NULL';
             }
         }
         $oldWeight = NULL;
         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']);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['membershipType'] = $this->_id;
         }
         $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The membership type \'%1\' has been saved.', array(1 => $membershipType->name)), ts('Saved'), 'success');
         $session = CRM_Core_Session::singleton();
         if ($buttonName == $this->getButtonName('upload', 'new')) {
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/member/membershipType/add', 'action=add&reset=1'));
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:82,代码来源:MembershipType.php

示例5: addOptionValue

 /**
  * Add/edit option-value of a particular group
  *
  * @param array $params
  *   Array containing exported values from the invoking form.
  * @param array $groupParams
  *   Array containing group fields whose option-values is to retrieved/saved.
  * @param $action
  * @param int $optionValueID Has the id of the optionValue being edited, disabled ..etc.
  *   Has the id of the optionValue being edited, disabled ..etc.
  *
  * @return CRM_Core_DAO_OptionValue
  *
  */
 public static function addOptionValue(&$params, &$groupParams, &$action, &$optionValueID)
 {
     $ids = array();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     // checking if the group name with the given id or name (in $groupParams) exists
     if (!empty($groupParams)) {
         $config = CRM_Core_Config::singleton();
         $groupParams['is_active'] = 1;
         $optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $defaults);
     }
     // if the corresponding group doesn't exist, create one, provided $groupParams has 'name' in it.
     if (!$optionGroup->id) {
         if ($groupParams['name']) {
             $newOptionGroup = CRM_Core_BAO_OptionGroup::add($groupParams, $defaults);
             $params['weight'] = 1;
             $optionGroupID = $newOptionGroup->id;
         }
     } else {
         $optionGroupID = $optionGroup->id;
         $oldWeight = NULL;
         if ($optionValueID) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'weight', 'id');
         }
         $fieldValues = array('option_group_id' => $optionGroupID);
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues);
     }
     $params['option_group_id'] = $optionGroupID;
     if ($action & CRM_Core_Action::ADD && empty($params['value'])) {
         $fieldValues = array('option_group_id' => $optionGroupID);
         // use the next available value
         /* CONVERT(value, DECIMAL) is used to convert varchar
            field 'value' to decimal->integer                    */
         $params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, 'CONVERT(value, DECIMAL)');
     }
     if (!$params['label'] && $params['name']) {
         $params['label'] = $params['name'];
     }
     // set name to label if it's not set - but *only* for ADD action (CRM-3522)
     if ($action & CRM_Core_Action::ADD && empty($params['name']) && $params['label']) {
         $params['name'] = $params['label'];
     }
     if ($action & CRM_Core_Action::UPDATE) {
         $ids['optionValue'] = $optionValueID;
     }
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
     return $optionValue;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:61,代码来源:OptionValue.php

示例6: add

 /**
  * function to add the UF Field
  *
  * @param array $params (reference) array containing the values submitted by the form
  * @param array $ids    (reference) array containing the id
  *
  * @return object CRM_Core_BAO_UFField object
  *
  * @access public
  * @static
  *
  */
 static function add(&$params, &$ids)
 {
     // set values for uf field properties and save
     $ufField = new CRM_Core_DAO_UFField();
     $ufField->field_type = $params['field_name'][0];
     $ufField->field_name = $params['field_name'][1];
     //should not set location type id for Primary
     $locationTypeId = CRM_Utils_Array::value(2, $params['field_name']);
     if ($locationTypeId) {
         $ufField->location_type_id = $locationTypeId;
     } else {
         $ufField->location_type_id = 'null';
     }
     $ufField->phone_type_id = CRM_Utils_Array::value(3, $params['field_name'], 'NULL');
     $ufField->listings_title = CRM_Utils_Array::value('listings_title', $params);
     $ufField->visibility = CRM_Utils_Array::value('visibility', $params);
     $ufField->help_pre = CRM_Utils_Array::value('help_pre', $params);
     $ufField->help_post = CRM_Utils_Array::value('help_post', $params);
     $ufField->label = CRM_Utils_Array::value('label', $params);
     $ufField->is_required = CRM_Utils_Array::value('is_required', $params, FALSE);
     $ufField->is_active = CRM_Utils_Array::value('is_active', $params, FALSE);
     $ufField->in_selector = CRM_Utils_Array::value('in_selector', $params, FALSE);
     $ufField->is_view = CRM_Utils_Array::value('is_view', $params, FALSE);
     $ufField->is_registration = CRM_Utils_Array::value('is_registration', $params, FALSE);
     $ufField->is_match = CRM_Utils_Array::value('is_match', $params, FALSE);
     $ufField->is_searchable = CRM_Utils_Array::value('is_searchable', $params, FALSE);
     // fix for CRM-316
     $oldWeight = NULL;
     if (CRM_Utils_Array::value('field_id', $params)) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $params['field_id'], 'weight', 'id');
     }
     $fieldValues = array('uf_group_id' => $params['group_id']);
     $ufField->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, $params['weight'], $fieldValues);
     // need the FKEY - uf group id
     $ufField->uf_group_id = CRM_Utils_Array::value('uf_group', $ids, FALSE);
     $ufField->id = CRM_Utils_Array::value('uf_field', $ids, FALSE);
     return $ufField->save();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:50,代码来源:UFField.php

示例7: postProcess

 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $urlParams = 'civicrm/admin/contribute/premium';
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $single = $session->get('singleForm');
         CRM_Utils_System::redirect($url);
         return;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->id = $this->_pid;
         $dao->delete();
         CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'), ts('Saved'), 'success');
         CRM_Utils_System::redirect($url);
     } else {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         if ($this->_pid) {
             $params['id'] = $this->_pid;
         }
         $dao = new CRM_Contribute_DAO_Premium();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $this->_id;
         $dao->find(TRUE);
         $premiumID = $dao->id;
         $params['premiums_id'] = $premiumID;
         $oldWeight = NULL;
         if ($this->_pid) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $this->_pid, 'weight', 'id');
         }
         // updateOtherWeights needs to filter on premiums_id
         $filter = array('premiums_id' => $params['premiums_id']);
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Contribute_DAO_PremiumsProduct', $oldWeight, $params['weight'], $filter);
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->copyValues($params);
         $dao->save();
         CRM_Utils_System::redirect($url);
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:50,代码来源:AddProduct.php

示例8: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         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 {
         $buttonName = $this->controller->getButtonName();
         $submitted = $this->controller->exportValues($this->_name);
         $this->set('searchDone', 0);
         if ($buttonName == '_qf_MembershipType_refresh') {
             $this->search($submitted);
             $this->set('searchDone', 1);
             return;
         }
         $fields = array('name', 'weight', 'is_active', 'member_org', 'visibility', 'period_type', 'minimum_fee', 'description', 'auto_renew', 'autorenewal_msg_id', 'duration_unit', 'renewal_msg_id', 'duration_interval', 'renewal_reminder_day', 'contribution_type_id', 'fixed_period_start_day', 'fixed_period_rollover_day');
         $params = $ids = array();
         foreach ($fields as $fld) {
             $params[$fld] = CRM_Utils_Array::value($fld, $submitted, 'NULL');
         }
         //clean money.
         if ($params['minimum_fee']) {
             $params['minimum_fee'] = CRM_Utils_Rule::cleanMoney($params['minimum_fee']);
         }
         $hasRelTypeVal = FALSE;
         if (!CRM_Utils_System::isNull($submitted['relationship_type_id'])) {
             // To insert relation ids and directions with value separator
             $relTypeDirs = $submitted['relationship_type_id'];
             $relIds = $relDirection = array();
             foreach ($relTypeDirs as $key => $value) {
                 $relationId = explode('_', $value);
                 if (count($relationId) == 3 && is_numeric($relationId[0])) {
                     $relIds[] = $relationId[0];
                     $relDirection[] = $relationId[1] . '_' . $relationId[2];
                 }
             }
             if (!empty($relIds)) {
                 $hasRelTypeVal = TRUE;
                 $params['relationship_type_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $relIds);
                 $params['relationship_direction'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $relDirection);
             }
         }
         if (!$hasRelTypeVal) {
             $params['relationship_type_id'] = $params['relationship_direction'] = 'NULL';
         }
         if ($params['duration_unit'] == 'lifetime' && 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 (CRM_Utils_Array::value('M', $params[$per]) && CRM_Utils_Array::value('d', $params[$per])) {
                 $mon = $params[$per]['M'];
                 $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', $submitted);
         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']);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['membershipType'] = $this->_id;
         }
         $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The membership type \'%1\' has been saved.', array(1 => $membershipType->name)));
         $session = CRM_Core_Session::singleton();
         if ($buttonName == $this->getButtonName('upload', 'new')) {
             CRM_Core_Session::setStatus(ts(' You can add another membership type.'));
             $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/member/membershipType', 'action=add&reset=1'));
         }
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:86,代码来源:MembershipType.php

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

示例10: create

 /**
  * takes an associative array and creates a custom group object
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Core_DAO_CustomGroup object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     // create custom group dao, populate fields and then save.
     $group = new CRM_Core_DAO_CustomGroup();
     $group->title = $params['title'];
     require_once 'CRM/Utils/String.php';
     if (isset($params['name'])) {
         $group->name = $params['name'];
     } else {
         $maxLength = CRM_Core_DAO::getAttribute('CRM_Core_DAO_CustomGroup', 'name');
         $group->name = CRM_Utils_String::titleToVar($params['title'], CRM_Utils_Array::value('maxlength', $maxLength));
     }
     if (in_array($params['extends'][0], array('ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'))) {
         $group->extends = 'Participant';
     } else {
         $group->extends = $params['extends'][0];
     }
     $group->extends_entity_column_id = null;
     if ($params['extends'][0] == 'ParticipantRole' || $params['extends'][0] == 'ParticipantEventName' || $params['extends'][0] == 'ParticipantEventType') {
         $group->extends_entity_column_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $params['extends'][0], 'value', 'name');
     }
     //this is format when form get submit.
     $extendsChildType = CRM_Utils_Array::value(1, $params['extends']);
     //lets allow user to pass direct child type value, CRM-6893
     if (CRM_Utils_Array::value('extends_entity_column_value', $params)) {
         $extendsChildType = $params['extends_entity_column_value'];
     }
     if (!CRM_Utils_System::isNull($extendsChildType)) {
         $extendsChildType = implode(CRM_Core_DAO::VALUE_SEPARATOR, $extendsChildType);
         if (CRM_Utils_Array::value(0, $params['extends']) == 'Relationship') {
             $extendsChildType = str_replace(array('_a_b', '_b_a'), array('', ''), $extendsChildType);
         }
         if (substr($extendsChildType, 0, 1) != CRM_Core_DAO::VALUE_SEPARATOR) {
             $extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $extendsChildType = 'null';
     }
     $group->extends_entity_column_value = $extendsChildType;
     if (isset($params['id'])) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'weight', 'id');
     } else {
         $oldWeight = 0;
     }
     require_once 'CRM/Utils/Weight.php';
     $group->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomGroup', $oldWeight, CRM_Utils_Array::value('weight', $params, false));
     $fields = array('style', 'collapse_display', 'collapse_adv_display', 'help_pre', 'help_post', 'is_active', 'is_multiple');
     foreach ($fields as $field) {
         $group->{$field} = CRM_Utils_Array::value($field, $params, false);
     }
     $group->max_multiple = isset($params['is_multiple']) ? isset($params['max_multiple']) && $params['max_multiple'] >= '0' ? $params['max_multiple'] : 'null' : 'null';
     $tableName = null;
     if (isset($params['id'])) {
         $group->id = $params['id'];
         //check whether custom group was changed from single-valued to multiple-valued
         $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'is_multiple');
         if ($params['is_multiple'] != $isMultiple && (CRM_Utils_Array::value('is_multiple', $params) || $isMultiple)) {
             $oldTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'table_name');
         }
     } else {
         $group->created_id = CRM_Utils_Array::value('created_id', $params);
         $group->created_date = CRM_Utils_Array::value('created_date', $params);
         require_once 'CRM/Utils/String.php';
         // lets create the table associated with the group and save it
         $tableName = $group->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($group->title, '_', 32));
         // we do this only once, so name never changes
         $group->name = CRM_Utils_String::munge($params['title'], '_', 64);
     }
     // enclose the below in a transaction
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $group->save();
     if ($tableName) {
         // now append group id to table name, this prevent any name conflicts
         // like CRM-2742
         $tableName .= "_{$group->id}";
         $group->table_name = $tableName;
         CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $group->id, 'table_name', $tableName);
         // now create the table associated with this group
         self::createTable($group);
     } elseif ($oldTableName) {
         require_once 'CRM/Core/BAO/SchemaHandler.php';
         CRM_Core_BAO_SchemaHandler::changeUniqueToIndex($oldTableName, CRM_Utils_Array::value('is_multiple', $params));
     }
     if (CRM_Utils_Array::value('overrideFKConstraint', $params) == 1) {
         $table = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'table_name');
         require_once 'CRM/Core/BAO/SchemaHandler.php';
         CRM_Core_BAO_SchemaHandler::changeFKConstraint($table, self::mapTableName($params['extends'][0]));
     }
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:CustomGroup.php

示例11: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $dataTypeKey = $this->_defaultDataType[0];
         $params['data_type'] = self::$_dataTypeKeys[$this->_defaultDataType[0]];
         $params['html_type'] = self::$_dataToHTML[$this->_defaultDataType[0]][$this->_defaultDataType[1]];
     } else {
         $dataTypeKey = $params['data_type'][0];
         $params['html_type'] = self::$_dataToHTML[$params['data_type'][0]][$params['data_type'][1]];
         $params['data_type'] = self::$_dataTypeKeys[$params['data_type'][0]];
     }
     //fix for 'is_search_range' field.
     if (in_array($dataTypeKey, array(1, 2, 3, 5))) {
         if (!CRM_Utils_Array::value('is_searchable', $params)) {
             $params['is_search_range'] = 0;
         }
     } else {
         $params['is_search_range'] = 0;
     }
     // fix for CRM-316
     $oldWeight = null;
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $fieldValues = array('custom_group_id' => $this->_gid);
         if ($this->_id) {
             $oldWeight = $this->_values['weight'];
         }
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $oldWeight, $params['weight'], $fieldValues);
     }
     //store the primary key for State/Province or Country as default value.
     if (strlen(trim($params['default_value']))) {
         switch ($params['data_type']) {
             case 'StateProvince':
                 $fieldStateProvince = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_state_province \n WHERE LOWER(name) = '{$fieldStateProvince}' \n    OR abbreviation = '{$fieldStateProvince}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
             case 'Country':
                 $fieldCountry = strtolower($params['default_value']);
                 $query = "\nSELECT id\n  FROM civicrm_country\n WHERE LOWER(name) = '{$fieldCountry}' \n    OR iso_code = '{$fieldCountry}'";
                 $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
                 if ($dao->fetch()) {
                     $params['default_value'] = $dao->id;
                 }
                 break;
         }
     }
     // need the FKEY - custom group id
     $params['custom_group_id'] = $this->_gid;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $customField = CRM_Core_BAO_CustomField::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.', array(1 => $customField->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 custom field.'));
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=add&gid=' . $this->_gid));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Field.php

示例12: postProcess

 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($this->_id)) {
             CRM_Core_Session::setStatus(ts('Selected participant status has been deleted.'), ts('Record Deleted'), 'success');
         } else {
             CRM_Core_Session::setStatus(ts('Selected participant status has <strong>NOT</strong> been deleted; there are still participants with this status.'), ts('Sorry'), 'error');
         }
         return;
     }
     $formValues = $this->controller->exportValues($this->_name);
     $params = array('name' => CRM_Utils_Array::value('name', $formValues), 'label' => CRM_Utils_Array::value('label', $formValues), 'class' => CRM_Utils_Array::value('class', $formValues), 'is_active' => CRM_Utils_Array::value('is_active', $formValues, FALSE), 'is_counted' => CRM_Utils_Array::value('is_counted', $formValues, FALSE), 'weight' => CRM_Utils_Array::value('weight', $formValues), 'visibility_id' => CRM_Utils_Array::value('visibility_id', $formValues));
     // make sure a malicious POST does not change these on reserved statuses
     if ($this->_isReserved) {
         unset($params['name'], $params['class'], $params['is_active']);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     if ($this->_id) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantStatusType', $this->_id, 'weight', 'id');
     } else {
         $oldWeight = 0;
     }
     $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Event_DAO_ParticipantStatusType', $oldWeight, $params['weight']);
     $participantStatus = CRM_Event_BAO_ParticipantStatusType::create($params);
     if ($participantStatus->id) {
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Core_Session::setStatus(ts('The Participant Status has been updated.'), ts('Saved'), 'success');
         } else {
             CRM_Core_Session::setStatus(ts('The new Participant Status has been saved.'), ts('Saved'), 'success');
         }
     } else {
         CRM_Core_Session::setStatus(ts('The changes have not been saved.'), ts('Saved'), 'success');
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:36,代码来源:ParticipantStatusType.php

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

示例14: create

 /**
  * Creates a new entry in the database.
  *
  * @param array $params
  *   (reference), array $ids.
  *
  * @param $ids
  *
  * @return CRM_Price_DAO_PriceFieldValue
  */
 public static function create(&$params, $ids = array())
 {
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids));
     if (!is_array($params) || empty($params)) {
         return NULL;
     }
     if (!$id && empty($params['name'])) {
         $params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
     }
     if ($id && !empty($params['weight'])) {
         if (isset($params['name'])) {
             unset($params['name']);
         }
         $oldWeight = NULL;
         if ($id) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'weight', 'id');
         }
         $fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceFieldValue', $oldWeight, $params['weight'], $fieldValues);
     } else {
         if (!$id) {
             CRM_Core_DAO::setCreateDefaults($params, self::getDefaults());
             if (empty($params['name'])) {
                 $params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
             }
         }
     }
     return self::add($params, $ids);
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:39,代码来源:PriceFieldValue.php

示例15: upgrade_1105

 public function upgrade_1105()
 {
     $this->ctx->log->info('Applying update 1105');
     $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_group_id', array('labelColumn' => 'name'));
     $customFieldID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', 'Is_Visa_Required', 'id', 'name');
     $customGroupID = array_search('Extended_Demographics', $groups);
     if ($customFieldID && $customGroupID) {
         CRM_Core_BAO_CustomField::moveField($customFieldID, $customGroupID);
         $result = civicrm_api3('CustomField', 'get', array('sequential' => 1, 'name' => 'Is_Visa_Required'));
         $weight = $result['values']['weight'];
         //fix the weight so that the field is next to nationality
         $fieldValues['custom_group_id'] = $customGroupID;
         CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomField', $weight, 2, $fieldValues);
         $params = array('sequential' => 1, 'id' => $result['id'], 'is_active' => 1, 'html_type' => 'Radio', 'data_type' => 'Boolean', 'weight' => 2);
         $result = civicrm_api3('CustomField', 'create', $params);
     }
     return TRUE;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:18,代码来源:Upgrader.php


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