From 6854cb3f4d8219cf1829e32122eb2502a916eae9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 1 Feb 2020 09:05:48 +0100 Subject: initial checkin --- header.php | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 header.php (limited to 'header.php') diff --git a/header.php b/header.php new file mode 100644 index 0000000..3e36110 --- /dev/null +++ b/header.php @@ -0,0 +1,75 @@ +add('default-src', "'none'"); + +// If it is empty, take the user to the setup page +if (!$conf) { + Flyspray::redirect('setup/index.php'); +} + +$db = new Database(); +$db->dbOpenFast($conf['database']); +$fs = new Flyspray(); + +// If version number of database and files do not match, run upgrader +if (Flyspray::base_version($fs->version) != Flyspray::base_version($fs->prefs['fs_ver'])) { + Flyspray::redirect('setup/upgrade.php'); +} + + +# load the correct $proj early also for checks on quickedit.php taskediting calls +if( (BASEDIR.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'callbacks'.DIRECTORY_SEPARATOR.'quickedit.php' == $_SERVER['SCRIPT_FILENAME']) && Post::num('task_id')){ + $result = $db->query('SELECT project_id FROM {tasks} WHERE task_id = ?', array(Post::num('task_id'))); + $project_id = $db->fetchOne($result); +} +# Any "do" mode that accepts a task_id field should be added here. +elseif (in_array(Req::val('do'), array('details', 'depends', 'editcomment'))) { + if (Req::num('task_id')) { + $result = $db->query('SELECT project_id FROM {tasks} WHERE task_id = ?', array(Req::num('task_id'))); + $project_id = $db->fetchOne($result); + } +} + +if (Req::val('do') =='pm' && Req::val('area')=='editgroup') { + if (Req::num('id')) { + $result = $db->query('SELECT project_id FROM {groups} WHERE group_id = ?', array(Req::num('id'))); + $project_id = $db->fetchOne($result); + } +} + +if (!isset($project_id)) { + $project_id = $fs->prefs['default_project']; + # Force default value if input format is not allowed + if(is_array(Req::val('project'))) { + Req::set('project', $fs->prefs['default_project']); + } + $project_id = Req::val('project', Req::val('project_id', $project_id)); +} + +$proj = new Project($project_id); -- cgit v1.2.3-70-g09d2