= c.next and fr.status = 1". // Due now. " and c.status = 1 and c.report_id is not null and c.email is not null"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return; while ($val = $res->fetchRow()) { $this->reports[] = $val; } } // exec - processes reports one at a time by sending each out. function exec() { foreach ($this->reports as $report) { // Get favorite report details. $options = $this->getReportOptions($report['report_id']); if (!$options) continue; // Skip not found report. // Recycle global $user object, as user settings are specific for each report. unset($user); $user = new ttUser(null, $options['user_id']); if (!$user->id) continue; // Skip not found user. // Avoid complications with impersonated users, possibly from subgroups. // Note: this may happen when cron.php is called by a browser who already impersonates. // This is not supposed to happen in automatic cron job. if ($user->behalf_id) continue; // Skip processing on behalf situations entirely. // TODO: coding ongoing here. Not finished. Add other processing when ready. } } // getReportOptions - returns an array of fav report options from database data. private function getReportOptions($id) { $mdb2 = getConnection(); $sql = "select * from tt_fav_reports where id = $id and status = 1"; $res = $mdb2->query($sql); if (is_a(res, 'PEAR_Error')) return false; $val = $res->fetchRow(); if (!$val) return false; // Drop things we don't need. unset($val['id']); unset($val['report_spec']); unset($val['status']); return $val; } }