예제 #1
0
 private function get_created_group()
 {
     $groups = new USVN_Db_Table_Groups();
     return $groups->fetchRow(array('groups_name = ?' => 'Test'));
 }
예제 #2
0
 public function addleadergroupAction()
 {
     if ($this->_group->isLeaderOrAdmin($this->view->user) == 1) {
         $request = $this->getRequest();
         /* @var $request USVN_Controller_Request_Http */
         $table = new USVN_Db_Table_Groups();
         $group = $table->fetchRow(array("groups_name = ?" => str_replace(USVN_URL_SEP, '/', $request->getParam('group'))));
         /* @var $group USVN_Db_Table_Row_Group */
         try {
             $table = new USVN_Db_Table_Users();
             if ($request->getParam('ap', "") != "") {
                 $user = $table->fetchRow(array("users_login = ?" => $request->getParam('ap')));
                 if ($user === null) {
                     throw new USVN_Exception(sprintf(T_("Unknown user %s"), $request->getParam('ap')));
                 }
                 if (!$group->hasUser($user)) {
                     $group->addUser($user, true);
                 } else {
                     $group->updateLeaderUser($user, 1);
                 }
             }
             if ($request->getParam('deleteid', 0) != 0) {
                 $user = $table->fetchRow(array("users_id = ?" => $request->getParam('deleteid')));
                 if ($user === null) {
                     throw new USVN_Exception(sprintf(T_("Unknown user %s"), $request->getParam('deleteid')));
                 }
                 if ($group->hasUser($user)) {
                     $group->deleteUser($user);
                 }
             }
         } catch (Exception $e) {
             $this->view->message = $e->getMessage();
         }
         $this->view->group = $group;
     } else {
         throw new USVN_Exception(sprintf(T_("Access denied.")));
     }
 }
예제 #3
0
 public function deleteAction()
 {
     $table = new USVN_Db_Table_Groups();
     $group_name = str_replace(USVN_URL_SEP, '/', $this->getRequest()->getParam('name'));
     $group = $table->fetchRow(array('groups_name = ?' => $group_name));
     if ($group === null) {
         throw new USVN_Exception(T_("Invalid group %s."), $group_name);
     }
     $group->delete();
     $this->_redirect("/admin/group/");
 }
예제 #4
0
파일: Project.php 프로젝트: phpscr/usvn
 public static function deleteProject($project_name)
 {
     $table = new USVN_Db_Table_Projects();
     $project = $table->fetchRow(array('projects_name = ?' => $project_name));
     if ($project === null) {
         throw new USVN_Exception(T_("Project %s doesn't exist."), $project_name);
     }
     $project->delete();
     $groups = new USVN_Db_Table_Groups();
     $where = $groups->getAdapter()->quoteInto("groups_name = ?", $project_name);
     $group = $groups->fetchRow($where);
     if ($group !== null) {
         $group->delete();
     }
     USVN_DirectoryUtils::removeDirectory(Zend_Registry::get('config')->subversion->path . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . $project_name);
 }
예제 #5
0
파일: User.php 프로젝트: phpscr/usvn
 /**
  * Save all information
  *
  */
 public function save()
 {
     $this->user->save();
     if ($this->createGroup) {
         $table = new USVN_Db_Table_Groups();
         $group = $table->createRow(array("groups_name" => $this->user->login));
         try {
             $group->save();
             $this->groups[] = $group->id;
         } catch (Exception $e) {
             $table = new USVN_Db_Table_Groups();
             $where = $table->getAdapter()->quoteInto('groups_name = ?', $this->user->login);
             $row = $table->fetchRow($where);
             if ($row != null) {
                 $this->user->delete();
                 throw new USVN_Exception(T_("This user can't be created. A group has the same name."));
             } else {
                 throw $e;
             }
         }
     }
     if ($this->groups !== null) {
         $this->user->deleteAllGroups();
         foreach ($this->groups as $group) {
             $this->user->addGroup($group);
         }
     }
 }
예제 #6
0
 public function testCreateProjectWithGroupWithoutAdmin()
 {
     $project = USVN_Project::createProject(array('projects_name' => 'InsertProjectOk', 'projects_start_date' => '1984-12-03 00:00:00'), "test", true, true, false, true);
     $table = new USVN_Db_Table_Projects();
     $this->assertTrue($table->isAProject('InsertProjectOk'), "Le projet n'est pas cree");
     $this->assertTrue(USVN_SVNUtils::isSVNRepository('tests/tmp/svn/InsertProjectOk'), "Le repository n'est pas cree");
     $table = new USVN_Db_Table_Groups();
     $this->assertTrue($table->isAGroup('InsertProjectOk'), "Le groupe n'est pas cree");
     $group = $table->fetchRow(array("groups_name = ?" => 'InsertProjectOk'));
     $table = new USVN_Db_Table_FilesRights();
     $right = $table->fetchRow(array("files_rights_path = ?" => "/", "projects_id = ?" => $project->id));
     $this->assertNotNull($right, "La ligne pour les droits sur / n'a pas ete trouvee");
     $table = new USVN_Db_Table_GroupsToFilesRights();
     $rights = $table->fetchRow(array("files_rights_id = ?" => $right->id, "groups_id = ?" => $group->id));
     $this->assertNotNull($rights, "La ligne pour les droits du groupe n'a pas ete trouvee");
     $this->assertEquals(1, $rights->files_rights_is_readable, "Le groupe n'a pas la lecture");
     $this->assertEquals(1, $rights->files_rights_is_readable, "Le groupe n'a pas l'ecriture");
     $this->assertTrue($group->hasUser($this->_user));
     $this->assertFalse($project->userIsAdmin($this->_user));
 }
예제 #7
0
 public function addgroupAction()
 {
     $this->requireAdmin();
     $table = new USVN_Db_Table_Groups();
     $group = $table->fetchRow(array("groups_name = ?" => $this->getRequest()->getParam('groups_name')));
     if ($group !== null) {
         try {
             $this->_project->addGroup($group);
         } catch (Exception $e) {
         }
     }
     $this->_redirect("/project/" . str_replace('/', USVN_URL_SEP, $this->_project->name) . "/");
 }
예제 #8
0
 public function test_delete()
 {
     $groups = new USVN_Db_Table_Groups();
     $this->assertNotNull($groups->fetchRow(array('groups_name = ?' => 'Indochine')));
     $this->request->setParam('name', 'Indochine');
     try {
         $this->runAction('delete');
     } catch (USVN_Test_Exception_Redirect $e) {
         $this->assertEquals('/admin/group/', $e->url);
     }
     $this->assertNull($groups->fetchRow(array('groups_name = ?' => 'Indochine')));
 }