[Fusionforge-commits] r14040 - in branches/Branch_5_1: . src/www/admin

Roland Mas lolando at fusionforge.org
Tue Aug 2 16:22:51 CEST 2011


Author: lolando
Date: 2011-08-02 16:22:51 +0200 (Tue, 02 Aug 2011)
New Revision: 14040

Added:
   branches/Branch_5_1/src/www/admin/globalroledelete.php
Modified:
   branches/Branch_5_1/
   branches/Branch_5_1/src/www/admin/globalroleedit.php
Log:
Added UI to delete a global role

Added: branches/Branch_5_1/src/www/admin/globalroledelete.php
===================================================================
--- branches/Branch_5_1/src/www/admin/globalroledelete.php	                        (rev 0)
+++ branches/Branch_5_1/src/www/admin/globalroledelete.php	2011-08-02 14:22:51 UTC (rev 14040)
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Role Delete Page
+ *
+ * Copyright 2010 (c) Alcatel-Lucent
+ *
+ * @author Alain Peyrat
+ * @date 2010-05-18
+ *
+ * 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.
+ */
+
+require_once('../../env.inc.php');
+require_once $gfcommon.'include/pre.php';
+require_once $gfwww.'project/admin/project_admin_utils.php';
+require_once $gfcommon.'include/Role.class.php';
+
+$role_id = getIntFromRequest('role_id');
+
+session_require_perm ('forge_admin') ;
+
+if (!$role_id) {
+	session_redirect('/admin');
+}
+
+$role = RBACEngine::getInstance()->getRoleById($role_id);
+
+if (!$role || !is_object($role)) {
+	exit_error(_('Could Not Get Role'),'admin');
+} elseif ($role->isError()) {
+	exit_error($role->getErrorMessage(),'admin');
+}
+
+if ($role->getHomeProject() != NULL) {
+	exit_error(_("You can only delete a global role from here."),'admin');
+}
+
+if (getStringFromRequest('submit')) {
+	if (getIntFromRequest('sure')) {
+		if (!$role->delete()) {
+			$error_msg = _('ERROR: ').$role->getErrorMessage();
+		} else {
+			$feedback = _('Successfully Deleted Role');
+			session_redirect('/admin/index.php?feedback='.urlencode($feedback));
+		}
+	} else {
+		$error_msg = _('Error: Please confirm the deletion of the role.');
+	}
+
+	if (!isset($error_msg)) {
+		session_redirect('/admin/globalroleedit.php?role_id='.$role_id.'&error_msg='.urlencode($error_msg));
+	}
+}

Modified: branches/Branch_5_1/src/www/admin/globalroleedit.php
===================================================================
--- branches/Branch_5_1/src/www/admin/globalroleedit.php	2011-08-02 14:22:42 UTC (rev 14039)
+++ branches/Branch_5_1/src/www/admin/globalroleedit.php	2011-08-02 14:22:51 UTC (rev 14040)
@@ -247,6 +247,15 @@
 echo '<p><input type="submit" name="submit" value="'._('Submit').'" /></p>
 </form>';
 
+echo '
+<form action="'.util_make_url('/admin/globalroledelete.php').'" method="post">';
+echo '<input type="hidden" name="role_id" value="'.$role_id.'" />';
+		
+echo '<p><strong>'._('Delete role').'</strong></p>';
+echo '<p><input type="checkbox" name="sure" value="1"/> '._("Really delete this role?");
+echo '<input type="submit" name="submit" value="'._('Submit').'" /></p>
+</form>';
+
 site_admin_footer(array());
 
 // Local Variables:




More information about the Fusionforge-commits mailing list