public function PageLoad() { if ($this->page->GetGroupId() != null) { $groupList = $this->groupRepository->GetList(1, 1, null, null, new SqlFilterEquals(new SqlFilterColumn(TableNames::GROUPS_ALIAS, ColumnNames::GROUP_ID), $this->page->GetGroupId())); } else { $groupList = $this->groupRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize()); } $this->page->BindGroups($groupList->Results()); $this->page->BindPageInfo($groupList->PageInfo()); $this->page->BindResources($this->resourceRepository->GetResourceList()); $this->page->BindRoles(array(new RoleDto(1, 'Group Admin', RoleLevel::GROUP_ADMIN), new RoleDto(2, 'Application Admin', RoleLevel::APPLICATION_ADMIN), new RoleDto(3, 'Resource Admin', RoleLevel::RESOURCE_ADMIN), new RoleDto(4, 'Schedule Admin', RoleLevel::SCHEDULE_ADMIN))); $this->page->BindAdminGroups($this->groupRepository->GetGroupsByRole(RoleLevel::GROUP_ADMIN)); }
public function PageLoad() { if ($this->page->GetUserId() != null) { $userList = $this->userRepository->GetList(1, 1, null, null, new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId())); } else { $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, null, $this->page->GetFilterStatusId()); } $this->page->BindUsers($userList->Results()); $this->page->BindPageInfo($userList->PageInfo()); $groups = $this->groupViewRepository->GetList(); $this->page->BindGroups($groups->Results()); $resources = array(); $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId); $allResources = $this->resourceRepository->GetResourceList(); foreach ($allResources as $resource) { if ($user->IsResourceAdminFor($resource)) { $resources[] = $resource; } } $this->page->BindResources($resources); $userIds = array(); /** @var $user UserItemView */ foreach ($userList->Results() as $user) { $userIds[] = $user->Id; } $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::USER, $userIds); $this->page->BindAttributeList($attributeList); }
public function testGetsGroupsWithPermission() { $resourceId = 123; $rows = array(array(ColumnNames::GROUP_ID => 1, ColumnNames::GROUP_NAME => 'g1'), array(ColumnNames::GROUP_ID => 2, ColumnNames::GROUP_NAME => 'g2')); $this->db->SetRows($rows); $list = $this->repository->GetGroupsWithPermission($resourceId); $this->assertTrue($this->db->ContainsCommand(new GetResourceGroupPermissionCommand($resourceId))); $this->assertEquals(2, $list->PageInfo()->Total); }
/** * @param SchedulePeriod $begin * @param SchedulePeriod $end * @param Date $displayDate * @param int $periodSpan * @param ReservationItemView $reservation */ public function __construct(SchedulePeriod $begin, SchedulePeriod $end, Date $displayDate, $periodSpan, ReservationItemView $reservation) { $this->_reservation = $reservation; $this->_begin = $begin->BeginDate(); $this->_displayDate = $displayDate; $this->_end = $end->EndDate(); $this->_periodSpan = $periodSpan; $this->_participantNumber = count($reservation->ParticipantIds); $this->_participantNames = $reservation->ParticipantNames; $this->_inviteeNames = $reservation->InviteeNames; $this->_beginSlotId = $begin->Id(); $this->_endSlotId = $end->Id(); $resourceId = $this->_reservation->GetResourceId(); $resourceRepo = new ResourceRepository(); $resource = $resourceRepo->LoadById($resourceId); $this->_maxparticipants = $resource->GetMaxParticipants(); $this->_beginPeriod = $begin; $this->_endPeriod = $end; }
/** * @param User $user * @return BookableResource[] */ private function GetResourcesThatCurrentUserCanAdminister($user) { $resources = array(); $allResources = $this->resourceRepository->GetResourceList(); foreach ($allResources as $resource) { if ($user->IsResourceAdminFor($resource)) { $resources[] = $resource; } } return $resources; }
private function MigrateResources(Database $legacyDatabase, Database $currentDatabase) { $resourcesMigrated = MigrationSession::GetLastResourceRow(); Log::Debug('Start migrating resources. Starting at row %s', $resourcesMigrated); $resourceRepo = new ResourceRepository(); $getExisting = new AdHocCommand('select legacyid from resources'); $reader = $currentDatabase->Query($getExisting); $knownIds = array(); while ($row = $reader->GetRow()) { $knownIds[] = $row['legacyid']; } $getResources = new AdHocCommand("select machid, scheduleid, name, location, rphone, notes, status, minres, maxres, autoassign, approval,\n allow_multi, max_participants, min_notice_time, max_notice_time\n from resources order by machid limit {$resourcesMigrated}, 500"); $reader = $legacyDatabase->Query($getResources); while ($row = $reader->GetRow()) { $legacyResourceId = $row['machid']; if (in_array($legacyResourceId, $knownIds)) { continue; } $newScheduleReader = $currentDatabase->Query(new AdHocCommand("select schedule_id from schedules where legacyId = \"{$row['scheduleid']}\"")); if ($srow = $newScheduleReader->GetRow()) { $newScheduleId = $srow['schedule_id']; } $minTimeSeconds = $row['minres'] * 60; $maxTimeSeconds = $row['maxres'] * 60; $min_notice_time = $row['min_notice_time'] * 60; $max_notice_time = $row['max_notice_time'] * 60; $newId = $resourceRepo->Add(new BookableResource(null, $row['name'], $row['location'], $row['rphone'], $row['notes'], $minTimeSeconds, $maxTimeSeconds, $row['autoassign'], $row['approval'], $row['allow_multi'], $row['max_participants'], $min_notice_time, $max_notice_time, null, $newScheduleId)); $currentDatabase->Execute(new AdHocCommand("update resources set legacyid = \"{$row['machid']}\" where resource_id = {$newId}")); $resourcesMigrated++; MigrationSession::SetLastResourceRow($resourcesMigrated); } Log::Debug('Done migrating resources (%s resources)', $resourcesMigrated); $getLegacyCount = new AdHocCommand('select count(*) as count from resources'); $getMigratedCount = new AdHocCommand('select count(*) as count from resources where legacyid is not null'); $progressCounts = $this->GetProgressCounts($getLegacyCount, $getMigratedCount); $this->page->SetProgress($progressCounts); $this->page->SetResourcesMigrated($progressCounts->MigratedCount); MigrationSession::SetLastResourceRow($progressCounts->MigratedCount); }
Booked Scheduler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>. */ define('ROOT_DIR', dirname(__FILE__) . '/../'); require_once ROOT_DIR . "lib/Email/namespace.php"; require_once ROOT_DIR . "lib/Email/Messages/ReservationCreatedEmail.php"; require_once ROOT_DIR . "lib/Email/Messages/ReservationUpdatedEmail.php"; require_once ROOT_DIR . "Domain/namespace.php"; require_once ROOT_DIR . "tests/fakes/namespace.php"; $start = Date::Parse('2010-10-05 03:30:00', 'UTC'); $end = Date::Parse('2010-10-06 13:30:00', 'UTC'); $resourceRepo = new ResourceRepository(); $resources = $resourceRepo->GetResourceList(); $builder = new ExistingReservationSeriesBuilder(); $builder->WithPrimaryResource($resources[1]); $reservation = $builder->Build(); //$reservation->WithCurrentInstance(new TestReservation("ref", new TestDateRange())); //$reservation->Update(1, new FakeBookableResource(1, 'name'), 'crazy title', 'super description', new FakeUserSession()); //$reservation->UpdateDuration(new DateRange($start, $end)); $reservation->Repeats(new RepeatDayOfMonth(1, $end->AddDays(100), new DateRange($start, $end))); $user = new FakeUser(); //$user->SetLanguage('en_gb'); $email = new ReservationUpdatedEmail($user, $reservation, 'en_us', new AttributeRepository()); echo $email->Body(); //$emailService = new EmailService(); //$emailService->Send($email);
public function PageLoad() { $resourceId = $this->page->GetResourceId(); $resource = $this->resourceRepository->LoadById($resourceId); $this->page->BindResource($resource); $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, $resourceId); $this->page->BindAttributes($attributeList->GetAttributes($resourceId)); if ($resource->HasResourceType()) { $resourceType = $this->resourceRepository->LoadResourceType($resource->GetResourceTypeId()); $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE_TYPE, $resource->GetResourceTypeId()); $this->page->BindResourceType($resourceType, $attributeList->GetAttributes($resource->GetResourceTypeId())); } }
header('HTTP/1.1 406 Not Acceptable', true, 406); print json_encode(array('message' => "{$key} has to be set")); return; } } $rn = $params['rn']; $userRepo = new UserRepository(); $user = $userRepo->LoadByUsername($params['username']); if ($user instanceof NullUser) { header('HTTP/1.1 403 Forbidden', true, 403); print json_encode(array('message' => "invalid userId")); return; } $user_session = new UserSession($user->Id()); // load resource by contact_info or rid $resourceRepository = new ResourceRepository(); $contact_info = trim($_REQUEST['contact_info']); $rid = trim($_REQUEST['rid']); if ($contact_info && $rid) { header('HTTP/1.1 406 Not Acceptable', true, 406); print json_encode(array('message' => "You must not set both contact_info and rid")); return; } if ($contact_info) { $resource = $resourceRepository->LoadByContactInfo($contact_info); } elseif ($rid) { $resource = $resourceRepository->LoadByPublicId($rid); } $updateAction = ReservationAction::Update; $persistenceFactory = new ReservationPersistenceFactory(); $persistenceService = $persistenceFactory->Create($updateAction);
public function GetScheduleResources($scheduleId) { $resources = parent::GetScheduleResources($scheduleId); return $this->GetFilteredResources($resources); }
$numberOfAccessories = 20; $users = array(); $resources = array(); $db = ServiceLocator::GetDatabase(); // USERS $db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'")); $userRepo = new UserRepository(); for ($i = 0; $i < $numberOfUsers; $i++) { $user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b"); $userId = $userRepo->Add($user); $users[] = $user; } echo "Loaded {$numberOfUsers} users<br/>"; // RESOURCES $db->Execute(new AdHocCommand("delete from resources where name like 'load%'")); $resourceRepo = new ResourceRepository(); for ($i = 0; $i < $numberOfResources; $i++) { $resource = BookableResource::CreateNew("load{$i}", 1); $resourceId = $resourceRepo->Add($resource); $resources[] = $resource; } echo "Loaded {$numberOfResources} resources<br/>"; // ACCESSORIES $db->Execute(new AdHocCommand("delete from accessories where accessory_name like 'load%'")); $accessoryRepo = new AccessoryRepository(); for ($i = 0; $i < $numberOfAccessories; $i++) { $accessory = new Accessory(0, "Load {$i}", 10); $id = $accessoryRepo->Add($accessory); } echo "Loaded {$numberOfAccessories} accessories<br/>"; // RESERVATIONS