[evolvis-commits] r17556: [#2021] New /usr/share/gforge/bin/user-del.php utility

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Sep 20 11:36:40 CEST 2011


Author: mirabilos
Date: 2011-09-20 11:36:40 +0200 (Tue, 20 Sep 2011)
New Revision: 17556

Added:
   branches/ev48fixes/utils/user-del.php
Modified:
   branches/ev48fixes/debian/changelog
   branches/ev48fixes/install/common
Log:
[#2021] New /usr/share/gforge/bin/user-del.php utility

The problem stems from having deleted users still being group members.


Modified: branches/ev48fixes/debian/changelog
===================================================================
--- branches/ev48fixes/debian/changelog	2011-09-20 09:12:03 UTC (rev 17555)
+++ branches/ev48fixes/debian/changelog	2011-09-20 09:36:40 UTC (rev 17556)
@@ -2,11 +2,12 @@
 
   [ Thorsten Glaser ]
   * [TTID# 1118041] Fixup permissions on /svnroot/*/db/ hourly (g+w)
+  * [#2021] New /usr/share/gforge/bin/user-del.php utility
 
   [ Patrick Apel ]
   * Fix XHTML validity in the German translation
 
- -- Thorsten Glaser <t.glaser at tarent.de>  Tue, 20 Sep 2011 11:02:03 +0200
+ -- Thorsten Glaser <t.glaser at tarent.de>  Tue, 20 Sep 2011 11:36:02 +0200
 
 gforge (4.8.3+evolvis36+fixes2) unstable; urgency=low
 

Modified: branches/ev48fixes/install/common
===================================================================
--- branches/ev48fixes/install/common	2011-09-20 09:12:03 UTC (rev 17555)
+++ branches/ev48fixes/install/common	2011-09-20 09:36:40 UTC (rev 17556)
@@ -28,3 +28,4 @@
 deb-specific/evolvis-captcha.flf       usr/share/figlet/
 cronjobs/unlocale.sh                   usr/share/gforge/bin/
 utils/scm-newsubrepo.php               usr/share/gforge/bin/
+utils/user-del.php                     usr/share/gforge/bin/

Copied: branches/ev48fixes/utils/user-del.php (from rev 17551, branches/ev48fixes/utils/scm-newsubrepo.php)
===================================================================
--- branches/ev48fixes/utils/user-del.php	                        (rev 0)
+++ branches/ev48fixes/utils/user-del.php	2011-09-20 09:36:40 UTC (rev 17556)
@@ -0,0 +1,85 @@
+#!/usr/bin/php5 -f
+<?php
+/*-
+ * Delete a forge user from the command line
+ *
+ * Copyright © 2011
+ *	Thorsten Glaser <t.glaser at tarent.de>
+ * Copyright © 2010
+ *	Roland Mas
+ * All rights reserved.
+ *
+ * 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.
+ *-
+ * Mark a forge user as deleted, including things like group memberships.
+ */
+
+function usage($rc=1) {
+	echo "Usage: .../user-del.php username username\n";
+	exit($rc);
+}
+
+if (count($argv) != 3) {
+	usage();
+}
+$argv0 = array_shift($argv);
+$u_name = array_shift($argv);
+$u_check = array_shift($argv);
+
+if ($u_name == '-h') {
+	usage(0);
+}
+
+if ($u_name !== $u_check) {
+	usage();
+}
+
+require_once(dirname(__FILE__).'/../www/env.inc.php');
+require_once $gfwww.'include/squal_pre.php';
+require_once $gfcommon.'include/cron_utils.php';
+
+// Fake admin user login
+$G_SESSION = user_get_object_by_name("admin");
+$G_SESSION->is_logged_in = true;
+$G_SESSION->is_super_user = true;
+
+// Plugins subsystem
+require_once $gfcommon.'include/Plugin.class.php';
+require_once $gfcommon.'include/PluginManager.class.php';
+
+// SCM-specific plugins subsystem
+require_once $gfcommon.'include/SCM.class.php';
+
+setup_plugin_manager();
+
+$u_obj = user_get_object_by_name($u_name);
+if (!$u_obj || $u_obj->isError()) {
+	echo "Wrong user! ";
+	if ($u_obj) {
+		echo $u_obj->getErrorMessage();
+	}
+	echo "\n";
+	usage();
+}
+
+if (!$u_obj->delete(true)) {
+	echo "Error! " . $u_obj->getErrorMessage() . "\n";
+	exit(1);
+}
+
+plugin_hook('del_cal_user', $u_obj->getID());
+
+?>



More information about the evolvis-commits mailing list