Public Member Functions | Data Fields

ilCron Class Reference

Public Member Functions

 ilCron (&$db)
 initLog ($path, $file, $client)
 txt ($language, $key, $module= 'common')
 start ()
 __checkUserAccounts ()
 __checkLinks ()
 __readSetting ($a_keyword)

Data Fields

 $db
 $log

Detailed Description

Definition at line 35 of file class.ilCron.php.


Member Function Documentation

ilCron::__checkLinks (  ) 

Definition at line 141 of file class.ilCron.php.

Referenced by start().

        {
                include_once'../classes/class.ilLinkChecker.php';

                $link_checker =& new ilLinkChecker($this->db);
                $link_checker->setMailStatus(true);

                $invalid = $link_checker->checkLinks();
                foreach($link_checker->getLogMessages() as $message)
                {
                        $this->log->write($message);
                }

                return true;
        }

Here is the caller graph for this function:

ilCron::__checkUserAccounts (  ) 

Definition at line 86 of file class.ilCron.php.

References $data, $query, $res, $row, and txt().

Referenced by start().

        {
                $two_weeks_in_seconds = 60 * 60 * 24 * 14;

                $this->log->write('Cron: Start checkUserAccounts()');
                $query = "SELECT * FROM usr_data,usr_pref ".
                        "WHERE time_limit_message = '0' ".
                        "AND time_limit_unlimited = '0' ".
                        "AND time_limit_from < '".time()."' ".
                        "AND time_limit_until > '".$two_weeks_in_seconds."' ".
                        "AND usr_data.usr_id = usr_pref.usr_id ".
                        "AND keyword = 'language'";

                $res = $this->db->query($query);

                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        include_once '../classes/class.ilMimeMail.php';

                        $data['expires'] = $row->time_limit_until;
                        $data['email'] = $row->email;
                        $data['login'] = $row->login;
                        $data['usr_id'] = $row->usr_id;
                        $data['language'] = $row->value;
                        $data['owner'] = $row->time_limit_owner;

                        // Get owner
                        $query = "SELECT email FROM usr_data WHERE usr_id = '".$data['owner']."'";
                        
                        $res2 = $this->db->query($query);
                        while($row = $res2->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $from = $row->email;
                        }

                        // Send mail
                        $mail =& new ilMimeMail();
                        
                        $mail->From($from);
                        $mail->To($data['email']);
                        $mail->Subject($this->txt($data['language'],'account_expires_subject'));
                        $mail->Body($this->txt($data['language'],'account_expires_body')." ".strftime('%Y-%m-%d %R',$data['expires']));
                        $mail->send();

                        // set status 'mail sent'
                        $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '".$data['usr_id']."'";
                        $this->db->query($query);
                        
                        // Send log message
                        $this->log->write('Cron: (checkUserAccounts()) sent message to '.$data['login'].'.');
                }
                
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCron::__readSetting ( a_keyword  ) 

Definition at line 157 of file class.ilCron.php.

References $query, $res, and $row.

Referenced by start().

        {
                $query = "SELECT * FROM settings ".
                        "WHERE keyword = '".$a_keyword."'";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return $row->value ? $row->value : 0;
                }
                return 0;
        }

Here is the caller graph for this function:

ilCron::ilCron ( &$  db  ) 

Definition at line 40 of file class.ilCron.php.

References $db.

        {
                define('DEBUG',1);
                define('SOCKET_TIMEOUT',5);

                $this->db = $db;
        }

ilCron::initLog ( path,
file,
client 
)

Definition at line 48 of file class.ilCron.php.

References $client, and $file.

        {
                include_once '../classes/class.ilLog.php';

                $this->log =& new ilLog($path,$file,$client);

                return true;
        }

ilCron::start (  ) 

Definition at line 73 of file class.ilCron.php.

References __checkLinks(), __checkUserAccounts(), and __readSetting().

        {
                // add here other checks
                if($this->__readSetting('cron_user_check'))
                {
                        $this->__checkUserAccounts();
                }
                if($this->__readSetting('cron_link_check'))
                {
                        $this->__checkLinks();
                }
        }

Here is the call graph for this function:

ilCron::txt ( language,
key,
module = 'common' 
)

Definition at line 57 of file class.ilCron.php.

References $key, $query, $res, and $row.

Referenced by __checkUserAccounts().

        {
                $query = "SELECT value FROM lng_data ".
                        "WHERE module = '".$module."' ".
                        "AND identifier = '".$key."' ".
                        "AND lang_key = '".$language."'";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $value = $row->value;
                }
                return $value ? $value : $key;
        }

Here is the caller graph for this function:


Field Documentation

ilCron::$db

Definition at line 37 of file class.ilCron.php.

Referenced by ilCron().

ilCron::$log

Definition at line 38 of file class.ilCron.php.


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