Commit 1a5d395c authored by Aaron Wells's avatar Aaron Wells

Revert "Add class JavascriptDetector for checking if javascript is enabled"

This reverts commit 1cdc0486.

The JSDetector class has caused three regressions so far (Bug 1270846,
Bug 1261610, and Bug 1268788). Since it's been buggy and it's not
actively in use anywhere in the site, I think we should revert it.

Change-Id: If32d5adf8733ce3f455aab09a5d138c7707ae95d
parent c7c1648c
......@@ -422,9 +422,6 @@ function auth_setup () {
$USER->logout();
$SESSION->add_ok_msg(get_string('loggedoutok'));
// reset Javascript Detector
require_once(get_config('libroot') . 'jsCheck/jsdetector.php');
JavascriptDetector::reset();
redirect();
}
if ($sessionlogouttime > time()) {
......
......@@ -399,10 +399,6 @@ else {
$SESSION->set('tablet', false);
}
// Javascript detection
require_once(get_config('libroot') . 'jsCheck/jsdetector.php');
JavascriptDetector::check_javascript();
/*
* Initializes our performance info early.
*
......
Javascript check in Mahara
===============
Website: http://www.phpclasses.org/browse/file/26690.html
Author: Gustav Eklundh
This class will check whether Javascript is enabled in the browser or
not. If javascript is enabled this class does js check only once, then
uses set $SESSION variable, which only gets cleared on logout.
Changes:
* Replace $_SESSION by the Mahara global $SESSION variable
* Add reset method
<?php
/*
* jsCheck - By Gustav Eklundh
* A PHP-class to check if JavaScript is activated or not.
*
* Copyright (C) 2009 Gustav Eklundh
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License v3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Homepage: http://threebyte.eu/
* Email: gustav@xcoders.info
**/
/**
*
* This class will detect if the browser supports javascript and store the result in $_SESSION['javascriptenabled'].
*
* How to use:
* // At the begining of your PHP file
* JavascriptDetector::check_javascript();
* ...
* ...
* // When you need to know if the browser supports javascript or not
* if (JavascriptDetector::is_javascript_activated()) {
* // Code for javascript is enabled
* ...
* }
* else {
* // Code for javascript is disabled
* ...
* }
* // You can also use $SESSION->get('javascriptenabled')
* if ($SESSION->get('javascriptenabled')) {
* // Code for javascript is supported
* ...
* }
*
* The following method should be called when the user does logout
* JavascriptDetector::reset(); // to force the JavascriptDetector to detect again
*/
class JavascriptDetector {
static public function check_javascript() {
global $SESSION;
if (isset($_POST['javascriptenabled'])) {
$SESSION->set('javascriptenabled', true);
}
if ($SESSION->get('javascriptenabled') === null && !defined('JSON') && !defined('CLI')) {
$SESSION->set('javascriptenabled', false);
echo <<<JS
<form name="jsdetector_form" id="jsdetector_form" method="post">
<input name="javascriptenabled" type="hidden" value="true" />
<script type="text/javascript">
document.jsdetector_form.submit();
</script>
</form>
JS;
}
}
static public function reset() {
global $SESSION;
$SESSION->clear('javascriptenabled');
}
static public function is_javascript_activated() {
global $SESSION;
return ($SESSION->get('javascriptenabled') === true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment