Add "direct message" type instead of sending "You have a message from X" see #7717

1.10.x
Julio Montoya 10 years ago
parent cccc193660
commit 2e8fb1ab8c
  1. 7
      main/inc/lib/AnnouncementEmail.php
  2. 26
      main/inc/lib/message.lib.php
  3. 35
      main/inc/lib/notification.lib.php

@ -309,7 +309,8 @@ class AnnouncementEmail
$subject,
$message,
$sender['user_id'],
$sendToDrhUsers
$sendToDrhUsers,
true
);
}
@ -329,7 +330,9 @@ class AnnouncementEmail
$user['user_id'],
$subject,
$message,
$sender['user_id']
$sender['user_id'],
false,
true
);
}
}

@ -195,7 +195,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);
@ -316,8 +317,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,
@ -350,8 +355,10 @@ class MessageManager
$group_info
);
}
return $inbox_last_id;
}
return false;
}
@ -360,7 +367,8 @@ class MessageManager
* @param int $subject
* @param string $message
* @param int $sender_id
* @param int $sendCopyToDrhUsers send copy to related DRH users
* @param bool $sendCopyToDrhUsers send copy to related DRH users
* @param bool $directMessage
*
* @return bool
*/
@ -369,7 +377,8 @@ class MessageManager
$subject,
$message,
$sender_id = null,
$sendCopyToDrhUsers = false
$sendCopyToDrhUsers = false,
$directMessage = false
) {
$result = MessageManager::send_message(
$receiver_user_id,
@ -381,7 +390,8 @@ class MessageManager
null,
null,
null,
$sender_id
$sender_id,
$directMessage
);
if ($sendCopyToDrhUsers) {
@ -399,12 +409,12 @@ class MessageManager
$drhInfo['user_id'],
$subject,
$message,
$sender_id
$sender_id,
false,
$directMessage
);
}
}
}
return $result;

@ -31,13 +31,13 @@ class Notification extends Model
public $adminEmail;
public $titlePrefix;
//mail_notify_message ("At once", "Daily", "No")
// mail_notify_message ("At once", "Daily", "No")
const NOTIFY_MESSAGE_AT_ONCE = 1;
const NOTIFY_MESSAGE_DAILY = 8;
const NOTIFY_MESSAGE_WEEKLY = 12;
const NOTIFY_MESSAGE_NO = 0;
//mail_notify_invitation ("At once", "Daily", "No")
// mail_notify_invitation ("At once", "Daily", "No")
const NOTIFY_INVITATION_AT_ONCE = 1;
const NOTIFY_INVITATION_DAILY = 8;
const NOTIFY_INVITATION_WEEKLY = 12;
@ -48,13 +48,16 @@ class Notification extends Model
const NOTIFY_GROUP_DAILY = 8;
const NOTIFY_GROUP_WEEKLY = 12;
const NOTIFY_GROUP_NO = 0;
// Notification types
const NOTIFICATION_TYPE_MESSAGE = 1;
const NOTIFICATION_TYPE_INVITATION = 2;
const NOTIFICATION_TYPE_GROUP = 3;
const NOTIFICATION_TYPE_WALL_MESSAGE = 4;
const NOTIFICATION_TYPE_DIRECT_MESSAGE = 5;
/**
*
* Constructor
*/
public function __construct()
{
@ -102,7 +105,7 @@ class Notification extends Model
/**
* Send the notifications
* @param int notification frequency
* @param int $frequency notification frequency
*/
public function send($frequency = 8)
{
@ -138,7 +141,7 @@ class Notification extends Model
/**
* @param string $title
* @param array $senderInfo
* @param array $senderInfo
*
* @return string
*/
@ -152,6 +155,7 @@ class Notification extends Model
$title = $data['title'];
}
}
$newTitle = $this->getTitlePrefix();
switch ($this->type) {
@ -166,6 +170,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(
@ -205,14 +212,14 @@ class Notification extends Model
/**
* Save message notification
* @param int $type message type
* @param int $type message type
* NOTIFICATION_TYPE_MESSAGE,
* NOTIFICATION_TYPE_INVITATION,
* NOTIFICATION_TYPE_GROUP
* @param array $user_list recipients: user list of ids
* @param string $title
* @param string $content
* @param array $sender_info
* @param array $user_list recipients: user list of ids
* @param string $title
* @param string $content
* @param array $sender_info
* result of api_get_user_info() or GroupPortalManager:get_group_data()
*/
public function save_notification(
@ -230,6 +237,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;
@ -339,6 +347,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