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

Public Member Functions

 ilCronForumNotification ()
 sendMails ($res)
 sendNotifications ()

Detailed Description

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

Member Function Documentation

ilCronForumNotification::ilCronForumNotification ( )

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

References $ilLog.

{
global $ilLog,$ilDB;
$this->log =& $ilLog;
$this->db =& $ilDB;
}
ilCronForumNotification::sendMails (   $res)

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

References $_GET, $ref_id, $res, ilObject\_getAllReferences(), ilForum\_getLanguageInstanceByUsrId(), ilObjUser\_lookupLogin(), and DB_FETCHMODE_ASSOC.

Referenced by sendNotifications().

{
global $ilias, $rbacsystem, $ilAccess;
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($_GET["ref_id"]);
$frm = $forumObj->Forum;
$numRows = 0;
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
// don not send a notification to the post author
if($row['pos_usr_id'] != $row['user_id'])
{
// GET AUTHOR OF NEW POST
$row['pos_usr_name'] = ilObjUser::_lookupLogin($row['pos_usr_id']);
// 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),
$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 99 of file class.ilCronForumNotification.php.

References $res, and sendMails().

{
global $ilias;
if(!($lastDate = $ilias->getSetting("cron_forum_notification_last_date")))
{
$lastDate = "0000-00-00 00:00:00";
}
$numRows = 0;
/*** FORUMS ***/
$q = "SELECT frm_threads.thr_subject AS thr_subject, frm_data.top_name AS top_name, frm_data.top_frm_fk AS obj_id, frm_notification.user_id AS user_id, frm_posts.* FROM frm_notification, frm_posts, frm_threads, frm_data WHERE ";
$q .= "frm_posts.pos_date >= '" . $lastDate . "' AND ";
$q .= "frm_posts.pos_thr_fk = frm_threads.thr_pk AND ";
$q .= "frm_threads.thr_top_fk = frm_data.top_pk AND ";
$q .= "frm_data.top_frm_fk = frm_notification.frm_id ";
$q .= "ORDER BY frm_posts.pos_date ASC";
$res = $this->db->query($q);
$numRows += $this->sendMails($res);
/*** THREADS ***/
$q = "SELECT frm_threads.thr_subject AS thr_subject, frm_data.top_name AS top_name, frm_data.top_frm_fk AS obj_id, frm_notification.user_id AS user_id, frm_posts.* FROM frm_notification, frm_posts, frm_threads, frm_data WHERE ";
$q .= "frm_posts.pos_date >= '" . $lastDate . "' AND ";
$q .= "frm_posts.pos_thr_fk = frm_threads.thr_pk AND ";
$q .= "frm_threads.thr_pk = frm_notification.thread_id AND ";
$q .= "frm_data.top_pk = frm_threads.thr_top_fk ";
$q .= "ORDER BY frm_posts.pos_date ASC";
$res = $this->db->query($q);
$numRows += $this->sendMails($res);
$ilias->setSetting("cron_forum_notification_last_date", date("Y-m-d H:i:s"));
$this->log->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: