Background:
I have to set up several copies of mantis with a specified set of access levels, stati, priorites, etc.. being new to mantis it was quite time consuming to locate all the files to configure and to find out what dependencies are implied.
I appreciate CoC & DRY & SoC & readability:
I really like the idea of the custom_*-files since I'm a fan of "Convention over Configuration" (CoC). In addition I like "Don't repeat yourself" (DRY): Whenever I had to type in something twice I started to think about encapsulating this functionality in a separate function.
What I don't like is that the files of mantis are mixed with the user (configuration) files in one directory. In my opinion there should be a strict separation of the "framework" mantis and user customization files. It should be possible to see all user files at one glance.
Keys like the access level "REPORTER" and all depending keys (like the "reporter" string used in several PHP variables) should be defined together at one place using constants. All other configuration strings should be built on base of these constants.
My rough copy (A): custom_*-files --> custom directory
In order to separate the mantis files from those supplied by me (i.e. configuration files, css, js, images,...) I redirected the custom_*-files and the config_inc.php file to a separate directory "_custom". any customization is located in this directory.
thus my custom_XXX.inc.php files / config_inc.php look like this:
Code: Select all
<?php
$file = $customDir . DIRECTORY_SEPARATOR . '_mantis.constant.php';
if (file_exists($file)) {
require_once($file);
}
?>
Code: Select all
$customDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_custom';
If mantis was looking for the custom files in the custom directory by default, I would not need the ugly redirects in the custom_*_inc.php files.
But that are changes in mantis itself ... maybe this is supported in a new version of mantis?
My rough copy (B): helper functions for defining CONSTANTS et al
I supply two helper functions to define the constants and string-ids that mantis uses for defining priorities, severities, access levels, etc. This makes things a lot more easy to read.
The two helper functions are located in my _mantis.constant.php file. They could be placed in custom_constant_inc.php too or, what I would prefer, in a core file of mantis.
Code: Select all
function defineCONST ($name, $value) {
if (!defined($name)) { define($name, $value); }
}
function defineID ($name, $value, $color=NULL) {
defineCONST($name, $value);
defineCONST($name . '_ID', strtolower($name));
defineCONST($name . '_PAIR', constant($name) . ':' . constant($name . '_ID'));
if (isset($color)) { defineCONST($name . '_COLOR', $color); };
}
Code: Select all
# priority
defineID('DEFERRED', 10);
defineID('NORMAL', 30);
defineID('IMMEDIATE', 60);
# severity
defineID('SUGGESTION_FOR_IMPROVEMENT', 20);
defineID('CHANGE_REQUEST', 40);
defineID('TASK', 50);
defineID('ANY_ERROR', 60);
# access levels
defineID('REPORTER', 25);
defineID('DEVELOPER', 55);
defineID('MANAGER', 70);
defineID('ADMINISTRATOR', 90);
# status
defineID('NEW_', 10, '#ff9000');
defineID('ACKNOWLEDGED', 30, '#ffd850');
defineID('IN_PROCESS', 50, '#d0e8ff');
defineID('RESOLVED', 80, '#e6ffc8');
defineID('REJECTED', 82, '#ffff66');
defineID('READY_FOR_TEST', 85, '#CDFF91');
defineID('CLOSED', 90, '#e8e8e8');
Code: Select all
...
$g_access_levels_enum_string = REPORTER_PAIR
. ',' . DEVELOPER_PAIR
. ',' . MANAGER_PAIR
. ',' . ADMINISTRATOR_PAIR
;
...
$g_status_enum_string = NEW__PAIR
. ',' . ACKNOWLEDGED_PAIR
. ',' . IN_PROCESS_PAIR
. ',' . RESOLVED_PAIR
. ',' . READY_FOR_TEST_PAIR
. ',' . REJECTED_PAIR
. ',' . CLOSED_PAIR
;
...
$g_status_colors = array( NEW__ID => NEW__COLOR
, ACKNOWLEDGED_ID => ACKNOWLEDGED_COLOR
, IN_PROCESS_ID => IN_PROCESS_COLOR
, RESOLVED_ID => RESOLVED_COLOR
, READY_FOR_TEST_ID => READY_FOR_TEST_COLOR
, REJECTED_ID => REJECTED_COLOR
, CLOSED_ID => CLOSED_COLOR
);
...
Code: Select all
...
$s_priority_enum_string = DEFERRED . ':' . 'zurückgestellt'
. ',' . NORMAL . ':' . 'normal'
. ',' . IMMEDIATE . ':' . 'produktionsverhindernd';
$s_severity_enum_string = SUGGESTION_FOR_IMPROVEMENT . ':' . 'Verbesserungsvorschlag'
. ',' . CHANGE_REQUEST . ':' . 'ChangeRequest'
. ',' . TASK . ':' . 'Auftrag'
. ',' . ANY_ERROR . ':' . 'Fehler';
$s_status_enum_string = NEW_ . ':' . 'neu'
. ',' . ACKNOWLEDGED . ':' . 'akzeptiert'
. ',' . IN_PROCESS . ':' . 'wird bearbeitet'
. ',' . RESOLVED . ':' . 'erledigt'
. ',' . READY_FOR_TEST . ':' . 'bereit für (Re)Test'
. ',' . REJECTED . ':' . 'abgelehnt'
. ',' . CLOSED . ':' . 'geschlossen';
$s_access_levels_enum_string = REPORTER . ':' . 'Reporter'
. ',' . DEVELOPER . ':' . 'Entwickler'
. ',' . MANAGER . ':' . 'Manager'
. ',' . ADMINISTRATOR . ':' . 'Administrator';
...
I ask you to discuss my approach. Any hints or ideas?