Fixing the notification.lib.php

skala
Julio Montoya 14 years ago
parent ee3408c69b
commit ff530dca35
  1. 6
      main/inc/lib/message.lib.php
  2. 16
      main/inc/lib/notification.lib.php

@ -215,7 +215,7 @@ class MessageManager
* @param bool sent an email or not (@todo) * @param bool sent an email or not (@todo)
* @return bool * @return bool
*/ */
public static function send_message ($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $sent_email = false) { public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $sent_email = false) {
global $charset; global $charset;
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id); $group_id = intval($group_id);
@ -294,10 +294,10 @@ class MessageManager
$user_id = $receiver_user_id; $user_id = $receiver_user_id;
$notification->save_message_notifications(array($user_id), $subject,$content); $notification->save_message_notifications(array($user_id), $subject,$content);
} else { } else {
$user_list = GroupPortalManager::get_users_by_group($group_id); $user_list = GroupPortalManager::get_users_by_group($group_id, false, array(),0, 1000);
$new_user_list = array(); $new_user_list = array();
foreach($user_list as $user_data) { foreach($user_list as $user_data) {
$new_user_list []= $user_data['user_id']; $new_user_list[]= $user_data['user_id'];
} }
$notification->save_group_notifications($new_user_list, $subject,$content); $notification->save_group_notifications($new_user_list, $subject,$content);
} }

@ -31,7 +31,7 @@ class Notification extends Model {
var $table; var $table;
var $columns = array('id','dest_user_id','dest_mail','title','content','send_freq','created_at','sent_at'); var $columns = array('id','dest_user_id','dest_mail','title','content','send_freq','created_at','sent_at');
var $max_content_length = 255; var $max_content_length = 254; //Max lenght of the notification.content field
var $debug = true; var $debug = true;
public function __construct() { public function __construct() {
@ -43,7 +43,8 @@ class Notification extends Model {
if (!empty($notifications)) { if (!empty($notifications)) {
foreach($notifications as $item_to_send) { foreach($notifications as $item_to_send) {
//Sending email //Sending email
api_send_mail($item_to_send['dest_mail'], $item_to_send['title'], $item_to_send['content']); //$name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
api_mail_html($item_to_send['dest_mail'], $item_to_send['dest_mail'], $item_to_send['title'], $item_to_send['content']);
if ($this->debug) { error_log('Sending message to: '.$item_to_send['dest_mail']); } if ($this->debug) { error_log('Sending message to: '.$item_to_send['dest_mail']); }
//Updating //Updating
$item_to_send['sent_at'] = api_get_utc_datetime(); $item_to_send['sent_at'] = api_get_utc_datetime();
@ -71,7 +72,8 @@ class Notification extends Model {
case NOTIFY_MESSAGE_AT_ONCE: case NOTIFY_MESSAGE_AT_ONCE:
$user_info = api_get_user_info($user_id); $user_info = api_get_user_info($user_id);
if (!empty($user_info['mail'])) { if (!empty($user_info['mail'])) {
api_send_mail($user_info['mail'], $title, cut($content, $this->max_content_length)); $name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
api_mail_html($name, $user_info['mail'], $title, $content);
} }
$params['sent_at'] = api_get_utc_datetime(); $params['sent_at'] = api_get_utc_datetime();
default: default:
@ -107,7 +109,8 @@ class Notification extends Model {
case NOTIFY_INVITATION_AT_ONCE: case NOTIFY_INVITATION_AT_ONCE:
$user_info = api_get_user_info($user_id); $user_info = api_get_user_info($user_id);
if (!empty($user_info['mail'])) { if (!empty($user_info['mail'])) {
api_send_mail($user_info['mail'], $title, cut($content, $this->max_content_length)); $name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
api_mail_html($name, $user_info['mail'], $title, $content);
} }
$params['sent_at'] = api_get_utc_datetime(); $params['sent_at'] = api_get_utc_datetime();
default: default:
@ -148,7 +151,8 @@ class Notification extends Model {
case NOTIFY_GROUP_AT_ONCE: case NOTIFY_GROUP_AT_ONCE:
$user_info = api_get_user_info($user_id); $user_info = api_get_user_info($user_id);
if (!empty($user_info['mail'])) { if (!empty($user_info['mail'])) {
api_send_mail($user_info['mail'], $subject, cut($content,150)); $name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
api_mail_html($name, $user_info['mail'], $title, $content);
} }
$params['sent_at'] = api_get_utc_datetime(); $params['sent_at'] = api_get_utc_datetime();
default: default:
@ -157,7 +161,7 @@ class Notification extends Model {
$params['dest_user_id'] = $user_id; $params['dest_user_id'] = $user_id;
$params['dest_mail'] = $user_info['mail']; $params['dest_mail'] = $user_info['mail'];
$params['title'] = $subject; $params['title'] = $subject;
$params['content'] = cut($content,150); $params['content'] = cut($content,$this->max_content_length);
$params['send_freq'] = $extra_data['mail_notify_group_message']; $params['send_freq'] = $extra_data['mail_notify_group_message'];
$this->save($params); $this->save($params);
break; break;

Loading…
Cancel
Save