*
* Copyright 2009, Fabien Dubois - Capgemini
* Copyright 2009-2011, Franck Villaume - Capgemini
- * Copyright 2011, Franck Villaume - TrivialDev
+ * Copyright 2011-2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class MantisBTPlugin extends Plugin {
$this->_addHook('group_delete');
$this->_addHook('group_update');
$this->_addHook('site_admin_option_hook');
+ $this->_addHook('widget_instance', 'myPageBox', false);
+ $this->_addHook('widgets', 'widgets', false);
}
function CallHook($hookname, &$params) {
case "usermenu": {
if ($G_SESSION->usesPlugin($this->name)) {
$param = '?type=user&user_id=' . $G_SESSION->getId() . '&pluginname=' . $this->name; // we indicate the part we're calling is the user one
- echo $HTML->PrintSubMenu(array($this->text), array('/plugins/mantisbt/index.php' . $param), array(_('Personnal MantisBT page')));
+ echo $HTML->PrintSubMenu(array($this->text), array('/plugins/mantisbt/index.php' . $param), array(array('class'=> 'tabtitle', 'title' => _('Personal MantisBT page'))));
}
$returned = true;
break;
if ($project->usesPlugin($this->name)) {
$params['TITLES'][] = $this->text;
$params['DIRS'][] = '/plugins/'.$this->name.'/?type=group&group_id=' . $group_id . '&pluginname=' . $this->name;
+ $params['TOOLTIPS'][] = _('Tickets Management');
if (session_loggedin()) {
$user = session_get_user();
$userperm = $project->getPermission($user);
if ($userperm->isAdmin()) {
- $params['TITLES'][] = $this->text . _('Admin');
$params['ADMIN'][] = '/plugins/'.$this->name.'/?type=admin&group_id=' . $group_id . '&pluginname=' . $this->name;
}
}
- }
- if ($params['toptab'] == $this->name) {
- $params['selected']=(count($params['TITLES'])-1);
+ if (isset($params['toptab'])) {
+ (($params['toptab'] == $this->name) ? $params['selected'] = (count($params['TITLES'])-1) : '' );
+ }
}
$returned = true;
break;
// this displays the link in the user's profile page to it's personal MantisBT (if you want other sto access it, youll have to change the permissions in the index.php
$userid = $params['user_id'];
$user = user_get_object($userid);
- $text = $params['text'];
//check if the user has the plugin activated
if ($user->usesPlugin($this->name)) {
echo '<p>';
- echo util_make_link('/plugins/'.$this->name.'/?user_id=$userid&type=user&pluginname='.$this->name, _('View Personal MantisBT'));
+ $arr_t = array();
+ $arr_t[] = array('title' => _('Manage your mantisbt account and follow your tickets'), 'class' => 'tabtitle');
+ echo util_make_link('/plugins/'.$this->name.'/?user_id='.$userid.'&type=user&pluginname='.$this->name, _('View Personal MantisBT'), $arr_t);
echo '</p>';
}
$returned = true;
$group = group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
echo '<p>';
- echo util_make_link("/plugins/mantisbt/?group_id=$group_id&type=admin&pluginname=".$this->name,
- _('View Admin MantisBT')
- );
+ echo util_make_link("/plugins/mantisbt/?group_id=$group_id&type=admin&pluginname=".$this->name, _('View Admin MantisBT'), array('class' => 'tabtitle', 'title' => _('MantisBT administration page')));
echo '</p>';
}
$returned = true;
break;
}
case "site_admin_option_hook": {
- echo '<li>'.util_make_link("/plugins/mantisbt/?type=globaladmin&pluginname=".$this->name,_('Global MantisBT admin')).'</li>';
+ echo '<li>'.$this->getAdminOptionLink().'</li>';
$returned = true;
break;
}
}
break;
}
+ case "widgets": {
+ $group = group_get_object($GLOBALS['group_id']);
+ if ($group->usesPlugin($this->name)) {
+ return $this->widgets($params);
+ }
+ break;
+ }
+ case "widget_instance": {
+ $group = group_get_object($GLOBALS['group_id']);
+ if ((is_object($group)? $group->usesPlugin($this->name) : false) || $G_SESSION->usesPlugin($this->name)) {
+ return $this->myPageBox($params);
+ }
+ break;
+ }
}
return $returned;
}
* @param int enable tooltips : default NO
* @return bool true only currently
*/
- function getSubMenu($enable_tooltips = 0) {
+ function getSubMenu() {
global $HTML;
global $group_id;
global $user;
$labelPage[] = "/plugins/".$this->name."/?type=group&group_id=".$group_id."&pluginname=".$this->name."&view=roadmap";
$labelPage[] = "/plugins/".$this->name."/?type=group&group_id=".$group_id."&pluginname=".$this->name;
$labelAttr = array();
- if ($enable_tooltips) {
- $labelAttr[] = array('title' => _('View the roadmap, per version tickets'), 'id' => 'roadmapView');
- $labelAttr[] = array('title' => _('View all tickets.'), 'id' => 'ticketView');
- } else {
- $labelAttr[] = array();
- $labelAttr[] = array();
- }
+ $labelAttr[] = array('title' => _('View the roadmap, per version tickets'), 'id' => 'roadmapView', 'class' => 'tabtitle-nw');
+ $labelAttr[] = array('title' => _('View all tickets.'), 'id' => 'ticketView', 'class' => 'tabtitle');
$userperm = $group->getPermission($user);
- if ( $userperm->isAdmin() ) {
+ if ($userperm->isAdmin()) {
$labelTitle[] = _('Administration');
$labelPage[] = "/plugins/".$this->name."/?type=admin&group_id=".$group_id."&pluginname=".$this->name;
$labelTitle[] = _('Statistics');
$labelPage[] = "/plugins/".$this->name."/?type=admin&group_id=".$group_id."&pluginname=".$this->name."&view=stat";
- if ($enable_tooltips) {
- $labelAttr[] = array('title' => _('Manage versions, categories and general configuration.'), 'id' => 'adminView');
- $labelAttr[] = array('title' => _('View global statistics.'), 'id' => 'statView');
- } else {
- $labelAttr[] = array();
- $labelAttr[] = array();
- }
+ $labelAttr[] = array('title' => _('Manage versions, categories and general configuration.'), 'id' => 'adminView', 'class' => 'tabtitle');
+ $labelAttr[] = array('title' => _('View global statistics.'), 'id' => 'statView', 'class' => 'tabtitle');
}
echo $HTML->subMenu($labelTitle, $labelPage, $labelAttr);
function getHeader($type) {
global $gfplugins;
$returned = false;
- html_use_tooltips();
use_javascript('/plugins/'.$this->name.'/scripts/MantisBTController.js');
use_stylesheet('/plugins/'.$this->name.'/style.css');
switch ($type) {
}
case 'user': {
global $user_id;
- $params['user'] = $user_id;
+ $params['user_id'] = $user_id;
site_user_header($params);
$returned = true;
break;
* @return bool success or not
*/
function initialize($group_id, $confArr) {
+ if ($confArr['globalconf']) {
+ $globalConfArr = $this->getGlobalconf();
+ $confArr['url'] = $globalConfArr['url'];
+ $confArr['soap_user'] = $globalConfArr['soap_user'];
+ $confArr['soap_password'] = $globalConfArr['soap_password'];
+ }
if ($confArr['mantisbtcreate']) {
$idProjectMantis = $this->addProjectMantis($group_id, $confArr);
- } else {
+ } elseif ($confArr['mantisbtname'] && sizeof($confArr['mantisbtname'])) {
$idProjectMantis = $this->getProjectMantisByName($group_id, $confArr);
+ } else {
+ $groupObject = group_get_object($group_id);
+ $groupObject->setError('initialize::Error: '. _('MantisBT project not initialized, missing params'));
}
- if ($idProjectMantis) {
- $result = db_query_params('insert into plugin_mantisbt (id_group, id_mantisbt, url, soap_user, soap_password, sync_roles)
- values ($1, $2, $3, $4, $5, $6)',
+
+ if (isset($idProjectMantis) && $idProjectMantis) {
+ $result = db_query_params('insert into plugin_mantisbt (id_group, id_mantisbt, url, soap_user, soap_password, sync_roles, use_global)
+ values ($1, $2, $3, $4, $5, $6, $7)',
array($group_id,
$idProjectMantis,
$confArr['url'],
$confArr['soap_user'],
$confArr['soap_password'],
- $confArr['sync_roles']));
- if (!$result)
+ $confArr['sync_roles'],
+ $confArr['globalconf']));
+ if (!$result) {
+ $groupObject = group_get_object($group_id);
+ $groupObject->setError('initialize::Error: '. db_error());
return false;
-
+ }
return true;
}
return false;
return $mantisbtProject->id;
}
}
- $groupObject->setError('getProjectMantisByName::Error: mantisbt project not found');
+ $groupObject->setError('getProjectMantisByName::Error: '. _('MantisBT project not found'));
return false;
}
if (!isset($confArr['url']) || !isset($confArr['soap_user']) || !isset($confArr['soap_password']))
return false;
- $res = db_query_params('truncate plugin_mantisbt_global',array());
+ $res = db_query_params('truncate plugin_mantisbt_global', array());
if (!$res)
return false;
function getGlobalAdminView() {
global $gfplugins;
$user = session_get_user();
- $use_tooltips = $user->usesTooltips();
include $gfplugins.$this->name.'/view/admin/viewGlobalConfiguration.php';
return true;
}
+
+ function getAdminOptionLink() {
+ return util_make_link('/plugins/'.$this->name.'/?type=globaladmin&pluginname='.$this->name, _('Global MantisBT admin'), array('class' => 'tabtitle', 'title' => _('Direct link to global configuration of this plugin')));
+ }
+
+ function widgets($params) {
+ $group = group_get_object($GLOBALS['group_id']);
+ if ( !$group || !$group->usesPlugin ( $this->name ) ) {
+ return false;
+ }
+ require_once('common/widget/WidgetLayoutManager.class.php');
+ if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_GROUP) {
+ $params['fusionforge_widgets'][] = 'plugin_mantisbt_project_latestissues';
+ }
+ return true;
+ }
+
+ function myPageBox($params) {
+ global $gfplugins;
+ require_once('common/widget/WidgetLayoutManager.class.php');
+ if ($params['widget'] == 'plugin_mantisbt_project_latestissues') {
+ require_once $gfplugins.$this->name.'/common/mantisbt_Widget_ProjectLastIssues.class.php';
+ $params['instance'] = new mantisbt_Widget_ProjectLastIssues($this);
+ }
+ }
}
// Local Variables:
// mode: php