Index: controlies/trunk/applications/controlies/controllers/usuarios.py
===================================================================
--- controlies/trunk/applications/controlies/controllers/usuarios.py	(revision 231)
+++ controlies/trunk/applications/controlies/controllers/usuarios.py	(revision 232)
@@ -52,6 +52,7 @@
 @service.json
 @auth.requires_login()    
 def modify_user():
+
     l=conecta() 
     departments=[]
     classrooms=[]                
@@ -62,12 +63,41 @@
     response = u.process(request.vars['action'])
     l.close()
     return dict(response = response)    
+    #return dict(response = "OK")        
+
+@service.json
+@auth.requires_login()   
+def create_home_directory():
+    from applications.controlies.modules.SSHConnection import SSHConnection
+
+    c = SSHConnection(request.vars['host'],request.vars['user'],request.vars['password'])
+    response = c.process()
     
-      
+    if response != True:
+		return dict(response = response)
 
+    l=conecta()
+    u = Users(l,"","","","",request.vars['username'],"","","","")
+    responseUser = u.getUserData()
+    l.close()
+
+    if request.vars['type'] == "teacher":
+		homeDirectory = "/home/profesor/"+responseUser["user"]
+    else:
+		homeDirectory = "/home/alumnos/"+responseUser["user"]
+			
+    c.exec_command("cp -r /etc/skel "+homeDirectory)
+    c.exec_command("chown -R "+responseUser["uidnumber"]+":"+responseUser["gidnumber"]+" "+homeDirectory)
+    c.close()
+
+    return dict(response = "OK")       
+    
 def form():
     return dict()
-    
+
+def form_home_directory():
+    return dict()
+
 def call():
     """
     exposes services. for example:
Index: controlies/trunk/applications/controlies/modules/SSHConnection.py
===================================================================
--- controlies/trunk/applications/controlies/modules/SSHConnection.py	(nonexistent)
+++ controlies/trunk/applications/controlies/modules/SSHConnection.py	(revision 232)
@@ -0,0 +1,91 @@
+##############################################################################
+# -*- coding: utf-8 -*-
+# Project:     ControlIES
+# Module:      SSHConnection.py
+# Purpose:     Connection with ssh protocol
+# Language:    Python 2.5
+# Date:        17-Oct-2011.
+# Ver:         17-Oct-2011.
+# Author:      Manuel Mora Gordillo
+# Copyright:   2011 - Manuel Mora Gordillo <manuito @no-spam@ gmail.com>
+#
+# ControlIES is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# ControlIES 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 ControlAula. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import paramiko   
+    
+class SSHConnection(object):
+	
+    connection = ""
+    channel = ""
+ 
+    def __init__(self,session):
+        pass
+
+    def __init__(self,host,user,passwd):
+        self.host = host
+        self.user = user
+        self.passwd = passwd
+        self.port = 22
+
+        
+    def validation(self):
+        if self.host == "":
+            return "host"
+
+        if self.user == "":
+            return "user"
+
+        if self.passwd == "":
+            return "password"
+
+        return "OK"
+
+    def process(self):
+        val = self.validation()
+            
+        if val != "OK":
+            return val
+
+        auth = self.connect()
+        return auth
+
+    def connect(self):
+        try:
+            self.connection = paramiko.Transport((self.host, self.port))
+        except:
+            return "failServer"
+            
+        try:
+            self.connection.connect(username = self.user, password = self.passwd)
+        except:
+            return "failAuth"
+            			        
+        return True        
+
+    def exec_command(self,command):
+        self.channel = self.connection.open_session()		
+        self.channel.exec_command(command)
+
+        """salida = self.channel.makefile('rb', -1).readlines()
+        if salida:
+            # Si ha ido todo bien mostramos el listado de directorios
+            print salida
+        else:
+            # Si se ha producido algún error lo mostramos
+            print self.channel.makefile_stderr('rb', -1).readlines()"""
+        
+    def close(self):
+        self.connection.close()
+        
+
Index: controlies/trunk/applications/controlies/modules/Users.py
===================================================================
--- controlies/trunk/applications/controlies/modules/Users.py	(revision 231)
+++ controlies/trunk/applications/controlies/modules/Users.py	(revision 232)
@@ -403,10 +403,10 @@
         
     def getUserData(self):
         self.getUserGroups()
-        result = self.ldap.search("ou=People","uid="+self.user,["uid","cn","sn","employeenumber","homedirectory","jpegPhoto"])
+        result = self.ldap.search("ou=People","uid="+self.user,["uid","cn","sn","employeenumber","homedirectory","uidnumber","gidnumber","jpegPhoto"])
         
         if len(result) == 0:
-            return { "user":"", "name":"", "surname":"", "nif":"", "photo":"", "type":"", "groups":[] }
+            return { "user":"", "name":"", "surname":"", "nif":"", "photo":"", "type":"","uidnumber":"","gidnumber":"", "groups":[] }
         
         type = "student"
         if result[0][0][1]["homeDirectory"][0][0:14]=="/home/profesor":
@@ -423,6 +423,8 @@
             "name":userdata["cn"][0],
             "surname":userdata["sn"][0],
             "nif":userdata["employeeNumber"][0],
+            "uidnumber":userdata["uidNumber"][0],
+            "gidnumber":userdata["gidNumber"][0],
             "photo":photo,
             "type":type,
             "groups":self.getUserGroups()
Index: controlies/trunk/applications/controlies/views/usuarios/form.html
===================================================================
--- controlies/trunk/applications/controlies/views/usuarios/form.html	(revision 231)
+++ controlies/trunk/applications/controlies/views/usuarios/form.html	(revision 232)
@@ -16,14 +16,19 @@
     function send(){
 
         restartStyle();
-
         jQuery.post('call/json/modify_user', jQuery("#form_data").serialize(), function(result) {
             //var result = $.parseJSON(data);
             switch(result.response){
                 case "OK":{
                     jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
-                    setTimeout("$('#dialog-form').dialog('close')",1000);
-                    jQuery("#list").trigger("reloadGrid");
+                    
+					if(jQuery("#form_data #action").val()=="add" && jQuery("#form_data #homeDirectory").is(':checked'))
+						setTimeout("createHomeDirectory('"+jQuery("#form_data #user").val()+"','"+jQuery("#form_data #type").val()+"')",500);
+					else{
+						setTimeout("$('#dialog-form').dialog('close')",1000);
+						jQuery("#list").trigger("reloadGrid");
+						//setTimeout("createHomeDirectory()",1000);
+					}
                     break;
                 }
                 case "fail":{
@@ -53,7 +58,7 @@
 
         return false;
     }
-    
+
     function searchUsername(){
         if(jQuery("#form_data #action").val()=="add")
             jQuery.post('call/json/searchUsername','name='+jQuery("#form_data #name").val()+'&surname='+jQuery("#form_data #surname").val(), function(data) {
@@ -86,6 +91,7 @@
             <p><span id="userTag">Usuario</span><br><input type="text" id="user" name="user"/></p>
             <p><span id="passwordTag">Contraseña</span><br><input type="text" id="password" name="password"/></p>
             <p><span id="password2Tag">Repita Contraseña</span><br><input type="text" id="password2" name="password2"/></p>
+            <p id="homeDirectoryP" style="display:none;"><span id="homeDirectoryTag">Crear directorio personal</span>&nbsp;&nbsp;<input type="checkbox" id="homeDirectory" name="homeDirectory"/></p>            
         </div>
     </div>
     <div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
@@ -92,3 +98,5 @@
     <div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button>&nbsp;&nbsp;<button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
     <p style="padding-top:10px; text-align:center; font-size:10px;" id="messageForm"></p>       
 </form>
+
+<div id="dialog-form-home-directory"></div>
Index: controlies/trunk/applications/controlies/views/usuarios/index.html
===================================================================
--- controlies/trunk/applications/controlies/views/usuarios/index.html	(revision 231)
+++ controlies/trunk/applications/controlies/views/usuarios/index.html	(revision 232)
@@ -125,13 +125,15 @@
     
             jQuery("#messageLoading").show();
         
-            jQuery("#dialog-form").html("").css("display","none");;
+            jQuery("#dialog-form").html("").css("display","none");
             jQuery("#dialog-form").load("form.html", function() {
                 getAllGroups();
                 jQuery("#form_data #action").val("add");
+                jQuery("#form_data #homeDirectoryP").css("display","block");
+                
                 jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");                                     
         
-                x = (jQuery(window).width()-300)/2;
+                x = (jQuery(window).width()-350)/2;
                 y = (jQuery(window).height()-500)/2;
         
                 jQuery("#messageLoading").hide();
@@ -140,7 +142,7 @@
                     resizable: false,
                     position: top,
                     modal: true,
-                    width: 300,                     
+                    width: 350,
                     title: "Añadir Usuario"
                 }).dialog('option', 'position', [x, y]);
             });
@@ -191,7 +193,7 @@
                                 jQuery('#form_data input:checkbox[value='+l+']').attr('checked', true);                          
                             });                     
     
-                            x = (jQuery(window).width()-300)/2;
+                            x = (jQuery(window).width()-350)/2;
                             y = (jQuery(window).height()-500)/2;
                             
                             jQuery("#messageLoading").hide();
@@ -199,7 +201,7 @@
                             jQuery("#dialog-form").dialog({
                                 resizable: false,
                                 modal: true,
-                                width: 300,
+                                width: 350,
                                 title: "Modificar Usuario"
                             }).dialog('option', 'position', [x, y]);                        
                         });               
@@ -245,7 +247,29 @@
                 jQuery("#form_data #classrooms").multiselect();                       
             });             
     }
-    
+
+	function createHomeDirectory(username,type){
+        if(jQuery("#form_data #action").val()=="add"){
+			if(jQuery("#form_data #homeDirectory").is(':checked')){
+				
+				jQuery("#dialog-form").load("form_home_directory.html", function() {
+					jQuery("#form_data #username").val(username);
+					jQuery("#form_data #type").val(type);					
+					x = (jQuery(window).width()-300)/2;
+					y = (jQuery(window).height()-500)/2;			
+			
+					jQuery("#dialog-form").dialog({
+						resizable: false,
+						position: top,
+						modal: true,
+						width: 300,
+						title: "Crear Directorio Personal"
+					}).dialog('option', 'position', [x, y]);
+				});
+			}
+		}
+	}
+
 </script>
 
 
Index: controlies/trunk/applications/controlies/views/usuarios/form_home_directory.html
===================================================================
--- controlies/trunk/applications/controlies/views/usuarios/form_home_directory.html	(nonexistent)
+++ controlies/trunk/applications/controlies/views/usuarios/form_home_directory.html	(revision 232)
@@ -0,0 +1,76 @@
+<script language="javascript">
+
+    $(function() {
+        $("#password").focus();
+        $("#saveButton").button({ icons: { primary: "ui-icon-disk"}});
+        $("#cancelButton")
+            .button({ icons: { primary: "ui-icon-close"}})
+            .click( function(){ $('#dialog-form').dialog('close'); });
+    });
+
+    function restartStyle(){
+        $("#form_data p span").css("color","black");
+        $('#message').html("");
+    }
+
+    function send(){
+
+        restartStyle();
+        jQuery.post('call/json/create_home_directory', jQuery("#form_data").serialize(), function(result) {
+            //var result = $.parseJSON(data);
+            switch(result.response){
+                case "OK":{
+                    jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
+                    setTimeout("$('#dialog-form').dialog('close')",1000);
+                    jQuery("#list").trigger("reloadGrid");
+                    createHomeDirectory();
+                    break;
+                }
+                case "failServer":{
+                    jQuery('#message').html("Falló la conexión con el servidor").effect("highlight", {"color":"yellow"}, 1000);
+                    break;
+                }
+                case "failAuth":{
+                    jQuery('#message').html("Falló la autenticación").effect("highlight", {"color":"yellow"}, 1000);
+                    break;
+                }                
+                default:{
+                    jQuery('#'+result.response+"Tag").css("color","red");
+                    jQuery('#'+result.response).effect("highlight", {"color":"yellow"}, 1000).focus();
+                    jQuery('#message').html("Hay campos vacíos o incorrectos").effect("slide");
+                    break;
+                }
+            }
+        });
+
+        return false;
+    }
+
+	function createHomeDirectory(){
+        if(jQuery("#form_data #action").val()=="add"){
+			if(jQuery("#form_data #homeDirectory").is(':checked')){
+				jQuery.post('call/json/searchUsername','name='+jQuery("#form_data #name").val()+'&surname='+jQuery("#form_data #surname").val(), function(data) {
+					//var result = $.parseJSON(data);
+					jQuery("#form_data #user").val(result.response);
+				});
+			}
+		}
+	}
+
+</script>
+ 
+<form id="form_data" onsubmit="return send();">
+    <input type="hidden" id="action" name="action"/>
+    <input type="hidden" id="username" name="username"/>    
+    <input type="hidden" id="type" name="type"/>     
+    <div>
+        <div>
+            <p><span id="hostTag">Servidor NFS</span><br><input type="text" id="host" name="host" value="servidor"/></p>                    
+            <p><span id="userTag">Usuario</span><br><input type="text" id="user" name="user" value="root"/></p>
+            <p><span id="passwordTag">Contraseña</span><br><input type="text" id="password" name="password"/></p>
+        </div>
+    </div>
+    <div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
+    <div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button>&nbsp;&nbsp;<button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
+    <p style="padding-top:10px; text-align:center; font-size:10px;" id="messageForm"></p>       
+</form>
