|
|
|
@ -47,6 +47,9 @@ class Notification extends Model |
|
|
|
|
const NOTIFICATION_TYPE_INVITATION = 2; |
|
|
|
|
const NOTIFICATION_TYPE_GROUP = 3; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public function __construct() |
|
|
|
|
{ |
|
|
|
|
$this->table = Database::get_main_table(TABLE_NOTIFICATION); |
|
|
|
@ -63,16 +66,23 @@ class Notification extends Model |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Send the notifications |
|
|
|
|
* @param int notification frecuency |
|
|
|
|
* @param int notification frequency |
|
|
|
|
*/ |
|
|
|
|
public function send($frec = 8) |
|
|
|
|
public function send($frequency = 8) |
|
|
|
|
{ |
|
|
|
|
$notifications = $this->find('all', array('where' => array('sent_at IS NULL AND send_freq = ?' => $frec))); |
|
|
|
|
$notifications = $this->find('all', array('where' => array('sent_at IS NULL AND send_freq = ?' => $frequency))); |
|
|
|
|
|
|
|
|
|
if (!empty($notifications)) { |
|
|
|
|
foreach ($notifications as $item_to_send) { |
|
|
|
|
// Sending email |
|
|
|
|
api_mail_html($item_to_send['dest_mail'], $item_to_send['dest_mail'], Security::filter_terms($item_to_send['title']), Security::filter_terms($item_to_send['content']), $this->admin_name, $this->admin_email); |
|
|
|
|
api_mail_html( |
|
|
|
|
$item_to_send['dest_mail'], |
|
|
|
|
$item_to_send['dest_mail'], |
|
|
|
|
Security::filter_terms($item_to_send['title']), |
|
|
|
|
Security::filter_terms($item_to_send['content']), |
|
|
|
|
$this->admin_name, |
|
|
|
|
$this->admin_email |
|
|
|
|
); |
|
|
|
|
if ($this->debug) { |
|
|
|
|
error_log('Sending message to: '.$item_to_send['dest_mail']); |
|
|
|
|
} |
|
|
|
@ -104,15 +114,15 @@ class Notification extends Model |
|
|
|
|
$avoid_my_self = false; |
|
|
|
|
|
|
|
|
|
switch ($this->type) { |
|
|
|
|
case self::NOTIFICATION_TYPE_MESSAGE; |
|
|
|
|
case self::NOTIFICATION_TYPE_MESSAGE: |
|
|
|
|
$setting_to_check = 'mail_notify_message'; |
|
|
|
|
$default_status = self::NOTIFY_MESSAGE_AT_ONCE; |
|
|
|
|
break; |
|
|
|
|
case self::NOTIFICATION_TYPE_INVITATION; |
|
|
|
|
case self::NOTIFICATION_TYPE_INVITATION: |
|
|
|
|
$setting_to_check = 'mail_notify_invitation'; |
|
|
|
|
$default_status = self::NOTIFY_INVITATION_AT_ONCE; |
|
|
|
|
break; |
|
|
|
|
case self::NOTIFICATION_TYPE_GROUP; |
|
|
|
|
case self::NOTIFICATION_TYPE_GROUP: |
|
|
|
|
$setting_to_check = 'mail_notify_group_message'; |
|
|
|
|
$default_status = self::NOTIFY_GROUP_AT_ONCE; |
|
|
|
|
$avoid_my_self = true; |
|
|
|
@ -178,8 +188,9 @@ class Notification extends Model |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Formats the content in order to add the welcome message, the notification preference, etc |
|
|
|
|
* @param string the content |
|
|
|
|
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data() |
|
|
|
|
* @param string the content |
|
|
|
|
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data() |
|
|
|
|
* @param string |
|
|
|
|
* */ |
|
|
|
|
public function format_content($content, $sender_info) |
|
|
|
|
{ |
|
|
|
|