|
|
@ -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; |
|
|
|