[evolvis-commits] r6543: • we do not need to setError here , boolean results suffice↵ • thus we don’t need to be a class either↵ • add a couple more fields to the result sets↵ • add some kind of documentation (C style, since I don’t know javadoc ) ↵

mirabilos at evolvis.org mirabilos at evolvis.org
Mon Apr 19 11:30:43 CEST 2010


Author: mirabilos
Date: 2010-04-19 11:30:43 +0200 (Mon, 19 Apr 2010)
New Revision: 6543

Added:
   trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.php
Removed:
   trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php
Log:
• we do not need to setError here, boolean results suffice
• thus we don’t need to be a class either
• add a couple more fields to the result sets
• add some kind of documentation (C style, since I don’t know javadoc)


Deleted: trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php
===================================================================
--- trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php	2010-04-19 09:06:01 UTC (rev 6542)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php	2010-04-19 09:30:43 UTC (rev 6543)
@@ -1,143 +0,0 @@
-<?php
-/**
- * @author: Patrick Apel, tarent GmbH
- */
-
-require_once $gfcommon.'include/Error.class.php';
-class ProjectTaskSqlQueries extends Error {
-
-
-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) {
-		$this->setError(_('No group project id and group id were found.'));
-		return false;
-	}
-
-	while ($arr = db_fetch_array($res)) {
-		$arrResult = array(
-		    'group_project_id' => $arr[0],
-		    'group_id' => $arr[1]
-		);
-	}
-
-	return $arrResult;
-}
-
-
-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) {
-		$this->setError(_('The information of the project task is not public.'));
-		/* Maybe this function should not throw an error with the error class?
-		 * Maybe there is a class that just gives back
-		 * an information message?
-		 * $this->setInformation('...') */
-		return false;
-	}
-
-	return true;
-}
-
-
-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) {
-		$this->setError(_('The user is not in an user group that matches to the project group of the project task.'));
-		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;
- *
- */
-
-
-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, ' .
-	    '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) {
-		$this->setError(_('No data were found related to the project task.'));
-		return false;
-	}
-
-	while ($arr = db_fetch_array($res)) {
-		$arrResult = array(
-		    'project_task_id'=>$arr[0],
-		    'group_project_id'=>$arr[1],
-		    'summary'=>$arr[2],
-		    'priority'=>$arr[3],
-		    'created_by'=>$arr[4],
-		    'status_id'=>$arr[5],
-		    'category_id'=>$arr[6],
-		    'created_by_name'=>$arr[7],
-		    'category_name'=>$arr[8],
-		    'project_name'=>$arr[9],
-		    'group_name'=>$arr[10],
-		    'status_name'=>$arr[11]
-		);
-	}
-
-	return $arrResult;
-}
-
-/* class */ }
-
-?>

Copied: trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.php (from rev 6542, trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php)
===================================================================
--- trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.php	                        (rev 0)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.php	2010-04-19 09:30:43 UTC (rev 6543)
@@ -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;
+}
+
+?>


Property changes on: trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.php
___________________________________________________________________
Added: svn:mergeinfo
   + 




More information about the evolvis-commits mailing list