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