1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
|
<?php
/**
* MantisBPlugin Class
*
* Copyright 2009, Fabien Dubois - Capgemini
* Copyright 2009-2011, Franck Villaume - Capgemini
* 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 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class MantisBTPlugin extends Plugin {
function __construct() {
$this->Plugin();
$this->name = "mantisbt";
$this->text = "MantisBT"; // To show in the tabs, use...
$this->_addHook('user_personal_links'); //to make a link to the user's personal part of the plugin
$this->_addHook('usermenu');
$this->_addHook('groupmenu'); // To put into the project tabs
$this->_addHook('groupisactivecheckbox'); // The "use ..." checkbox in editgroupinfo
$this->_addHook('groupisactivecheckboxpost'); //
$this->_addHook('userisactivecheckbox'); // The "use ..." checkbox in user account
$this->_addHook('userisactivecheckboxpost'); //
$this->_addHook('project_admin_plugins'); // to show up in the admin page fro group
$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) {
global $G_SESSION, $HTML;
$returned = false;
switch ($hookname) {
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(array('class'=> 'tabtitle', 'title' => _('Personal MantisBT page'))));
}
$returned = true;
break;
}
case "groupmenu": {
$group_id = $params['group'];
$project = group_get_object($group_id);
if (!$project || !is_object($project) || $project->isError() || !$project->isProject()) {
return;
}
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();
if ($userperm->isAdmin()) {
$params['ADMIN'][] = '/plugins/'.$this->name.'/?type=admin&group_id=' . $group_id . '&pluginname=' . $this->name;
}
}
if (isset($params['toptab'])) {
(($params['toptab'] == $this->name) ? $params['selected'] = (count($params['TITLES'])-1) : '' );
}
}
$returned = true;
break;
}
case "user_personal_links": {
// 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);
//check if the user has the plugin activated
if ($user->usesPlugin($this->name)) {
echo '<p>';
$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;
break;
}
case "project_admin_plugins": {
// this displays the link in the project admin options page to it's MantisBT administration
$group_id = $params['group_id'];
$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'), array('class' => 'tabtitle', 'title' => _('MantisBT administration page')));
echo '</p>';
}
$returned = true;
break;
}
case "site_admin_option_hook": {
echo '<li>'.$this->getAdminOptionLink().'</li>';
$returned = true;
break;
}
case "group_delete": {
$group_id = $params['group_id'];
$group = group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
if ($this->isProjectMantisCreated($group_id)) {
if ($this->removeProjectMantis($group_id)) {
$returned = true;
}
} else {
$returned = true;
}
} else {
$returned = true;
}
break;
}
case "group_update": {
$group_id = $params['group_id'];
$group_name =$params['group_name'];
$group_ispublic = $params['group_ispublic'];
$group = group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
if ($this->isProjectMantisCreated($group_id)) {
if ($this->updateProjectMantis($group_id, $group_name, $group_ispublic)) {
$returned = true;
}
} else {
$returned = true;
}
} else {
$returned = true;
}
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;
}
/**
* addUserMantisBT - inject the User into MantisBT thru SOAP
*
* @param array Configuration Array (url, soap_user, soap_password, mantisbt_password)
* @return bool success or not
*/
function addUserMantisBT($confArr) {
global $user;
$mantisbtAccount = array();
$mantisbtAccount['name'] = $user->getUnixName();
$mantisbtAccount['real_name'] = $user->getRealName();
$mantisbtAccount['email'] = $user->getEmail();
$mantisbtAccount['password'] = $confArr['mantisbt_password'];
try {
$clientSOAP = new SoapClient($confArr['url']."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$idUserMantisBT = $clientSOAP->__soapCall('mc_account_create', array("username" => $confArr['soap_user'], "password" => $confArr['soap_password'], "account" => $mantisbtAccount));
} catch (SoapFault $soapFault) {
$user->setError('addUserMantisBT::Error: ' . $soapFault->faultstring);
return false;
}
if (!isset($idUserMantisBT) || !is_int($idUserMantisBT)){
$user->setError('addUserMantisBT::Error: ' . _('Unable to create user in Mantisbt'));
return false;
}
return $idUserMantisBT;
}
/**
* addProjectMantis - inject the Group into Mantisbt thru SOAP
*
* @param array Configuration Array (url, soap_user, soap_password, sync_roles)
* @return bool success or not
*/
function addProjectMantis($groupId, $confArr) {
$groupObject = group_get_object($groupId);
$project = array();
$project['name'] = $groupObject->getPublicName();
$project['status'] = "development";
//TODO : make it works correctly and use the config soap api to get the real value.
if ($groupObject->isPublic()) {
$project['view_state'] = 10;
}else{
$project['view_state'] = 50;
}
$project['description'] = $groupObject->getDescription();
try {
$clientSOAP = new SoapClient($confArr['url']."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$idProjetMantis = $clientSOAP->__soapCall('mc_project_add', array("username" => $confArr['soap_user'], "password" => $confArr['soap_password'], "project" => $project));
} catch (SoapFault $soapFault) {
$groupObject->setError('addProjectMantis::Error: ' . $soapFault->faultstring);
return false;
}
if (!isset($idProjetMantis) || !is_int($idProjetMantis)){
$groupObject->setError('addProjectMantis::Error: ' . _('Unable to create project in Mantisbt'));
return false;
}
return $idProjetMantis;
}
function removeProjectMantis($idProjet) {
$groupObject = group_get_object($idProjet);
$localMantisbtConf = $this->getMantisBTConf($groupObject->getID());
if (!$localMantisbtConf) {
$groupObject->setError('removeProjetMantis::Error' . ' '. _('No project found'));
return false;
} else {
try {
$clientSOAP = new SoapClient($localMantisbtConf['url']."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$delete = $clientSOAP->__soapCall('mc_project_delete', array("username" => $localMantisbtConf['soap_user'], "password" => $localMantisbtConf['soap_password'], "project_id" => $localMantisbtConf['id_mantisbt']));
} catch (SoapFault $soapFault) {
$groupObject->setError('removeProjetMantis::Error' . ' '.$soapFault->faultstring);
return false;
}
if (!isset($delete)) {
$groupObject->setError('removeProjetMantis:: ' . _('No project found in MantisBT') . ' ' .$localMantisbtConf['id_mantisbt']);
return false;
} else {
$res = db_query_params('DELETE FROM plugin_mantisbt WHERE id_mantisbt = $1',
array($localMantisbtConf['id_mantisbt']));
if (!$res) {
$groupObject->setError('removeProjetMantis:: ' . _('Cannot delete in database') . ' ' .$localMantisbtConf['id_mantisbt']);
return false;
}
}
return true;
}
}
/**
* updateProjectMantis - update the Group informations into Mantisbt
* @param int id of the Group
* @param string group name
* @param int public or private
* @return bool success or not
*/
function updateProjectMantis($groupId, $groupName, $groupIspublic) {
$groupObject = group_get_object($groupId);
$projet = array();
$localMantisbtConf = $this->getMantisBTConf($groupObject->getID());
$project['name'] = $groupName;
$project['status'] = "development";
// should check the config on mantisbt side and not used hard coded values
if ($groupIspublic) {
$project['view_state'] = 10;
} else {
$project['view_state'] = 50;
}
if ($localMantisbtConf['id_mantisbt'] != 0) {
try {
$clientSOAP = new SoapClient($localMantisbtConf['url']."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$update = $clientSOAP->__soapCall('mc_project_update', array("username" => $localMantisbtConf['soap_user'], "password" => $localMantisbtConf['soap_password'], "project_id" => $localMantisbtConf['id_mantisbt'], "project" => $project));
} catch (SoapFault $soapFault) {
$groupObject->setError('updateProjectMantis::Error' . ' '. $soapFault->faultstring);
return false;
}
if (!isset($update)) {
$groupObject->setError('updateProjectMantis::Error' . ' ' . _('Update MantisBT project'));
return false;
}
} else {
$groupObject->setError('updateProjectMantis::Error ' . _('ID MantisBT project not found'));
return false;
}
return true;
}
/**
* isProjectMantisCreated - check if the Project is already created
*
* @param int the Group Id
* @return boolean created or not
*/
function isProjectMantisCreated($idProjet){
$resIdProjetMantis = db_query_params('SELECT id_mantisbt FROM plugin_mantisbt WHERE id_group = $1',
array($idProjet));
if (!$resIdProjetMantis)
return false;
if (db_numrows($resIdProjetMantis) > 0) {
return true;
}else{
return false;
}
}
/**
* getMantisBTConf - get the mantisbt configuration id for a specific group_id
*
* @param integer the group_id
* @return array the mantisbt configuration array
* @access public
*/
function getMantisBTConf($group_id) {
$group = group_get_object($group_id);
$mantisbtConfArray = array();
$resIdProjetMantis = db_query_params('SELECT * FROM plugin_mantisbt WHERE id_group = $1', array($group_id));
if (!$resIdProjetMantis) {
$group->setError('getMantisBTId::error '.db_error());
return $mantisbtConfArray;
}
$row = db_numrows($resIdProjetMantis);
if ($row == null || count($row) > 2) {
$mantisbtConfArray['id_mantisbt'] = 0;
return $mantisbtConfArray;
}
$row = db_fetch_array($resIdProjetMantis);
$mantisbtConfArray['id_mantisbt'] = $row['id_mantisbt'];
$mantisbtConfArray['sync_roles'] = $row['sync_roles'];
$mantisbtConfArray['use_global'] = $row['use_global'];
if ($mantisbtConfArray['use_global']) {
$mantisbtGlobConf = $this->getGlobalconf();
$mantisbtConfArray['url'] = $mantisbtGlobConf['url'];
$mantisbtConfArray['soap_user'] = $mantisbtGlobConf['soap_user'];
$mantisbtConfArray['soap_password'] = $mantisbtGlobConf['soap_password'];
} else {
$mantisbtConfArray['url'] = $row['url'];
$mantisbtConfArray['soap_user'] = $row['soap_user'];
$mantisbtConfArray['soap_password'] = $row['soap_password'];
}
return $mantisbtConfArray;
}
/**
* getInitDisplay - display the init page
* @return bool true only currently
*/
function getInitDisplay() {
global $gfplugins;
require_once $gfplugins.$this->name.'/view/init.php';
return true;
}
/**
* getAdminView - display the admin page
* @return bool true only currently
*/
function getAdminView() {
global $gfplugins;
require_once $gfplugins.$this->name.'/www/admin/index.php';
return true;
}
/**
* getSubMenu - display the submenu
*
* @param int enable tooltips : default NO
* @return bool true only currently
*/
function getSubMenu() {
global $HTML;
global $group_id;
global $user;
$group = group_get_object($group_id);
// submenu
$labelTitle = array();
$labelTitle[] = _('Roadmap');
$labelTitle[] = _('Tickets');
$labelPage = array();
$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();
$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();
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";
$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);
}
/**
* getHeader - initialize header and js
* @param string type : user, project (aka group)
* @return bool success or not
*/
function getHeader($type) {
global $gfplugins;
$returned = false;
use_javascript('/plugins/'.$this->name.'/scripts/MantisBTController.js');
use_stylesheet('/plugins/'.$this->name.'/style.css');
switch ($type) {
case 'project': {
global $group_id;
$params['toptab'] = $this->name;
$params['group'] = $group_id;
$params['title'] = $this->name.' Project Plugin!';
$params['pagename'] = $this->name;
$params['sectionvals'] = array(group_getname($group_id));
site_project_header($params);
$returned = true;
break;
}
case 'user': {
global $user_id;
$params['user_id'] = $user_id;
site_user_header($params);
$returned = true;
break;
}
case 'globaladmin': {
session_require_global_perm('forge_admin');
global $gfwww;
require_once($gfwww.'admin/admin_utils.php');
site_admin_header(array('title'=>_('Site Global MantisBT Admin'), 'toptab' => ''));
$returned = true;
break;
}
default: {
break;
}
}
return $returned;
}
/**
* initialize - initialize the mantisbt plugin
* create mantisbt project if needed
* save config in db
* @param int the group id
* @param array configuration array
* @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);
} 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 (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'],
$confArr['globalconf']));
if (!$result) {
$groupObject = group_get_object($group_id);
$groupObject->setError('initialize::Error: '. db_error());
return false;
}
return true;
}
return false;
}
/**
* initialize - initialize the mantisbt user
* save config in db
* @param array configuration array
* @return bool success or not
*/
function initializeUser($confArr) {
global $user;
if ($confArr['mantisbt_useglobal']) {
$globalConfArr = $this->getGlobalconf();
$confArr['url'] = $globalConfArr['url'];
$confArr['soap_user'] = $globalConfArr['soap_user'];
$confArr['soap_password'] = $globalConfArr['soap_password'];
}
if ($confArr['mantisbtcreate']) {
$idMantisBTUser = $this->addUserMantisBT($confArr);
$confArr['mantisbt_user'] = $user->getUnixName();
}
if ($idMantisBTUser || !$confArr['mantisbtcreate']) {
$result = db_query_params('insert into plugin_mantisbt_users (id_user, mantisbt_user, mantisbt_password)
values ($1, $2, $3)',
array($user->getID(),
$confArr['mantisbt_user'],
$confArr['mantisbt_password']));
if (!$result) {
$user->setError('initializeUser::Error: '. db_error());
return false;
}
return true;
}
return false;
}
/**
* updateConf - update the MantisBT plugin configuration
*
* @param int the group_id
* @param array configuration array
* @return bool success or not
*/
function updateConf($group_id, $confArr) {
$result = db_query_params('update plugin_mantisbt set url = $1 , soap_user = $2, soap_password = $3, use_global = $4
where id_group = $5',
array($confArr['url'],
$confArr['soap_user'],
$confArr['soap_password'],
$confArr['global_conf'],
$group_id));
if (!$result)
return false;
return true;
}
/**
* updateUserConf - update the MantisBT User configuration
*
* @param array configuration array
* @return bool success or not
*/
function updateUserConf($confArr) {
global $user;
$result = db_query_params('update plugin_mantisbt_users set mantisbt_user = $1 , mantisbt_password = $2
where id_user = $3',
array($confArr['mantisbt_user'],
$confArr['mantisbt_password'],
$user->getID()));
if (!$result)
return false;
return true;
}
/**
* getProjectMantisByName - find the project to link with
*
* @param array configuration array
* @return int the mantisbt id
*/
function getProjectMantisByName($group_id, $confArr) {
$groupObject = group_get_object($group_id);
try {
$clientSOAP = new SoapClient($confArr['url']."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$mantisbtProjectArr = $clientSOAP->__soapCall('mc_projects_get_user_accessible', array("username" => $confArr['soap_user'], "password" => $confArr['soap_password']));
} catch (SoapFault $soapFault) {
$groupObject->setError('getProjectMantisByName::Error: ' . $soapFault->faultstring);
return false;
}
foreach ($mantisbtProjectArr as $mantisbtProject) {
if ($mantisbtProject->name == $confArr['mantisbtname']) {
return $mantisbtProject->id;
}
}
$groupObject->setError('getProjectMantisByName::Error: '. _('MantisBT project not found'));
return false;
}
/**
* getUserConf - return the user / password for the user id mantisbt account
*
* @return array the user configuration
*/
function getUserConf() {
global $user;
$userConf = array();
$resIdUser = db_query_params('SELECT mantisbt_user, mantisbt_password FROM plugin_mantisbt_users WHERE id_user = $1', array($user->getID()));
if (!$resIdUser) {
$user->setError('getUserConf::error '.db_error());
return false;
}
$row = db_numrows($resIdUser);
if ($row == null || count($row) > 2) {
return false;
}
$row = db_fetch_array($resIdUser);
$userConf['user'] = $row['mantisbt_user'];
$userConf['password'] = $row['mantisbt_password'];
$userConf['url'] = array();
foreach ($user->getGroups() as $groupObject) {
if ($groupObject->usesPlugin($this->name)) {
$mantisbtGroupConf = $this->getMantisBTConf($groupObject->getID());
$userConf['url'][] = $mantisbtGroupConf['url'];
}
}
return $userConf;
}
/**
* getGlobalconf - return the global configuration defined at forge level
*
* @return array the global configuration array
*/
function getGlobalconf() {
$resGlobConf = db_query_params('SELECT * from plugin_mantisbt_global',array());
if (!$resGlobConf) {
return false;
}
$row = db_numrows($resGlobConf);
if ($row == null || count($row) > 2) {
return false;
}
return db_fetch_array($resGlobConf);
}
/**
* updateGlobalConf - update the global configuration in database
*
* @param array configuration array (url, soap_user, soap_password)
* @return bool true on success
*/
function updateGlobalConf($confArr) {
if (!isset($confArr['url']) || !isset($confArr['soap_user']) || !isset($confArr['soap_password']))
return false;
$res = db_query_params('truncate plugin_mantisbt_global', array());
if (!$res)
return false;
$res = db_query_params('insert into plugin_mantisbt_global (url, soap_user, soap_password)
values ($1, $2, $3)',
array(
$confArr['url'],
$confArr['soap_user'],
$confArr['soap_password'],
));
if (!$res)
return false;
return true;
}
/**
* getGlobalAdminView - display the Global Admin View
*
* @return bool true
*/
function getGlobalAdminView() {
global $gfplugins;
$user = session_get_user();
include $gfplugins.$this->name.'/view/admin/viewGlobalConfiguration.php';
return true;
}
function getAdminOptionLink() {
return util_make_link('/plugins/'.$this->name.'/?type=globaladmin', _('Global MantisBT admin'), array('class' => 'tabtitle', 'title' => _('Direct link to global configuration of this plugin')));
}
/**
* getPluginDescription - display the description of this plugin in pluginman admin page
*
* @return string the description
*/
function getPluginDescription() {
return _('Use Mantis Bugtracker as another ticket management tool.');
}
/** Widgets function **/
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
// c-file-style: "bsd"
// End:
|