You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
8.9 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <?php $basedir="/~kaos/lilik-users/";?>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <script type="text/javascript" src="<?php $basedit?>/jquery-1.9.1.js"></script>
  6. <script type="text/javascript" src="<?php $basedit?>/js/bootstrap.js"></script>
  7. <script type="text/javascript">
  8. var service_hash={'admin':{'text':'Gestisci gli utenti del LILiK', 'href': 'http://login.lilik.it'},
  9. 'mail':{'text':'Controlla la tua casella @lilik.it', 'href': 'http://webmail.lilik.it'},
  10. 'ltsp':{'text':'Accedi ai client del LILiK'},
  11. 'users':{'text':'Hai un utente sulla macchina users', 'href': 'http://users.lilik.it'},
  12. 'wiki':{'text':'Modifica la wiki', 'href': 'http://wiki.lilik.it'},
  13. 'users_sites':{'text':'Hai un sito web sulla macchina users', 'href': 'http://users.lilik.it'},
  14. 'lilik.it':{'text':'Accedi con il tuo utente a lilik.it', 'href': 'http://www.lilik.it'},
  15. 'cloud':{'text':'Accedi alla piattaforma cloud', 'href': 'http://cloud.lilik.it'},
  16. 'projects':{'text':'Accedi al portale progetti', 'href': 'http://projects.lilik.it'},
  17. 'teambox':{'text':'Accedi a teambox', 'href': 'http://teambox.lilik.it'},
  18. 'im':{'text':'Usa la messaggistica istantanea', 'href': 'http://im.lilik.it'}
  19. };
  20. function parsedata(data){
  21. $('#content').text('');
  22. $('#alerts').text('');
  23. $('#services').text('');
  24. if (!data['loggedin']){
  25. $('#loginModal').modal('show');
  26. }
  27. if (data['admin']==true){
  28. $('#search-form').show();
  29. $('#old_password').hide()
  30. }else{
  31. $('#search-form').hide();
  32. $('#old_password').show()
  33. }
  34. if ('username' in data){
  35. $('#content').append($('<h2 class="">').text(data['username']));
  36. var cn=$('<h5>').text(data['cn']);
  37. if (data['admin']==true){
  38. cn=$('<input type="text" name="cn" placeholder="Nome completo" >').val(data['cn']);
  39. }
  40. $('#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'))));
  41. }
  42. ['error', 'info', 'success'].forEach(function(what){
  43. if (what in data){
  44. $('#alerts').append($('<div class="alert alert-block alert-'+what+'">').text(data[what]).fadeIn(700))
  45. }
  46. });
  47. if ('avaible_services' in data){
  48. services=data['services'];
  49. if (data['admin']==true){
  50. var fieldset=$('<fieldset>');
  51. $('#content').append(fieldset);
  52. data['avaible_services'].forEach(function(service){
  53. tmp=$('<label>');
  54. tmp=tmp.prepend($('<input name="services[]" type="checkbox" value="'+service+'" '+((services.indexOf(service)>=0)?'checked="true"':'')+'>'));
  55. tmp.append((service in service_hash)?service_hash[service]['text']:service);
  56. fieldset.append(tmp);
  57. });
  58. }else{
  59. $('#content').append($('<ul id="services">'));
  60. services.forEach(function(service){
  61. var tmp=$('<li>');
  62. tmp.text((service in service_hash && 'text' in service_hash[service])?service_hash[service]['text']:service);
  63. if (service in service_hash && 'href' in service_hash[service]){
  64. tmp.wrapInner($('<a target="_blank">').attr('href', service_hash[service]['href']));
  65. }
  66. $('#services').append(tmp);
  67. });
  68. }
  69. }
  70. if (data['admin']==true & data['exist']!=false & $('#content').text()!=''){
  71. $('#content').append($('<button type="submit" class="btn btn-primary">Salva</button>'));
  72. $('#content').wrapInner($('<form data-async action="user.php" method="POST">'));
  73. }
  74. }
  75. function get(url){
  76. $.getJSON(url).done(parsedata);
  77. }
  78. $(document).ready(function() {
  79. $("#search-user").change(function() {
  80. $("#search-form").attr("action", "<?php $basedit?>/users/" + $(this).val() + "/");
  81. });
  82. $("#inputUsername").change(function() {
  83. $("#newUserForm").attr("action", "<?php $basedit?>/users/" + $(this).val() + "/user.php");
  84. });
  85. jQuery(function($) {
  86. $("body").on('submit', 'form[data-async]', function(event) {
  87. var $form = $(this);
  88. $.ajax({
  89. type: $form.attr('method'),
  90. url: $form.attr('action'),
  91. data: $form.serialize(),
  92. dataType: 'json',
  93. success: function(data, status) {
  94. parsedata(data);
  95. $('#loginModal').modal('hide');
  96. $('#passwordModal').modal('hide');
  97. $('#newUserModal').modal('hide');
  98. }
  99. });
  100. $form.find('input:password').val('');
  101. event.preventDefault();
  102. });
  103. });
  104. get('user.php');
  105. });
  106. </script>
  107. <link href="/css/bootstrap.css" rel="stylesheet" media="screen">
  108. <style type="text/css">
  109. form.form-modal{
  110. margin-bottom: 0px;
  111. }
  112. </style>
  113. </head>
  114. <body>
  115. <div id="container" class="container">
  116. <div class="navbar">
  117. <div class="navbar-inner">
  118. <a class="brand" href="/">Lilik User</a>
  119. <ul class="nav">
  120. <li class="active"><a href="#">Home</a></li>
  121. <li><a href="#newUserModal" data-toggle="modal">Crea utente</a></li>
  122. <li><a href="javascript:get('/user.php?logout')">Logout</a></li>
  123. </ul>
  124. <form id="search-form" class="navbar-search pull-right">
  125. <input id="search-user" type="text" class="search-query" placeholder="Cerca">
  126. </form>
  127. </div>
  128. </div>
  129. <div id="alerts"></div>
  130. <div id="content"></div>
  131. <div id="newUserModal" class="modal hide fade">
  132. <div class="modal-header">
  133. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  134. <h3>Crea utente</h3>
  135. </div>
  136. <form data-async action="user.php" method="POST" id="newUserForm" class="form-horizontal form-modal">
  137. <div class="modal-body">
  138. <div class="control-group">
  139. <label class="control-label" for="inputUsername">Username</label>
  140. <div class="controls">
  141. <input type="text" id="inputUsername" placeholder="username" name="new_username">
  142. </div>
  143. </div>
  144. <div class="control-group">
  145. <label class="control-label" for="inputName">Nome</label>
  146. <div class="controls">
  147. <input type="text" id="inputName" placeholder="name" name="new_name">
  148. </div>
  149. </div>
  150. <div class="control-group">
  151. <label class="control-label" for="inputSurname">Cognome</label>
  152. <div class="controls">
  153. <input type="text" id="inputSurname" placeholder="surname" name="new_surname">
  154. </div>
  155. </div>
  156. <div class="control-group">
  157. <label class="control-label" for="inputPassword">Password</label>
  158. <div class="controls">
  159. <input type="password" id="inputPassword" placeholder="password" name="new_passwd">
  160. </div>
  161. </div>
  162. <input type="hidden" name="new_user" value="true">
  163. </div>
  164. <div class="modal-footer">
  165. <a href="#" class="btn" data-toggle="modal" data-target="#newUserModal">Chiudi</a>
  166. <button type="submit" class="btn btn-primary">Salva</button>
  167. </div>
  168. </form>
  169. </div>
  170. <div id="passwordModal" class="modal hide fade">
  171. <div class="modal-header">
  172. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  173. <h3>Cambia password</h3>
  174. </div>
  175. <form data-async action="user.php" method="POST" class="form-horizontal form-modal">
  176. <div class="modal-body">
  177. <div class="control-group" id="old_password" >
  178. <label class="control-label" for="inputOldPassword">Password attuale</label>
  179. <div class="controls">
  180. <input type="text" id="inputOldPassword" placeholder="old password" name="old_password">
  181. </div>
  182. </div>
  183. <div class="control-group">
  184. <label class="control-label" for="inputPassword">Password</label>
  185. <div class="controls">
  186. <input type="password" id="inputPassword" placeholder="new password" name="new_password">
  187. </div>
  188. </div>
  189. <div class="control-group">
  190. <label class="control-label" for="inputPassword2">Reimmetti password</label>
  191. <div class="controls">
  192. <input type="password" id="inputPassword2" placeholder="new password" name="new_password2">
  193. </div>
  194. </div>
  195. </div>
  196. <div class="modal-footer">
  197. <a href="#" class="btn" data-toggle="modal" data-target="#passwordModal">Chiudi</a>
  198. <button type="submit" class="btn btn-primary">Salva</button>
  199. </div>
  200. </form>
  201. </div>
  202. <div id="loginModal" class="modal hide fade">
  203. <div class="modal-header">
  204. <h3>Login</h3>
  205. </div>
  206. <form data-async action="user.php" method="POST" class="form-horizontal form-modal">
  207. <div class="modal-body">
  208. <div class="control-group">
  209. <label class="control-label" for="inputUsername">Username</label>
  210. <div class="controls">
  211. <input type="text" id="inputUsername" placeholder="username" name="username">
  212. </div>
  213. </div>
  214. <div class="control-group">
  215. <label class="control-label" for="inputPassword">Password</label>
  216. <div class="controls">
  217. <input type="password" id="inputPassword" placeholder="password" name="password">
  218. </div>
  219. </div>
  220. </div>
  221. <div class="modal-footer">
  222. <button type="submit" class="btn btn-primary">Login</button>
  223. </div>
  224. </form>
  225. </div>
  226. </div>
  227. </body>
  228. </html>