Public Member Functions

ilCronForumNotification Class Reference

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, $ilias, $lng, $ref_id, $res, ilObject::_getAllReferences(), ilObjUser::_lookupLanguage(), and ilObjUser::_lookupLogin().

Referenced by sendNotifications().

        {
                global $ilias, $rbacsystem;

                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))
                {
                        if ($row["pos_usr_id"] != $row["user_id"])
                        {
                                // GET AUTHOR OF NEW POST
                                $row["pos_usr_name"] = ilObjUser::_lookupLogin($row["pos_usr_id"]);

                                if (is_array($obj_data = ilObject::_getAllReferences($row["obj_id"])))
                                {
                                        foreach($obj_data as $ref_id)
                                        {
                                                if ($rbacsystem->checkAccessOfUser($row["user_id"], "read", $ref_id))
                                                {
                                                        $row["ref_id"] = $ref_id;
                                                        break;
                                                }
                                        }
                                }

                                if ($row["ref_id"] != "")
                                {
                                        // SEND NOTIFICATIONS BY E-MAIL
                                        $user_language = ilObjUser::_lookupLanguage($row["user_id"]);
                                        if (!is_object($lng[$user_language]))
                                        {
                                                $lng[$user_language] =& new ilLanguage($user_language);
                                                $lng[$user_language]->loadLanguageModule("forum");
                                        }
                                        $frm->setLanguage($lng[$user_language]);                                        
                                        $message = $mail_obj->sendMail(ilObjUser::_lookupLogin($row["user_id"]),"","",
                                                                                                           $frm->formatNotificationSubject(),
                                                                                                           $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 $ilias, $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: