public function testInsertUserToProjects() { $table = new USVN_Db_Table_Users(); $obj = $table->fetchNew(); $obj->setFromArray(array('users_login' => 'TestOk', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**')); $obj->save(); $users = $table->findByName("TestOk"); $table = new USVN_Db_Table_Projects(); $project = $table->fetchNew(); $project->setFromArray(array('projects_name' => 'InsertProjectOk', 'projects_start_date' => '1984-12-03 00:00:00')); $project->save(); $projects = $table->findByName("InsertProjectOk"); $table->AddUserToProject($users, $projects); $UserToProject = new USVN_Db_Table_UsersToProjects(); $this->assertEquals(count($UserToProject->fetchRow(array('users_id = ?' => $users->users_id, 'projects_id = ?' => $projects->projects_id))), 1); $table->DeleteUserToProject($users, $projects); $this->assertEquals(count($UserToProject->fetchRow(array('users_id = ?' => $users->users_id, 'projects_id = ?' => $projects->projects_id))), 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"; }
/** * Get all groups associated with $project for this user * * Project can be the project name as a string or a project row. * * @param string|USVN_Db_Table_Row_Project $project * @return Zend_Db_Table_Rowset */ public function getAllGroupsFor($project) { if (!is_object($project)) { $projects = new USVN_Db_Table_Projects(); $project = $projects->findByName($project); } $groups = new USVN_Db_Table_Groups(); return $groups->fetchAllForUserAndProject($this, $project); }
/** * 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"; }