Example #1
0
 public function createAction()
 {
     $data = $this->getGroupData($_POST);
     if (empty($data)) {
         $this->_redirect("/admin/group/new");
     }
     $table = new USVN_Db_Table_Groups();
     $group = $table->createRow($data);
     $this->view->group = $group;
     if ($table->isAGroup($data['groups_name'])) {
         $this->view->message = sprintf(T_("Group %s already exist"), $data['groups_name']);
         $this->render('new');
         return;
     }
     try {
         $group->save();
         foreach ($_POST['users'] as $user) {
             $group->addUser($user);
         }
         $this->_redirect("/admin/group/");
     } catch (USVN_Exception $e) {
         $this->view->message = $e->getMessage();
         $table = new USVN_Db_Table_Users();
         $this->view->users = $table->fetchAll(null, "users_login");
         $this->render('new');
     }
 }
Example #2
0
 public function testUpdateOnlyDesc()
 {
     $table = new USVN_Db_Table_Groups();
     $obj = $table->fetchNew();
     $obj->setFromArray(array('groups_name' => 'UpdateGroupOk'));
     $id = $obj->save();
     $this->assertTrue($table->isAGroup('UpdateGroupOk'));
     $obj = $table->find($id)->current();
     $obj->setFromArray(array('groups_description' => 'test'));
     $id = $obj->save();
     $this->assertTrue($table->isAGroup('UpdateGroupOk'));
 }
Example #3
0
 public function testDeleteProject()
 {
     USVN_Project::createProject(array('projects_name' => 'InsertProjectOK', 'projects_start_date' => '1984-12-03 00:00:00'), "test", true, true, true, false);
     USVN_Project::deleteProject('InsertProjectOK');
     $table = new USVN_Db_Table_Projects();
     $this->assertFalse($table->isAProject('InsertProjectOk'), "Le projet n'est pas supprime");
     $table_groups = new USVN_Db_Table_Groups();
     $this->assertFalse($table_groups->isAGroup('InsertProjectOk'), "Le groupe n'est pas supprime");
 }