Various fixes and improvements

This commit is contained in:
Frédéric Guillot
2015-01-02 21:11:19 -05:00
parent 3076ba22dd
commit 45c95d74fc
15 changed files with 100 additions and 46 deletions

View File

@@ -324,17 +324,29 @@ class ProjectPermission extends Base
/**
* Copy user access from a project to another one
*
* @author Antonio Rabelo
* @param integer $project_from Project Template
* @return integer $project_to Project that receives the copy
* @param integer $project_src Project Template
* @return integer $project_dst Project that receives the copy
* @return boolean
*/
public function duplicate($project_from, $project_to)
public function duplicate($project_src, $project_dst)
{
$users = $this->getMembers($project_from);
$rows = $this->db
->table(self::TABLE)
->columns('project_id', 'user_id', 'is_owner')
->eq('project_id', $project_src)
->findAll();
foreach ($users as $user_id => $name) {
if (! $this->addMember($project_to, $user_id)) { // TODO: Duplicate managers
foreach ($rows as $row) {
$result = $this->db
->table(self::TABLE)
->save(array(
'project_id' => $project_dst,
'user_id' => $row['user_id'],
'is_owner' => (int) $row['is_owner'], // (int) for postgres
));
if (! $result) {
return false;
}
}

View File

@@ -21,6 +21,10 @@ class TaskCreation extends Base
*/
public function create(array $values)
{
if (! $this->project->exists($values['project_id'])) {
return 0;
}
$this->prepare($values);
$task_id = $this->persist(Task::TABLE, $values);
@@ -51,6 +55,10 @@ class TaskCreation extends Base
$values['color_id'] = $this->color->getDefaultColor();
}
if (empty($values['title'])) {
$values['title'] = t('Untitled');
}
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
$values['date_creation'] = time();
$values['date_modification'] = $values['date_creation'];