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: 40: 41: 42: 43: 44: 45: 46: 47: 48:
49: public function select($where = '', $group_by = '', $order_by = '', $limit = '') {
50: if ($where == '') {
51: $where = "comtype='todo'";
52: } else {
53: $where .= " AND comtype='todo'";
54: }
55:
56: return parent::select($where, $group_by, $order_by, $limit);
57: }
58:
59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
72: public function createItem($itemtype, $itemid, $reminderdate, $subject, $content, $notimail, $notibackend, $recipient) {
73: $item = parent::create();
74:
75: $item->set('comtype', 'todo');
76: $item->set('subject', $subject);
77: $item->set('message', $content);
78: $item->set('recipient', $recipient);
79: $item->store();
80:
81: if ($notimail === true) {
82: $notimail = 1;
83: }
84:
85:
86: if (!is_numeric($reminderdate)) {
87:
88: $reminderdate = strtotime($reminderdate);
89: }
90:
91: $item->setProperty('todo', 'reminderdate', $reminderdate);
92: $item->setProperty('todo', 'itemtype', $itemtype);
93: $item->setProperty('todo', 'itemid', $itemid);
94: $item->setProperty('todo', 'emailnoti', $notimail);
95: $item->setProperty('todo', 'backendnoti', $notibackend);
96: $item->setProperty('todo', 'status', 'new');
97: $item->setProperty('todo', 'priority', 'medium');
98: $item->setProperty('todo', 'progress', '0');
99:
100: return $item;
101: }
102:
103: 104: 105: 106:
107: public function getStatusTypes() {
108: return array(
109: 'new' => i18n('New'),
110: 'progress' => i18n('In progress'),
111: 'done' => i18n('Done'),
112: 'waiting' => i18n('Waiting for action'),
113: 'deferred' => i18n('Deferred')
114: );
115: }
116:
117: 118: 119: 120:
121: public function getPriorityTypes() {
122: return array(
123: 'low' => i18n('Low'),
124: 'medium' => i18n('Medium'),
125: 'high' => i18n('High'),
126: 'immediately' => i18n('Immediately')
127: );
128: }
129: }
130:
131: 132: 133: 134: 135: 136: 137:
138: class TODOItem extends cApiCommunication {
139:
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: 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: public function __construct($itemtype, $itemid, $subject, $message) {
185: global $sess;
186: parent::__construct();
187:
188: $subject = urlencode($subject);
189: $message = urlencode($message);
190:
191: $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');");
192: $this->setEvent('mouseover', "this.style.cursor='pointer'");
193:
194: $img = new cHTMLImage('images/but_setreminder.gif');
195: $img->setClass("vAlignMiddle tableElement");
196:
197: $img->setAlt(i18n('Set reminder / add to todo list'));
198: $this->setLink('#');
199: $this->setContent($img->render());
200: $this->setAlt(i18n('Set reminder / add to todo list'));
201: }
202: }
203: