Do not list private projects when adding a new user
This commit is contained in:
@@ -202,16 +202,23 @@ class ProjectModel extends Base
|
|||||||
* Return the list of all projects
|
* Return the list of all projects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param bool $prepend If true, prepend to the list the value 'None'
|
* @param bool $prependNone
|
||||||
|
* @param bool $noPrivateProjects
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getList($prepend = true)
|
public function getList($prependNone = true, $noPrivateProjects = true)
|
||||||
{
|
{
|
||||||
if ($prepend) {
|
if ($noPrivateProjects) {
|
||||||
return array(t('None')) + $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name');
|
$projects = $this->db->hashtable(self::TABLE)->eq('is_private', 0)->asc('name')->getAll('id', 'name');
|
||||||
|
} else {
|
||||||
|
$projects = $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name');
|
if ($prependNone) {
|
||||||
|
return array(t('None')) + $projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -354,4 +354,17 @@ class ProjectModelTest extends Base
|
|||||||
$this->assertEquals('', $project['owner_username']);
|
$this->assertEquals('', $project['owner_username']);
|
||||||
$this->assertEquals(0, $project['owner_id']);
|
$this->assertEquals(0, $project['owner_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetList()
|
||||||
|
{
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'Project B'), 1));
|
||||||
|
$this->assertEquals(2, $projectModel->create(array('name' => 'Project A', 'is_private' => 1), 1));
|
||||||
|
|
||||||
|
$this->assertEquals(array(0 => 'None', 1 => 'Project B'), $projectModel->getList());
|
||||||
|
$this->assertEquals(array(1 => 'Project B'), $projectModel->getList(false));
|
||||||
|
$this->assertEquals(array(2 => 'Project A', 1 => 'Project B'), $projectModel->getList(false, false));
|
||||||
|
$this->assertEquals(array(0 => 'None', 2 => 'Project A', 1 => 'Project B'), $projectModel->getList(true, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user