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: class TODOCollection extends cApiCommunicationCollection {
25:
26: public function __construct() {
27: parent::__construct();
28: $this->_setItemClass('TODOItem');
29: }
30:
31: public function select($where = '', $group_by = '', $order_by = '', $limit = '') {
32: if ($where == '') {
33: $where = "comtype='todo'";
34: } else {
35: $where .= " AND comtype='todo'";
36: }
37:
38: return parent::select($where, $group_by, $order_by, $limit);
39: }
40:
41: 42: 43:
44: public function createItem($itemtype, $itemid, $reminderdate, $subject, $content, $notimail, $notibackend, $recipient) {
45: $item = parent::create();
46:
47: $item->set('subject', $subject);
48: $item->set('message', $content);
49: $item->set('comtype', 'todo');
50: $item->set('recipient', $recipient);
51: $item->store();
52:
53: if ($notimail === true) {
54: $notimail = 1;
55: }
56:
57:
58: if (!is_numeric($reminderdate)) {
59:
60: $reminderdate = strtotime($reminderdate);
61: }
62:
63: $item->setProperty('todo', 'reminderdate', $reminderdate);
64: $item->setProperty('todo', 'itemtype', $itemtype);
65: $item->setProperty('todo', 'itemid', $itemid);
66: $item->setProperty('todo', 'emailnoti', $notimail);
67: $item->setProperty('todo', 'backendnoti', $notibackend);
68: $item->setProperty('todo', 'status', 'new');
69: $item->setProperty('todo', 'priority', 'medium');
70: $item->setProperty('todo', 'progress', '0');
71:
72: return $item;
73: }
74:
75: public function getStatusTypes() {
76: $statusTypes = array(
77: 'new' => i18n('New'),
78: 'progress' => i18n('In progress'),
79: 'done' => i18n('Done'),
80: 'waiting' => i18n('Waiting for action'),
81: 'deferred' => i18n('Deferred')
82: );
83: return ($statusTypes);
84: }
85:
86: public function getPriorityTypes() {
87: $priorityTypes = array(
88: 'low' => i18n('Low'),
89: 'medium' => i18n('Medium'),
90: 'high' => i18n('High'),
91: 'immediately' => i18n('Immediately')
92: );
93: return ($priorityTypes);
94: }
95:
96: }
97:
98: 99: 100: 101: 102: 103:
104: class TODOItem extends cApiCommunication {
105: public function setProperty($type, $name, $value, $client = 0) {
106: if ($type == 'todo' && $name == 'emailnoti') {
107: if ($value) {
108: parent::setProperty('todo', 'emailnoti-sent', false);
109: $value = true;
110: } else {
111: $value = false;
112: }
113: }
114:
115: parent::setProperty($type, $name, $value);
116: }
117:
118: }
119:
120: 121: 122: 123: 124: 125:
126: class TODOLink extends cHTMLLink {
127:
128: public function __construct($itemtype, $itemid, $subject, $message) {
129: global $sess;
130: parent::__construct();
131:
132: $subject = urlencode($subject);
133: $message = urlencode($message);
134:
135: $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');");
136: $this->setEvent('mouseover', "this.style.cursor='pointer'");
137:
138: $img = new cHTMLImage('images/but_setreminder.gif');
139: $img->setClass("vAlignMiddle tableElement");
140:
141: $img->setAlt(i18n('Set reminder / add to todo list'));
142: $this->setLink('#');
143: $this->setContent($img->render());
144: $this->setAlt(i18n('Set reminder / add to todo list'));
145: }
146:
147: }
148:
149: ?>