mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	add more methods for sending mails
This commit is contained in:
		
							parent
							
								
									64c6c21592
								
							
						
					
					
						commit
						d6a296c071
					
				|  | @ -152,110 +152,183 @@ class SeedDMS_NotificationService { | |||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * | ||||
| 	 * This notification is sent when a workflow action is needed. | ||||
| 	 */ | ||||
| 	public function sendNewDocumentMail($document, $user) { | ||||
| 	public function sendRequestWorkflowActionMail($content, $user) { /* {{{ */ | ||||
| 		$document = $content->getDocument(); | ||||
| 		$folder = $document->getFolder(); | ||||
| 			$fnl = $folder->getNotifyList(); | ||||
| 			$dnl = $document->getNotifyList(); | ||||
| 			$nl = array( | ||||
| 				'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR), | ||||
| 				'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR) | ||||
| 			); | ||||
| 
 | ||||
| 			$lc = $document->getLatestContent(); | ||||
| 			$subject = "new_document_email_subject"; | ||||
| 			$message = "new_document_email_body"; | ||||
| 		/* Send mail only if enabled in the configuration */ | ||||
| 		if($this->settings->_enableNotificationWorkflow && ($workflow = $content->getWorkflow())) { | ||||
| 			$subject = "request_workflow_action_email_subject"; | ||||
| 			$message = "request_workflow_action_email_body"; | ||||
| 			$params = array(); | ||||
| 			$params['name'] = $document->getName(); | ||||
| 			$params['version'] = $content->getVersion(); | ||||
| 			$params['workflow'] = $workflow->getName(); | ||||
| 			$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 			$params['current_state'] = $workflow->getInitState()->getName(); | ||||
| 			$params['username'] = $user->getFullName(); | ||||
| 			$params['sitename'] = $this->settings->_siteName; | ||||
| 			$params['http_root'] = $this->settings->_httpRoot; | ||||
| 			$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 
 | ||||
| 			foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) { | ||||
| 				foreach($ntransition->getUsers() as $tuser) { | ||||
| 					$this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); | ||||
| 				} | ||||
| 				foreach($ntransition->getGroups() as $tuser) { | ||||
| 					$this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * This notification is sent when a review or approval is needed. | ||||
| 	 */ | ||||
| 	public function sendRequestRevAppActionMail($content, $user) { /* {{{ */ | ||||
| 		$document = $content->getDocument(); | ||||
| 		$folder = $document->getFolder(); | ||||
| 
 | ||||
| 		if($this->settings->_enableNotificationAppRev) { | ||||
| 			/* Reviewers and approvers will be informed about the new document */ | ||||
| 			$reviewers = $content->getReviewers(); //$controller->getParam('reviewers');
 | ||||
| 			$approvers = $content->getApprovers(); //$controller->getParam('approvers');
 | ||||
| 			if($reviewers['i'] || $reviewers['g']) { | ||||
| 				$subject = "review_request_email_subject"; | ||||
| 				$message = "review_request_email_body"; | ||||
| 				$params = array(); | ||||
| 				$params['name'] = $document->getName(); | ||||
| 				$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 				$params['version'] = $content->getVersion(); | ||||
| 				$params['comment'] = $document->getComment(); | ||||
| 				$params['username'] = $user->getFullName(); | ||||
| 				$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 				$params['sitename'] = $this->settings->_siteName; | ||||
| 				$params['http_root'] = $this->settings->_httpRoot; | ||||
| 
 | ||||
| 				foreach($reviewers['i'] as $reviewer) { | ||||
| 					$this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); | ||||
| 				} | ||||
| 				foreach($reviewers['g'] as $reviewergrp) { | ||||
| 					$this->toGroup($user, $reviewergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			elseif($approvers['i'] || $approvers['g']) { | ||||
| 				$subject = "approval_request_email_subject"; | ||||
| 				$message = "approval_request_email_body"; | ||||
| 				$params = array(); | ||||
| 				$params['name'] = $document->getName(); | ||||
| 				$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 				$params['version'] = $content->getVersion(); | ||||
| 				$params['comment'] = $document->getComment(); | ||||
| 				$params['username'] = $user->getFullName(); | ||||
| 				$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 				$params['sitename'] = $this->settings->_siteName; | ||||
| 				$params['http_root'] = $this->settings->_httpRoot; | ||||
| 
 | ||||
| 				foreach($approvers['i'] as $approver) { | ||||
| 					$this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); | ||||
| 				} | ||||
| 				foreach($approvers['g'] as $approvergrp) { | ||||
| 					$this->toGroup($user, $approvergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * This notification is sent when a new document is created. | ||||
| 	 */ | ||||
| 	public function sendNewDocumentMail($document, $user) { /* {{{ */ | ||||
| 		$folder = $document->getFolder(); | ||||
| 		$fnl = $folder->getNotifyList(); | ||||
| 		$dnl = $document->getNotifyList(); | ||||
| 		$nl = array( | ||||
| 			'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR), | ||||
| 			'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR) | ||||
| 		); | ||||
| 
 | ||||
| 		$lc = $document->getLatestContent(); | ||||
| 		$subject = "new_document_email_subject"; | ||||
| 		$message = "new_document_email_body"; | ||||
| 		$params = array(); | ||||
| 		$params['name'] = $document->getName(); | ||||
| 		$params['folder_name'] = $folder->getName(); | ||||
| 		$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 		$params['username'] = $user->getFullName(); | ||||
| 		$params['comment'] = $document->getComment(); | ||||
| 		$params['version_comment'] = $lc->getComment(); | ||||
| 		$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 		$params['sitename'] = $this->settings->_siteName; | ||||
| 		$params['http_root'] = $this->settings->_httpRoot; | ||||
| 		$this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 		foreach ($nl["groups"] as $grp) { | ||||
| 			$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->sendRequestWorkflowActionMail($lc, $user); | ||||
| 
 | ||||
| 		$this->sendRequestRevAppActionMail($lc, $user); | ||||
| 
 | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * This notification is sent when a new document version is created. | ||||
| 	 */ | ||||
| 	public function sendNewDocumentVersionMail($document, $user) { /* {{{ */ | ||||
| 		$lc = $document->getLatestContent(); | ||||
| 		$folder = $document->getFolder(); | ||||
| 		$notifyList = $document->getNotifyList(); | ||||
| 
 | ||||
| 		$subject = "document_updated_email_subject"; | ||||
| 		$message = "document_updated_email_body"; | ||||
| 		$params = array(); | ||||
| 		$params['name'] = $document->getName(); | ||||
| 		$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 		$params['username'] = $user->getFullName(); | ||||
| 		$params['comment'] = $document->getComment(); | ||||
| 		$params['version_comment'] = $lc->getComment(); | ||||
| 		$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 		$params['sitename'] = $this->settings->_siteName; | ||||
| 		$params['http_root'] = $this->settings->_httpRoot; | ||||
| 		$this->toList($user, $notifyList["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 		foreach ($notifyList["groups"] as $grp) { | ||||
| 			$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 		} | ||||
| //	 if user is not owner send notification to owner
 | ||||
| //		if ($user->getID() != $document->getOwner()->getID()) 
 | ||||
| //			$this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
 | ||||
| 
 | ||||
| 		$this->sendRequestWorkflowActionMail($lc, $user); | ||||
| 
 | ||||
| 		$this->sendRequestRevAppActionMail($lc, $user); | ||||
| 
 | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	public function sendChangedExpiryMail($document, $user, $oldexpires) { /* {{{ */ | ||||
| 		$folder = $document->getFolder(); | ||||
| 		$notifyList = $document->getNotifyList(); | ||||
| 
 | ||||
| 		if($oldexpires != $document->getExpires()) { | ||||
| 			// Send notification to subscribers.
 | ||||
| 			$subject = "expiry_changed_email_subject"; | ||||
| 			$message = "expiry_changed_email_body"; | ||||
| 			$params = array(); | ||||
| 			$params['name'] = $document->getName(); | ||||
| 			$params['folder_name'] = $folder->getName(); | ||||
| 			$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 			$params['username'] = $user->getFullName(); | ||||
| 			$params['comment'] = $document->getComment(); | ||||
| 			$params['version_comment'] = $lc->getComment(); | ||||
| 			$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 			$params['sitename'] = $this->settings->_siteName; | ||||
| 			$params['http_root'] = $this->settings->_httpRoot; | ||||
| 			$this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 			foreach ($nl["groups"] as $grp) { | ||||
| 			$this->toList($user, $notifyList["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 			foreach ($notifyList["groups"] as $grp) { | ||||
| 				$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); | ||||
| 			} | ||||
| 
 | ||||
| 			/* Get workflow from controller in case it was modified in a hook */ | ||||
| //			$workflow = $controller->getParam('workflow');
 | ||||
| 			if($this->settings->_enableNotificationWorkflow && ($workflow = $lc->getWorkflow())) { | ||||
| 				$subject = "request_workflow_action_email_subject"; | ||||
| 				$message = "request_workflow_action_email_body"; | ||||
| 				$params = array(); | ||||
| 				$params['name'] = $document->getName(); | ||||
| 				$params['version'] = $lc->getVersion(); | ||||
| 				$params['workflow'] = $workflow->getName(); | ||||
| 				$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 				$params['current_state'] = $workflow->getInitState()->getName(); | ||||
| 				$params['username'] = $user->getFullName(); | ||||
| 				$params['sitename'] = $this->settings->_siteName; | ||||
| 				$params['http_root'] = $this->settings->_httpRoot; | ||||
| 				$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 
 | ||||
| 				foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) { | ||||
| 					foreach($ntransition->getUsers() as $tuser) { | ||||
| 						$this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); | ||||
| 					} | ||||
| 					foreach($ntransition->getGroups() as $tuser) { | ||||
| 						$this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			if($this->settings->_enableNotificationAppRev) { | ||||
| 				/* Reviewers and approvers will be informed about the new document */ | ||||
| 				/* Get reviewers and approvers from controller in case it was | ||||
| 				 * modified in a hook | ||||
| 				 */ | ||||
| 				$reviewers = $lc->getReviewers(); //$controller->getParam('reviewers');
 | ||||
|         $approvers = $lc->getApprovers(); //$controller->getParam('approvers');
 | ||||
| 				if($reviewers['i'] || $reviewers['g']) { | ||||
| 					$subject = "review_request_email_subject"; | ||||
| 					$message = "review_request_email_body"; | ||||
| 					$params = array(); | ||||
| 					$params['name'] = $document->getName(); | ||||
| 					$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 					$params['version'] = $lc->getVersion(); | ||||
| 					$params['comment'] = $document->getComment(); | ||||
| 					$params['username'] = $user->getFullName(); | ||||
| 					$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 					$params['sitename'] = $this->settings->_siteName; | ||||
| 					$params['http_root'] = $this->settings->_httpRoot; | ||||
| 
 | ||||
| 					foreach($reviewers['i'] as $reviewer) { | ||||
| 						$this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); | ||||
| 					} | ||||
| 					foreach($reviewers['g'] as $reviewergrp) { | ||||
| 						$this->toGroup($user, $reviewergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); | ||||
| 					} | ||||
| 				} | ||||
| 
 | ||||
| 				elseif($approvers['i'] || $approvers['g']) { | ||||
| 					$subject = "approval_request_email_subject"; | ||||
| 					$message = "approval_request_email_body"; | ||||
| 					$params = array(); | ||||
| 					$params['name'] = $document->getName(); | ||||
| 					$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 					$params['version'] = $lc->getVersion(); | ||||
| 					$params['comment'] = $document->getComment(); | ||||
| 					$params['username'] = $user->getFullName(); | ||||
| 					$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); | ||||
| 					$params['sitename'] = $this->settings->_siteName; | ||||
| 					$params['http_root'] = $this->settings->_httpRoot; | ||||
| 
 | ||||
| 					foreach($approvers['i'] as $approver) { | ||||
| 						$this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); | ||||
| 					} | ||||
| 					foreach($approvers['g'] as $approvergrp) { | ||||
| 						$this->toGroup($user, $approvergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann