public function testDuration_set_get() { $meeting = new Meeting(); $duration = 3; $meeting->setDuration($duration); $this->assertEquals($duration, $meeting->getDuration()); }
function delete($id = FALSE) { if ($id) { $meeting = new Meeting($id); $meeting->delete(); set_notify('success', lang('delete_data_complete')); } redirect('meetings'); }
public function testFindPlaceFor() { $this->hoursync->addCalendarURI(self::VALID_CALENDAR_URI); $this->hoursync->loadCalendars(); $meeting = new Meeting(); $meeting->setFrequency(Meeting::WEEKLY); $meeting->setDuration(2); $place = $this->hoursync->findPlaceFor($meeting); $this->assertNotEquals($place, false); }
public function testEndDateChange() { $meetingsSql = "UPDATE meetings AS a INNER JOIN meetings AS b ON a.id = b.id SET a.date_end = date_add(b.date_start, INTERVAL + concat(b.duration_hours, b.duration_minutes) HOUR_MINUTE) WHERE a.id = '{$this->_meetingId}'"; $GLOBALS['db']->query($meetingsSql); $meeting = new Meeting(); $meeting->disable_row_level_security = true; $meeting->retrieve($this->_meetingId); $meeting->fixUpFormatting(); $this->assertEquals($meeting->date_end, '2010-10-12 00:15:00', 'Ensuring that the end_date is saved properly as a date time field'); }
public function setUp() { global $current_user, $currentModule; $mod_strings = return_module_language($GLOBALS['current_language'], "Meetings"); $current_user = SugarTestUserUtilities::createAnonymousUser(); $meeting = new Meeting(); $meeting->id = uniqid(); $meeting->name = 'Test Meeting'; $meeting->save(); $this->meeting = $meeting; }
public static function createMeeting($id = '') { $time = mt_rand(); $name = 'Meeting'; $meeting = new Meeting(); $meeting->name = $name . $time; if (!empty($id)) { $meeting->new_with_id = true; $meeting->id = $id; } $meeting->save(); self::$_createdMeetings[] = $meeting; return $meeting; }
protected function createNewMeeting() { $m = new Meeting(); $m->name = "40541TestMeeting"; $m->date_start = gmdate($GLOBALS['timedate']->get_db_date_time_format(), time() + 3000); $m->duration_hours = 0; $m->duration_minutes = 15; $m->reminder_time = 60; $m->reminder_checked = true; $m->save(); $m->load_relationship("users"); $m->users->add($this->_user->id); $this->beans[] = $m; return $m; }
/** * A method to return the datetime of meeting associated with the note * @return string the datetime */ function getMeetingDatetime() { # If this note has a meeting associated with it if ($this->MeetingId != 0) { require_once 'Meeting.php'; # Get the meeting object $meeting = new Meeting($this->MeetingId); # Get datetime and return it in user friendly format $meetingDatetime = $meeting->getDatetime(); return DatetimeConverter::getUserFriendlyDateTimeFormat($meetingDatetime); # Otherwise return an empty string } else { return ""; } }
public function toTableRow($day) { // sets the character to print out for Open or Closed $open_char = "C"; if ($this->open) { $open_char = 'O'; } // adds the meeting codes to the end of the meeting name $newname = Meeting::addToName($this->name); // combines address pieces together to create a whole address $wholeaddress = $this->address . ", " . $this->city . " WA " . $this->zipcode; // adds the last update date at the end of the meeting notes if ($this->notes == "") { $newnotes = $this->notes . "Info Last Updated: " . $this->lupdate; } else { $newnotes = $this->notes . "; Info Last Updated: " . $this->lupdate; } // creates a String of the meeting info as an HTML table row and returns it $htmlstring = "<tr><td class=\"oc\">{$day}</td>"; // day, input as parameter $htmlstring = $htmlstring . "<td data-value=\"{$this->stime_num}\">{$this->stime}</td>"; // String start time with numeric data-value for sorting $htmlstring = $htmlstring . "<td class=\"oc\">{$open_char}</td><td>{$newname}</td>"; // O or C // street name and number but link to apple maps of whole address // used apple maps, as if it's a non apple device it automatically goes to google maps $htmlstring = $htmlstring . "<td><a target=\"_blank\" href=\"http://maps.apple.com/?q={$wholeaddress}\">{$this->address}</a>"; $htmlstring = $htmlstring . "</td><td>{$this->city}</td>"; // city $htmlstring = $htmlstring . "<td>{$newnotes}</td></tr>"; // notes return $htmlstring; }
protected static function resolveUpdateScoreTypeByModel($model) { if ($model->category->value == Meeting::getCategoryCallValue()) { return static::SCORE_TYPE_UPDATE_CALL; } return parent::resolveUpdateScoreTypeByModel($model); }
public function testLoad() { $this->assertEquals(2, Group::getCount()); $this->assertEquals(0, Role::getCount()); $this->assertEquals(0, Account::getCount()); $this->assertEquals(0, Contact::getCount()); $this->assertEquals(0, Opportunity::getCount()); $this->assertEquals(0, Meeting::getCount()); $this->assertEquals(0, Note::getCount()); $this->assertEquals(0, Task::getCount()); $this->assertEquals(1, User::getCount()); $this->assertEquals(0, ProductCatalog::getCount()); $this->assertEquals(0, ProductCategory::getCount()); $this->assertEquals(0, ProductTemplate::getCount()); $this->assertEquals(0, Product::getCount()); $messageLogger = new MessageLogger(); DemoDataUtil::unsetLoadedModules(); DemoDataUtil::load($messageLogger, 3); $this->assertEquals(8, Group::getCount()); $this->assertEquals(3, Role::getCount()); $this->assertEquals(3, Account::getCount()); $this->assertEquals(16, Contact::getCount()); $this->assertEquals(6, Opportunity::getCount()); $this->assertEquals(18, Meeting::getCount()); $this->assertEquals(12, Note::getCount()); $this->assertEquals(9, Task::getCount()); $this->assertEquals(10, User::getCount()); $this->assertEquals(1, ProductCatalog::getCount()); $this->assertEquals(6, ProductCategory::getCount()); $this->assertEquals(32, ProductTemplate::getCount()); $this->assertEquals(59, Product::getCount()); }
public static function createMeeting($id = '') { $time = mt_rand(); $name = 'Meeting'; $meeting = new Meeting(); $meeting->name = $name . $time; $meeting->date_start = $GLOBALS['timedate']->getNow()->asDb(); $meeting->duration_hours = '0'; $meeting->duration_minutes = '15'; if (!empty($id)) { $meeting->new_with_id = true; $meeting->id = $id; } $meeting->save(); self::$_createdMeetings[] = $meeting; return $meeting; }
public static function createMeetingWithOwnerAndRelatedAccount($name, $owner, $account) { $startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000); $endStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 11000); $meeting = new Meeting(); $meeting->name = $name; $meeting->owner = $owner; $meeting->location = 'my location'; $meeting->category->value = 'Call'; $meeting->startDateTime = $startStamp; $meeting->endDateTime = $endStamp; $meeting->description = 'my test description'; $meeting->activityItems->add($account); $saved = $meeting->save(); assert('$saved'); return $meeting; }
/** * MeetingInfo constructor. * @param $xml \SimpleXMLElement */ public function __construct($xml) { parent::__construct($xml); $this->internalMeetingId = $xml->internalMeetingID->__toString(); $this->isRecording = $xml->recording->__toString() == 'true'; $this->startTime = doubleval($xml->startTime); $this->endTime = doubleval($xml->endTime); $this->maxUsers = $xml->maxUsers->__toString() + 0; $this->moderatorCount = $xml->moderatorCount->__toString() + 0; }
public function testSimpleUserImportWhereAllRowsSucceed() { Yii::app()->user->userModel = User::getByUsername('super'); $meetings = Meeting::getAll(); $this->assertEquals(0, count($meetings)); $import = new Import(); $serializedData['importRulesType'] = 'Meetings'; $serializedData['firstRowIsHeaderRow'] = true; $import->serializedData = serialize($serializedData); $this->assertTrue($import->save()); ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.meetings.tests.unit.files')); $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName())); // includes header rows. $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('location'), 'column_2' => ImportMappingUtil::makeDateTimeColumnMappingData('startDateTime'), 'column_3' => ImportMappingUtil::makeDateTimeColumnMappingData('endDateTime'), 'column_4' => ImportMappingUtil::makeDropDownColumnMappingData('category'), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_6' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_7' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'), 'column_8' => ImportMappingUtil::makeTextAreaColumnMappingData('description')); $importRules = ImportRulesUtil::makeImportRulesByType('Meetings'); $page = 0; $config = array('pagination' => array('pageSize' => 50)); //This way all rows are processed. $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config); $dataProvider->getPagination()->setCurrentPage($page); $importResultsUtil = new ImportResultsUtil($import); $messageLogger = new ImportMessageLogger(); ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger); $importResultsUtil->processStatusAndMessagesForEachRow(); //Confirm that 3 models where created. $meetings = Meeting::getAll(); $this->assertEquals(3, count($meetings)); $meetings = Meeting::getByName('meeting1'); $this->assertEquals(1, count($meetings[0])); $this->assertEquals(1, count($meetings[0]->activityItems)); $this->assertEquals('testAccount', $meetings[0]->activityItems[0]->name); $this->assertEquals('Account', get_class($meetings[0]->activityItems[0])); $this->assertEquals('2011-12-22 05:03', substr($meetings[0]->latestDateTime, 0, -3)); $meetings = Meeting::getByName('meeting2'); $this->assertEquals(1, count($meetings[0])); $this->assertEquals(1, count($meetings[0]->activityItems)); $this->assertEquals('testContact', $meetings[0]->activityItems[0]->firstName); $this->assertEquals('Contact', get_class($meetings[0]->activityItems[0])); $this->assertEquals('2011-12-22 05:03', substr($meetings[0]->latestDateTime, 0, -3)); $meetings = Meeting::getByName('meeting3'); $this->assertEquals(1, count($meetings[0])); $this->assertEquals(1, count($meetings[0]->activityItems)); $this->assertEquals('testOpportunity', $meetings[0]->activityItems[0]->name); $this->assertEquals('Opportunity', get_class($meetings[0]->activityItems[0])); $this->assertEquals('2011-12-22 06:03', substr($meetings[0]->latestDateTime, 0, -3)); //Confirm 10 rows were processed as 'created'. $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED)); //Confirm that 0 rows were processed as 'updated'. $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED)); //Confirm 2 rows were processed as 'errors'. $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR)); $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR); $this->assertEquals(0, count($beansWithErrors)); }
public function testMeetingsThanSpanForMoreThanOneMonth() { $savedCalendars = SavedCalendar::getByName('aSavedCalendar'); $savedCalendar = $savedCalendars[0]; $meetings = Meeting::getByName('aMeeting'); $meeting = $meetings[0]; $meeting->startDateTime = '2014-04-29 01:00:00'; $meeting->endDateTime = '2014-05-09 01:00:00'; $this->assertTrue($meeting->save()); $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser($this->super, (string) $savedCalendar->id); $dataProvider = new CalendarItemsDataProvider($savedCalendarSubscriptions, array('startDate' => '2014-05-01 01:00:00', 'endDate' => '2014-05-31 01:00:00', 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH)); $data = $dataProvider->getData(); $this->assertCount(1, $data); $this->assertEquals('aMeeting', $data[0]->getTitle()); $meeting->startDateTime = '2014-04-29 01:00:00'; $meeting->endDateTime = '2014-06-09 01:00:00'; $this->assertTrue($meeting->save()); $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser($this->super, (string) $savedCalendar->id); $dataProvider = new CalendarItemsDataProvider($savedCalendarSubscriptions, array('startDate' => '2014-05-01 01:00:00', 'endDate' => '2014-05-31 01:00:00', 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH)); $data = $dataProvider->getData(); $this->assertCount(1, $data); $this->assertEquals('aMeeting', $data[0]->getTitle()); $meeting->startDateTime = '2014-05-29 01:00:00'; $meeting->endDateTime = '2014-06-09 01:00:00'; $this->assertTrue($meeting->save()); $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser($this->super, (string) $savedCalendar->id); $dataProvider = new CalendarItemsDataProvider($savedCalendarSubscriptions, array('startDate' => '2014-05-01 01:00:00', 'endDate' => '2014-05-31 01:00:00', 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH)); $data = $dataProvider->getData(); $this->assertCount(1, $data); $this->assertEquals('aMeeting', $data[0]->getTitle()); //Meeting start and ends before calendar start/end dates $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser($this->super, (string) $savedCalendar->id); $dataProvider = new CalendarItemsDataProvider($savedCalendarSubscriptions, array('startDate' => '2014-07-01 01:00:00', 'endDate' => '2014-08-31 01:00:00', 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH)); $data = $dataProvider->getData(); $this->assertCount(0, $data); //Meeting start and ends after calendar start/end dates $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser($this->super, (string) $savedCalendar->id); $dataProvider = new CalendarItemsDataProvider($savedCalendarSubscriptions, array('startDate' => '2014-01-01 01:00:00', 'endDate' => '2014-03-31 01:00:00', 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH)); $data = $dataProvider->getData(); $this->assertCount(0, $data); }
public function init() { if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted()) { $eventHandler = array($this, 'updateContactLatestActivityDateTimeByTask'); Task::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Task'] = array('onAfterSave', $eventHandler); } if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated()) { $eventHandler = array($this, 'updateContactLatestActivityDateTimeByNote'); Note::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Note'] = array('onAfterSave', $eventHandler); } if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived()) { $eventHandler = array($this, 'updateContactLatestActivityDateTimeByEmailMessage'); EmailMessage::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['EmailMessage'] = array('onAfterSave', $eventHandler); } if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast()) { $eventHandler = array($this, 'resolveModelLatestActivityDateTimeProcessFlagByMeeting'); Meeting::model()->attachEventHandler('onBeforeSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Meeting'] = array('onBeforeSave', $eventHandler); } }
/** * A method to get a meeting that is before the one that is provided as a parameter * @param Meeting $meeting the meeting after the one that should be returned * @return Meeting|null the previous meeting */ public static function getPreviousMeeting($meeting) { # Get database connection $objPDO = PDOFactory::get(); # Get project ID from session $projectId = HTTPSession::getInstance()->PROJECT_ID; # Get the previous meeting, which we can recognize by # 1. datetime of that meeting is less than meeting provided # 2. Meeting is not deleted, however can be cancelled, because we might look for a meeting that was cancelled # 3. Meeting is approved $strQuery = "SELECT id FROM Meeting WHERE project_id = :project_id\n AND datetime < (SELECT datetime FROM Meeting WHERE id = " . $meeting->getID() . ")\n AND is_deleted = 0\n AND is_approved = 1\n ORDER BY datetime DESC\n LIMIT 1"; $objStatement = $objPDO->prepare($strQuery); $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT); $objStatement->execute(); # Define empty variable $prevMeeting = null; # Get the previous meeting if it exists if ($row = $objStatement->fetch(PDO::FETCH_ASSOC)) { $prevMeeting = new Meeting($row['id']); } # The previous meeting return $prevMeeting; }
if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } require_once "modules/ECalendar/SaveInvitees.php"; require_once "modules/ECalendar/functions.php"; if ($_REQUEST['cur_module'] == 'Calls') { require_once "modules/Calls/Call.php"; $bean = new Call(); $type = 'call'; $table_name = 'calls'; $jn = "call_id_c"; } if ($_REQUEST['cur_module'] == 'Meetings') { require_once "modules/Meetings/Meeting.php"; $bean = new Meeting(); $type = 'meeting'; $table_name = 'meetings'; $jn = "meeting_id_c"; } if (!empty($_REQUEST['record'])) { $bean->retrieve($_REQUEST['record']); } if (!$bean->ACLAccess('Save')) { $json_arr = array('succuss' => 'no'); echo json_encode($json_arr); die; } $bean->name = $_REQUEST['name']; $bean->date_start = $_REQUEST['date_start']; $bean->date_end = $_REQUEST['date_start'];
public function testUpdateLatestActivityDateTimeWhenAMeetingIsInThePast() { $meeting = new Meeting(); $meeting->name = 'my meeting'; $meeting->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 86400); $this->assertNull($meeting->processedForLatestActivity); $meeting->processedForLatestActivity = true; $this->assertTrue($meeting->save()); $this->assertTrue($meeting->processedForLatestActivity == false); $meeting->processedForLatestActivity = true; $this->assertTrue($meeting->save()); $this->assertTrue($meeting->processedForLatestActivity == true); }
function save($check_notify = FALSE) { global $timedate; global $current_user; global $disable_date_format; if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { $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) { $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->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 { SugarApplication::appendErrorMessage($GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']); return $this->id; } $api->logoff(); } $return_id = parent::save($check_notify); if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } return $return_id; }
/** * handles save functionality for meetings * @param string prefix * @param bool redirect default True * @param bool useRequired default True */ function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; global $current_user; global $timedate; $focus = new Meeting(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } if (!isset($_POST['reminder_checked']) or isset($_POST['reminder_checked']) && $_POST['reminder_checked'] == '0') { $_POST['reminder_time'] = -1; } if (!isset($_POST['reminder_time'])) { $_POST['reminder_time'] = $current_user->getPreference('reminder_time'); $_POST['reminder_checked'] = 1; } if (!isset($_POST['email_reminder_checked']) || isset($_POST['email_reminder_checked']) && $_POST['email_reminder_checked'] == '0') { $_POST['email_reminder_time'] = -1; } if (!isset($_POST['email_reminder_time'])) { $_POST['email_reminder_time'] = $current_user->getPreference('email_reminder_time'); $_POST['email_reminder_checked'] = 1; } // don't allow to set recurring_source from a form unset($_POST['recurring_source']); $time_format = $timedate->get_user_time_format(); $time_separator = ":"; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } if (!empty($_POST[$prefix . 'time_hour_start']) && empty($_POST['time_start'])) { $_POST[$prefix . 'time_start'] = $_POST[$prefix . 'time_hour_start'] . $time_separator . $_POST[$prefix . 'time_minute_start']; } if (isset($_POST[$prefix . 'meridiem']) && !empty($_POST[$prefix . 'meridiem'])) { $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(), $_POST[$prefix . 'meridiem']); } if (isset($_POST[$prefix . 'time_start']) && strlen($_POST[$prefix . 'date_start']) == 10) { $_POST[$prefix . 'date_start'] = $_POST[$prefix . 'date_start'] . ' ' . $_POST[$prefix . 'time_start']; } // retrieve happens here $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } // if dates changed if (!empty($focus->id)) { $oldBean = new Meeting(); $oldBean->retrieve($focus->id); if ($focus->date_start != $oldBean->date_start || $focus->date_end != $oldBean->date_end) { $focus->date_changed = true; } else { $focus->date_changed = false; } } $newBean = true; if (!empty($focus->id)) { $newBean = false; } //add assigned user and current user if this is the first time bean is saved if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Meetings' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] == 'DetailView') { //if return action is set to detail view and return module to meeting, then this is from the long form, do not add the assigned user (only the current user) //The current user is already added to UI and we want to give the current user the option of opting out of meeting. //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id']) { $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } } elseif (empty($focus->id)) { //this is not from long form so add assigned and current user automatically as there is no invitee list UI. //This call could be through an ajax call from subpanels or shortcut bar if (!isset($_POST['user_invitees'])) { $_POST['user_invitees'] = ''; } $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id'] && $_REQUEST['module'] != "Calendar") { $_POST['user_invitees'] .= ',' . $current_user->id . ', '; } //remove any double comma's introduced during appending $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } if (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true' || (isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id) || isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer' && !empty($focus->id)) || !isset($_POST['user_invitees'])) { $focus->save(true); $return_id = $focus->id; } else { if ($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()) { //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no //need to process user invitees, just save the current values. $focus->save(true); } else { /////////////////////////////////////////////////////////////////////////// //// 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 meeting $q = 'SELECT mu.user_id, mu.accept_status FROM meetings_users mu WHERE mu.meeting_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 meetings_users set deleted = 1 where user_id in ({$sql}) AND meeting_id = '" . $focus->id . "'"; $focus->db->query($sql); } // Get all contacts for the meeting 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 meetings_contacts mu WHERE mu.meeting_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 meetings_contacts set deleted = 1 where contact_id in ({$sql}) AND meeting_id = '" . $focus->id . "'"; $focus->db->query($sql); } if (!empty($_POST['lead_invitees'])) { $leadInvitees = explode(',', trim($_POST['lead_invitees'], ',')); } else { $leadInvitees = array(); } $deleteLeads = array(); $focus->load_relationship('leads'); $q = 'SELECT mu.lead_id, mu.accept_status FROM meetings_leads mu WHERE mu.meeting_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['lead_id']] = $a['accept_status']; } } if (count($deleteLeads) > 0) { $sql = ''; foreach ($deleteLeads 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 meetings_leads set deleted = 1 where lead_id in ({$sql}) AND meeting_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 Meeting module's save function to handle saving other fields besides // the users and contacts relationships $focus->update_vcal = false; // Bug #49195 : don't update vcal b/s related users aren't saved yet, create vcal cache below $focus->save(true); $return_id = $focus->id; if (empty($return_id)) { //this is to handle the situation where the save fails, most likely because of a failure //in the external api. bug: 42200 $_REQUEST['action'] = 'EditView'; $_REQUEST['return_action'] = 'EditView'; handleRedirect('', 'Meetings'); } // 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->users->add($user_id); } else { if (!$focus->date_changed) { // update query to preserve accept_status $qU = 'UPDATE meetings_users SET deleted = 0, accept_status = \'' . $acceptStatusUsers[$user_id] . '\' '; $qU .= 'WHERE meeting_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])) { continue; } if (!isset($acceptStatusContacts[$contact_id])) { $focus->contacts->add($contact_id); } else { if (!$focus->date_changed) { // update query to preserve accept_status $qU = 'UPDATE meetings_contacts SET deleted = 0, accept_status = \'' . $acceptStatusContacts[$contact_id] . '\' '; $qU .= 'WHERE meeting_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])) { continue; } if (!isset($acceptStatusLeads[$lead_id])) { $focus->leads->add($lead_id); } else { if (!$focus->date_changed) { // update query to preserve accept_status $qU = 'UPDATE meetings_leads SET deleted = 0, accept_status = \'' . $acceptStatusLeads[$lead_id] . '\' '; $qU .= 'WHERE meeting_id = \'' . $focus->id . '\' '; $qU .= 'AND lead_id = \'' . $lead_id . '\''; $focus->db->query($qU); } } } // Bug #49195 : update vcal vCal::cache_sugar_vcal($current_user); // CCL - Comment out call to set $current_user as invitee // set organizer to auto-accept if ($focus->assigned_user_id == $current_user->id && $newBean) { $focus->set_accept_status($current_user, 'accept'); } //// END REBUILD INVITEE RELATIONSHIPS /////////////////////////////////////////////////////////////////////////// } } if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Home') { header("Location: index.php?module=Home&action=index"); } else { if ($redirect) { handleRedirect($return_id, 'Meetings'); } else { return $focus; } } }
/** * @depends testListMeetings */ public function testUnprivilegedUserViewUpdateDeleteMeetings() { Yii::app()->user->userModel = User::getByUsername('super'); $notAllowedUser = UserTestHelper::createBasicUser('Steven'); $notAllowedUser->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API); $saved = $notAllowedUser->save(); $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $this->assertTrue($everyoneGroup->save()); $meetings = Meeting::getByName('Michael Meeting'); $this->assertEquals(1, count($meetings)); $data['description'] = "Some new description 2"; // Test with unprivileged user to view, edit and delete account. $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/read/' . $meetings[0]->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/update/' . $meetings[0]->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/delete/' . $meetings[0]->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); //now check if user have rights, but no permissions. $notAllowedUser->setRight('MeetingsModule', MeetingsModule::getAccessRight()); $notAllowedUser->setRight('MeetingsModule', MeetingsModule::getCreateRight()); $notAllowedUser->setRight('MeetingsModule', MeetingsModule::getDeleteRight()); $saved = $notAllowedUser->save(); $this->assertTrue($saved); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/read/' . $meetings[0]->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/update/' . $meetings[0]->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/delete/' . $meetings[0]->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); // Allow everyone group to read/write meeting $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); unset($data); $data['explicitReadWriteModelPermissions'] = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/update/' . $meetings[0]->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/read/' . $meetings[0]->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); unset($data); $data['description'] = "Some new description 3"; $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/update/' . $meetings[0]->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals("Some new description 3", $response['data']['description']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/delete/' . $meetings[0]->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); // Test with privileged user $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); //Test Delete $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/delete/' . $meetings[0]->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/meetings/meeting/api/read/' . $meetings[0]->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); }
public function testConversionAndDoNothing() { global $sugar_config; // init $lead = SugarTestLeadUtilities::createLead(); $account = SugarTestAccountUtilities::createAccount(); $meeting = SugarTestMeetingUtilities::createMeeting(); SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id); $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id); $_REQUEST['record'] = $lead->id; // set the request/post parameters before converting the lead $_REQUEST['module'] = 'Leads'; $_REQUEST['action'] = 'ConvertLead'; $_REQUEST['record'] = $lead->id; $_REQUEST['handle'] = 'save'; $_REQUEST['selectedAccount'] = $account->id; $sugar_config['lead_conv_activity_opt'] = 'none'; // call display to trigger conversion $vc = new ViewConvertLead(); $vc->display(); // refresh meeting $meeting_id = $meeting->id; $meeting = new Meeting(); $meeting->retrieve($meeting_id); // refresh lead $lead_id = $lead->id; $lead = new Lead(); $lead->retrieve($lead_id); // retrieve the new contact id from the conversion $contact_id = $lead->contact_id; // 1. Lead's contact_id should not be null $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.'); // 2. Lead status should be 'Converted' $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'."); // 3. parent_type of the original meeting should be Leads $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads'); // 4. parent_id of the original meeting should be contact id $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.'); // 5. record should NOT be deleted from meetings_leads table $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0"; $result = $GLOBALS['db']->query($sql); $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse(empty($row), "Meeting-Lead relationship is removed."); // 6. record should NOT be added to meetings_contacts table $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0"; $result = $GLOBALS['db']->query($sql); $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse($row, "Meeting-Contact relationship should not be added."); // clean up unset($_REQUEST['record']); $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'"); $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'"); $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'"); $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'"); $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'"); SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id); SugarTestMeetingUtilities::removeMeetingContacts(); SugarTestMeetingUtilities::removeAllCreatedMeetings(); SugarTestAccountUtilities::removeAllCreatedAccounts(); SugarTestLeadUtilities::removeAllCreatedLeads(); }
* 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. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ global $json, $current_user; if ($_REQUEST['object_type'] == "Meeting") { $focus = new Meeting(); $focus->id = $_REQUEST['object_id']; $test = $focus->set_accept_status($current_user, $_REQUEST['accept_status']); } else { if ($_REQUEST['object_type'] == "Call") { $focus = new Call(); $focus->id = $_REQUEST['object_id']; $test = $focus->set_accept_status($current_user, $_REQUEST['accept_status']); } } print 1; exit;
/** * handles save functionality for meetings * @param string prefix * @param bool redirect default True * @param bool useRequired default True */ function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'include/formbase.php'; global $current_user; global $timedate; $focus = BeanFactory::getBean('Meetings'); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } if (!isset($_POST['reminder_checked']) or isset($_POST['reminder_checked']) && $_POST['reminder_checked'] == '0') { $_POST['reminder_time'] = -1; } if (!isset($_POST['reminder_time'])) { $_POST['reminder_time'] = $current_user->getPreference('reminder_time'); $_POST['reminder_checked'] = 1; } if (!isset($_POST['email_reminder_checked']) || isset($_POST['email_reminder_checked']) && $_POST['email_reminder_checked'] == '0') { $_POST['email_reminder_time'] = -1; } if (!isset($_POST['email_reminder_time'])) { $_POST['email_reminder_time'] = $current_user->getPreference('email_reminder_time'); $_POST['email_reminder_checked'] = 1; } if (isset($_POST['repeat_parent_id']) && trim($_POST['repeat_parent_id']) == '') { unset($_POST['repeat_parent_id']); } // don't allow to set recurring_source from a form unset($_POST['recurring_source']); $time_format = $timedate->get_user_time_format(); $time_separator = ":"; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } if (!empty($_POST[$prefix . 'time_hour_start']) && empty($_POST['time_start'])) { $_POST[$prefix . 'time_start'] = $_POST[$prefix . 'time_hour_start'] . $time_separator . $_POST[$prefix . 'time_minute_start']; } if (isset($_POST[$prefix . 'meridiem']) && !empty($_POST[$prefix . 'meridiem'])) { $_POST[$prefix . 'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix . 'time_start'], $timedate->get_time_format(), $_POST[$prefix . 'meridiem']); } if (isset($_POST[$prefix . 'time_start']) && strlen($_POST[$prefix . 'date_start']) == 10) { $_POST[$prefix . 'date_start'] = $_POST[$prefix . 'date_start'] . ' ' . $_POST[$prefix . 'time_start']; } // retrieve happens here $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } // if dates changed if (!empty($focus->id)) { $oldBean = new Meeting(); $oldBean->retrieve($focus->id); if ($focus->date_start != $oldBean->date_start || $focus->date_end != $oldBean->date_end) { $focus->date_changed = true; } else { $focus->date_changed = false; } } $newBean = true; if (!empty($focus->id)) { $newBean = false; } //add assigned user and current user if this is the first time bean is saved if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Meetings' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] == 'DetailView') { //if return action is set to detail view and return module to meeting, then this is from the long form, do not add the assigned user (only the current user) //The current user is already added to UI and we want to give the current user the option of opting out of meeting. //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id']) { $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } } elseif (empty($focus->id)) { //this is not from long form so add assigned and current user automatically as there is no invitee list UI. //This call could be through an ajax call from subpanels or shortcut bar if (!isset($_POST['user_invitees'])) { $_POST['user_invitees'] = ''; } $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', '; //add current user if the assigned to user is different than current user. if ($current_user->id != $_POST['assigned_user_id'] && $_REQUEST['module'] != "Calendar") { $_POST['user_invitees'] .= ',' . $current_user->id . ', '; } //remove any double comma's introduced during appending $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']); } if (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true' || (isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id) || isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer' && !empty($focus->id)) || !isset($_POST['user_invitees'])) { $focus->save(true); $return_id = $focus->id; } else { if ($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()) { //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no //need to process user invitees, just save the current values. $focus->save(true); } else { $relate_to = $this->getRelatedModuleName($focus); $userInvitees = array(); $contactInvitees = array(); $leadInvitees = array(); $existingUsers = array(); $existingContacts = array(); $existingLeads = array(); if (!empty($_POST['user_invitees'])) { $userInvitees = explode(',', trim($_POST['user_invitees'], ',')); } if (!empty($_POST['existing_invitees'])) { $existingUsers = explode(",", trim($_POST['existing_invitees'], ',')); } if (!empty($_POST['contact_invitees'])) { $contactInvitees = explode(',', trim($_POST['contact_invitees'], ',')); } if (!empty($_POST['existing_contact_invitees'])) { $existingContacts = explode(",", trim($_POST['existing_contact_invitees'], ',')); } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') { $contactInvitees[] = $_POST['parent_id']; } if ($relate_to == 'Contacts') { if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $contactInvitees)) { $contactInvitees[] = $_REQUEST['relate_id']; } } if (!empty($_POST['lead_invitees'])) { $leadInvitees = explode(',', trim($_POST['lead_invitees'], ',')); } if (!empty($_POST['existing_lead_invitees'])) { $existingLeads = explode(",", trim($_POST['existing_lead_invitees'], ',')); } if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Leads') { $leadInvitees[] = $_POST['parent_id']; } if ($relate_to == 'Leads') { if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $leadInvitees)) { $leadInvitees[] = $_REQUEST['relate_id']; } } // Call the Meeting module's save function to handle saving other fields besides // the users and contacts relationships $focus->update_vcal = false; // Bug #49195 : don't update vcal b/s related users aren't saved yet, create vcal cache below $focus->users_arr = $userInvitees; $focus->contacts_arr = $contactInvitees; $focus->leads_arr = $leadInvitees; $focus->save(true); $return_id = $focus->id; if (empty($return_id)) { //this is to handle the situation where the save fails, most likely because of a failure //in the external api. bug: 42200 $_REQUEST['action'] = 'EditView'; $_REQUEST['return_action'] = 'EditView'; handleRedirect('', 'Meetings'); } $focus->setUserInvitees($userInvitees, $existingUsers); $focus->setContactInvitees($contactInvitees, $existingContacts); $focus->setLeadInvitees($focus->leads_arr, $existingLeads); // Bug #49195 : update vcal vCal::cache_sugar_vcal($current_user); $this->processRecurring($focus); } } if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] === 'Home') { SugarApplication::redirect(buildRedirectURL('', 'Home')); } else { if ($redirect) { handleRedirect($return_id, 'Meetings'); } else { return $focus; } } }
if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } require_once "modules/ECalendar/functions.php"; global $beanFiles, $beanList; if ($_REQUEST['cur_module'] == 'Calls') { require_once "modules/Calls/Call.php"; $bean = new Call(); $type = 'call'; $table_name = 'calls'; $jn = "call_id_c"; } if ($_REQUEST['cur_module'] == 'Meetings') { require_once "modules/Meetings/Meeting.php"; $bean = new Meeting(); $type = 'meeting'; $table_name = 'meetings'; $jn = "meeting_id_c"; } $bean->retrieve($_REQUEST['record']); if (!$bean->ACLAccess('DetailView')) { $json_arr = array('succuss' => 'no'); echo json_encode($json_arr); die; } if ($bean->ACLAccess('Save')) { $editview = 1; } else { $editview = 0; }
$task->date_due = create_date() . ' ' . create_time(); $task->date_due_flag = 0; $task->assigned_user_id = $contacts_account->assigned_user_id; $task->assigned_user_name = $contacts_account->assigned_user_name; $key = array_rand($app_list_strings['task_priority_dom']); $task->priority = $app_list_strings['task_priority_dom'][$key]; $key = array_rand($app_list_strings['task_status_dom']); $task->status = $app_list_strings['task_status_dom'][$key]; $task->contact_id = $contact->id; if ($contact->primary_address_city == "San Mateo") { $task->parent_id = $account_id; $task->parent_type = 'Accounts'; $task->save(); } //Create new meetings $meeting = new Meeting(); $key = array_rand($meeting->default_meeting_name_values); $meeting->name = $meeting->default_meeting_name_values[$key]; $meeting->date_start = create_date() . ' ' . create_time(); //$meeting->time_start = date("H:i",time()); $meeting->duration_hours = array_rand($possible_duration_hours_arr); $meeting->duration_minutes = array_rand($possible_duration_minutes_arr); $meeting->assigned_user_id = $assigned_user_id; $meeting->assigned_user_id = $contacts_account->assigned_user_id; $meeting->assigned_user_name = $contacts_account->assigned_user_name; $meeting->description = 'Meeting to discuss project plan and hash out the details of implementation'; $key = array_rand($app_list_strings['meeting_status_dom']); $meeting->status = $app_list_strings['meeting_status_dom'][$key]; $meeting->contact_id = $contact->id; $meeting->parent_id = $account_id; $meeting->parent_type = 'Accounts';
/** * 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; }
$any = new Anylist(); if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 'Maintenance_Type_ID'; } if (isset($_GET['spmdescid'])) { $spmdescid = $_GET['spmdescid']; } else { $spmdescid = ''; } $any->createAnyGrid('SPM_Desc', 'SPM_Desc', 'SPM_Desc_ID', $spmdescid, 'SPM_ID', $_GET['spmid']); break; case 'meeting': //machine list $meet = new Meeting(); if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 'Meeting_ID'; } $meet->createMeetingList(); $sel = new selectlist($id, $meet->getMeetingList(), 'Select Meeting to Edit', 'Meeting_ID', 'meetagenda', '', '', '1'); break; case 'nclogtype': //machine list $any = new Anylist(); $any->createList('NC_Type'); $sel = new selectlist('NC_Type_ID', $any->anylist, 'Select NC Type', 'NC_Type_ID', 'NC_Type', '', '', '1'); break; case 'leave':