Add project owner
This commit is contained in:
@@ -46,6 +46,22 @@ class Project extends Base
|
||||
return $this->db->table(self::TABLE)->eq('id', $project_id)->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a project by id with owner name
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @return array
|
||||
*/
|
||||
public function getByIdWithOwner($project_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)
|
||||
->columns(self::TABLE.'.*', User::TABLE.'.username AS owner_username', User::TABLE.'.name AS owner_name')
|
||||
->eq(self::TABLE.'.id', $project_id)
|
||||
->join(User::TABLE, 'id', 'owner_id')
|
||||
->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a project by the name
|
||||
*
|
||||
@@ -275,23 +291,6 @@ class Project extends Base
|
||||
return $projects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch more information for each project
|
||||
*
|
||||
* @access public
|
||||
* @param array $projects
|
||||
* @return array
|
||||
*/
|
||||
public function applyProjectDetails(array $projects)
|
||||
{
|
||||
foreach ($projects as &$project) {
|
||||
$this->getColumnStats($project);
|
||||
$project = array_merge($project, $this->projectUserRole->getAllUsersGroupedByRole($project['id']));
|
||||
}
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project summary for a list of project
|
||||
*
|
||||
@@ -307,29 +306,12 @@ class Project extends Base
|
||||
|
||||
return $this->db
|
||||
->table(Project::TABLE)
|
||||
->in('id', $project_ids)
|
||||
->columns(self::TABLE.'.*', User::TABLE.'.username AS owner_username', User::TABLE.'.name AS owner_name')
|
||||
->join(User::TABLE, 'id', 'owner_id')
|
||||
->in(self::TABLE.'.id', $project_ids)
|
||||
->callback(array($this, 'applyColumnStats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project details (users + columns) for a list of project
|
||||
*
|
||||
* @access public
|
||||
* @param array $project_ids List of project id
|
||||
* @return \PicoDb\Table
|
||||
*/
|
||||
public function getQueryProjectDetails(array $project_ids)
|
||||
{
|
||||
if (empty($project_ids)) {
|
||||
return $this->db->table(Project::TABLE)->limit(0);
|
||||
}
|
||||
|
||||
return $this->db
|
||||
->table(Project::TABLE)
|
||||
->in('id', $project_ids)
|
||||
->callback(array($this, 'applyProjectDetails'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a project
|
||||
*
|
||||
@@ -346,6 +328,7 @@ class Project extends Base
|
||||
$values['token'] = '';
|
||||
$values['last_modified'] = time();
|
||||
$values['is_private'] = empty($values['is_private']) ? 0 : 1;
|
||||
$values['owner_id'] = $user_id;
|
||||
|
||||
if (! empty($values['identifier'])) {
|
||||
$values['identifier'] = strtoupper($values['identifier']);
|
||||
|
||||
Reference in New Issue
Block a user