Add default project categories in settings

This commit is contained in:
Frédéric Guillot
2014-12-28 15:39:39 -05:00
parent bcbc1b78c6
commit e59be3dc02
22 changed files with 142 additions and 4 deletions

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
'Unable to remove this swimlane.' => 'Impossible de supprimer 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.',
'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)',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
// 'Unable to remove this swimlane.' => '',
// 'Unable to update this swimlane.' => '',
// 'Your swimlane have been created successfully.' => '',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -624,4 +624,6 @@ return array(
'Unable to remove this swimlane.' => '无法删除此泳道',
'Unable to update this swimlane.' => '无法更新此泳道',
'Your swimlane have been created successfully.' => '已经成功创建泳道。',
// 'Example: "Bug, Feature Request, Improvement"' => '',
// 'Default categories for new projects (Comma-separated)' => '',
);

View File

@@ -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
* @param array $values Form values

View File

@@ -298,6 +298,8 @@ class Project extends Base
$this->projectPermission->allowUser($project_id, $user_id);
}
$this->category->createDefaultCategories($project_id);
$this->db->closeTransaction();
return (int) $project_id;

View File

@@ -5,7 +5,13 @@ namespace Schema;
use PDO;
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)
{

View File

@@ -5,7 +5,13 @@ namespace Schema;
use PDO;
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)
{

View File

@@ -5,7 +5,13 @@ namespace Schema;
use Core\Security;
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)
{

View File

@@ -22,6 +22,10 @@
<?= $this->formText('board_columns', $values, $errors) ?><br/>
<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">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
</div>