This repository was archived by the owner on Dec 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmod_session.php
More file actions
71 lines (62 loc) · 1.66 KB
/
mod_session.php
File metadata and controls
71 lines (62 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php defined('_JEXEC') or die;
/**
*
* File mod_session.php
* Created 5/22/13 6:43 AM
* Author Matt Thomas | matt@betweenbrain.com | http://betweenbrain.com
* Support https://github.com/betweenbrain/
* Copyright Copyright (C) 2013 betweenbrain llc. All Rights Reserved.
* License GNU General Public License version 2, or later.
*/
// Include the helper.
require_once __DIR__ . '/helper.php';
// Instantiate global document object
$doc = JFactory::getDocument();
$loadJquery = $params->get('loadJquery', 1);
$format = $params->get('format', 'debug');
// Load jQuery
if ($loadJquery == '1') {
$doc->addScript('//code.jquery.com/jquery-latest.min.js');
}
$js = <<<JS
(function ($) {
$(document).on('click', 'input[type=submit]', function () {
var value = $('input[name=data]').val(),
action = $(this).attr('class'),
request = {
'option' : 'com_ajax',
'module' : 'session',
'cmd' : action,
'data' : value,
'format' : '{$format}'
};
$.ajax({
type : 'POST',
data : request,
success: function (response) {
console.log(response);
if(response.data){
var result = '';
$.each(response.data, function (index, value) {
result = result + ' ' + value;
});
$('.status').html(result);
} else {
$('.status').html(response);
}
},
error: function(response) {
var data = '',
obj = $.parseJSON(response.responseText);
for(key in obj){
data = data + ' ' + obj[key] + '<br/>';
}
$('.status').html(data);
}
});
return false;
});
})(jQuery)
JS;
$doc->addScriptDeclaration($js);
require(JModuleHelper::getLayoutPath('mod_session'));