예제 #1
0
 /**
  * @Route("/insert", name="project_territory_insert")
  */
 public function insertAction(Request $request)
 {
     $entity = new Territory();
     $entity->setProject($this->getActiveProject());
     $action = new InsertAction($this->crudInfo, $entity, ProjectTerritoryForm::class);
     $action->slug($this->getSlug());
     return $action->run($this, $request);
 }
예제 #2
0
 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);
 }
예제 #3
0
 public static function fetchByProject(Connection $conn, $id, Project $project)
 {
     $data = $conn->fetchAssoc('SELECT r.*, v.id AS `verifier_id`, v.`name` AS `verifier_name`, ' . 't.`id` AS `territory_id`, t.`name` AS `territory_name`, t.`areaNum` AS `territory_areaNum`, t.`requestNum` as `territory_requestNum` ' . 'FROM `' . CoreTables::AREA_REQUEST_TBL . '` r ' . 'INNER JOIN `' . CoreTables::TERRITORY_TBL . '` t ON t.`id` = r.`territoryId` ' . 'LEFT JOIN `' . CoreTables::USER_TBL . '` v ON v.`id` = r.`verifierId` ' . 'WHERE r.`id` = :id AND r.`projectId` = :projectId', [':id' => $id, ':projectId' => $project->getId()]);
     if (null === $data) {
         return false;
     }
     $user = User::fetchByCriteria($conn, QueryClause::clause('u.`id` = :id', ':id', $data['requestorId']));
     $item = self::fromArray($data);
     $item->setProject($project);
     $item->setRequestor($user);
     if (!empty($data['verifier_id'])) {
         $item->verifier = new Verifier($data['verifier_id'], $data['verifier_name']);
     }
     $item->setTerritory($item->oldTerritory = Territory::fromArray($data, 'territory'));
     return $item;
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }
예제 #6
0
파일: Area.php 프로젝트: zyxist/cantiga
 /**
  * @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']);
 }
예제 #7
0
 public function remove(Territory $item)
 {
     $this->transaction->requestTransaction();
     try {
         return $item->remove($this->conn);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }