[Fusionforge-commits] r11587 - in trunk/src/plugins/mantisbt: common www
Franck VILLAUME
nerville at libremir.placard.fr.eu.org
Sat Nov 20 13:19:11 CET 2010
Author: nerville
Date: 2010-11-20 13:19:11 +0100 (Sat, 20 Nov 2010)
New Revision: 11587
Modified:
trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
trunk/src/plugins/mantisbt/common/mantisbt-init.php
trunk/src/plugins/mantisbt/www/index.php
Log:
starting cleanup mantisbt
Modified: trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
===================================================================
--- trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php 2010-11-19 17:32:32 UTC (rev 11586)
+++ trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php 2010-11-20 12:19:11 UTC (rev 11587)
@@ -1,9 +1,10 @@
<?php
-
/**
* MantisBPlugin Class
*
- * Copyright 2009 - 2010 (c) : Franck Villaume - Capgemini
+ * Copyright 2009, Fabien Dubois - Capgemini
+ * Copyright 2009-2010, Franck Villaume - Capgemini
+ * http://fusionforge.org
*
* This file is part of FusionForge.
*
@@ -22,6 +23,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/*
+ * @todo : need a massive cleanup
+ * deal correctly with password (might need direct db access ?)
+ * limit non SOAP call aka direct db access to mantisbt
+ */
+
require_once 'include/database-pgsql.php';
class MantisBTPlugin extends Plugin {
@@ -29,9 +37,9 @@
$this->Plugin() ;
$this->name = "mantisbt" ;
$this->text = "MantisBT" ; // To show in the tabs, use...
- $this->hooks[] = "user_personal_links";//to make a link to the user's personal part of the plugin
+ $this->hooks[] = "user_personal_links"; //to make a link to the user's personal part of the plugin
$this->hooks[] = "usermenu" ;
- $this->hooks[] = "groupmenu" ; // To put into the project tabs
+ $this->hooks[] = "groupmenu" ; // To put into the project tabs
$this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
$this->hooks[] = "groupisactivecheckboxpost" ; //
$this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
@@ -49,7 +57,7 @@
function CallHook ($hookname, $params) {
global $use_mantisbtplugin,$G_SESSION,$HTML;
switch ($hookname) {
- case "usermenu":
+ case "usermenu": {
$text = $this->text; // this is what shows in the tab
if ($G_SESSION->usesPlugin($this->name)) {
$param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
@@ -57,28 +65,27 @@
array ('/plugins/mantisbt/index.php' . $param ));
}
break;
-
- case "groupmenu":
+ }
+ case "groupmenu": {
$group_id=$params['group'];
- $project = &group_get_object($group_id);
+ $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&id=' . $group_id . "&pluginname=" . $this->name;
}
if ($params['toptab'] == $this->name) {
- $params['selected']=(count($params['TITLES'])-1);
- }
+ $params['selected']=(count($params['TITLES'])-1);
+ }
break;
-
- case "groupisactivecheckbox":
+ }
+ case "groupisactivecheckbox": {
//Check if the group is active
// this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
- $group_id=$params['group'];
- $group = &group_get_object($group_id);
+ $group_id = $params['group'];
+ $group = group_get_object($group_id);
echo "<tr>";
echo "<td>";
echo ' <input type="CHECKBOX" name="use_mantisbtplugin" value="1" ';
@@ -93,36 +100,36 @@
echo "</td>";
echo "</tr>";
break;
-
- case "groupisactivecheckboxpost":
+ }
+ case "groupisactivecheckboxpost": {
// this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
- $group_id=$params['group'];
- $group = &group_get_object($group_id);
+ $group_id = $params['group'];
+ $group = group_get_object($group_id);
$use_mantisbtplugin = getIntFromRequest('use_mantisbtplugin');
if ( $use_mantisbtplugin == "1" ) {
if (! $group->usesPlugin($this->name)) {
// activation plugin
$group->setPluginUse($this->name, true);
-
- // ajout du projet mantis s'il n'existe pas
+
+ // add project in mantis if does not exists
if (!isProjetMantisCreated($group->data_array['group_id'])){
addProjetMantis($group->data_array['group_id'],$group->data_array['group_name'],$group->data_array['is_public'], $group->data_array['short_description']);
}
- // mise a jour des utilisateurs avec les roles
+ // update users and roles in mantis
$members = array ();
foreach($group->getMembers() as $member){
$members[] = $member->data_array['user_name'];
}
- //updateUsersProjetMantis($group->data_array['group_id'],$members);
+ updateUsersProjetMantis($group->data_array['group_id'],$members);
}
} else if ( $use_mantisbtplugin == "0" ) {
$group->setPluginUse ( $this->name, false );
}
break;
-
- case "userisactivecheckbox":
+ }
+ case "userisactivecheckbox": {
//check if user is active
- // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
+ // this code creates the checkbox in the user account maintenance page to activate/deactivate the plugin
$user = $params['user'];
echo "<tr>";
echo "<td>";
@@ -135,8 +142,8 @@
echo "</td>";
echo "</tr>";
break;
-
- case "userisactivecheckboxpost":
+ }
+ case "userisactivecheckboxpost": {
// this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
$user = $params['user'];
$use_mantisbtplugin = getIntFromRequest('use_mantisbtplugin');
@@ -145,9 +152,9 @@
} else {
$user->setPluginUse ( $this->name, false );
}
- break;
-
- case "user_personal_links":
+ 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);
@@ -161,8 +168,8 @@
echo '</p>';
}
break;
-
- case "project_admin_plugins":
+ }
+ 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);
@@ -173,8 +180,8 @@
echo '<br/>';
}
break;
-
- case "group_approved":
+ }
+ case "group_approved": {
$group_id=$params['group_id'];
$group = &group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
@@ -182,17 +189,16 @@
if (!isProjetMantisCreated($group->data_array['group_id'])){
addProjetMantis($group->data_array['group_id'],$group->data_array['group_name'],$group->data_array['is_public'], $group->data_array['short_description']);
}
- exit;
// mise a jour des utilisateurs avec les roles
$members = array ();
foreach($group->getMembers() as $member){
$members[] = $member->data_array['user_name'];
}
- //updateUsersProjetMantis($group->data_array['group_id'],$members);
+ updateUsersProjetMantis($group->data_array['group_id'],$members);
}
break;
-
- case "change_cal_permission":
+ }
+ case "change_cal_permission": {
// mise a jour des utilisateurs avec les roles
$group_id=$params[1];
$group = &group_get_object($group_id);
@@ -202,21 +208,21 @@
}
//updateUsersProjetMantis($group->data_array['group_id'],$members);
break;
-
- // mise a jour de l'adresse mail utilisateur
- case "change_cal_mail":
- $user_id=$params[1];
- updateUserInMantis($user_id);
- break;
-
+ }
+ // mise a jour de l'adresse mail utilisateur
+ case "change_cal_mail":
+ $user_id=$params[1];
+ updateUserInMantis($user_id);
+ break;
+ }
case "add_cal_link_father":
- case "del_cal_link_father":
+ case "del_cal_link_father": {
$sub_group_id = $params[0];
$group_id = $params[1];
refreshHierarchyMantisBt();
break;
-
- case "group_delete":
+ }
+ case "group_delete": {
$group_id=$params['group_id'];
$group = &group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
@@ -225,8 +231,8 @@
}
}
break;
-
- case "group_update":
+ }
+ case "group_update": {
$group_id=$params['group_id'];
$group = &group_get_object($group_id);
if ($group->usesPlugin($this->name)) {
@@ -235,12 +241,13 @@
}
}
break;
+ }
}
}
}
function addProjetMantis($idProjet, $nomProjet, $isPublic, $description) {
-
+
$projet = array();
$project['name'] = $nomProjet;
$project['status'] = "development";
@@ -253,16 +260,16 @@
$project['description'] = $description;
- try{
- $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
- $idProjetMantis = $clientSOAP->__soapCall('mc_project_add', array("username" => forge_get_config('adminsoap_user','mantisbt'), "password" => forge_get_config('adminsoap_password','mantisbt'), "project" => $project));
- }catch (SoapFault $soapFault) {
+ try {
+ $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
+ $idProjetMantis = $clientSOAP->__soapCall('mc_project_add', array("username" => forge_get_config('adminsoap_user', 'mantisbt'), "password" => forge_get_config('adminsoap_password', 'mantisbt'), "project" => $project));
+ } catch (SoapFault $soapFault) {
echo $soapFault->faultstring;
- exit;
- }
+ exit;
+ }
if (!isset($idProjetMantis) || !is_int($idProjetMantis)){
echo "Error : Impossible de créer le projet dans mantis";
- exit;
+ exit;
}else{
db_query_params('INSERT INTO group_mantisbt (id_group, id_mantisbt) VALUES ($1,$2)',
array($idProjet, $idProjetMantis));
@@ -274,23 +281,22 @@
$resIdProjetMantis = db_query_params('SELECT group_mantisbt.id_mantisbt FROM group_mantisbt WHERE group_mantisbt.id_group = $1',
array($idProjet));
-
+
echo db_error();
$row = db_fetch_array($resIdProjetMantis);
if ($row == null || count($row)>2) {
- echo "Erreur : impossible de retrouver le projet au sein de mantisbt";
+ echo 'removeProjetMantis:: ' . _('No project found');
}else{
$idMantisbt = $row['id_mantisbt'];
- try{
- $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
+ try {
+ $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$delete = $clientSOAP->__soapCall('mc_project_delete', array("username" => forge_get_config('adminsoap_user','mantisbt'), "password" => forge_get_config('adminsoap_password','mantisbt'), "project_id" => $idMantisbt));
- }catch (SoapFault $soapFault) {
+ } catch (SoapFault $soapFault) {
echo $soapFault->faultstring;
}
if (!isset($delete)){
- echo "Error : Impossible de supprimer le projet dans mantis : ".$idProjet;
- echo "<br/>";
+ echo 'removeProjetMantis:: ' . _('No project found in MantisBT') . ' ' .$idProjet;
}else{
db_query_params('DELETE FROM group_mantisbt WHERE group_mantisbt.id_mantisbt = $1',
array($idMantisbt));
@@ -304,7 +310,7 @@
$projet = array();
$project['name'] = $nomProjet;
$project['status'] = "development";
-
+
if ($isPublic == "1"){
$project['view_state'] = 10;
}else{
@@ -316,23 +322,22 @@
echo db_error();
$row = db_fetch_array($resIdProjetMantis);
if ($row == null || count($row)>2) {
- echo "Erreur : impossible de retrouver le projet au sein de mantisbt";
+ echo 'updateProjetMantis:: ' . _('No project found');
}else{
$idMantisbt = $row['id_mantisbt'];
- try{
- $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
+ try {
+ $clientSOAP = new SoapClient("http://".forge_get_config('server','mantisbt')."/api/soap/mantisconnect.php?wsdl", array('trace'=>true, 'exceptions'=>true));
$update = $clientSOAP->__soapCall('mc_project_update', array("username" => forge_get_config('adminsoap_user','mantisbt'), "password" => forge_get_config('adminsoap_password','mantisbt'), "project_id" => $idMantisbt, "project" => $project));;
} catch (SoapFault $soapFault) {
echo $soapFault->faultstring;
}
if (!isset($update))
- echo "Error : update MantisBT projet";
-
+ echo 'updateProjetMantis::Error ' . _('Update MantisBT project');
}
}
function isProjetMantisCreated($idProjet){
-
+
$resIdProjetMantis = db_query_params('SELECT group_mantisbt.id_mantisbt FROM group_mantisbt WHERE group_mantisbt.id_group = $1',
array($idProjet));
echo db_error();
@@ -346,7 +351,7 @@
}
function getIdProjetMantis($idProjet){
-
+
$resIdProjetMantis = db_query_params('SELECT group_mantisbt.id_mantisbt FROM group_mantisbt WHERE group_mantisbt.id_group = $1',
array($idProjet));
echo db_error();
@@ -362,23 +367,23 @@
function updateUserInMantis($user_id) {
global $sys_mantisbt_host, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_db_port, $sys_mantisbt_db_name;
- // recuperation du nouveau mail
+ // recuperation du nouveau mail
$resUser = db_query_params ('SELECT user_name, email FROM users WHERE user_id = $1',array($user_id));
echo db_error();
$row = db_fetch_array($resUser);
$dbConnection = db_connect_host($sys_mantisbt_db_name, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_host, $sys_mantisbt_db_port);
if(!$dbConnection){
- $errMantis1 = "Error : Could not open connection" . db_error($dbConnection);
+ $errMantis1 = "Error : Could not open connection" . db_error($dbConnection);
echo $errMantis1;
db_rollback($dbConnection);
} else {
- db_query_params('UPDATE mantis_user_table set email = $1 where username = $2',array($row['email'],$row['user_name']),'-1','0',$dbConnection);
- echo db_error();
- }
+ db_query_params('UPDATE mantis_user_table set email = $1 where username = $2',array($row['email'],$row['user_name']),'-1','0',$dbConnection);
+ echo db_error();
+ }
}
function updateUsersProjetMantis($idProjet, $members) {
-
+
global $role;
global $sys_mantisbt_host, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_db_port, $sys_mantisbt_db_name;
@@ -392,16 +397,16 @@
$role['Collaborateur'] = 55;
$role['Rapporteur'] = 55;
}
-
+
// etat forge
$stateForge = array ();
foreach ($members as $key => $member){
$resUserRole = db_query_params('SELECT role.role_name
- FROM role, user_group, users
- WHERE users.user_name = $1
- AND ( user_group.user_id = users.user_id AND user_group.group_id = $2 )
- AND user_group.role_id = role.role_id',
- array($member,$idProjet));
+ FROM role, user_group, users
+ WHERE users.user_name = $1
+ AND ( user_group.user_id = users.user_id AND user_group.group_id = $2 )
+ AND user_group.role_id = role.role_id',
+ array($member, $idProjet));
echo db_error();
$row = db_fetch_array($resUserRole);
$stateForge[$member]['name'] = $member;
@@ -411,29 +416,29 @@
$stateMantis = array ();
$dbConnection = db_connect_host($sys_mantisbt_db_name, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_host, $sys_mantisbt_db_port);
if(!$dbConnection){
- $errMantis1 = "Error : Could not open connection" . db_error($dbConnection);
+ $errMantis1 = _('Error : Could not open connection') . db_error($dbConnection);
echo $errMantis1;
db_rollback($dbConnection);
}else{
$result = pg_delete($dbConnection,"mantis_project_user_list_table",array("project_id"=>$idMantis));
if (!$result){
- echo "Error : Impossible de nettoyer les roles dans mantisbt";
+ echo 'updateUsersProjetMantis::Error '. _('Unable to clean roles in Mantisbt');
}else{
foreach($stateForge as $member => $array){
// recuperation de l'id user dans mantis
$resultIdUser = db_query_params('SELECT mantis_user_table.id FROM mantis_user_table WHERE mantis_user_table.username = $1',
- array($member),'-1',0,$dbConnection);
-
+ array($member), '-1', 0, $dbConnection);
+
$rowIdUser = db_fetch_array($resultIdUser);
$idUser = $rowIdUser['id'];
// insertion de la relation
$resultInsert = pg_insert($dbConnection,
"mantis_project_user_list_table",
- array ("project_id" => $idMantis, "user_id" => $idUser, "access_level" => $role[$array['role']])
+ array("project_id" => $idMantis, "user_id" => $idUser, "access_level" => $role[$array['role']])
);
if (!isset($resultInsert))
- echo "Error : Impossible de mettre à jour les roles dans mantisbt";
+ echo 'updateUsersProjetMantis::Error '. _('Unable to update roles in mantisbt');
}
}
@@ -441,48 +446,48 @@
}
function refreshHierarchyMantisBt(){
- global $sys_mantisbt_host, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_db_port, $sys_mantisbt_db_name;
+ global $sys_mantisbt_host, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_db_port, $sys_mantisbt_db_name;
- $hierarchies=db_query_params('SELECT project_id, sub_project_id FROM plugin_projects_hierarchy WHERE activated=true',array());
- echo db_error();
- $dbConnection = db_connect_host($sys_mantisbt_db_name, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_host, $sys_mantisbt_db_port);
- if(!$dbConnection){
- db_rollback($dbConnection);
- return false;
- }
+ $hierarchies=db_query_params('SELECT project_id, sub_project_id FROM plugin_projects_hierarchy WHERE activated=true',array());
+ echo db_error();
+ $dbConnection = db_connect_host($sys_mantisbt_db_name, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_host, $sys_mantisbt_db_port);
+ if(!$dbConnection){
+ db_rollback($dbConnection);
+ return false;
+ }
- db_begin($dbConnection);
- db_query_params('TRUNCATE TABLE mantis_project_hierarchy_table',array() , '-1', 0, $dbConnection);
- while ($hierarchy = db_fetch_array($hierarchies)) {
- $result = db_query_params ('INSERT INTO mantis_project_hierarchy_table (child_id, parent_id, inherit_parent) VALUES ($1, $2, $3)',
- array (getIdProjetMantis($hierarchy['sub_project_id']), getIdProjetMantis($hierarchy['project_id']), 1),
- '-1',
- 0,
- $dbConnection) ;
+ db_begin($dbConnection);
+ db_query_params('TRUNCATE TABLE mantis_project_hierarchy_table', array() , '-1', 0, $dbConnection);
+ while ($hierarchy = db_fetch_array($hierarchies)) {
+ $result = db_query_params ('INSERT INTO mantis_project_hierarchy_table (child_id, parent_id, inherit_parent) VALUES ($1, $2, $3)',
+ array (getIdProjetMantis($hierarchy['sub_project_id']), getIdProjetMantis($hierarchy['project_id']), 1),
+ '-1',
+ 0,
+ $dbConnection);
- if (!$result) {
- $this->setError(_('Insert Failed') . db_error($dbConnection));
- db_rollback();
- return false;
- }
- }
+ if (!$result) {
+ $this->setError(_('Insert Failed') . db_error($dbConnection));
+ db_rollback();
+ return false;
+ }
+ }
- db_commit($dbConnection);
- pg_close($dbConnection);
- return true;
+ db_commit($dbConnection);
+ pg_close($dbConnection);
+ return true;
}
function getGroupIdByName($name){
- $child_query = db_query_params('select group_id from groups where group_name = $1',array($name));
- echo db_error();
- $row = db_fetch_array($child_query);
+ $child_query = db_query_params('select group_id from groups where group_name = $1', array($name));
+ echo db_error();
+ $row = db_fetch_array($child_query);
- if ($row == null) {
+ if ($row == null) {
return 0;
- }else{
+ }else{
return $row['group_id'];
- }
+ }
}
// Local Variables:
Modified: trunk/src/plugins/mantisbt/common/mantisbt-init.php
===================================================================
--- trunk/src/plugins/mantisbt/common/mantisbt-init.php 2010-11-19 17:32:32 UTC (rev 11586)
+++ trunk/src/plugins/mantisbt/common/mantisbt-init.php 2010-11-20 12:19:11 UTC (rev 11587)
@@ -1,9 +1,9 @@
<?php
-
/**
*
- * Copyright 2010, Capgemini
- * Author: Franck Villaume - Capgemini
+ * Copyright 2009, Fabien Dubois - Capgemini
+ * Copyright 2010, Franck Villaume - Capgemini
+ * http://fusionforge.org
*
* This file is part of FusionForge.
*
@@ -23,11 +23,11 @@
*/
global $gfplugins;
-require_once $gfplugins.'mantisbt/common/MantisBTPlugin.class.php' ;
+require_once $gfplugins.'mantisbt/common/MantisBTPlugin.class.php';
-$MantisBTPluginObject = new MantisBTPlugin ;
+$MantisBTPluginObject = new MantisBTPlugin;
-register_plugin ($MantisBTPluginObject) ;
+register_plugin($MantisBTPluginObject);
// Local Variables:
// mode: php
Modified: trunk/src/plugins/mantisbt/www/index.php
===================================================================
--- trunk/src/plugins/mantisbt/www/index.php 2010-11-19 17:32:32 UTC (rev 11586)
+++ trunk/src/plugins/mantisbt/www/index.php 2010-11-20 12:19:11 UTC (rev 11587)
@@ -2,10 +2,10 @@
/*
* MantisBT plugin
*
- * Copyright 2010, Capgemini
- * Authors: Franck Villaume - Capgemini
- * Fabien Dubois - Capgemini
- * Antoine Mercadal - Capgemini
+ * Copyright 2009-2010, Franck Villaume - Capgemini
+ * Copyright 2009, Fabien Dubois - Capgemini
+ * Copyright 2010, Antoine Mercadal - Capgemini
+ * http://fusionforge.org
*
* This file is part of FusionForge.
*
@@ -34,8 +34,8 @@
$params['toptab']='mantisbt';
$params['group']=$id;
/*
- Show horizontal links
- */
+ * Show horizontal links
+ */
site_project_header($params);
}
@@ -45,7 +45,7 @@
$params['toptab']='mantisbt';
$params['user']=$user_id;
/*
- Show horizontal links
+ * Show horizontal links
*/
site_user_header($params);
}
@@ -72,120 +72,120 @@
$error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
$warning_msg = htmlspecialchars(getStringFromRequest('warning_msg'));
-//$password = getPassword($user);
$password = '';
$username = $user->getUnixName();
if (!$type) {
- exit_missing_params($_SERVER['HTTP_REFERER'],array('No TYPE specified'),'mantisbt');
+ exit_missing_params($_SERVER['HTTP_REFERER'], array('No TYPE specified'),'mantisbt');
} elseif (!$id) {
- exit_missing_params($_SERVER['HTTP_REFERER'],array('No ID specified'),'mantisbt');
+ exit_missing_params($_SERVER['HTTP_REFERER'], array('No ID specified'),'mantisbt');
} else {
- switch ($type) {
- case 'group':
- $group = group_get_object($id);
- if ( !$group) {
- exit_no_group();
- }
- if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the MantisBT plugin active
- exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'),$pluginname),'home');
- }
- $userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
- if ( !$userperm->IsMember()) {
+ switch ($type) {
+ case 'group': {
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_no_group();
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the MantisBT plugin active
+ exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'),$pluginname),'home');
+ }
+ $userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
+ if ( !$userperm->IsMember()) {
exit_permission_denied(_('You are not a member of this project'),'home');
- }
- // other perms checks here...
- mantisbt_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
-
- // recuperer les info de URL
- $sort = getStringFromRequest('sort');
- $dir = getStringFromRequest('dir');
- $action = getStringFromRequest('action');
- $idBug = getStringFromRequest('idBug');
-
- $idNote = getStringFromRequest('idNote');
- $idAttachment = getStringFromRequest('idAttachment');
- $actionAttachment = getStringFromRequest('actionAttachment');
- $page = getStringFromRequest('page');
+ }
+ // other perms checks here...
+ mantisbt_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
- // Si la variable $_GET['page'] existe...
- if($page != null && $page != ''){
- $pageActuelle=intval($page);
- }
- else {
- $pageActuelle=1; // La page actuelle est la n°1
- }
+ // URL analysis
+ $sort = getStringFromRequest('sort');
+ $dir = getStringFromRequest('dir');
+ $action = getStringFromRequest('action');
+ $idBug = getStringFromRequest('idBug');
+ $idNote = getStringFromRequest('idNote');
+ $idAttachment = getStringFromRequest('idAttachment');
+ $actionAttachment = getStringFromRequest('actionAttachment');
+ $page = getStringFromRequest('page');
- $format = "%07d";
+ // Si la variable $_GET['page'] existe...
+ if($page != null && $page != ''){
+ $pageActuelle=intval($page);
+ }
+ else {
+ $pageActuelle=1; // La page actuelle est la n°1
+ }
- if($idProjetMantis == 0){
- exit_error(_('Projet non initialisé. Pour forcer son activation, il faut désactiver/activer mantis pour ce projet'),'home');
- } else if (is_int($password)){
- exit_error(_('Impossible de récupérer les identifiants de connexions depuis le LDAP'),'home');
- } else {
- // do the job
- include ('mantisbt/www/group/index.php');
- }
- break;
- case 'user':
- $realuser = user_get_object($id);//
- if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
- exit_error(sprintf(_('First activate the User\'s %s plugin through Account Maintenance Page'),$pluginname),'my');
- }
- if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private MantisBT part of this user
- exit_permission_denied(sprintf(_('You cannot access other user\'s personal %s'),$pluginname),'my');
- }
- mantisbt_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+ $format = "%07d";
- //$password = getPasswordFromLDAP($realuser);
+ if($idProjetMantis == 0){
+ exit_error(_('Uninitialized Project. Force his activation by desactivate/activate mantisbt for this project'),'home');
+ } else if (is_int($password)){
+ exit_error(_('Impossible de récupérer les identifiants de connexions depuis le LDAP'),'home');
+ } else {
+ // do the job
+ include ('mantisbt/www/group/index.php');
+ }
+ break;
+ }
+ case 'user': {
+ $realuser = user_get_object($id);//
+ if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+ exit_error(sprintf(_('First activate the User\'s %s plugin through Account Maintenance Page'),$pluginname),'my');
+ }
+ if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private MantisBT part of this user
+ exit_permission_denied(sprintf(_('You cannot access other user\'s personal %s'),$pluginname),'my');
+ }
+ mantisbt_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+
$password ='';
- $username = $realuser->getUnixName();
+ $username = $realuser->getUnixName();
- // recuperer les info de URL
- $sort = getStringFromRequest('sort');
- $dir = getStringFromRequest('dir');
- $action = getStringFromRequest('action');
- $idBug = getStringFromRequest('idBug');
+ // URL analysis
+ $sort = getStringFromRequest('sort');
+ $dir = getStringFromRequest('dir');
+ $action = getStringFromRequest('action');
+ $idBug = getStringFromRequest('idBug');
- $idNote = getStringFromRequest('idNote');
- $page = getStringFromRequest('page');
- // Si la variable $_GET['page'] existe...
- if($page != null && $page != ''){
- $pageActuelle=intval($page);
- } else {
- $pageActuelle=1; // La page actuelle est la n°1
- }
+ $idNote = getStringFromRequest('idNote');
+ $page = getStringFromRequest('page');
+ // Si la variable $_GET['page'] existe...
+ if($page != null && $page != ''){
+ $pageActuelle=intval($page);
+ } else {
+ $pageActuelle=1; // La page actuelle est la n°1
+ }
- $format = "%07d";
+ $format = "%07d";
- if (!is_int($password)){
- // do the job
- include ('mantisbt/www/user/index.php');
- } else {
- exit_error(_('Impossible de récupérer les identifiants de connexions depuis le LDAP'),'home');
- }
- break;
- case 'admin':
- $group = group_get_object($id);
- if ( !$group) {
+ if (!is_int($password)){
+ // do the job
+ include ('mantisbt/www/user/index.php');
+ } else {
+ exit_error(_('Impossible de récupérer les identifiants de connexions depuis le LDAP'),'home');
+ }
+ break;
+ }
+ case 'admin': {
+ $group = group_get_object($id);
+ if ( !$group) {
exit_no_group();
- }
- if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the MantisBT plugin active
- exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'),$pluginname),'home');
- }
- $userperm = $group->getPermission($user);//we'll check if the user belongs to the group
- if ( !$userperm->IsMember()) {
- exit_permission_denied(_('You are not a member of this project'));
- }
- //only project admin can access here
- if ( $userperm->isAdmin() ) {
- // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
- mantisbt_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
- include ('mantisbt/www/admin/index.php');
- } else {
- exit_permission_denied(_('You are not Admin of this project'),'home');
- }
- break;
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the MantisBT plugin active
+ exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'),$pluginname),'home');
+ }
+ $userperm = $group->getPermission($user);//we'll check if the user belongs to the group
+ if ( !$userperm->IsMember()) {
+ exit_permission_denied(_('You are not a member of this project'));
+ }
+ //only project admin can access here
+ if ( $userperm->isAdmin() ) {
+ // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+ mantisbt_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ include ('mantisbt/www/admin/index.php');
+ } else {
+ exit_permission_denied(_('You are not Admin of this project'),'home');
+ }
+ break;
+ }
}
}
More information about the Fusionforge-commits
mailing list