function _getMessageForUser(&$user, $message_type, $params) { $msg = ''; switch ($message_type) { case self::MESSAGE_ADDED: $monitoredItem = $this->_getMonitoredItemForUser($user, $params['parent']); $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_added_mail_body', array($params['path']->get($params['parent']), $user->getRealName(), $this->_url, $params['parent']->getId(), $params['item']->getTitle(), $monitoredItem->getId())); break; default: $msg .= parent::_getMessageForUser($user, $message_type, $params); break; } return $msg; }
function _getMessageForUser(&$user, $message_type, $params) { $msg = ''; $dpm = $this->_getPermissionsManager(); switch ($message_type) { case self::MESSAGE_MOVED: $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_mail_body_begin', array($params['item']->getTitle(), $user->getRealName(), $this->_url, $params['parent']->getId())); $msg .= " "; $need_sep = false; if ($dpm->userCanAccess($params['user_monitor'], $params['old_parent']->getId())) { $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_from', array($params['path']->get($params['old_parent']))); $need_sep = true; } if ($dpm->userCanAccess($params['user_monitor'], $params['parent']->getId())) { if ($need_sep) { $msg .= "\n "; } $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_to', array($params['path']->get($params['parent']))); } $monitoredItem = $this->_getMonitoredItemForUser($user, $params['item']); $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_mail_body_end', array($this->_url, $monitoredItem->getId())); break; case self::MESSAGE_MOVED_FROM: $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_from_mail_body_begin', array($params['path']->get($params['old_parent']), $user->getRealName(), $this->_url, $params['parent']->getId(), $params['item']->getTitle())); $msg .= " "; if ($dpm->userCanAccess($params['user_monitor'], $params['old_parent']->getId())) { $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_from', array($params['path']->get($params['old_parent']))); } if ($dpm->userCanAccess($params['user_monitor'], $params['parent']->getId())) { $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_to', array($params['path']->get($params['parent']))); } $monitoredItem = $this->_getMonitoredItemForUser($user, $params['old_parent']); $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_mail_body_end', array($this->_url, $monitoredItem->getId())); break; case self::MESSAGE_MOVED_TO: $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_from_mail_body_begin', array($params['path']->get($params['parent']), $user->getRealName(), $this->_url, $params['parent']->getId(), $params['item']->getTitle())); $msg .= " "; if ($dpm->userCanAccess($params['user_monitor'], $params['old_parent']->getId())) { $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_from', array($params['path']->get($params['old_parent']))); } if ($dpm->userCanAccess($params['user_monitor'], $params['parent']->getId())) { $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_to', array($params['path']->get($params['parent']))); } $monitoredItem = $this->_getMonitoredItemForUser($user, $params['parent']); $msg .= $GLOBALS['Language']->getText('plugin_docman', 'notifications_moved_mail_body_end', array($this->_url, $monitoredItem->getId())); break; default: $msg .= parent::_getMessageForUser($user, $message_type, $params); break; } return $msg; }
/** * Constructor * * @param Integer $group_id The group id * @param String $url Default url of docman controller * @param Feedback $feedback Docman controller feedback * * @return void */ function __construct($group_id, $url, $feedback) { parent::__construct($group_id, $url, $feedback); }
/** * Function called when a project goes from public to private so * documents monitored by non member users should be monitored no more. * * @param array $params * * @return void */ function projectIsPrivate($params) { $groupId = $params['group_id']; $private = $params['project_is_private']; if ($private) { require_once 'Docman_ItemFactory.class.php'; $docmanItemFactory = new Docman_ItemFactory(); $root = $docmanItemFactory->getRoot($groupId); if ($root) { require_once 'Docman_NotificationsManager.class.php'; $notificationsManager = new Docman_NotificationsManager($this->getProject($groupId), null, null, $this->getMailBuilder()); $dar = $notificationsManager->listAllMonitoredItems($groupId); if ($dar && !$dar->isError()) { $userManager = UserManager::instance(); $user = null; foreach ($dar as $row) { $user = $userManager->getUserById($row['user_id']); if (!$user->isMember($groupId)) { $notificationsManager->remove($row['user_id'], $row['object_id'], $row['type']); } } } } } }