[evolvis-commits] r6547: merge bm:taramir/patches/ improvetasks↵ ↵ Quotes of PHP’s founder contributed by Benny Siegert < bsiegert at mirbsd.org> ↵ 10x↵

Thorsten Glaser t.glaser at tarent.de
Tue Apr 20 16:16:03 CEST 2010


Author: Thorsten Glaser <t.glaser at tarent.de>
Date: 2010-04-20 16:16:03 +0200 (Tue, 20 Apr 2010)
New Revision: 6547

Added:
   trunk/gforge_base/evolvisforge/gforge/common/include/minijson.php
   trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTaskSqlQueries.php
   trunk/gforge_base/evolvisforge/gforge/www/pm/t_follow.php
   trunk/gforge_base/evolvisforge/gforge/www/pm/t_lookup.php
Modified:
   trunk/gforge_base/evolvisforge/gforge/common/include/utils.php
   trunk/gforge_base/evolvisforge/gforge/debian/changelog
   trunk/gforge_base/evolvisforge/gforge/www/export/rss20_tasks.php
   trunk/gforge_base/evolvisforge/gforge/www/pm/detail_task.php
   trunk/gforge_base/evolvisforge/gforge/www/pm/mod_task.php
Log:
merge bm:taramir/patches/improvetasks

Quotes of PHP’s founder contributed by Benny Siegert <bsiegert at mirbsd.org>
10x


Added: trunk/gforge_base/evolvisforge/gforge/common/include/minijson.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/include/minijson.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge/gforge/common/include/minijson.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -0,0 +1,148 @@
+<?php
+/**
+ * Minimal JSON generator 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.
+ *-
+ * Do *not* use PHP’s json_encode because it is broken. Rather,
+ * use (and, if necessary, extend) this module.
+ */
+
+/*-
+ * I was really, really bad at writing parsers. I still am really bad at
+ * writing parsers.
+ * -- Rasmus Lerdorf
+ */
+
+/**
+ * Encodes an array (indexed or associative) as JSON.
+ *
+ * in:	array x
+ * out:	string encoded
+ */
+function minijson_encode($x, $ri="") {
+	if (!isset($x) || is_null($x) || (is_float($x) &&
+	    (is_nan($x) || is_infinite($x))))
+		return "null";
+	if ($x === true)
+		return "true";
+	if ($x === false)
+		return "false";
+	if (is_int($x)) {
+		$y = (int)$x;
+		$z = (string)$y;
+		if ($x == $z)
+			return $z;
+		$x = (string)$x;
+	}
+	/* note: no float here (for now); be locales-aware! */
+	if (is_string($x)) {
+		$rs = "\"";
+		foreach (str_split($x) as $v) {
+			$y = ord($v);
+			if ($y == 8) {
+				$rs .= "\\b";
+			} else if ($y == 9) {
+				$rs .= "\\t";
+			} else if ($y == 10) {
+				$rs .= "\\n";
+			} else if ($y == 12) {
+				$rs .= "\\f";
+			} else if ($y == 13) {
+				$rs .= "\\r";
+			} else if ($y < 0x20 || ($y > 0x7E && $y < 0xA0)) {
+				$rs .= sprintf("\\u%04X", $y);
+			} else if ($y > 0xFFFD) {
+				/* XXX encode as UTF-16 */
+				$rs .= "\\uFFFD";
+			} else if ($v == "\"" || $v == "\\") {
+				$rs .= "\\".$v;
+			} else
+				$rs .= $v;
+		}
+		return $rs."\"";
+	}
+	if (is_array($x)) {
+		$k = array_keys($x);
+
+		$isnum = true;
+		foreach ($k as $v) {
+			if (is_int($v)) {
+				$y = (int)$v;
+				$z = (string)$y;
+				if ($v != $z) {
+					$isnum = false;
+					break;
+				}
+			} else {
+				$isnum = false;
+				break;
+			}
+		}
+
+		if ($isnum) {
+			/* all array keys are integers */
+			$s = $k;
+			sort($s, SORT_NUMERIC);
+			/* test keys for order and delta */
+			$y = 0;
+			foreach ($s as $v) {
+				if ($v != $y) {
+					$isnum = false;
+					break;
+				}
+				$y++;
+			}
+		}
+
+		$first = true;
+		if ($isnum) {
+			/* all array keys are integers 0‥n */
+			$rs = "[\n";
+			foreach ($s as $v) {
+				if ($first)
+					$first = false;
+				else
+					$rs .= ",\n";
+				$rs .= $ri . "  " .
+				    minijson_encode($x[$v], $ri."  ");
+			}
+			return $rs."\n".$ri."]";
+		}
+
+		$rs = "{\n";
+		foreach ($k as $v) {
+			if ($first)
+				$first = false;
+			else
+				$rs .= ",\n";
+			$rs .= $ri . "  " . minijson_encode((string)$v) .
+			    ": " . minijson_encode($x[$v], $ri."  ");
+		}
+		return $rs."\n".$ri."}";
+	}
+
+	/* treat everything else as array or string */
+	if (!is_scalar($x))
+		return minijson_encode((array)$x, $ri);
+	return minijson_encode((string)$x, $ri);
+}
+
+?>

Modified: trunk/gforge_base/evolvisforge/gforge/common/include/utils.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/include/utils.php	2010-04-20 14:15:59 UTC (rev 6546)
+++ trunk/gforge_base/evolvisforge/gforge/common/include/utils.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -1006,6 +1006,36 @@
 	}
 }
 
+/*-
+ * 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() {
+	if (!isset($_SERVER['PATH_INFO']))
+		return false;
+
+	/* 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_base/evolvisforge/gforge/common/pm/ProjectTaskSqlQueries.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTaskSqlQueries.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTaskSqlQueries.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -0,0 +1,177 @@
+<?php
+/**
+ * @author: Patrick Apel, tarent GmbH
+ */
+
+
+/**
+ * Retrieve group_project_id and group_id for a specific project_task_id,
+ * for URI construction and similar things.
+ *
+ * in:	int project_task_id
+ * out:	false, or an associative array with
+ *	- int project_task_id (copy)
+ *	- int group_project_id
+ *	- int group_id
+ */
+function getGroupProjectIdGroupId($project_task_id) {
+	$res = db_query_params('SELECT project_task.group_project_id, project_group_list.group_id FROM project_task ' .
+	    'INNER JOIN project_group_list ON project_task.group_project_id = project_group_list.group_project_id ' .
+	    'WHERE project_task.project_task_id = $1',
+	    array($project_task_id));
+
+	if (!$res || db_numrows($res) != 1) {
+		return false;
+	}
+
+	while ($arr = db_fetch_array($res)) {
+		$arrResult = array(
+		    'project_task_id' => (int)$project_task_id,
+		    'group_project_id' => (int)$arr[0],
+		    'group_id' => (int)$arr[1]
+		);
+	}
+
+	return $arrResult;
+}
+
+
+/**
+ * Check if the task behind project_task_id is considered public.
+ *
+ * in:	int project_task_id
+ * out:	true, if it is; false otherwise
+ */
+function isProjectTaskInfoPublic($project_task_id) {
+	$res = db_query_params('SELECT * FROM project_task ' .
+	    'INNER JOIN project_group_list ON ' .
+	    'project_task.group_project_id = project_group_list.group_project_id ' .
+	    'INNER JOIN groups ON ' .
+	    'project_group_list.group_id = groups.group_id ' .
+	    'WHERE project_task.project_task_id = $1 ' .
+	    'AND project_group_list.is_public = $2 AND groups.is_public = $3',
+	    array($project_task_id, 1, 1));
+
+	if (!$res || db_numrows($res) < 1) {
+		return false;
+	}
+
+	return true;
+}
+
+
+/**
+ * Check whether the user has access to the project task by
+ * means of common group membership.
+ *
+ * in:	int project_task_id
+ *	str user_name (Unix user name)
+ * out:	true, if he has; false otherwise
+ */
+function isUserAndTaskinSameGroup($project_task_id, $user_name) {
+	$res = db_query_params('SELECT * FROM user_group ' .
+	    'INNER JOIN users ON ' .
+	    'users.user_id = user_group.user_id ' .
+	    'INNER JOIN project_group_list ON ' .
+	    'project_group_list.group_id = user_group.group_id ' .
+	    'INNER JOIN project_task ON ' .
+	    'project_group_list.group_project_id = project_task.group_project_id ' .
+	    'WHERE project_task.project_task_id = $1 AND users.user_name = $2',
+	    array($project_task_id, $user_name));
+
+	if (!$res || db_numrows($res) < 1) {
+		return false;
+	}
+
+	return true;
+}
+
+/*-
+ * Query for controlling the result. It gives back all user_names and
+ * project_task_ids that matches the groups above:
+ *
+ * SELECT users.user_name, project_task.project_task_id FROM users
+ * INNER JOIN user_group ON users.user_id = user_group.user_id
+ * INNER JOIN project_group_list ON user_group.group_id = project_group_list.group_id
+ * INNER JOIN project_task ON project_group_list.group_project_id = project_task.group_project_id;
+ *
+ * Query for controlling the result. It gives back all user_names that
+ * does not match a group above:
+ *
+ * SELECT users.user_name, project_task.project_task_id FROM users
+ * LEFT JOIN user_group ON users.user_id = user_group.user_id
+ * LEFT JOIN project_group_list ON user_group.group_id = project_group_list.group_id
+ * LEFT JOIN project_task ON project_group_list.group_project_id = project_task.group_project_id
+ * WHERE project_task_id isNull;
+ */
+
+
+/**
+ * Retrieve extended information about a project task.
+ *
+ * in:	int project_task_id
+ * out:	false (if an error occured) or an associative array with
+ *	- int project_task_id (copy)
+ *	- int group_project_id (for URI construction)
+ *	- int group_id (for URI construction)
+ *	- str group_name
+ *	- str summary (of the task)
+ *	- int priority
+ *	- int created_by (user ID)
+ *	- str created_by_name (Unix user name)
+ *	- int status_id
+ *	- str status_name
+ *	- int category_id
+ *	- str category_name (of the per-group category the task is in)
+ *	- str project_name (of the per-group subproject the task is in)
+ */
+function getAllFromProjectTask($project_task_id) {
+	$res = db_query_params('SELECT ' .
+	    'project_task.project_task_id, project_task.group_project_id, project_task.summary, project_task.priority, ' .
+	    'project_task.created_by, project_task.status_id, project_task.category_id, ' .
+	    'users.user_name, ' .
+	    'project_category.category_name, ' .
+	    'project_group_list.project_name, ' .
+	    'groups.group_name, ' .
+	    'groups.group_id, ' .
+	    'project_status.status_name ' .
+	    'FROM project_status ' .
+	    'INNER JOIN project_task ON ' .
+	    'project_task.status_id = project_status.status_id ' .
+	    'INNER JOIN users ON ' .
+	    'users.user_id = project_task.created_by ' .
+	    'INNER JOIN project_category ON ' .
+	    'project_category.category_id = project_task.category_id ' .
+	    'INNER JOIN project_group_list ON ' .
+	    'project_group_list.group_project_id = project_task.group_project_id ' .
+	    'INNER JOIN groups ON ' .
+	    'groups.group_id = project_group_list.group_id ' .
+	    'WHERE project_task.project_task_id = $1',
+	    array($project_task_id));
+
+	if (!$res || db_numrows($res) != 1) {
+		return false;
+	}
+
+	while ($arr = db_fetch_array($res)) {
+		$arrResult = array(
+		    'project_task_id' => (int)$arr[0],
+		    'group_project_id' => (int)$arr[1],
+		    'group_id' => (int)$arr[11],
+		    'summary' => $arr[2],
+		    'priority' => (int)$arr[3],
+		    'created_by' => (int)$arr[4],
+		    'status_id' => (int)$arr[5],
+		    'category_id' => (int)$arr[6],
+		    'created_by_name' => $arr[7],
+		    'category_name' => $arr[8],
+		    'project_name' => $arr[9],
+		    'group_name' => $arr[10],
+		    'status_name' => $arr[12]
+		);
+	}
+
+	return $arrResult;
+}
+
+?>

Modified: trunk/gforge_base/evolvisforge/gforge/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/debian/changelog	2010-04-20 14:15:59 UTC (rev 6546)
+++ trunk/gforge_base/evolvisforge/gforge/debian/changelog	2010-04-20 14:16:03 UTC (rev 6547)
@@ -4,8 +4,10 @@
   * Add $sys_hudson_base (default: empty)
   * gf-p-mw: put group name into <title> header
   * merge bugfixes from upstream 4.8-stable branch
+  * implement using the project_task_id as forge-global UUID
+  * add permalinks for task UUIDs as redirection and JSON info
 
- -- Thorsten Glaser <t.glaser at tarent.de>  Tue, 20 Apr 2010 12:19:08 +0200
+ -- Thorsten Glaser <t.glaser at tarent.de>  Tue, 20 Apr 2010 12:41:33 +0200
 
 gforge (4.8.3+evolvis4) unstable; urgency=low
 

Modified: trunk/gforge_base/evolvisforge/gforge/www/export/rss20_tasks.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/export/rss20_tasks.php	2010-04-20 14:15:59 UTC (rev 6546)
+++ trunk/gforge_base/evolvisforge/gforge/www/export/rss20_tasks.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -251,13 +251,13 @@
     //------------ build one feed item ------------
     print "  <item>\n";					
         print "   <title>".$msg['subject']."</title>\n"; 
-        print "   <link>http://".$sys_default_domain."/".$link."</link>\n";
+        print "   <link>" . util_make_url("/pm/t_follow.php/" . $msg['project_task_id']) . "</link>\n";
         print "   <category>".$item_cat."</category>\n";
         print "   <description>".$msg['details']."</description>\n";
         print "   <author>".$msg['user_realname']."</author>\n";
                 //print "   <comment></comment>\n";
         print "   <pubDate>".gmdate('D, d M Y G:i:s',$msg['most_recent_date'])." GMT</pubDate>\n";
-                //print "   <guid></guid>\n";			
+	print "   <guid>" . util_make_url("/pm/t_lookup.php?tid=" . $msg['project_task_id']) . "</guid>\n";
     print "  </item>\n";
 
 }

Modified: trunk/gforge_base/evolvisforge/gforge/www/pm/detail_task.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/pm/detail_task.php	2010-04-20 14:15:59 UTC (rev 6546)
+++ trunk/gforge_base/evolvisforge/gforge/www/pm/detail_task.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -23,13 +23,25 @@
 
         <tr>
                 <td><strong><?php echo _('Submitted by') ?>:</strong><br /><?php echo $pt->getSubmittedRealName(); ?> (<?php echo $pt->getSubmittedUnixName(); ?>)</td>
+
+		<td>
+			<strong><a href="<?php echo util_make_url("/pm/t_follow.php/" . $project_task_id); ?>">Permalink</a>:</strong><br />
+			<?php echo util_make_url("/pm/t_follow.php/" . $project_task_id); ?>
+		</td>
         </tr>
 
 	<tr>
-		<td colspan="2">
+		<td>
 		<strong><?php echo _('Category') ?></strong><br />
 		<?php echo $pt->getCategoryName(); ?>
 		</td>
+
+		<td>
+		<strong>Task Detail Information (JSON):</strong><br />
+		<a href="<?php echo util_make_url("/pm/t_lookup.php?tid=" . $project_task_id); ?>">application/json</a>
+		or
+		<a href="<?php echo util_make_url("/pm/t_lookup.php?text=1&amp;tid=" . $project_task_id); ?>">text/plain</a>
+		</td>
 	</tr>
 
 	<tr>

Modified: trunk/gforge_base/evolvisforge/gforge/www/pm/mod_task.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/pm/mod_task.php	2010-04-20 14:15:59 UTC (rev 6546)
+++ trunk/gforge_base/evolvisforge/gforge/www/pm/mod_task.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -35,6 +35,8 @@
 		<td><strong><?php echo _('Submitted by') ?>:</strong><br />
 			<?php echo $pt->getSubmittedRealName(); ?> (<?php echo $pt->getSubmittedUnixName(); ?>)</td>
 		<td><input type="submit" value="<?php echo _('Submit') ?>" name="submit" /></td>
+		<td><strong>Task ID:</strong> <?php echo $project_task_id; ?> @ <?php
+		    echo $GLOBALS['sys_default_domain']; ?></td>
 	</tr>
 
 	<tr>
@@ -47,6 +49,11 @@
 			<strong><?php echo _('Subproject'); ?>:</strong><br />
 			<?php echo $pg->groupProjectBox('new_group_project_id',$group_project_id,false); ?>
 		</td>
+
+		<td>
+			<strong><a href="<?php echo util_make_url("/pm/t_follow.php/" . $project_task_id); ?>">Permalink</a>:</strong><br />
+			<?php echo util_make_url("/pm/t_follow.php/" . $project_task_id); ?>
+		</td>
 	</tr>
 
 	<tr>
@@ -59,6 +66,13 @@
 		<strong><?php echo _('Priority') ?>:</strong><br />
 		<?php echo build_priority_select_box('priority',$pt->getPriority()); ?>
 		</td>
+
+		<td>
+		<strong>Task Detail Information (JSON):</strong><br />
+		<a href="<?php echo util_make_url("/pm/t_lookup.php?tid=" . $project_task_id); ?>">application/json</a>
+		or
+		<a href="<?php echo util_make_url("/pm/t_lookup.php?text=1&amp;tid=" . $project_task_id); ?>">text/plain</a>
+		</td>
 	</tr>
 
   	<tr>
@@ -66,13 +80,13 @@
 		<strong><?php echo _('Task Summary') ?>:</strong><br />
 		<input type="text" name="summary" size="40" maxlength="65" value="<?php echo $pt->getSummary(); ?>" />
 		</td>
-		<td>
+		<td colspan="2">
 		<a href="<?php echo getStringFromServer('PHP_SELF')."?func=deletetask&amp;project_task_id=$project_task_id&amp;group_id=$group_id&amp;group_project_id=$group_project_id"; ?>"><?php echo _('Delete this task') ?></a>
 		</td>
 	</tr>
 
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 		<strong><?php echo _('Original Comment') ?>:</strong><br />
 		<?php echo nl2br( $pt->getDetails() ); ?>
 		<p />
@@ -82,7 +96,7 @@
 	</tr>
 
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 		<strong><?php echo _('Start Date') ?>:</strong><br />
 		<?php
 		echo $pg->showMonthBox ('start_month',date('m', $pt->getStartDate()));
@@ -96,7 +110,7 @@
 	</tr>
 
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 		<strong><?php echo _('End Date') ?>:</strong><br />
 		<?php
 		echo $pg->showMonthBox ('end_month',date('m', $pt->getEndDate()));
@@ -119,7 +133,7 @@
 		?>
 		</td>
 
-		<td valign="top">
+		<td valign="top" colspan="2">
 		<strong><?php echo _('Dependent on task') ?>:</strong><br />
 		<?php
 		/*
@@ -138,7 +152,7 @@
 		<input type="text" name="hours" size="5" value="<?php echo $pt->getHours(); ?>" />
 		</td>
 
-		<td>
+		<td colspan="2">
 		<strong><?php echo _('Status') ?></strong><br />
 		<?php
 		echo $pg->statusBox('status_id', $pt->getStatusID(), false );
@@ -155,7 +169,7 @@
 		<input type="text" name="hours" size="5" value="<?php echo $pt->getHours(); ?>" />
 		</td>
 
-		<td>
+		<td colspan="2">
 		<strong><?php echo _('Status') ?></strong><br />
 		<?php
 //		echo $pg->statusBox('status_id', $pt->getStatusID(), false );
@@ -164,19 +178,19 @@
 	</tr>
 -->
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 			<?php echo $pt->showDependentTasks(); ?>
 		</td>
 	</tr>
 
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 			<?php echo $pt->showRelatedArtifacts(); ?>
 		</td>
 	</tr>
 
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 			<?php echo $pt->showMessages(); ?>
 		</td>
 	</tr>
@@ -185,13 +199,13 @@
 		plugin_hook("task_extra_detail",$hookParams);
 	?>
 	<tr>
-		<td colspan="2">
+		<td colspan="3">
 			<?php echo $pt->showHistory(); ?>
 		</td>
 	</tr>
 
 	<tr>
-		<td colspan="2" style="text-align:center">
+		<td colspan="3" style="text-align:center">
 		<input type="submit" value="<?php echo _('Submit') ?>" name="submit" />
 		</td>
 	</tr>

Added: trunk/gforge_base/evolvisforge/gforge/www/pm/t_follow.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/pm/t_follow.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge/gforge/www/pm/t_follow.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -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;

Added: trunk/gforge_base/evolvisforge/gforge/www/pm/t_lookup.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/pm/t_lookup.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge/gforge/www/pm/t_lookup.php	2010-04-20 14:16:03 UTC (rev 6547)
@@ -0,0 +1,97 @@
+<?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.
+ *-
+ * Locate task information by UUID (project_task_id) and return as JSON.
+ */
+
+/*-
+ * We have things like protected properties. We have abstract methods.
+ * We have all this stuff that your computer science teacher told you
+ * you should be using. I don't care about this crap at all.
+ * -- Rasmus Lerdorf
+ */
+
+require_once('../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfcommon.'include/minijson.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;
+}
+
+$asuser = getStringFromRequest('asuser');
+
+if (getIntFromRequest('text'))
+	$asformat = "text/plain; charset=\"UTF-8\"";
+else
+	$asformat = "application/json; charset=\"UTF-8\"";
+
+$islogin = session_loggedin();
+$isadmin = session_checkperm(array('group'=>'1','admin_flags'=>'A'));
+$ishttps = session_issecure();
+$ispublic = isProjectTaskInfoPublic($tid);
+
+if (!$ishttps) {
+	$islogin = false;
+	$isadmin = false;
+}
+
+if ($ispublic) {
+	$showall = true;
+} else if ($islogin) {
+	if (!$isadmin) {
+		/* operate as ourselves */
+		$asuser = session_get_user()->getUnixName();
+	}
+
+	if (isUserAndTaskinSameGroup($tid, $asuser))
+		$showall = true;
+	else
+		$showall = false;
+} else {
+	$showall = false;
+}
+
+if ($showall) {
+	$tinfo = getAllFromProjectTask($tid);
+}
+
+$tinfo['public'] = $ispublic;
+
+header("Content-type: " . $asformat);
+echo minijson_encode($tinfo) . "\n";
+exit;




More information about the evolvis-commits mailing list