Add default project categories in settings
This commit is contained in:
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
'Unable to remove this swimlane.' => 'Impossible de supprimer cette swimlane.',
|
'Unable to remove this swimlane.' => 'Impossible de supprimer cette swimlane.',
|
||||||
'Unable to update this swimlane.' => 'Impossible de mettre à jour cette swimlane.',
|
'Unable to update this swimlane.' => 'Impossible de mettre à jour cette swimlane.',
|
||||||
'Your swimlane have been created successfully.' => 'Votre swimlane a été créée avec succès.',
|
'Your swimlane have been created successfully.' => 'Votre swimlane a été créée avec succès.',
|
||||||
|
'Example: "Bug, Feature Request, Improvement"' => 'Exemple: « Incident, Demande de fonctionnalité, Amélioration »',
|
||||||
|
'Default categories for new projects (Comma-separated)' => 'Catégories par défaut pour les nouveaux projets (séparé par des virgules)',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
// 'Unable to remove this swimlane.' => '',
|
// 'Unable to remove this swimlane.' => '',
|
||||||
// 'Unable to update this swimlane.' => '',
|
// 'Unable to update this swimlane.' => '',
|
||||||
// 'Your swimlane have been created successfully.' => '',
|
// 'Your swimlane have been created successfully.' => '',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -624,4 +624,6 @@ return array(
|
|||||||
'Unable to remove this swimlane.' => '无法删除此泳道',
|
'Unable to remove this swimlane.' => '无法删除此泳道',
|
||||||
'Unable to update this swimlane.' => '无法更新此泳道',
|
'Unable to update this swimlane.' => '无法更新此泳道',
|
||||||
'Your swimlane have been created successfully.' => '已经成功创建泳道。',
|
'Your swimlane have been created successfully.' => '已经成功创建泳道。',
|
||||||
|
// 'Example: "Bug, Feature Request, Improvement"' => '',
|
||||||
|
// 'Default categories for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -118,7 +118,30 @@ class Category extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a category
|
* Create default cetegories during project creation (transaction already started in Project::create())
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id
|
||||||
|
*/
|
||||||
|
public function createDefaultCategories($project_id)
|
||||||
|
{
|
||||||
|
$categories = explode(',', $this->config->get('project_categories'));
|
||||||
|
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
|
||||||
|
$category = trim($category);
|
||||||
|
|
||||||
|
if (! empty($category)) {
|
||||||
|
$this->db->table(self::TABLE)->insert(array(
|
||||||
|
'project_id' => $project_id,
|
||||||
|
'name' => $category,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a category (run inside a transaction)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values Form values
|
* @param array $values Form values
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ class Project extends Base
|
|||||||
$this->projectPermission->allowUser($project_id, $user_id);
|
$this->projectPermission->allowUser($project_id, $user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->category->createDefaultCategories($project_id);
|
||||||
|
|
||||||
$this->db->closeTransaction();
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
return (int) $project_id;
|
return (int) $project_id;
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use PDO;
|
use PDO;
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 38;
|
const VERSION = 39;
|
||||||
|
|
||||||
|
function version_39($pdo)
|
||||||
|
{
|
||||||
|
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||||
|
$rq->execute(array('project_categories', ''));
|
||||||
|
}
|
||||||
|
|
||||||
function version_38($pdo)
|
function version_38($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use PDO;
|
use PDO;
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 19;
|
const VERSION = 20;
|
||||||
|
|
||||||
|
function version_20($pdo)
|
||||||
|
{
|
||||||
|
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||||
|
$rq->execute(array('project_categories', ''));
|
||||||
|
}
|
||||||
|
|
||||||
function version_19($pdo)
|
function version_19($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use Core\Security;
|
use Core\Security;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
|
||||||
const VERSION = 37;
|
const VERSION = 38;
|
||||||
|
|
||||||
|
function version_38($pdo)
|
||||||
|
{
|
||||||
|
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||||
|
$rq->execute(array('project_categories', ''));
|
||||||
|
}
|
||||||
|
|
||||||
function version_37($pdo)
|
function version_37($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
<?= $this->formText('board_columns', $values, $errors) ?><br/>
|
<?= $this->formText('board_columns', $values, $errors) ?><br/>
|
||||||
<p class="form-help"><?= t('Default values are "%s"', $default_columns) ?></p>
|
<p class="form-help"><?= t('Default values are "%s"', $default_columns) ?></p>
|
||||||
|
|
||||||
|
<?= $this->formLabel(t('Default categories for new projects (Comma-separated)'), 'project_categories') ?>
|
||||||
|
<?= $this->formText('project_categories', $values, $errors) ?><br/>
|
||||||
|
<p class="form-help"><?= t('Example: "Bug, Feature Request, Improvement"') ?></p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,5 +51,8 @@ class ConfigTest extends Base
|
|||||||
$this->assertEquals('foo', $c->get('board_columns'));
|
$this->assertEquals('foo', $c->get('board_columns'));
|
||||||
$this->assertEquals('foo', $c->get('board_columns', 'test'));
|
$this->assertEquals('foo', $c->get('board_columns', 'test'));
|
||||||
$this->assertEquals('test', $c->get('empty_value', 'test'));
|
$this->assertEquals('test', $c->get('empty_value', 'test'));
|
||||||
|
|
||||||
|
session_id('');
|
||||||
|
unset($this->container['session']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use Model\Task;
|
|||||||
use Model\TaskCreation;
|
use Model\TaskCreation;
|
||||||
use Model\Acl;
|
use Model\Acl;
|
||||||
use Model\Board;
|
use Model\Board;
|
||||||
|
use Model\Config;
|
||||||
|
use Model\Category;
|
||||||
|
|
||||||
class ProjectTest extends Base
|
class ProjectTest extends Base
|
||||||
{
|
{
|
||||||
@@ -28,6 +30,64 @@ class ProjectTest extends Base
|
|||||||
$this->assertEmpty($project['token']);
|
$this->assertEmpty($project['token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreationWithDefaultCategories()
|
||||||
|
{
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$c = new Config($this->container);
|
||||||
|
$cat = new Category($this->container);
|
||||||
|
|
||||||
|
// Multiple categories correctly formatted
|
||||||
|
|
||||||
|
$this->assertTrue($c->save(array('project_categories' => 'Test1, Test2')));
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||||
|
|
||||||
|
$project = $p->getById(1);
|
||||||
|
$this->assertNotEmpty($project);
|
||||||
|
|
||||||
|
$categories = $cat->getAll(1);
|
||||||
|
$this->assertNotEmpty($categories);
|
||||||
|
$this->assertEquals(2, count($categories));
|
||||||
|
$this->assertEquals('Test1', $categories[0]['name']);
|
||||||
|
$this->assertEquals('Test2', $categories[1]['name']);
|
||||||
|
|
||||||
|
// Single category
|
||||||
|
|
||||||
|
$this->assertTrue($c->save(array('project_categories' => 'Test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
|
||||||
|
|
||||||
|
$project = $p->getById(2);
|
||||||
|
$this->assertNotEmpty($project);
|
||||||
|
|
||||||
|
$categories = $cat->getAll(2);
|
||||||
|
$this->assertNotEmpty($categories);
|
||||||
|
$this->assertEquals(1, count($categories));
|
||||||
|
$this->assertEquals('Test1', $categories[0]['name']);
|
||||||
|
|
||||||
|
// Multiple categories badly formatted
|
||||||
|
|
||||||
|
$this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3, ')));
|
||||||
|
$this->assertEquals(3, $p->create(array('name' => 'UnitTest3')));
|
||||||
|
|
||||||
|
$project = $p->getById(3);
|
||||||
|
$this->assertNotEmpty($project);
|
||||||
|
|
||||||
|
$categories = $cat->getAll(3);
|
||||||
|
$this->assertNotEmpty($categories);
|
||||||
|
$this->assertEquals(2, count($categories));
|
||||||
|
$this->assertEquals('ABC', $categories[0]['name']);
|
||||||
|
$this->assertEquals('DEF 3', $categories[1]['name']);
|
||||||
|
|
||||||
|
// No default categories
|
||||||
|
$this->assertTrue($c->save(array('project_categories' => ' ')));
|
||||||
|
$this->assertEquals(4, $p->create(array('name' => 'UnitTest4')));
|
||||||
|
|
||||||
|
$project = $p->getById(4);
|
||||||
|
$this->assertNotEmpty($project);
|
||||||
|
|
||||||
|
$categories = $cat->getAll(4);
|
||||||
|
$this->assertEmpty($categories);
|
||||||
|
}
|
||||||
|
|
||||||
public function testUpdateLastModifiedDate()
|
public function testUpdateLastModifiedDate()
|
||||||
{
|
{
|
||||||
$p = new Project($this->container);
|
$p = new Project($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user