ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCronForumNotification Class Reference
+ Collaboration diagram for ilCronForumNotification:

Public Member Functions

 sendMails ($res)
 sendNotifications ()

Detailed Description

Definition at line 12 of file class.ilCronForumNotification.php.

Member Function Documentation

ilCronForumNotification::sendMails (   $res)

Definition at line 14 of file class.ilCronForumNotification.php.

References $_GET, $cache, $ilDB, $lng, $ref_id, $res, $row, ilObject\_getAllReferences(), ilForum\_getLanguageInstanceByUsrId(), and ilObjUser\_lookupLogin().

Referenced by sendNotifications().

{
global $ilias, $rbacsystem, $ilAccess, $ilDB, $lng;
static $cache = array();
include_once 'Modules/Forum/classes/class.ilObjForum.php';
include_once 'Services/Mail/classes/class.ilMail.php';
include_once 'Services/User/classes/class.ilObjUser.php';
include_once 'Services/Language/classes/class.ilLanguage.php';
$forumObj = new ilObjForum((int)$_GET['ref_id']);
$frm = $forumObj->Forum;
$numRows = 0;
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
$mail_obj->enableSOAP(false);
while($row = $ilDB->fetchAssoc($res))
{
// don not send a notification to the post author
if($row['pos_usr_id'] != $row['user_id'])
{
// GET AUTHOR OF NEW POST
if($row['pos_usr_id'])
{
$row['pos_usr_name'] = ilObjUser::_lookupLogin($row['pos_usr_id']);
}
else if(strlen($row['pos_usr_alias']))
{
$row['pos_usr_name'] = $row['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
}
if($row['pos_usr_name'] == '')
{
$row['pos_usr_name'] = $lng->txt('forums_anonymous');
}
// get all references of obj_id
if(!isset($cache[$row['obj_id']]))
$cache[$row['obj_id']] = ilObject::_getAllReferences($row['obj_id']);
// do rbac check before sending notification
$send_mail = false;
foreach((array)$cache[$row['obj_id']] as $ref_id)
{
if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
{
$row['ref_id'] = $ref_id;
$send_mail = true;
break;
}
}
if($send_mail)
{
// SEND NOTIFICATIONS BY E-MAIL
$frm->setLanguage(ilForum::_getLanguageInstanceByUsrId($row['user_id']));
$message = $mail_obj->sendMail(ilObjUser::_lookupLogin($row['user_id']),'','',
$frm->formatNotificationSubject($row),
strip_tags($frm->formatNotification($row, 1)),
array(),array('normal'));
$numRows++;
}
}
}
return $numRows;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronForumNotification::sendNotifications ( )

Definition at line 83 of file class.ilCronForumNotification.php.

References $ilDB, $ilLog, $ilSetting, $lng, $res, and sendMails().

{
$lng->loadLanguageModule('forum');
if(!($lastDate = $ilSetting->get('cron_forum_notification_last_date')))
{
$lastDate = null;
}
$numRows = 0;
$datecondition_frm = '';
$types = array();
$values = array();
if($lastDate != null &&
checkDate(date('m', strtotime($lastDate)), date('d', strtotime($lastDate)), date('Y', strtotime($lastDate))))
{
$datecondition_frm = ' frm_posts.pos_date >= %s AND ';
$types[] = 'timestamp';
$values[] = $lastDate;
}
/*** FORUMS ***/
$res = $ilDB->queryf('
SELECT frm_threads.thr_subject thr_subject,
frm_data.top_name top_name,
frm_data.top_frm_fk obj_id,
frm_notification.user_id user_id,
frm_posts.*
FROM frm_notification, frm_posts, frm_threads, frm_data
WHERE '.$datecondition_frm.' frm_posts.pos_thr_fk = frm_threads.thr_pk
AND frm_threads.thr_top_fk = frm_data.top_pk
AND frm_data.top_frm_fk = frm_notification.frm_id
ORDER BY frm_posts.pos_date ASC',
$types,
$values
);
$numRows += $this->sendMails($res);
/*** THREADS ***/
$res = $ilDB->queryf('
SELECT frm_threads.thr_subject thr_subject,
frm_data.top_name top_name,
frm_data.top_frm_fk obj_id,
frm_notification.user_id user_id,
frm_posts.*
FROM frm_notification, frm_posts, frm_threads, frm_data
WHERE '.$datecondition_frm.' frm_posts.pos_thr_fk = frm_threads.thr_pk
AND frm_threads.thr_pk = frm_notification.thread_id
AND frm_data.top_pk = frm_threads.thr_top_fk
ORDER BY frm_posts.pos_date ASC',
$types,
$values
);
$numRows += $this->sendMails($res);
$ilSetting->set('cron_forum_notification_last_date', date('Y-m-d H:i:s'));
$ilLog->write(__METHOD__.': Send '.$numRows.' messages.');
return true;
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: