index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
commit | 6854cb3f4d8219cf1829e32122eb2502a916eae9 (patch) | |
tree | 350feb504587d932e02837a1442b059759927646 /scripts/activity.php |
-rw-r--r-- | scripts/activity.php | 64 |
diff --git a/scripts/activity.php b/scripts/activity.php new file mode 100644 index 0000000..7968c19 --- /dev/null +++ b/scripts/activity.php @@ -0,0 +1,64 @@ +<?php +/*****************************\ +| Activity Graph Maker | +| Renders a graph for topview | +\*****************************/ + +if (!defined('IN_FS')) { + die('Do not access this file directly.'); +} + +$data=''; + +# Project Graph +if ((Get::has('project_id') && Get::val('graph', 'project') == 'project')) { + if ($user->can_view_project(Get::num('project_id'))) { + $today = date('Y-m-d'); + $thirtyone_days = date('U' , strtotime("-31 day", strtotime($today))); + $sixtyone_days = date('U' , strtotime("-61 day", strtotime($today))); + + //look 30 + days and if found scale + $projectCheck = Project::getActivityProjectCount($sixtyone_days, $thirtyone_days, Get::num('project_id')); + + if($projectCheck > 0) { + $data = Project::getDayActivityByProject($sixtyone_days, date('U', strtotime(date('Y-m-d'))), Get::num('project_id')); + } else { + $data = Project::getDayActivityByProject($thirtyone_days, date('U', strtotime(date('Y-m-d'))), Get::num('project_id')); + } + + $data = implode(',', $data); + } else { + # and make the zero-line 'invisible' + $_GET['line']='fff'; + } +# User Graph +} else if(Get::has('user_id') && Get::has('project_id') && Get::val('graph') == 'user') { + if ($user->can_view_project(Get::num('project_id'))) { + $today = date('Y-m-d'); + $thirtyone_days = date('U' , strtotime("-31 day", strtotime($today))); + $sixtyone_days = date('U' , strtotime("-61 day", strtotime($today))); + + //look 30 + days and if found scale + $projectCheck = Project::getActivityProjectCount($sixtyone_days, $thirtyone_days, Get::num('project_id')); + + if($projectCheck > 0) { + $data = User::getDayActivityByUser($sixtyone_days, date('U', strtotime(date('Y-m-d'))), Get::num('project_id'), Get::num('user_id')); + } else { + $data = User::getDayActivityByUser($thirtyone_days, date('U', strtotime(date('Y-m-d'))), Get::num('project_id'), Get::num('user_id')); + } + + $data = implode(',', $data); + } else { + # and make the zero-line 'invisible' + $_GET['line']='fff'; + } +} else { + # make the zero-line 'invisible' + $_GET['line']='fff'; +} + +// Not pretty but gets the job done. +$_SERVER['QUERY_STRING'] = 'size=160x25&data='. $data; +$_GET['size'] = '160x25'; +$_GET['data'] = $data; +require dirname(__DIR__) . '/vendor/jamiebicknell/Sparkline/sparkline.php'; |