mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-08 20:46:05 +00:00
add methods sendRequestWorkflowActionMail and sendTriggerWorkflowTransitionMail
This commit is contained in:
parent
33ad98bdfd
commit
96ca072528
|
@ -1038,5 +1038,86 @@ class SeedDMS_NotificationService {
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
public function sendTriggerWorkflowTransitionMail($content, $user, $wkflog) { /* {{{ */
|
||||
$document = $content->getDocument();
|
||||
$workflow = $wkflog->getWorkflow();
|
||||
$transition = $wkflog->getTransition();
|
||||
$nl = $document->getNotifyList();
|
||||
$folder = $document->getFolder();
|
||||
$subject = "transition_triggered_email_subject";
|
||||
$message = "transition_triggered_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $document->getName();
|
||||
$params['version'] = $content->getVersion();
|
||||
$params['workflow'] = $workflow->getName();
|
||||
$params['action'] = $transition->getAction()->getName();
|
||||
$params['folder_path'] = $folder->getFolderPathPlain();
|
||||
$params['comment'] = $wkflog->getComment();
|
||||
$params['previous_state'] = $transition->getState()->getName();
|
||||
$params['current_state'] = $transition->getNextState()->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();
|
||||
|
||||
// Send notification to subscribers.
|
||||
$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 notification is sent when a workflow action needed.
|
||||
* If a transition is passed this must be the translation lately fired, hence
|
||||
* the state of the workflow is next state of the transition. If no transition
|
||||
* is passed, the workflow just started and is still in its initial state.
|
||||
*/
|
||||
public function sendRequestWorkflowActionMail($content, $user, $transition=null) { /* {{{ */
|
||||
$document = $content->getDocument();
|
||||
$folder = $document->getFolder();
|
||||
if($transition) {
|
||||
$workflow = $transition->getWorkflow();
|
||||
$state = $transition->getNextState();
|
||||
} else {
|
||||
$workflow = $content->getWorkflow();
|
||||
$state = $workflow->getInitState();
|
||||
}
|
||||
|
||||
if($this->settings->_enableNotificationWorkflow) {
|
||||
$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();
|
||||
if($transition)
|
||||
$params['current_state'] = $transition->getNextState()->getName();
|
||||
else
|
||||
$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();
|
||||
|
||||
$usersinformed = array();
|
||||
$groupsinformed = array();
|
||||
foreach($workflow->getNextTransitions($state) as $ntransition) {
|
||||
foreach($ntransition->getUsers() as $tuser) {
|
||||
if(!in_array($tuser->getUser()->getID(), $usersinformed)) {
|
||||
$usersinformed[] = $tuser->getUser()->getID();
|
||||
$this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW);
|
||||
}
|
||||
}
|
||||
foreach($ntransition->getGroups() as $tuser) {
|
||||
if(!in_array($tuser->getGroup()->getID(), $groupsinformed)) {
|
||||
$groupsinformed[] = $tuser->getGroup()->getID();
|
||||
$this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user