/**
  * @depends testEditOfTheMeetingForTheTagCloudFieldAfterRemovingAllTagsPlacedForMeetingsModule
  */
 public function testEditOfTheMeetingForTheCustomFieldsPlacedForMeetingsModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Retrieve the meeting Id.
     $meeting = Meeting::getByName('myEditMeeting');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     //Get the super user, account, opportunity and contact id.
     $superUserId = $super->id;
     $superAccount = Account::getByName('superAccount');
     $superContactId1 = self::getModelIdByModelNameAndName('Contact', 'superContact1 superContact1son');
     $superContactId2 = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
     $superContactId3 = self::getModelIdByModelNameAndName('Contact', 'superContact3 superContact3son');
     $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     $activityItemFormContacts = $superContactId1 . ',' . $superContactId2 . ',' . $superContactId3;
     // Not Coding Standard
     //Edit the meeting based on the custom fields and the meeting Id.
     $this->setGetArray(array('id' => $meeting[0]->id));
     $this->setPostArray(array('Meeting' => array('name' => 'myEditMeeting', 'location' => 'LandLine', 'startDateTime' => $datetime, 'endDateTime' => $datetime, 'category' => array('value' => 'Call'), 'description' => 'This is Edit Meeting Description', 'owner' => array('id' => $superUserId), 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '12', 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com'), 'ActivityItemForm' => array('Account' => array('id' => $superAccount[0]->id), 'contact' => array('ids' => $activityItemFormContacts), 'Opportunity' => array('id' => $superOpportunityId))));
     $this->runControllerWithRedirectExceptionAndGetUrl('meetings/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $meeting = Meeting::getByName('myEditMeeting');
     //Retrieve the permission of the meeting.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Meeting::getById($meeting[0]->id));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($meeting[0]->name, 'myEditMeeting');
     $this->assertEquals($meeting[0]->location, 'LandLine');
     $this->assertEquals($meeting[0]->startDateTime, $datetimeAssert);
     $this->assertEquals($meeting[0]->endDateTime, $datetimeAssert);
     $this->assertEquals($meeting[0]->category->value, 'Call');
     $this->assertEquals($meeting[0]->description, 'This is Edit Meeting Description');
     $this->assertEquals($meeting[0]->owner->id, $superUserId);
     $this->assertEquals($meeting[0]->activityItems->count(), 5);
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($meeting[0]->checkboxCstm, '0');
     $this->assertEquals($meeting[0]->currencyCstm->value, 40);
     $this->assertEquals($meeting[0]->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($meeting[0]->dateCstm, $dateAssert);
     $this->assertEquals($meeting[0]->datetimeCstm, $datetimeAssert);
     $this->assertEquals($meeting[0]->decimalCstm, '12');
     $this->assertEquals($meeting[0]->picklistCstm->value, 'b');
     $this->assertEquals($meeting[0]->integerCstm, 11);
     $this->assertEquals($meeting[0]->phoneCstm, '259-784-2069');
     $this->assertEquals($meeting[0]->radioCstm->value, 'e');
     $this->assertEquals($meeting[0]->textCstm, 'This is a test Edit Text');
     $this->assertEquals($meeting[0]->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($meeting[0]->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($meeting[0]->countrylistCstm->value, 'aaaa');
     $this->assertEquals($meeting[0]->statelistCstm->value, 'aaa1');
     $this->assertEquals($meeting[0]->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $meeting[0]->multiselectCstm->values);
     $this->assertContains('hh', $meeting[0]->multiselectCstm->values);
     $this->assertContains('reading', $meeting[0]->tagcloudCstm->values);
     $this->assertContains('surfing', $meeting[0]->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Meeting');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $meeting[0]);
     $this->assertEquals(1, $testCalculatedValue);
 }
示例#2
0
 /**
  * @depends testValidateBeforeAfterDateTimeValues
  */
 public function testAutomatedLatestDateTimeChanges()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     //Creating a new meeting with a startDateTime. The latestDateTime should populate.
     $startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $meeting = new Meeting();
     $meeting->name = 'aTest';
     $meeting->startDateTime = $startStamp;
     $this->assertTrue($meeting->save());
     $this->assertEquals($startStamp, $meeting->startDateTime);
     $this->assertEquals($startStamp, $meeting->latestDateTime);
     //Modify the meeting but do not change the startDateTime. The latestDateTime should not change.
     $meeting = Meeting::getById($meeting->id);
     $meeting->name = 'bTest';
     $this->assertTrue($meeting->save());
     $this->assertEquals($startStamp, $meeting->startDateTime);
     $this->assertEquals($startStamp, $meeting->latestDateTime);
     //Modify the meeting and change the startDateTime. Confirm the latestDateTime has changed.
     $newStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 1);
     $this->assertNotEquals($startStamp, $newStamp);
     $meeting = Meeting::getById($meeting->id);
     $meeting->name = 'bTest';
     $meeting->startDateTime = $newStamp;
     $this->assertTrue($meeting->save());
     $this->assertEquals($newStamp, $meeting->startDateTime);
     $this->assertEquals($newStamp, $meeting->latestDateTime);
 }
 public function testRunWhereStartDateTimesAreInThePastForAnAccount()
 {
     $meetingIdAndAccountId4 = $this->createMeetingWithRelatedAccount('first name4', 'meeting 4', true);
     $meetingIdAndAccountId5 = $this->createMeetingWithRelatedAccount('first name5', 'meeting 5', true);
     $meetingIdAndAccountId6 = $this->createMeetingWithRelatedAccount('first name6', 'meeting 6', true);
     $meeting4 = Meeting::getById($meetingIdAndAccountId4[0]);
     $meeting5 = Meeting::getById($meetingIdAndAccountId5[0]);
     $meeting6 = Meeting::getById($meetingIdAndAccountId6[0]);
     $this->assertTrue($meeting4->processedForLatestActivity == false);
     $this->assertTrue($meeting5->processedForLatestActivity == false);
     $this->assertTrue($meeting6->processedForLatestActivity == false);
     $account4 = Account::getById($meetingIdAndAccountId4[1]);
     $account5 = Account::getById($meetingIdAndAccountId5[1]);
     $account6 = Account::getById($meetingIdAndAccountId6[1]);
     $this->assertNull($account4->latestActivityDateTime);
     $this->assertNull($account5->latestActivityDateTime);
     $this->assertNull($account6->latestActivityDateTime);
     $models = UpdateModelsLatestActivityDateTimeByMeetingJob::getModelsToProcess(20);
     $this->assertEquals(3, count($models));
     $dateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $job = new UpdateModelsLatestActivityDateTimeByMeetingJob();
     $this->assertTrue($job->run());
     $this->assertTrue($meeting4->processedForLatestActivity == true);
     $this->assertTrue($meeting5->processedForLatestActivity == true);
     $this->assertTrue($meeting6->processedForLatestActivity == true);
     $this->assertTrue(!empty($account4->latestActivityDateTime));
     $this->assertTrue(!empty($account5->latestActivityDateTime));
     $this->assertTrue(!empty($account6->latestActivityDateTime));
     $this->assertTrue($account4->latestActivityDateTime < $dateTime);
     $this->assertTrue($account5->latestActivityDateTime < $dateTime);
     $this->assertTrue($account6->latestActivityDateTime < $dateTime);
 }
 public function testCreateWithRelations()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $this->assertTrue($everyoneGroup->save());
     $john = UserTestHelper::createBasicUser('John');
     $john->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $john->setRight('MeetingsModule', MeetingsModule::getAccessRight());
     $john->setRight('MeetingsModule', MeetingsModule::getCreateRight());
     $saved = $john->save();
     $this->assertTrue($saved);
     $contact = ContactTestHelper::createContactByNameForOwner('Simon', $super);
     $contact2 = ContactTestHelper::createContactByNameForOwner('Simona', $john);
     $contactItemId = $contact->getClassId('Item');
     $contact2ItemId = $contact2->getClassId('Item');
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $categories = array('Meeting', 'Call');
     $categoryFieldData = CustomFieldData::getByName('MeetingCategories');
     $categoryFieldData->serializedData = serialize($categories);
     $this->assertTrue($categoryFieldData->save());
     $startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
     $endStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 11000);
     $data['name'] = "Meeting with relations for super user";
     $data['startDateTime'] = $startStamp;
     $data['endDateTime'] = $endStamp;
     $data['category']['value'] = $categories[1];
     $data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact->id, 'modelClassName' => 'Contact')), 'userAttendees' => array(array('action' => 'add', 'modelId' => $john->id, 'modelClassName' => 'User')));
     $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($data['name'], $response['data']['name']);
     $this->assertEquals($data['startDateTime'], $response['data']['startDateTime']);
     $this->assertEquals($data['endDateTime'], $response['data']['endDateTime']);
     RedBeanModel::forgetAll();
     $meeting = Meeting::getById($response['data']['id']);
     $this->assertEquals(1, count($meeting->activityItems));
     $this->assertEquals($contactItemId, $meeting->activityItems[0]->id);
     $this->assertEquals(1, count($meeting->userAttendees));
     $this->assertEquals($john->id, $meeting->userAttendees[0]->id);
     // Now test with regular user
     $authenticationData = $this->login('john', 'john');
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $data = array();
     $data['name'] = "Meeting with relations for regular user";
     $data['startDateTime'] = $startStamp;
     $data['endDateTime'] = $endStamp;
     $data['category']['value'] = $categories[1];
     $data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact2->id, 'modelClassName' => 'Contact')), 'userAttendees' => array(array('action' => 'add', 'modelId' => $super->id, 'modelClassName' => 'User')));
     $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($data['name'], $response['data']['name']);
     $this->assertEquals($data['startDateTime'], $response['data']['startDateTime']);
     $this->assertEquals($data['endDateTime'], $response['data']['endDateTime']);
     RedBeanModel::forgetAll();
     $meeting = Meeting::getById($response['data']['id']);
     $this->assertEquals(1, count($meeting->activityItems));
     $this->assertEquals($contact2ItemId, $meeting->activityItems[0]->id);
     $this->assertEquals(1, count($meeting->userAttendees));
     $this->assertEquals($super->id, $meeting->userAttendees[0]->id);
 }
 public function actionEdit($id, $redirectUrl = null)
 {
     $meeting = Meeting::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($meeting);
     $this->processEdit($meeting, $redirectUrl);
 }
 /**
  * Get all attendees
  * Function get user attendees and attendees from activity items and merge them into one array
  * @param $meetingId
  * @return ApiResult
  * @throws ApiException
  */
 protected static function getMeetingAttendees($meetingId)
 {
     try {
         $meeting = Meeting::getById(intval($meetingId));
         $activityItemAttendees = static::getAttendeesFromActivityItems($meeting);
         $userAttendees = static::getUserAttendees($meeting);
         $organizerAttendee = static::getMeetingOrganizerDetails($meeting);
         $data = array_merge($activityItemAttendees, $userAttendees, $organizerAttendee);
     } catch (Exception $e) {
         $message = $e->getMessage();
         throw new ApiException($message);
     }
     return $data;
 }