[Fusionforge-commits] r14019 - in trunk/src/plugins/projects_hierarchy: common view/admin www

Franck VILLAUME nerville at fusionforge.org
Sun Jul 31 20:16:50 CEST 2011


Author: nerville
Date: 2011-07-31 20:16:49 +0200 (Sun, 31 Jul 2011)
New Revision: 14019

Added:
   trunk/src/plugins/projects_hierarchy/view/admin/viewProjectConfiguration.php
Modified:
   trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
   trunk/src/plugins/projects_hierarchy/www/index.php
Log:
start to add project admin page

Modified: trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
===================================================================
--- trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-07-31 18:16:28 UTC (rev 14018)
+++ trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-07-31 18:16:49 UTC (rev 14019)
@@ -77,6 +77,11 @@
 				}
 				break;
 			}
+			case "site_admin_option_hook": {
+				echo '<li>'.$this->getAdminOptionLink().'</li>';
+				$returned = true;
+				break;
+			}
 			case "project_admin_plugins": {
 				// this displays the link in the project admin options page to it's administration
 				$group_id = $params['group_id'];
@@ -89,11 +94,6 @@
 				$returned = true;
 				break;
 			}
-			case "site_admin_option_hook": {
-				echo '<li>'.$this->getAdminOptionLink().'</li>';
-				$returned = true;
-				break;
-			}
 		}
 		return $returned;
 	}
@@ -345,10 +345,10 @@
 	 */
 	function add($group_id) {
 		if (!$this->exists($group_id)) {
-			$res = db_query_params('INSERT INTO plugin_projects_hierarchy (project_id) VALUES ($1)', array($group_id));
+			$globalConf = $this->getGlobalConf();
+			$res = db_query_params('INSERT INTO plugin_projects_hierarchy (project_id, tree, docman, delegate) VALUES ($1)', array($group_id, $globalConf['tree'], $globalConf['docman'], $globalConf['delegate']));
 			if (!$res)
 				return false;
-
 		}
 		return true;
 	}
@@ -547,11 +547,14 @@
 				session_require_global_perm('forge_admin');
 				global $gfwww;
 				require_once($gfwww.'admin/admin_utils.php');
-				site_admin_header(array('title'=>_('Site Global Hierarchy Admin'), 'toptab' => ''));
+				site_admin_header(array('title'=>_('Site Global Hierarchy Admin'), 'toptab'=>''));
 				$returned = true;
 				break;
 			}
+			case 'admin':
 			default: {
+				site_project_header();
+				$returned = true;
 				break;
 			}
 		}
@@ -601,11 +604,31 @@
 		return $returnArr;
 	}
 
+	function getProjectAdminView() {
+		global $gfplugins, $use_tooltips;
+		include $gfplugins.$this->name.'/view/admin/viewProjectConfiguration.php';
+		return true;
+	}
+
 	/**
 	 * getFooter - display footer
 	 */
-	function getFooter() {
-		site_admin_footer(array());
+	function getFooter($type) {
+		global $gfplugins;
+		$returned = false;
+		switch ($type) {
+			case 'globaladmin': {
+				session_require_global_perm('forge_admin');
+				site_admin_footer(array());
+				break;
+			}
+			case 'admin':
+			default: {
+				site_project_footer(array());
+				break;
+			}
+		}
+		return $returned;
 	}
 
 	/**

Copied: trunk/src/plugins/projects_hierarchy/view/admin/viewProjectConfiguration.php (from rev 14015, trunk/src/plugins/projects_hierarchy/view/admin/viewGlobalConfiguration.php)
===================================================================
--- trunk/src/plugins/projects_hierarchy/view/admin/viewProjectConfiguration.php	                        (rev 0)
+++ trunk/src/plugins/projects_hierarchy/view/admin/viewProjectConfiguration.php	2011-07-31 18:16:49 UTC (rev 14019)
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Projects Hierarchy plugin
+ *
+ * Copyright 2011, Franck Villaume - Capgemini
+ * 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.
+ */
+
+global $HTML;
+global $projectsHierarchy;
+global $use_tooltips;
+
+$projectsHierarchyGlobalConf = $projectsHierarchy->getGlobalconf();
+
+echo $HTML->boxTop(_('Manage project configuration'));
+echo '<form method="post" action="?type=admin&&pluginname='.$projectsHierarchy->name.'&action=updateProjectConf">';
+echo '<table>';
+
+echo '<tr><td><label id="projectsHierarchy-delegate" ';
+if ($use_tooltips)
+	echo 'title="'._('Enable full rights and configuration delegation to parent.').'"';
+echo ' >'._('Enable delegate').'</label></td><td><input type="checkbox" name="delegate" value="1"';
+if ($projectsHierarchyProjectConf['delegate'])
+	echo 'checked="checked" ';
+
+echo '/></td></tr>';
+echo '<tr><td><label id="projectsHierarchy-globalconf" ';
+if ($use_tooltips)
+	echo 'title="'._('Use forge global configuration. Superseed any configuration done at project level.').'"';
+echo ' >'._('Use forge global configuration').'</label></td><td><input type="checkbox" name="globalconf" value="1"';
+if ($projectsHierarchyProjectConf['globalconf'])
+	echo 'checked="checked" ';
+
+echo '/></td></tr>';
+
+echo '</table>';
+echo '<input type="submit" value="'._('Update').'" />';
+echo '</form>';
+echo $HTML->boxBottom();
+?>

Modified: trunk/src/plugins/projects_hierarchy/www/index.php
===================================================================
--- trunk/src/plugins/projects_hierarchy/www/index.php	2011-07-31 18:16:28 UTC (rev 14018)
+++ trunk/src/plugins/projects_hierarchy/www/index.php	2011-07-31 18:16:49 UTC (rev 14019)
@@ -39,6 +39,9 @@
 
 switch ($type) {
 	case "group": {
+		if (!session_loggedin()) {
+			exit_not_logged_in();
+		}
 		$id = getStringFromRequest('id');
 		if (!$id) {
 			exit_error("Cannot Process your request: No ID specified", 'home');
@@ -71,6 +74,10 @@
 		break;
 	}
 	case "globaladmin": {
+		if (!session_loggedin()) {
+			exit_not_logged_in();
+		}
+		session_require_global_perm('forge_admin');
 		$action = getStringFromRequest('action');
 		switch ($action) {
 			case 'updateGlobalConf': {
@@ -81,9 +88,37 @@
 		}
 		$projectsHierarchy->getHeader('globaladmin');
 		$projectsHierarchy->getGlobalAdminView();
-		$projectsHierarchy->getFooter();
+		$projectsHierarchy->getFooter('globaladmin');
 		break;
 	}
+	case "admin": {
+		if (!session_loggedin()) {
+			exit_not_logged_in();
+		}
+		session_require_perm('project_admin', $id);
+		$id = getStringFromRequest('group_id');
+		if (!$id) {
+			exit_error("Cannot Process your request: No ID specified", 'home');
+		}
+		$group = group_get_object($id);
+		if ( !$group) {
+			exit_error("Invalid Project", 'home');
+		}
+		if (!$group->usesPlugin($projectsHierarchy->name)) {//check if the group has the projects_hierarchy plugin active
+			exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'), $projectsHierarchy->name), 'home');
+		}
+		$action = getStringFromRequest('action');
+		switch ($action) {
+			case 'updateProjectConf': {
+				global $gfplugins;
+				include($gfplugins.$projectsHierarchy->name.'/actions/'.$action.'.php');
+				break;
+			}
+		}
+		$projectsHierarchy->getHeader('admin');
+		$projectsHierarchy->getProjectAdminView();
+		$projectsHierarchy->getFooter('admin');
+	}
 	default: {
 		exit_error("No TYPE specified", 'home');
 		break;




More information about the Fusionforge-commits mailing list