public function testSaveAndMarkDeleted() { $call = new Call(); $call->name = 'test'; $call->id = $call->save(); //test for record ID to verify that record is saved $this->assertTrue(isset($call->id)); $this->assertEquals(36, strlen($call->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $call->mark_deleted($call->id); $result = $call->retrieve($call->id); $this->assertEquals(null, $result); }
public function testParentsAreRelatedDuringImport() { $file = 'upload://test50438.csv'; $ret = file_put_contents($file, $this->fileArr); $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true)); $importSource = new ImportFile($file, ',', '"'); $bean = loadBean('Calls'); $_REQUEST['columncount'] = 5; $_REQUEST['colnum_0'] = 'id'; $_REQUEST['colnum_1'] = 'subject'; $_REQUEST['colnum_2'] = 'status'; $_REQUEST['colnum_3'] = 'parent_type'; $_REQUEST['colnum_4'] = 'parent_id'; $_REQUEST['import_module'] = 'Contacts'; $_REQUEST['importlocale_charset'] = 'UTF-8'; $_REQUEST['importlocale_timezone'] = 'GMT'; $_REQUEST['importlocale_default_currency_significant_digits'] = '2'; $_REQUEST['importlocale_currency'] = '-99'; $_REQUEST['importlocale_dec_sep'] = '.'; $_REQUEST['importlocale_currency'] = '-99'; $_REQUEST['importlocale_default_locale_name_format'] = 's f l'; $_REQUEST['importlocale_num_grp_sep'] = ','; $_REQUEST['importlocale_dateformat'] = 'm/d/y'; $_REQUEST['importlocale_timeformat'] = 'h:i:s'; $importer = new Importer($importSource, $bean); $importer->import(); //fetch the bean using the passed in id and get related contacts require_once 'modules/Calls/Call.php'; $call = new Call(); $call->retrieve($this->call_id); $call->load_relationship('contacts'); $related_contacts = $call->contacts->get(); //test that the contact id is in the array of related contacts. $this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id'); unset($call); /* if (is_file($file)) { unlink($file); } */ }
$cUser = new User(); $cUser->retrieve($_SESSION['authenticated_user_id']); // query log // Very basic santization $contactId = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['contact_id']); // mysql_real_escape_string($_REQUEST['ui_state']); $callRecord = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['call_record']); // mysql_real_escape_string($_REQUEST['call_record']); $query = "update asterisk_log set contact_id=\"{$contactId}\" where call_record_id=\"{$callRecord}\""; $resultSet = $cUser->db->query($query, false); if ($cUser->db->checkError()) { trigger_error("Update setContactId-Query failed: {$query}"); } // Adds the new relationship! (This must be done here in case the call has already been hungup as that's when asteriskLogger sets relations) $focus = new Call(); $focus->retrieve($callRecord); $focus->load_relationship('contacts'); // Remove any contacts already associated with call (if there are any) foreach ($focus->contacts->getBeans() as $contact) { $focus->contacts->delete($callRecord, $contact->id); } $focus->contacts->add($contactId); // Add the new one! $contactBean = new Contact(); $contactBean->retrieve($contactId); $focus->parent_id = $contactBean->account_id; $focus->parent_type = "Accounts"; $focus->save(); } else { if ($_REQUEST['action'] == "call") { // TODO: For some reason this code isn't working... I think it's getting the extension.
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); } return $return_id; }
/** * main method that runs reminding process * @return boolean */ public function process() { $admin = new Administration(); $admin->retrieveSettings(); $meetings = $this->getMeetingsForRemind(); foreach ($meetings as $id) { $recipients = $this->getRecipients($id, 'Meetings'); $bean = new Meeting(); $bean->retrieve($id); if ($this->sendReminders($bean, $admin, $recipients)) { $bean->email_reminder_sent = 1; $bean->save(); } } $calls = $this->getCallsForRemind(); foreach ($calls as $id) { $recipients = $this->getRecipients($id, 'Calls'); $bean = new Call(); $bean->retrieve($id); if ($this->sendReminders($bean, $admin, $recipients)) { $bean->email_reminder_sent = 1; $bean->save(); } } return true; }
/** * @group bug40999 * Check if empty status is handled correctly */ public function testCallEmptyStatusLangConfig() { $this->markTestIncomplete("This test is failing on Jenkins only. Disabling for now"); $langpack = new SugarTestLangPackCreator(); $langpack->setModString('LBL_DEFAULT_STATUS', 'FAILED!', 'Calls'); $langpack->save(); $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Calls'); $call = new Call(); $call->field_defs['status']['default'] = 'My Call'; $call = new Call(); $this->callid = $call->id = create_guid(); $call->new_with_id = 1; $call->save(); // then retrieve $call = new Call(); $call->retrieve($this->callid); $this->assertEquals('My Call', $call->status); }
* * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'modules/Calls/Call.php'; $focus = new Call(); if (!isset($_REQUEST['record'])) { sugar_die("A record number must be specified to delete the call."); } $focus->retrieve($_REQUEST['record']); if (!$focus->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->mark_deleted($_REQUEST['record']); header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
function save($check_notify = FALSE) { require_once 'modules/Calendar/DateTimeUtil.php'; global $timedate, $current_user; global $disable_date_format; if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { $date_start_in_db_fmt = $timedate->swap_formats($this->date_start, $timedate->get_date_time_format(true, $current_user), $timedate->get_db_date_time_format()); $date_start_array = split(" ", trim($date_start_in_db_fmt)); $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]); $date_start_timestamp = mktime($date_time_start->hour, $date_time_start->min, $date_time_start->sec, $date_time_start->month, $date_time_start->day); $date_start_timestamp += $this->duration_hours * 3600 + $this->duration_minutes * 60; $this->date_end = date($timedate->get_date_time_format(true, $current_user), $date_start_timestamp); // Need to convert it to the db date right here so that we don't miss the time calculation $this->date_end = $timedate->to_db_date($this->date_end); if (empty($disable_date_format)) { $this->date_end = $timedate->swap_formats($this->date_end, $timedate->dbDayFormat, $timedate->get_date_format()); } } 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; $check_notify = true; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } if (empty($this->status)) { $mod_strings = return_module_language($GLOBALS['current_language'], $this->module_dir); $this->status = $mod_strings['LBL_DEFAULT_STATUS']; } /*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'); }*/ parent::save($check_notify); global $current_user; if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } }
function save($check_notify = FALSE) { require_once 'modules/Calendar/DateTimeUtil.php'; global $timedate, $current_user; global $disable_date_format; if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { $date_time_start = DateTimeUtil::get_time_start($this->date_start); $date_time_end = DateTimeUtil::get_time_end($date_time_start, $this->duration_hours, $this->duration_minutes); $this->date_end = gmdate("Y-m-d", $date_time_end->ts); } 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; $check_notify = true; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } if (empty($this->status)) { $mod_strings = return_module_language($GLOBALS['current_language'], $this->module_dir); $this->status = $mod_strings['LBL_DEFAULT_STATUS']; } /*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); } return $return_id; }
function post_edit($url, $post_data, $arr_headers = array(), &$http_code, $evid, $tablename, $_entry, $old_link_edit, $user_data) { //$auth=getAuthCode($user_data[0],$user_data[1]); // 190509 not working if not ssl on server $this->login(); $auth = $this->fAuth; $header = array(); $header[] = "MIME-Version: 1.0"; $header[] = "Accept: text/xml"; $header[] = "Authorization: GoogleLogin auth=" . $auth; $header[] = "Content-length: " . strlen($_entry); $header[] = "Content-type: application/atom+xml"; $header[] = "Cache-Control: no-cache"; $header[] = "Connection: close \r\n"; $header[] = $_entry; $link = $old_link_edit; $entry1 = curlToHost($link, 'PUT', $header); $entry = $entry1; $checkok = explode("<link rel='edit' type='application/atom+xml' href='", $entry); $checkok1 = explode("'/>", $checkok[1]); $checkok_url = $checkok1[0]; if ($checkok_url != '') { if ($tablename == "tasks") { $mmod = new Task(); $mmod1 = new Task(); } if ($tablename == "meetings") { $mmod = new Meeting(); $mmod1 = new Meeting(); } if ($tablename == "calls") { $mmod = new Call(); $mmod1 = new Call(); } $newtbname = $tablename . "_cstm"; $cs1 = "delete from {$newtbname} where id_c='{$evid}'"; $cs2 = "insert into {$newtbname} (id_c,google_response_c) values ('{$evid}',\"{$entry}\")"; debugg("<br>update ev1 >" . $cs1); debugg("<br>update ev1 >" . $cs2); $r = $mmod->db->query($cs1); $r = $mmod->db->query($cs2); $s1 = explode("<entry xmlns", $entry); $s2 = explode("</entry>", $s1[1]); $xmlstr = "<entry xmlns" . $s2[0] . "</entry>"; $xmlparse =& new ParseXML(); $xml = $xmlparse->GetXMLTree($xmlstr); $old_id = $xml['ENTRY'][0]['ID'][0]['VALUE']; $old_published = $xml['ENTRY'][0]['PUBLISHED'][0]['VALUE']; $old_updated = $xml['ENTRY'][0]['UPDATED'][0]['VALUE']; $old_link_alt = $xml['ENTRY'][0]['LINK'][0]['ATTRIBUTES']['HREF']; $old_link_self = $xml['ENTRY'][0]['LINK'][1]['ATTRIBUTES']['HREF']; $old_link_edit = $xml['ENTRY'][0]['LINK'][2]['ATTRIBUTES']['HREF']; $old_author = $xml['ENTRY'][0]['AUTHOR'][0]['NAME'][0]['VALUE']; $old_email = $xml['ENTRY'][0]['AUTHOR'][0]['EMAIL'][0]['VALUE']; $mmod1->retrieve($evid); $mmod1->old_id_c = $old_id; $mmod1->old_published_c = $old_published; $mmod1->old_updated_c = $old_updated; $mmod1->old_link_alt_c = $old_link_alt; $mmod1->old_link_self_c = $old_link_self; $mmod1->old_link_edit_c = $old_link_edit; $mmod1->old_author_c = $old_author; $mmod1->old_email_c = $old_email; $mmod1->Save(); debugg("<br>***** Event update ok"); } else { debugg("<br>***** Error updating event .. response " . print_r($entry)); } }
function setBeanID($call_record, $bean_module, $bean_id) { //wrapped the entire action to require a call_record - if this is not being passed then there is no point for this action - PJH if (is_string($call_record) && is_string($bean_id)) { // Very basic sanitization $bean_id = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $bean_id); $bean_module = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $bean_module); $call_record = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $call_record); // Workaround See Discussion here: https://github.com/blak3r/yaai/pull/20 $parent_module = null; $parent_id = null; $parent_name = null; $parent_link = null; $bean_link = build_link($bean_module, $bean_id); $bean_module = strtolower($bean_module); if ($bean_module == 'contacts') { $c = new Contact(); $c->retrieve($bean_id); $bean_name = $c->name; $bean_description = $c->description; $parent_id = $c->account_id; $parent_module = "accounts"; $parent_name = $c->account_name; //$GLOBALS["log"]->fatal(print_r($c,true)); } else { if ($bean_module == "accounts") { $a = new Account(); $a->retrieve($bean_id); $bean_name = $a->name; $bean_description = $a->description; } else { $GLOBALS['log']->fatal("Unsupported Module: {$bean_module}!"); } } $query = "update asterisk_log set bean_id='{$bean_id}', bean_module='{$bean_module}', bean_name='{$bean_name}', bean_link='{$bean_link}', bean_description='{$bean_description}', " . " parent_id='{$parent_id}', parent_module='{$parent_module}', parent_name='{$parent_name}', parent_link='{$parent_link}' " . " where call_record_id='{$call_record}'"; // $GLOBALS['log']->fatal($query); $GLOBALS['current_user']->db->query($query, false); if ($GLOBALS['current_user']->db->checkError()) { trigger_error("Update setContactId-Query failed: {$query}"); } $focus = new Call(); $focus->retrieve($call_record); $focus->load_relationship('contacts'); $focus->load_relationship('accounts'); // TODO here, find if there is a way to remove all relationships dynamically so we don't need to specify 'contacts', 'accounts' explicitly // Remove any contacts already associated with call (if there are any) foreach ($focus->contacts->getBeans() as $contact) { $focus->contacts->delete($call_record, $contact->id); } foreach ($focus->accounts->getBeans() as $account) { $focus->accounts->delete($call_record, $account->id); } switch ($bean_module) { case 'contacts': $focus->contacts->add($bean_id); // Add the new one! $contactBean = new Contact(); $contactBean->retrieve($bean_id); $focus->parent_id = $contactBean->account_id; $focus->parent_type = "Accounts"; break; case 'accounts': $focus->accounts->add($bean_id); break; } $focus->save(); } }
function delete_event($settings, $evid, $tablename, $user_data, $add_notifications) { global $offset_val; if (!$this->isLogged) { $this->login(); } if ($this->isLogged) { if ($tablename == "tasks") { $mmod = new Task(); } if ($tablename == "meetings") { $mmod = new Meeting(); } if ($tablename == "calls") { $mmod = new Call(); } $mmod->retrieve($evid); $str = $mmod->google_response_c; $newtbname = $tablename . "_cstm"; $cs = "select * from {$newtbname} where id_c='{$evid}'"; $r = $mmod->db->query($cs); $a = $mmod->db->fetchByAssoc($r, -1, false); $str = $a['google_response_c']; if ($mmod->old_id_c != "") { $old_id = $mmod->old_id_c; $old_published = $mmod->old_published_c; $old_updated = $mmod->old_updated_c; $old_link_alt = $mmod->old_link_alt_c; $old_link_self = $mmod->old_link_self_c; $old_link_edit = $mmod->old_link_edit_c; $old_author = $mmod->old_author_c; $old_email = $mmod->old_email_c; $settings["reminder_time"] = 10; $offset_val = ".000+03:00"; $offset_val = ".000+00:00"; ////////// dmc290609 if (isset($_REQUEST['delete_invite_user_id'])) { $old_link_edit = $_REQUEST['delete_invite_url']; } ////////// dmc290609 //<gCal:sequence value='0'/> 030509 $_entry = ""; $_entry = "<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:gd='http://schemas.google.com/g/2005'><id>{$old_id}</id><published>{$old_published}</published><updated>{$old_updated}</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/><title type='text'>" . $settings["title"] . "</title><content type='text'>" . $settings["content"] . "</content><link rel='alternate' type='text/html' href='{$old_link_alt}' title='alternate'/><link rel='self' type='application/atom+xml' href='{$old_link_self}'/><link rel='edit' type='application/atom+xml' href='{$old_link_edit}'/><author><name>" . $user_data[0] . "</name><email>" . $user_data[0] . "</email></author><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'/><gd:visibility value='http://schemas.google.com/g/2005#event.default'/><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'/><gd:when startTime='" . $settings["startDay"] . "T" . $settings["startTime"] . "" . $offset_val . "' endTime='" . $settings["endDay"] . "T" . $settings["endTime"] . $offset_val . "'>" . $remindersettings . "</gd:when><gd:who rel='http://schemas.google.com/g/2005#event.organizer' valueString='{$old_author}' email='{$old_email}'/><gd:where valueString='" . $settings["where"] . "'/></entry>"; $header = ""; $this->prepare_feed_url(); $this->post_delete_onl($this->feed_url_prepared, null, $header, $http_code, $evid, $tablename, $_entry, $old_link_edit, $user_data, $old_id, ""); } } }