Esempio n. 1
0
 /**
  * @see SugarController::loadBean()
  */
 public function loadBean()
 {
     global $mod_strings;
     if (!isset($_REQUEST['import_module'])) {
         return;
         // there is no module to load
     }
     $this->importModule = $_REQUEST['import_module'];
     $this->bean = BeanFactory::getBean($this->importModule);
     if ($this->bean) {
         if (!$this->bean->importable) {
             $this->bean = false;
         } elseif ($_REQUEST['import_module'] == 'Users' && !is_admin($GLOBALS['current_user'])) {
             $this->bean = false;
         } elseif ($this->bean->bean_implements('ACL')) {
             if (!ACLController::checkAccess($this->bean->module_dir, 'import', true)) {
                 ACLController::displayNoAccess();
                 sugar_die('');
             }
         }
     }
     if (!$this->bean && $this->importModule != "Administration") {
         $_REQUEST['message'] = $mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'];
         $this->view = 'error';
         if (!isset($_REQUEST['import_map_id']) && !isset($_REQUEST['delete_map_id'])) {
             $this->_processed = true;
         }
     } else {
         $GLOBALS['FOCUS'] = $this->bean;
     }
 }
Esempio n. 2
0
 public function preDisplay()
 {
     if (!$this->bean->ACLAccess('edit')) {
         ACLController::displayNoAccess();
         sugar_die('');
     }
 }
Esempio n. 3
0
 function display()
 {
     ob_start();
     if (isset($GLOBALS['cal_strings'])) {
         return parent::display() . "Only one Calendar dashlet is allowed.";
     }
     require_once 'modules/Calendar/Calendar.php';
     require_once 'modules/Calendar/CalendarDisplay.php';
     require_once "modules/Calendar/CalendarGrid.php";
     global $cal_strings, $current_language;
     $cal_strings = return_module_language($current_language, 'Calendar');
     if (!ACLController::checkAccess('Calendar', 'list', true)) {
         ACLController::displayNoAccess(true);
     }
     $cal = new Calendar($this->view);
     $cal->dashlet = true;
     $cal->add_activities($GLOBALS['current_user']);
     $cal->load_activities();
     $display = new CalendarDisplay($cal, $this->id);
     $display->display_calendar_header(false);
     $display->display();
     $str = ob_get_contents();
     ob_end_clean();
     return parent::display() . $str;
 }
Esempio n. 4
0
 function display()
 {
     $this->bean->password = empty($this->bean->password) ? '' : EAPM::$passwordPlaceholder;
     $this->ss->assign('return_id', $this->_returnId);
     if ($GLOBALS['current_user']->is_admin || empty($this->bean) || empty($this->bean->id) || $this->bean->isOwner($GLOBALS['current_user']->id)) {
         parent::display();
     } else {
         ACLController::displayNoAccess();
     }
 }
Esempio n. 5
0
 public function preDisplay()
 {
     // Add by Thanh Le At 27/06/2012
     //  ViewConvertLead::convertToCustomer();
     // End
     if (!$this->bean->ACLAccess('edit')) {
         ACLController::displayNoAccess();
         sugar_die('');
     }
 }
Esempio n. 6
0
 function preDisplay()
 {
     $this->sugarpdfBean = SugarpdfFactory::loadSugarpdf($this->sugarpdf, $this->module, $this->bean, $this->view_object_map);
     // ACL control
     if (!empty($this->bean) && !$this->bean->ACLAccess($this->sugarpdfBean->aclAction)) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if (isset($this->errors)) {
         $this->sugarpdfBean->errors = $this->errors;
     }
 }
Esempio n. 7
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     if ($this->bean instanceof SugarBean && isset($this->view_object_map['remap_action']) && !$this->bean->ACLAccess($this->view_object_map['remap_action'])) {
         ACLController::displayNoAccess(true);
         return false;
     }
     // Call SugarController::getActionFilename to handle case sensitive file names
     $file = SugarController::getActionFilename($this->action);
     $classic_file = SugarAutoLoader::existingCustomOne('modules/' . $this->module . '/' . $file . '.php');
     if ($classic_file) {
         $this->includeClassicFile($classic_file);
         return true;
     }
     return false;
 }
Esempio n. 8
0
 protected function action_delete()
 {
     global $current_user;
     //do any pre delete processing
     //if there is some custom logic for deletion.
     if (!empty($_REQUEST['record'])) {
         if (!is_admin($current_user) && $this->bean->assigned_user_id != $current_user->id) {
             ACLController::displayNoAccess(true);
             sugar_cleanup(true);
         }
         $this->bean->mark_deleted($_REQUEST['record']);
     } else {
         sugar_die("A record number must be specified to delete");
     }
 }
Esempio n. 9
0
 protected function action_removeAllRecurrences()
 {
     if (!empty($this->bean->repeat_parent_id)) {
         $id = $this->bean->repeat_parent_id;
         $this->bean->retrieve($id);
     } else {
         $id = $this->bean->id;
     }
     if (!$this->bean->ACLAccess('Delete')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     require_once "modules/Calendar/CalendarUtils.php";
     CalendarUtils::markRepeatDeleted($this->bean);
     $this->bean->mark_deleted($id);
     header("Location: index.php?module=Meetings");
 }
Esempio n. 10
0
 function load_merge_bean($merge_module, $load_module_strings = false, $merge_id = '')
 {
     global $moduleList;
     global $beanList;
     global $beanFiles;
     global $current_language;
     $this->merge_module = $merge_module;
     $this->merge_bean = BeanFactory::getBean($this->merge_module, $merge_id);
     // Bug 18853 - Disable this view if the user doesn't have edit and delete permissions
     if (!$this->merge_bean->ACLAccess('edit') || !$this->merge_bean->ACLAccess('delete')) {
         ACLController::displayNoAccess();
         sugar_die('');
     }
     //load master module strings
     if ($load_module_strings) {
         $this->merge_bean_strings = return_module_language($current_language, $merge_module);
     }
 }
Esempio n. 11
0
 function display()
 {
     global $popupMeta, $mod_strings;
     if ($this->bean instanceof SugarBean && !$this->bean->ACLAccess('list')) {
         ACLController::displayNoAccess();
         sugar_cleanup(true);
     }
     if (isset($_REQUEST['metadata']) && strpos($_REQUEST['metadata'], "..") !== false) {
         ACLController::displayNoAccess();
         sugar_cleanup(true);
     }
     $popupMeta = SugarAutoLoader::loadPopupMeta($this->module, isset($_REQUEST['metadata']) ? $_REQUEST['metadata'] : null);
     $defs = $this->loadWithPopup('listviewdefs');
     if (is_array($defs)) {
         $listViewDefs[$this->module] = $defs;
     } elseif (!empty($defs)) {
         require $defs;
     }
     $defs = $this->loadWithPopup('searchdefs');
     if (is_array($defs)) {
         $searchdefs[$this->module]['layout']['advanced_search'] = $defs;
     } elseif (!empty($defs)) {
         require $defs;
     }
     if (!empty($this->bean) && isset($_REQUEST[$this->module . '2_' . strtoupper($this->bean->object_name) . '_offset'])) {
         //if you click the pagination button, it will populate the search criteria here
         if (!empty($_REQUEST['current_query_by_page'])) {
             $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
             $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page']));
             foreach ($current_query_by_page as $search_key => $search_value) {
                 if ($search_key != $this->module . '2_' . strtoupper($this->bean->object_name) . '_offset' && !in_array($search_key, $blockVariables)) {
                     $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value);
                 }
             }
         }
     }
     foreach (SugarAutoLoader::existing('modules/' . $this->module . '/Popup_picker.php', 'include/Popups/Popup_picker.php') as $file) {
         require_once $file;
         break;
     }
     $popup = new Popup_Picker();
     $popup->_hide_clear_button = true;
     echo $popup->process_page();
 }
Esempio n. 12
0
 /**
  * Creates a new Popup_Picker object. Controls displaying of single select and multi select popups
  *
  */
 function Popup_Picker()
 {
     global $currentModule, $popupMeta;
     // cn: bug 12269 - directory navigation attack - detect and stop.
     if (isset($_REQUEST['metadata']) && strpos($_REQUEST['metadata'], "..") !== false) {
         ACLController::displayNoAccess();
         sugar_cleanup(true);
     }
     if (empty($popupMeta)) {
         $popupMeta = SugarAutoLoader::loadPopupMeta($currentModule, isset($_REQUEST['metadata']) ? $_REQUEST['metadata'] : null);
     }
     $this->_popupMeta = $popupMeta;
     require_once 'modules/' . $currentModule . '/' . $this->_popupMeta['moduleMain'] . '.php';
     if (isset($this->_popupMeta['create']['formBase']) && isset($_REQUEST['create']) && $_REQUEST['create'] == 'true') {
         // include create form
         require_once 'modules/' . $currentModule . '/' . $this->_popupMeta['create']['formBase'];
         $this->_create = true;
     }
 }
Esempio n. 13
0
/**
 * Returns the bean object of the given module
 *
 * @param  string $module
 * @return object
 */
function loadImportBean($module)
{
    $focus = loadBean($module);
    if ($focus) {
        if (!$focus->importable) {
            return false;
        }
        if ($module == 'Users' && !is_admin($GLOBALS['current_user']) && !is_admin_for_module($GLOBALS['current_user'], 'Users')) {
            return false;
        }
        if ($focus->bean_implements('ACL')) {
            if (!ACLController::checkAccess($focus->module_dir, 'import', true)) {
                ACLController::displayNoAccess();
                sugar_die('');
            }
        }
    } else {
        return false;
    }
    return $focus;
}
Esempio n. 14
0
 /**
  * @see SugarController::loadBean()
  */
 public function loadBean()
 {
     global $mod_strings;
     $this->bean = loadBean($_REQUEST['import_module']);
     if ($this->bean) {
         if (!$this->bean->importable) {
             $this->bean = false;
         } elseif ($_REQUEST['import_module'] == 'Users' && !is_admin($GLOBALS['current_user'])) {
             $this->bean = false;
         } elseif ($this->bean->bean_implements('ACL')) {
             if (!ACLController::checkAccess($this->bean->module_dir, 'import', true)) {
                 ACLController::displayNoAccess();
                 sugar_die('');
             }
         }
     }
     if (!$this->bean) {
         $_REQUEST['message'] = $mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'];
         $this->view = 'error';
     } else {
         $GLOBALS['FOCUS'] = $this->bean;
     }
 }
Esempio n. 15
0
 function processListView($seed, $xTemplateSection, $html_varName)
 {
     global $sugar_config;
     $populateOnly = $this->ignorePopulateOnly ? FALSE : !empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only';
     if (isset($seed->module_dir) && $populateOnly) {
         if (empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI') && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
             $_SESSION['last_search_mod'] = $_REQUEST['module'];
             return;
         }
     }
     if (strcmp(strtolower($_REQUEST['action']), 'popup') != 0) {
         $_SESSION['last_search_mod'] = $_REQUEST['module'];
     }
     //following session variable will track the detail view nvigation history.
     //needs to the reset after each search.
     $this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY", false);
     require_once 'include/MassUpdate.php';
     $mass = new MassUpdate();
     $add_acl_javascript = false;
     if (!isset($_REQUEST['action'])) {
         $this->shouldProcess = false;
     } else {
         $this->shouldProcess = is_subclass_of($seed, "SugarBean") && ($_REQUEST['action'] == 'index' || 'ListView' == substr($_REQUEST['action'], 0, 8)) && $_REQUEST['module'] == $seed->module_dir;
     }
     //when processing a multi-select popup.
     if ($this->process_for_popups && $this->multi_select_popup) {
         $this->shouldProcess = true;
     }
     //mass update turned off?
     if (!$this->show_mass_update) {
         $this->shouldProcess = false;
     }
     if (is_subclass_of($seed, "SugarBean")) {
         if ($seed->bean_implements('ACL')) {
             if (!ACLController::checkAccess($seed->module_dir, 'list', true)) {
                 if ($_REQUEST['module'] != 'Home') {
                     ACLController::displayNoAccess();
                 }
                 return;
             }
             if (!ACLController::checkAccess($seed->module_dir, 'export', true)) {
                 $sugar_config['disable_export'] = true;
             }
         }
     }
     //force mass update form if requested.
     if ($this->force_mass_update) {
         $this->shouldProcess = true;
     }
     if ($this->shouldProcess) {
         echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup);
         echo $mass->getMassUpdateFormHeader($this->multi_select_popup);
         $mass->setSugarBean($seed);
         //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups
         if (!$this->multi_select_popup) {
             $mass->handleMassUpdate();
         }
     }
     $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
     if ($this->shouldProcess && empty($this->process_for_popups)) {
         //echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>";
         // cn: preserves current functionality, exception is InboundEmail
         if ($this->show_mass_update_form) {
             echo $mass->getMassUpdateForm();
         }
         if (!$this->keep_mass_update_form_open) {
             echo $mass->endMassUpdateForm();
         }
     }
 }
Esempio n. 16
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. 17
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. 18
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. 19
0
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author SalesAgility <*****@*****.**>
 */
if (!ACLController::checkAccess('AOS_Contracts', 'edit', true)) {
    ACLController::displayNoAccess();
    die;
}
require_once 'modules/AOS_Quotes/AOS_Quotes.php';
require_once 'modules/AOS_Contracts/AOS_Contracts.php';
//Setting values in Quotes
$quote = new AOS_Quotes();
$quote->retrieve($_REQUEST['record']);
//Setting Contract Values
$contract = new AOS_Contracts();
$contract->name = $quote->name;
$contract->assigned_user_id = $quote->assigned_user_id;
$contract->total_contract_value = format_number($quote->total_amount);
$contract->contract_account_id = $quote->billing_account_id;
$contract->contact_id = $quote->billing_contact_id;
$contract->opportunity_id = $quote->opportunity_id;
 function action_delete()
 {
     if (!empty($_REQUEST['record'])) {
         if (!$this->bean->ACLAccess('Delete')) {
             ACLController::displayNoAccess(true);
             sugar_cleanup(true);
         }
         $this->bean->mark_deleted($_REQUEST['record']);
     } else {
         sugar_die("A record number must be specified to delete");
     }
 }
Esempio n. 21
0
/**
 * builds up a delimited string for export
 * @param string type the bean-type to export
 * @param array records an array of records if coming directly from a query
 * @return string delimited string for export
 */
function export($type, $records = null, $members = false)
{
    global $beanList;
    global $beanFiles;
    global $current_user;
    global $app_strings;
    global $app_list_strings;
    global $timedate;
    $contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
    $account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
    $focus = 0;
    $content = '';
    $bean = $beanList[$type];
    require_once $beanFiles[$bean];
    $focus = new $bean();
    $searchFields = array();
    $db = DBManagerFactory::getInstance();
    if ($records) {
        $records = explode(',', $records);
        $records = "'" . implode("','", $records) . "'";
        $where = "{$focus->table_name}.id in ({$records})";
    } elseif (isset($_REQUEST['all'])) {
        $where = '';
    } else {
        if (!empty($_REQUEST['current_post'])) {
            $ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
            $where = $ret_array['where'];
            $searchFields = $ret_array['searchFields'];
        } else {
            $where = '';
        }
    }
    $order_by = "";
    if ($focus->bean_implements('ACL')) {
        if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
            ACLController::displayNoAccess();
            sugar_die('');
        }
        if (ACLController::requireOwner($focus->module_dir, 'export')) {
            if (!empty($where)) {
                $where .= ' AND ';
            }
            $where .= $focus->getOwnerWhere($current_user->id);
        }
    }
    // Export entire list was broken because the where clause already has "where" in it
    // and when the query is built, it has a "where" as well, so the query was ill-formed.
    // Eliminating the "where" here so that the query can be constructed correctly.
    if ($members == true) {
        $query = $focus->create_export_members_query($records);
    } else {
        $beginWhere = substr(trim($where), 0, 5);
        if ($beginWhere == "where") {
            $where = substr(trim($where), 5, strlen($where));
        }
        $ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
        if (!empty($ret_array['join'])) {
            $query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
        } else {
            $query = $focus->create_export_query($order_by, $ret_array['where']);
        }
    }
    $result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
    $fields_array = $db->getFieldsArray($result, true);
    // setup the "header" line with proper delimiters
    $header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
    if ($members) {
        $header = str_replace('"ea_deleted"' . getDelimiter() . '"ear_deleted"' . getDelimiter() . '"primary_address"' . getDelimiter() . '', '', $header);
    }
    $header = "\"" . $header;
    $header .= "\"\r\n";
    $content .= $header;
    $pre_id = '';
    while ($val = $db->fetchByAssoc($result, -1, false)) {
        $new_arr = array();
        if ($members) {
            if ($pre_id == $val['id']) {
                continue;
            }
            if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
                $val['primary_email_address'] = '';
            }
            unset($val['ea_deleted']);
            unset($val['ear_deleted']);
            unset($val['primary_address']);
        }
        $pre_id = $val['id'];
        $vals = array_values($val);
        foreach ($vals as $key => $value) {
            //getting content values depending on their types
            $fieldType = $focus->field_name_map[$fields_array[$key]]['type'];
            if (isset($fieldType)) {
                switch ($fieldType) {
                    //if our value is a currency field, then apply the users locale
                    case 'currency':
                        require_once 'modules/Currencies/Currency.php';
                        $value = currency_format_number($value, array('currency_symbol' => false));
                        break;
                        //if our value is a datetime field, then apply the users locale
                    //if our value is a datetime field, then apply the users locale
                    case 'datetime':
                    case 'datetimecombo':
                        $value = $timedate->to_display_date_time($value);
                        $value = preg_replace('/([pm|PM|am|AM]+)/', ' \\1', $value);
                        break;
                        //kbrill Bug #16296
                    //kbrill Bug #16296
                    case 'date':
                        $value = $timedate->to_display_date($value, false);
                        break;
                        // Bug 32463 - Properly have multienum field translated into something useful for the client
                    // Bug 32463 - Properly have multienum field translated into something useful for the client
                    case 'multienum':
                        $value = str_replace("^", "", $value);
                        if (isset($focus->field_name_map[$fields_array[$key]]['options']) && isset($app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']])) {
                            $valueArray = explode(",", $value);
                            foreach ($valueArray as $multikey => $multivalue) {
                                if (isset($app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']][$multivalue])) {
                                    $valueArray[$multikey] = $app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']][$multivalue];
                                }
                            }
                            $value = implode(",", $valueArray);
                        }
                        break;
                }
            }
            array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
        }
        $line = implode("\"" . getDelimiter() . "\"", $new_arr);
        $line = "\"" . $line;
        $line .= "\"\r\n";
        $content .= $line;
    }
    return $content;
}
Esempio n. 22
0
 function display()
 {
     if (!$this->bean->ACLAccess('list')) {
         ACLController::displayNoAccess();
         return;
     }
     $module = $GLOBALS['module'];
     $metadataFile = null;
     $foundViewDefs = false;
     if (file_exists('custom/modules/' . $module . '/metadata/listviewdefs.php')) {
         $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
         $foundViewDefs = true;
     } else {
         if (file_exists('custom/modules/' . $module . '/metadata/metafiles.php')) {
             require_once 'custom/modules/' . $module . '/metadata/metafiles.php';
             if (!empty($metafiles[$module]['listviewdefs'])) {
                 $metadataFile = $metafiles[$module]['listviewdefs'];
                 $foundViewDefs = true;
             }
         } elseif (file_exists('modules/' . $module . '/metadata/metafiles.php')) {
             require_once 'modules/' . $module . '/metadata/metafiles.php';
             if (!empty($metafiles[$module]['listviewdefs'])) {
                 $metadataFile = $metafiles[$module]['listviewdefs'];
                 $foundViewDefs = true;
             }
         }
     }
     if (!$foundViewDefs && file_exists('modules/' . $module . '/metadata/listviewdefs.php')) {
         $metadataFile = 'modules/' . $module . '/metadata/listviewdefs.php';
     }
     require_once $metadataFile;
     $seed = $this->bean;
     if (!empty($this->bean->object_name) && isset($_REQUEST[$module . '2_' . strtoupper($this->bean->object_name) . '_offset'])) {
         //if you click the pagination button, it will poplate the search criteria here
         if (!empty($_REQUEST['current_query_by_page'])) {
             //The code support multi browser tabs pagination
             $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'request_data', 'current_query_by_page', $module . '2_' . strtoupper($this->bean->object_name) . '_ORDER_BY');
             if (isset($_REQUEST['lvso'])) {
                 $blockVariables[] = 'lvso';
             }
             $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page']));
             foreach ($current_query_by_page as $search_key => $search_value) {
                 if ($search_key != $module . '2_' . strtoupper($this->bean->object_name) . '_offset' && !in_array($search_key, $blockVariables)) {
                     if (!is_array($search_value)) {
                         $_REQUEST[$search_key] = $GLOBALS['db']->quoteForEmail($search_value);
                     } else {
                         foreach ($search_value as $key => &$val) {
                             $val = $GLOBALS['db']->quoteForEmail($val);
                         }
                         $_REQUEST[$search_key] = $search_value;
                     }
                 }
             }
         }
     }
     if (!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') {
         if (empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query'] != 'true')) {
             $this->saved_search = loadBean('SavedSearch');
             $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
             $this->saved_search->populateRequest();
         } elseif (!empty($_REQUEST['button'])) {
             // click the search button, after retrieving from saved_search
             $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
             unset($_REQUEST['saved_search_select']);
             unset($_REQUEST['saved_search_select_name']);
         }
     }
     $lv = new ListViewSmarty();
     $displayColumns = array();
     if (!empty($_REQUEST['displayColumns'])) {
         foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
             if (!empty($listViewDefs[$module][$col])) {
                 $displayColumns[$col] = $listViewDefs[$module][$col];
             }
         }
     } else {
         foreach ($listViewDefs[$module] as $col => $params) {
             if (!empty($params['default']) && $params['default']) {
                 $displayColumns[$col] = $params;
             }
         }
     }
     global $current_user;
     if (!is_admin($current_user)) {
         $params = array('massupdate' => false);
         $lv->export = false;
     } else {
         $params = array('massupdate' => true, 'export' => true);
     }
     if (!empty($_REQUEST['orderBy'])) {
         $params['orderBy'] = $_REQUEST['orderBy'];
         $params['overrideOrder'] = true;
         if (!empty($_REQUEST['sortOrder'])) {
             $params['sortOrder'] = $_REQUEST['sortOrder'];
         }
     }
     $lv->displayColumns = $displayColumns;
     $this->seed = $seed;
     $this->module = $module;
     $searchForm = null;
     $storeQuery = new StoreQuery();
     if (!isset($_REQUEST['query'])) {
         $storeQuery->loadQuery($this->module);
         $storeQuery->populateRequest();
     } else {
         $storeQuery->saveFromRequest($this->module);
     }
     //search
     $view = 'basic_search';
     if (!empty($_REQUEST['search_form_view'])) {
         $view = $_REQUEST['search_form_view'];
     }
     $headers = true;
     if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
         $headers = false;
     } elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
         if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
             $view = 'advanced_search';
         } else {
             $view = 'basic_search';
         }
     }
     $use_old_search = true;
     if (file_exists('modules/' . $this->module . '/SearchForm.html')) {
         require_once 'include/SearchForm/SearchForm.php';
         $searchForm = new SearchForm($this->module, $this->seed);
     } else {
         $use_old_search = false;
         require_once 'include/SearchForm/SearchForm2.php';
         if (file_exists('custom/modules/' . $this->module . '/metadata/searchdefs.php')) {
             require_once 'custom/modules/' . $this->module . '/metadata/searchdefs.php';
         } elseif (!empty($metafiles[$this->module]['searchdefs'])) {
             require_once $metafiles[$this->module]['searchdefs'];
         } elseif (file_exists('modules/' . $this->module . '/metadata/searchdefs.php')) {
             require_once 'modules/' . $this->module . '/metadata/searchdefs.php';
         }
         if (!empty($metafiles[$this->module]['searchfields'])) {
             require_once $metafiles[$this->module]['searchfields'];
         } elseif (file_exists('modules/' . $this->module . '/metadata/SearchFields.php')) {
             require_once 'modules/' . $this->module . '/metadata/SearchFields.php';
         }
         $searchForm = new SearchForm($this->seed, $this->module, $this->action);
         $searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
         $searchForm->lv = $lv;
     }
     if (isset($this->options['show_title']) && $this->options['show_title']) {
         $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
         echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
     }
     $where = '';
     if (isset($_REQUEST['query'])) {
         // we have a query
         if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
             // from EditView cancel
             $searchForm->populateFromArray($storeQuery->query);
         } else {
             $searchForm->populateFromRequest();
         }
         $where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
         if (count($where_clauses) > 0) {
             $where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
         }
         $GLOBALS['log']->info("List View Where Clause: {$where}");
     }
     if ($use_old_search) {
         switch ($view) {
             case 'basic_search':
                 $searchForm->setup();
                 $searchForm->displayBasic($headers);
                 break;
             case 'advanced_search':
                 $searchForm->setup();
                 $searchForm->displayAdvanced($headers);
                 break;
             case 'saved_views':
                 echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
                 break;
         }
     } else {
         echo $searchForm->display($headers);
     }
     if (!$headers) {
         return;
     }
     if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
         if (!is_admin($current_user)) {
             $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
         } else {
             $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
         }
         $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
         echo $lv->display();
     }
 }
Esempio n. 23
0
 function display()
 {
     if (!$this->bean || !$this->bean->ACLAccess('list')) {
         ACLController::displayNoAccess();
     } else {
         $this->listViewPrepare();
         $this->listViewProcess();
     }
 }
Esempio n. 24
0
<?php

if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}
require_once 'modules/Destinations/Destination.php';
require_once 'include/formbase.php';
require_once 'include/upload_file.php';
$focus = new Destination();
$focus->retrieve($_POST['record']);
if (!$focus->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (!empty($_POST['assigned_user_id']) && $focus->assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
    $check_notify = TRUE;
} else {
    $check_notify = FALSE;
}
foreach ($focus->column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
foreach ($focus->additional_column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
Esempio n. 25
0
 function display()
 {
     global $popupMeta, $mod_strings;
     if ($this->bean instanceof SugarBean && !$this->bean->ACLAccess('list')) {
         ACLController::displayNoAccess();
         sugar_cleanup(true);
     }
     if (isset($_REQUEST['metadata']) && strpos($_REQUEST['metadata'], "..") !== false) {
         die("Directory navigation attack denied.");
     }
     if (!empty($_REQUEST['metadata']) && $_REQUEST['metadata'] != 'undefined' && file_exists('custom/modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php')) {
         require 'custom/modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php';
     } elseif (!empty($_REQUEST['metadata']) && $_REQUEST['metadata'] != 'undefined' && file_exists('modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php')) {
         require 'modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php';
     } elseif (file_exists('custom/modules/' . $this->module . '/metadata/popupdefs.php')) {
         require 'custom/modules/' . $this->module . '/metadata/popupdefs.php';
     } elseif (file_exists('modules/' . $this->module . '/metadata/popupdefs.php')) {
         require 'modules/' . $this->module . '/metadata/popupdefs.php';
     }
     if (!empty($popupMeta) && !empty($popupMeta['listviewdefs'])) {
         if (is_array($popupMeta['listviewdefs'])) {
             //if we have an array, then we are not going to include a file, but rather the
             //listviewdefs will be defined directly in the popupdefs file
             $listViewDefs[$this->module] = $popupMeta['listviewdefs'];
         } else {
             //otherwise include the file
             require_once $popupMeta['listviewdefs'];
         }
     } elseif (file_exists('custom/modules/' . $this->module . '/metadata/listviewdefs.php')) {
         require_once 'custom/modules/' . $this->module . '/metadata/listviewdefs.php';
     } elseif (file_exists('modules/' . $this->module . '/metadata/listviewdefs.php')) {
         require_once 'modules/' . $this->module . '/metadata/listviewdefs.php';
     }
     //check for searchdefs as well
     if (!empty($popupMeta) && !empty($popupMeta['searchdefs'])) {
         if (is_array($popupMeta['searchdefs'])) {
             //if we have an array, then we are not going to include a file, but rather the
             //searchdefs will be defined directly in the popupdefs file
             $searchdefs[$this->module]['layout']['advanced_search'] = $popupMeta['searchdefs'];
         } else {
             //otherwise include the file
             require_once $popupMeta['searchdefs'];
         }
     } else {
         if (empty($searchdefs) && file_exists('custom/modules/' . $this->module . '/metadata/searchdefs.php')) {
             require_once 'custom/modules/' . $this->module . '/metadata/searchdefs.php';
         } else {
             if (empty($searchdefs) && file_exists('modules/' . $this->module . '/metadata/searchdefs.php')) {
                 require_once 'modules/' . $this->module . '/metadata/searchdefs.php';
             }
         }
     }
     //if you click the pagination button, it will populate the search criteria here
     if (!empty($this->bean) && isset($_REQUEST[$this->module . '2_' . strtoupper($this->bean->object_name) . '_offset'])) {
         if (!empty($_REQUEST['current_query_by_page'])) {
             $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
             $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page']));
             foreach ($current_query_by_page as $search_key => $search_value) {
                 if ($search_key != $this->module . '2_' . strtoupper($this->bean->object_name) . '_offset' && !in_array($search_key, $blockVariables)) {
                     if (!is_array($search_value)) {
                         $_REQUEST[$search_key] = securexss($search_value);
                     } else {
                         foreach ($search_value as $key => &$val) {
                             $val = securexss($val);
                         }
                         $_REQUEST[$search_key] = $search_value;
                     }
                 }
             }
         }
     }
     if (!empty($listViewDefs) && !empty($searchdefs)) {
         require_once 'include/Popups/PopupSmarty.php';
         $displayColumns = array();
         $filter_fields = array();
         $popup = new PopupSmarty($this->bean, $this->module);
         foreach ($listViewDefs[$this->module] as $col => $params) {
             $filter_fields[strtolower($col)] = true;
             if (!empty($params['related_fields'])) {
                 foreach ($params['related_fields'] as $field) {
                     //id column is added by query construction function. This addition creates duplicates
                     //and causes issues in oracle. #10165
                     if ($field != 'id') {
                         $filter_fields[$field] = true;
                     }
                 }
             }
             if (!empty($params['default']) && $params['default']) {
                 $displayColumns[$col] = $params;
             }
         }
         $popup->displayColumns = $displayColumns;
         $popup->filter_fields = $filter_fields;
         $popup->mergeDisplayColumns = true;
         //check to see if popupdefs contains searchdefs
         $popup->_popupMeta = $popupMeta;
         $popup->listviewdefs = $listViewDefs;
         $popup->searchdefs = $searchdefs;
         if (isset($_REQUEST['query'])) {
             $popup->searchForm->populateFromRequest();
         }
         $massUpdateData = '';
         if (isset($_REQUEST['mass'])) {
             foreach (array_unique($_REQUEST['mass']) as $record) {
                 $massUpdateData .= "<input style='display: none' checked type='checkbox' name='mass[]' value='{$record}'>\n";
             }
         }
         $popup->massUpdateData = $massUpdateData;
         $tpl = 'include/Popups/tpls/PopupGeneric.tpl';
         if (file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupGeneric.tpl"))) {
             $tpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupGeneric.tpl");
         }
         if (file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupHeader.tpl"))) {
             $popup->headerTpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupHeader.tpl");
         }
         if (file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupFooter.tpl"))) {
             $popup->footerTpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupFooter.tpl");
         }
         $popup->setup($tpl);
         //We should at this point show the header and javascript even if to_pdf is true.
         //The insert_popup_header javascript is incomplete and shouldn't be relied on.
         if (isset($this->options['show_all']) && $this->options['show_all'] == false) {
             unset($this->options['show_all']);
             $this->options['show_javascript'] = true;
             $this->options['show_header'] = true;
             $this->_displayJavascript();
         }
         insert_popup_header(null, false);
         if (isset($this->override_popup['template_data']) && is_array($this->override_popup['template_data'])) {
             $popup->th->ss->assign($this->override_popup['template_data']);
         }
         echo $popup->display();
     } else {
         if (file_exists('modules/' . $this->module . '/Popup_picker.php')) {
             require_once 'modules/' . $this->module . '/Popup_picker.php';
         } else {
             require_once 'include/Popups/Popup_picker.php';
         }
         $popup = new Popup_Picker();
         $popup->_hide_clear_button = true;
         echo $popup->process_page();
     }
 }
Esempio n. 26
0
 /**
  * @param $merge_module
  * @param bool $load_module_strings
  * @param string $merge_id
  */
 public function load_merge_bean($merge_module, $load_module_strings = false, $merge_id = '')
 {
     global $beanList;
     global $beanFiles;
     global $current_language;
     $this->merge_module = $merge_module;
     $this->merge_bean_class = $beanList[$this->merge_module];
     $this->merge_bean_file_path = $beanFiles[$this->merge_bean_class];
     require_once $this->merge_bean_file_path;
     $this->merge_bean = new $this->merge_bean_class();
     if ($merge_id != '') {
         $this->merge_bean->retrieve($merge_id);
     }
     // Bug 18853 - Disable this view if the user doesn't have edit and delete permissions
     if (!$this->merge_bean->ACLAccess('edit') || !$this->merge_bean->ACLAccess('delete')) {
         ACLController::displayNoAccess();
         sugar_die('');
     }
     //load master module strings
     if ($load_module_strings) {
         $this->merge_bean_strings = return_module_language($current_language, $merge_module);
     }
 }
 /**
  * This should be called when the bean is saved. The bean itself will be passed by reference
  * @param SugarBean bean - the bean performing the save
  * @param array params - an array of paramester relevant to the save, most likely will be $_REQUEST
  */
 public function save(&$bean, $params, $field, $properties, $prefix = '')
 {
     if (isset($_POST["primary_" . $field . "_collection"])) {
         $save = false;
         $value_name = $field . "_values";
         $link_field = array();
         // populate $link_field from POST
         foreach ($_POST as $name => $value) {
             if (strpos($name, $field . "_collection_") !== false) {
                 $num = substr($name, -1);
                 if (is_numeric($num)) {
                     settype($num, 'int');
                     if (strpos($name, $field . "_collection_extra_") !== false) {
                         $extra_field = substr($name, $field . "_collection_extra_" . $num);
                         $link_field[$num]['extra_field'][$extra_field] = $value;
                     } else {
                         if ($name == $field . "_collection_" . $num) {
                             $link_field[$num]['name'] = $value;
                         } else {
                             if ($name == "id_" . $field . "_collection_" . $num) {
                                 $link_field[$num]['id'] = $value;
                             }
                         }
                     }
                 }
             }
         }
         // Set Primary
         if (isset($_POST["primary_" . $field . "_collection"])) {
             $primary = $_POST["primary_" . $field . "_collection"];
             settype($primary, 'int');
             $link_field[$primary]['primary'] = true;
         }
         // Create or update record and take care of the extra_field
         require_once 'data/Link.php';
         $class = load_link_class($bean->field_defs[$field]);
         $link_obj = new $class($bean->field_defs[$field]['relationship'], $bean, $bean->field_defs[$field]);
         $module = $link_obj->getRelatedModuleName();
         foreach ($link_field as $k => $v) {
             $save = false;
             $update_fields = array();
             $obj = BeanFactory::getBean($module);
             if (!isset($link_field[$k]['name']) || empty($link_field[$k]['name'])) {
                 // There is no name so it is an empty record -> ignore it!
                 unset($link_field[$k]);
                 break;
             }
             if (!isset($link_field[$k]['id']) || empty($link_field[$k]['id']) || isset($_POST[$field . "_new_on_update"]) && $_POST[$field . "_new_on_update"] === 'true') {
                 // Create a new record
                 if (isset($_POST[$field . "_allow_new"]) && ($_POST[$field . "_allow_new"] === 'false' || $_POST[$field . "_allow_new"] === false)) {
                     // Not allow to create a new record so remove from $link_field
                     unset($link_field[$k]);
                     break;
                 }
                 if (!isset($link_field[$k]['id']) || empty($link_field[$k]['id'])) {
                     // There is no ID so it is a new record
                     $save = true;
                     $obj->name = $link_field[$k]['name'];
                 } else {
                     // We duplicate an existing record because new_on_update is set
                     $obj->retrieve($link_field[$k]['id']);
                     $obj->id = '';
                     $obj->name = $obj->name . '_DUP';
                 }
             } else {
                 // id exist so retrieve the data
                 $obj->retrieve($link_field[$k]['id']);
             }
             // Update the extra field for the new or the existing record
             if (isset($v['extra_field']) && is_array($v['extra_field'])) {
                 // Retrieve the changed fields
                 if (isset($_POST["update_fields_{$field}_collection"]) && !empty($_POST["update_fields_{$field}_collection"])) {
                     $JSON = getJSONobj();
                     $update_fields = $JSON->decode(html_entity_decode($_POST["update_fields_{$field}_collection"]));
                 }
                 // Update the changed fields
                 foreach ($update_fields as $kk => $vv) {
                     if (!isset($_POST[$field . "_allow_update"]) || $_POST[$field . "_allow_update"] !== 'false' && $_POST[$field . "_allow_update"] !== false) {
                         //allow to update the extra_field in the record
                         if (isset($v['extra_field'][$kk]) && $vv == true) {
                             $extra_field_name = str_replace("_" . $field . "_collection_extra_" . $k, "", $kk);
                             if ($obj->{$extra_field_name} != $v['extra_field'][$kk]) {
                                 $save = true;
                                 $obj->{$extra_field_name} = $v['extra_field'][$kk];
                             }
                         }
                     }
                 }
             }
             // Save the new or updated record
             if ($save) {
                 if (!$obj->ACLAccess('save')) {
                     ACLController::displayNoAccess(true);
                     sugar_cleanup(true);
                 }
                 $obj->save();
                 $link_field[$k]['id'] = $obj->id;
             }
         }
         // Save new relationship or delete deleted relationship
         if (!empty($link_field)) {
             if ($bean->load_relationship($field)) {
                 $oldvalues = $bean->{$field}->get(true);
                 $role_field = $bean->{$field}->_get_link_table_role_field($bean->{$field}->_relationship_name);
                 foreach ($link_field as $new_v) {
                     if (!empty($new_v['id'])) {
                         if (!empty($role_field)) {
                             if (isset($new_v['primary']) && $new_v['primary']) {
                                 $bean->{$field}->add($new_v['id'], array($role_field => 'primary'));
                             } else {
                                 $bean->{$field}->add($new_v['id'], array($role_field => 'NULL'));
                             }
                         } else {
                             $bean->{$field}->add($new_v['id'], array());
                         }
                     }
                 }
                 foreach ($oldvalues as $old_v) {
                     $match = false;
                     foreach ($link_field as $new_v) {
                         if ($new_v['id'] == $old_v['id']) {
                             $match = true;
                         }
                     }
                     if (!$match) {
                         $bean->{$field}->delete($bean->id, $old_v['id']);
                     }
                 }
             }
         }
     }
 }
Esempio n. 28
0
 /**
  * Perform the actual massupdate.
  */
 protected function action_massupdate()
 {
     if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))) {
         if (!empty($_REQUEST['Delete']) && $_REQUEST['Delete'] == 'true' && !$this->bean->ACLAccess('delete') || (empty($_REQUEST['Delete']) || $_REQUEST['Delete'] != 'true') && !$this->bean->ACLAccess('save')) {
             ACLController::displayNoAccess(true);
             sugar_cleanup(true);
         }
         set_time_limit(0);
         //I'm wondering if we will set it never goes timeout here.
         // until we have more efficient way of handling MU, we have to disable the limit
         $GLOBALS['db']->setQueryLimit(0);
         require_once "include/MassUpdate.php";
         require_once 'modules/MySettings/StoreQuery.php';
         $seed = loadBean($_REQUEST['module']);
         $mass = new MassUpdate();
         $mass->setSugarBean($seed);
         if (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
             $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
         }
         $mass->handleMassUpdate();
         $storeQuery = new StoreQuery();
         //restore the current search. to solve bug 24722 for multi tabs massupdate.
         $temp_req = array('current_query_by_page' => $_REQUEST['current_query_by_page'], 'return_module' => $_REQUEST['return_module'], 'return_action' => $_REQUEST['return_action']);
         if ($_REQUEST['return_module'] == 'Emails') {
             if (!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
                 $this->req_for_email = array('type' => $_REQUEST['type'], 'ie_assigned_user_id' => $_REQUEST['ie_assigned_user_id']);
                 // Specifically for My Achieves
             }
         }
         $_REQUEST = array();
         $_REQUEST = unserialize(base64_decode($temp_req['current_query_by_page']));
         unset($_REQUEST[$seed->module_dir . '2_' . strtoupper($seed->object_name) . '_offset']);
         //after massupdate, the page should redirect to no offset page
         $storeQuery->saveFromRequest($_REQUEST['module']);
         $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']);
         //for post_massupdate, to go back to original page.
     } else {
         sugar_die("You must massupdate at least one record");
     }
 }
 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
 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;
         }
     }
 }