function action_save() { $move = false; $file = new File(); $file = populateFromPost('', $file); $upload_file = new UploadFile('uploadfile'); $return_id = ''; if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) { $file->filename = $upload_file->get_stored_file_name(); $file->file_mime_type = $upload_file->mime_type; $file->file_ext = $upload_file->file_ext; $move = true; } $return_id = $file->save(); if ($move) { $upload_file->final_move($file->id); } handleRedirect($return_id, $this->object_name); }
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. */ require_once 'modules/Paperformat/Paperformat.php'; require_once 'include/formbase.php'; $sugarbean = new Paperformat(); $sugarbean = populateFromPost('', $sugarbean); if (isset($_REQUEST['email_id'])) { $sugarbean->email_id = $_REQUEST['email_id']; } if (!$sugarbean->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $sugarbean->save($GLOBALS['check_notify']); $return_id = $sugarbean->id; handleRedirect($return_id, 'Paperformat');
if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } foreach ($focus->additional_column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } if (!empty($this->uploadfile)) { $this->picture = $this->uploadfile; } $focus->save($check_notify); $return_id = $focus->id; if (!empty($_POST['uploadfile'])) { $file_name = $_FILES['uploadfile']['name']; $ext = explode('.', $file_name); $img_ext = $ext[count($ext) - 1]; $image_extension = 'jpg_jpeg_gif_bmp_png'; $image_extension_arr = explode('_', $image_extension); for ($i = 0; $i < count($image_extension_arr); $i++) { if ($img_ext != $image_extension_arr[$i]) { echo "<script language='javascript'> alert('file ảnh không hợp lệ'); </script>"; } } move_uploaded_file($_FILES['uploadfile']['tmp_name'], 'modules/images/' . $_FILES['uploadfile']['tmp_name']); } handleRedirect($return_id, 'Destinations');
$query = "SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; $query .= " left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; $query .= " where email_marketing.campaign_id='{$record}'"; $query .= " and email_marketing_prospect_lists.prospect_list_id='{$linked_id}'"; $result = $focus->db->query($query); while (($row = $focus->db->fetchByAssoc($result)) != null) { $del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=" . db_convert("'" . gmdate($GLOBALS['timedate']->get_db_date_time_format(), time()) . "'", 'datetime'); $del_query .= " WHERE email_marketing_prospect_lists.id='{$row['id']}'"; $focus->db->query($del_query); } $focus->db->query($query); } if ($bean_name == "Meeting") { $focus->retrieve($record); $user = new User(); $user->retrieve($linked_id); if (!empty($user->id)) { //make sure that record exists. we may have a contact on our hands. if ($focus->update_vcal) { vCal::cache_sugar_vcal($user); } } } if (!empty($_REQUEST['return_url'])) { $_REQUEST['return_url'] = urldecode($_REQUEST['return_url']); } $GLOBALS['log']->debug("deleted relationship: bean: {$bean_name}, linked_field: {$linked_field}, linked_id:{$linked_id}"); if (empty($_REQUEST['refresh_page'])) { handleRedirect(); } exit;
$focus = new CampaignTracker(); $focus->retrieve($_POST['record']); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $check_notify = FALSE; foreach ($focus->column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } foreach ($focus->additional_column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } //set check box states. if (isset($_POST['is_optout']) && $_POST['is_optout'] == 'on') { $focus->is_optout = 1; $focus->tracker_url = 'index.php?entryPoint=removeme'; } else { $focus->is_optout = 0; } $focus->save($check_notify); $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); handleRedirect('', '');
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; $focus = new Account(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } else { $check_notify = FALSE; } if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicateAccounts = $this->checkForDuplicates($prefix); if (isset($duplicateAccounts)) { $location = 'module=Accounts&action=ShowDuplicates'; $get = ''; //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->{$field}) && !is_object($focus->{$field})) { $get .= "&Accounts{$field}=" . urlencode($focus->{$field}); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->{$field})) { $get .= "&Accounts{$field}=" . urlencode($focus->{$field}); } } if ($focus->hasCustomFields()) { foreach ($focus->field_defs as $name => $field) { if (!empty($field['source']) && $field['source'] == 'custom_fields') { $get .= "&Accounts{$name}=" . urlencode($focus->{$name}); } } } $emailAddress = new SugarEmailAddress(); $get .= $emailAddress->getFormBaseURL($focus); //create list of suspected duplicate account id's in redirect get string $i = 0; foreach ($duplicateAccounts as $account) { $get .= "&duplicate[{$i}]=" . $account['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= '&return_module='; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= 'Accounts'; } $get .= '&return_action='; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } //else $get .= 'DetailView'; if (!empty($_POST['return_id'])) { $get .= '&return_id=' . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } //now redirect the post to modules/Accounts/ShowDuplicates.php if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { $json = getJSONobj(); echo $json->encode(array('status' => 'dupe', 'get' => $get)); } else { if (!empty($_POST['to_pdf'])) { $location .= '&to_pdf=' . $_POST['to_pdf']; } $_SESSION['SHOW_DUPLICATES'] = $get; header("Location: index.php?{$location}"); } return null; } } if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->save($check_notify); $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { $json = getJSONobj(); echo $json->encode(array('status' => 'success', 'get' => '')); return null; } if (isset($_POST['popup']) && $_POST['popup'] == 'true') { $get = '&module='; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= 'Accounts'; } $get .= '&action='; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } else { $get .= 'Popup'; } if (!empty($_POST['return_id'])) { $get .= '&return_id=' . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } if (!empty($_POST['to_pdf'])) { $get .= '&to_pdf=' . $_POST['to_pdf']; } $get .= '&name=' . $focus->name; $get .= '&query=true'; header("Location: index.php?{$get}"); return; } if ($redirect) { handleRedirect($return_id, 'Accounts'); } else { return $focus; } }
sugar_cleanup(true); } if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } else { $check_notify = FALSE; } $sugarbean->save($check_notify); $return_id = $sugarbean->id; if (isset($_REQUEST['save_type']) || isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") { for ($i = 0; $i < count($projectTasks); $i++) { if (isset($_REQUEST['save_type']) || isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") { $projectTasks[$i]->id = ''; $projectTasks[$i]->project_id = $sugarbean->id; } if ($sugarbean->is_template) { $projectTasks[$i]->assigned_user_id = ''; } $projectTasks[$i]->team_id = $sugarbean->team_id; if (empty($projectTasks[$i]->duration_unit)) { $projectTasks[$i]->duration_unit = " "; } //Since duration_unit cannot be null. $projectTasks[$i]->save(false); } } if ($sugarbean->is_template) { header("Location: index.php?action=ProjectTemplatesDetailView&module=Project&record={$return_id}&return_module=Project&return_action=ProjectTemplatesEditView"); } else { handleRedirect($return_id, 'Project'); }
* The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. */ require_once 'modules/ProductEstimate/ProductEstimate.php'; require_once 'modules/Products/Products.php'; require_once 'include/formbase.php'; $sugarbean = new ProductEstimate(); $sugarbean = populateFromPost('', $sugarbean); $sugarbean->status = "uptodate"; if (isset($_REQUEST['email_id'])) { $sugarbean->email_id = $_REQUEST['email_id']; } if (!$sugarbean->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $sugarbean->save($GLOBALS['check_notify']); $return_id = $sugarbean->id; $product = new Products(); $product->retrieve($sugarbean->product_id); //// Status Update if (isset($_REQUEST['stat_action']) && !empty($_REQUEST['stat_action']) && !is_null($_REQUEST['stat_action'])) { $product->status_update('', $product->id, $_REQUEST['stat_action'], ''); } else { $product->status_update('', $product->id, '', ''); } ///////////////// handleRedirect($return_id, 'ProductEstimate');
global $mod_strings; //if no prospect lists are attached, then lets create a subscription and unsubscription //default prospect lists as these are required for newsletters. //create subscription list $subs = new ProspectList(); $subs->name = $focus->name . ' ' . $mod_strings['LBL_SUBSCRIPTION_LIST']; $subs->assigned_user_id = $current_user->id; $subs->list_type = "default"; $subs->save(); $focus->prospectlists->add($subs->id); //create unsubscription list $unsubs = new ProspectList(); $unsubs->name = $focus->name . ' ' . $mod_strings['LBL_UNSUBSCRIPTION_LIST']; $unsubs->assigned_user_id = $current_user->id; $unsubs->list_type = "exempt"; $unsubs->save(); $focus->prospectlists->add($unsubs->id); //create unsubscription list $test_subs = new ProspectList(); $test_subs->name = $focus->name . ' ' . $mod_strings['LBL_TEST_LIST']; $test_subs->assigned_user_id = $current_user->id; $test_subs->list_type = "test"; $test_subs->save(); $focus->prospectlists->add($test_subs->id); } //save new relationships $focus->save(); } //finish newsletter processing handleRedirect($focus->id, 'Campaigns');
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. */ require_once 'modules/ProductOperations/ProductOperation.php'; require_once 'include/formbase.php'; $sugarbean = new ProductOperation(); $sugarbean = populateFromPost('', $sugarbean); if (isset($_REQUEST['email_id'])) { $sugarbean->email_id = $_REQUEST['email_id']; } if (!$sugarbean->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $sugarbean->save($GLOBALS['check_notify']); $return_id = $sugarbean->id; handleRedirect($return_id, 'ProductOperations');
/** * handles save functionality for meetings * @param string prefix * @param bool redirect default True * @param bool useRequired default True */ function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; global $current_user; global $timedate; $focus = BeanFactory::getBean('Meetings'); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } if (!isset($_POST['reminder_checked']) or isset($_POST['reminder_checked']) && $_POST['reminder_checked'] == '0') { $_POST['reminder_time'] = -1; } if (!isset($_POST['reminder_time'])) { $_POST['reminder_time'] = $current_user->getPreference('reminder_time'); $_POST['reminder_checked'] = 1; } if (!isset($_POST['email_reminder_checked']) || isset($_POST['email_reminder_checked']) && $_POST['email_reminder_checked'] == '0') { $_POST['email_reminder_time'] = -1; } if (!isset($_POST['email_reminder_time'])) { $_POST['email_reminder_time'] = $current_user->getPreference('email_reminder_time'); $_POST['email_reminder_checked'] = 1; } if (isset($_POST['repeat_parent_id']) && trim($_POST['repeat_parent_id']) == '') { unset($_POST['repeat_parent_id']); } // don't allow to set recurring_source from a form unset($_POST['recurring_source']); $time_format = $timedate->get_user_time_format(); $time_separator = ":"; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } if (!empty($_POST[$prefix . 'time_hour_start']) && empty($_POST['time_start'])) { $_POST[$prefix . 'time_start'] = $_POST[$prefix . 'time_hour_start'] . $time_separator . $_POST[$prefix . 'time_minute_start']; } if (isset($_POST[$prefix . 'meridiem']) && !empty($_POST[$prefix . 'meridiem'])) { $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(), $_POST[$prefix . 'meridiem']); } if (isset($_POST[$prefix . 'time_start']) && strlen($_POST[$prefix . 'date_start']) == 10) { $_POST[$prefix . 'date_start'] = $_POST[$prefix . 'date_start'] . ' ' . $_POST[$prefix . 'time_start']; } // retrieve happens here $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } // if dates changed if (!empty($focus->id)) { $oldBean = new Meeting(); $oldBean->retrieve($focus->id); if ($focus->date_start != $oldBean->date_start || $focus->date_end != $oldBean->date_end) { $focus->date_changed = true; } else { $focus->date_changed = false; } } $newBean = true; if (!empty($focus->id)) { $newBean = false; } //add assigned user and current user if this is the first time bean is saved if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Meetings' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] == 'DetailView') { //if return action is set to detail view and return module to meeting, then this is from the long form, do not add the assigned user (only the current user) //The current user is already added to UI and we want to give the current user the option of opting out of meeting. //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id']) { $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } } elseif (empty($focus->id)) { //this is not from long form so add assigned and current user automatically as there is no invitee list UI. //This call could be through an ajax call from subpanels or shortcut bar if (!isset($_POST['user_invitees'])) { $_POST['user_invitees'] = ''; } $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id'] && $_REQUEST['module'] != "Calendar") { $_POST['user_invitees'] .= ',' . $current_user->id . ', '; } //remove any double comma's introduced during appending $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } if (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true' || (isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id) || isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer' && !empty($focus->id)) || !isset($_POST['user_invitees'])) { $focus->save(true); $return_id = $focus->id; } else { if ($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()) { //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no //need to process user invitees, just save the current values. $focus->save(true); } else { $relate_to = $this->getRelatedModuleName($focus); $userInvitees = array(); $contactInvitees = array(); $leadInvitees = array(); $existingUsers = array(); $existingContacts = array(); $existingLeads = array(); if (!empty($_POST['user_invitees'])) { $userInvitees = explode(',', trim($_POST['user_invitees'], ',')); } if (!empty($_POST['existing_invitees'])) { $existingUsers = explode(",", trim($_POST['existing_invitees'], ',')); } if (!empty($_POST['contact_invitees'])) { $contactInvitees = explode(',', trim($_POST['contact_invitees'], ',')); } if (!empty($_POST['existing_contact_invitees'])) { $existingContacts = explode(",", trim($_POST['existing_contact_invitees'], ',')); } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') { $contactInvitees[] = $_POST['parent_id']; } if ($relate_to == 'Contacts') { if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $contactInvitees)) { $contactInvitees[] = $_REQUEST['relate_id']; } } if (!empty($_POST['lead_invitees'])) { $leadInvitees = explode(',', trim($_POST['lead_invitees'], ',')); } if (!empty($_POST['existing_lead_invitees'])) { $existingLeads = explode(",", trim($_POST['existing_lead_invitees'], ',')); } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Leads') { $leadInvitees[] = $_POST['parent_id']; } if ($relate_to == 'Leads') { if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $leadInvitees)) { $leadInvitees[] = $_REQUEST['relate_id']; } } // Call the Meeting module's save function to handle saving other fields besides // the users and contacts relationships $focus->update_vcal = false; // Bug #49195 : don't update vcal b/s related users aren't saved yet, create vcal cache below $focus->users_arr = $userInvitees; $focus->contacts_arr = $contactInvitees; $focus->leads_arr = $leadInvitees; $focus->save(true); $return_id = $focus->id; if (empty($return_id)) { //this is to handle the situation where the save fails, most likely because of a failure //in the external api. bug: 42200 $_REQUEST['action'] = 'EditView'; $_REQUEST['return_action'] = 'EditView'; handleRedirect('', 'Meetings'); } $focus->setUserInvitees($userInvitees, $existingUsers); $focus->setContactInvitees($contactInvitees, $existingContacts); $focus->setLeadInvitees($focus->leads_arr, $existingLeads); // Bug #49195 : update vcal vCal::cache_sugar_vcal($current_user); $this->processRecurring($focus); } } if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] === 'Home') { SugarApplication::redirect(buildRedirectURL('', 'Home')); } else { if ($redirect) { handleRedirect($return_id, 'Meetings'); } else { return $focus; } } }
<?php require_once 'include/formbase.php'; require_once 'modules/ZuckerRunnableReport/RunnableReport.php'; $runnable = new RunnableReport(); if (!empty($_REQUEST['record'])) { $runnable->retrieve($_REQUEST['record']); } $runnable = populateFromPost("", $runnable); if (empty($_REQUEST['schedule_interval'])) { $runnable->nextrun = ""; } else { global $timedate; if (empty($_REQUEST['schedule_start'])) { $runnable->nextrun = date($timedate->get_date_time_format(), time()); } else { $runnable->nextrun = date($timedate->get_date_time_format(), strtotime($_REQUEST['schedule_start'])); } } $_REQUEST['return_id'] = $runnable->save(); $_REQUEST['return_action'] = "DetailView"; handleRedirect($return_id, "ZuckerRunnableReport");
$sugarbean->email_id = $_REQUEST['email_id']; } if (!$sugarbean->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!isset($sugarbean->name) || is_null($sugarbean->name)) { $sugarbean->name = $sugarbean->generateName($sugarbean->id); } $sugarbean->save($GLOBALS['check_notify']); $return_id = $sugarbean->id; $pressLine1 = new Pressline(); $pressLine1->mark_deletedByPressid($return_id); $count = count($_POST); $keys = array_keys($_POST); for ($i = 0; $i < $count; $i++) { if (substr_count($keys[$i], "layout_id_") > 0) { $index = substr($keys[$i], -1, 1); $layout_id = $_POST["layout_id_" . $index]; $layout_name = $_POST["layout_name_" . $index]; $part = $_POST["part_" . $index]; $pressLine = new Pressline(); $pressLine->layout_id = $layout_id; $pressLine->layout_name = $layout_name; $pressLine->part = $part; $pressLine->press_id = $sugarbean->id; $pressLine->save(); } } handleRedirect($return_id, 'Press');
* (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. */ require_once 'modules/Pressmachine/Pressmachine.php'; require_once 'include/formbase.php'; $sugarbean = new Pressmachine(); $sugarbean = populateFromPost('', $sugarbean); foreach ($sugarbean->column_fields as $field) { if (!isset($_REQUEST['active'])) { $sugarbean->active = 'off'; } } if (isset($_REQUEST['email_id'])) { $sugarbean->email_id = $_REQUEST['email_id']; } if (!$sugarbean->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $sugarbean->save($GLOBALS['check_notify']); $return_id = $sugarbean->id; handleRedirect($return_id, 'Pressmachine');
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; global $current_user; global $timedate; //BUG 17418 MFH if (isset($_POST[$prefix . 'duration_hours'])) { $_POST[$prefix . 'duration_hours'] = trim($_POST[$prefix . 'duration_hours']); } $focus = new Call(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } if (!isset($_POST[$prefix . 'reminder_checked']) or $_POST[$prefix . 'reminder_checked'] == 0) { $GLOBALS['log']->debug(__FILE__ . '(' . __LINE__ . '): No reminder checked, resetting the reminder_time'); $_POST[$prefix . 'reminder_time'] = -1; } if (!isset($_POST[$prefix . 'reminder_time'])) { $GLOBALS['log']->debug(__FILE__ . '(' . __LINE__ . '): Getting the users default reminder time'); $_POST[$prefix . 'reminder_time'] = $current_user->getPreference('reminder_time'); } $time_format = $timedate->get_user_time_format(); $time_separator = ":"; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } if (!empty($_POST[$prefix . 'time_hour_start']) && empty($_POST[$prefix . 'time_start'])) { $_POST[$prefix . 'time_start'] = $_POST[$prefix . 'time_hour_start'] . $time_separator . $_POST[$prefix . 'time_minute_start']; } if (isset($_POST[$prefix . 'meridiem']) && !empty($_POST[$prefix . 'meridiem'])) { $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(), $_POST[$prefix . 'meridiem']); } if (isset($_POST[$prefix . 'time_start']) && strlen($_POST[$prefix . 'date_start']) == 10) { $_POST[$prefix . 'date_start'] = $_POST[$prefix . 'date_start'] . ' ' . $_POST[$prefix . 'time_start']; } // retrieve happens here $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } //add assigned user and current user if this is the first time bean is saved if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Calls' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] == 'DetailView') { //if return action is set to detail view and return module to call, then this is from the long form, do not add the assigned user (only the current user) //The current user is already added to UI and we want to give the current user the option of opting out of meeting. if ($current_user->id != $_POST['assigned_user_id']) { $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } } elseif (empty($focus->id)) { //this is not from long form so add assigned and current user automatically as there is no invitee list UI. //This call could be through an ajax call from subpanels or shortcut bar $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id']) { $_POST['user_invitees'] .= ',' . $current_user->id . ', '; } //remove any double comma's introduced during appending $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } if (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true' || isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id)) { $focus->save(true); $return_id = $focus->id; } else { if ($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()) { //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no //need to process user invitees, just save the current values. $focus->save(true); } else { /////////////////////////////////////////////////////////////////////////// //// REMOVE INVITEE RELATIONSHIPS if (!empty($_POST['user_invitees'])) { $userInvitees = explode(',', trim($_POST['user_invitees'], ',')); } else { $userInvitees = array(); } // Calculate which users to flag as deleted and which to add $deleteUsers = array(); $focus->load_relationship('users'); // Get all users for the call $q = 'SELECT mu.user_id, mu.accept_status FROM calls_users mu WHERE mu.call_id = \'' . $focus->id . '\''; $r = $focus->db->query($q); $acceptStatusUsers = array(); while ($a = $focus->db->fetchByAssoc($r)) { if (!in_array($a['user_id'], $userInvitees)) { $deleteUsers[$a['user_id']] = $a['user_id']; } else { $acceptStatusUsers[$a['user_id']] = $a['accept_status']; } } if (count($deleteUsers) > 0) { $sql = ''; foreach ($deleteUsers as $u) { $sql .= ",'" . $u . "'"; } $sql = substr($sql, 1); // We could run a delete SQL statement here, but will just mark as deleted instead $sql = "UPDATE calls_users set deleted = 1 where user_id in ({$sql}) AND call_id = '" . $focus->id . "'"; $focus->db->query($sql); } // Get all contacts for the call if (!empty($_POST['contact_invitees'])) { $contactInvitees = explode(',', trim($_POST['contact_invitees'], ',')); } else { $contactInvitees = array(); } $deleteContacts = array(); $focus->load_relationship('contacts'); $q = 'SELECT mu.contact_id, mu.accept_status FROM calls_contacts mu WHERE mu.call_id = \'' . $focus->id . '\''; $r = $focus->db->query($q); $acceptStatusContacts = array(); while ($a = $focus->db->fetchByAssoc($r)) { if (!in_array($a['contact_id'], $contactInvitees)) { $deleteContacts[$a['contact_id']] = $a['contact_id']; } else { $acceptStatusContacts[$a['contact_id']] = $a['accept_status']; } } if (count($deleteContacts) > 0) { $sql = ''; foreach ($deleteContacts as $u) { $sql .= ",'" . $u . "'"; } $sql = substr($sql, 1); // We could run a delete SQL statement here, but will just mark as deleted instead $sql = "UPDATE calls_contacts set deleted = 1 where contact_id in ({$sql}) AND call_id = '" . $focus->id . "'"; $focus->db->query($sql); } if (!empty($_POST['lead_invitees'])) { $leadInvitees = explode(',', trim($_POST['lead_invitees'], ',')); } else { $leadInvitees = array(); } // Calculate which leads to flag as deleted and which to add $deleteLeads = array(); $focus->load_relationship('leads'); // Get all leads for the call $q = 'SELECT mu.lead_id, mu.accept_status FROM calls_leads mu WHERE mu.call_id = \'' . $focus->id . '\''; $r = $focus->db->query($q); $acceptStatusLeads = array(); while ($a = $focus->db->fetchByAssoc($r)) { if (!in_array($a['lead_id'], $leadInvitees)) { $deleteLeads[$a['lead_id']] = $a['lead_id']; } else { $acceptStatusLeads[$a['user_id']] = $a['accept_status']; } } if (count($deleteLeads) > 0) { $sql = ''; foreach ($deleteLeads as $u) { // make sure we don't delete the assigned user if ($u != $focus->assigned_user_id) { $sql .= ",'" . $u . "'"; } } $sql = substr($sql, 1); // We could run a delete SQL statement here, but will just mark as deleted instead $sql = "UPDATE calls_leads set deleted = 1 where lead_id in ({$sql}) AND call_id = '" . $focus->id . "'"; $focus->db->query($sql); } //// END REMOVE /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //// REBUILD INVITEE RELATIONSHIPS $focus->users_arr = array(); $focus->users_arr = $userInvitees; $focus->contacts_arr = array(); $focus->contacts_arr = $contactInvitees; $focus->leads_arr = array(); $focus->leads_arr = $leadInvitees; if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') { $focus->contacts_arr[] = $_POST['parent_id']; } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Leads') { $focus->leads_arr[] = $_POST['parent_id']; } // Call the Call module's save function to handle saving other fields besides // the users and contacts relationships $focus->save(true); $return_id = $focus->id; // Process users $existing_users = array(); if (!empty($_POST['existing_invitees'])) { $existing_users = explode(",", trim($_POST['existing_invitees'], ',')); } foreach ($focus->users_arr as $user_id) { if (empty($user_id) || isset($existing_users[$user_id]) || isset($deleteUsers[$user_id])) { continue; } if (!isset($acceptStatusUsers[$user_id])) { $focus->load_relationship('users'); $focus->users->add($user_id); } else { // update query to preserve accept_status $qU = 'UPDATE calls_users SET deleted = 0, accept_status = \'' . $acceptStatusUsers[$user_id] . '\' '; $qU .= 'WHERE call_id = \'' . $focus->id . '\' '; $qU .= 'AND user_id = \'' . $user_id . '\''; $focus->db->query($qU); } } // Process contacts $existing_contacts = array(); if (!empty($_POST['existing_contact_invitees'])) { $existing_contacts = explode(",", trim($_POST['existing_contact_invitees'], ',')); } foreach ($focus->contacts_arr as $contact_id) { if (empty($contact_id) || isset($existing_contacts[$contact_id]) || isset($deleteContacts[$contact_id]) && $contact_id != $_POST['parent_id']) { continue; } if (!isset($acceptStatusContacts[$contact_id])) { $focus->load_relationship('contacts'); $focus->contacts->add($contact_id); } else { // update query to preserve accept_status $qU = 'UPDATE calls_contacts SET deleted = 0, accept_status = \'' . $acceptStatusContacts[$contact_id] . '\' '; $qU .= 'WHERE call_id = \'' . $focus->id . '\' '; $qU .= 'AND contact_id = \'' . $contact_id . '\''; $focus->db->query($qU); } } // Process leads $existing_leads = array(); if (!empty($_POST['existing_lead_invitees'])) { $existing_leads = explode(",", trim($_POST['existing_lead_invitees'], ',')); } foreach ($focus->leads_arr as $lead_id) { if (empty($lead_id) || isset($existing_leads[$lead_id]) || isset($deleteLeads[$lead_id]) && $lead_id != $_POST['parent_id']) { continue; } if (!isset($acceptStatusLeads[$lead_id])) { $focus->load_relationship('leads'); $focus->leads->add($lead_id); } else { // update query to preserve accept_status $qU = 'UPDATE calls_leads SET deleted = 0, accept_status = \'' . $acceptStatusLeads[$lead_id] . '\' '; $qU .= 'WHERE call_id = \'' . $focus->id . '\' '; $qU .= 'AND lead_id = \'' . $lead_id . '\''; $focus->db->query($qU); } } // CCL - Comment out call to set $current_user as invitee //set organizer to auto-accept //$focus->set_accept_status($current_user, 'accept'); //// END REBUILD INVITEE RELATIONSHIPS /////////////////////////////////////////////////////////////////////////// } } if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Home') { $_REQUEST['return_action'] = 'index'; handleRedirect('', 'Home'); } else { if ($redirect) { handleRedirect($return_id, 'Calls'); } else { return $focus; } } }
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; require_once 'include/upload_file.php'; global $upload_maxsize; global $mod_strings; global $sugar_config; $focus = new EmailTemplate(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); //process the text only flag if (isset($_POST['text_only']) && $_POST['text_only'] == '1') { $focus->text_only = 1; } else { $focus->text_only = 0; } if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!isset($_REQUEST['published'])) { $focus->published = 'off'; } $preProcessedImages = array(); $emailTemplateBodyHtml = from_html($focus->body_html); if (strpos($emailTemplateBodyHtml, '"cache/images/')) { $matches = array(); preg_match_all('#<img[^>]*[\\s]+src[^=]*=[\\s]*["\']cache/images/(.+?)["\']#si', $emailTemplateBodyHtml, $matches); foreach ($matches[1] as $match) { $filename = urldecode($match); $file_location = sugar_cached("images/{$filename}"); $mime_type = pathinfo($filename, PATHINFO_EXTENSION); if (file_exists($file_location)) { $id = create_guid(); $newFileLocation = "upload://{$id}"; if (!copy($file_location, $newFileLocation)) { $GLOBALS['log']->debug("EMAIL Template could not copy attachment to {$newFileLocation}"); } else { $secureLink = "index.php?entryPoint=download&type=Notes&id={$id}"; $emailTemplateBodyHtml = str_replace("cache/images/{$match}", $secureLink, $emailTemplateBodyHtml); unlink($file_location); $preProcessedImages[$filename] = $id; } } // if } // foreach } // if if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } else { $check_notify = FALSE; } $focus->body_html = $emailTemplateBodyHtml; $return_id = $focus->save($check_notify); /////////////////////////////////////////////////////////////////////////////// //// ATTACHMENT HANDLING /////////////////////////////////////////////////////////////////////////// //// ADDING NEW ATTACHMENTS $max_files_upload = count($_FILES); if (!empty($focus->id)) { $note = new Note(); $where = "notes.parent_id='{$focus->id}'"; if (!empty($_REQUEST['old_id'])) { // to support duplication of email templates $where .= " OR notes.parent_id='" . $_REQUEST['old_id'] . "'"; } $notes_list = $note->get_full_list("", $where, true); } if (!isset($notes_list)) { $notes_list = array(); } if (!is_array($focus->attachments)) { // PHP5 does not auto-create arrays(). Need to initialize it here. $focus->attachments = array(); } $focus->attachments = array_merge($focus->attachments, $notes_list); //for($i = 0; $i < $max_files_upload; $i++) { foreach ($_FILES as $key => $file) { $note = new Note(); //Images are presaved above so we need to prevent duplicate files from being created. if (isset($preProcessedImages[$file['name']])) { $oldId = $preProcessedImages[$file['name']]; $note->id = $oldId; $note->new_with_id = TRUE; $GLOBALS['log']->debug("Image {$file['name']} has already been processed."); } $i = preg_replace("/email_attachment(.+)/", '$1', $key); $upload_file = new UploadFile($key); if (isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/", $key)) { $note->filename = $upload_file->get_stored_file_name(); $note->file = $upload_file; $note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ' . $note->file->original_file_name; if (isset($_REQUEST['embedded' . $i]) && !empty($_REQUEST['embedded' . $i])) { if ($_REQUEST['embedded' . $i] == 'true') { $note->embed_flag = true; } else { $note->embed_flag = false; } } array_push($focus->attachments, $note); } } $focus->saved_attachments = array(); foreach ($focus->attachments as $note) { if (!empty($note->id) && $note->new_with_id === FALSE) { if (empty($_REQUEST['old_id'])) { array_push($focus->saved_attachments, $note); } else { // we're duplicating a template with attachments // dupe the file, create a new note, assign the note to the new template $newNote = new Note(); $newNote->retrieve($note->id); $newNote->id = create_guid(); $newNote->parent_id = $focus->id; $newNote->new_with_id = true; $newNote->date_modified = ''; $newNote->date_entered = ''; $newNoteId = $newNote->save(); UploadFile::duplicate_file($note->id, $newNoteId, $note->filename); } continue; } $note->parent_id = $focus->id; $note->parent_type = 'Emails'; $note->file_mime_type = $note->file->mime_type; $note_id = $note->save(); array_push($focus->saved_attachments, $note); $note->id = $note_id; if ($note->new_with_id === FALSE) { $note->file->final_move($note->id); } else { $GLOBALS['log']->debug("Not performing final move for note id {$note->id} as it has already been processed"); } } //// END NEW ATTACHMENTS /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //// ATTACHMENTS FROM DOCUMENTS $count = ''; //_pp($_REQUEST); //_ppd(count($_REQUEST['document'])); if (!empty($_REQUEST['document'])) { $count = count($_REQUEST['document']); } else { $count = 10; } for ($i = 0; $i < $count; $i++) { if (isset($_REQUEST['documentId' . $i]) && !empty($_REQUEST['documentId' . $i])) { $doc = new Document(); $docRev = new DocumentRevision(); $docNote = new Note(); $doc->retrieve($_REQUEST['documentId' . $i]); $docRev->retrieve($doc->document_revision_id); array_push($focus->saved_attachments, $docRev); $docNote->name = $doc->document_name; $docNote->filename = $docRev->filename; $docNote->description = $doc->description; $docNote->parent_id = $focus->id; $docNote->parent_type = 'Emails'; $docNote->file_mime_type = $docRev->file_mime_type; $docId = $docNote = $docNote->save(); UploadFile::duplicate_file($docRev->id, $docId, $docRev->filename); } } //// END ATTACHMENTS FROM DOCUMENTS /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //// REMOVE ATTACHMENTS if (isset($_REQUEST['remove_attachment']) && !empty($_REQUEST['remove_attachment'])) { foreach ($_REQUEST['remove_attachment'] as $noteId) { $q = 'UPDATE notes SET deleted = 1 WHERE id = \'' . $noteId . '\''; $focus->db->query($q); } } //// END REMOVE ATTACHMENTS /////////////////////////////////////////////////////////////////////////// //// END ATTACHMENT HANDLING /////////////////////////////////////////////////////////////////////////////// clear_register_value('select_array', $focus->object_name); if ($redirect) { $GLOBALS['log']->debug("Saved record with id of " . $return_id); handleRedirect($return_id, "EmailTemplates"); } else { return $focus; } }
function handleSave($prefix, $redirect = true, $useRequired = false, $do_save = true, $exist_lead = null) { require_once 'modules/Campaigns/utils.php'; require_once 'include/formbase.php'; if (empty($exist_lead)) { $focus = new Lead(); } else { $focus = $exist_lead; } if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } //Check for duplicate Leads if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicateLeads = $this->checkForDuplicates($prefix); if (isset($duplicateLeads)) { //Set the redirect location to call the ShowDuplicates action. This will map to view.showduplicates.php $location = 'module=Leads&action=ShowDuplicates'; $get = ''; if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) { $get .= '&inbound_email_id=' . $_POST['inbound_email_id']; } if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) { $get .= '&Leadsrelate_to=' . $_POST['relate_to']; } if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) { $get .= '&Leadsrelate_id=' . $_POST['relate_id']; } //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->{$field}) && !is_object($focus->{$field})) { $get .= "&Leads{$field}=" . urlencode($focus->{$field}); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->{$field})) { $get .= "&Leads{$field}=" . urlencode($focus->{$field}); } } if ($focus->hasCustomFields()) { foreach ($focus->field_defs as $name => $field) { if (!empty($field['source']) && $field['source'] == 'custom_fields') { $get .= "&Leads{$name}=" . urlencode($focus->{$name}); } } } $emailAddress = new SugarEmailAddress(); $get .= $emailAddress->getFormBaseURL($focus); //create list of suspected duplicate lead ids in redirect get string $i = 0; foreach ($duplicateLeads as $lead) { $get .= "&duplicate[{$i}]=" . $lead['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= "&return_module="; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= "Leads"; } $get .= "&return_action="; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } if (!empty($_POST['return_id'])) { $get .= "&return_id=" . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } // for InboundEmail flow if (!empty($_POST['start'])) { $get .= '&start=' . $_POST['start']; } $_SESSION['SHOW_DUPLICATES'] = $get; if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { ob_clean(); $json = getJSONobj(); echo $json->encode(array('status' => 'dupe', 'get' => $location)); } else { if (!empty($_REQUEST['ajax_load'])) { echo "<script>SUGAR.ajaxUI.loadContent('index.php?{$location}');</script>"; } else { if (!empty($_POST['to_pdf'])) { $location .= '&to_pdf=' . $_POST['to_pdf']; } header("Location: index.php?{$location}"); } } return null; } } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 0; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 0; } if ($do_save) { if (!empty($GLOBALS['check_notify'])) { $focus->save($GLOBALS['check_notify']); } else { $focus->save(FALSE); } } $return_id = $focus->id; if (isset($_POST[$prefix . 'prospect_id']) && !empty($_POST[$prefix . 'prospect_id'])) { $prospect = new Prospect(); $prospect->retrieve($_POST[$prefix . 'prospect_id']); $prospect->lead_id = $focus->id; // Set to keep email in target $prospect->in_workflow = true; $prospect->save(); //if prospect id exists, make sure we are coming from prospect detail if (strtolower($_POST['return_module']) == 'prospects' && strtolower($_POST['return_action']) == 'detailview') { //create campaing_log entry if (isset($focus->campaign_id) && $focus->campaign_id != null) { campaign_log_lead_entry($focus->campaign_id, $prospect, $focus, 'lead'); } } } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { if (!isset($current_user)) { global $current_user; } // fake this case like it's already saved. $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Leads'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('leads'); $email->leads->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start']); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Leads'); } else { return $focus; } }
function handleSave($prefix, $redirect = true, $useRequired = false, $do_save = true, $exist_lead = null) { require_once 'modules/Campaigns/utils.php'; require_once 'include/formbase.php'; if (empty($exist_lead)) { $focus = new Lead(); } else { $focus = $exist_lead; } if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 0; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 0; } if ($do_save) { if (!empty($GLOBALS['check_notify'])) { $focus->save($GLOBALS['check_notify']); } else { $focus->save(FALSE); } } $return_id = $focus->id; if (isset($_POST[$prefix . 'prospect_id']) && !empty($_POST[$prefix . 'prospect_id'])) { $prospect = new Prospect(); $prospect->retrieve($_POST[$prefix . 'prospect_id']); $prospect->lead_id = $focus->id; $prospect->save(); //if prospect id exists, make sure we are coming from prospect detail if (strtolower($_POST['return_module']) == 'prospects' && strtolower($_POST['return_action']) == 'detailview') { //create campaing_log entry if (isset($focus->campaign_id) && $focus->campaign_id != null) { campaign_log_lead_entry($focus->campaign_id, $prospect, $focus, 'lead'); } } } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { if (!isset($current_user)) { global $current_user; } // fake this case like it's already saved. $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Leads'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('leads'); $email->leads->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start']); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Leads'); } else { return $focus; } }
function handleSave($prefix, $redirect = true, $useRequired = false) { global $current_user; require_once 'include/formbase.php'; $focus = new Opportunity(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } if (empty($_POST['currency_id'])) { $currency_id = $current_user->getPreference('currency'); if (isset($currency_id)) { $focus->currency_id = $currency_id; } } $focus = populateFromPost($prefix, $focus); if (!ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))) { ACLController::displayNoAccess(true); } $check_notify = FALSE; if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } $focus->save($check_notify); if (!empty($_POST['duplicate_parent_id'])) { clone_relationship($focus->db, array('opportunities_contacts'), 'opportunity_id', $_POST['duplicate_parent_id'], $focus->id); } $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, "Opportunities"); } else { return $focus; } }
$success = TRUE; if (isset($_FILES['reportfile']) && $upload_file->confirm_upload()) { $success = $template->set_reportfile($_FILES['reportfile']['tmp_name'], $upload_file->original_file_name); if (!$success) { $errors[] = "error compiling report " . $upload_file->original_file_name . " - " . $template->report_output; } } for ($i = 0; $i < 5; $i++) { $paramName = "subreport" . $i; $upload_file = new UploadFile($paramName); if (isset($_FILES[$paramName]) && $upload_file->confirm_upload()) { $success = $template->add_subreportfile($_FILES[$paramName]['tmp_name'], $upload_file->original_file_name); if (!$success) { $errors[] = "error compiling subreport " . $upload_file->original_file_name . " - " . $template->report_output; } } } for ($i = 0; $i < 5; $i++) { $paramName = "resource" . $i; $upload_file = new UploadFile($paramName); if (isset($_FILES[$paramName]) && $upload_file->confirm_upload()) { $template->add_resource_file($_FILES[$paramName]['tmp_name'], $upload_file->original_file_name); } } if (empty($errors)) { $return_id = $template->save(); handleRedirect("", ""); } else { $_REQUEST["ZR_ERROR_MSG"] = join("<br/>", $errors); include "modules/ZuckerReportTemplate/EditView.php"; }
<?php require_once 'include/formbase.php'; require_once 'include/upload_file.php'; require_once 'modules/ZuckerQueryTemplate/QueryTemplate.php'; $template = new QueryTemplate(); if (!empty($_REQUEST['record'])) { $template->retrieve($_REQUEST['record']); $template = $template->retrieve($_REQUEST['record']); if ($template == null) { echo "no access"; exit; } } $template = populateFromPost("", $template); if (!$template->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $template->sql1 = $_REQUEST['sql']; $_REQUEST['return_id'] = $template->save(); $_REQUEST['return_action'] = "DetailView"; $_REQUEST['return_module'] = "ZuckerQueryTemplate"; handleRedirect($return_id, "ZuckerQueryTemplate");
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; $focus = new xVendor(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } else { $check_notify = FALSE; } if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicatexVendors = $this->checkForDuplicates($prefix); if (isset($duplicatexVendors)) { $location = 'module=xVendors&action=ShowDuplicates'; $get = ''; // Bug 25311 - Add special handling for when the form specifies many-to-many relationships if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) { $get .= '&xVendorsrelate_to=' . $_POST['relate_to']; } if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) { $get .= '&xVendorsrelate_id=' . $_POST['relate_id']; } //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->{$field}) && !is_object($focus->{$field})) { $get .= "&xVendors{$field}=" . urlencode($focus->{$field}); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->{$field})) { $get .= "&xVendors{$field}=" . urlencode($focus->{$field}); } } if ($focus->hasCustomFields()) { foreach ($focus->field_defs as $name => $field) { if (!empty($field['source']) && $field['source'] == 'custom_fields') { $get .= "&xVendors{$name}=" . urlencode($focus->{$name}); } } } $emailAddress = new SugarEmailAddress(); $get .= $emailAddress->getFormBaseURL($focus); //create list of suspected duplicate xvendor id's in redirect get string $i = 0; foreach ($duplicatexVendors as $xvendor) { $get .= "&duplicate[{$i}]=" . $xvendor['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= '&return_module='; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= 'xVendors'; } $get .= '&return_action='; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } //else $get .= 'DetailView'; if (!empty($_POST['return_id'])) { $get .= '&return_id=' . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } $_SESSION['SHOW_DUPLICATES'] = $get; //now redirect the post to modules/xVendors/ShowDuplicates.php if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { ob_clean(); $json = getJSONobj(); echo $json->encode(array('status' => 'dupe', 'get' => $location)); } else { if (!empty($_REQUEST['ajax_load'])) { echo "<script>SUGAR.ajaxUI.loadContent('index.php?{$location}');</script>"; } else { if (!empty($_POST['to_pdf'])) { $location .= '&to_pdf=' . $_POST['to_pdf']; } header("Location: index.php?{$location}"); } } return null; } } if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->save($check_notify); $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { $json = getJSONobj(); echo $json->encode(array('status' => 'success', 'get' => '')); $trackerManager = TrackerManager::getInstance(); $timeStamp = TimeDate::getInstance()->nowDb(); if ($monitor = $trackerManager->getMonitor('tracker')) { $monitor->setValue('action', 'detailview'); $monitor->setValue('user_id', $GLOBALS['current_user']->id); $monitor->setValue('module_name', 'xVendors'); $monitor->setValue('date_modified', $timeStamp); $monitor->setValue('visible', 1); if (!empty($this->bean->id)) { $monitor->setValue('item_id', $return_id); $monitor->setValue('item_summary', $focus->get_summary_text()); } $trackerManager->saveMonitor($monitor, true, true); } return null; } if (isset($_POST['popup']) && $_POST['popup'] == 'true') { $get = '&module='; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= 'xVendors'; } $get .= '&action='; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } else { $get .= 'Popup'; } if (!empty($_POST['return_id'])) { $get .= '&return_id=' . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } if (!empty($_POST['to_pdf'])) { $get .= '&to_pdf=' . $_POST['to_pdf']; } $get .= '&name=' . $focus->name; $get .= '&query=true'; header("Location: index.php?{$get}"); return; } if ($redirect) { handleRedirect($return_id, 'xVendors'); } else { return $focus; } }
$contract_conditions->event = $contract_condition['event'][$i]; $contract_conditions->percent = $contract_condition['percent'][$i]; $contract_conditions->money = $contract_condition['money'][$i]; $contract_conditions->currency = $contract_condition['currency'][$i]; $contract_conditions->in_word = $contract_condition['in_word'][$i]; $contract_conditions->deleted = $contract_condition['deleted'][$i]; $contract_conditions->save(); } elseif ($contract_condition['deleted'][$i] == 1) { $contract_conditions->mark_deleted($contract_condition['id'][$i]); } } $transport_contract = array('id' => $_POST['transport_id'], 'loaixe' => $_POST['loaixe'], 'soxe' => $_POST['soxe'], 'lotrinh' => $_POST['lotrinh'], 'thoigiansudung' => $_POST['thoigiansudung'], 'dongia' => $_POST['dongia'], 'deleted' => $_POST['deleted']); $transport_contract_count = count($transport_contract['id']); for ($i = 0; $i < $transport_contract_count; $i++) { $transportcontract = new TransportContracts(); if ($transport_contract['deleted'][$i] != 1) { $transportcontract->id = $transport_contract['id'][$i]; $transportcontract->loaixe = $transport_contract['loaixe'][$i]; $transportcontract->soxe = $transport_contract['soxe'][$i]; $transportcontract->lotrinh = $transport_contract['lotrinh'][$i]; $transportcontract->thoigiansudung = $transport_contract['thoigiansudung'][$i]; $transportcontract->dongia = $transport_contract['dongia'][$i]; $transportcontract->contract_id = $return_id; $transportcontract->deleted = $transport_contract['deleted'][$i]; $transportcontract->save(); } else { $transportcontract->mark_deleted($transport_contract['id'][$i]); } } handleRedirect($return_id, 'Contracts');
function handleSave($prefix, $redirect = true, $useRequired = false) { global $current_user; require_once 'modules/Calls/Call.php'; require_once 'include/formbase.php'; global $timedate; if (isset($_POST['should_remind']) && $_POST['should_remind'] == '0') { $_POST['reminder_time'] = -1; } if (!isset($_POST['reminder_time'])) { $_POST['reminder_time'] = $current_user->getPreference('reminder_time'); if (empty($_POST['reminder_time'])) { $_POST['reminder_time'] = -1; } } if (!empty($_POST[$prefix . 'time_hour_start']) && empty($_POST['time_start'])) { $_POST['time_start'] = $_POST[$prefix . 'time_hour_start'] . ":" . $_POST[$prefix . 'time_minute_start']; } if (isset($_POST[$prefix . 'meridiem']) && !empty($_POST[$prefix . 'meridiem'])) { $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(true), $_POST[$prefix . 'meridiem']); } $focus = new Call(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } /////////////////////////////////////////////////////////////////////////// //// REMOVE INVITEE RELATIONSHIPS if (!empty($_POST['user_invitees'])) { $focus->load_relationship('users'); // this query to preserve accept_status across deletes $q = 'SELECT mu.user_id, mu.accept_status FROM calls_users mu WHERE mu.call_id = \'' . $focus->id . '\' AND mu.deleted = 0'; $r = $focus->db->query($q); $acceptStatusUsers = array(); while ($a = $focus->db->fetchByAssoc($r)) { $acceptStatusUsers[$a['user_id']] = $a['accept_status']; } $focus->users->delete($focus->id); } if (!empty($_POST['contact_invitees'])) { $focus->load_relationship('contacts'); // this query to preserve accept_status across deletes $q = 'SELECT mc.contact_id, mc.accept_status FROM calls_contacts mc WHERE mc.call_id = \'' . $focus->id . '\' AND mc.deleted = 0'; $r = $focus->db->query($q); $acceptStatusContacts = array(); while ($a = $focus->db->fetchByAssoc($r)) { $acceptStatusContacts[$a['contact_id']] = $a['accept_status']; } $focus->contacts->delete($focus->id); } //// END REMOVE /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //// REBUILD INVITEE RELATIONSHIPS if (!empty($_POST['user_invitees'])) { $existing_users = array(); $_POST['user_invitees'] = preg_replace('/\\,$/', '', $_POST['user_invitees']); if (!empty($_POST['existing_invitees'])) { $existing_users = explode(",", $_POST['existing_invitees']); } $focus->users_arr = explode(",", $_POST['user_invitees']); } if (!empty($_POST['contact_invitees'])) { $_POST['contact_invitees'] = preg_replace('/\\,$/', '', $_POST['contact_invitees']); $existing_contacts = array(); if (!empty($_POST['existing_contact_invitees'])) { $existing_contacts = explode(",", $_POST['existing_contact_invitees']); } $focus->contacts_arr = explode(",", $_POST['contact_invitees']); } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') { $focus->contacts_arr[] = $_POST['parent_id']; } $focus->save(true); $return_id = $focus->id; if (!empty($focus->users_arr) && is_array($focus->users_arr)) { foreach ($focus->users_arr as $user_id) { if (empty($user_id) || isset($existing_users[$user_id])) { continue; } if (!isset($focus->users)) { $focus->load_relationship('users'); } $focus->users->add($user_id); // update query to preserve accept_status if (isset($acceptStatusUsers[$user_id]) && !empty($acceptStatusUsers[$user_id])) { $qU = 'UPDATE calls_users mu SET mu.accept_status = \'' . $acceptStatusUsers[$user_id] . '\' '; $qU .= 'WHERE mu.deleted = 0 '; $qU .= 'AND mu.call_id = \'' . $focus->id . '\' '; $qU .= 'AND mu.user_id = \'' . $user_id . '\''; $focus->db->query($qU); } } } if (!empty($focus->contacts_arr) && is_array($focus->contacts_arr)) { foreach ($focus->contacts_arr as $contact_id) { if (empty($contact_id) || isset($existing_contacts[$contact_id])) { continue; } if (!is_array($focus->contacts)) { $focus->load_relationship('contacts'); } $focus->contacts->add($contact_id); // update query to preserve accept_status if (isset($acceptStatusContacts[$contact_id]) && !empty($acceptStatusContacts[$contact_id])) { $qU = 'UPDATE calls_contacts mc SET mc.accept_status = \'' . $acceptStatusContacts[$contact_id] . '\' '; $qU .= 'WHERE mc.deleted = 0 '; $qU .= 'AND mc.call_id = \'' . $focus->id . '\' '; $qU .= 'AND mc.contact_id = \'' . $contact_id . '\''; $focus->db->query($qU); } } } // set organizer to auto-accept $focus->set_accept_status($current_user, 'accept'); //// END REBUILD INVITEE RELATIONSHIPS /////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Calls'); } else { return $focus; } }
/////////////////////////////////////////////////////////////////////////////// $return_id = $focus->id; if (empty($_POST['return_module'])) { $return_module = "Emails"; } else { $return_module = $_POST['return_module']; } if (empty($_POST['return_action'])) { $return_action = "DetailView"; } else { $return_action = $_POST['return_action']; } $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($focus->type == 'draft') { if ($return_module == 'Emails') { header("Location: index.php?module={$return_module}&action=ListViewDrafts"); } else { handleRedirect($return_id, 'Emails'); } } elseif ($focus->type == 'out') { if ($return_module == 'Home') { header('Location: index.php?module=' . $return_module . '&action=index'); } if (!empty($_REQUEST['return_id'])) { $return_id = $_REQUEST['return_id']; } header('Location: index.php?action=' . $return_action . '&module=' . $return_module . '&record=' . $return_id . '&assigned_user_id=' . $current_user->id . '&type=inbound'); } elseif (isset($_POST['return_id']) && $_POST['return_id'] != "") { $return_id = $_POST['return_id']; } header("Location: index.php?action={$return_action}&module={$return_module}&record={$return_id}");
function handleSave($prefix, $redirect = true, $useRequired = false) { global $theme; require_once 'include/formbase.php'; global $timedate; $focus = new Prospect(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { return null; } if (!isset($GLOBALS['check_notify'])) { $GLOBALS['check_notify'] = false; } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 0; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 0; } if (empty($_POST['record']) && empty($_POST['dup_checked'])) { /* // we don't check dupes on Prospects - this is the dirtiest data in the system //$duplicateProspects = $this->checkForDuplicates($prefix); if(isset($duplicateProspects)){ $get='module=Prospects&action=ShowDuplicates'; //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->$field)) { $get .= "&Prospects$field=".urlencode($focus->$field); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->$field)) { $get .= "&Prospects$field=".urlencode($focus->$field); } } //create list of suspected duplicate prospect id's in redirect get string $i=0; foreach ($duplicateProspects as $prospect) { $get .= "&duplicate[$i]=".$prospect['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= "&return_module="; if(!empty($_POST['return_module'])) $get .= $_POST['return_module']; else $get .= "Prospects"; $get .= "&return_action="; if(!empty($_POST['return_action'])) $get .= $_POST['return_action']; else $get .= "DetailView"; if(!empty($_POST['return_id'])) $get .= "&return_id=".$_POST['return_id']; //now redirect the post to modules/Prospects/ShowDuplicates.php header("Location: index.php?$get"); return null; }*/ } global $current_user; $focus->save($GLOBALS['check_notify']); $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); if (isset($_POST['popup']) && $_POST['popup'] == 'true') { $get = '&module='; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= 'Prospects'; } $get .= '&action='; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } else { $get .= 'Popup'; } if (!empty($_POST['return_id'])) { $get .= '&return_id=' . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } if (!empty($_POST['to_pdf'])) { $get .= '&to_pdf=' . $_POST['to_pdf']; } $get .= '&first_name=' . $focus->first_name; $get .= '&last_name=' . $focus->last_name; $get .= '&query=true'; header("Location: index.php?{$get}"); return; } if ($redirect) { require_once 'include/formbase.php'; handleRedirect($return_id, 'Prospects'); } else { return $focus; } }
if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { // fake this case like it's already saved. $focus->save(); $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Tasks'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('tasks'); $email->tasks->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start'] . '&assigned_user_id=' . $current_user->id); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// // CCL - Bugs 41103 and 43751. 41103 address the issue where the parent_id is set, but // the relate_id field overrides the relationship. 43751 fixes the problem where the relate_id and // parent_id are the same value (in which case it should just use relate_id) by adding the != check if (!empty($_REQUEST['relate_id']) && !empty($_REQUEST['parent_id']) && $_REQUEST['relate_id'] != $_REQUEST['parent_id']) { $_REQUEST['relate_id'] = false; } // avoid undefined index if (!isset($GLOBALS['check_notify'])) { $GLOBALS['check_notify'] = false; } $focus->save($GLOBALS['check_notify']); $return_id = $focus->id; handleRedirect($return_id, 'Tasks');
<?php require_once 'include/formbase.php'; require_once 'modules/ZuckerReportContainer/ReportContainer.php'; $container = new ReportContainer(); $container = populateFromPost("", $container); $container->assigned_user_id = $current_user->id; if (!empty($_REQUEST["parent_id"])) { $parent_container = new ReportContainer(); $parent_container->retrieve($_REQUEST["parent_id"]); $container->parent_id = $parent_container->id; $container->team_id = $parent_container->team_id; } $_REQUEST['return_id'] = $container->save(); $_REQUEST['return_action'] = "DetailView"; handleRedirect(null, "ZuckerReportContainer");
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'modules/Paper/Paper.php'; require_once 'log4php/LoggerManager.php'; require_once 'include/formbase.php'; require_once 'include/TimeDate.php'; require_once 'include/upload_file.php'; require_once 'config.php'; global $sugar_config; $timedate = new TimeDate(); $focus = new Paper(); /*if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))){ return null; }*/ $focus = populateFromPost($prefix, $focus); if (!ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))) { ACLController::displayNoAccess(true); } $upload_file = new UploadFile('uploadfile'); if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) { $focus->stored_file_name = $upload_file->get_stored_file_name(); $focus->imagename = $upload_file->get_stored_file_name(); $focus->imagepath = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name(); $do_final_move = 1; } if (!isset($_REQUEST['active'])) { $focus->active = 'off'; } if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } //Goodwill if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicatePaper = $this->checkForDuplicates($prefix); if (isset($duplicatePaper)) { //$GLOBALS['log']->info("Duplicate Product:".$duplicateProducts['id']); $this->handleRedirect($return_id, "Paper"); return null; } } //End Goodwill $return_id = $focus->save(); if ($do_final_move) { $upload_file->final_move($return_id); $focus->stored_file_name = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name(); $focus->imagename = $upload_file->get_stored_file_name(); $focus->imagepath = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name(); $focus->save(); //echo "dir:".$sugar_config['upload_dir']."<br/>"; //echo $focus->imagepath."<br/>"; } $paper_id = $return_id; $pref_supplier_id = $focus->pref_supplier_id; $result = $focus->db->query("SELECT count(*) AS the_count FROM papers_relation WHERE material_id = '{$paper_id}' AND relation_id = '{$pref_supplier_id}'"); $row = $focus->db->fetchByAssoc($result, -1, true); $row_count = $row['the_count']; if ($row_count == 0) { $id = create_guid(); $result = $focus->db->query("INSERT INTO papers_relation (id, paper_id, relation_id, relation_type, deleted) VALUES ('{$id}','{$paper_id}','{$pref_supplier_id}','Suppliers', '0')"); } //echo "Saved record with id of ".$return_id; $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, "Paper"); } else { return $focus; } }
foreach ($focus->column_fields as $field) { if (isset($_REQUEST[$field])) { $focus->{$field} = $_REQUEST[$field]; } } foreach ($focus->additional_column_fields as $field) { if (isset($_REQUEST[$field])) { $value = $_REQUEST[$field]; $focus->{$field} = $value; } } $focus = populateFromPost('', $focus); $focus->unformat_all_fields(); $focus->save(); $return_id = $focus->id; if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") { $return_module = $_REQUEST['return_module']; } else { $return_module = "ProductTemplates"; } if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") { $return_action = $_REQUEST['return_action']; } else { $return_action = "DetailView"; } if (isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") { $return_id = $_REQUEST['return_id']; } $GLOBALS['log']->debug("Saved record with id of " . $return_id); handleRedirect($return_id, $return_module); //header("Location: index.php?action=$return_action&module=$return_module&record=$return_id");