If notify settings are not set, use "send upon reception" by default see BT#11805

pull/2487/head
jmontoyaa 9 years ago
parent 0ce264055e
commit 7125c336fd
  1. 2
      main/inc/lib/message.lib.php
  2. 24
      main/inc/lib/notification.lib.php
  3. 45
      main/inc/lib/usermanager.lib.php

@ -235,7 +235,6 @@ class MessageManager
$now = api_get_utc_datetime();
if (!empty($receiver_user_id) || !empty($group_id)) {
// message for user friend
//@todo it's possible to edit a message? yes, only for groups
if ($edit_message_id) {
@ -246,7 +245,6 @@ class MessageManager
Database::query($query);
$inbox_last_id = $edit_message_id;
} else {
$params = [
'user_sender_id' => $user_sender_id,
'user_receiver_id' => $receiver_user_id,

@ -216,15 +216,16 @@ class Notification extends Model
* NOTIFICATION_TYPE_MESSAGE,
* NOTIFICATION_TYPE_INVITATION,
* NOTIFICATION_TYPE_GROUP
* @param array $user_list recipients: user list of ids
* @param array $userList 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()
* @param array $senderInfo result of api_get_user_info() or GroupPortalManager:get_group_data()
* @param array $attachments
*
*/
public function save_notification(
$type,
$user_list,
$userList,
$title,
$content,
$senderInfo = array(),
@ -259,8 +260,8 @@ class Notification extends Model
$settingInfo = UserManager::get_extra_field_information_by_name($settingToCheck);
if (!empty($user_list)) {
foreach ($user_list as $user_id) {
if (!empty($userList)) {
foreach ($userList as $user_id) {
if ($avoid_my_self) {
if ($user_id == api_get_user_id()) {
continue;
@ -273,9 +274,16 @@ class Notification extends Model
if (!empty($settingInfo)) {
$extra_data = UserManager::get_extra_user_data($user_id);
if (isset($extra_data[$settingToCheck]) && !empty($extra_data[$settingToCheck])) {
if (isset($extra_data[$settingToCheck])) {
$userSetting = $extra_data[$settingToCheck];
}
// Means that user extra was not set
// Then send email now.
if ($userSetting === '') {
$userSetting = NOTIFY_MESSAGE_AT_ONCE;
}
}
$sendDate = null;
@ -329,7 +337,7 @@ class Notification extends Model
$this->save($params);
}
self::sendPushNotification($user_list, $title, $content);
self::sendPushNotification($userList, $title, $content);
}
}

@ -223,7 +223,7 @@ class UserManager
$expirationDate = null,
$active = 1,
$hr_dept_id = 0,
$extra = null,
$extra = [],
$encrypt_method = '',
$send_mail = false,
$isAdmin = false,
@ -383,12 +383,25 @@ class UserManager
}
if (api_get_multiple_access_url()) {
UrlManager::add_user_to_url($return, api_get_current_access_url_id());
UrlManager::add_user_to_url($userId, api_get_current_access_url_id());
} else {
//we are adding by default the access_url_user table with access_url_id = 1
UrlManager::add_user_to_url($return, 1);
UrlManager::add_user_to_url($userId, 1);
}
if (is_array($extra) && count($extra) > 0) {
foreach ($extra as $fname => $fvalue) {
self::update_extra_field_value($userId, $fname, $fvalue);
}
} else {
// Create notify settings by default
self::update_extra_field_value($userId, 'mail_notify_invitation', '1');
self::update_extra_field_value($userId, 'mail_notify_message', '1');
self::update_extra_field_value($userId, 'mail_notify_group_message', '1');
}
self::update_extra_field_value($userId, 'already_logged_in', 'false');
if (!empty($email) && $send_mail) {
$recipient_name = api_get_person_name(
$firstName,
@ -483,29 +496,21 @@ class UserManager
}
/* ENDS MANAGE EVENT WITH MAIL */
}
Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $return);
if (!empty($hook)) {
$hook->setEventData(array(
'return' => $userId,
'originalPassword' => $original_password
));
$hook->notifyCreateUser(HOOK_EVENT_TYPE_POST);
}
Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $userId);
} else {
Display::addFlash(Display::return_message(get_lang('ErrorContactPlatformAdmin')));
return false;
}
if (is_array($extra) && count($extra) > 0) {
$res = true;
foreach ($extra as $fname => $fvalue) {
$res = $res && self::update_extra_field_value($return, $fname, $fvalue);
}
}
self::update_extra_field_value($return, 'already_logged_in', 'false');
if (!empty($hook)) {
$hook->setEventData(array(
'return' => $return,
'originalPassword' => $original_password
));
$hook->notifyCreateUser(HOOK_EVENT_TYPE_POST);
}
return $return;
}

Loading…
Cancel
Save