1: <?php
  2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14: 
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18:  19:  20:  21:  22:  23:  24: 
 25: class TODOCollection extends cApiCommunicationCollection {
 26: 
 27:      28: 
 29:     public function __construct() {
 30:         parent::__construct();
 31:         $this->_setItemClass('TODOItem');
 32:     }
 33: 
 34:      35:  36:  37:  38: 
 39:     public function select($where = '', $group_by = '', $order_by = '', $limit = '') {
 40:         if ($where == '') {
 41:             $where = "comtype='todo'";
 42:         } else {
 43:             $where .= " AND comtype='todo'";
 44:         }
 45: 
 46:         return parent::select($where, $group_by, $order_by, $limit);
 47:     }
 48: 
 49:      50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61: 
 62:     public function createItem($itemtype, $itemid, $reminderdate, $subject, $content, $notimail, $notibackend, $recipient) {
 63:         $item = parent::create();
 64: 
 65:         $item->set('comtype', 'todo');
 66:         $item->set('subject', $subject);
 67:         $item->set('message', $content);
 68:         $item->set('recipient', $recipient);
 69:         $item->store();
 70: 
 71:         if ($notimail === true) {
 72:             $notimail = 1;
 73:         }
 74: 
 75:         
 76:         if (!is_numeric($reminderdate)) {
 77:             
 78:             $reminderdate = strtotime($reminderdate);
 79:         }
 80: 
 81:         $item->setProperty('todo', 'reminderdate', $reminderdate);
 82:         $item->setProperty('todo', 'itemtype', $itemtype);
 83:         $item->setProperty('todo', 'itemid', $itemid);
 84:         $item->setProperty('todo', 'emailnoti', $notimail);
 85:         $item->setProperty('todo', 'backendnoti', $notibackend);
 86:         $item->setProperty('todo', 'status', 'new');
 87:         $item->setProperty('todo', 'priority', 'medium');
 88:         $item->setProperty('todo', 'progress', '0');
 89: 
 90:         return $item;
 91:     }
 92: 
 93:      94:  95:  96: 
 97:     public function getStatusTypes() {
 98:         return array(
 99:             'new' => i18n('New'),
100:             'progress' => i18n('In progress'),
101:             'done' => i18n('Done'),
102:             'waiting' => i18n('Waiting for action'),
103:             'deferred' => i18n('Deferred')
104:         );
105:     }
106: 
107:     108: 109: 110: 
111:     public function getPriorityTypes() {
112:         return array(
113:             'low' => i18n('Low'),
114:             'medium' => i18n('Medium'),
115:             'high' => i18n('High'),
116:             'immediately' => i18n('Immediately')
117:         );
118:     }
119: }
120: 
121: 122: 123: 124: 125: 126: 127: 
128: class TODOItem extends cApiCommunication {
129: 
130:     131: 132: 133: 134: 135: 
136:     public function setProperty($type, $name, $value, $client = 0) {
137:         if ($type == 'todo' && $name == 'emailnoti') {
138:             if ($value) {
139:                 parent::setProperty('todo', 'emailnoti-sent', false);
140:                 $value = true;
141:             } else {
142:                 $value = false;
143:             }
144:         }
145: 
146:         parent::setProperty($type, $name, $value);
147:     }
148: }
149: 
150: 151: 152: 153: 154: 155: 
156: class TODOLink extends cHTMLLink {
157: 
158:     159: 160: 161: 162: 163: 164: 
165:     public function __construct($itemtype, $itemid, $subject, $message) {
166:         global $sess;
167:         parent::__construct();
168: 
169:         $subject = urlencode($subject);
170:         $message = urlencode($message);
171: 
172:         $this->setEvent('click', 'javascript:window.open(' . "'" . $sess->url("main.php?subject=$subject&message=$message&area=todo&frame=1&itemtype=$itemtype&itemid=$itemid") . "', 'todo', 'scrollbars=yes,resizable=yes,height=350,width=625');");
173:         $this->setEvent('mouseover', "this.style.cursor='pointer'");
174: 
175:         $img = new cHTMLImage('images/but_setreminder.gif');
176:         $img->setClass("vAlignMiddle tableElement");
177: 
178:         $img->setAlt(i18n('Set reminder / add to todo list'));
179:         $this->setLink('#');
180:         $this->setContent($img->render());
181:         $this->setAlt(i18n('Set reminder / add to todo list'));
182:     }
183: }
184: 
185: ?>