/** * Injects a reminder event into the event queue. * Repeat interval is one day, repeat count * and days to trigger before event overdue is * set in the system config. */ public function addReminder() { $day = 86400; if (!w2PgetConfig('task_reminder_control')) { return; } if (!$this->task_end_date) { // No end date, can't do anything. return $this->clearReminder(true); // Also no point if it is changed to null } if ($this->task_percent_complete >= 100) { return $this->clearReminder(true); } $eq = new w2p_Core_EventQueue(); $pre_charge = w2PgetConfig('task_reminder_days_before', 1); $repeat = w2PgetConfig('task_reminder_repeat', 100); /* * If we don't need any arguments (and we don't) then we set this to null. * We can't just put null in the call to add as it is passed by reference. */ $args = null; // Find if we have a reminder on this task already $old_reminders = $eq->find('tasks', 'remind', $this->task_id); if (count($old_reminders)) { /* * It shouldn't be possible to have more than one reminder, * but if we do, we may as well clean them up now. */ foreach ($old_reminders as $old_id => $old_data) { $eq->remove($old_id); } } // Find the end date of this task, then subtract the required number of days. $date = new w2p_Utilities_Date($this->task_end_date); $today = new w2p_Utilities_Date(date('Y-m-d')); if (w2p_Utilities_Date::compare($date, $today) < 0) { $start_day = time(); } else { $start_day = $date->getDate(DATE_FORMAT_UNIXTIME); $start_day -= $day * $pre_charge; } $eq->add(array($this, 'remind'), $args, 'tasks', false, $this->task_id, 'remind', $start_day, $day, $repeat); }
/** * Queue mail to allow the queue manager to trigger * the email transfer. * * @access private */ public function QueueMail() { global $AppUI; $ec = new w2p_Core_EventQueue(); $vars = get_object_vars($this); return $ec->add(array('w2p_Utilities_Mail', 'SendQueuedMail'), $vars, 'w2p_Utilities_Mail', true); }