public function preDisplay()
 {
     $module = $_REQUEST['inviteeModule'];
     $this->bean = BeanFactory::getBean($module);
     if ($this->bean->ACLAccess('save')) {
         require_once 'include/formbase.php';
         $this->bean = populateFromPost("", $this->bean);
         $this->bean->save();
     } else {
         $sendbackArr = array('noAccess' => true, 'module' => $this->bean->object_name);
         echo json_encode($sendbackArr);
         die;
     }
 }
Esempio n. 2
0
 public function preDisplay()
 {
     global $beanFiles, $beanList;
     $module = $_REQUEST['inviteeModule'];
     require_once $beanFiles[$beanList[$module]];
     $this->bean = new $beanList[$module]();
     if ($this->bean->ACLAccess('save')) {
         require_once 'include/formbase.php';
         $this->bean = populateFromPost("", $this->bean);
         $this->bean->save();
     } else {
         $sendbackArr = array('noAccess' => true, 'module' => $this->bean->object_name);
         echo json_encode($sendbackArr);
         die;
     }
 }
 public function preDisplay()
 {
     global $beanFiles, $beanList;
     $module = empty($_REQUEST['inviteeModule']) ? '' : $_REQUEST['inviteeModule'];
     if (!in_array($module, array('Leads', 'Contacts')) || empty($beanList[$module])) {
         $this->returnNoAccess($module);
     }
     require_once $beanFiles[$beanList[$module]];
     $this->bean = new $beanList[$module]();
     if ($this->bean->ACLAccess('save')) {
         require_once 'include/formbase.php';
         $this->bean = populateFromPost("", $this->bean);
         $this->bean->save();
     } else {
         $this->returnNoAccess($this->bean->object_name);
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     require_once 'include/formbase.php';
     $focus = new iFrame();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     $focus = populateFromPost($prefix, $focus);
     if (empty($_REQUEST['status']) || $_REQUEST['status'] == 'off') {
         $focus->status = 0;
     } else {
         $focus->status = 1;
     }
     $focus->save();
     $GLOBALS['log']->debug("Saved record with id of " . $return_id);
     if ($redirect) {
         $this->handleRedirect('');
     } else {
         return $focus;
     }
 }
 function display()
 {
     require_once "modules/Calls/Call.php";
     require_once "modules/Meetings/Meeting.php";
     global $beanFiles, $beanList;
     $module = $_REQUEST['current_module'];
     require_once $beanFiles[$beanList[$module]];
     $bean = new $beanList[$module]();
     $bean->retrieve($_REQUEST['record']);
     if (!$bean->ACLAccess('Save')) {
         die;
     }
     $field = "date_start";
     if ($module == "Tasks") {
         $field = "date_due";
     }
     $_POST[$field] = $_REQUEST['datetime'];
     require_once 'include/formbase.php';
     $bean = populateFromPost("", $bean);
     $bean->save();
     $json_arr = array('success' => 'yes');
     ob_clean();
     echo json_encode($json_arr);
 }
/*********************************************************************************
 * Description:  TODO: To be written.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
require_once 'include/formbase.php';
global $mod_strings;
//create new campaign bean and populate
$campaign_focus = new Campaign();
if (isset($_REQUEST['record'])) {
    $campaign_focus->retrieve($_REQUEST['record']);
}
$camp_steps[] = 'wiz_step1_';
$camp_steps[] = 'wiz_step2_';
$campaign_focus = populateFromPost('', $campaign_focus);
foreach ($camp_steps as $step) {
    $campaign_focus = populate_wizard_bean_from_request($campaign_focus, $step);
}
//save here so we can link relationships
$campaign_focus->save();
$GLOBALS['log']->debug("Saved record with id of " . $campaign_focus->id);
//process prospect lists
//process subscription lists if this is a newsletter
if ($campaign_focus->campaign_type == 'NewsLetter') {
    $pl_list = process_subscriptions_from_request($campaign_focus->name);
    $campaign_focus->load_relationship('prospectlists');
    $existing_pls = $campaign_focus->prospectlists->get();
    $ui_ids = array();
    //for each list returned, add the list to the relationship
    foreach ($pl_list as $pl) {
Esempio n. 8
0
 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;
     }
 }
Esempio n. 9
0
 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;
     }
 }
Esempio n. 10
0
 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;
         }
     }
 }
Esempio n. 11
0
<?php

require_once 'include/formbase.php';
require_once 'modules/ZuckerReportModuleLink/ReportModuleLink.php';
if (!is_admin($current_user)) {
    sugar_die("only admin allowed");
}
$link = new ReportModuleLink();
if (!empty($_REQUEST['record'])) {
    $link->retrieve($_REQUEST['record']);
}
$link = populateFromPost("module_", $link);
$link->save();
handleRedirect();
Esempio n. 12
0
<?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");
Esempio n. 13
0
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
$project = new ProjectTask();
if (!empty($_POST['record'])) {
    $project->retrieve($_POST['record']);
}
////
//// save the fields to the ProjectTask object
////
if (isset($_REQUEST['email_id'])) {
    $project->email_id = $_REQUEST['email_id'];
}
require_once 'include/formbase.php';
$project = populateFromPost('', $project);
if (!isset($_REQUEST['milestone_flag'])) {
    $project->milestone_flag = '0';
}
$GLOBALS['check_notify'] = false;
if (!empty($_POST['assigned_user_id']) && $project->assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
    $GLOBALS['check_notify'] = true;
}
if (!$project->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (empty($project->project_id)) {
    $project->project_id = $_POST['relate_id'];
}
//quick for 5.1 till projects are revamped for 5.5 nsingh- 7/3/08
Esempio n. 14
0
 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;
     }
 }
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     global $theme, $current_user;
     require_once 'include/formbase.php';
     global $timedate;
     $focus = new Contact();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     if (!empty($_POST[$prefix . 'new_reports_to_id'])) {
         $focus->retrieve($_POST[$prefix . 'new_reports_to_id']);
         $focus->reports_to_id = $_POST[$prefix . 'record'];
     } else {
         $focus = populateFromPost($prefix, $focus);
         if (!empty($focus->portal_password) && $focus->portal_password != $_POST[$prefix . 'old_portal_password']) {
             $focus->portal_password = md5($focus->portal_password);
         }
         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 (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if ($_REQUEST['action'] != 'BusinessCard' && $_REQUEST['action'] != 'ConvertLead' && $_REQUEST['action'] != 'ConvertProspect') {
         if (!empty($_POST[$prefix . 'sync_contact'])) {
             $focus->contacts_users_id = $current_user->id;
         } else {
             if (!isset($focus->users)) {
                 $focus->load_relationship('user_sync');
             }
             $focus->contacts_users_id = null;
             $focus->user_sync->delete($focus->id, $current_user->id);
         }
     }
     if (isset($GLOBALS['check_notify'])) {
         $check_notify = $GLOBALS['check_notify'];
     } else {
         $check_notify = FALSE;
     }
     if (empty($_POST['dup_checked'])) {
         $duplicateContacts = $this->checkForDuplicates($prefix);
         if (isset($duplicateContacts)) {
             $location = 'module=Contacts&action=ShowDuplicates';
             $get = '';
             if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) {
                 $get .= '&inbound_email_id=' . $_POST['inbound_email_id'];
             }
             // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
             if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) {
                 $get .= '&Contactsrelate_to=' . $_POST['relate_to'];
             }
             if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) {
                 $get .= '&Contactsrelate_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 .= "&Contacts{$field}=" . urlencode($focus->{$field});
                 }
             }
             foreach ($focus->additional_column_fields as $field) {
                 if (!empty($focus->{$field})) {
                     $get .= "&Contacts{$field}=" . urlencode($focus->{$field});
                 }
             }
             if ($focus->hasCustomFields()) {
                 foreach ($focus->field_defs as $name => $field) {
                     if (!empty($field['source']) && $field['source'] == 'custom_fields') {
                         $get .= "&Contacts{$name}=" . urlencode($focus->{$name});
                     }
                 }
             }
             $emailAddress = new SugarEmailAddress();
             $get .= $emailAddress->getFormBaseURL($focus);
             //create list of suspected duplicate contact id's in redirect get string
             $i = 0;
             foreach ($duplicateContacts as $contact) {
                 $get .= "&duplicate[{$i}]=" . $contact['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 .= "Contacts";
             }
             $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'];
             }
             // for InboundEmail flow
             if (!empty($_POST['start'])) {
                 $get .= '&start=' . $_POST['start'];
             }
             $_SESSION['SHOW_DUPLICATES'] = $get;
             //now redirect the post to modules/Contacts/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;
         }
     }
     global $current_user;
     if (is_admin($current_user)) {
         if (!isset($_POST[$prefix . 'portal_active'])) {
             $focus->portal_active = '0';
         }
         //if no password is set set account to inactive for portal
         if (empty($_POST[$prefix . 'portal_name'])) {
             $focus->portal_active = '0';
         }
     }
     ///////////////////////////////////////////////////////////////////////////////
     ////	INBOUND EMAIL HANDLING
     ///////////////////////////////////////////////////////////////////////////////
     if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) {
         // fake this case like it's already saved.
         $focus->save($check_notify);
         $email = new Email();
         $email->retrieve($_REQUEST['inbound_email_id']);
         $email->parent_type = 'Contacts';
         $email->parent_id = $focus->id;
         $email->assigned_user_id = $current_user->id;
         $email->status = 'read';
         $email->save();
         $email->load_relationship('contacts');
         $email->contacts->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
     ///////////////////////////////////////////////////////////////////////////////
     $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', 'Contacts');
             $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 .= 'Contacts';
         }
         $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=' . urlencode($focus->first_name);
         $get .= '&last_name=' . urlencode($focus->last_name);
         $get .= '&query=true';
         header("Location: index.php?{$get}");
         return;
     }
     if ($redirect) {
         $this->handleRedirect($return_id);
     } else {
         return $focus;
     }
 }
Esempio n. 16
0
 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;
     }
 }
Esempio n. 17
0
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     global $theme, $current_user;
     require_once 'include/formbase.php';
     $galleria = $_POST['galleria_c'];
     $focus = new Realty();
     if (!empty($_POST[$prefix . 'new_reports_to_id'])) {
         $focus->retrieve($_POST[$prefix . 'new_reports_to_id']);
         $focus->reports_to_id = $_POST[$prefix . 'record'];
     } else {
         $focus = populateFromPost($prefix, $focus);
     }
     if (isset($galleria)) {
         $focus->galleria_c = $galleria;
     }
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     if (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if (isset($GLOBALS['check_notify'])) {
         $check_notify = $GLOBALS['check_notify'];
     } else {
         $check_notify = FALSE;
     }
     if (empty($_POST['dup_checked'])) {
         $duplicateRealty = $this->checkForDuplicates($prefix);
         if (isset($duplicateRealty)) {
             $focus->possible_duplicate = 1;
             $_SESSION['duplicateRealty'] = $duplicateRealty;
             $location = 'module=Realty&action=ShowDuplicates&record=' . $_POST['record'];
             $get = '';
             if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) {
                 $get .= '&inbound_email_id=' . $_POST['inbound_email_id'];
             }
             // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
             if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) {
                 $get .= '&Realtyrelate_to=' . $_POST['relate_to'];
             }
             if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) {
                 $get .= '&Realtyrelate_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 .= "&Realty{$field}=" . urlencode($focus->{$field});
                 }
             }
             foreach ($focus->additional_column_fields as $field) {
                 if (!empty($focus->{$field})) {
                     $get .= "&Realty{$field}=" . urlencode($focus->{$field});
                 }
             }
             if ($focus->hasCustomFields()) {
                 foreach ($focus->field_defs as $name => $field) {
                     if (!empty($field['source']) && $field['source'] == 'custom_fields') {
                         $get .= "&Realty{$name}=" . urlencode($focus->{$name});
                     }
                 }
             }
             $emailAddress = new SugarEmailAddress();
             $get .= $emailAddress->getFormBaseURL($focus);
             //create list of suspected duplicate realty id's in redirect get string
             $i = 0;
             foreach ($duplicateRealty as $realty) {
                 $get .= "&duplicate[{$i}]=" . $realty['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 .= "Realty";
             }
             $get .= "&return_action=";
             if (!empty($_POST['return_action'])) {
                 $get .= 'EditView';
             }
             //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'];
             }
             // for InboundEmail flow
             if (!empty($_POST['start'])) {
                 $get .= '&start=' . $_POST['start'];
             }
             $_SESSION['SHOW_DUPLICATES'] = $get;
             //now redirect the post to modules/Realty/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;
         }
     }
     $focus->save($check_notify);
     $return_id = $focus->id;
     $GLOBALS['log']->debug("Saved record with id of " . $return_id);
     //    $focus->load_relationship('realty_realty_1');
     //    $focus->realty_realty_1->delete($focus->id);
     //    foreach ($_SESSION['duplicateRealty'] as $realty)
     //    {
     //        $focus->realty_realty_1->add($realty['id']);
     //    }
     $_SESSION['duplicateRealty'] = array();
     if (isset($_POST['popup']) && $_POST['popup'] == 'true') {
         $get = '&module=';
         if (!empty($_POST['return_module'])) {
             $get .= $_POST['return_module'];
         } else {
             $get .= 'Realty';
         }
         $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=' . urlencode($focus->name);
         $get .= '&query=true';
         header("Location: index.php?{$get}");
         return;
     }
     if ($redirect) {
         $this->handleRedirect($return_id);
     } 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;
     }
 }
Esempio n. 19
0
<?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");
Esempio n. 20
0
 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;
     }
 }
Esempio n. 21
0
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
require_once 'include/formbase.php';
global $current_user;
$sugarbean = new Project();
$sugarbean = populateFromPost('', $sugarbean);
$projectTasks = array();
if (isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") {
    $base_project_id = $_REQUEST['relate_id'];
} else {
    $base_project_id = $sugarbean->id;
}
if (isset($_REQUEST['save_type']) || isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") {
    $query = "SELECT id FROM project_task WHERE project_id = '" . $base_project_id . "' AND deleted = 0";
    $result = $sugarbean->db->query($query, true, "Error retrieving project tasks");
    $row = $sugarbean->db->fetchByAssoc($result);
    while ($row != null) {
        $projectTaskBean = new ProjectTask();
        $projectTaskBean->id = $row['id'];
        $projectTaskBean->retrieve();
        $projectTaskBean->date_entered = '';
Esempio n. 22
0
 /**
  * Action Resize
  * Used for drag & drop resizing
  */
 protected function action_resize()
 {
     $this->view = 'json';
     if (!$this->retrieveCurrentBean('Save')) {
         return;
     }
     require_once 'include/formbase.php';
     $this->currentBean = populateFromPost("", $this->currentBean);
     $this->currentBean->save();
     $this->view_object_map['jsonData'] = array('access' => 'yes');
 }
Esempio n. 23
0
 /**
  * Populates the passed in Bean fron the contact and the $_REQUEST
  * @param String $module Module of new bean
  * @param SugarBean $bean SugarBean to be populated.
  * @param Contact $contact Contact to relate the bean to.
  */
 protected function populateNewBean($module, $bean, $contact, $lead)
 {
     //Copy data from the contact to new bean
     foreach ($bean->field_defs as $field => $def) {
         if (!isset($_REQUEST[$module . $field]) && isset($lead->{$field}) && $field != 'id') {
             $bean->{$field} = $lead->{$field};
             if ($field == 'date_entered') {
                 $bean->{$field} = gmdate($GLOBALS['timedate']->get_db_date_time_format());
             }
             //bug 41030
         }
     }
     populateFromPost($module, $bean, true);
     //Try to link to the new contact
     $contactRel = "";
     if (!empty($vdef['ConvertLead']['select'])) {
         $select = $vdef['ConvertLead']['select'];
         $fieldDef = $contact->field_defs[$select];
         if (!empty($fieldDef['id_name'])) {
             $bean->id = create_guid();
             $bean->new_with_id = true;
             $contact->{$fieldDef}['id_name'] = $bean->id;
             if ($fieldDef['id_name'] != $select) {
                 $rname = isset($fieldDef['rname']) ? $fieldDef['rname'] : "";
                 if (!empty($rname) && isset($bean->{$rname})) {
                     $contact->{$select} = $bean->{$rname};
                 } else {
                     $contact->{$select} = $bean->name;
                 }
             }
         }
     } else {
         if ($module != "Contacts") {
             $contactRel = $this->findRelationship($contact, $bean);
             if (!empty($contactRel)) {
                 $bean->id = create_guid();
                 $bean->new_with_id = true;
                 $contact->load_relationship($contactRel);
                 $relObject = $contact->{$contactRel}->getRelationshipObject();
                 if ($relObject->relationship_type == "one-to-many" && $contact->{$contactRel}->_get_bean_position()) {
                     $id_field = $relObject->rhs_key;
                     $bean->{$id_field} = $contact->id;
                 } else {
                     $contact->{$contactRel}->add($bean);
                 }
                 //Set the parent of activites to the new Contact
                 if (isset($bean->field_defs['parent_id']) && isset($bean->field_defs['parent_type'])) {
                     $bean->parent_id = $contact->id;
                     $bean->parent_type = "Contacts";
                 }
             }
         }
     }
 }
Esempio n. 24
0
    $time_separator = $match[1];
}
if (!empty($_POST[$prefix . 'due_meridiem'])) {
    $_POST[$prefix . 'time_due'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_due'], $timedate->get_time_format(), $_POST[$prefix . 'due_meridiem']);
}
if (!empty($_POST[$prefix . 'start_meridiem'])) {
    $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(), $_POST[$prefix . 'start_meridiem']);
}
if (isset($_POST[$prefix . 'time_due']) && !empty($_POST[$prefix . 'time_due'])) {
    $_POST[$prefix . 'date_due'] = $_POST[$prefix . 'date_due'] . ' ' . $_POST[$prefix . 'time_due'];
}
if (isset($_POST[$prefix . 'time_start']) && !empty($_POST[$prefix . 'time_start'])) {
    $_POST[$prefix . 'date_start'] = $_POST[$prefix . 'date_start'] . ' ' . $_POST[$prefix . 'time_start'];
}
require_once 'include/formbase.php';
$focus = populateFromPost('', $focus);
if (!$focus->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (isCloseAndCreateNewPressed()) {
    $focus->status = 'Completed';
}
if (!isset($_POST['date_due_flag'])) {
    $focus->date_due_flag = 0;
}
if (!isset($_POST['date_start_flag'])) {
    $focus->date_start_flag = 0;
}
if ($focus->date_due_flag != 'off' && $focus->date_due_flag != 1) {
    $focus->date_due = '';
 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;
     }
 }
Esempio n. 26
0
 /**
  * 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;
         }
     }
 }
Esempio n. 27
0
 /**
  * Executes the massupdate form
  * @param displayname Name to display in the popup window
  * @param varname name of the variable
  */
 function handleMassUpdate()
 {
     require_once 'include/formbase.php';
     global $current_user, $db, $disable_date_format, $timedate;
     foreach ($_POST as $post => $value) {
         if (is_array($value)) {
             if (empty($value)) {
                 unset($_POST[$post]);
             }
         } elseif (strlen($value) == 0) {
             if (isset($this->sugarbean->field_defs[$post]) && $this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post])) {
                 $_POST[$post] = '';
             } else {
                 unset($_POST[$post]);
             }
         }
         if (is_string($value) && isset($this->sugarbean->field_defs[$post])) {
             if ($this->sugarbean->field_defs[$post]['type'] == 'bool' || !empty($this->sugarbean->field_defs[$post]['custom_type']) && $this->sugarbean->field_defs[$post]['custom_type'] == 'bool') {
                 if (strcmp($value, '2') == 0) {
                     $_POST[$post] = 0;
                 }
                 if (!empty($this->sugarbean->field_defs[$post]['dbType']) && strcmp($this->sugarbean->field_defs[$post]['dbType'], 'varchar') == 0) {
                     if (strcmp($value, '1') == 0) {
                         $_POST[$post] = 'on';
                     }
                     if (strcmp($value, '2') == 0) {
                         $_POST[$post] = 'off';
                     }
                 }
             }
             if ($this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) && strlen($value) == 0) {
                 $_POST[$post] = '';
             }
             if ($this->sugarbean->field_defs[$post]['type'] == 'bool') {
                 $this->checkClearField($post, $value);
             }
             if ($this->sugarbean->field_defs[$post]['type'] == 'date' && !empty($_POST[$post])) {
                 $_POST[$post] = $timedate->to_db_date($_POST[$post]);
             }
             if ($this->sugarbean->field_defs[$post]['type'] == 'datetime' && !empty($_POST[$post])) {
                 $_POST[$post] = $timedate->to_db($this->date_to_dateTime($post, $value));
             }
             if ($this->sugarbean->field_defs[$post]['type'] == 'datetimecombo' && !empty($_POST[$post])) {
                 $_POST[$post] = $timedate->to_db($_POST[$post]);
             }
         }
     }
     //We need to disable_date_format so that date values for the beans remain in database format
     //notice we make this call after the above section since the calls to TimeDate class there could wind up
     //making it's way to the UserPreferences objects in which case we want to enable the global date formatting
     //to correctly retrieve the user's date format preferences
     $old_value = $disable_date_format;
     $disable_date_format = true;
     if (!empty($_REQUEST['uid'])) {
         $_POST['mass'] = explode(',', $_REQUEST['uid']);
     } elseif (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
         if (empty($order_by)) {
             $order_by = '';
         }
         $ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $this->searchFields, $this->where_clauses);
         if (!isset($ret_array['join'])) {
             $ret_array['join'] = '';
         }
         $query = $this->sugarbean->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
         $result = $db->query($query, true);
         $new_arr = array();
         while ($val = $db->fetchByAssoc($result, -1, false)) {
             array_push($new_arr, $val['id']);
         }
         $_POST['mass'] = $new_arr;
     }
     if (isset($_POST['mass']) && is_array($_POST['mass']) && $_REQUEST['massupdate'] == 'true') {
         $count = 0;
         foreach ($_POST['mass'] as $id) {
             if (empty($id)) {
                 continue;
             }
             if (isset($_POST['Delete'])) {
                 $this->sugarbean->retrieve($id);
                 if ($this->sugarbean->ACLAccess('Delete')) {
                     //Martin Hu Bug #20872
                     if ($this->sugarbean->object_name == 'EmailMan') {
                         $query = "DELETE FROM emailman WHERE id = '" . $this->sugarbean->id . "'";
                         $db->query($query);
                     } else {
                         $this->sugarbean->mark_deleted($id);
                     }
                 }
             } else {
                 if ($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])) {
                     // special for contacts module
                     if ($_POST['Sync'] == 'true') {
                         $this->sugarbean->retrieve($id);
                         if ($this->sugarbean->ACLAccess('Save')) {
                             if ($this->sugarbean->object_name == 'Contact') {
                                 $this->sugarbean->contacts_users_id = $current_user->id;
                                 $this->sugarbean->save(false);
                             }
                         }
                     } elseif ($_POST['Sync'] == 'false') {
                         $this->sugarbean->retrieve($id);
                         if ($this->sugarbean->ACLAccess('Save')) {
                             if ($this->sugarbean->object_name == 'Contact') {
                                 if (!isset($this->sugarbean->users)) {
                                     $this->sugarbean->load_relationship('user_sync');
                                 }
                                 $this->sugarbean->contacts_users_id = null;
                                 $this->sugarbean->user_sync->delete($this->sugarbean->id, $current_user->id);
                             }
                         }
                     }
                 }
                 //end if for special Contact handling
                 if ($count++ != 0) {
                     //Create a new instance to clear values and handle additional updates to bean's 2,3,4...
                     $className = get_class($this->sugarbean);
                     $this->sugarbean = new $className();
                 }
                 $this->sugarbean->retrieve($id);
                 if ($this->sugarbean->ACLAccess('Save')) {
                     $_POST['record'] = $id;
                     $_GET['record'] = $id;
                     $_REQUEST['record'] = $id;
                     $newbean = $this->sugarbean;
                     $old_reports_to_id = null;
                     if (!empty($_POST['reports_to_id']) && $newbean->reports_to_id != $_POST['reports_to_id']) {
                         $old_reports_to_id = empty($newbean->reports_to_id) ? 'null' : $newbean->reports_to_id;
                     }
                     $check_notify = FALSE;
                     if (isset($this->sugarbean->assigned_user_id)) {
                         $old_assigned_user_id = $this->sugarbean->assigned_user_id;
                         if (!empty($_POST['assigned_user_id']) && $old_assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
                             $check_notify = TRUE;
                         }
                     }
                     //Call include/formbase.php, but do not call retrieve again
                     populateFromPost('', $newbean, true);
                     $newbean->save_from_post = false;
                     if (!isset($_POST['parent_id'])) {
                         $newbean->parent_type = null;
                     }
                     $email_address_id = '';
                     if (!empty($_POST['optout_primary'])) {
                         $optout_flag_value = 0;
                         if ($_POST['optout_primary'] == 'true') {
                             $optout_flag_value = 1;
                         }
                         // if
                         if (isset($this->sugarbean->emailAddress)) {
                             if (!empty($this->sugarbean->emailAddress->addresses)) {
                                 foreach ($this->sugarbean->emailAddress->addresses as $key => $emailAddressRow) {
                                     if ($emailAddressRow['primary_address'] == '1') {
                                         $email_address_id = $emailAddressRow['email_address_id'];
                                         break;
                                     }
                                     // if
                                 }
                                 // foreach
                             }
                             // if
                         }
                         // if
                     }
                     // if
                     $newbean->save($check_notify);
                     if (!empty($email_address_id)) {
                         $query = "UPDATE email_addresses SET opt_out = {$optout_flag_value} where id = '{$emailAddressRow['email_address_id']}'";
                         $GLOBALS['db']->query($query);
                     }
                     // if
                     if (!empty($old_reports_to_id) && method_exists($newbean, 'update_team_memberships')) {
                         $old_id = $old_reports_to_id == 'null' ? '' : $old_reports_to_id;
                     }
                 }
             }
         }
     }
     $disable_date_format = $old_value;
 }
 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;
     }
 }
 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;
     }
 }
Esempio n. 30
0
<?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");