Regular users are able to create private projects

This commit is contained in:
Frédéric Guillot
2014-10-05 19:40:57 -04:00
parent 7f5a871f84
commit d138834dcf
39 changed files with 379 additions and 319 deletions

View File

@@ -142,12 +142,10 @@ class ProjectPermission extends Base
*/
public function isUserAllowed($project_id, $user_id)
{
// Check if the user has admin rights
if ($this->user->isAdmin($user_id)) {
return true;
}
// Otherwise, allow only specific users
return (bool) $this->db
->table(self::TABLE)
->eq('project_id', $project_id)
@@ -155,6 +153,23 @@ class ProjectPermission extends Base
->count();
}
/**
* Check if a specific user is allowed to manage a project
*
* @access public
* @param integer $project_id Project id
* @param integer $user_id User id
* @return bool
*/
public function adminAllowed($project_id, $user_id)
{
if ($this->isUserAllowed($project_id, $user_id) && $this->project->isPrivate($project_id)) {
return true;
}
return false;
}
/**
* Filter a list of projects for a given user
*