コード例 #1
0
 protected function body()
 {
     if (!$this->userHasPrivileges(User::usersPrivPresets)) {
         return false;
     }
     $privilegeGroups = array('users', 'subscriptions', 'plugins', 'assignments', 'submissions', 'lectures', 'groups', 'other');
     $inputs = array_merge(array('name' => array('isAlphaNumeric', 'isNotEmpty')), array_combine($privilegeGroups, array_pad(array(), count($privilegeGroups), array())));
     if (!$this->isInputValid($inputs)) {
         return false;
     }
     $id = $this->getParams('id');
     $name = $this->getParams('name');
     $privileges = array();
     foreach ($privilegeGroups as $i => $group) {
         $value = $this->getParams($group);
         $privileges = array_merge($privileges, $value != '' ? explode(';', $value) : array());
     }
     if (count($privileges)) {
         $privileges = array_combine($privileges, array_pad(array(), count($privileges), true));
     }
     $privileges = User::instance()->packPrivileges($privileges);
     if ($id === null || $id === '') {
         $usertype = new \UserType();
         $usertype->setName($name);
         $usertype->setPrivileges($privileges);
         Repositories::persistAndFlush($usertype);
     } else {
         /** @var \UserType $usertype */
         $usertype = Repositories::findEntity(Repositories::UserType, $id);
         $usertype->setName($name);
         $usertype->setPrivileges($privileges);
         Repositories::persistAndFlush($usertype);
     }
     return true;
 }
コード例 #2
0
 protected function body()
 {
     if (!$this->isInputValid(array('id' => 'isIndex'))) {
         return false;
     }
     $id = $this->getParams('id');
     /** @var \XTest $test */
     $test = Repositories::findEntity(Repositories::Xtest, $id);
     if (!$this->checkTestGenerationPrivileges($test->getLecture()->getId())) {
         return false;
     }
     $randomized = $this->generateTest($test->getTemplate(), $test->getCount());
     $test->setGenerated(implode(',', $randomized));
     Repositories::persistAndFlush($test);
     return true;
 }
コード例 #3
0
 protected function handleRequest(\Subscription $subscriptionRequest)
 {
     $subscriptionRequest->setStatus(\Subscription::STATUS_SUBSCRIBED);
     Repositories::persistAndFlush($subscriptionRequest);
 }