Skip to content
Snippets Groups Projects
Commit 7c631452 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add ajax suppor to client interface - needed to fetch multifile config.

parent 87972399
No related branches found
No related tags found
No related merge requests found
ajax.php 0 → 100644
<?php
/*********************************************************************
ajax.php
Ajax utils for client interface.
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2012 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
function clientLoginPage($msg='Unauthorized') {
Http::response(403,'Must login: '.Format::htmlchars($msg));
exit;
}
require('client.inc.php');
if(!defined('INCLUDE_DIR')) Http::response(500,'config error');
require_once INCLUDE_DIR.'/class.dispatcher.php';
require_once INCLUDE_DIR.'/class.ajax.php';
$dispatcher = patterns('',
url('^/config/', patterns('ajax.config.php:ConfigAjaxAPI',
url_get('^client', 'client')
))
);
print $dispatcher->resolve($_SERVER['PATH_INFO']);
?>
......@@ -20,14 +20,27 @@ class ConfigAjaxAPI extends AjaxController {
//config info UI might need.
function scp() {
global $thisstaff, $cfg;
global $cfg;
$config=array('lock_time' => ($cfg->getLockTime()*3600),
$config=array(
'lock_time' => ($cfg->getLockTime()*3600),
'file_types' => $cfg->getAllowedFileTypes(),
'max_file_size' => (int) $cfg->getMaxFileSize(),
'max_file_uploads'=> (int) $cfg->getStaffMaxFileUploads()
);
return $this->json_encode($config);
}
function client() {
global $cfg;
$config=array(
'file_types' => $cfg->getAllowedFileTypes(),
'max_file_size' => (int) $cfg->getMaxFileSize(),
'max_file_uploads'=> (int) $cfg->getClientMaxFileUploads()
);
return $this->json_encode($config);
}
}
?>
//Nothing for now...
/*
osticket.js
Copyright (c) osTicket.com
*/
$(document).ready(function(){
$("input:not(.dp):visible:enabled:first").focus();
$('table.list tbody tr:odd').addClass('odd');
$("form#save :input").change(function() {
var fObj = $(this).closest('form');
if(!fObj.data('changed')){
fObj.data('changed', true);
$('input[type=submit]', fObj).css('color', 'red');
$(window).bind('beforeunload', function(e) {
return 'Are you sure you want to leave? Any changes or info you\'ve entered will be discarded!';
});
}
});
$("form#save :input[type=reset]").click(function() {
var fObj = $(this).closest('form');
if(fObj.data('changed')){
$('input[type=submit]', fObj).removeAttr('style');
$('label', fObj).removeAttr('style');
$('label', fObj).removeClass('strike');
fObj.data('changed', false);
$(window).unbind('beforeunload');
}
});
$('form#save').submit(function() {
$(window).unbind('beforeunload');
return true;
});
/* Get config settings from the backend */
var $config = null;
$.ajax({
url: "ajax.php/config/client",
dataType: 'json',
async: false,
success: function (config) {
$config = config;
}
});
/* Multifile uploads */
$('.multifile').multifile({
container: '.uploads',
max_uploads: ($config && $config.max_file_uploads)?$config.max_file_uploads:1,
file_types: ($config && $config.file_types)?$config.file_types:".*"
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment