From 21b1cc8e7ee0c0decffef215c80b4ebcb6c1b692 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 23 Mar 2017 09:00:13 -0600 Subject: [PATCH] Infolog - use current sorting on infolog list for calendar todo list --- infolog/inc/class.infolog_bo.inc.php | 4 ++-- infolog/inc/class.infolog_ui.inc.php | 22 ++++++++++++++++++++++ infolog/setup/setup.inc.php | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/infolog/inc/class.infolog_bo.inc.php b/infolog/inc/class.infolog_bo.inc.php index 2758703d6f..57eff8cff8 100644 --- a/infolog/inc/class.infolog_bo.inc.php +++ b/infolog/inc/class.infolog_bo.inc.php @@ -1452,8 +1452,8 @@ class infolog_bo $to_include = array(); $date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']); $query = array( - 'order' => 'info_startdate', - 'sort' => $do_events ? 'ASC' : 'DESC', + 'order' => $args['order'] ? $args['order'] : 'info_startdate', + 'sort' => $args['sort'] ? $args['sort'] : ($do_events ? 'ASC' : 'DESC'), 'filter'=> "user$user".($do_events ? 'date' : 'opentoday').$date_wanted, 'start' => 0, ); diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 30597680a3..5fdf73e1bf 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -686,6 +686,28 @@ class infolog_ui return $event; } + /** + * hook called be calendar to include events or todos in the cal-dayview + * Since the hook has no idea about infolog or preferences, we add the user's + * current sorting for infolog here so they're in the expected order + * + * @param int $args[year], $args[month], $args[day] date of the events + * @param int $args[owner] owner of the events + * @param string $args[location] calendar_include_{events|todos} + * @return array of events (array with keys starttime, endtime, title, view, icon, content) + */ + public function cal_to_include($args) + { + $nm = Api\Cache::getSession('infolog', 'session_data'); + if($nm) + { + $args['order'] = $nm['order']; + $args['sort'] = $nm['sort']; + } + + return $this->bo->cal_to_include($args); + } + /** * Shows the infolog list * diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index 6a0305699e..8a86dd1a64 100644 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -57,7 +57,7 @@ $setup_info['infolog']['hooks']['projects_view'] = 'infolog.infolog_ui.hook_v $setup_info['infolog']['hooks']['calendar_view'] = 'infolog.infolog_ui.hook_view'; $setup_info['infolog']['hooks']['infolog'] = 'infolog.infolog_ui.hook_view'; $setup_info['infolog']['hooks']['calendar_include_events'] = 'infolog.infolog_bo.cal_to_include'; -$setup_info['infolog']['hooks']['calendar_include_todos'] = 'infolog.infolog_bo.cal_to_include'; +$setup_info['infolog']['hooks']['calendar_include_todos'] = 'infolog.infolog_ui.cal_to_include'; $setup_info['infolog']['hooks']['sidebox_menu'] = 'infolog_hooks::all_hooks'; $setup_info['infolog']['hooks']['search_link'] = 'infolog_hooks::search_link'; $setup_info['infolog']['hooks']['pm_custom_app_icons'] = 'infolog.infolog_bo.pm_icons';