3 * in theory a generic 'action' handler..
5 * Part of the eventual workflow code...
6 * -> at present, just flags something as done.....
10 require_once 'Pman.php';
12 class Pman_Core_NotifyAction extends Pman
17 $au = $this->getAuthUser();
19 $this->jerr("Not authenticated", array('authFailure' => true));
21 // workflow only applicable to owner company..
22 if ($au->company()->comptype != 'OWNER') {
23 $this->jerr("Core:NotifyAction: invalid user - not owner company.");
27 $this->authUser = $au;
28 // check that it's a supplier!!!!
36 $this->jerr("invalid request");
41 // needs: (Array of...)
43 // action(eg. APPROVAL)
44 // on_id (comma delimited.)
45 //DB_DataObject::debugLevel(1);
46 $n = DB_DataObject::factory('core_notify');
47 $n->person_id = $this->authUser->id;
48 // in theory in workflow, this could trigger another action...
49 // if watch is on it..
50 foreach(array('ontable','onid','action') as $k) {
51 if (empty($_POST[$k])) {
52 $this->jerr("missing argument $k");
60 $n->whereAdd('sent < act_when'); // not issued yet..
61 $n->whereAdd("join_watch_id_id.medium = '". $n->escape($n->action) ."'");
62 $n->whereAddIn('core_notify.onid', explode(',', $_POST['onid']), 'int' );
70 $nc->sent = date('Y-m-d H:i:s');
73 // add an event????? - yeap... only once per object
74 $key = implode(':', array($nc->ontable,$nc->onid));
75 if (!isset($done[$key])) {
77 $e = $this->addEvent($_POST['action'],$n->object());
81 $this->jok("updated");