From: <mo...@us...> - 2005-01-16 15:02:58
|
Update of /cvsroot/tikiwiki/tiki In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22399/tikiwiki Modified Files: Tag: BRANCH-1-9 tiki-user_tasks.php Log Message: hange in design and new functions move_task_to_trash, ... Index: tiki-user_tasks.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/tiki-user_tasks.php,v retrieving revision 1.15.2.7 retrieving revision 1.15.2.8 diff -u -d -r1.15.2.7 -r1.15.2.8 --- tiki-user_tasks.php 15 Jan 2005 19:30:49 -0000 1.15.2.7 +++ tiki-user_tasks.php 16 Jan 2005 15:02:47 -0000 1.15.2.8 @@ -8,6 +8,7 @@ require_once ('tiki-setup.php'); include_once ('lib/tasks/tasklib.php'); +include_once ('lib/userslib.php'); if ($feature_tasks != 'y') { $smarty->assign('msg', tra("This feature is disabled").": feature_tasks"); @@ -42,8 +43,8 @@ $smarty->assign('comp_array', $comp_array); $smarty->assign('comp_array_p', $comp_array_p); -if (!isset($_REQUEST["taskId"])){ - $_REQUEST["taskId"] = 0; +if (!isset($_REQUEST['taskId'])){ + $_REQUEST['taskId'] = 0; } @@ -76,6 +77,22 @@ } } +if (isset($_REQUEST['accept'])){ + $tasklib->accept_task($user, $_REQUEST['taskId'], 'y'); +} + +if (isset($_REQUEST['reject'])){ + $tasklib->accept_task($user, $_REQUEST['taskId'], 'n'); +} + +if (isset($_REQUEST['move_task_into_trash'])){ + $tasklib->move_task_into_trash($user, $_REQUEST['taskId']); +} + +if (isset($_REQUEST['remove_task_from_trash'])){ + $tasklib->remove_task_from_trash($user, $_REQUEST['taskId']); +} + if(isset($_REQUEST["show_form"]) and $_REQUEST["show_form"] == 'y'){ $smarty->assign('show_form', true); } @@ -85,8 +102,8 @@ $smarty->assign('tasks_maxRecords', $tasks_maxRecords); -if ($_REQUEST["taskId"]) { - $info = $tasklib->get_task($user, $_REQUEST["taskId"]); +if ($_REQUEST['taskId']) { + $info = $tasklib->get_task($user, $_REQUEST['taskId']); if(!(isset($info['user']))){ $smarty->assign('msg', tra("Sorry this task does not exist or you have no rights to view this task")); $smarty->display("error.tpl"); @@ -97,80 +114,288 @@ $info = $tasklib->get_default_new_task($user); } - $right = $tasklib->check_right_on_task($user, $info); +if(isset($right)){ + $editable['user'] = true; + $editable['taskId'] = true; + $editable['belongs_to'] = true; + $editable['task_version'] = true; + $editable['title'] = true; + $editable['description'] = true; + $editable['date'] = true; + $editable['start'] = true; + $editable['end'] = true; + $editable['status'] = true; + $editable['priority'] = true; + $editable['completed'] = true; + $editable['percentage'] = true; + $editable['lasteditor'] = true; + $editable['changes'] = true; + $editable['deleted'] = true; + $editable['creator'] = true; + $editable['accepted_creator'] = true; + $editable['accepted_user'] = true; + $editable['public_for_group'] = true; + $editable['rights_by_creator'] = true; + $editable['info'] = true; + + if($right == 'new'){ + $editable['taskId'] = false; + $editable['belongs_to'] = false; + $editable['task_version'] = false; + $editable['date'] = false; + $editable['lasteditor'] = false; + $editable['changes'] = false; + $editable['deleted'] = false; + $editable['creator'] = false; + $editable['accepted_creator'] = false; + $editable['accepted_user'] = false; + } else + if($right == 'private'){ + $editable['user'] = false; + $editable['taskId'] = false; + $editable['belongs_to'] = false; + $editable['task_version'] = false; + $editable['date'] = false; + $editable['lasteditor'] = false; + $editable['changes'] = false; + $editable['creator'] = false; + $editable['accepted_creator'] = false; + $editable['accepted_user'] = false; + $editable['rights_by_creator'] = false; + $editable['info'] = false; + $editable['rights_by_creator'] = false; + } else + if($right == 'creator'){ + $editable['user'] = false; + $editable['taskId'] = false; + $editable['belongs_to'] = false; + $editable['task_version'] = false; + $editable['date'] = false; + $editable['lasteditor'] = false; + $editable['changes'] = false; + $editable['creator'] = false; + if($info['user'] != $info['creator'] and $user != $info['creator']) $editable['rights_by_creator'] = false; + } else + if($right == 'user'){ + $editable['user'] = false; + $editable['taskId'] = false; + $editable['belongs_to'] = false; + $editable['task_version'] = false; + $editable['date'] = false; + $editable['lasteditor'] = false; + $editable['changes'] = false; + $editable['deleted'] = false; + $editable['creator'] = false; + $editable['rights_by_creator'] = false; + } + if($info['user'] == $user) $editable['accepted_user'] = true; else $editable['accepted_user'] = false; + if($info['creator'] == $user) $editable['accepted_creator'] = true; else $editable['accepted_creator'] = false; + + if ($tiki_p_tasks_send != 'y') { + $editable['user'] = false; + } +} + if (isset($_REQUEST['save']) and isset($right) and $right != 'view') { $dc = $tikilib->get_date_converter($user); - - if( isset($_REQUEST["date_Hour"]) and - isset($_REQUEST["date_Hour"]) and - isset($_REQUEST["date_Hour"]) and - isset($_REQUEST["date_Hour"]) and - isset($_REQUEST["date_Hour"])){ - $date_now = $dc->getServerDateFromDisplayDate(mktime( $_REQUEST["date_Hour"], - $_REQUEST["date_Minute"], + $save = $info; + + + if( isset($_REQUEST['use_start_date']) and + isset($_REQUEST['start_Hour']) and + isset($_REQUEST['start_Minute']) and + isset($_REQUEST['start_Month']) and + isset($_REQUEST['start_Day']) and + isset($_REQUEST['start_Year'])){ + $start_date = $dc->getServerDateFromDisplayDate(mktime( $_REQUEST['start_Hour'], + $_REQUEST['start_Minute'], 0, - $_REQUEST["date_Month"], - $_REQUEST["date_Day"], - $_REQUEST["date_Year"])); - } - - if ($_REQUEST['status'] == 'c') { - $_REQUEST['percentage'] = 100; + $_REQUEST['start_Month'], + $_REQUEST['start_Day'], + $_REQUEST['start_Year'])); + } else $start_date = null; + + if( isset($_REQUEST['use_end_date']) and + isset($_REQUEST['end_Hour']) and + isset($_REQUEST['end_Minute']) and + isset($_REQUEST['end_Month']) and + isset($_REQUEST['end_Day']) and + isset($_REQUEST['end_Year'])){ + $end_date = $dc->getServerDateFromDisplayDate(mktime( $_REQUEST['end_Hour'], + $_REQUEST['end_Minute'], + 0, + $_REQUEST['end_Month'], + $_REQUEST['end_Day'], + $_REQUEST['end_Year'])); + } else $end_date = null; - $completed = $date; - } else { - $completed = 0; + if($editable['user'] and isset($_REQUEST['task_user'])) $save['user'] = $_REQUEST['task_user']; + $save['belongs_to'] = $save['belongs_to']; + if($right != 'new') $save['task_version'] = $save['task_version'] + 1; + if($editable['title'] and isset($_REQUEST['title'])) $save['title'] = $_REQUEST['title']; + if($editable['description'] and isset($_REQUEST['description'])){ + $save['description'] = $_REQUEST['description']; } + if($editable['start']) $save['start'] = $start_date; + if($editable['end']) $save['end'] = $end_date; + + if($editable['status']){ + if(!isset($_REQUEST["status"])) $save['status'] = null; + else if(isset($_REQUEST["status"]) and $_REQUEST["status"] == 'w') $save['status'] = null; + else if(isset($_REQUEST["status"]) and $_REQUEST["status"] == 'o'){ + $save['status'] = 'o'; + $save['completed'] = null; + } + else if(isset($_REQUEST["status"]) and $_REQUEST["status"] == 'c'){ + $save['status'] = 'c'; + $save['completed'] = date("U"); + $_REQUEST["percentage"] = 100; + } + $save['description'] = $_REQUEST["description"]; + } + + if($editable['priority']){ + if(!isset($_REQUEST["priority"])) $save['priority'] = 3; + else + $save['priority'] = $_REQUEST["priority"]; + } + + if($editable['percentage'] and isset($_REQUEST["percentage"])) $save['percentage'] = $_REQUEST["percentage"]; + + $editable['lasteditor'] = $user; + $editable['changes'] = date("U"); + + if($editable['creator'] and isset($_REQUEST["creator"])) $save['creator'] = $_REQUEST["creator"]; + + + if($right != 'new' and $right != 'private'){ + if($editable['accepted_creator'] and $info['creator'] == $user){ + $save['accepted_creator'] = 'y'; + $save['accepted_user'] = null; + } + if($editable['accepted_user'] and $info['user'] == $user){ + $save['accepted_creator'] = 'y'; + $save['accepted_user'] = null; + } + }else if($right == 'new') $save['accepted_creator'] = 'y'; - if ($_REQUEST['percentage'] == 100) { - $completed = $date; - - $_REQUEST['status'] = 'c'; - } else { - $_REQUEST['status'] = 'o'; - - $completed = 0; + if($editable['public_for_group']){ + if (isset($_REQUEST['public_for_group'])) $save['public_for_group'] = $_REQUEST['public_for_group']; + else $save['public_for_group'] = null; + } + + if($editable['rights_by_creator']){ + if(isset($_REQUEST['rights_by_creator'])) $save['rights_by_creator'] = 'y'; + if(!isset($_REQUEST['rights_by_creator'])) $save['rights_by_creator'] = null; } + + if($editable['info'] and isset($_REQUEST["info"])) $save['info'] = $_REQUEST["info"]; + + $save['deleted'] = null; - $tasklib->replace_task($user, $_REQUEST["taskId"], $_REQUEST["title"], $_REQUEST["description"], - $date_now, $_REQUEST['status'], $_REQUEST['priority'], $completed, $_REQUEST['percentage']); - $info = array(); - $info['title'] = ''; - $info['description'] = ''; - $info['priority'] = 3; - $info['status'] = 'o'; - $info['date'] = date("U"); - $_REQUEST["taskId"] = 0; + + if(!isset($save['title']) or strlen($save['title']) < 3){ + $smarty->assign('msg', tra("The tile must have at lease three characters!")); + $smarty->display("error.tpl"); + die; + } + if(isset($save['end']) and isset($save['start']) and $save['start'] >= $save['end']){ + $smarty->assign('msg', tra("The end date must be after the start date!")); + $smarty->display("error.tpl"); + die; + } + + /* + if($save['creator'] != $save['user']){ + if($userslib->user_has_permission($save['user'],'tiki_p_tasks_receive') != 1){ + $smarty->assign('msg', tra("Sorry the task user has no right to recive tasks")); + $smarty->display("error.tpl"); + die; + } + if($userslib->user_has_permission($save['creator'],'tiki_p_tasks_send') != 1){ + $smarty->assign('msg', tra("Sorry the creator has no right to send tasks")); + $smarty->display("error.tpl"); + die; + } + } + */ + $new_taskId = $tasklib->write_task_in_db( $save['user'], + $save['taskId'], + $save['belongs_to'], + $save['task_version'], + $save['title'], + $save['description'], + $save['date'], + $save['start'], + $save['end'], + $save['status'], + $save['priority'], + $save['completed'], + $save['percentage'], + $save['lasteditor'], + $save['changes'], + $save['deleted'], + $save['creator'], + $save['accepted_creator'], + $save['accepted_user'], + $save['public_for_group'], + $save['rights_by_creator'], + $save['info'] + ); + $info = $tasklib->get_task($user, $new_taskId); + + if(!isset($info['user'])){ + unset($_REQUEST['taskId']); + $smarty->assign('msg', tra("Sorry this problems by writing into the database")); + $smarty->display("error.tpl"); + die; + } + + $_REQUEST['taskId'] = $new_taskId; + $smarty->assign('saved', true); + $smarty->assign('show_form', true); + $right = $tasklib->check_right_on_task($user, $info); } -$smarty->assign('taskId', $_REQUEST["taskId"]); +$smarty->assign('taskId', $_REQUEST['taskId']); $smarty->assign('info', $info); -$smarty->assign('date_Month', date("m", $info['date'])); -$smarty->assign('date_Day', date("d", $info['date'])); -$smarty->assign('date_Year', date("Y", $info['date'])); -$smarty->assign('date_Hour', date("H", $info['date'])); -$smarty->assign('date_Minute', date("M", $info['date'])); +$smarty->assign('created_Month', date('m', $info['date'])); +$smarty->assign('created_Day', date('d', $info['date'])); +$smarty->assign('created_Year', date('Y', $info['date'])); +$smarty->assign('created_Hour', date('H', $info['date'])); +$smarty->assign('created_Minute', date('M', $info['date'])); + + +if($info['start'] == null) $smarty->assign('start_date', date("U")); + else $smarty->assign('start_date', $info['start']); + +if($info['end'] == null){ + if($info['start'] == null) $smarty->assign('end_date', date("U")); + else $smarty->assign('end_date', $info['start']); +} else $smarty->assign('end_date', $info['end']); + + $smarty->assign('right', $right); -if (!isset($_REQUEST["sort_mode"])) { +if (!isset($_REQUEST['sort_mode'])) { $sort_mode = 'priority_desc'; } else { - $sort_mode = $_REQUEST["sort_mode"]; + $sort_mode = $_REQUEST['sort_mode']; } -if (!isset($_REQUEST["offset"])) { +if (!isset($_REQUEST['offset'])) { $offset = 0; } else { - $offset = $_REQUEST["offset"]; + $offset = $_REQUEST['offset']; } $smarty->assign_by_ref('offset', $offset); -if (isset($_REQUEST["find"])) { - $find = $_REQUEST["find"]; +if (isset($_REQUEST['find'])) { + $find = $_REQUEST['find']; } else { $find = ''; } @@ -187,11 +412,12 @@ $channels = $tasklib->list_tasks($user, $offset, $maxRecords, $sort_mode, $find, $tasks_useDates, $pdate); -$cant_pages = ceil($channels["cant"] / $maxRecords); +$cant_pages = ceil($channels['cant'] / $maxRecords); $smarty->assign_by_ref('cant_pages', $cant_pages); $smarty->assign('actual_page', 1 + ($offset / $maxRecords)); $receive_groups = $tikilib->get_groups_to_user_with_permissions($user, 'tiki_p_tasks_receive'); $smarty->assign('receive_groups', $receive_groups); +$smarty->assign('editable', $editable); if ($channels["cant"] > ($offset + $maxRecords)) { $smarty->assign('next_offset', $offset + $maxRecords); |