protected function body() { if (!$this->userHasPrivileges(User::groupsJoinPublic, User::groupsJoinPrivate, User::groupsRequest)) { return false; } $user = User::instance(); $displayPublic = $user->hasPrivileges(User::groupsJoinPublic); $displayPrivate = $user->hasPrivileges(User::groupsJoinPrivate, User::groupsRequest); /** * @var $groups \Group[] * @var $subscriptions \Subscription[] */ $subscriptions = Repositories::getRepository(Repositories::Subscription)->findBy(array('user' => $user->getId())); $subscriptionGroupIds = array_map(function ($subscription) { /** @var $subscription \Subscription */ return $subscription->getGroup()->getId(); }, $subscriptions); $conditions = array('deleted' => false); if (!$displayPrivate) { $conditions['type'] = 'public'; } if (!$displayPublic) { $conditions['type'] = 'private'; } $groups = Repositories::getRepository(Repositories::Group)->findBy($conditions); foreach ($groups as $group) { if (in_array($group->getId(), $subscriptionGroupIds)) { continue; } $row = array($group->getId(), $group->getName(), $group->getDescription(), $group->getType(), $group->getLecture()->getId(), $group->getLecture()->getName(), $group->getLecture()->getDescription()); $this->addRowToOutput($row); } return true; }
/** * Returns an array of all tests that can be viewed, edited and deleted by the logged-in user. * * @return \Xtest[] tests that can be edited by the active user */ public static function GetTestsVisibleToUser() { $repository = Repositories::getRepository(Repositories::Xtest); if (User::instance()->hasPrivileges(User::lecturesManageAll)) { return $repository->findAll(); } else { return Repositories::getEntityManager()->createQuery("SELECT x FROM \\Xtest x JOIN x.lecture l WHERE l.owner = :ownerId")->setParameter('ownerId', User::instance()->getId())->getResult(); } }
protected function body() { if (!$this->userHasPrivileges(User::pluginsExplore, User::lecturesManageOwn, User::lecturesManageAll)) { return false; } /** @var \Plugin[] $plugins */ $plugins = Repositories::getRepository(Repositories::Plugin)->findAll(); foreach ($plugins as $plugin) { $this->addRowToOutput([$plugin->getId(), $plugin->getName(), $plugin->getType(), $plugin->getDescription(), $plugin->getConfig()]); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::groupsJoinPublic, User::groupsJoinPrivate, User::groupsRequest)) { return false; } $subscriptions = Repositories::getRepository(Repositories::Subscription)->findBy(['user' => User::instance()->getId()]); foreach ($subscriptions as $subscription) { /** * @var $subscription \Subscription */ $this->addRowToOutput([$subscription->getId(), $subscription->getGroup()->getName(), $subscription->getGroup()->getDescription(), $subscription->getGroup()->getLecture()->getName(), $subscription->getGroup()->getLecture()->getDescription(), $subscription->getStatus()]); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::usersAdd, User::usersManage, User::usersPrivPresets)) { return false; } $userTypes = Repositories::getRepository(Repositories::UserType)->findAll(); /** * @var $userTypes \UserType[] */ foreach ($userTypes as $userType) { $this->addRowToOutput([$userType->getId(), $userType->getName(), User::instance()->unpackPrivileges($userType->getPrivileges())]); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::pluginsTest)) { return false; } /** * @var $tests \PluginTest[] */ $tests = Repositories::getRepository(Repositories::PluginTest)->findAll(); foreach ($tests as $test) { $this->addRowToOutput([$test->getId(), $test->getDescription(), $test->getPlugin()->getName(), $test->getPlugin()->getDescription(), $test->getPlugin()->getConfig(), $test->getConfig(), $test->getStatus(), $test->getSuccess(), $test->getInfo(), $test->getOutput() ? "yes" : ""]); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::usersExplore)) { return; } /** * @var $users \User[] */ $users = Repositories::getRepository(Repositories::User)->findAll(); foreach ($users as $user) { if ($user->getDeleted() == true) { continue; } $this->addRowToOutput([$user->getId(), $user->getName(), $user->getType()->getId(), $user->getType()->getName(), $user->getRealName(), $user->getEmail(), $user->getLastAccess()->format("Y-m-d H:i:s")]); } }
protected function body() { if (!$this->userHasPrivileges(User::assignmentsSubmit)) { return; } /** * @var $submissions \Submission[] */ $submissions = Repositories::getRepository(Repositories::Submission)->findBy(['user' => User::instance()->getId()]); foreach ($submissions as $submission) { if ($submission->getStatus() == \Submission::STATUS_DELETED) { continue; } $row = [$submission->getId(), $submission->getAssignment()->getProblem()->getName(), $submission->getAssignment()->getDeadline()->format("Y-m-d H:i:s"), $submission->getDate()->format("Y-m-d H:i:s"), $submission->getStatus(), $submission->getSuccess(), $submission->getInfo(), $submission->getRating(), $submission->getExplanation(), $submission->getOutputfile() != '']; $this->addRowToOutput($row); } }
protected function body() { if (!$this->userHasPrivileges(User::groupsAdd, User::groupsManageAll, User::groupsManageOwn)) { return false; } $user = User::instance(); $displayAll = $user->hasPrivileges(User::groupsManageAll); $groups = $displayAll ? Repositories::getRepository(Repositories::Group)->findBy(array('deleted' => false)) : Repositories::getRepository(Repositories::Group)->findBy(array('deleted' => false, 'owner' => $user->getId())); /** * @var $group \Group */ foreach ($groups as $group) { $row = array($group->getId(), $group->getName(), $group->getDescription(), $group->getType(), $group->getLecture()->getId(), $group->getLecture()->getName(), $group->getLecture()->getDescription()); $this->addRowToOutput($row); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::groupsManageAll, User::groupsManageOwn)) { return false; } /** * @var $assignments \Assignment[] */ if (User::instance()->hasPrivileges(User::groupsManageAll)) { $assignments = Repositories::getRepository(Repositories::Assignment)->findBy(['deleted' => false]); } else { $assignments = Repositories::getEntityManager()->createQuery('SELECT a, g FROM \\Assignment a JOIN a.group g WHERE a.deleted = false AND g.owner = :ownerId')->setParameter('ownerId', User::instance()->getId())->getResult(); } foreach ($assignments as $assignment) { $row = array($assignment->getId(), $assignment->getProblem()->getId(), $assignment->getProblem()->getName(), $assignment->getDeadline()->format('Y-m-d H:i:s'), $assignment->getReward(), $assignment->getGroup()->getId(), $assignment->getGroup()->getName(), $assignment->getGroup()->getOwner()->getId()); $this->addRowToOutput($row); } return true; }
protected function body() { if (!$this->userHasPrivileges(User::lecturesAdd, User::lecturesManageAll, User::lecturesManageOwn, User::groupsAdd)) { return; } $lite = $this->getParams('lite'); $user = User::instance(); $displayAll = $user->hasPrivileges(User::lecturesManageAll) || $lite; /** * @var $lectures \Lecture[] */ $lectures = $displayAll ? Repositories::getRepository('Lecture')->findBy(array('deleted' => false)) : Repositories::getRepository('Lecture')->findBy(array('owner' => $user->getId(), 'deleted' => false)); foreach ($lectures as $lecture) { $row = array($lecture->getId(), $lecture->getName()); if (!$lite) { $row[] = $lecture->getDescription(); } $this->addRowToOutput($row); } }
protected function body() { if (!$this->isInputSet(array('name', 'table'))) { return false; } $table = $this->getParams('table'); $name = strtolower($this->getParams('name')); $columnName = "name"; switch ($table) { case 'groups': $repositoryName = Repositories::Group; break; case 'lectures': $repositoryName = Repositories::Lecture; break; case 'plugins': $repositoryName = Repositories::Plugin; break; case 'problems': $repositoryName = Repositories::Problem; break; case 'users': $repositoryName = Repositories::User; break; case 'usertypes': $repositoryName = Repositories::UserType; break; default: return $this->stop('name duplicity check cannot be performed on table' . $table); } $repository = Repositories::getRepository($repositoryName); $results = $repository->findBy([$columnName => $name]); $nameConflict = count($results) > 0; if ($table == 'groups' || $table == 'lectures' || $table == 'problems') { $nameConflict = false; // For these three, we now allow duplicate names. } $this->addOutput('nameTaken', $nameConflict); return true; }