|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript" src="/jquery-1.9.1.js"></script>
|
|
<!-- <script type="text/javascript" src="/jquery.validate.js"></script>-->
|
|
<script type="text/javascript" src="/js/bootstrap.js"></script>
|
|
<!-- <script type="text/javascript" src="jquery.dform-1.0.1.js"></script>-->
|
|
<script type="text/javascript">
|
|
var service_hash={'admin':{'text':'Gestisci gli utenti del LILiK', 'href': 'http://login.lilik.it'},
|
|
'mail':{'text':'Controlla la tua casella @lilik.it', 'href': 'http://webmail.lilik.it'},
|
|
'ltsp':{'text':'Accedi ai client del LILiK'},
|
|
'users':{'text':'Hai un utente sulla macchina users', 'href': 'http://users.lilik.it'},
|
|
'wiki':{'text':'Modifica la wiki', 'href': 'http://wiki.lilik.it'},
|
|
'public_html':{'text':'Hai un sito web sulla macchina users', 'href': 'http://users.lilik.it'},
|
|
'lilik.it':{'text':'Accedi con il tuo utente a lilik.it', 'href': 'http://www.lilik.it'},
|
|
'cloud':{'text':'Accedi alla piattaforma cloud', 'href': 'http://cloud.lilik.it'},
|
|
'projects':{'text':'Accedi al portale progetti', 'href': 'http://projects.lilik.it'},
|
|
'teambox':{'text':'Accedi a teambox', 'href': 'http://teambox.lilik.it'}
|
|
};
|
|
|
|
function parsedata(data){
|
|
$('#content').text('');
|
|
$('#alerts').text('');
|
|
$('#services').text('');
|
|
|
|
if (!data['loggedin']){
|
|
$('#loginModal').modal('show');
|
|
}
|
|
|
|
if (data['admin']==true){
|
|
$('#search-form').show();
|
|
$('#old_password').hide()
|
|
}else{
|
|
$('#search-form').hide();
|
|
$('#old_password').show()
|
|
}
|
|
|
|
if ('username' in data){
|
|
$('#content').append($('<h2 class="">').text(data['username']));
|
|
var cn=$('<h5>').text(data['cn']);
|
|
if (data['admin']==true){
|
|
cn=$('<input type="text" name="cn" placeholder="Nome completo" >').val(data['cn']);
|
|
}
|
|
$('#content').append($('<div class="row-fluid">').append($('<div class="span4">').append(cn)).append($('<div class="span8">').append($('<a href="#passwordModal" role="button" class="btn inline" data-toggle="modal">').text('Cambia password'))));
|
|
}
|
|
['error', 'info', 'success'].forEach(function(what){
|
|
if (what in data){
|
|
$('#alerts').append($('<div class="alert alert-block alert-'+what+'">').text(data[what]).append('uup-').fadeIn(700))
|
|
}
|
|
});
|
|
if ('avaible_services' in data){
|
|
services=data['services'];
|
|
if (data['admin']==true){
|
|
var fieldset=$('<fieldset>');
|
|
$('#content').append(fieldset);
|
|
data['avaible_services'].forEach(function(service){
|
|
tmp=$('<label>');
|
|
tmp=tmp.prepend($('<input name="services[]" type="checkbox" value="'+service+'" '+((services.indexOf(service)>=0)?'checked="true"':'')+'>'));
|
|
tmp.append((service in service_hash)?service_hash[service]['text']:service);
|
|
fieldset.append(tmp);
|
|
});
|
|
}else{
|
|
$('#content').append($('<ul id="services">'));
|
|
services.forEach(function(service){
|
|
var tmp=$('<li>');
|
|
tmp.text((service in service_hash && 'text' in service_hash[service])?service_hash[service]['text']:service);
|
|
if (service in service_hash && 'href' in service_hash[service]){
|
|
tmp.wrapInner($('<a target="_blank">').attr('href', service_hash[service]['href']));
|
|
}
|
|
$('#services').append(tmp);
|
|
});
|
|
}
|
|
}
|
|
if (data['admin']==true & data['exist']!=false & $('#content').text()!=''){
|
|
$('#content').append($('<button type="submit" class="btn btn-primary">Salva</button>'));
|
|
$('#content').wrapInner($('<form data-async action="user.php" method="POST">'));
|
|
}
|
|
}
|
|
|
|
function get(url){
|
|
$.getJSON(url).done(parsedata);
|
|
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$("#search-user").change(function() {
|
|
$("#search-form").attr("action", "/users/" + $(this).val() + "/");
|
|
});
|
|
$("#inputUsername").change(function() {
|
|
$("#newUserForm").attr("action", "/users/" + $(this).val() + "/user.php");
|
|
});
|
|
jQuery(function($) {
|
|
$("body").on('submit', 'form[data-async]', function(event) {
|
|
var $form = $(this);
|
|
$.ajax({
|
|
type: $form.attr('method'),
|
|
url: $form.attr('action'),
|
|
data: $form.serialize(),
|
|
dataType: 'json',
|
|
success: function(data, status) {
|
|
parsedata(data);
|
|
$('#loginModal').modal('hide');
|
|
$('#passwordModal').modal('hide');
|
|
$('#newUserModal').modal('hide');
|
|
}
|
|
});
|
|
$form.find('input:password').val('');
|
|
event.preventDefault();
|
|
});
|
|
});
|
|
get('user.php');
|
|
});
|
|
|
|
</script>
|
|
<link href="/css/bootstrap.css" rel="stylesheet" media="screen">
|
|
<style type="text/css">
|
|
form.form-modal{
|
|
margin-bottom: 0px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container" class="container">
|
|
<div class="navbar">
|
|
<div class="navbar-inner">
|
|
<a class="brand" href="/">Lilik User</a>
|
|
<ul class="nav">
|
|
<li class="active"><a href="#">Home</a></li>
|
|
<li><a href="#newUserModal" data-toggle="modal">Crea utente</a></li>
|
|
<li><a href="javascript:get('/user.php?logout')">Logout</a></li>
|
|
</ul>
|
|
<form id="search-form" class="navbar-search pull-right">
|
|
<input id="search-user" type="text" class="search-query" placeholder="Cerca">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="alerts"></div>
|
|
<div id="content"></div>
|
|
|
|
|
|
<div id="newUserModal" class="modal hide fade">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h3>Crea utente</h3>
|
|
</div>
|
|
<form data-async action="user.php" method="POST" id="newUserForm" class="form-horizontal form-modal">
|
|
<div class="modal-body">
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputUsername">Username</label>
|
|
<div class="controls">
|
|
<input type="text" id="inputUsername" placeholder="username" name="new_username">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputName">Nome</label>
|
|
<div class="controls">
|
|
<input type="text" id="inputName" placeholder="name" name="new_name">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputSurname">Cognome</label>
|
|
<div class="controls">
|
|
<input type="text" id="inputSurname" placeholder="surname" name="new_surname">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputPassword">Password</label>
|
|
<div class="controls">
|
|
<input type="password" id="inputPassword" placeholder="password" name="new_passwd">
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" name="new_user" value="true">
|
|
</div>
|
|
<div class="modal-footer">
|
|
<a href="#" class="btn" data-toggle="modal" data-target="#newUserModal">Chiudi</a>
|
|
<button type="submit" class="btn btn-primary">Salva</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div id="passwordModal" class="modal hide fade">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h3>Cambia password</h3>
|
|
</div>
|
|
<form data-async action="user.php" method="POST" class="form-horizontal form-modal">
|
|
<div class="modal-body">
|
|
<div class="control-group" id="old_password" >
|
|
<label class="control-label" for="inputOldPassword">Password attuale</label>
|
|
<div class="controls">
|
|
<input type="text" id="inputOldPassword" placeholder="old password" name="old_password">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputPassword">Password</label>
|
|
<div class="controls">
|
|
<input type="password" id="inputPassword" placeholder="new password" name="new_password">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputPassword2">Reimmetti password</label>
|
|
<div class="controls">
|
|
<input type="password" id="inputPassword2" placeholder="new password" name="new_password2">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<a href="#" class="btn" data-toggle="modal" data-target="#passwordModal">Chiudi</a>
|
|
<button type="submit" class="btn btn-primary">Salva</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div id="loginModal" class="modal hide fade">
|
|
<div class="modal-header">
|
|
<h3>Login</h3>
|
|
</div>
|
|
<form data-async action="user.php" method="POST" class="form-horizontal form-modal">
|
|
<div class="modal-body">
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputUsername">Username</label>
|
|
<div class="controls">
|
|
<input type="text" id="inputUsername" placeholder="username" name="username">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label" for="inputPassword">Password</label>
|
|
<div class="controls">
|
|
<input type="password" id="inputPassword" placeholder="password" name="password">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="submit" class="btn btn-primary">Login</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|