[evolvis-commits] r17678: [#1846] Ausblenden von Tasks die fertiggestellt sind auf "Meine(r) Seite".

papel at evolvis.org papel at evolvis.org
Wed Nov 2 10:10:41 CET 2011


Author: papel
Date: 2011-11-02 10:10:41 +0100 (Wed, 02 Nov 2011)
New Revision: 17678

Modified:
   trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTasksForUser.class.php
   trunk/gforge_base/evolvisforge/gforge/www/my/index.php
   trunk/gforge_base/evolvisforge/gforge/www/pm/include/ProjectTaskHTML.class.php
Log:
[#1846] Ausblenden von Tasks die fertiggestellt sind auf "Meine(r) Seite".

Modified: trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTasksForUser.class.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTasksForUser.class.php	2011-10-31 14:44:48 UTC (rev 17677)
+++ trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTasksForUser.class.php	2011-11-02 09:10:41 UTC (rev 17678)
@@ -67,10 +67,95 @@
 		}
 		return $tasks;
 	}
+	
+	/**
+	* Gets a list of tasks for this user
+	*
+	* @param the SQL query to use to fetch the tasks
+	*	@return	an array of ProjectTask objects
+	*/
+	function &getProjectGroupsFromSQLwithParams($sql, $params) {
+		$group_projects = array();
+		$result = db_query_params ($sql, $params);
+		$rows=db_numrows($result);
+		for ($i=0; $i < $rows; $i++) {
+			$group_project_id = db_result($result,$i,'group_project_id');
+			$arr = db_fetch_array($result);
+			$group_project = projectgroup_get_object($group_project_id,$arr);
+			$group_projects[] = $group_project;
+		}
+		return $group_projects;
+	}
+	
+	/**	 
+	 * 	Gets the status and status_ids
+	 * 	@return an array of status_ids and names
+	 */
+	function getStatus() { //Maybe we can move this method to some other file, where the whole project can benefit from it.
+		$status = array('status_id' => array(), 'status_name' => array());
+		$result = db_query("SELECT * FROM project_status");
+		$i = 0;
+		while ($arr = db_fetch_array($result)) {
+			$status['status_id'][$i] = $arr[0];
+			$status['status_name'][$i] = $arr[1];
+			$i++;
+		}	
+		return $status;
+	}
+	
+	/**	 
+	 * 	Gets the task list of the logged in user by status
+	 * 
+	 * 	@return an array of ProjectTask objects
+	 */
+	function getTasksByStatus($arrFilter = array()) {
+		
+		$select = "SELECT * FROM project_task pt";
+		$join = " INNER JOIN project_status ps ON (pt.status_id = ps.status_id)" . 
+		" INNER JOIN project_assigned_to pat ON (pt.project_task_id = pat.project_task_id)";
+		
+		$where = " WHERE pat.assigned_to_id = $1";
+		
+		if(count($arrFilter) > 0) {
+			$strFilter = "";
+			$where .= " AND pt.status_id NOT IN (";
+			for($i = 1; $i < (count($arrFilter)+1); $i++) {
+				$strFilter .= "$".($i+1);
+				if(($i+1) < count($arrFilter)+1) {
+					$strFilter .= ",";
+				}
+			}
+			$where .= $strFilter .")";
+		} 
+		
+		array_unshift($arrFilter, $this->User->getID()); 
+		
+		$sqlQuery = $select . $join . $where;
 
+		return $this->getTasksFromSQLwithParams($sqlQuery, $arrFilter);
+	}
+	
 	/**
-	*	Gets a list of tasks by group project name
+	* getGroupProjectNames - Gets all information about the project groups
 	*
+	* @return Array - an array of all project groups available
+	*/
+	function getGroupProjectNames() {
+
+		$select = "SELECT DISTINCT pgl.group_project_id, pgl.group_id, pgl.project_name, g.group_id, g.group_name FROM project_group_list pgl";
+		$join = " INNER JOIN groups g ON (pgl.group_id = g.group_id)";
+		$join .= " INNER JOIN project_task pt ON (pt.group_project_id = pgl.group_project_id)";
+		$join .= " INNER JOIN project_assigned_to pat ON (pt.project_task_id = pat.project_task_id)";
+		$where = " WHERE pat.assigned_to_id = $1";
+
+		$sqlQuery = $select . $join . $where;
+
+		return  $this->getProjectGroupsFromSQLwithParams($sqlQuery, array($this->User->getID()));
+	}
+
+	/**
+	* Gets a list of tasks by group project name
+	*
 	* @return an array of ProjectTask objects
 	*/
 	function &getTasksByGroupProjectName () {

Modified: trunk/gforge_base/evolvisforge/gforge/www/my/index.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/my/index.php	2011-10-31 14:44:48 UTC (rev 17677)
+++ trunk/gforge_base/evolvisforge/gforge/www/my/index.php	2011-11-02 09:10:41 UTC (rev 17678)
@@ -31,8 +31,11 @@
 require_once $gfcommon.'forum/ForumsForUser.class.php';
 require_once $gfcommon.'pm/ProjectTasksForUser.class.php';
 require_once $gfwww.'tracker/include/ArtifactTypeHtml.class.php';
+require_once $gfwww.'/pm/include/ProjectTaskHTML.class.php';
+require_once $gfcommon.'include/Group.class.php';
+require_once $gfwww.'pm/include/ProjectGroupHTML.class.php'; //
 
-if (!session_loggedin()) { // || $sf_user_hash) {
+if (!session_loggedin()) {
 
 	exit_not_logged_in();
 
@@ -43,29 +46,37 @@
 	$requestedExtraFieldParams = array();
 	$requestedExtraFieldParams = getArrayFromRequest('extra_fields');
 	
+	$requestedStatusIds = array();
+	$requestedStatusIds = getArrayFromRequest('status_ids');
+	
 	$artifact_type_id = getIntFromRequest('artifact_type_id');
+	$project_group_id = getIntFromRequest('project_group_id');
+	
 	$requestedExtraField = array();
 	
-		foreach($requestedExtraFieldParams as $requestedExtraFieldParam) {
-			foreach($requestedExtraFieldParam as $param) {
-				array_push($requestedExtraField, $param);
-			}
-		}	
+	foreach($requestedExtraFieldParams as $requestedExtraFieldParam) {
+		foreach($requestedExtraFieldParam as $param) {
+			array_push($requestedExtraField, $param);
+		}
+	}	
 	
 	$artifactsForUser = new ArtifactsForUser($user);
-	
 	$allAssignedArtifacts =& $artifactsForUser->getAssignedArtifactBugsGroups();
 
  	$pref_ = minijson_encode($requestedExtraField, false);
+ 	$pref = minijson_encode($requestedStatusIds, false);
+ 	
  	if($artifact_type_id != 0) {
  		$user->setPreference('mypage_bug_res_'.$artifact_type_id,$pref_);
  	}
+ 	
+ 	if($project_group_id != 0) {
+ 		$user->setPreference('mypage_task_'.$project_group_id,$pref);
+ 	}
 
-
 	$arrGroupProjectValues = array('group_id' => array(), 'group_artifact_type_id' => array(), 'group_public_name' => array(), 'group_artifact_name' => array(), 'artifact_extra_fields' => array(), 'element_ids' => array(), 'group' => array());
-	
+		
 	$tmpGroupId = null;
-	$arrTest = array();
 	$requestedExtraFieldIds = array();
 	foreach($allAssignedArtifacts as $thisArtifact) {
 		if($tmpGroupId != $thisArtifact->ArtifactType->Group->getID()) {
@@ -154,35 +165,34 @@
 
 		$j = 0;
 		foreach($arrGroupProjectValues['group_id'] as $thisGroupId) {
-		$artifactTypeId = $arrGroupProjectValues['group_artifact_type_id'][$j];
-		$publicName = $arrGroupProjectValues['group_public_name'][$j];
-		$group = $arrGroupProjectValues['group'][$j];
-		$groupName = $arrGroupProjectValues['group'][$j]->getPublicName();
-		$artifactTypeName = $arrGroupProjectValues['group_artifact_name'][$j];
-		$arrExtraFieldData = $arrGroupProjectValues['artifact_extra_fields'][$j];
+			$artifactTypeId = $arrGroupProjectValues['group_artifact_type_id'][$j];
+			$publicName = $arrGroupProjectValues['group_public_name'][$j];
+			$group = $arrGroupProjectValues['group'][$j];
+			$groupName = $arrGroupProjectValues['group'][$j]->getPublicName();
+			$artifactTypeName = $arrGroupProjectValues['group_artifact_name'][$j];
+			$arrExtraFieldData = $arrGroupProjectValues['artifact_extra_fields'][$j];
 
-					echo '
-					<tr><td colspan="4" class="tablecontent myPageArtifactGroupHeader">'.
-					'<form action="'.getStringFromServer('PHP_SELF').'" method="post">';
-					echo '<input type="hidden" name="artifact_type_id" value="'.$artifactTypeId.'" />';
-					echo util_make_link ( '/tracker/?group_id='.$thisGroupId.'&atid='.$artifactTypeId, $groupName.' - '.$artifactTypeName);
+				echo '
+				<tr><td colspan="4" class="tablecontent myPageArtifactGroupHeader">'.
+				'<form action="'.getStringFromServer('PHP_SELF').'" method="post">';
+				echo '<input type="hidden" name="artifact_type_id" value="'.$artifactTypeId.'" />';
+				echo util_make_link ( '/tracker/?group_id='.$thisGroupId.'&atid='.$artifactTypeId, $groupName.' - '.$artifactTypeName);
 
-					echo '   ';
+				echo '   ';
 
-						foreach($arrExtraFieldData as $extraFieldData) {
+					foreach($arrExtraFieldData as $extraFieldData) {
 
-							if($extraFieldData['field_name'] == 'Resolution') {
-								$id = $extraFieldData['extra_field_id'];
+						if($extraFieldData['field_name'] == 'Resolution') {
+							$id = $extraFieldData['extra_field_id'];
 
-								$ath = new ArtifactTypeHtml($group);
-									echo $ath->renderCheckbox($id, $requestedExtraFieldIds, false, 'none', 'horizontal');
-							}
+							$ath = new ArtifactTypeHtml($group);
+							echo $ath->renderCheckbox($id, $requestedExtraFieldIds, false, 'none', 'horizontal');
 						}
+					}
 
-					echo '   <input type="submit" value="'._('Hide selected').'" /></form></td>';
+				echo '   <input type="submit" value="'._('Hide selected').'" /></form></td>';
+				echo '</tr>';
 
-					echo '</tr>';
-
 			$j++;
 			$i=0;
 			foreach($assignedArtifacts as $art) {
@@ -192,16 +202,16 @@
 
 				if($group_id === $thisGroupId) {
 
-				$i++;
-				echo '
-				<tr '. $HTML->boxGetAltRowStyle($i++) .'>
-				<td width="10%">'.$art->getID().'</td>
-				<td width="10%" class="priority'.$art->getPriority().'">'.$art->getPriority().'</td>
-				<td>'.
-				util_make_link ('/tracker/?func=detail&aid='.$art->getID().'&group_id='.$art->ArtifactType->Group->getID().'&atid='.$art->ArtifactType->getID(),$art->getSummary()).'</td>' .
-				'<td>'.$art->getElementName().'</td></tr>';
+					$i++;
+					echo '
+					<tr '. $HTML->boxGetAltRowStyle($i++) .'>
+					<td width="10%">'.$art->getID().'</td>
+					<td width="10%" class="priority'.$art->getPriority().'">'.$art->getPriority().'</td>
+					<td>'.
+					util_make_link ('/tracker/?func=detail&aid='.$art->getID().'&group_id='.$art->ArtifactType->Group->getID().'&atid='.$art->ArtifactType->getID(),$art->getSummary()).'</td>' .
+					'<td>'.$art->getElementName().'</td></tr>';
 
-				$last_group = $art->ArtifactType->getID();
+					$last_group = $art->ArtifactType->getID();
 				}
 			}
 		}
@@ -215,7 +225,6 @@
 <br />
 
 
-
 <div><b><?php echo _('Remaining'). ' '._('assigned artifacts'); ?></b></div>
 
 <div class="tabbertab myPageArtifactTaskDiv" title="<?php echo _('Assigned Artifacts'); ?>">
@@ -274,6 +283,13 @@
 <div class="tabbertab myPageArtifactTaskDiv" title="<?php echo _('Assigned Tasks'); ?>">
 
 <?php
+
+	$projectTasksForUser = new ProjectTasksForUser($user);
+
+	$status = $projectTasksForUser->getStatus();
+	
+	$userGroups = $projectTasksForUser->getGroupProjectNames(); //First loop
+
 	/*
 		Tasks assigned to me
 	*/
@@ -284,35 +300,78 @@
 	$order_name_arr[]=_('Priority');
 	$order_name_arr[]=_('Summary');
 	echo $HTML->listTableTop($order_name_arr,'',$tabcnt);
-	$projectTasksForUser = new ProjectTasksForUser($user);
-	$userTasks =& $projectTasksForUser->getTasksByGroupProjectName();
 
-	if (count($userTasks) > 0) {
-		$i=0;
-		foreach ($userTasks as $task) {
+	$arrGroupProjectTaskValues = array('group_id' => array(), 
+		'group_artifact_type_id' => array(), 
+		'group_public_name' => array(), 
+		'group_artifact_name' => array(), 
+		'artifact_extra_fields' => array(), 
+		'element_ids' => array(), 
+		'group' => array());
 
-			/* Deduce summary style */
-			$style_begin='';
-			$style_end='';
-			if ($task->getPercentComplete()==100) {
-				$style_begin='<span style="text-decoration:underline">';
-				$style_end='</span>';
+	if (count($userGroups) > 0) {
+		
+		foreach($userGroups as $userGroup) {
+		
+			$i=0;	
+			$firstProjectGroup = $userGroup->getID();
+					
+			$g =& group_get_object($userGroup->getGroup()->getID());
+			if (!$g || !is_object($g)) {
+				exit_no_group();
+			} elseif ($g->isError()) {
+				exit_error('Error',$g->getErrorMessage());
 			}
-			//if ($task->getProjectGroup()->getID() != $last_group) {
-			$projectGroup =& $task->getProjectGroup();
-			$group =& $projectGroup->getGroup();
-			if ($projectGroup->getID() != $last_group) {
-				echo '
-				<tr><td colspan="3" class="tablecontent myPageArtifactGroupHeader">'.
-				util_make_link ('/pm/task.php?group_id='.$group->getID().'&group_project_id='.$projectGroup->getID(),$group->getPublicName().' - '.$projectGroup->getName()).'</td></tr>';
+
+			$pg = new ProjectGroupHTML($g,$userGroup->getID());
+			if (!$pg || !is_object($pg)) {
+				exit_error('Error','Could Not Get Factory');
+			} elseif ($pg->isError()) {
+				exit_error('Error',$pg->getErrorMessage());
 			}
-			echo '
-			<tr '. $HTML->boxGetAltRowStyle($i++) .'>
-			<td width="10%">'.$task->getID().'</td>
-			<td width="10%" class="priority'.$task->getPriority().'">'.$task->getPriority().'</td>
-			<td>'.util_make_link ('/pm/task.php?func=detailtask&project_task_id='.$task->getID().'&group_id='.$group->getID().'&group_project_id='.$projectGroup->getID(),$style_begin.$task->getSummary().$style_end).'</td></tr>';
 
-			$last_group = $projectGroup->getID();
+			$projectTaskHTML = new ProjectTaskHTML($pg);
+
+			$strJson=$user->getPreference('mypage_task_'.$userGroup->getID());
+			if($strJson != '') {
+				minijson_decode($strJson, &$requestedStatusIds);
+			}	
+
+			echo '<tr><td colspan="3" class="tablecontent myPageArtifactGroupHeader">';
+			echo '<form action="'.getStringFromServer('PHP_SELF').'" method="post">';
+			echo '<input type="hidden" name="project_group_id" value="'.$userGroup->getID().'" />';
+			echo util_make_link ('/pm/task.php?group_id='.$userGroup->getGroup()->getID().'&group_project_id='.$userGroup->getID(),$userGroup->getGroup()->getPublicName().' - '.$userGroup->getName());
+
+			
+			echo $projectTaskHTML->renderCheckbox($status, $requestedStatusIds, false, 'none', 'horizontal');	
+			echo '   ';
+			echo '<input type="submit" value="'._('Hide selected').'" /></form></td></tr>';
+
+			
+			$userTasksByStatus = $projectTasksForUser->getTasksByStatus($requestedStatusIds);
+			foreach ($userTasksByStatus as $task) {
+	 
+				$projectGroup =& $task->getProjectGroup();
+				$group =& $projectGroup->getGroup();
+				
+				$secondProjectGroup = $projectGroup->getID();
+				
+				if($firstProjectGroup === $secondProjectGroup) {
+
+					/* Deduce summary style */
+					$style_begin='';
+					$style_end='';
+					if ($task->getPercentComplete()==100) {
+						$style_begin='<span style="text-decoration:underline">';
+						$style_end='</span>';
+					}
+
+					echo '<tr '. $HTML->boxGetAltRowStyle($i++) .'>
+					<td width="10%">'.$task->getID().'</td>
+					<td width="10%" class="priority'.$task->getPriority().'">'.$task->getPriority().'</td>
+					<td>'.util_make_link ('/pm/task.php?func=detailtask&project_task_id='.$task->getID().'&group_id='.$group->getID().'&group_project_id='.$projectGroup->getID(),$style_begin.$task->getSummary().$style_end).'</td></tr>';				
+				}
+			}
 		}
 	} else {
 		echo '
@@ -339,7 +398,7 @@
 	$order_name_arr[]=_('Summary');
 	echo $HTML->listTableTop($order_name_arr,'',$tabcnt);
 	$artifactsForUser = new ArtifactsForUser($user);
-	$submittedArtifacts =& $artifactsForUser->getSubmittedArtifactsByGroup(); 
+	$submittedArtifacts =& $artifactsForUser->getSubmittedArtifactsByGroup();
 	
 	if (count($submittedArtifacts) > 0) {
 		$i=0;

Modified: trunk/gforge_base/evolvisforge/gforge/www/pm/include/ProjectTaskHTML.class.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/www/pm/include/ProjectTaskHTML.class.php	2011-10-31 14:44:48 UTC (rev 17677)
+++ trunk/gforge_base/evolvisforge/gforge/www/pm/include/ProjectTaskHTML.class.php	2011-11-02 09:10:41 UTC (rev 17678)
@@ -72,8 +72,48 @@
 		$arr2 =& $this->getAssignedTo();
 		return html_build_multiple_select_box ($result,$name,$arr2);
 	}
+	
+	/**
+	 *	renderCheckbox - this function builds checkboxes.
+	 *	
+	 *	@param		int 	The ID of this field.
+	 *	@param 		array	The items that should be checked
+	 *	@param		string	Whether to show the '100 row'
+	 *	@param		string	What to call the '100 row'
+	 *	@return		checkbox
+	 */	
+	function renderCheckbox ($status_ids,$checked=array(),$show_100=false,$text_100='none',$alignment='vertical') {
+		
+		if ($text_100 == 'none'){
+			$text_100=_('None');
+		}
+		if (!$checked || !is_array($checked)) {
+			$checked=array();
+		}
+		
+		$return = "";
+		if ($show_100) {
+			$return .= '
+				<input type="checkbox" name="status_ids[]" value="100" '.
+			((in_array(100,$checked)) ? 'checked="checked" ' : '').'/>'.$text_100;
+			if($alignment == 'vertical') {
+				$return .= '<br />';
+			}
+			
+		}
+		for ($i=0; $i<count($status_ids['status_id']); $i++) {
+			$return .= '
+				<input type="checkbox" name="status_ids[]" value="'.$status_ids['status_id'][$i].'" '.
+			((in_array($status_ids['status_id'][$i], $checked)) ? 'checked="checked" ' : '').'/> '.$status_ids['status_name'][$i];
+			if($alignment == 'vertical') {
+				$return .= '<br />';
+			}
+		}
 
+		return $return;
+	}
 
+
 	function showDependentTasks () {
 		$sql="SELECT project_task.project_task_id,project_task.summary FROM project_task".
 		" INNER JOIN project_dependencies ON (project_task.project_task_id = project_dependencies.is_dependent_on_task_id)".



More information about the evolvis-commits mailing list