--- knowledgeTree-OSS-orig/lib/subscriptions/subscriptions.inc.php	2007-06-21 17:49:23.000000000 +0200
+++ ktdms/knowledgeTree/lib/subscriptions/subscriptions.inc.php	2007-07-06 14:40:50.000000000 +0200
@@ -94,6 +94,10 @@
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+                  
 		
 		    // notification object first.		
 		    $aNotificationOptions = array();
@@ -113,6 +117,7 @@
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
     }
     function AddDocument ($oAddedDocument, $oParentFolder) { 
@@ -121,15 +126,18 @@
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null - is this valid?
-		    $aNotificationOptions['target_name'] = $oAddedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oAddedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "AddDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null - is this valid?
+			$aNotificationOptions['target_name'] = $oAddedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oAddedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "AddDocument";		
 			
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
@@ -141,6 +149,7 @@
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
     }
     function RemoveFolder($oRemovedFolder, $oParentFolder) {
@@ -153,8 +162,11 @@
 		$aUsers = $this->_getSubscribers($oRemovedFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
 			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
@@ -164,8 +176,6 @@
 			$aNotificationOptions['event_type'] = "RemoveSubscribedFolder";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 			    $emailSubject = $content->getEmailAlertSubject($oNotification);
@@ -178,31 +188,34 @@
 			if (!(PEAR::isError($oSubscription) || ($oSubscription == false))) {
 			    $oSubscription->delete();
 			}
+		  }
 		}
 		
 		// now handle (for those who haven't been alerted) users watching the folder.
 		$aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oRemovedFolder->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
-		    $aNotificationOptions['event_type'] = "RemoveChildFolder";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oRemovedFolder->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
+			$aNotificationOptions['event_type'] = "RemoveChildFolder";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
 	}
@@ -216,19 +229,20 @@
 		$aUsers = $this->_getSubscribers($oRemovedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oRemovedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
-		    $aNotificationOptions['event_type'] = "RemoveSubscribedDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oRemovedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
+			$aNotificationOptions['event_type'] = "RemoveSubscribedDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
@@ -241,31 +255,34 @@
 			if (!(PEAR::isError($oSubscription) || ($oSubscription == false))) {
 			    $oSubscription->delete();
 			}
+		  }
 		}
 		
 		// now handle (for those who haven't been alerted) users watching the folder.
 		$aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oRemovedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
-		    $aNotificationOptions['event_type'] = "RemoveChildDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oRemovedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oParentFolder->getId();  // parent folder_id, since the removed one is removed.
+			$aNotificationOptions['event_type'] = "RemoveChildDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
 	}
@@ -275,50 +292,54 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "ModifyDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+		 	$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "ModifyDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
 			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "ModifyDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "ModifyDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
     }
     
@@ -328,49 +349,53 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "DiscussDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "DiscussDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "DiscussDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "DiscussDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
     }
     
@@ -380,44 +405,47 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "CheckInDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "CheckInDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "CheckInDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "CheckInDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
@@ -425,6 +453,7 @@
 				$oEmail->send();
 
 			}
+		  }
 		}
     }
     function CheckOutDocument($oModifiedDocument, $oParentFolder)  { 
@@ -433,50 +462,56 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
 		
-		    // notification object first.		
+			// notification object first.		
 			$aNotificationOptions = array();
 			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "CheckOutDocument";		
+			$aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			$aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			$aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			$aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			$aNotificationOptions['event_type'] = "CheckOutDocument";		
 			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
+				
 			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
 			    $emailContent = $content->getEmailAlertContent($oNotification);
 				$emailSubject = $content->getEmailAlertSubject($oNotification);
 				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
 				$oEmail->send();
 			}
+		  }
 		}
 		
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
-		
-		    // notification object first.		
-			$aNotificationOptions = array();
-			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "CheckOutDocument";		
-			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
-			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-			    $emailContent = $content->getEmailAlertContent($oNotification);
-				$emailSubject = $content->getEmailAlertSubject($oNotification);
-				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-				$oEmail->send();
-			}
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+		
+			    // notification object first.		
+				$aNotificationOptions = array();
+				$aNotificationOptions['target_user'] = $oSubscriber->getID();
+			    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			    $aNotificationOptions['event_type'] = "CheckOutDocument";		
+				$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+				// now the email content.			
+				// FIXME this needs to be handled entirely within notifications from now on.
+				if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+				    $emailContent = $content->getEmailAlertContent($oNotification);
+					$emailSubject = $content->getEmailAlertSubject($oNotification);
+					$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+					$oEmail->send();
+				}
+		  }
 		}
     }
 
@@ -487,73 +522,85 @@
 	$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 
 	foreach ($aUsers as $oSubscriber) {
-	    // notification object first.		
-	    $aNotificationOptions = array();
-	    $aNotificationOptions['target_user'] = $oSubscriber->getID();
-	    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-	    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
-	    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId());
-	    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
-	    $aNotificationOptions['event_type'] = "MovedDocument";		
-	    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-	    // now the email content.			
-	    // FIXME this needs to be handled entirely within notifications from now on.
-	    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-		$emailContent = $content->getEmailAlertContent($oNotification);
-		$emailSubject = $content->getEmailAlertSubject($oNotification);
-		$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-		$oEmail->send();
-	    }
+	  //The user who do the action don't need a notification
+	  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+	  {
+		    // notification object first.		
+		    $aNotificationOptions = array();
+		    $aNotificationOptions['target_user'] = $oSubscriber->getID();
+		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+		    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
+		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId());
+		    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
+		    $aNotificationOptions['event_type'] = "MovedDocument";		
+		    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+		    // now the email content.			
+		    // FIXME this needs to be handled entirely within notifications from now on.
+		    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+			$emailContent = $content->getEmailAlertContent($oNotification);
+			$emailSubject = $content->getEmailAlertSubject($oNotification);
+			$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+			$oEmail->send();
+		    }
+	  }
 	}
 		
 		
         $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]);
 	$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 	foreach ($aUsers as $oSubscriber) {
+	  //The user who do the action don't need a notification
+	  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+	  {
 	    
-	    // notification object first.		
-	    $aNotificationOptions = array();
-	    $aNotificationOptions['target_user'] = $oSubscriber->getID();
-	    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-	    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
-	    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId());
-	    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
-	    $aNotificationOptions['event_type'] = "MovedDocument";		
-	    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-	    
-	    // now the email content.			
-	    // FIXME this needs to be handled entirely within notifications from now on.
-	    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-		$emailContent = $content->getEmailAlertContent($oNotification);
-		$emailSubject = $content->getEmailAlertSubject($oNotification);
-		$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-		$oEmail->send();
-	    }
+		    // notification object first.		
+		    $aNotificationOptions = array();
+		    $aNotificationOptions['target_user'] = $oSubscriber->getID();
+		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+		    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
+		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId());
+		    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
+		    $aNotificationOptions['event_type'] = "MovedDocument";		
+		    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+		    
+		    // now the email content.			
+		    // FIXME this needs to be handled entirely within notifications from now on.
+		    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+			$emailContent = $content->getEmailAlertContent($oNotification);
+			$emailSubject = $content->getEmailAlertSubject($oNotification);
+			$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+			$oEmail->send();
+		    }
+	  }
 	}
 	
         $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]);
 	$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 	foreach ($aUsers as $oSubscriber) {
+	  //The user who do the action don't need a notification
+	  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+	  {
 	    
-	    // notification object first.		
-	    $aNotificationOptions = array();
-	    $aNotificationOptions['target_user'] = $oSubscriber->getID();
-	    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-	    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
-	    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-	    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
-	    $aNotificationOptions['event_type'] = "MovedDocument";		
-	    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-	    
-	    // now the email content.			
-	    // FIXME this needs to be handled entirely within notifications from now on.
-	    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-		$emailContent = $content->getEmailAlertContent($oNotification);
-		$emailSubject = $content->getEmailAlertSubject($oNotification);
-		$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-		$oEmail->send();
-	    }
+		    // notification object first.		
+		    $aNotificationOptions = array();
+		    $aNotificationOptions['target_user'] = $oSubscriber->getID();
+		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+		    $aNotificationOptions['target_name'] = $oMovedDocument->getName();
+		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+		    $aNotificationOptions['object_id'] = $oToFolder->getId();  // parent folder_id, in this case.
+		    $aNotificationOptions['event_type'] = "MovedDocument";		
+		    $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+		    
+		    // now the email content.			
+		    // FIXME this needs to be handled entirely within notifications from now on.
+		    if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+			$emailContent = $content->getEmailAlertContent($oNotification);
+			$emailSubject = $content->getEmailAlertSubject($oNotification);
+			$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+			$oEmail->send();
+		    }
+	  }
 	}		
     }
     function ArchivedDocument($oModifiedDocument, $oParentFolder)  { 
@@ -562,50 +609,58 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
-		
-		    // notification object first.		
-			$aNotificationOptions = array();
-			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "ArchivedDocument";		
-			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
-			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-			    $emailContent = $content->getEmailAlertContent($oNotification);
-				$emailSubject = $content->getEmailAlertSubject($oNotification);
-				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-				$oEmail->send();
-			}
-		}
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+		
+			    // notification object first.		
+				$aNotificationOptions = array();
+				$aNotificationOptions['target_user'] = $oSubscriber->getID();
+			    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			    $aNotificationOptions['event_type'] = "ArchivedDocument";		
+				$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+				// now the email content.			
+				// FIXME this needs to be handled entirely within notifications from now on.
+				if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+				    $emailContent = $content->getEmailAlertContent($oNotification);
+					$emailSubject = $content->getEmailAlertSubject($oNotification);
+					$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+					$oEmail->send();
+				}
+		  }
+	  }
 		
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
-		
-		    // notification object first.		
-			$aNotificationOptions = array();
-			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "ArchivedDocument";		
-			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
-			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-			    $emailContent = $content->getEmailAlertContent($oNotification);
-				$emailSubject = $content->getEmailAlertSubject($oNotification);
-				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-				$oEmail->send();
-			}
+		  //The user who do the action don't need a notification
+	  	  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+		
+			    // notification object first.		
+				$aNotificationOptions = array();
+				$aNotificationOptions['target_user'] = $oSubscriber->getID();
+			    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			    $aNotificationOptions['event_type'] = "ArchivedDocument";		
+				$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+				// now the email content.			
+				// FIXME this needs to be handled entirely within notifications from now on.
+				if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+				    $emailContent = $content->getEmailAlertContent($oNotification);
+					$emailSubject = $content->getEmailAlertSubject($oNotification);
+					$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+					$oEmail->send();
+				}
+		  }
 		}
     }
 	
@@ -615,50 +670,58 @@
         $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
-		
-		    // notification object first.		
-			$aNotificationOptions = array();
-			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "RestoreArchivedDocument";		
-			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
-			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-			    $emailContent = $content->getEmailAlertContent($oNotification);
-				$emailSubject = $content->getEmailAlertSubject($oNotification);
-				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-				$oEmail->send();
-			}
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+			
+			    // notification object first.		
+				$aNotificationOptions = array();
+				$aNotificationOptions['target_user'] = $oSubscriber->getID();
+			    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			    $aNotificationOptions['event_type'] = "RestoreArchivedDocument";		
+				$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+				// now the email content.			
+				// FIXME this needs to be handled entirely within notifications from now on.
+				if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+				    $emailContent = $content->getEmailAlertContent($oNotification);
+					$emailSubject = $content->getEmailAlertSubject($oNotification);
+					$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+					$oEmail->send();
+				}
+		  }
 		}
 		
 		
         $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
 		$aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users.  _might_ be a singleton.
 		foreach ($aUsers as $oSubscriber) {
-		
-		    // notification object first.		
-			$aNotificationOptions = array();
-			$aNotificationOptions['target_user'] = $oSubscriber->getID();
-		    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
-		    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
-		    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
-		    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
-		    $aNotificationOptions['event_type'] = "RestoreArchivedDocument";		
-			$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
-			
-			// now the email content.			
-			// FIXME this needs to be handled entirely within notifications from now on.
-			if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
-			    $emailContent = $content->getEmailAlertContent($oNotification);
-				$emailSubject = $content->getEmailAlertSubject($oNotification);
-				$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
-				$oEmail->send();
-			}
+		  //The user who do the action don't need a notification
+		  if ( $oSubscriber->getId() != KTUtil::arrayGet($_SESSION,"userID", null) )
+		  {
+		
+			    // notification object first.		
+				$aNotificationOptions = array();
+				$aNotificationOptions['target_user'] = $oSubscriber->getID();
+			    $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null.
+			    $aNotificationOptions['target_name'] = $oModifiedDocument->getName();
+			    $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
+			    $aNotificationOptions['object_id'] = $oModifiedDocument->getId();  // parent folder_id, in this case.
+			    $aNotificationOptions['event_type'] = "RestoreArchivedDocument";		
+				$oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
+				
+				// now the email content.			
+				// FIXME this needs to be handled entirely within notifications from now on.
+				if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
+				    $emailContent = $content->getEmailAlertContent($oNotification);
+					$emailSubject = $content->getEmailAlertSubject($oNotification);
+					$oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent);
+					$oEmail->send();
+				}
+		  }
 		}
     }
 
