function save($check_notify = FALSE) { global $timedate, $current_user; if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { $td = $timedate->fromDb($this->date_start); if ($td) { $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); } } if (!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { $check_notify = true; } else { $check_notify = false; } if (empty($_REQUEST['send_invites'])) { if (!empty($this->id)) { $old_record = new Call(); $old_record->retrieve($this->id); $old_assigned_user_id = $old_record->assigned_user_id; } if (empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id'] || isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) { $this->special_notification = true; if (!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { $check_notify = true; } if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } // prevent a mass mailing for recurring meetings created in Calendar module if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { $check_notify = false; } /*nsingh 7/3/08 commenting out as bug #20814 is invalid if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ $this->reminder_checked = '1'; $this->reminder_time = $current_user->getPreference('reminder_time'); }*/ $return_id = parent::save($check_notify); global $current_user; if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } if (isset($_REQUEST['reminders_data'])) { Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); } return $return_id; }
function save($check_notify = FALSE) { global $timedate; global $current_user; global $disable_date_format; if (isset($this->date_start)) { $td = $timedate->fromDb($this->date_start); if (!$td) { $this->date_start = $timedate->to_db($this->date_start); $td = $timedate->fromDb($this->date_start); } if ($td) { if (isset($this->duration_hours) && $this->duration_hours != '') { $td->modify("+{$this->duration_hours} hours"); } if (isset($this->duration_minutes) && $this->duration_minutes != '') { $td->modify("+{$this->duration_minutes} mins"); } $this->date_end = $td->asDb(); } } $check_notify = !empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1' ? true : false; if (empty($_REQUEST['send_invites'])) { if (!empty($this->id)) { $old_record = new Meeting(); $old_record->retrieve($this->id); $old_assigned_user_id = $old_record->assigned_user_id; } if (empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id'] || isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) { $this->special_notification = true; $check_notify = true; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } /*nsingh 7/3/08 commenting out as bug #20814 is invalid if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ $this->reminder_checked = '1'; $this->reminder_time = $current_user->getPreference('reminder_time'); }*/ // prevent a mass mailing for recurring meetings created in Calendar module if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { $check_notify = false; } if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } // Do any external API saving // Clear out the old external API stuff if we have changed types if (isset($this->fetched_row) && $this->fetched_row['type'] != $this->type) { $this->join_url = ''; $this->host_url = ''; $this->external_id = ''; $this->creator = ''; } if (!empty($this->type) && $this->type != 'Sugar') { require_once 'include/externalAPI/ExternalAPIFactory.php'; $api = ExternalAPIFactory::loadAPI($this->type); } if (empty($this->type)) { $this->type = 'Sugar'; } if (isset($api) && is_a($api, 'WebMeeting') && empty($this->in_relationship_update)) { // Make sure the API initialized and it supports Web Meetings // Also make suer we have an ID, the external site needs something to reference if (!isset($this->id) || empty($this->id)) { $this->id = create_guid(); $this->new_with_id = true; } $response = $api->scheduleMeeting($this); if ($response['success'] == TRUE) { // Need to send out notifications if ($api->canInvite) { $notifyList = $this->get_notification_recipients(); foreach ($notifyList as $person) { $api->inviteAttendee($this, $person, $check_notify); } } } else { // Generic Message Provides no value to End User - Log the issue with message detail and continue // SugarApplication::appendErrorMessage($GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']); $GLOBALS['log']->warn('ERR_EXTERNAL_API_SAVE_FAIL' . ": " . $this->type . " - " . $response['errorMessage']); } $api->logoff(); } $return_id = parent::save($check_notify); if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } if (isset($_REQUEST['reminders_data'])) { $reminderData = json_encode($this->removeUnInvitedFromReminders(json_decode(html_entity_decode($_REQUEST['reminders_data']), true))); Reminder::saveRemindersDataJson('Meetings', $return_id, $reminderData); } return $return_id; }