Example #1
0
 protected function saveImportBean($focus, $newRecord)
 {
     global $timedate, $current_user;
     // Populate in any default values to the bean
     $focus->populateDefaultValues();
     if (!isset($focus->assigned_user_id) || $focus->assigned_user_id == '' && $newRecord) {
         $focus->assigned_user_id = $current_user->id;
     }
     /*
      * Bug 34854: Added all conditions besides the empty check on date modified.
      */
     if (!empty($focus->new_with_id) && !empty($focus->date_modified) || empty($focus->new_with_id) && $timedate->to_db($focus->date_modified) != $timedate->to_db($timedate->to_display_date_time($focus->fetched_row['date_modified']))) {
         $focus->update_date_modified = false;
     }
     $focus->optimistic_lock = false;
     if ($focus->object_name == "Contact" && isset($focus->sync_contact)) {
         //copy the potential sync list to another varible
         $list_of_users = $focus->sync_contact;
         //and set it to false for the save
         $focus->sync_contact = false;
     } else {
         if ($focus->object_name == "User" && !empty($current_user) && $focus->is_admin && !is_admin($current_user) && is_admin_for_module($current_user, 'Users')) {
             sugar_die($GLOBALS['mod_strings']['ERR_IMPORT_SYSTEM_ADMININSTRATOR']);
         }
     }
     //bug# 46411 importing Calls will not populate Leads or Contacts Subpanel
     if (!empty($focus->parent_type) && !empty($focus->parent_id)) {
         foreach ($focus->relationship_fields as $key => $val) {
             if ($val == strtolower($focus->parent_type)) {
                 $focus->{$key} = $focus->parent_id;
             }
         }
     }
     //bug# 40260 setting it true as the module in focus is involved in an import
     $focus->in_import = true;
     // call any logic needed for the module preSave
     $focus->beforeImportSave();
     // if modified_user_id is set, set the flag to false so SugarBEan will not reset it
     if (isset($focus->modified_user_id) && $focus->modified_user_id) {
         $focus->update_modified_by = false;
     }
     // if created_by is set, set the flag to false so SugarBEan will not reset it
     if (isset($focus->created_by) && $focus->created_by) {
         $focus->set_created_by = false;
     }
     if ($focus->object_name == "Contact" && isset($list_of_users)) {
         $focus->process_sync_to_outlook($list_of_users);
     }
     $focus->save(false);
     //now that save is done, let's make sure that parent and related id's were saved as relationships
     //this takes place before the afterImportSave()
     $this->checkRelatedIDsAfterSave($focus);
     // call any logic needed for the module postSave
     $focus->afterImportSave();
     // Add ID to User's Last Import records
     if ($newRecord) {
         $this->importSource->writeRowToLastImport($_REQUEST['import_module'], $focus->object_name == 'Case' ? 'aCase' : $focus->object_name, $focus->id);
     }
 }
Example #2
0
 protected function saveImportBean($focus, $newRecord)
 {
     global $timedate, $current_user;
     // Populate in any default values to the bean
     $focus->populateDefaultValues();
     if (!isset($focus->assigned_user_id) || $focus->assigned_user_id == '' && $newRecord) {
         $focus->assigned_user_id = $current_user->id;
     }
     /*
      * Bug 34854: Added all conditions besides the empty check on date modified.
      */
     if (!empty($focus->new_with_id) && !empty($focus->date_modified) || empty($focus->new_with_id) && $timedate->to_db($focus->date_modified) != $timedate->to_db($timedate->to_display_date_time($focus->fetched_row['date_modified']))) {
         $focus->update_date_modified = false;
     }
     $focus->optimistic_lock = false;
     if ($focus->object_name == "Contacts" && isset($focus->sync_contact)) {
         //copy the potential sync list to another varible
         $list_of_users = $focus->sync_contact;
         //and set it to false for the save
         $focus->sync_contact = false;
     } else {
         if ($focus->object_name == "User" && !empty($current_user) && $focus->is_admin && !is_admin($current_user) && is_admin_for_module($current_user, 'Users')) {
             sugar_die($GLOBALS['mod_strings']['ERR_IMPORT_SYSTEM_ADMININSTRATOR']);
         }
     }
     //bug# 40260 setting it true as the module in focus is involved in an import
     $focus->in_import = true;
     // call any logic needed for the module preSave
     $focus->beforeImportSave();
     $focus->save(false);
     // call any logic needed for the module postSave
     $focus->afterImportSave();
     if ($focus->object_name == "Contacts" && isset($list_of_users)) {
         $focus->process_sync_to_outlook($list_of_users);
     }
     // Add ID to User's Last Import records
     if ($newRecord) {
         $this->importSource->writeRowToLastImport($_REQUEST['import_module'], $focus->object_name == 'Case' ? 'aCase' : $focus->object_name, $focus->id);
     }
 }