Add option to enable or disable global tags per projects

This commit is contained in:
Timo
2020-04-04 20:39:17 +02:00
committed by GitHub
parent 1cc0ac0713
commit 67a5dd6a89
42 changed files with 185 additions and 62 deletions

View File

@@ -605,4 +605,20 @@ class ProjectModel extends Base
->join(ColumnModel::TABLE, 'id', 'project_id')
->count();
}
/**
* Change usage of global tags
*
* @param integer $project_id Project id
* @param bool $global_tags New global tag value
* @return bool
*/
public function changeGlobalTagUsage($project_id, $global_tags)
{
return $this->exists($project_id) &&
$this->db
->table(self::TABLE)
->eq('id', $project_id)
->save(array('enable_global_tags' => $global_tags));
}
}

View File

@@ -45,19 +45,28 @@ class TagModel extends Base
/**
* Get assignable tags for a project
*
* @access public
* @param integer $project_id
* @param integer $project_id Project Id
* @param bool $include_global_tags Flag to include global tags
* @return array
*/
public function getAssignableList($project_id)
public function getAssignableList($project_id, $include_global_tags = true)
{
return $this->db->hashtable(self::TABLE)
->beginOr()
->eq('project_id', $project_id)
->eq('project_id', 0)
->closeOr()
->asc('name')
->getAll('id', 'name');
if ($include_global_tags) {
return $this->db->hashtable(self::TABLE)
->beginOr()
->eq('project_id', $project_id)
->eq('project_id', 0)
->closeOr()
->asc('name')
->getAll('id', 'name');
} else {
return $this->db->hashtable(self::TABLE)
->beginOr()
->eq('project_id', $project_id)
->closeOr()
->asc('name')
->getAll('id', 'name');
}
}
/**
@@ -85,8 +94,8 @@ class TagModel extends Base
return $this->db
->table(self::TABLE)
->beginOr()
->eq('project_id', 0)
->eq('project_id', $project_id)
->eq('project_id', 0)
->eq('project_id', $project_id)
->closeOr()
->ilike('name', $tag)
->asc('project_id')
@@ -162,18 +171,18 @@ class TagModel extends Base
*/
public function update($tag_id, $tag, $color_id = null, $project_id = null)
{
if($project_id !== null){
if ($project_id !== null) {
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
'color_id' => $color_id,
'project_id' => $project_id
'project_id' => $project_id,
));
} else {
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
'color_id' => $color_id
'color_id' => $color_id,
));
}
}
}
/**