/** * @return AreaStatus */ public function getItem($id) { $this->transaction->requestTransaction(); $item = AreaStatus::fetchByProject($this->conn, $id, $this->project); if (false === $item) { $this->transaction->requestRollback(); throw new ItemNotFoundException('The specified item has not been found.', $id); } return $item; }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
public static function fetchById(Connection $conn, $id) { $data = $conn->fetchAssoc('SELECT * FROM `' . ExportTables::DATA_EXPORT_TBL . '` WHERE `id` = :id', [':id' => $id]); if (false === $data) { return false; } $item = self::fromArray($data); $item->project = Project::fetch($conn, $data['projectId']); $item->areaStatus = AreaStatus::fetchByProject($conn, $data['areaStatusId'], $item->project); return $item; }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->area2 = Area::newArea($this->project, $this->territory, $this->status, 'Area2'); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->user2 = User::newUser('login2', 'Another user', $lang); $this->user2->insert(self::$conn); $tpa1 = new CourseProgress($this->area); $tpa1->insert(self::$conn); }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->course = new Course(); $this->course->setProject($this->project); $this->course->setName('Foo'); $this->course->setAuthorName('Foo'); $this->course->setAuthorEmail('*****@*****.**'); $this->course->setPresentationLink('http://www.example.com/'); $this->course->setIsPublished(true); $this->course->insert(self::$conn); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->anotherUser = User::newUser('login2', 'Another user', $lang); $this->anotherUser->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
/** * @param Connection $conn * @param int $projectId * @param int $userId * @return Membership */ public static function fetchMembership(Connection $conn, MembershipRoleResolver $resolver, $slug, $userId) { $data = $conn->fetchAssoc('SELECT a.*, ' . 't.`id` AS `territory_id`, t.`name` AS `territory_name`, t.`areaNum` AS `territory_areaNum`, t.`requestNum` as `territory_requestNum`, ' . 'm.`role` AS `membership_role`, m.`note` AS `membership_note`, ' . self::createEntityFieldList() . 'FROM `' . CoreTables::AREA_TBL . '` a ' . self::createEntityJoin('a') . 'INNER JOIN `' . CoreTables::TERRITORY_TBL . '` t ON t.`id` = a.`territoryId` ' . 'INNER JOIN `' . CoreTables::AREA_MEMBER_TBL . '` m ON m.`areaId` = a.`id` WHERE m.`userId` = :userId AND a.`slug` = :slug', [':userId' => $userId, ':slug' => $slug]); if (false === $data) { return false; } $item = self::fromArray($data); $item->project = Project::fetchActive($conn, $data['projectId']); if (false == $item->project) { return false; } $item->status = $item->oldStatus = AreaStatus::fetchByProject($conn, $data['statusId'], $item->project); if (!empty($data['groupId'])) { $item->group = $item->oldGroup = Group::fetchByProject($conn, $data['groupId'], $item->project); } $item->setTerritory($item->oldTerritory = Territory::fromArray($data, 'territory')); $role = $resolver->getRole('Area', $data['membership_role']); $item->entity = Entity::fromArray($data, 'entity'); return new Membership($item, $role, $data['membership_note']); }