[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.
From: |
uid65887 |
Subject: |
[Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12 |
Date: |
Wed, 27 Apr 2005 09:36:53 -0000 |
Update of todo/inc
Added Files:
Branch: MAIN
class.uitodo.inc.php lines: +310 -170
class.sotodo.inc.php lines: +201 -185
class.botodo.inc.php lines: +181 -128
Removed Files:
Branch: MAIN
class.ui.inc.php
class.bo.inc.php
class.so.inc.php
Log Message:
return id when adding a todo plus classname update
====================================================
Index: class.uitodo.inc.php
<?php
/*************************************************************************\
* phpGroupWare - Todo list
*
* http://www.phpgroupware.org
*
* This program is part of the GNU project, see http://www.gnu.org/
*
*
*
* Written by Joseph Engo <address@hidden> *
* Bettina Gille address@hidden *
* -----------------------------------------------
*
* Copyright 2000 - 2003 Free Software Foundation, Inc
*
*
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\*************************************************************************/
/* $Id: class.uitodo.inc.php,v 1.23 2003/12/24 00:39:04 uid65887 Exp $
*/
class uitodo
{
var $grants;
var $historylog;
var $t;
var $public_functions = array
(
'show_list' => True,
'view' => True,
'add' => True,
'edit' => True,
'delete' => True,
'matrix' => True
);
function uitodo()
{
$this->botodo =
CreateObject('todo.botodo',True);
$this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
$this->historylog =
CreateObject('phpgwapi.historylog','todo');
$this->historylog->types = array
(
'A' => lang('Entry added'),
'C' => lang('Category changed'),
'S' => lang('Start date changed'),
'E' => lang('End date changed'),
'U' => lang('Urgency changed'),
's' => lang('Status changed'),
'T' => lang('Title changed'),
'D' => lang('Description changed'),
'a' => lang('Access changed'),
'P' => lang('Parent changed')
);
$this->historylog->alternate_handlers = array
(
'S' => '$GLOBALS[\'phpgw\']->common->show_date',
'E' => '$GLOBALS[\'phpgw\']->common->show_date',
'C' =>
'$GLOBALS[\'phpgw\']->categories->id2name'
);
$this->cats = CreateObject('phpgwapi.categories');
$GLOBALS['phpgw']->categories = $this->cats;
$this->sbox = CreateObject('phpgwapi.sbox');
$this->matrix = CreateObject('phpgwapi.matrixview');
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->t =
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('todo'));
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('todo');
$this->start = $this->botodo->start;
$this->query = $this->botodo->query;
$this->filter = $this->botodo->filter;
$this->order = $this->botodo->order;
$this->sort = $this->botodo->sort;
$this->cat_id = $this->botodo->cat_id;
}
function save_sessiondata()
{
$data = array
(
'start' => $this->start,
'query' => $this->query,
'filter' => $this->filter,
'order' => $this->order,
'sort' => $this->sort,
'cat_id' => $this->cat_id
);
$this->botodo->save_sessiondata($data);
}
function set_app_langs()
{
$this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->t->set_var('row_on',$GLOBALS['phpgw_info']['theme']['row_on']);
$this->t->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
$this->t->set_var('lang_category',lang('Category'));
$this->t->set_var('lang_select',lang('Select'));
$this->t->set_var('lang_descr',lang('Description'));
$this->t->set_var('lang_title',lang('Title'));
$this->t->set_var('lang_none',lang('None'));
$this->t->set_var('lang_nobody',lang('Nobody'));
$this->t->set_var('lang_urgency',lang('Urgency'));
$this->t->set_var('lang_completed',lang('Completed'));
$this->t->set_var('lang_start_date',lang('Start Date'));
$this->t->set_var('lang_end_date',lang('End Date'));
$this->t->set_var('lang_date_due',lang('date due'));
$this->t->set_var('lang_access',lang('Private'));
$this->t->set_var('lang_parent',lang('Parent project'));
$this->t->set_var('lang_submit',lang('Submit'));
$this->t->set_var('lang_save',lang('Save'));
$this->t->set_var('lang_done',lang('Done'));
$this->t->set_var('lang_assigned',lang('Assigned to'));
$this->t->set_var('lang_owner',lang('Created by'));
}
function show_list()
{
$GLOBALS['phpgw']->common->phpgw_header();
echo $this->show_list_body(True);
}
function show_list_body($show_page_header=True)
{
$this->t->set_file(
Array(
'todo_list_t' => 'list.tpl'
)
);
$this->t->set_block('todo_list_t','page_header','page_header');
$this->t->set_block('todo_list_t','table_header','table_header');
$this->t->set_block('todo_list_t','todo_list','todo_list');
$this->t->set_block('todo_list_t','table_footer','table_footer');
$this->t->set_block('todo_list_t','page_footer','page_footer');
$body = '';
$this->set_app_langs();
$this->t->set_var(lang_action,lang('todo list'));
$this->t->set_var('lang_all',lang('All'));
if (!$this->start)
{
$this->start = 0;
}
$todo_list = $this->botodo->_list($this->start, True,
$this->query,$this->filter,$this->order,$this->sort,$this->cat_id,'all');
// --------------------- nextmatch variable template-declarations
------------------------
if($show_page_header)
{
$left =
$this->nextmatchs->left('/index.php',$this->start,$this->botodo->total_records,'&menuaction=todo.ui.show_list');
$right =
$this->nextmatchs->right('/index.php',$this->start,$this->botodo->total_records,'&menuaction=todo.ui.show_list');
$this->t->set_var('left',$left);
$this->t->set_var('right',$right);
$this->t->set_var('total_matchs',$this->nextmatchs->show_hits($this->botodo->total_records,$this->start));
// ------------------------- end nextmatch template
--------------------------------------
$this->t->set_var('cat_action',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.ui.show_list'));
$this->t->set_var('categories',$this->cats->formatted_list('select','all',$this->cat_id,'True'));
$this->t->set_var('filter_action',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.ui.show_list'));
$this->t->set_var('filter_list',$this->nextmatchs->filter(1,array('yours' =>
1,'filter' => $this->filter)));
$this->t->set_var('search_action',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.ui.show_list'));
$this->t->set_var('search_list',$this->nextmatchs->search(array('search_obj' =>
1,'query' => $this->query)));
$body .= $this->t->fp('out','page_header');
}
// ---------------- list header variable template-declarations
--------------------------
$this->t->set_var('sort_status',$this->nextmatchs->show_sort_order($this->sort,'todo_status',$this->order,'/todo/index.php',lang('Status')));
$this->t->set_var('sort_urgency',$this->nextmatchs->show_sort_order($this->sort,'todo_pri',$this->order,'/todo/index.php',lang('Urgency')));
$this->t->set_var('sort_title',$this->nextmatchs->show_sort_order($this->sort,'todo_title',$this->order,'/todo/index.php',lang('title')));
$this->t->set_var('sort_sdate',$this->nextmatchs->show_sort_order($this->sort,'todo_startdate',$this->order,'/todo/index.php',lang('start
date')));
$this->t->set_var('sort_edate',$this->nextmatchs->show_sort_order($this->sort,'todo_enddate',$this->order,'/todo/index.php',lang('end
date')));
$this->t->set_var('sort_owner',$this->nextmatchs->show_sort_order($this->sort,'todo_owner',$this->order,'/todo/index.php',lang('created
by')));
$this->t->set_var('sort_assigned',$this->nextmatchs->show_sort_order($this->sort,'todo_assigned',$this->order,'/todo/index.php',lang('assigned
to')));
$this->t->set_var('h_lang_sub',lang('Add Sub'));
$this->t->set_var('h_lang_view',lang('View'));
$this->t->set_var('h_lang_edit',lang('Edit'));
$body .= $this->t->fp('out','table_header');
// -------------- end header declaration ---------------------------------------
for ($i=0;$i<count($todo_list);$i++)
{
$this->nextmatchs->template_alternate_row_color($this->t);
$level = $todo_list[$i]['level'];
$title =
$GLOBALS['phpgw']->strip_html($todo_list[$i]['title']);
if (!$title)
{
$words = split('
',$GLOBALS['phpgw']->strip_html($todo_list[$i]['descr']));
$title = "$words[0] $words[1] $words[2]
$words[3] ...";
}
if ($level == 0)
{
$title = '<font color="#0000EE"><b>' .
$title . '</b></font>';
}
else
{
$space = ' ';
$spaceset = str_repeat($space,$level);
$title = $spaceset . $title;
}
switch ($todo_list[$i]['pri'])
{
case 1: $pri = lang('Low'); break;
case 2: $pri = '<b>' . lang('normal') .
'</b>'; break;
case 3: $pri = '<font
color="#CC0000"><b>' . lang('high') . '</b></font>'; break;
}
if ($todo_list[$i]['edate_epoch'] == 0)
{
$datedueout = ' ';
}
else
{
$datedue =
$todo_list[$i]['edate_epoch'];
$datedue = $datedue -
$this->botodo->datetime->tz_offset;
$month =
$GLOBALS['phpgw']->common->show_date(time(),'n');
$day =
$GLOBALS['phpgw']->common->show_date(time(),'d');
$year =
$GLOBALS['phpgw']->common->show_date(time(),'Y');
$currentdate =
mktime(2,0,0,$month,$day,$year);
if (($currentdate >= $datedue) &&
($todo_list[$i]['status'] < 100))
{
$datedueout = '<font
color="#CC0000"><b>';
}
else
{
$datedueout = '';
}
$datedueout .= $todo_list[$i]['edate'];
if ($currentdate >= $datedue)
{
$datedueout .= '</b></font>';
}
}
$assigned =
$this->botodo->list_assigned($todo_list[$i]['assigned']);
$assigned .=
$this->botodo->list_assigned($todo_list[$i]['assigned_group']);
// --------------- template declaration for list records
-------------------------------------
$this->t->set_var(array
(
'status' =>
$todo_list[$i]['status'],
'pri' => $pri,
'title' => $title,
'datecreated' =>
$todo_list[$i]['sdate'],
'datedue' => $datedueout,
'owner' =>
$todo_list[$i]['owner'],
'assigned' => $assigned
));
$this->t->set_var('view','<a href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.view&todo_id=' .
$todo_list[$i]['id'])
. '">' . lang('View') . '</a>');
if
($this->botodo->check_perms($this->grants[$todo_list[$i]['owner_id']],PHPGW_ACL_EDIT))
{
$this->t->set_var('edit','<a href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.edit&todo_id=' .
$todo_list[$i]['id'])
. '">' . lang('Edit') . '</a>');
}
else
{
$this->t->set_var('edit',' ');
}
if
($this->botodo->check_perms($this->grants[$todo_list[$i]['owner_id']],PHPGW_ACL_DELETE))
{
$this->t->set_var('delete','<a href="'
. $GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.delete&todo_id='
. $todo_list[$i]['id'])
. '">' . lang('Delete') . '</a>');
}
else
{
$this->t->set_var('delete',' ');
}
if
($this->botodo->check_perms($this->grants[$todo_list[$i]['owner_id']],PHPGW_ACL_ADD))
{
$this->t->set_var('subadd', '<a href="'
. $GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.add&parent=' .
$todo_list[$i]['id']
. '&cat_id=' . $this->cat_id) .
'">' . lang('Add Sub') . '</a>');
}
else
{
$this->t->set_var('subadd',' ');
}
$body .= $this->t->fp('out','todo_list');
}
$body .= $this->t->fp('out','table_footer');
// ------------------------- end record declaration ------------------------
// --------------- template declaration for Add Form --------------------------
if($show_page_header)
{
if ($this->cat_id && $this->cat_id != 0)
{
$cat =
$this->cats->return_single($this->cat_id);
}
if ($cat[0]['app_name'] == 'phpgw' ||
$cat[0]['owner'] == '-1' || !$this->cat_id)
{
$this->t->set_var('add','<form
method="POST" action="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.add&cat_id=' .
$this->cat_id)
. '"><input type="submit"
name="Add" value="' . lang('Add') .'"></form>');
}
else
{
if
($this->botodo->check_perms($this->grants[$cat[0]['owner']],PHPGW_ACL_ADD) ||
$cat[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
{
$this->t->set_var('add','<form
method="POST" action="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.add&cat_id=' .
$this->cat_id)
. '"><input
type="submit" name="Add" value="' . lang('Add') .'"></form>');
}
else
{
$this->t->set_var('add','');
}
}
// ----------------------- end Add form declaration ----------------------------
// ------------ get actual date and year for matrixview arguments --------------
$year = date('Y');
$month = date('m');
$this->t->set_var('matrixview',$GLOBALS['phpgw']->common->check_owner($GLOBALS['phpgw_info']['user']['account_id'],'/index.php',
lang('View matrix of actual
month'),'menuaction=todo.uitodo.matrix&month=' . $month . '&year=' . $year));
$body .= $this->t->fp('out','page_footer');
}
$this->save_sessiondata();
return $body;
}
function formatted_user($selected = '',$type)
{
if (!$selected)
{
$selected = $this->account;
}
if (! is_array($selected))
{
$selected = explode(',',$selected);
}
$employees = $this->botodo->employee_list($type);
while (list($null,$account) = each($employees))
{
$user_list .= '<option value="' .
$account['account_id'] . '"';
if (in_array($account['account_id'],$selected))
{
$user_list .= ' selected';
}
if ($account['account_type'] == 'u')
{
$user_list .= '>' .
$account['account_firstname'] . ' ' . $account['account_lastname']
. ' [' . $account['account_lid'] . ']';
}
else
{
$user_list .= '>' .
$account['account_firstname'] . ' ' . lang('Group');
}
$user_list .= '</option>' . "\n";
}
return $user_list;
}
function formatted_todo($selected = '')
{
$todos = $this->botodo->_list($start, False, $query,
$filter, $sort, $order, $cat_id, $tree);
for ($i=0;$i<count($todos);$i++)
{
$todo_select .= '<option value="' .
$todos[$i]['id'] . '"';
if ($todos[$i]['id'] == $selected)
{
$todo_select .= ' selected';
}
if (! $todos[$i]['title'])
{
$words = split('
',$GLOBALS['phpgw']->strip_html($todos[$i]['descr']));
$title = "$words[0] $words[1] $words[2]
$words[3] ...";
$todo_select .= '>' . $title;
}
else
{
$todo_select .= '>' .
$GLOBALS['phpgw']->strip_html($todos[$i]['title']);
}
$todo_select .= '</option>';
}
return $todo_select;
}
function add()
{
global $cat_id, $new_cat, $values, $submit,
$new_parent, $parent, $assigned, $assigned_group;
if ($new_parent)
{
$parent = $new_parent;
}
if ($new_cat)
{
$cat_id = $new_cat;
}
if ($submit)
{
$values['cat'] = $cat_id;
$values['parent'] = $parent;
if (is_array($assigned))
{
$values['assigned'] =
implode(',',$assigned);
if (count($assigned) > 1)
{
$values['assigned'] = ',' .
$values['assigned'] . ',';
}
}
if (is_array($assigned_group))
{
$values['assigned_group'] =
implode(',',$assigned_group);
if (count($assigned_group) > 1)
{
$values['assigned_group'] = ','
. $values['assigned_group'] . ',';
}
}
$error = $this->botodo->check_values($values);
if (is_array($error))
{
$this->t->set_var('error',$GLOBALS['phpgw']->common->error_list($error));
}
else
{
$this->botodo->save($values);
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.show_list&cat_id='
. $cat_id));
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
exit;
}
}
$GLOBALS['phpgw']->common->phpgw_header();
$this->t->set_file('todo_add','form.tpl');
$this->t->set_block('todo_add','add','addhandle');
$this->t->set_block('todo_add','edit','edithandle');
$this->set_app_langs();
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.add'));
if ($parent)
{
$this->t->set_var('lang_todo_action',lang('Add
sub project'));
}
else
{
$this->t->set_var('lang_todo_action',lang('Add
main project'));
}
$this->t->set_var('cat_list',$this->cats->formatted_list('select','all',$cat_id,'True'));
$this->t->set_var('todo_list',$this->formatted_todo($parent));
$this->t->set_var('descr',$values['descr']);
$this->t->set_var('pri_list',$this->sbox->getPriority('values[pri]'));
$this->t->set_var('stat_list',$this->sbox->getPercentage('values[status]',0));
$this->t->set_var('user_list',$this->formatted_user($assigned,'accounts'));
$this->t->set_var('group_list',$this->formatted_user($assigned_group,'groups'));
if (!$values['smonth'])
{
$values['smonth'] = date('m',time());
}
if (!$values['sday'])
{
$values['sday'] = date('d',time());
}
if (!$values['syear'])
{
$values['syear'] = date('Y',time());
}
$this->t->set_var('start_select_date',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[syear]',$values['syear']),
$this->sbox->getMonthText('values[smonth]',$values['smonth']),$this->sbox->getDays('values[sday]',$values['sday'])));
$this->t->set_var('end_select_date',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[eyear]',$values['eyear']),
$this->sbox->getMonthText('values[emonth]',$values['emonth']),$this->sbox->getDays('values[eday]',$values['eday'])));
$this->t->set_var('selfortoday','<input type="checkbox"
name="values[seltoday]" value="True">');
$this->t->set_var('daysfromstartdate','<input
type="text" name="values[daysfromstart]" size="3" maxlength="3">');
$this->t->set_var('access_list', '<input
type="checkbox" name="values[access]" value="True"' . ($values['access'] ==
'private'?' checked':'') . '>');
$this->t->set_var('lang_selfortoday',lang('or: select
for today:'));
$this->t->set_var('lang_daysfromstartdate',lang('or:
days from startdate:'));
$this->t->set_var('lang_submit',lang('Submit'));
$this->t->set_var('lang_reset',lang('Clear form'));
$this->t->set_var('edithandle','');
$this->t->set_var('addhandle','');
$this->t->pfp('out','todo_add');
$this->t->pfp('addhandle','add');
}
function view()
{
$GLOBALS['phpgw']->common->phpgw_header();
$values = $this->botodo->read($GLOBALS['todo_id']);
$this->t->set_file('_view','view.tpl');
$this->set_app_langs();
$this->t->set_var('lang_todo_action',lang('View todo
item'));
$this->t->set_var('value_title',$GLOBALS['phpgw']->strip_html($values['title']));
$this->t->set_var('value_descr',$GLOBALS['phpgw']->strip_html($values['descr']));
$this->t->set_var('value_category',$this->cats->id2name($values['cat']));
$sdate = $values['sdate'] -
$this->botodo->datetime->tz_offset;
$this->t->set_var('value_start_date',$GLOBALS['phpgw']->common->show_date($sdate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']));
if ($values['edate'] && $values['edate'] != 0)
{
$edate = $values['edate'] -
$this->botodo->datetime->tz_offset;
$this->t->set_var('value_end_date',$GLOBALS['phpgw']->common->show_date($edate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']));
}
$parent_values = $this->botodo->read($values['parent']);
$this->t->set_var('value_parent',$GLOBALS['phpgw']->strip_html($parent_values['title']));
$this->t->set_var('value_completed',$values['status']);
$assigned =
$this->botodo->list_assigned($this->botodo->format_assigned($values['assigned']));
$assigned .=
$this->botodo->list_assigned($this->botodo->format_assigned($values['assigned_group']));
$this->t->set_var('assigned',$assigned);
$cached_data =
$this->botodo->cached_accounts($values['owner']);
$this->t->set_var('owner',$GLOBALS['phpgw']->common->display_fullname($cached_data[$values['owner']]['lid'],
$cached_data[$values['owner']]['firstname'],$cached_data[$values['owner']]['lastname']));
switch ($values['pri'])
{
case 1: $pri = lang('Low'); break;
case 2: $pri = lang('normal'); break;
case 3: $pri = '<font color="CC0000"><b>' .
lang('high') . '</b></font>'; break;
}
$this->t->set_var('value_urgency',$pri);
$this->t->set_var('lang_access',lang('Access'));
$this->t->set_var('access',lang($values['access']));
$this->t->set_var('history',$this->historylog->return_html(array(),'','',$GLOBALS['todo_id']));
$this->t->set_var('done_action',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.show_list'));
$this->t->pfp('out','_view');
}
function edit()
{
global $cat_id, $new_cat, $values, $submit,
$new_parent, $parent, $todo_id, $assigned, $assigned_group;
if ($new_parent)
{
$parent = $new_parent;
}
if ($new_cat)
{
$cat_id = $new_cat;
}
if ($submit)
{
$values['cat'] = $cat_id;
$values['parent'] = $parent;
$values['id'] = $todo_id;
if (is_array($assigned))
{
$values['assigned'] =
implode(',',$assigned);
if (count($assigned) > 1)
{
$values['assigned'] = ',' .
$values['assigned'] . ',';
}
}
if (is_array($assigned_group))
{
$values['assigned_group'] =
implode(',',$assigned_group);
if (count($assigned_group) > 1)
{
$values['assigned_group'] = ','
. $values['assigned_group'] . ',';
}
}
$error = $this->botodo->check_values($values);
if (is_array($error))
{
$this->t->set_var('error',$GLOBALS['phpgw']->common->error_list($error));
}
else
{
$this->botodo->save($values,'edit');
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.show_list&cat_id='
. $cat_id));
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
exit;
}
}
$GLOBALS['phpgw']->common->phpgw_header();
$this->t->set_file(array('todo_edit' => 'form.tpl'));
$this->t->set_block('todo_edit','add','addhandle');
$this->t->set_block('todo_edit','edit','edithandle');
$this->set_app_langs();
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.edit&todo_id='
. $todo_id));
$values = $this->botodo->read($todo_id);
if ($values['parent'] != 0)
{
$this->t->set_var('lang_todo_action',lang('Edit
sub project'));
}
else
{
$this->t->set_var('lang_todo_action',lang('Edit
main project'));
}
$this->t->set_var('cat_list',$this->cats->formatted_list('select','all',$values['cat'],'True'));
$this->t->set_var('todo_list',$this->formatted_todo($values['parent']));
$this->t->set_var('descr',$GLOBALS['phpgw']->strip_html($values['descr']));
$this->t->set_var('title',$GLOBALS['phpgw']->strip_html($values['title']));
$this->t->set_var('pri_list',$this->sbox->getPriority('values[pri]',$values['pri']));
$this->t->set_var('stat_list',$this->sbox->getPercentage('values[status]',$values['status']));
$this->t->set_var('user_list',$this->formatted_user($this->botodo->format_assigned($values['assigned']),'accounts'));
$this->t->set_var('group_list',$this->formatted_user($this->botodo->format_assigned($values['assigned_group']),'groups'));
if ($values['sdate'] == 0)
{
$values['sday'] = 0;
$values['smonth'] = 0;
$values['syear'] = 0;
}
else
{
$values['sday'] = date('d',$values['sdate']);
$values['smonth'] = date('m',$values['sdate']);
$values['syear'] = date('Y',$values['sdate']);
}
$this->t->set_var('start_select_date',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[syear]',$values['syear']),
$this->sbox->getMonthText('values[smonth]',$values['smonth']),$this->sbox->getDays('values[sday]',$values['sday'])));
if ($values['edate'] == 0)
{
$values['eday'] = 0;
$values['emonth'] = 0;
$values['eyear'] = 0;
}
else
{
$values['eday'] = date('d',$values['edate']);
$values['emonth'] = date('m',$values['edate']);
$values['eyear'] = date('Y',$values['edate']);
}
$this->t->set_var('end_select_date',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[eyear]',$values['eyear']),
$this->sbox->getMonthText('values[emonth]',$values['emonth']),$this->sbox->getDays('values[eday]',$values['eday'])));
$this->t->set_var('selfortoday',' ');
$this->t->set_var('lang_selfortoday',' ');
$this->t->set_var('lang_daysfromstartdate',' ');
$this->t->set_var('daysfromstartdate',' ');
$this->t->set_var('access_list', '<input
type="checkbox" name="values[access]" value="True"' . ($values['access'] ==
'private'?' checked':'') . '>');
if
($this->botodo->check_perms($this->grants[$values['owner']],PHPGW_ACL_DELETE)
|| $values['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
{
$this->t->set_var('delete','<form method="POST"
action="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.delete&todo_id=' .
$values['id'])
. '"><input type="submit" value="' .
lang('Delete') .'"></form>');
}
else
{
$this->t->set_var('delete',' ');
}
$this->t->set_var('lang_submit',lang('Submit'));
$this->t->set_var('edithandle','');
$this->t->set_var('addhandle','');
$this->t->pfp('out','todo_edit');
$this->t->pfp('edithandle','edit');
}
function delete()
{
global $confirm, $todo_id, $subs;
if ($confirm)
{
if ($subs)
{
$this->botodo->delete($todo_id,True);
}
else
{
$this->botodo->delete($todo_id);
}
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.show_list'));
}
$GLOBALS['phpgw']->common->phpgw_header();
$this->t->set_file(array('todo_delete' =>
'delete.tpl'));
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.delete&todo_id='
. $todo_id));
$exists = $this->botodo->exists($todo_id);
if ($exists)
{
$this->t->set_var('lang_subs',lang('Do you also
want to delete all sub projects ?'));
$this->t->set_var('subs','<input
type="checkbox" name="subs" value="True">');
}
else
{
$this->t->set_var('lang_subs','');
$this->t->set_var('subs', '');
}
$this->t->set_var('nolink',$GLOBALS['phpgw']->link('/index.php','menuaction=todo.ui.show_list'));
$this->t->set_var('deleteheader',lang('Are you sure you
want to delete this entry'));
$this->t->set_var('lang_no',lang('No'));
$this->t->set_var('lang_yes',lang('Yes'));
$this->t->pfp('out','todo_delete');
}
function matrix()
{
global $month, $year, $o;
$GLOBALS['phpgw']->common->phpgw_header();
$colors = array
(
'#CC0033',
'#006600',
'#00CCFF',
'#FF6600',
'#0000FF'
);
$this->matrix->matrixview($month,$year);
$entries =
$this->botodo->_list($start,False,$query,$filter,$order,$sort,$cat_id,'mains');
for ($i=0;$i<count($entries);$i++)
{
$o++;
$ind = $o % count($colors);
if ($entries[$i]['sdate_epoch'] > 0 &&
$entries[$i]['edate_epoch'] > 0)
{
$startd =
date('Y',$entries[$i]['sdate_epoch']) . date('m',$entries[$i]['sdate_epoch']) .
date('d',$entries[$i]['sdate_epoch']);
$endd =
date('Y',$entries[$i]['edate_epoch']) . date('m',$entries[$i]['edate_epoch']) .
date('d',$entries[$i]['edate_epoch']);
$this->matrix->setPeriod($GLOBALS['phpgw']->strip_html($entries[$i]['title']),$startd,$endd,$colors[$ind]);
$subentries =
$this->botodo->_list($start,False,$query,$filter,$order,$sort,$cat_id,'subs',$entries[$i]['id']);
for ($j=0;$j<count($subentries);$j++)
{
if
($subentries[$j]['sdate_epoch'] > 0 && $subentries[$j]['edate_epoch'] > 0)
{
$startd =
date('Y',$subentries[$j]['sdate_epoch']) .
date('m',$subentries[$j]['sdate_epoch']) .
date('d',$subentries[$j]['sdate_epoch']);
$endd =
date('Y',$subentries[$j]['edate_epoch']) .
date('m',$subentries[$j]['edate_epoch']) .
date('d',$subentries[$j]['edate_epoch']);
$this->matrix->setPeriod($GLOBALS['phpgw']->strip_html($subentries[$j]['title']),$startd,$endd,$colors[$ind]);
}
}
}
}
$this->matrix->out($GLOBALS['phpgw']->link('/index.php','menuaction=todo.uitodo.matrix'));
}
}
?>
====================================================
Index: class.sotodo.inc.php
<?php
/*************************************************************************\
* phpGroupWare - Todo list
*
* http://www.phpgroupware.org
*
* This program is part of the GNU project, see http://www.gnu.org/
*
*
*
* Written by Joseph Engo <address@hidden> *
* Bettina Gille address@hidden *
* -----------------------------------------------
*
* Copyright 2000 - 2003 Free Software Foundation, Inc
*
*
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\*************************************************************************/
/* $Id: class.sotodo.inc.php,v 1.16 2003/12/24 00:39:04 uid65887 Exp $
*/
class sotodo
{
var $db;
var $grants;
var $historylog;
function sotodo()
{
$this->db = $GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('todo');
$this->user_groups =
$GLOBALS['phpgw']->accounts->membership($this->account);
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->historylog =
CreateObject('phpgwapi.historylog','todo');
// This is so our transactions follow across classes
$this->historylog->db = $this->db;
}
function type($tree)
{
switch ($tree)
{
case 'mains': $s = ' and todo_id_parent=0';
break;
case 'subs': $s = ' and todo_id_parent != 0';
break;
default: return False;
}
return $s;
}
function read_todos($start = 0, $limit = True, $query = '',
$filter = '', $order = '', $sort = '', $cat_id = '', $tree = '', $parent = '')
{
$type = $this->type($tree);
if($order)
{
$ordermethod = 'order by ' . $order . ' ' .
$sort;
}
else
{
$ordermethod = 'order by todo_id_main,
todo_id_parent, todo_level, todo_datecreated asc';
}
$filter = strtolower($filter);
if(!$filter)
{
$filter = 'none';
}
$filtermethod = '(( todo_owner=' . $this->account . "
OR todo_assigned like '%," . $this->account . ",%' OR todo_assigned='" .
$this->account . "'";
if(is_array($this->user_groups))
{
$groups = $this->user_groups;
while (list($null,$group) = each($groups))
{
$filtermethod .= " OR assigned_group
like '%," . $group['account_id'] . ",%' OR assigned_group='" .
$group['account_id'] . "'";
}
}
$filtermethod .= ')';
if($filter == 'none')
{
if(is_array($this->grants))
{
$grants = $this->grants;
while(list($user) = each($grants))
{
$public_user_list[] = $user;
}
reset($public_user_list);
$filtermethod .= " OR
(todo_access='public' AND todo_owner IN(" . implode(',',$public_user_list) .
'))';
}
}
$filtermethod .= ')';
if($filter == 'private')
{
$filtermethod .= " AND todo_access='private'";
}
if($cat_id)
{
$filtermethod .= ' AND todo_cat=' . $cat_id;
}
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
$querymethod = " AND (todo_des LIKE '%$query%'
OR todo_title LIKE '%$query%')";
}
if($parent)
{
$parentmethod = ' AND todo_id_parent=' .
$parent;
}
$sql = "SELECT * FROM phpgw_todo WHERE $filtermethod
$querymethod $type $parentmethod";
if($limit)
{
$this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
}
else
{
$this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
}
$this->total_records = $this->db->num_rows();
while($this->db->next_record())
{
$todos[] = array
(
'id' =>
(int)$this->db->f('todo_id'),
'main' =>
(int)$this->db->f('todo_id_main'),
'parent' =>
(int)$this->db->f('todo_id_parent'),
'level' =>
(int)$this->db->f('todo_level'),
'owner' =>
$this->db->f('todo_owner'),
'owner_id' =>
$this->db->f('todo_owner'),
'access' =>
$this->db->f('todo_access'),
'cat' =>
(int)$this->db->f('todo_cat'),
'title' =>
$this->db->f('todo_title'),
'descr' =>
$this->db->f('todo_des'),
'pri' =>
(int)$this->db->f('todo_pri'),
'status' =>
(int)$this->db->f('todo_status'),
'sdate' =>
$this->db->f('todo_startdate'),
'edate' =>
$this->db->f('todo_enddate'),
'grants' =>
(int)$this->grants[$this->db->f('todo_owner')],
'sdate_epoch' =>
(int)$this->db->f('todo_startdate'),
'edate_epoch' =>
(int)$this->db->f('todo_enddate'),
'assigned' =>
$this->db->f('todo_assigned'),
'assigned_group' =>
$this->db->f('assigned_group')
);
}
return $todos;
}
function read_single_todo($todo_id)
{
$this->db->query('select * from phpgw_todo where
todo_id=' . intval($todo_id),__LINE__,__FILE__);
if ($this->db->next_record())
{
$todo['id'] =
$this->db->f('todo_id');
$todo['main'] =
$this->db->f('todo_id_main');
$todo['parent'] =
$this->db->f('todo_id_parent');
$todo['level'] =
$this->db->f('todo_level');
$todo['owner'] =
$this->db->f('todo_owner');
$todo['access'] =
$this->db->f('todo_access');
$todo['cat'] =
$this->db->f('todo_cat');
$todo['title'] =
$this->db->f('todo_title');
$todo['descr'] =
$this->db->f('todo_des');
$todo['pri'] =
$this->db->f('todo_pri');
$todo['status'] =
$this->db->f('todo_status');
$todo['sdate'] =
$this->db->f('todo_startdate');
$todo['edate'] =
$this->db->f('todo_enddate');
$todo['assigned'] =
$this->db->f('todo_assigned');
$todo['assigned_group'] =
$this->db->f('assigned_group');
}
return $todo;
}
function add_todo($values)
{
if (floor(phpversion()) == 4)
{
ob_start();
print_r($values);
$contents = ob_get_contents();
ob_end_clean();
}
$GLOBALS['phpgw']->log->message(array
(
'text' => 'debug, so add_todo values: %1',
'p1' => $contents,
'line' => __LINE__,
'file' => __FILE__
));
$GLOBALS['phpgw']->log->commit();
$values['parent'] = intval($values['parent']);
if ($values['parent'] > 0)
{
$values['main'] =
$this->return_value($values['parent']);
$values['level'] =
$this->return_value($values['parent'],'level')+1;
}
$values['title'] =
$this->db->db_addslashes($values['title']);
$values['descr'] =
$this->db->db_addslashes($values['descr']);
$this->db->transaction_begin();
$this->db->query('insert into phpgw_todo
(todo_id_main,todo_id_parent,todo_level,todo_owner,todo_access,todo_cat,'
.
'todo_des,todo_title,todo_pri,todo_status,todo_datecreated,todo_startdate,todo_enddate,todo_assigned,assigned_group)
values ('
. intval($values['main']) . ',' .
$values['parent'] . ',' . intval($values['level']) . ',' . $this->account .
",'" . $values['access']
. "'," . intval($values['cat']) . ",'" .
$values['descr'] . "','" . $values['title'] . "'," . intval($values['pri']) .
",'"
. $values['status'] . "'," . time() . ',' .
intval($values['sdate']) . ',' . intval($values['edate']) . ",'" .
$values['assigned']
. "','" . $values['assigned_group'] .
"')",__LINE__,__FILE__);
$todo_id =
$this->db->get_last_insert_id('phpgw_todo','todo_id');
if (!$values['parent'] || $values['parent'] == 0)
{
$this->db->query('update phpgw_todo set
todo_id_main=' . $todo_id . ' where todo_id=' . $todo_id,__LINE__,__FILE__);
}
$this->historylog->add('A',$todo_id,'');
$this->db->transaction_commit();
return $todo_id
}
function find_subs($list_parents='', $list='')
{
if ($list_parents == '')
{
return $list;
}
$query = "SELECT todo_id FROM phpgw_todo WHERE
todo_id_parent IN ($list_parents)";
if ($list <> '')
{
$query .= " AND todo_id NOT IN ($list)";
}
$this->db->query($query,__LINE__,__FILE__);
$subs = array();
while ($this->db->next_record())
{
$subs[] = $this->db->f('todo_id');
}
if (count($subs))
{
$list_subs = implode(',', $subs);
if ($list <> '')
{
$list .= ',';
}
$list = $this->find_subs($list_subs, $list .
$list_subs);
}
return $list;
}
function delete_todo($todo_id, $sub = False)
{
$this->db->transaction_begin();
$sub_todos = $this->find_subs($todo_id);
if ($sub_todos)
{
if($sub)
{
$subdelete = " OR todo_id in
($sub_todos)";
}
else
{
$parent =
$this->return_value($todo_id,'parent');
}
}
$this->db->query('DELETE from phpgw_todo where
todo_id=' . intval($todo_id) . $subdelete . " AND ((todo_access='public' "
. 'AND todo_owner != '
. $this->owner . ') OR (todo_owner=' . $this->owner . '))',__LINE__,__FILE__);
if (!$sub && $sub_todos)
{
$this->db->query('UPDATE phpgw_todo set
todo_id_parent=' . $parent . ' where todo_id_parent=' .
$todo_id,__LINE__,__FILE__);
$this->db->query("UPDATE phpgw_todo set
todo_level=todo_level-1 where todo_id in ($sub_todos)",__LINE__,__FILE__);
}
$this->historylog->delete($todo_id);
$this->db->transaction_commit();
}
function edit_todo($values)
{
$values['parent'] = intval($values['parent']);
$values['id'] = intval($values['id']);
if($values['parent'] > 0)
{
$values['main'] =
$this->return_value($values['parent']);
$values['level'] =
$this->return_value($values['parent'],'level')+1;
}
else
{
$values['main'] = $values['id'];
$values['level'] = 0;
}
$old_values = $this->read_single_todo($values['id']);
$this->db->transaction_begin();
if($old_values['descr'] != $values['descr'])
{
$this->historylog->add('D',$values['id'],$values['descr']);
}
if(($old_values['parent'] || $values['parent']) &&
($old_values['parent'] != $values['parent']))
{
$this->historylog->add('P',$values['id'],$values['parent']);
}
if($old_values['pri'] != $values['pri'])
{
$this->historylog->add('U',$values['id'],$values['pri']);
}
if($old_values['status'] != $values['status'])
{
$this->historylog->add('s',$values['id'],$values['status']);
}
if($old_values['access'] != $values['access'])
{
$this->historylog->add('a',$values['id'],$values['access']);
}
if(($old_values['sdate'] || $values['sdate']) &&
($old_values['sdate'] != $values['sdate']))
{
$this->historylog->add('S',$values['id'],$values['sdate']);
}
if(($old_values['edate'] || $values['edate']) &&
($old_values['edate'] != $values['edate']))
{
$this->historylog->add('E',$values['id'],$values['edate']);
}
if($old_values['title'] != $values['title'])
{
$this->historylog->add('T',$values['id'],$values['title']);
}
if($old_values['cat'] != $values['cat'])
{
$this->historylog->add('C',$values['id'],$values['cat']);
}
$values['title'] =
$this->db->db_addslashes($values['title']);
$values['descr'] =
$this->db->db_addslashes($values['descr']);
$this->db->query("update phpgw_todo set todo_des='".
$values['descr'] . "', todo_id_parent=" . $values['parent']
. ', todo_pri=' . intval($values['pri']) . ",
todo_status='" . $values['status'] . "', todo_id_main=" .
intval($values['main'])
. ", todo_access='" . $values['access'] . "',
todo_level=" . intval($values['level'])
. ', todo_startdate=' .
intval($values['sdate']) . ', todo_enddate=' . intval($values['edate']) . "',
todo_title='" . $values['title']
. "', todo_cat=" . intval($values['cat']) . ",
todo_assigned='" . $values['assigned'] . "', assigned_group='" .
$values['assigned_group']
. "' where todo_id=" .
$values['id'],__LINE__,__FILE__);
$this->db->transaction_commit();
}
function return_value($todo_id,$action = 'main')
{
switch($action)
{
case 'main': $item = ' todo_id_main '; break;
case 'level': $item = ' todo_level '; break;
}
$this->db->query("select $item from phpgw_todo where
todo_id=" . intval($todo_id),__LINE__,__FILE__);
if($this->db->next_record())
{
return $this->db->f(0);
}
}
function exists($todo_id)
{
$this->db->query('select count(*) from phpgw_todo where
todo_id_parent=' . intval($todo_id),__LINE__,__FILE__);
$this->db->next_record();
if($this->db->f(0))
{
return True;
}
else
{
return False;
}
}
}
?>
====================================================
Index: class.botodo.inc.php
<?php
/*************************************************************************\
* phpGroupWare - Todo list
*
* http://www.phpgroupware.org
*
* This program is part of the GNU project, see http://www.gnu.org/
*
*
*
* Written by Joseph Engo <address@hidden> *
* Bettina Gille address@hidden *
* -----------------------------------------------
*
* Copyright 2000 - 2003 Free Software Foundation, Inc
*
*
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\*************************************************************************/
/* $Id: class.botodo.inc.php,v 1.17 2003/12/24 00:39:04 uid65887 Exp $
*/
class botodo
{
var $start;
var $query;
var $filter;
var $order;
var $sort;
var $cat_id;
var $public_functions = array
(
'cached_accounts' => True,
'_list' => True,
'check_perms' => True,
'check_values' => True,
'select_todo_list' => True,
'save' => True,
'_read' => True,
'delete' => True,
'exists' => True,
'list_methods' => True
);
function botodo($session=False)
{
$this->sotodo = CreateObject('todo.sotodo');
$this->datetime = CreateObject('phpgwapi.datetime');
if ($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
$_start = $GLOBALS['HTTP_POST_VARS']['start'] ?
$GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
$_query = $GLOBALS['HTTP_POST_VARS']['query'] ?
$GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
$_sort = $GLOBALS['HTTP_POST_VARS']['sort'] ?
$GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
$_order = $GLOBALS['HTTP_POST_VARS']['order'] ?
$GLOBALS['HTTP_POST_VARS']['order'] : $GLOBALS['HTTP_GET_VARS']['order'];
$_filter = $GLOBALS['HTTP_POST_VARS']['filter']
? $GLOBALS['HTTP_POST_VARS']['filter'] : $GLOBALS['HTTP_GET_VARS']['filter'];
$_cat_id = $GLOBALS['HTTP_POST_VARS']['cat_id']
? $GLOBALS['HTTP_POST_VARS']['cat_id'] : $GLOBALS['HTTP_GET_VARS']['cat_id'];
if(!empty($_start) || ($_start == '0') || ($_start ==
0))
{
if($this->debug) { echo '<br>overriding $start:
"' . $this->start . '" now "' . $_start . '"'; }
$this->start = $_start;
}
if((empty($_query) && !empty($this->query)) ||
!empty($_query))
{
$this->query = $_query;
}
if(isset($_cat_id) && !empty($_cat_id))
{
$this->cat_id = $_cat_id;
}
if((isset($GLOBALS['HTTP_POST_VARS']['cat_id']) ||
isset($GLOBALS['HTTP_GET_VARS']['cat_id'])) &&
($_cat_id == '0' || $_cat_id == 0 || $_cat_id
== ''))
{
$this->cat_id = 0;
}
if(isset($_sort) && !empty($_sort))
{
if($this->debug) { echo '<br>overriding $sort:
"' . $this->sort . '" now "' . $_sort . '"'; }
$this->sort = $_sort;
}
if(isset($_order) && !empty($_order))
{
if($this->debug) { echo '<br>overriding $order:
"' . $this->order . '" now "' . $_order . '"'; }
$this->order = $_order;
}
if(isset($_filter) && !empty($_filter))
{
if($this->debug) { echo '<br>overriding
$filter: "' . $this->filter . '" now "' . $_filter . '"'; }
$this->filter = $_filter;
}
}
function list_methods($_type)
{
if (is_array($_type))
{
$_type = $_type['type'];
}
switch($_type)
{
case 'xmlrpc':
$xml_functions = array(
'list_methods' => array(
'function' =>
'list_methods',
'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
'docstring' =>
lang('Read this list of methods.')
),
'list' => array(
'function' => '_list',
'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' =>
lang('Returns an array of todo items')
),
'save' => array(
'function' => 'save',
'signature' =>
array(array(xmlrpcBoolean,xmlrpcStruct)),
'docstring' =>
lang('Adds or edits a todo item')
),
'delete' => array(
'function' => 'delete',
'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
'docstring' =>
lang('Deletes a todo item')
),
'total_records' => array(
'function' =>
'total_records',
'signature' =>
array(array(xmlrpcInt)),
'docstring' =>
lang('Returns a the total number of records in the database, must call
list_todos first')
)
);
return $xml_functions;
break;
case 'soap':
return $this->soap_functions;
break;
default:
return array();
break;
}
}
function get_grants()
{
return $this->sotodo->grants;
}
function save_sessiondata($data)
{
if ($this->use_session)
{
$GLOBALS['phpgw']->session->appsession('session_data','todo',$data);
}
}
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','todo');
$this->start = $data['start'];
$this->query = $data['query'];
$this->filter = $data['filter'];
$this->order = $data['order'];
$this->sort = $data['sort'];
$this->cat_id = $data['cat_id'];
}
function check_perms($has, $needed)
{
return (!!($has & $needed) == True);
}
function cached_accounts($account_id)
{
return
$GLOBALS['phpgw']->accounts->get_account_data($account_id);
}
function employee_list($type)
{
$employees =
$GLOBALS['phpgw']->accounts->get_list($type);
return $employees;
}
function format_assigned($a = '')
{
if (substr($a,0,1) == ',' &&
(substr($a,strlen($a-1),1)) == ',')
{
$a = substr($a,1,strlen($a)-2);
}
$a = explode(',',$a);
return $a;
}
function list_assigned($assi = '')
{
if (is_array($assi))
{
while (list($null,$a) = each($assi))
{
$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>';
}
elseif($adata[$a]['type'] == 'g')
{
$aout .=
$adata[$a]['firstname'] . ' ' . lang('Group') . '<br>';
}
}
}
return $aout;
}
function _list($start = 0, $limit = '', $query = '', $filter =
'', $order = '', $sort = '', $cat_id = 0, $tree = '', $parent = '')
{
if (is_array($start))
{
$params = $start;
$start = $params['start'];
$limit = $params['limit'];
$query = $params['query'];
$filter = $params['filter'];
$order = $params['order'];
$sort = $params['sort'];
$cat_id = $params['cat_id'];
$tree = $params['tree'];
$parent = $params['parent'];
}
$todos = $this->sotodo->read_todos($start, $limit,
$query, $filter, $order, $sort, $cat_id, $tree, $parent);
$this->total_records = $this->sotodo->total_records;
while (is_array($todos) && list(,$v) = each($todos))
{
$sdate = $v['sdate'] -
$this->datetime->tz_offset;
$v['sdate'] =
$GLOBALS['phpgw']->common->show_date($sdate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
if ($v['edate'] && $v['edate'] != 0)
{
$edate = $v['edate'] -
$this->datetime->tz_offset;
$v['edate'] =
$GLOBALS['phpgw']->common->show_date($edate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
}
if ($v['assigned'])
{
$v['assigned'] =
$this->format_assigned($v['assigned']);
}
if ($v['assigned_group'])
{
$v['assigned_group'] =
$this->format_assigned($v['assigned_group']);
}
$adata = $this->cached_accounts($v['owner']);
$v['owner'] =
$GLOBALS['phpgw']->common->display_fullname($adata[$v['owner']]['lid'],
$adata[$v['owner']]['firstname'],$adata[$v['owner']]['lastname']);
$r[] = array
(
'id' =>
(int)$v['id'],
'main' =>
(int)$v['main'],
'parent' =>
(int)$v['parent'],
'level' =>
(int)$v['level'],
'owner' =>
$v['owner'],
'owner_id' =>
(int)$v['owner_id'],
'access' =>
$v['access'],
'cat' =>
(int)$v['cat'],
'title' =>
$v['title'],
'descr' =>
$v['descr'],
'pri' =>
(int)$v['pri'],
'status' =>
(int)$v['status'],
'sdate' =>
$v['sdate'],
'edate' =>
$v['edate'],
'grants' =>
(int)$v['grants'],
'sdate_epoch' =>
(int)$v['sdate_epoch'],
'edate_epoch' =>
(int)$v['edate_epoch'],
'assigned' =>
$v['assigned'],
'assigned_group' =>
$v['assigned_group']
);
}
return $r;
}
function read($todo_id)
{
$todo = $this->sotodo->read_single_todo($todo_id);
return $todo;
}
function check_values($values)
{
if (!$values['title'])
{
$error[] = lang('Please enter a title');
}
if (strlen($values['descr']) >= 8000)
{
$error[] = lang('Description can not exceed
8000 characters in length');
}
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']))
{
$error[] = lang('You have entered an
starting invalid date');
}
}
if ($values['emonth'] || $values['eday'] ||
$values['eyear'])
{
if(!
$this->datetime->date_valid($values['eyear'],$values['emonth'],$values['eday']))
{
$error[] = lang('You have entered an
ending invalid date');
}
}
if ($values['edate'] < $values['sdate'] &&
$values['edate'] && $values['sdate'])
{
$error[] = lang('Ending date can not be before
start date');
}
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)
{
$error[] = lang('Ending date can not be
before start date');
}
}
if (is_array($error))
{
return $error;
}
}
function save($values)
{
if ($values['access'])
{
$values['access'] = 'private';
}
else
{
$values['access'] = 'public';
}
if ($values['seltoday'])
{
$values['sdate'] = time();
}
else
{
if ($values['smonth'] || $values['sday'] ||
$values['syear'])
{
$values['sdate'] =
mktime(0,0,0,$values['smonth'], $values['sday'], $values['syear']);
}
}
if (!$values['sdate'])
{
$values['sdate'] = time();
}
if ($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']));
}
if ($values['id'] && intval($values['id']) > 0)
{
$this->sotodo->edit_todo($values);
$todo_id = $values['id'];
}
else
{
$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;
}
}
function delete($todo_id, $subs = False)
{
if (is_array($todo_id))
{
$todo_id = $todo_id[0];
}
if ($subs)
{
$this->sotodo->delete_todo($todo_id,True);
}
else
{
$this->sotodo->delete_todo($todo_id);
}
return True;
}
}
?>
- [Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12, uid65887, 2005/04/27
- [Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12, uid65887, 2005/04/27
- [Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12, uid65887, 2005/04/27
- [Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12,
uid65887 <=
- Prev by Date:
[Phpgroupware-cvs] filemanager/inc html.inc.php,1.12.2.2.2.3
- Next by Date:
[Phpgroupware-cvs] todo/inc class.so.inc.php, 1.1.2.8.2.2 class.bo.inc.php, 1.1.2.7.2.2
- Previous by thread:
[Phpgroupware-cvs] todo/inc class.uitodo.inc.php, 1.23 class.sotodo.inc.php, 1.16 class.botodo.inc.php, 1.17 class.ui.inc.php, 1.21 class.bo.inc.php, 1.12 class.so.inc.php, 1.12
- Next by thread:
[Phpgroupware-cvs] bookkeeping index.php,1.18
- Index(es):