Beispiel #1
0
 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);
 }
Beispiel #2
0
 public function editAction()
 {
     //rechercher projet + users
     $identity = Zend_Auth::getInstance()->getIdentity();
     $user_table = new USVN_Db_Table_Users();
     $users = $user_table->fetchRow(array('users_login = ?' => $identity['username']));
     $table = new USVN_Db_Table_Projects();
     $this->view->project = $table->fetchRow(array('projects_name = ?' => str_replace(USVN_URL_SEP, '/', $this->getRequest()->getParam('name'))));
     $table = new USVN_Db_Table_UsersToProjects();
     $UserToProject = $table->fetchRow(array('users_id = ?' => $users->users_id, 'projects_id = ?' => $this->view->project->projects_id));
     if ($UserToProject !== null) {
         $this->view->AdminProject = 1;
     }
     if ($this->view->project === null) {
         $this->_redirect("/admin/project/");
     }
 }
Beispiel #3
0
 /**
  * Delete a row in users_to_project
  *
  * @param int $user
  * @param int $project
  */
 public function DeleteUserToProject($user, $project)
 {
     $table = new USVN_Db_Table_UsersToProjects();
     $check = count($table->fetchRow(array('users_id = ?' => $user->users_id, 'projects_id = ?' => $project->projects_id)));
     if ($check == 1) {
         $table->delete(array('users_id = ?' => $user->users_id, 'projects_id = ?' => $project->projects_id));
     }
 }
Beispiel #4
0
 public function timelineAction()
 {
     //		$project = $this->getRequest()->getParam('project');
     //		$table = new USVN_Db_Table_Projects();
     //		$project = $table->fetchRow(array("projects_name = ?" => $project));
     //		/* @var $project USVN_Db_Table_Row_Project */
     //		if ($project === null) {
     //			$this->_redirect("/");
     //		}
     //		$this->_project = $project;
     $project = $this->_project;
     //get the identity of the user
     $identity = Zend_Auth::getInstance()->getIdentity();
     $user_table = new USVN_Db_Table_Users();
     $user = $user_table->fetchRow(array('users_login = ?' => $identity['username']));
     //		$table = new USVN_Db_Table_Projects();
     //		$this->view->project = $table->fetchRow(array('projects_name = ?' => $project->name));
     $table = new USVN_Db_Table_UsersToProjects();
     $userToProject = $table->fetchRow(array('users_id = ?' => $user->users_id, 'projects_id = ?' => $project->projects_id));
     if ($userToProject == null) {
         //search project
         //			$this->view->project = $project;
         //			$this->view->user = $user;
         //			$this->render('accesdenied');
         //			return;
     }
     $this->view->project = $project;
     $SVN = new USVN_SVN($this->_project->name);
     $this->view->log = $SVN->log(100);
 }
Beispiel #5
0
 /**
  * Check if an user is in the project
  *
  * @param USVN_Db_Table_Row_User or string User
  * @return boolean
  */
 public function userIsAdmin($user)
 {
     if (!is_object($user)) {
         $table = new USVN_Db_Table_Users();
         $user = $table->fetchRow(array('users_login = ?' => $user));
     }
     $table = new USVN_Db_Table_UsersToProjects();
     $res = $table->fetchRow(array("users_id = ?" => $user->id, "projects_id = ?" => $this->id));
     if ($res === null) {
         return false;
     }
     return true;
 }