1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
8 * b) updateding watchers.
12 require_once 'MTrackWeb.php';
13 class MTrackWeb_Watch extends MTrackWeb
22 var $masterTemplate = 'watch.html';
28 require_once 'MTrack/ACL.php';
29 MTrackACL::requireAllRights('Reports', 'read');
38 $this->objname = empty($_REQUEST['objname']) ? '' : $_REQUEST['objname'];
39 $this->objid = empty($_REQUEST['objid']) ? '' : $_REQUEST['objid'];
44 MTrackACL::requireAllRights( $this->objname.':'.$this->objid, 'read');
47 $this->watchers = MTrackWatch::objectWatchersNameId( $this->objname, $this->objid);
50 $users = MTrack_DataObjects_Userinfo::selectList(array(''=>'-- Select to add --'));
51 $this->selfsubscribe = true;
52 foreach($this->watchers as $w) {
53 if (isset($users[$w->userid])) {
54 unset($users[$w->userid]);
56 if ($this->authUser->userid == $w->userid) {
57 $this->selfsubscribe = false;
60 require_once 'HTML/Template/Flexy/Element.php';
61 $this->elements['subscribe-add'] = new HTML_Template_Flexy_Element('select');
62 $this->elements['subscribe-add']->setOptions($users);
63 $this->addsubscribe = true;
64 if (count(array_keys($users)) == 1) {
65 $this->addsubscribe = false;
68 $this->elements['subscribe-add']->setValue('');
70 //$this->renderEvents();
77 $this->objname = empty($_REQUEST['objname']) ? '' : $_REQUEST['objname'];
78 $this->objid = empty($_REQUEST['objid']) ? '' : $_REQUEST['objid'];
80 if (empty($_REQUEST['userid'])) {
81 die("INVALID USER ID");
84 require_once 'DataObjects/Userinfo.php';
86 // throws exception if fails..
87 MTrack_DataObjects_Userinfo::get($_REQUEST['userid']);
88 // echo "Trying to add...";
89 MTrackWatch::watch_object( $this->objname, $this->objid, $_REQUEST['userid']);
92 // carry on and show get(..