Revision: 18613 http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18613 Author: johang Date: 2008-06-16 22:14:39 +0000 (Mon, 16 Jun 2008)
Log Message: ----------- * Updated to use datetime statically. * Minor clean-up. Modified Paths: -------------- trunk/todo/inc/class.botodo.inc.php Modified: trunk/todo/inc/class.botodo.inc.php =================================================================== --- trunk/todo/inc/class.botodo.inc.php 2008-06-15 23:13:11 UTC (rev 18612) +++ trunk/todo/inc/class.botodo.inc.php 2008-06-16 22:14:39 UTC (rev 18613) @@ -3,16 +3,18 @@ * Todo business * * @author Joseph Engo <[EMAIL PROTECTED]> - * @author Bettina Gille [EMAIL PROTECTED] + * @author Bettina Gille <[EMAIL PROTECTED]> * @copyright Copyright (C) 2000-2003,2005 Free Software Foundation, Inc. http://www.fsf.org/ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License * @package todo * @version $Id$ */ + phpgw::import_class('phpgwapi.datetime'); + /** * Todo business - * + * * @package todo */ class botodo @@ -23,7 +25,7 @@ var $order; var $sort; var $cat_id; - + /** * @var bool $debug enable debugging */ @@ -46,7 +48,6 @@ function botodo($session=False) { $this->sotodo = CreateObject('todo.sotodo'); - $this->datetime =& $GLOBALS['phpgw']->datetime; if ($session) { @@ -63,7 +64,11 @@ if(!empty($_start) || ($_start == '0') || ($_start == 0)) { - if($this->debug) { echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; } + if($this->debug) + { + echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; + } + $this->start = $_start; } @@ -88,6 +93,7 @@ { echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; } + $this->sort = $_sort; } @@ -95,8 +101,9 @@ { if($this->debug) { - echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; + echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; } + $this->order = $_order; } @@ -104,8 +111,9 @@ { if($this->debug) { - echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; + echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; } + $this->filter = $_filter; } } @@ -197,8 +205,7 @@ function employee_list($type) { - $employees = $GLOBALS['phpgw']->accounts->get_list($type); - return $employees; + return $GLOBALS['phpgw']->accounts->get_list($type); } function format_assigned($a = '') @@ -207,23 +214,26 @@ { $a = substr($a,1,strlen($a)-2); } - $a = explode(',',$a); - return $a; + + return explode(',', $a); } function list_assigned($assi = '') { $aout = ''; + if (is_array($assi)) { foreach ( $assi as $a ) { - $adata = $this->cached_accounts($a); + $adata = $this->cached_accounts($a); if ($adata[$a]['type'] == 'u') { - $aout .= $GLOBALS['phpgw']->common->display_fullname($adata[$a]['lid'], - $adata[$a]['firstname'],$adata[$a]['lastname']) . '<br>'; + $aout .= $GLOBALS['phpgw']->common->display_fullname( + $adata[$a]['lid'], + $adata[$a]['firstname'], + $adata[$a]['lastname']) . '<br>'; } elseif($adata[$a]['type'] == 'g') { @@ -231,6 +241,7 @@ } } } + return $aout; } @@ -251,19 +262,28 @@ $parent = $params['parent']; } - $todos = $this->sotodo->read_todos($start, $limit, $query, $filter, $order, $sort, $cat_id, $tree, $parent); + $todos = $this->sotodo->read_todos( + $start, $limit, $query, $filter, $order, $sort, $cat_id, $tree, $parent); + $this->total_records = $this->sotodo->total_records; $r = array(); + foreach ( $todos as $todo ) { - $sdate = $todo['sdate'] - $this->datetime->tz_offset; - $todo['sdate'] = $GLOBALS['phpgw']->common->show_date($sdate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); + $sdate = $todo['sdate'] - phpgwapi_datetime::user_timezone(); - if ( isset($todo['edate']) && $todo['edate'] != 0) + $todo['sdate'] = $GLOBALS['phpgw']->common->show_date( + $sdate, + $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); + + if (isset($todo['edate']) && $todo['edate'] != 0) { - $edate = $todo['edate'] - $this->datetime->tz_offset; - $v['edate'] = $GLOBALS['phpgw']->common->show_date($edate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); + $edate = $todo['edate'] - phpgwapi_datetime::user_timezone(); + + $todo['edate'] = $GLOBALS['phpgw']->common->show_date( + $edate, + $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); } if ($todo['assigned']) @@ -276,7 +296,6 @@ $todo['assigned_group'] = $this->format_assigned($todo['assigned_group']); } - $v['owner'] = $GLOBALS['phpgw']->accounts->name2id($todo['owner']); $r[] = array ( 'id' => (int) $todo['id'], @@ -311,6 +330,7 @@ function check_values($values) { $error = array(); + if (!$values['title']) { $error[] = lang('Please enter a title'); @@ -321,14 +341,14 @@ $error[] = lang('Description can not exceed 8000 characters in length'); } - if ($values['daysfromstart'] && ! ereg('^[0-9]+$',$values[daysfromstart])) + if ($values['daysfromstart'] && ! ereg('^[0-9]+$', $values['daysfromstart'])) { $error[] = lang('You can only enter numbers for days from now'); } if ($values['smonth'] || $values['sday'] || $values['syear']) { - if(! $this->datetime->date_valid($values['syear'],$values['smonth'],$values['sday'])) + if(! phpgwapi_datetime::date_valid($values['syear'], $values['smonth'], $values['sday'])) { $error[] = lang('You have entered an invalid start date'); } @@ -336,7 +356,7 @@ if ($values['emonth'] || $values['eday'] || $values['eyear']) { - if(! $this->datetime->date_valid($values['eyear'],$values['emonth'],$values['eday'])) + if(!phpgwapi_datetime::date_valid($values['eyear'], $values['emonth'], $values['eday'])) { $error[] = lang('You have entered an invalid end date'); } @@ -349,9 +369,12 @@ } */ - if (($values['smonth'] || $values['sday'] || $values['syear']) && ($values['emonth'] || $values['eday'] || $values['eyear'])) + if (($values['smonth'] || $values['sday'] || $values['syear']) && + ($values['emonth'] || $values['eday'] || $values['eyear'])) { - if($this->datetime->date_compare($values['eyear'],$values['emonth'],$values['eday'],$values['syear'],$values['smonth'],$values['sday']) == -1) + if(phpgwapi_datetime::date_compare( + $values['eyear'], $values['emonth'], $values['eday'], + $values['syear'], $values['smonth'], $values['sday']) == -1) { $error[] = lang('Ending date can not be before start date'); } @@ -382,7 +405,8 @@ { if ($values['smonth'] || $values['sday'] || $values['syear']) { - $values['sdate'] = mktime(0,0,0,$values['smonth'], $values['sday'], $values['syear']); + $values['sdate'] = mktime(0, 0, 0, $values['smonth'], + $values['sday'], $values['syear']); } } @@ -393,11 +417,14 @@ if ($values['emonth'] || $values['eday'] || $values['eyear']) { - $values['edate'] = mktime(2,0,0,$values['emonth'],$values['eday'],$values['eyear']); + $values['edate'] = mktime(2, 0, 0, $values['emonth'], + $values['eday'], $values['eyear']); } else if ($values['daysfromstart'] > 0) { - $values['edate'] = mktime(0,0,0,date('m',$values['sdate']), date('d',$values['sdate'])+$values['daysfromstart'], date('Y',$values['sdate'])); + $values['edate'] = mktime(0, 0, 0, date('m', $values['sdate']), + date('d', $values['sdate']) + $values['daysfromstart'], + date('Y',$values['sdate'])); } if ( isset($values['id']) && (int)$values['id'] > 0) @@ -409,38 +436,21 @@ { $todo_id = $this->sotodo->add_todo($values); } + return $todo_id; } function exists($todo_id) { - $exists = $this->sotodo->exists($todo_id); - - if ($exists) - { - return True; - } - else - { - return False; - } + return (bool)$this->sotodo->exists($todo_id); } function delete($todo_id, $subs = False) { - if (is_array($todo_id)) - { - $todo_id = $todo_id[0]; - } + $this->sotodo->delete_todo( + is_array($todo_id) ? $todo_id[0] : $todo_id, + (bool)$subs); - if ($subs) - { - $this->sotodo->delete_todo($todo_id,True); - } - else - { - $this->sotodo->delete_todo($todo_id); - } return True; } } _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs