Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztodo.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eztodo.php 7992 2001-10-22 09:22:31Z $
5 //
6 // Definition of eZTodo class
7 //
8 // Created on: <04-Sep-2000 16:53:15 ce>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
35 // include_once( "eztodo/classes/eztodolog.php" );
36 // include_once( "classes/ezdatetime.php" );
37
38 class eZTodo
39 {
41
44 function __construct( $id = -1 )
45 {
46 if ( $id != -1 )
47 {
48 $this->ID = $id;
49 $this->get( $this->ID );
50 }
51 }
52
57 function store()
58 {
59 $db =& eZDB::globalDatabase();
60 $db->begin();
61 $name = $db->escapeString( $this->Name );
62 $description = $db->escapeString( $this->Description );
63 if ( is_a( $this->Due, "eZDateTime" ) )
64 $due = $this->Due->timeStamp();
65 else
66 $due = "";
67
68 if ( !isset( $this->ID ) )
69 {
70 $db->lock( "eZTodo_Todo" );
71 $this->ID = $db->nextID( "eZTodo_Todo", "ID" );
72 $timestamp = (new eZDateTime())->timeStamp( true );
73 $res[] = $db->query( "INSERT INTO eZTodo_Todo
74 (ID,
75 Name,
76 Description,
77 Category,
78 Priority,
79 Due,
80 UserID,
81 OwnerID,
82 Status,
83 Date,
84 IsPublic)
85 VALUES
86 ('$this->ID',
87 '$name',
88 '$description',
89 '$this->Category',
90 '$this->Priority',
91 '$due',
92 '$this->UserID',
93 '$this->OwnerID',
94 '$this->Status',
95 '$timestamp',
96 '$this->IsPublic')" );
97 $db->unlock();
98 }
99 else
100 {
101 $res[] = $db->query( "UPDATE eZTodo_Todo SET
102 Name='$name',
103 Description='$description',
104 Category='$this->Category',
105 Priority='$this->Priority',
106 Due='$due',
107 UserID='$this->UserID',
108 OwnerID='$this->OwnerID',
109 Status='$this->Status',
110 IsPublic='$this->IsPublic',
111 Date=Date
112 WHERE ID='$this->ID' ");
113 }
114 eZDB::finish( $res, $db );
115 return true;
116 }
117
121 function delete()
122 {
123 $db =& eZDB::globalDatabase();
124 $db->begin();
125 $res[] = $db->query( "DELETE FROM eZTodo_Todo WHERE ID='$this->ID'" );
126 eZDB::finish( $res, $db );
127
128 return true;
129 }
130
134 function get( $id )
135 {
136 $db =& eZDB::globalDatabase();
137 $ret = false;
138
139 if ( $id != "" )
140 {
141 $db->array_query( $todo_array, "SELECT * FROM eZTodo_Todo WHERE ID='$id'" );
142 if ( count( $todo_array ) > 1 )
143 {
144 die( "Error: Todo's with the same ID was found in the database. This shouldent happen." );
145 }
146 else if ( count( $todo_array ) == 1 )
147 {
148 $this->ID = $todo_array[0][$db->fieldName( "ID" )];
149 $this->Name = $todo_array[0][$db->fieldName( "Name" )];
150 $this->Description = $todo_array[0][$db->fieldName( "Description" )];
151 $this->Category = $todo_array[0][$db->fieldName( "Category" )];
152 $this->Priority = $todo_array[0][$db->fieldName( "Priority" )];
153 $this->Due = $todo_array[0][$db->fieldName( "Due" )];
154 $this->Date = $todo_array[0][$db->fieldName( "Date" )];
155 $this->UserID = $todo_array[0][$db->fieldName( "UserID" )];
156 $this->OwnerID = $todo_array[0][$db->fieldName( "OwnerID" )];
157 $this->Status = $todo_array[0][$db->fieldName( "Status" )];
158 $this->IsPublic = $todo_array[0][$db->fieldName( "IsPublic" )];
159
160 $ret = true;
161 }
162 }
163
164 return $ret;
165 }
166
171 static public function getAll()
172 {
173 $db =& eZDB::globalDatabase();
174
175 $return_array = array();
176 $todo_array = array();
177
178 $db->array_query( $todo_array, "SELECT ID FROM eZTodo_Todo ORDER BY Priority" );
179
180 for ( $i = 0; $i < count( $todo_array ); $i++ )
181 {
182 $return_array[$i] = new eZTodo( $todo_array[$i][$db->fieldName( "ID" )], 0 );
183 }
184
185 return $return_array;
186 }
187
193 static public function getByUserID( $id, $statusID = 0, $categoryID = 0 )
194 {
195 $db =& eZDB::globalDatabase();
196 $todo_array = 0;
197
198 $return_array = array();
199 $todo_array = array();
200 $showStatus = false;
201 $showCategory = false;
202
203 if ( $statusID != 0 )
204 {
205 $showStatus = "AND Status='$statusID'";
206 }
207
208 if ( $categoryID != 0 )
209 {
210 $showCategory = "AND Category='$categoryID'";
211 }
212
213 $sql = "SELECT ID FROM eZTodo_Todo WHERE UserID='$id' $showStatus $showCategory";
214
215 $db->array_query( $todo_array, $sql );
216
217 for ( $i = 0; $i < count( $todo_array ); $i++ )
218 {
219 $return_array[$i] = new eZTodo( $todo_array[$i][$db->fieldName( "ID" )], 0 );
220 }
221 return $return_array;
222 }
223
229 function getByOthers( $id )
230 {
231 $db =& eZDB::globalDatabase();
232 $todo_array = 0;
233
234 $return_array = array();
235 $todo_array = array();
236
237 $db->array_query( $todo_array, "SELECT ID FROM eZTodo_Todo WHERE ( UserID='$id' or OwnerID='$id' ) AND IsPublic='1' ORDER BY Priority");
238
239 for ( $i = 0; $i < count( $todo_array ); $i++ )
240 {
241 $return_array[$i] = new eZTodo( $todo_array[$i][$db->fieldName( "ID" )], 0 );
242 }
243 return $return_array;
244 }
245
250 function name()
251 {
252 return htmlspecialchars( $this->Name );
253 }
254
260 function getByLimit( $id, $limit = 5, $status = 0, $except = 0 )
261 {
262 $db =& eZDB::globalDatabase();
263 $todo_array = 0;
264
265 $return_array = array();
266 $todo_array = array();
267
268 if ( $except == "0" )
269 {
270 $db->array_query( $todo_array, "SELECT ID FROM eZTodo_Todo WHERE UserID='$id' AND Status='$status' ORDER BY Priority", array( "Limit" => $limit, "Offset" => 0 ) );
271 }
272 else
273 {
274 $db->array_query( $todo_array, "SELECT ID FROM eZTodo_Todo WHERE UserID='$id' AND Status!='$status' ORDER BY Priority", array( "Limit" => $limit, "Offset" => 0 ) );
275 }
276
277 for ( $i = 0; $i < count( $todo_array ); $i++ )
278 {
279 $return_array[$i] = new eZTodo( $todo_array[$i][$db->fieldName( "ID" )], 0 );
280 }
281
282 return $return_array;
283 }
284
289 static public function &getByDate( $user, $date )
290 {
291 if ( is_a( $date, "eZDate" ) )
292 {
293 $currentUser =& eZUser::currentUser();
294 if ( is_numeric( $user ) )
295 $userid = $user;
296 else
297 $userid = $user->id();
298 if ( $currentUser && $currentUser->id() != $userid )
299 $public_string = "AND IsPublic='1'";
300 else
301 $public_string = "";
302 $return_array = array();
303 $enddate = new eZDate();
304 $enddate->setTimeStamp( $date->timeStamp() + 86400 );
305 $db =& eZDB::globalDatabase();
306 $db->array_query( $todo_array, "SELECT ID FROM eZTodo_Todo WHERE Due>='" . $date->timeStamp() . "' AND Due<'" . $enddate->timeStamp() . "' AND UserID='" . $userid . "' $public_string ORDER BY Priority" );
307 for ( $i = 0; $i < count( $todo_array ); $i++ )
308 {
309 $return_array[$i] = new eZTodo( $todo_array[$i][$db->fieldName( "ID" )], 0 );
310 }
311 return $return_array;
312 }
313 }
314
319 function setName( $value )
320 {
321 $this->Name = $value;
322 }
323
328 function description()
329 {
330 return htmlspecialchars( $this->Description );
331 }
332
337 function setDescription( $value )
338 {
339 $this->Description = $value;
340 }
341
346 function categoryID()
347 {
348 return $this->Category;
349 }
350
355 function setCategoryID( $value )
356 {
357 $this->Category = $value;
358 }
359
364 function priorityID()
365 {
366 return $this->Priority;
367 }
368
373 function setPriorityID( $value )
374 {
375 $this->Priority = $value;
376 }
377
382 function statusID()
383 {
384 return $this->Status;
385 }
386
391 function setStatusID( $value )
392 {
393 $this->Status = $value;
394 }
395
400 function due()
401 {
402 if ( $this->Due == 0 )
403 return false;
404 $dateTime = new eZDateTime();
405 $dateTime->setTimeStamp( $this->Due );
406
407 return $dateTime;
408 }
409
414 function setDue( $value )
415 {
416 $this->Due = $value;
417 }
418
423 function date()
424 {
425 $dateTime = new eZDateTime( );
426 $dateTime->setTimeStamp( $this->Date );
427
428 return $dateTime;
429 }
430
435 function setDate( $value )
436 {
437 $this->Date = $value;
438 }
439
443 function userID()
444 {
445 return $this->UserID;
446 }
447
452 function setUserID( $value )
453 {
454 $this->UserID = $value;
455 }
456
460 function ownerID()
461 {
462 return $this->OwnerID;
463 }
464
469 function setOwnerID( $value )
470 {
471 $this->OwnerID = $value;
472 }
473
478 function status()
479 {
480 return $this->Status;
481 }
482
487 function setStatus( $value )
488 {
489 $this->Status = $value;
490 }
491
492
497 function isPublic()
498 {
499 if ( $this->IsPublic == 1 )
500 return true;
501 else
502 return false;
503 }
504
509 function setIsPublic( $value )
510 {
511 if ( $value == true )
512 $this->IsPublic = 1;
513 else
514 $this->IsPublic = 0;
515 }
516
522 function logs()
523 {
524 $db =& eZDB::globalDatabase();
525 $returnArray = array();
526
527 $db->array_query( $logsArray, "SELECT LogID from eZTodo_TodoLogLink where TodoID='$this->ID'" );
528
529 if ( count( $logsArray ) > 0 )
530 {
531 foreach ( $logsArray as $log )
532 {
533 $returnArray[] = new eZTodoLog( $log[$db->fieldName( "LogID" )] );
534 }
535 }
536 return $returnArray;
537 }
538
542 function addLog( &$value )
543 {
544 if ( is_a( $value, "eZTodoLog" ) )
545 {
546 $db =& eZDB::globalDatabase();
547 $db->begin();
548
549 $logID = $value->id();
550 $db->lock( "eZTodo_TodoLogLink" );
551 $nextID = $db->nextID( "eZTodo_TodoLogLink", "ID" );
552 $res[] = $db->query( "INSERT INTO eZTodo_TodoLogLink (ID, TodoID, LogID)
553 VALUES ('$nextID', '$this->ID', '$logID')" );
554 $db->unlock();
555 eZDB::finish( $res, $db );
556 }
557 }
558
563 function id()
564 {
565 return $this->ID;
566 }
567
568 var $OwnerID;
569 var $UserID;
570 var $IsPublic;
571 var $Description;
572 var $Due;
573 var $Date;
574 var $Name;
575 var $CategoryID;
576 var $PriorityID;
577 var $ID;
578 var $Status;
579 var $Category;
580 var $Priority;
581 }
582
583 ?>
$i
$i
Definition: admin/adlist.php:91
$dateTime
$dateTime
Definition: authorview.php:77
$status
$status
Definition: bugedit.php:473
$date
$date
Definition: bugpreview.php:66
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZDate
Definition: ezdate.php:46
eZTodoLog
Definition: eztodolog.php:42
eZTodo
Definition: eztodo.php:39
eZTodo\$Date
$Date
Definition: eztodo.php:573
eZTodo\name
name()
Definition: eztodo.php:250
eZTodo\logs
logs()
Definition: eztodo.php:522
eZTodo\$Priority
$Priority
Definition: eztodo.php:580
eZTodo\setCategoryID
setCategoryID( $value)
Definition: eztodo.php:355
eZTodo\setName
setName( $value)
Definition: eztodo.php:319
eZTodo\categoryID
categoryID()
Definition: eztodo.php:346
eZTodo\setStatus
setStatus( $value)
Definition: eztodo.php:487
eZTodo\$Description
$Description
Definition: eztodo.php:571
eZTodo\due
due()
Definition: eztodo.php:400
eZTodo\setDue
setDue( $value)
Definition: eztodo.php:414
eZTodo\$Status
$Status
Definition: eztodo.php:578
eZTodo\setStatusID
setStatusID( $value)
Definition: eztodo.php:391
eZTodo\status
status()
Definition: eztodo.php:478
eZTodo\getByDate
static & getByDate( $user, $date)
Definition: eztodo.php:289
eZTodo\$Category
$Category
Definition: eztodo.php:579
eZTodo\setPriorityID
setPriorityID( $value)
Definition: eztodo.php:373
eZTodo\userID
userID()
Definition: eztodo.php:443
eZTodo\ownerID
ownerID()
Definition: eztodo.php:460
eZTodo\$UserID
$UserID
Definition: eztodo.php:569
eZTodo\store
store()
Definition: eztodo.php:57
eZTodo\setDate
setDate( $value)
Definition: eztodo.php:435
eZTodo\setIsPublic
setIsPublic( $value)
Definition: eztodo.php:509
eZTodo\getByUserID
static getByUserID( $id, $statusID=0, $categoryID=0)
Definition: eztodo.php:193
eZTodo\$IsPublic
$IsPublic
Definition: eztodo.php:570
eZTodo\date
date()
Definition: eztodo.php:423
eZTodo\$CategoryID
$CategoryID
Definition: eztodo.php:575
eZTodo\$PriorityID
$PriorityID
Definition: eztodo.php:576
eZTodo\getByLimit
getByLimit( $id, $limit=5, $status=0, $except=0)
Definition: eztodo.php:260
eZTodo\$Name
$Name
Definition: eztodo.php:574
eZTodo\__construct
__construct( $id=-1)
eZTodo
Definition: eztodo.php:44
eZTodo\isPublic
isPublic()
Definition: eztodo.php:497
eZTodo\setDescription
setDescription( $value)
Definition: eztodo.php:337
eZTodo\priorityID
priorityID()
Definition: eztodo.php:364
eZTodo\statusID
statusID()
Definition: eztodo.php:382
eZTodo\$ID
$ID
Definition: eztodo.php:577
eZTodo\setOwnerID
setOwnerID( $value)
Definition: eztodo.php:469
eZTodo\id
id()
Definition: eztodo.php:563
eZTodo\$OwnerID
$OwnerID
Definition: eztodo.php:568
eZTodo\getAll
static getAll()
Definition: eztodo.php:171
eZTodo\$Due
$Due
Definition: eztodo.php:572
eZTodo\getByOthers
getByOthers( $id)
Definition: eztodo.php:229
eZTodo\description
description()
Definition: eztodo.php:328
eZTodo\addLog
addLog(&$value)
Definition: eztodo.php:542
eZTodo\setUserID
setUserID( $value)
Definition: eztodo.php:452
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$timestamp
$timestamp
Definition: ezstats/admin/cron.php:35
$res
$res
Definition: ezstats/admin/cron.php:45
$categoryID
else $categoryID
Definition: productview.php:66
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$currentUser
$currentUser
Definition: surveyedit.php:54
$showCategory
if(isset( $ShowButton)) $showCategory
Definition: todolist.php:122
$todo_array
$todo_array
Definition: todomenulist.php:54
$due
for( $i=0; $i< count( $status_array); $i++) $due
Definition: todoview.php:158
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.