X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=NotifyAction.php;h=e3b9af5cd3d43c80988a61dcc8ad9f8aa89aa4a8;hp=8f880aeafaa0e7fbc36a0724b0dc8f93f33f2654;hb=1524f8b36295809a3eedd6da3c6494f8aa0d86f5;hpb=11e2653d626225d89e337f3d0efa37139bed22b0 diff --git a/NotifyAction.php b/NotifyAction.php index 8f880aea..e3b9af5c 100644 --- a/NotifyAction.php +++ b/NotifyAction.php @@ -7,6 +7,7 @@ * * */ +require_once 'Pman.php'; class Pman_Core_NotifyAction extends Pman { @@ -30,29 +31,54 @@ class Pman_Core_NotifyAction extends Pman } - function get() + function get($v, $opts=array()) { $this->jerr("invalid request"); } - function post() + function post($v) { // needs: (Array of...) - // ontable, action(eg. APPROVAL) - // onid (comma delimited.) + // on_table, + // action(eg. APPROVAL) + // on_id (comma delimited.) + //DB_DataObject::debugLevel(1); $n = DB_DataObject::factory('core_notify'); + $n->person_id = $this->authUser->id; // in theory in workflow, this could trigger another action... // if watch is on it.. - foreach(array('on_table','on_id','action') as $k) { + foreach(array('ontable','onid','action') as $k) { if (empty($_POST[$k])) { $this->jerr("missing argument $k"); } - $n->$k = $v; + if ($k == 'onid') { + continue; + } + $n->$k = $_POST[$k]; } + $n->whereAdd('sent < act_when'); // not issued yet.. + $n->whereAdd("join_watch_id_id.medium = '". $n->escape($n->action) ."'"); + $n->whereAddIn('core_notify.onid', explode(',', $_POST['onid']), 'int' ); + $n->autoJoin(); + $ar = $n->fetchAll(); + $done = array(); - + foreach($ar as $n) { + $nc = clone($n); + $nc->sent = date('Y-m-d H:i:s'); + $nc->update($n); + + // add an event????? - yeap... only once per object + $key = implode(':', array($nc->ontable,$nc->onid)); + if (!isset($done[$key])) { + + $e = $this->addEvent($_POST['action'],$n->object()); + } + $done[$key] = true; + } + $this->jok("updated"); }