2 require_once 'Pman.php';
5 * notification script runner
7 * This does not actualy send stuf out, it only starts the NotifySend/{id}
8 * which does the actuall notifcations.
10 * It manages a pool of notifiers.
16 class Pman_Core_NotifySend extends Pman
19 var $table = 'core_notify';
22 $ff = HTML_FlexyFramework::get();
26 //HTML_FlexyFramework::ensureSingle(__FILE__, $this);
35 DB_DataObject::debugLevel(1);
36 //date_default_timezone_set('UTC');
39 $w = DB_DataObject::factory($this->table);
41 if (!$w->get($id) || strtotime($w->act_when) < strtotime($w->sent)) {
42 die("invalid id or time");
48 // let's work out the last notification sent to this user..
49 $l = DB_DataObject::factory($this->table);
51 'ontable' => $w->ontable,
53 'person_id' => $w->person_id,
55 $l->whereAdd('id != '. $w->id);
56 $l->orderBy('sent DESC');
58 $ar = $l->fetchAll('sent');
59 $last = empty($ar) ? date('Y-m-d H:i:s', 0) : $ar[0];
62 $email = $o->toEmail($p,$last);
63 // should we fetch the watch that caused it.. - which should contain the method to call..
64 $dom = array_pop(explode('@', $p->email));
66 bool getmxrr ( $dom , array &$mxhosts [, array &$weight ] )
69 Mail::factory('smtp', array(
70 'host' => 'smtp.gmail.com',
81 $mx_records = array();
84 if (getmxrr($fqdn, $mx_records, $mx_weight)) {
85 // copy mx records and weight into array $mxs
86 // ignore multiple mx's at the same weight
87 for ($i = 0; $i < count($mx_records); $i++) {
88 $mxs[$mx_weight[$i]] = $mx_records[$i];
90 // sort array mxs to get servers with highest priority
91 ksort ($mxs, SORT_NUMERIC);