示例#1
0
文件: Project.php 项目: phpscr/usvn
 /**
  * Check if an group is in the project
  *
  * @param USVN_Db_Table_Row_Group Group
  * @return boolean
  */
 public function groupIsMember(USVN_Db_Table_Row_Group $group)
 {
     $table = new USVN_Db_Table_GroupsToProjects();
     $res = $table->fetchRow(array("groups_id = ?" => $group->id, "projects_id = ?" => $this->id));
     if ($res === null) {
         return false;
     }
     return true;
 }
示例#2
0
 private function CheckCreateProjectWithGroupWithAdmin($project)
 {
     $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_GroupsToProjects();
     $groupstoprojects = $table->fetchRow(array("projects_id = ?" => $project->id, "groups_id = ?" => $group->id));
     $this->assertNotNull($groupstoprojects);
     $this->assertTrue($group->hasUser($this->_user), "L'utilisateur n'est pas membre du groupe " . $group->name);
     $this->assertTrue($group->userIsGroupLeader($this->_user), "User is not leader of group " . $group->name);
     $this->assertTrue($project->userIsAdmin($this->_user));
     return $group;
 }
示例#3
0
 public function test_affectandremovegroup()
 {
     $table = new USVN_Db_Table_GroupsToProjects();
     $project = $this->createProject("project");
     $project2 = $this->createProject("project2");
     $this->assertEquals(0, count($table->findByProjectId($project->id)));
     $this->assertEquals(0, count($table->findByProjectId($project2->id)));
     $group1 = $this->createGroup("group1");
     $group2 = $this->createGroup("group2");
     $project->addGroup($group1);
     $project2->addGroup($group1);
     $project->addGroup($group2);
     $project2->addGroup($group2);
     $this->assertEquals(2, count($table->findByProjectId($project->id)));
     $this->assertEquals(2, count($table->findByProjectId($project2->id)));
     $table_files = new USVN_Db_Table_FilesRights();
     $fileid = $table_files->insert(array('projects_id' => $project->id, 'files_rights_path' => '/trunk'));
     $table_groupstofiles = new USVN_Db_Table_GroupsToFilesRights();
     $res = $table_groupstofiles->findByIdRightsAndIdGroup($fileid, $group1->id);
     $this->assertNull($res);
     $table_groupstofiles->insert(array('files_rights_id' => $fileid, 'files_rights_is_readable' => true, 'files_rights_is_writable' => false, 'groups_id' => $group1->id));
     $res = $table_groupstofiles->findByIdRightsAndIdGroup($fileid, $group1->id);
     $this->assertEquals(true, (bool) $res->files_rights_is_readable);
     $this->assertEquals(false, (bool) $res->files_rights_is_writable);
     $fileid2 = $table_files->insert(array('projects_id' => $project2->id, 'files_rights_path' => '/trunk'));
     $table_groupstofiles = new USVN_Db_Table_GroupsToFilesRights();
     $res = $table_groupstofiles->findByIdRightsAndIdGroup($fileid2, $group2->id);
     $this->assertNull($res);
     $table_groupstofiles->insert(array('files_rights_id' => $fileid2, 'files_rights_is_readable' => true, 'files_rights_is_writable' => false, 'groups_id' => $group1->id));
     $res = $table_groupstofiles->findByIdRightsAndIdGroup($fileid2, $group1->id);
     $this->assertEquals(true, (bool) $res->files_rights_is_readable);
     $this->assertEquals(false, (bool) $res->files_rights_is_writable);
     $project->deleteGroup($group1);
     $this->assertEquals(1, count($table->findByProjectId($project->id)));
     $this->assertEquals(2, count($table->findByProjectId($project2->id)));
     $res = $table_groupstofiles->findByIdRightsAndIdGroup($fileid2, $group1->id);
     $this->assertNotNull($res);
     $this->assertEquals(true, (bool) $res->files_rights_is_readable);
     $this->assertEquals(false, (bool) $res->files_rights_is_writable);
 }
示例#4
0
 public function completionAction()
 {
     echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
     $table = "<table width=100%>";
     $nb = 0;
     echo "<files>\n";
     if ($_GET['idx'] == 1) {
         if (isset($_GET['grp']) && $_GET['grp'] != "") {
             $table_groups = new USVN_Db_Table_Groups();
             $res_groups = $table_groups->findByGroupsName($_GET['grp']);
             $table_userstogroups = new USVN_Db_Table_UsersToGroups();
             $res_usersspe = $table_userstogroups->findByGroupId($res_groups->groups_id);
         } else {
             if (isset($_GET['prj']) && $_GET['prj'] != "") {
                 $table_project = new USVN_Db_Table_Projects();
                 $res_project = $table_project->findByName($_GET['prj']);
                 $table_userstoprojects = new USVN_Db_Table_UsersToProjects();
                 $res_usersspe = $table_userstoprojects->findByProjectId($res_project->projects_id);
             }
         }
         $table_users = new USVN_Db_Table_Users();
         $res_users = $table_users->allUsersLike($_GET['txt']);
         foreach ($res_users as $user) {
             $find = false;
             foreach ($res_usersspe as $tmpuser) {
                 if ($tmpuser->users_id == $user->users_id) {
                     $find = true;
                 }
             }
             if ($find == false) {
                 $table .= "<tr id='user" . $nb . "' class='comp'>";
                 $table .= "<td align=left onclick='javascript:dumpInput(" . "\"" . $user->users_login . "\"" . "," . "\"" . $_GET['input'] . "\"" . ", \"completion\")'>";
                 $table .= "<label id='luser" . $nb . "'>" . $user->users_login . "</label>";
                 $table .= "</td></tr>";
                 $nb++;
             }
         }
     }
     if ($_GET['idx'] == 2) {
         $table_project = new USVN_Db_Table_Projects();
         $res_project = $table_project->findByName($_GET['prj']);
         $table_groupstoprojects = new USVN_Db_Table_GroupsToProjects();
         $res_groupstoprojects = $table_groupstoprojects->findByProjectId($res_project->projects_id);
         $table_groups = new USVN_Db_Table_Groups();
         $res_groups = $table_groups->allGroupsLike($_GET['txt']);
         foreach ($res_groups as $group) {
             $find = false;
             foreach ($res_groupstoprojects as $tmpgrp) {
                 if ($tmpgrp->groups_id == $group->groups_id) {
                     $find = true;
                 }
             }
             if ($find == false) {
                 $table .= "<tr id='grp" . $nb . "' class='comp'>";
                 $table .= "<td align=left onclick='javascript:dumpInput(" . "\"" . $group->groups_name . "\"" . "," . "\"" . $_GET['input'] . "\"" . ", \"completion1\")'>";
                 $table .= "<label id='lgrp" . $nb . "'>" . $group->groups_name . "</label>";
                 $table .= "</td></tr>";
                 $nb++;
             }
         }
     }
     if ($_GET['idx'] == 3) {
         $table_users = new USVN_Db_Table_Users();
         $res_users = $table_users->allUsersLike($_GET['txt']);
         $table_groups = new USVN_Db_Table_Groups();
         $res_groups = $table_groups->findByGroupsName($_GET['grp']);
         $res_usersspe = $table_users->allLeader($res_groups->groups_id);
         foreach ($res_users as $user) {
             $find = false;
             foreach ($res_usersspe as $tmpuser) {
                 if ($tmpuser->users_id == $user->users_id) {
                     $find = true;
                 }
             }
             if ($find == false) {
                 $table .= "<tr id='user" . $nb . "' class='comp'>";
                 $table .= "<td align=left onclick='javascript:dumpInput(" . "\"" . $user->users_login . "\"" . "," . "\"" . $_GET['input'] . "\"" . ", \"completionleader\")'>";
                 $table .= "<label id='luser" . $nb . "'>" . $user->users_login . "</label>";
                 $table .= "</td></tr>";
                 $nb++;
             }
         }
     }
     if ($_GET['idx'] == 4) {
         $table_groups = new USVN_Db_Table_Groups();
         $res_groups = $table_groups->findByGroupsName($_GET['grp']);
         $table_userstogroups = new USVN_Db_Table_UsersToGroups();
         $res_usersspe = $table_userstogroups->noleaderFindByGroupId($res_groups->groups_id);
         $table_users = new USVN_Db_Table_Users();
         $res_users = $table_users->allUsersLike($_GET['txt']);
         foreach ($res_users as $user) {
             $find = false;
             foreach ($res_usersspe as $tmpuser) {
                 if ($tmpuser->users_id == $user->users_id) {
                     $find = true;
                 }
             }
             if ($find == false) {
                 $table .= "<tr id='user" . $nb . "' class='comp'>";
                 $table .= "<td align=left onclick='javascript:dumpInput(" . "\"" . $user->users_login . "\"" . "," . "\"" . $_GET['input'] . "\"" . ", \"completion\")'>";
                 $table .= "<label id='luser" . $nb . "'>" . $user->users_login . "</label>";
                 $table .= "</td></tr>";
                 $nb++;
             }
         }
     }
     $table .= "</table>";
     echo "<nbcomp>" . $nb . "</nbcomp>\n";
     echo "<tableau><![CDATA[" . $table . "]]></tableau>\n";
     echo "</files>\n";
 }
示例#5
0
 /**
  * If files exist dump rights
  */
 public function dumpRightsAction()
 {
     $text = "";
     $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);
     $table_files = new USVN_Db_Table_FilesRights();
     $table_groupstoproject = new USVN_Db_Table_GroupsToProjects();
     $res_groupstoproject = $table_groupstoproject->findByProjectId($res_project->projects_id);
     $table_groups = new USVN_Db_Table_Groups();
     $text = "<table class='usvn_table' width=22% cellpadding=3><tr><td>" . T_('Group') . "</td><td>" . T_('Read') . "</td><td>" . T_('Write') . "</td><td>" . T_('Recursive') . "</td></tr>";
     $i = 0;
     $disabled = "";
     $identity = Zend_Auth::getInstance()->getIdentity();
     if (!$res_project->userIsAdmin($identity["username"])) {
         $disabled = " disabled";
     }
     foreach ($res_groupstoproject as $groups) {
         $access = $acces_rights->findByPath($groups->groups_id, $_GET['name']);
         $res_groups = $table_groups->findByGroupsId($groups->groups_id);
         $grp_name = $res_groups->groups_name;
         $text .= "<tr><td weight=10%><label id=Lb" . $i . ">" . $grp_name . "</label></td>";
         if ($access['read'] == 1) {
             $text .= "<td width=3% align=center><input id='checkRead" . $grp_name . "' type='checkbox' checked='checked' onclick='javascript:fctRead(" . "\"" . $grp_name . "\"" . ");' {$disabled}/></td>";
         } else {
             $text .= "<td width=3% align=center><input id='checkRead" . $grp_name . "' type='checkbox' onclick='javascript:fctRead(" . "\"" . $grp_name . "\"" . ");' {$disabled}/></td>";
         }
         if ($access['write'] == 1) {
             $text .= "<td width=3% align=center><input id='checkWrite" . $grp_name . "' type='checkbox' checked='checked' onclick='javascript:fctWrite(" . "\"" . $grp_name . "\"" . ");' {$disabled}/></td>";
         } else {
             $text .= "<td width=3% align=center><input id='checkWrite" . $grp_name . "' type='checkbox' onclick='javascript:fctWrite(" . "\"" . $grp_name . "\"" . ");' {$disabled}/></td>";
         }
         $text .= '<td><input type="checkbox" id="recursive' . $grp_name . '" /></td>';
         $text .= "</tr>";
         $i++;
     }
     $text .= "</table>";
     $text .= "<br /><table><tr><td><input type='button' value='Ok' onclick=\"javascript:updateOrInsertRights('" . $_GET['name'] . "');\" {$disabled}/></td><td>";
     $text .= "<input type='button' value='Cancel' onclick='javascript:cancel();'/></td></tr></table><label id='labelError'></label>";
     echo "<basename>" . basename($_GET['name']) . "</basename>\n";
     echo "<nbgroup>" . $i . "</nbgroup>\n";
     echo "<groups><![CDATA[" . $text . "]]></groups>\n";
 }
示例#6
0
 public function testDeleteAffectedGroup()
 {
     $table = new USVN_Db_Table_GroupsToProjects();
     $project = $this->createProject("project");
     $project2 = $this->createProject("project2");
     $this->assertEquals(0, count($table->findByProjectId($project->id)));
     $this->assertEquals(0, count($table->findByProjectId($project2->id)));
     $group1 = $this->createGroup("group1");
     $group2 = $this->createGroup("group2");
     $project->addGroup($group1);
     $project2->addGroup($group1);
     $project->addGroup($group2);
     $project2->addGroup($group2);
     $this->assertEquals(2, count($table->findByProjectId($project->id)));
     $this->assertEquals(2, count($table->findByProjectId($project2->id)));
     $group1->delete();
     $this->assertEquals(1, count($table->findByProjectId($project->id)));
     $this->assertEquals(1, count($table->findByProjectId($project2->id)));
     $group2->delete();
     $this->assertEquals(0, count($table->findByProjectId($project->id)));
 }