Exemplo n.º 1
0
 public function testCreateAndGetSavedCalendarById()
 {
     $calendar = CalendarTestHelper::createSavedCalendarByName('My first calendar', '#ccccc');
     $id = $calendar->id;
     $calendar->forget();
     unset($calendar);
     $calendar = SavedCalendar::getById($id);
     $this->assertEquals('My first calendar', $calendar->name);
     $this->assertEquals('America/Chicago', $calendar->timeZone);
     $this->assertEquals('Newyork', $calendar->location);
     $this->assertEquals('ProductsModule', $calendar->moduleClassName);
     $this->assertEquals('createdDateTime', $calendar->startAttributeName);
     $this->assertEquals('#ccccc', $calendar->color);
 }
 /**
  * Get calendar name.
  * @param array $data
  * @return string
  */
 public static function getCalendarName($data)
 {
     $calId = $data['calendarId'];
     $savedCalendar = SavedCalendar::getById($calId);
     return strval($savedCalendar);
 }
 /**
  * Add subscription for calendar.
  * @param int $id
  */
 public function actionAddSubsriptionForCalendar($id)
 {
     $savedCalendar = SavedCalendar::getById(intval($id));
     $user = Yii::app()->user->userModel;
     $savedCalendarSubscription = new SavedCalendarSubscription();
     $savedCalendarSubscription->user = $user;
     $savedCalendarSubscription->savedcalendar = $savedCalendar;
     $savedCalendarSubscription->save();
     $dataProvider = CalendarUtil::getCalendarItemsDataProvider($user);
     $savedCalendarSubscriptions = $dataProvider->getSavedCalendarSubscriptions();
     $content = CalendarUtil::makeCalendarItemsList($savedCalendarSubscriptions->getSubscribedToSavedCalendarsAndSelected(), 'sharedcalendar[]', 'sharedcalendar', 'shared');
     echo $content;
 }
Exemplo n.º 4
0
 /**
  * Resolve report by saved calendar post data.
  * @param string $type
  * @param int $id
  * @param array $postData
  * @return Report
  */
 public static function resolveReportBySavedCalendarPostData($type, $id = null, $postData)
 {
     assert('is_string($type)');
     assert('is_array($postData)');
     if ($id == null) {
         $report = new Report();
         $report->setType($type);
     } else {
         $savedCalendar = SavedCalendar::getById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedCalendar);
         $report = SavedCalendarToReportAdapter::makeReportBySavedCalendar($savedCalendar);
     }
     if (isset($postData['SavedCalendar']) && isset($postData['SavedCalendar']['moduleClassName'])) {
         $report->setModuleClassName($postData['SavedCalendar']['moduleClassName']);
     } else {
         throw new NotSupportedException();
     }
     DataToReportUtil::resolveReportByWizardPostData($report, $postData, ReportToWizardFormAdapter::getFormClassNameByType($type));
     return $report;
 }
 public function testSuperUserDeleteAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Yii::app()->user->userModel = $super;
     $calendar = CalendarTestHelper::createSavedCalendarByName("My Cal 3", '#66367b');
     //Delete a calendar
     $this->setGetArray(array('id' => $calendar->id));
     $this->resetPostArray();
     $calendars = SavedCalendar::getAll();
     $this->assertEquals(4, count($calendars));
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/delete');
     $calendars = SavedCalendar::getAll();
     $this->assertEquals(3, count($calendars));
     try {
         SavedCalendar::getById($calendar->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
 }