function testRegistrationIsOpen()
 {
     $project = new Project();
     $cdata = new DateTime();
     $project->registrationFrom = date('Y-m-d', time() - 3600 * 24);
     $project->registrationTo = date('Y-m-d', time() + 3600 * 24);
     $this->assertEquals(true, $project->isRegistrationOpen());
     $project->registrationFrom = date('Y-m-d', time() - 3600);
     $project->registrationTo = date('Y-m-d', time() + 3600);
     $this->assertEquals(true, $project->isRegistrationOpen());
     $project->registrationFrom = date('Y-m-d', time() + 3600 * 24);
     $project->registrationTo = date('Y-m-d', time() + 3600 * 48);
     $this->assertEquals(false, $project->isRegistrationOpen());
 }
 protected function canUserSend($user)
 {
     if ($user->is('guest')) {
         return false;
     }
     if (!$this->project->isRegistrationOpen()) {
         return false;
     }
     if ($this->getSendValidationErrors()) {
         return false;
     }
     if ($user->is('admin')) {
         return true;
     }
     return $this->canUser('@control');
 }
 function testRegistrationIsOpen()
 {
     $project = new Project();
     $project->registrationFrom = date('Y-m-d', time() + 3600 * 24);
     $project->registrationTo = date('Y-m-d H:i', time() + 3600 * 48);
     $this->assertFalse($project->isRegistrationOpen(), 'isRegistrationOpen() de um projeto no com datas no futuro deve ser false');
     $project->registrationFrom = date('Y-m-d', time() - 3600 * 48);
     $project->registrationTo = date('Y-m-d H:i', time() - 3600 * 24);
     $this->assertFalse($project->isRegistrationOpen(), 'isRegistrationOpen() de um projeto no com datas no passado deve ser false');
     $project->registrationFrom = date('Y-m-d', time() - 3600 * 48);
     $project->registrationTo = date('Y-m-d H:i', time() - 3600);
     $this->assertFalse($project->isRegistrationOpen(), 'isRegistrationOpen() de um projeto no com datas no passado deve ser false');
     $project->registrationFrom = date('Y-m-d', time() - 3600 * 48);
     $project->registrationTo = date('Y-m-d H:i', time() + 3600 * 48);
     $this->assertTrue($project->isRegistrationOpen(), 'isRegistrationOpen() de um projeto com data inicial no passado e data final no futuro deve ser true');
     $project->registrationFrom = date('Y-m-d', time() - 3600 * 48);
     $project->registrationTo = date('Y-m-d H:i', time() + 3600);
     $this->assertTrue($project->isRegistrationOpen(), 'isRegistrationOpen() de um projeto com data inicial no passado e data final no futuro deve ser true');
 }
 protected function _canUser($user)
 {
     return $this->owner->canUser('modifyRegistrationFields', $user);
 }
 protected function canUserView($user)
 {
     if ($this->status === self::STATUS_ENABLED) {
         return true;
     } else {
         if ($this->status === self::STATUS_DRAFT) {
             return $this->canUser('@control', $user) || $this->project && $this->project->canUser('@control', $user);
         }
     }
     return false;
 }
Exemple #6
0
 function addProjectToJs(Entities\Project $entity)
 {
     $this->jsObject['entity']['useRegistrations'] = $entity->useRegistrations;
     $this->jsObject['entity']['registrationFileConfigurations'] = $entity->registrationFileConfigurations ? $entity->registrationFileConfigurations->toArray() : array();
     usort($this->jsObject['entity']['registrationFileConfigurations'], function ($a, $b) {
         if ($a->title > $b->title) {
             return 1;
         } else {
             if ($a->title < $b->title) {
             } else {
                 return 0;
             }
         }
     });
     $this->jsObject['entity']['registrationCategories'] = $entity->registrationCategories;
     $this->jsObject['entity']['published'] = $entity->publishedRegistrations;
     $this->jsObject['entity']['registrations'] = $entity->sentRegistrations ? $entity->sentRegistrations : array();
     $this->jsObject['entity']['registrationRulesFile'] = $entity->getFile('rules');
     $this->jsObject['entity']['canUserModifyRegistrationFields'] = $entity->canUser('modifyRegistrationFields');
     $this->jsObject['projectRegistrationsEnabled'] = App::i()->config['app.enableProjectRegistration'];
 }
 protected function validateProject()
 {
     if ($this->project && $this->_projectChanged) {
         return $this->project->canUser('modify');
     } else {
         return true;
     }
 }
 function canUser($action, $userOrAgent = null)
 {
     return $this->owner->canUser($action, $userOrAgent);
 }