Add type NOTIFICATION_TYPE_DIRECT_MESSAGE see BT#9609

1.9.x
Julio Montoya 10 years ago
parent ca4b522fe0
commit 351ce47d5f
  1. 10
      main/announcements/announcement_email.class.php
  2. 18
      main/inc/lib/message.lib.php
  3. 12
      main/inc/lib/notification.lib.php

@ -292,7 +292,7 @@ class AnnouncementEmail
* Send emails to users.
* @param bool $sendToUsersInSession
*/
public function send($sendToUsersInSession = false)
public function send($sendToUsersInSession = false, $sendToDrhUsers = false)
{
$sender = $this->sender();
$subject = $this->subject();
@ -306,7 +306,9 @@ class AnnouncementEmail
$user['user_id'],
$subject,
$message,
$sender['user_id']
$sender['user_id'],
$sendToDrhUsers,
true
);
}
@ -323,7 +325,9 @@ class AnnouncementEmail
$user['user_id'],
$subject,
$message,
$sender['user_id']
$sender['user_id'],
false,
true
);
}
}

@ -212,6 +212,8 @@ class MessageManager
* @param int $edit_message_id id for updating the message (optional)
* @param int $topic_id (optional) the default value is the current user_id
* @param int $sender_id
* @param bool $directMessage
*
* @return bool
*/
public static function send_message(
@ -224,7 +226,8 @@ class MessageManager
$parent_id = 0,
$edit_message_id = 0,
$topic_id = 0,
$sender_id = null
$sender_id = null,
$directMessage = false
) {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
@ -340,8 +343,12 @@ class MessageManager
$sender_info = api_get_user_info($user_sender_id);
if (empty($group_id)) {
$type = Notification::NOTIFICATION_TYPE_MESSAGE;
if ($directMessage) {
$type = Notification::NOTIFICATION_TYPE_DIRECT_MESSAGE;
}
$notification->save_notification(
Notification::NOTIFICATION_TYPE_MESSAGE,
$type,
array($receiver_user_id),
$subject,
$content,
@ -382,7 +389,9 @@ class MessageManager
$receiver_user_id,
$subject,
$message,
$sender_id = null
$sender_id = null,
$sendCopyToDrhUsers = false,
$directMessage = false
) {
return MessageManager::send_message(
$receiver_user_id,
@ -394,7 +403,8 @@ class MessageManager
null,
null,
null,
$sender_id
$sender_id,
$directMessage
);
}

@ -52,6 +52,7 @@ class Notification extends Model
const NOTIFICATION_TYPE_INVITATION = 2;
const NOTIFICATION_TYPE_GROUP = 3;
const NOTIFICATION_TYPE_WALL_MESSAGE = 4;
const NOTIFICATION_TYPE_DIRECT_MESSAGE = 5;
/**
*
@ -158,6 +159,9 @@ class Notification extends Model
$newTitle .= sprintf(get_lang('YouHaveANewMessageFromX'), $senderName);
}
break;
case self::NOTIFICATION_TYPE_DIRECT_MESSAGE:
$newTitle = $title;
break;
case self::NOTIFICATION_TYPE_INVITATION:
if (!empty($senderInfo)) {
$senderName = api_get_person_name(
@ -214,6 +218,7 @@ class Notification extends Model
$avoid_my_self = false;
switch ($this->type) {
case self::NOTIFICATION_TYPE_DIRECT_MESSAGE:
case self::NOTIFICATION_TYPE_MESSAGE:
$setting_to_check = 'mail_notify_message';
$defaultStatus = self::NOTIFY_MESSAGE_AT_ONCE;
@ -312,6 +317,13 @@ class Notification extends Model
$new_message_text = $link_to_new_message = '';
switch ($this->type) {
case self::NOTIFICATION_TYPE_DIRECT_MESSAGE:
$new_message_text = $content;
$link_to_new_message = Display::url(
get_lang('SeeMessage'),
api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'
);
break;
case self::NOTIFICATION_TYPE_MESSAGE:
if (!empty($sender_info)) {
$senderName = api_get_person_name(

Loading…
Cancel
Save