[evolvis-commits] r6542: make this more readable: ↵ • remove redundant whitespace (and one comment) ↵ • re-indent and correct whitespace↵ • the “else” in 「if (foo) { return true; } else { return false; }」 is↵ ugly and an unnecessary indentation level making the code too wide for↵ a regular 80-column ANSI terminal , so remove some of these↵ • add a missing }↵

mirabilos at evolvis.org mirabilos at evolvis.org
Mon Apr 19 11:06:02 CEST 2010


Author: mirabilos
Date: 2010-04-19 11:06:01 +0200 (Mon, 19 Apr 2010)
New Revision: 6542

Modified:
   trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php
Log:
make this more readable:
• remove redundant whitespace (and one comment)
• re-indent and correct whitespace
• the “else” in 「if (foo) { return true; } else { return false; }」 is
  ugly and an unnecessary indentation level making the code too wide for
  a regular 80-column ANSI terminal, so remove some of these
• add a missing }


Modified: 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 08:52:33 UTC (rev 6541)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTaskSqlQueries.class.php	2010-04-19 09:06:01 UTC (rev 6542)
@@ -2,140 +2,142 @@
 /**
  * @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;
-} else {
+	$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));
 
-	while($arr = db_fetch_array($res)) {
-	$arrResult = array('group_project_id'=>$arr[0],'group_id'=>$arr[1]);
+	if (!$res || db_numrows($res) < 1) {
+		$this->setError(_('No group project id and group id were found.'));
+		return false;
 	}
-	
-	return $arrResult; // returns $arrResult['group_project_id'] with group_project_id and $arrResult['group_id'] with group_id
-}
 
+	while ($arr = db_fetch_array($res)) {
+		$arrResult = array(
+		    'group_project_id' => $arr[0],
+		    'group_id' => $arr[1]
+		);
+	}
+
+	return $arrResult;
 }
 
 
-function isProjectTaskInfoPublic($project_task_id){
+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));
 
-$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;
+	}
 
-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;
-} else {
 	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));
+	$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;
-} else {
+	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 
+/* 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 
+ *
+ * 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; 
- * 
+ *
+ * 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));
 
-$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;
+	}
 
-if (!$res || db_numrows($res) < 1) {
-	$this->setError(_('No data were found related to the project task.'));
-	return false;
-} else {
+	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]
+		);
+	}
 
-	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 */ }
+
 ?>




More information about the evolvis-commits mailing list