Beispiel #1
0
 private static function ApplyFileRights($project, $group, $create_svn_directories)
 {
     $acces_rights = new USVN_FilesAccessRights($project->projects_id);
     if ($create_svn_directories) {
         $acces_rights->setRightByPath($group->groups_id, '/', true, false);
         $acces_rights->setRightByPath($group->groups_id, '/branches', true, true);
         $acces_rights->setRightByPath($group->groups_id, '/trunk', true, true);
     } else {
         $acces_rights->setRightByPath($group->groups_id, '/', true, true);
     }
 }
Beispiel #2
0
 /**
  * Add a group to a project
  *
  * @param mixed Group
  */
 public function addGroup($group)
 {
     $group_id = 0;
     if (is_object($group)) {
         $group_id = $group->id;
     } elseif (is_numeric($group)) {
         $group_id = intval($group);
     }
     if ($this->id && $group_id) {
         $table = new USVN_Db_Table_GroupsToProjects();
         $row = $table->createRow(array("groups_id" => $group_id, "projects_id" => $this->id));
         $row->save();
         $acces_rights = new USVN_FilesAccessRights($this->id);
         $acces_rights->setRightByPath($group_id, "/", true, false);
     }
 }
Beispiel #3
0
 /**
  * If files exist update rights if not insert rights
  */
 public function updateOrInsertRightsAction()
 {
     try {
         $table_project = new USVN_Db_Table_Projects();
         $res_project = $table_project->findByName(str_replace(USVN_URL_SEP, '/', $this->_request->getParam('project')));
         $acces_rights = new USVN_FilesAccessRights($res_project->projects_id);
         $user = $this->getRequest()->getParam('user');
         if (!$res_project->userIsAdmin($user) && !$user->is_admin) {
             $this->_redirect("/");
         }
         $msg = "Ok";
         $tabgroup = split(",", $_GET['group']);
         $tabrights = split(",", $_GET['rights']);
         $j = 0;
         foreach ($tabgroup as $group) {
             $table_group = new USVN_Db_Table_Groups();
             $res_groups = $table_group->findByGroupsName($group);
             $acces_rights->setRightByPath($res_groups->groups_id, $_GET['name'], $tabrights[$j] == 'true' ? true : false, $tabrights[$j + 1] == 'true' ? true : false, $tabrights[$j + 2] == 'true' ? true : false);
             $j += 3;
         }
     } catch (Exception $e) {
         $msg = nl2br($e->getMessage());
     }
     echo "<msg>" . $msg . "</msg>\n";
 }
Beispiel #4
0
 public function test_setRightByPathDoubleSlash()
 {
     $file_rights1 = new USVN_FilesAccessRights($this->_projectid1);
     $file_rights1->setRightByPath($this->_groupid2, '/trunk/', true, true);
     $file_rights1->setRightByPath($this->_groupid2, '//trunk/', false, false);
     $rights = $file_rights1->findByPath($this->_groupid2, '/trunk');
     $this->assertFalse($rights['read']);
     $this->assertFalse($rights['write']);
     $file_rights1->setRightByPath($this->_groupid2, '/test/toto/', true, true);
     $file_rights1->setRightByPath($this->_groupid2, '//test/toto', false, false);
     $rights = $file_rights1->findByPath($this->_groupid2, '/test/toto');
     $this->assertFalse($rights['read']);
     $this->assertFalse($rights['write']);
 }