[evolvis-commits] r6503: - [#572] Eyecatcher in Status-Emails. It works but it could be optimized. Will try it soon.

papel at evolvis.org papel at evolvis.org
Thu Apr 1 11:12:13 CEST 2010


Author: papel
Date: 2010-04-01 09:12:12 +0000 (Thu, 01 Apr 2010)
New Revision: 6503

Modified:
   trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTask.class.php
   trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/mod_task.php
   trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/task.php
Log:
- [#572] Eyecatcher in Status-Emails. It works but it could be optimized. Will try it soon.

Modified: trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTask.class.php
===================================================================
--- trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTask.class.php	2010-04-01 08:59:58 UTC (rev 6502)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/common/pm/ProjectTask.class.php	2010-04-01 09:12:12 UTC (rev 6503)
@@ -931,6 +931,11 @@
 		$status_id,$category_id,$percent_complete,&$assigned_arr,&$depend_arr,
 		$new_group_project_id,$duration=0,$parent_id=0) {
 		$has_changes = false; // if any of the values passed is different from
+		
+		$arrChangedAndInNotice = array("details"=>"","summary"=>"",
+		"complete"=>"","status"=>"","subproject"=>""); /* includes only 
+		entries that changed and will be sended by E-Mail (sendNotice()) */
+		
 		$v = new Validator();
 		$v->check($summary, "summary");
 		$v->check($priority, "priority");
@@ -1001,11 +1006,14 @@
 			$this->ProjectGroup =& $newProjectGroup;
 			$this->addHistory ('group_project_id',$group_project_id);
 			$has_changes = true;
+			$arrChangedAndInNotice['subproject'] = ">";
 		}
 
 
 		if ($details) {
 			$has_changes = true;
+			if($details != "" && $details != null) {$arrChangedAndInNotice['details'] = ">";}
+			//Message vorhanden;
 			if (!$this->addMessage($details)) {
 				db_rollback();
 				return false;
@@ -1014,6 +1022,7 @@
 		if ($this->getStatusID() != $status_id) { 
 			$this->addHistory ('status_id',$this->getStatusID());
 			$has_changes = true;
+			$arrChangedAndInNotice['status'] = ">";
 		}
 
 		if ($this->getCategoryID() != $category_id)	{
@@ -1029,11 +1038,13 @@
 		if ($this->getSummary() != htmlspecialchars(stripslashes($summary))) {
 			$this->addHistory ('summary',addslashes($this->getSummary()));
 			$has_changes = true;
+			$arrChangedAndInNotice['summary'] = ">";
 		}
 
 		if ($this->getPercentComplete() != $percent_complete) {
 			$this->addHistory ('percent_complete',$this->getPercentComplete());
 			$has_changes = true;
+			$arrChangedAndInNotice['complete'] = ">";
 		}
 
 		if ($this->getHours() != $hours) {
@@ -1113,7 +1124,7 @@
 					return false;
 				} else {
 					if ($has_changes) { //only send email if there was any change
-						$this->sendNotice();
+						$this->sendNotice(false, $arrChangedAndInNotice);
 					}
 					db_commit();
 					return true;
@@ -1128,8 +1139,9 @@
 	 *
 	 *	@return	boolean	success.
 	 */
-	function sendNotice($first=false) {
+	function sendNotice($first=false, $arrChangedAndInNotice=array()) {
 		global $send_task_email;
+
 		if ($send_task_email===false) {
 			return true;
 		}
@@ -1143,11 +1155,11 @@
 		}
 
 		$body = "Task #". $this->getID() ." has been updated. ".
-			"\n\nProject: ". $this->ProjectGroup->Group->getPublicName() .
-			"\nSubproject: ". $this->ProjectGroup->getName() .
-			"\nSummary: ".util_unconvert_htmlspecialchars( $this->getSummary() ).
-			"\nComplete: ". $this->getPercentComplete() ."%".
-			"\nStatus: ". $this->getStatusName() .
+			"\n\nProject: ". $this->ProjectGroup->Group->getPublicName() 
+			."\n". $arrChangedAndInNotice['subproject']."Subproject: ". $this->ProjectGroup->getName() 
+			."\n". $arrChangedAndInNotice['summary']. "Summary: ".util_unconvert_htmlspecialchars( $this->getSummary() )
+			."\n". $arrChangedAndInNotice['complete']. "Complete: ". $this->getPercentComplete() ."%"
+			."\n". $arrChangedAndInNotice['status']. "Status: ". $this->getStatusName() .
 			"\n\nDescription: ". util_unconvert_htmlspecialchars( $this->getDetails() );
 
 		/*
@@ -1160,12 +1172,14 @@
 		if ($result2 && $rows > 0) {
 			$body .= "\n\nFollow-Ups:";
 			for ($i=0; $i<$rows;$i++) {
+				if($i===0){ $temp = $arrChangedAndInNotice['details']; } else {$temp = "";}
 				$body .= "\n\n-------------------------------------------------------";
 				$body .= "\nDate: ". date(_('Y-m-d H:i'),db_result($result2,$i,'postdate'));
 				$body .= "\nBy: ".db_result($result2,$i,'user_name');
-				$body .= "\n\nComment:\n".util_unconvert_htmlspecialchars(db_result($result2,$i,'body'));
+				$body .= "\n\n". $temp ."Comment:\n".util_unconvert_htmlspecialchars(db_result($result2,$i,'body'));
 			}
 		}
+
 		$body .= "\n\n-------------------------------------------------------".
 			"\nFor more info, visit:".
 			"\n\n".util_make_url ('/pm/task.php?func=detailtask&project_task_id='.$this->getID().

Modified: trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/mod_task.php
===================================================================
--- trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/mod_task.php	2010-04-01 08:59:58 UTC (rev 6502)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/mod_task.php	2010-04-01 09:12:12 UTC (rev 6503)
@@ -42,6 +42,7 @@
 	$old_time_code = getStringFromRequest('old_time_code');
 	$hours = getStringFromRequest('hours');
 
+	if($group_project_id != $new_group_project_id) {$group_project_id = $new_group_project_id;}
 
 if (getStringFromRequest('add')) {
 		$days_adjust = getIntFromRequest('days_adjust');

Modified: trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/task.php
===================================================================
--- trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/task.php	2010-04-01 08:59:58 UTC (rev 6502)
+++ trunk/gforge_base/gforge-4.8.1+evolvis/www/pm/task.php	2010-04-01 09:12:12 UTC (rev 6503)
@@ -73,8 +73,6 @@
 	Figure out which function we're dealing with here
 */
 
-#echo '<b>'.getStringFromRequest('func').'</b>';
-
 switch (getStringFromRequest('func')) {
 
 	//
@@ -167,23 +165,39 @@
 						exit_error('ERROR','removeRelatedArtifacts():: '.$pt->getErrorMessage());
 					}
 				}
-				$feedback=_('Task Updated Successfully');
+				$feedback=_('Task Updated Successfully');		
 				
-				#Detailtask begin
-				#include $gfwww.'pm/browse_task.php'; OLD	
-				$pt=new ProjectTaskHTML($pg,$project_task_id);
-				if (!$pt || !is_object($pt)) {
+			    if (!$group_id || !$group_project_id) {
+					exit_missing_param();
+				}
+
+				$g =& group_get_object($group_id);
+				
+				if (!$g || !is_object($g)) {
+					exit_no_group();
+				} elseif ($g->isError()) {
+					exit_error('Error',$g->getErrorMessage());
+				} 
+				  
+				$pg = new ProjectGroupHTML($g, $new_group_project_id);
+				if (!$pg || !is_object($pg)) {
+					exit_error('Error','Could Not Get Factory');
+				} elseif ($pg->isError()) {
+					exit_error('Error',$pg->getErrorMessage());
+				} 
+
+				$pt=new ProjectTaskHTML($pg, $project_task_id);
+				if (!$pt|| !is_object($pt)) {
 					exit_error('Error','Could Not Get ProjectTask');
 				} elseif ($pt->isError()) {
 					exit_error('Error',$pt->getErrorMessage());
-				}
+				}  
 
 				if (session_loggedin() && $pg->userIsAdmin()) {
 					include $gfwww.'pm/mod_task.php';
 				} else {
 					include $gfwww.'pm/detail_task.php';
-				}	
-				#detailtask end
+				} 
 				
 			}
 		} else {




More information about the evolvis-commits mailing list