1
0
Files

127 lines
4.6 KiB
PHP
Raw Permalink Normal View History

2015-07-24 15:52:57 +02:00
<?php
2016-09-14 13:27:39 +02:00
require_once ('classes' . DIRECTORY_SEPARATOR . 'RelationshipsUtils' . DIRECTORY_SEPARATOR . 'RelationshipsUtils.php');
2015-07-24 15:52:57 +02:00
class RelationshipColumnViewPlugin extends MantisPlugin
{
function register()
{
$this->name = 'Relationship Column View';
$this->description = 'A simple column extender for relationships of issues';
$this->page = 'config';
2017-03-10 15:02:44 +01:00
$this->version = '1.1.2';
2015-07-24 15:52:57 +02:00
$this->requires = array
(
2017-03-10 15:02:44 +01:00
'MantisCore' => '1.2.0, <= 2.99.99'
2015-07-24 15:52:57 +02:00
);
$this->author = 'Rainer Dierck';
$this->contact = 'rainer.dierck@friends-at-net.de';
$this->url = '';
}
function hooks( )
{
$hooks = array
( 'EVENT_LAYOUT_PAGE_FOOTER' => 'footer',
2015-07-24 16:36:09 +02:00
'EVENT_REPORT_BUG_FORM' => 'report_bug_form',
'EVENT_REPORT_BUG' => 'report_bug',
'EVENT_UPDATE_BUG_FORM' => 'update_bug_form',
'EVENT_UPDATE_BUG' => 'update_bug',
2015-07-24 15:52:57 +02:00
2015-07-24 16:36:09 +02:00
'EVENT_VIEW_BUG_DETAILS' => 'view_bug',
'EVENT_VIEW_BUG_EXTRA' => 'view_bug_extra',
'EVENT_VIEW_BUGNOTES_START' => 'view_bugnotes_start',
'EVENT_VIEW_BUGNOTE' => 'view_bugnote',
2015-07-24 15:52:57 +02:00
2015-07-24 16:36:09 +02:00
'EVENT_BUGNOTE_ADD_FORM' => 'bugnote_add_form',
'EVENT_BUGNOTE_ADD' => 'bugnote_add',
'EVENT_BUGNOTE_EDIT_FORM' => 'bugnote_edit_form',
'EVENT_BUGNOTE_EDIT' => 'bugnote_edit',
2015-07-24 15:52:57 +02:00
2015-07-24 16:36:09 +02:00
'EVENT_MANAGE_PROJECT_CREATE_FORM' => 'project_create_form',
'EVENT_MANAGE_PROJECT_CREATE' => 'project_update',
'EVENT_MANAGE_PROJECT_UPDATE_FORM' => 'project_update_form',
'EVENT_MANAGE_PROJECT_UPDATE' => 'project_update',
2015-07-27 15:04:12 +02:00
'EVENT_LAYOUT_RESOURCES' => 'event_layout_resources',
2015-07-24 15:52:57 +02:00
'EVENT_FILTER_COLUMNS' => 'add_columns'
);
return $hooks;
}
2015-07-24 16:36:09 +02:00
function init ()
2015-07-27 15:04:12 +02:00
{ // Get path to core folder
2015-07-24 16:36:09 +02:00
$t_core_path = config_get_global ('plugin_path')
2015-07-24 15:52:57 +02:00
. plugin_get_current ()
. DIRECTORY_SEPARATOR
. 'core'
. DIRECTORY_SEPARATOR;
2015-07-24 16:36:09 +02:00
// Include constants
require_once ($t_core_path . 'constant_api.php');
}
2015-07-24 15:52:57 +02:00
2015-07-24 16:36:09 +02:00
function config()
2015-07-24 15:52:57 +02:00
{
2015-07-24 16:36:09 +02:00
return
2015-07-24 15:52:57 +02:00
array
(
2015-07-27 13:05:17 +02:00
'ShowInFooter' => ON,
'ShowRelationshipColumn' => ON,
2016-09-14 13:27:39 +02:00
'ShowRelationships' => ON,
2015-07-27 13:05:17 +02:00
'ShowRelationshipsColorful' => ON,
2016-09-14 13:27:39 +02:00
'ShowRelationshipIcons' => ON,
2015-07-30 11:13:19 +02:00
'ShowRelationshipsControl' => ON,
2015-07-27 13:05:17 +02:00
'RelationshipColumnAccessLevel' => ADMINISTRATOR
2015-07-24 15:52:57 +02:00
);
2015-07-24 16:36:09 +02:00
}
2015-07-24 15:52:57 +02:00
// --- hooks ---------------------------------------------------------------
2015-07-24 16:36:09 +02:00
2015-07-24 15:52:57 +02:00
function footer ()
{
$t_project_id = helper_get_current_project ();
$t_user_id = auth_get_current_user_id ();
2015-07-27 13:05:17 +02:00
$t_user_has_level = user_get_access_level ($t_user_id, $t_project_id) >= plugin_config_get ('RelationshipColumnAccessLevel', PLUGINS_RELATIONSHIPCOLUMNVIEW_THRESHOLD_LEVEL_DEFAULT);
2015-07-24 15:52:57 +02:00
if ( plugin_config_get ('ShowInFooter') == 1
2015-07-24 16:31:58 +02:00
&& $t_user_has_level
2015-07-24 15:52:57 +02:00
)
{
2017-03-10 15:02:44 +01:00
return '<address>' . $this->name . ' ' . $this->version . ' Copyright &copy; 2015-2017 by <a href="mailto://' . $this->contact . '">' . $this->author . '</a></address>';
2015-07-24 15:52:57 +02:00
}
2015-10-16 10:48:03 +02:00
return null;
2015-07-24 15:52:57 +02:00
}
function event_layout_resources ()
{
2016-04-29 00:21:43 +02:00
echo '<link rel="stylesheet" href="' . RELATIONSHIPCOLUMNVIEW_PLUGIN_URL . 'css/RelationshipColumnView.css"/>' . "\n";
2015-07-24 15:52:57 +02:00
}
2015-07-24 16:36:09 +02:00
function add_columns ()
2015-07-24 15:52:57 +02:00
{
$t_project_id = helper_get_current_project ();
$t_user_id = auth_get_current_user_id ();
2015-07-27 13:05:17 +02:00
$t_user_has_level = user_get_access_level ($t_user_id, $t_project_id) >= plugin_config_get ('RelationshipColumnAccessLevel', PLUGINS_RELATIONSHIPCOLUMNVIEW_THRESHOLD_LEVEL_DEFAULT);
2015-07-24 16:36:09 +02:00
$t_result = array ();
2015-07-24 15:52:57 +02:00
2015-07-24 16:36:09 +02:00
if ( plugin_config_get ('ShowRelationshipColumn') == gpc_get_int ('ShowRelationshipColumn', ON)
2015-07-24 16:31:58 +02:00
&& $t_user_has_level
2015-07-24 15:52:57 +02:00
)
{
2015-07-27 13:05:17 +02:00
if ('1.2.' == substr (MANTIS_VERSION, 0, 4))
2017-01-10 15:25:39 +01:00
{ // 1.2.x
2016-09-14 13:27:39 +02:00
require_once ('classes' . DIRECTORY_SEPARATOR . 'RelationshipColumn.class.1.2.0.php');
2017-01-10 15:25:39 +01:00
}
2015-07-27 13:05:17 +02:00
else
2017-01-10 15:25:39 +01:00
{ // 1.3.x & 2.0.x
2016-09-14 13:27:39 +02:00
require_once ('classes' . DIRECTORY_SEPARATOR . 'RelationshipColumn.class.1.3.0.php');
2017-01-10 15:25:39 +01:00
}
2015-07-24 16:36:09 +02:00
$t_result[] = 'RelationshipColumn';
}
return $t_result;
}
2015-07-24 15:52:57 +02:00
}