當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DynamicField::save方法代碼示例

本文整理匯總了PHP中DynamicField::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP DynamicField::save方法的具體用法?PHP DynamicField::save怎麽用?PHP DynamicField::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DynamicField的用法示例。


在下文中一共展示了DynamicField::save方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveIdLabel

 /**
  * Save label for id field
  *
  * @param string $idLabelName
  * @param DynamicField $df
  */
 protected function saveIdLabel($idLabelName, $df)
 {
     if ($df instanceof DynamicField) {
         $module = $df->module;
     } elseif ($df instanceof MBModule) {
         $module = $df->name;
     } else {
         Log::fatal('Unsupported DynamicField type');
     }
     $viewPackage = isset($df->package) ? $df->package : null;
     $idLabelValue = string_format($GLOBALS['mod_strings']['LBL_RELATED_FIELD_ID_NAME_LABEL'], array($this->label_value, $GLOBALS['app_list_strings']['moduleListSingular'][$this->ext2]));
     $idFieldLabelArr = array("label_{$idLabelName}" => $idLabelValue);
     foreach (ModuleBuilder::getModuleAliases($module) as $moduleName) {
         if ($df instanceof DynamicField) {
             $parser = new ParserLabel($moduleName, $viewPackage);
             $parser->handleSave($idFieldLabelArr, $GLOBALS['current_language']);
         } elseif ($df instanceof MBModule) {
             $df->setLabel($GLOBALS['current_language'], $idLabelName, $idLabelValue);
             $df->save();
         }
     }
 }
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:28,代碼來源:TemplateRelatedTextField.php

示例2: save

 /**
  * Implements a generic insert and update logic for any SugarBean
  * This method only works for subclasses that implement the same variable names.
  * This method uses the presence of an id field that is not null to signify and update.
  * The id field should not be set otherwise.
  *
  * TODO: Add support for field type validation and encoding of parameters.
  *
  * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email.
  *
  * @return string
  */
 function save($check_notify = false)
 {
     $this->in_save = true;
     // cn: SECURITY - strip XSS potential vectors
     $this->cleanBean();
     // This is used so custom/3rd-party code can be upgraded with fewer issues, this will be removed in a future release
     $this->fixUpFormatting();
     global $timedate, $current_user, $action;
     $isUpdate = true;
     if (empty($this->id)) {
         $isUpdate = false;
     }
     if ($this->new_with_id == true) {
         $isUpdate = false;
     }
     if (empty($this->date_modified) || $this->update_date_modified) {
         $this->date_modified = $GLOBALS['timedate']->nowDb();
     }
     $this->_checkOptimisticLocking($action, $isUpdate);
     if (!empty($this->modified_by_name)) {
         $this->old_modified_by_name = $this->modified_by_name;
     }
     if ($this->update_modified_by) {
         $this->modified_user_id = 1;
         if (!empty($current_user)) {
             $this->modified_user_id = $current_user->id;
             $this->modified_by_name = $current_user->user_name;
         }
     }
     if ($this->deleted != 1) {
         $this->deleted = 0;
     }
     if (!$isUpdate) {
         if (empty($this->date_entered)) {
             $this->date_entered = $this->date_modified;
         }
         if ($this->set_created_by == true) {
             // created by should always be this user
             $this->created_by = isset($current_user) ? $current_user->id : "";
         }
         if ($this->new_with_id == false) {
             $this->id = create_guid();
         }
     }
     require_once "data/BeanFactory.php";
     BeanFactory::registerBean($this->module_name, $this);
     if (empty($GLOBALS['updating_relationships']) && empty($GLOBALS['saving_relationships']) && empty($GLOBALS['resavingRelatedBeans'])) {
         $GLOBALS['saving_relationships'] = true;
         // let subclasses save related field changes
         $this->save_relationship_changes($isUpdate);
         $GLOBALS['saving_relationships'] = false;
     }
     if ($isUpdate && !$this->update_date_entered) {
         unset($this->date_entered);
     }
     // call the custom business logic
     $custom_logic_arguments['check_notify'] = $check_notify;
     $this->call_custom_logic("before_save", $custom_logic_arguments);
     unset($custom_logic_arguments);
     // If we're importing back semi-colon separated non-primary emails
     if ($this->hasEmails() && !empty($this->email_addresses_non_primary) && is_array($this->email_addresses_non_primary)) {
         // Add each mail to the account
         foreach ($this->email_addresses_non_primary as $mail) {
             $this->emailAddress->addAddress($mail);
         }
         $this->emailAddress->save($this->id, $this->module_dir);
     }
     if (isset($this->custom_fields)) {
         $this->custom_fields->bean = $this;
         $this->custom_fields->save($isUpdate);
     }
     //construct the SQL to create the audit record if auditing is enabled.
     $auditDataChanges = [];
     if ($this->is_AuditEnabled()) {
         if ($isUpdate && !isset($this->fetched_row)) {
             Log::debug('Auditing: Retrieve was not called, audit record will not be created.');
         } else {
             $auditDataChanges = $this->db->getAuditDataChanges($this);
         }
     }
     $this->_sendNotifications($check_notify);
     if ($isUpdate) {
         $this->db->update($this);
     } else {
         $this->db->insert($this);
     }
     if (!empty($auditDataChanges) && is_array($auditDataChanges)) {
         foreach ($auditDataChanges as $change) {
//.........這裏部分代碼省略.........
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:101,代碼來源:SugarBean.php


注:本文中的DynamicField::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。