Exemple #1
0
function calendar_cron()
{
    require 'includes/classes/events.class.php';
    require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php';
    //Iterate through each member's preference
    $sql = "SELECT * FROM %scalendar_notification WHERE 1=1";
    $rows_notify = queryDB($sql, array(TABLE_PREFIX));
    $event_obj = new Events();
    foreach ($rows_notify as $row) {
        //Send email only when preference is 1
        if ($row['status'] == 1) {
            $all_events = array();
            $mail = new ATutorMailer();
            //Get personal events
            $personal_events = $event_obj->get_personal_events($row['memberid']);
            foreach ($personal_events as $event) {
                $all_events[] = $event;
            }
            //Get course events
            $sql_q = "SELECT course_id FROM %scourse_enrollment WHERE member_id = %d";
            $rows_enrolled = queryDB($sql_q, array(TABLE_PREFIX, TABLE_PREFIX));
            foreach ($rows_enrolled as $row_q) {
                $course_events = $event_obj->get_atutor_events($row['memberid'], $row_q['course_id']);
                foreach ($course_events as $event) {
                    $all_events[] = $event;
                }
            }
            //Iterate through each event and keep only those events which will start tomorrow
            $email_msg = _AT('calendar_noti_mail_1') . "\n";
            $index = 1;
            foreach ($all_events as $id => $event) {
                if (strtotime(substr($event['start'], 0, 10)) == strtotime('tomorrow')) {
                    $email_msg .= _AT('calendar_noti_mail_2') . " #" . $index . " \n";
                    $email_msg .= _AT('calendar_noti_mail_3') . ": " . substr($event['start'], 0, 10) . " \n";
                    $email_msg .= _AT('calendar_noti_mail_4') . ": " . substr($event['end'], 0, 10) . " \n";
                    $email_msg .= _AT('calendar_noti_mail_5') . ": " . $event['title'] . " \n\n";
                    $index++;
                }
            }
            //Send email using ATutor mailer
            $mail->From = $_config['contact_email'];
            $mail->FromName = $_config['site_name'];
            $mail->AddAddress($_config['contact_email']);
            $mail->Subject = $stripslashes(_AT('calendar_noti_title'));
            $mail->Body = $email_msg;
            $sql_email = "SELECT email FROM %smembers WHERE member_id = %d";
            $row_email = queryDB($sql_email, array(TABLE_PREFIX, $row['memberid']), TRUE);
            $mail->AddBCC($row_email['email']);
            $mail->Send();
            unset($mail);
            //For testing
            // echo "<br/>".$email_msg."<br/>".$row_email['mail'];
        }
    }
}
Exemple #2
0
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation.                */
/****************************************************************/
/**
 * This file is used to generate ics file.
 */
$_user_location = 'public';
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
require 'includes/classes/events.class.php';
$rows = array();
$eventObj = new Events();
//Create ics file in $ical string variable
$ical = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//ATutor//ATutor Calendar Module//EN";
//Get all the events of the user
foreach ($eventObj->get_personal_events($_SESSION['member_id'], TRUE) as $event) {
    array_push($rows, $event);
}
//Get ATutor system events
foreach ($eventObj->get_atutor_events($_SESSION['member_id'], $_SESSION['course_id'], TRUE) as $event) {
    array_push($rows, $event);
}
foreach ($rows as $row) {
    /*Timezone manipulation
      $sstamp   = strtotime($row['start']) - ($_GET['hrs'] * 60 * 60);
      $estamp   = strtotime($row['end'])   - ($_GET['hrs'] * 60 * 60);
      
      $startdt  = gmdate('Y-m-d H:i:s', $sstamp);
      $enddt    = gmdate('Y-m-d H:i:s', $estamp);
      
      $part_s   = explode(' ', $startdt);
Exemple #3
0
        $courses[] = $row['course_id'];
    }
}
$eventObj = new Events();
//Create an empty array and push all the events in it.
$rows = array();
if (isset($_GET['all'])) {
    $member = $_SESSION['member_id'];
} else {
    if (isset($_GET['mini'])) {
        $member = $_SESSION['member_id'];
    } else {
        $member = $_GET['mid'];
    }
}
foreach ($eventObj->get_personal_events($member) as $event) {
    if (!isset($_GET['all'])) {
        $event['editable'] = true;
    }
    array_push($rows, $event);
}
if (isset($_GET['all']) || isset($_GET['mini']) || isset($_GET['mid'])) {
    if (isset($_GET['all']) || isset($_GET['mini'])) {
        if (is_array($courses)) {
            $i = 0;
            foreach ($eventObj->get_atutor_events($_SESSION['member_id'], $courses[$i]) as $event) {
                array_push($rows, $event);
                $i++;
            }
        } else {
            foreach ($eventObj->get_atutor_events($_SESSION['member_id'], $_SESSION['course_id']) as $event) {