Exemple #1
0
 private function _GetAllRows()
 {
     $rows = $this->GetRows();
     $expected = array();
     foreach ($rows as $item) {
         $schedule = new Schedule($item[ColumnNames::SCHEDULE_ID], $item[ColumnNames::SCHEDULE_NAME], $item[ColumnNames::SCHEDULE_DEFAULT], $item[ColumnNames::SCHEDULE_WEEKDAY_START], $item[ColumnNames::SCHEDULE_DAYS_VISIBLE], $item[ColumnNames::TIMEZONE_NAME]);
         $schedule->SetAdminGroupId($item[ColumnNames::SCHEDULE_ADMIN_GROUP_ID]);
         $expected[] = $schedule;
     }
     return $expected;
 }
 public function Add(Schedule $schedule, $copyLayoutFromScheduleId)
 {
     $user = $this->repo->LoadById($this->user->UserId);
     if (!$user->IsInRole(RoleLevel::SCHEDULE_ADMIN)) {
         throw new Exception(sprintf('Schedule Add Failed. User %s does not have admin access.', $this->user->UserId));
     }
     foreach ($user->Groups() as $group) {
         if ($group->IsScheduleAdmin) {
             $schedule->SetAdminGroupId($group->GroupId);
             break;
         }
     }
     parent::Add($schedule, $copyLayoutFromScheduleId);
 }
Exemple #3
0
 /**
  * @static
  * @param array $row
  * @return Schedule
  */
 public static function FromRow($row)
 {
     $schedule = new Schedule($row[ColumnNames::SCHEDULE_ID], $row[ColumnNames::SCHEDULE_NAME], $row[ColumnNames::SCHEDULE_DEFAULT], $row[ColumnNames::SCHEDULE_WEEKDAY_START], $row[ColumnNames::SCHEDULE_DAYS_VISIBLE], $row[ColumnNames::TIMEZONE_NAME], $row[ColumnNames::LAYOUT_ID]);
     $schedule->WithSubscription($row[ColumnNames::ALLOW_CALENDAR_SUBSCRIPTION]);
     $schedule->WithPublicId($row[ColumnNames::PUBLIC_ID]);
     $schedule->SetAdminGroupId($row[ColumnNames::SCHEDULE_ADMIN_GROUP_ID]);
     return $schedule;
 }
 public function testCanUpdateSchedule()
 {
     $id = 10;
     $name = 'super schedule';
     $isDefault = 0;
     $weekdayStart = 5;
     $daysVisible = 3;
     $subscriptionEnabled = true;
     $adminGroupId = 123;
     $schedule = new Schedule($id, $name, $isDefault, $weekdayStart, $daysVisible);
     $schedule->EnableSubscription();
     $publicId = $schedule->GetPublicId();
     $schedule->SetAdminGroupId($adminGroupId);
     $this->scheduleRepository->Update($schedule);
     $this->assertEquals(new UpdateScheduleCommand($id, $name, $isDefault, $weekdayStart, $daysVisible, $subscriptionEnabled, $publicId, $adminGroupId), $this->db->_LastCommand);
 }