[Fusionforge-commits] r9713 - in trunk/gforge: common/include www/pm

Roland Mas lolando at libremir.placard.fr.eu.org
Mon May 10 17:02:32 CEST 2010


Author: lolando
Date: 2010-05-10 17:02:30 +0200 (Mon, 10 May 2010)
New Revision: 9713

Added:
   trunk/gforge/www/pm/t_follow.php
Modified:
   trunk/gforge/common/include/utils.php
Log:
Copied from Evolvis: Part ?\226?\133?\160 of UUIDs for task items: a redirector to follow to the real URI

Modified: trunk/gforge/common/include/utils.php
===================================================================
--- trunk/gforge/common/include/utils.php	2010-05-10 15:02:11 UTC (rev 9712)
+++ trunk/gforge/common/include/utils.php	2010-05-10 15:02:30 UTC (rev 9713)
@@ -1176,6 +1176,33 @@
 	}
 }
 
+/*-
+ * I have absolutely no idea how to write a programming language, I just
+ * kept adding the next logical step on the way.
+ * -- Rasmus Lerdorf
+ */
+
+/* returns an integer from http://forge/foo/bar.php/123 or false */
+function util_path_info_last_numeric_component() {
+	/* PHP devs are idiots… ereg_replace is deprecated WTF? */
+	$ok = false;
+	foreach (str_split($_SERVER['PATH_INFO']) as $x) {
+		if ($x == '/') {
+			$rv = 0;
+			$ok = true;
+		} else if ($ok == false) {
+			; /* need reset using slash */
+		} else if ((ord($x) >= 48) && (ord($x) <= 57)) {
+			$rv = $rv * 10 + ord($x) - 48;
+		} else {
+			$ok = false;
+		}
+	}
+	if ($ok)
+		return $rv;
+	return false;
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Added: trunk/gforge/www/pm/t_follow.php
===================================================================
--- trunk/gforge/www/pm/t_follow.php	                        (rev 0)
+++ trunk/gforge/www/pm/t_follow.php	2010-05-10 15:02:30 UTC (rev 9713)
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Task UUID implementation for FusionForge
+ *
+ * Copyright © 2010
+ *	Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
+ * 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 License, 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.
+ *-
+ * Follow up to the task information page by UUID (project_task_id)
+ * via a redirection.
+ */
+
+/*
+ * I'm not a real programmer. I throw together things until it works
+ * then I move on. The real programmers will say "yeah it works but
+ * you're leaking memory everywhere. Perhaps we should fix that." I'll
+ * just restart apache every 10 requests.
+ * -- Rasmus Lerdorf
+ */
+
+require_once('../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfcommon.'pm/ProjectTaskSqlQueries.php';
+
+$tid = getIntFromRequest('tid');
+if (!$tid)
+	$tid = util_path_info_last_numeric_component();
+if (!$tid) {
+	header("HTTP/1.0 404 Not Found");
+	echo "You forgot to pass the tid.\n";
+	exit;
+}
+
+$tinfo = getGroupProjectIdGroupId($tid);
+
+if (!$tinfo) {
+	header("HTTP/1.0 404 Not Found");
+	echo "There is no task with id ".$tid."!\n";
+	exit;
+}
+
+$dsturl = util_make_url("/pm/task.php?func=detailtask&project_task_id=" .
+    $tinfo['project_task_id'] . "&group_id=" . $tinfo['group_id'] .
+    "&group_project_id=" . $tinfo['group_project_id']);
+header("HTTP/1.0 302 Found");
+header("Location: " . $dsturl);
+echo "The result is at:\n" . $dsturl . "\n";
+exit;




More information about the Fusionforge-commits mailing list