From 49c4aa1a546264fa39754ae8a7c08243a6896b04 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 20 Aug 2015 20:40:42 -0700 Subject: cleanup of task widget - make jquery workflow a bit smoother --- include/event.php | 4 ++-- include/widgets.php | 20 ++++++++++---------- mod/tasks.php | 54 +++++++++++++++++++++++++++++++---------------------- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/include/event.php b/include/event.php index fad852dfc..95a165fdc 100644 --- a/include/event.php +++ b/include/event.php @@ -927,10 +927,10 @@ function tasks_fetch($arr) { $ret = array(); $sql_extra = " and event_status != 'COMPLETED' "; - if(argc() > 1 && argv(1) === 'all') + if($arr && $arr['all'] == 1) $sql_extra = ''; - $r = q("select * from event where type = 'task' and uid = %d $sql_extra ", + $r = q("select * from event where type = 'task' and uid = %d $sql_extra order by created desc", intval(local_channel()) ); diff --git a/include/widgets.php b/include/widgets.php index 7433a1ec8..5e70730a3 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1047,17 +1047,17 @@ function widget_tasklist($arr) { require_once('include/event.php'); - $o .= ''; - $o .= ''; - $o .= '
' . '

' . t('Tasks') . '

'; - $x = tasks_fetch(array()); - - if($x['success']) { - foreach($x['tasks'] as $y) { - $o .= '
' . $y['summary'] . '
'; + $o .= ''; + $o .= ''; + + $o .= '
' . '

' . t('Tasks') . '

'; + $o .= '
'; $o .= '
'; return $o; diff --git a/mod/tasks.php b/mod/tasks.php index 869d9b3cd..ed267cc92 100644 --- a/mod/tasks.php +++ b/mod/tasks.php @@ -1,8 +1,39 @@ 1 && argv(1) === 'fetch') { + if(argc() > 2 && argv(2) === 'all') + $arr['all'] = 1; + + $x = tasks_fetch($arr); + if($x['tasks']) { + $x['html'] = ''; + foreach($x['tasks'] as $y) { + $x['html'] .= '
' . $y['summary'] . '
'; + } + } + json_return_and_die($x); + } + +} + + function tasks_post(&$a) { + +// logger('post: ' . print_r($_POST,true)); + + if(! local_channel()) return; @@ -71,27 +102,6 @@ function tasks_content(&$a) { if(! local_channel()) return; - $ret = array(); - $sql_extra = " and event_status != 'COMPLETED' "; - if(argc() > 1 && argv(1) === 'all') - $sql_extra = ''; -dbg(1); - $r = q("select * from event where type = 'task' and uid = %d $sql_extra ", - intval(local_channel()) - ); -dbg(0); - - $ret['success'] = (($r) ? true : false); - if($r) { - $ret['tasks'] = $r; - } - -// return $ret; - - return json_encode($ret); - -// json_return_and_die($ret); - - + return ''; } \ No newline at end of file -- cgit v1.2.3