Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » Joomla »

Que se cree una carpeta cuando un usuario se registre

Estas en el tema de Que se cree una carpeta cuando un usuario se registre en el foro de Joomla en Foros del Web. Bien, lo que quiero es que cuando un usuario nuevo se registre se cree un directorio con su nombre en mi servidor (porque para ciertas ...
  #1 (permalink)  
Antiguo 04/01/2012, 13:42
 
Fecha de Ingreso: septiembre-2011
Mensajes: 36
Antigüedad: 12 años, 7 meses
Puntos: 0
Que se cree una carpeta cuando un usuario se registre

Bien, lo que quiero es que cuando un usuario nuevo se registre se cree un directorio con su nombre en mi servidor (porque para ciertas funcionalidades que le estoy añadiendo a mi web lo voy a necesitar)

He ido a components/com_user/controllers/registration.php (joomla! 1.7.3)
y el problema es que no tengo ni idea de por donde empezar.
Os dejo aqui el código del registration.php: (aunque supongo que es el mismo para todos xD)

Código PHP:
<?php
/**
 * @version        $Id: registration.php 22355 2011-11-07 05:11:58Z github_bot $
 * @package        Joomla.Site
 * @subpackage    com_users
 * @copyright    Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

require_once 
JPATH_COMPONENT.'/controller.php';

/**
 * Registration controller class for Users.
 *
 * @package        Joomla.Site
 * @subpackage    com_users
 * @since        1.6
 */
class UsersControllerRegistration extends UsersController
{
    
/**
     * Method to activate a user.
     *
     * @return    boolean        True on success, false on failure.
     * @since    1.6
     */
    
public function activate()
    {
        
$user        JFactory::getUser();
        
$uParams    JComponentHelper::getParams('com_users');

        
// If the user is logged in, return them back to the homepage.
        
if ($user->get('id')) {
            
$this->setRedirect('index.php');
            return 
true;
        }

        
// If user registration or account activation is disabled, throw a 403.
        
if ($uParams->get('useractivation') == || $uParams->get('allowUserRegistration') == 0) {
            
JError::raiseError(403JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
            return 
false;
        }

        
$model $this->getModel('Registration''UsersModel');
        
$token JRequest::getVar('token'null'request''alnum');

        
// Check that the token is in a valid format.
        
if ($token === null || strlen($token) !== 32) {
            
JError::raiseError(403JText::_('JINVALID_TOKEN'));
            return 
false;
        }

        
// Attempt to activate the user.
        
$return $model->activate($token);

        
// Check for errors.
        
if ($return === false) {
            
// Redirect back to the homepage.
            
$this->setMessage(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'$model->getError()), 'warning');
            
$this->setRedirect('index.php');
            return 
false;
        }

        
$useractivation $uParams->get('useractivation');

        
// Redirect to the login screen.
        
if ($useractivation == 0)
        {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
        }
        elseif (
$useractivation == 1)
        {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_ACTIVATE_SUCCESS'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
        }
        elseif (
$return->getParam('activate'))
        {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_VERIFY_SUCCESS'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete'false));
        }
        else
        {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_ADMINACTIVATE_SUCCESS'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete'false));
        }
        return 
true;
    }

    
/**
     * Method to register a user.
     *
     * @return    boolean        True on success, false on failure.
     * @since    1.6
     */
    
public function register()
    {
        
// Check for request forgeries.
        
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

        
// If registration is disabled - Redirect to login page.
        
if(JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) {
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
            return 
false;
        }

        
// Initialise variables.
        
$app    JFactory::getApplication();
        
$model    $this->getModel('Registration''UsersModel');

        
// Get the user data.
        
$requestData JRequest::getVar('jform', array(), 'post''array');

        
// Validate the posted data.
        
$form    $model->getForm();
        if (!
$form) {
            
JError::raiseError(500$model->getError());
            return 
false;
        }
        
$data    $model->validate($form$requestData);

        
// Check for validation errors.
        
if ($data === false) {
            
// Get the validation messages.
            
$errors    $model->getErrors();

            
// Push up to three validation messages out to the user.
            
for ($i 0$n count($errors); $i $n && $i 3$i++) {
                if (
JError::isError($errors[$i])) {
                    
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
                } else {
                    
$app->enqueueMessage($errors[$i], 'warning');
                }
            }

            
// Save the data in the session.
            
$app->setUserState('com_users.registration.data'$requestData);

            
// Redirect back to the registration screen.
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration'false));
            return 
false;
        }

        
// Attempt to save the data.
        
$return    $model->register($data);

        
// Check for errors.
        
if ($return === false) {
            
// Save the data in the session.
            
$app->setUserState('com_users.registration.data'$data);

            
// Redirect back to the edit screen.
            
$this->setMessage(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'$model->getError()), 'warning');
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration'false));
            return 
false;
        }

        
// Flush the data from the session.
        
$app->setUserState('com_users.registration.data'null);

        
// Redirect to the profile screen.
        
if ($return === 'adminactivate'){
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete'false));
        } elseif (
$return === 'useractivate') {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete'false));
        } else {
            
$this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
            
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
        }


        return 
true;
    }
}
Gracias.
  #2 (permalink)  
Antiguo 05/01/2012, 02:43
Avatar de zulkas  
Fecha de Ingreso: julio-2011
Mensajes: 126
Antigüedad: 12 años, 9 meses
Puntos: 11
Respuesta: Que se cree una carpeta cuando un usuario se registre

Esto es codigo de creacion de una carpeta.

Código PHP:
  $folder[0][0] = 'images' DS 'carpetanueva' DS//para saber ruta relativa
  
$folder[0][1] = JPATH_ROOT DS $folder[0][0]; //ruta absoluta
 
  
foreach ($folder as $key => $value) {
    if (!
JFolder::exists($value[1])) {
      if (
JFolder::create($value[1], 0755)) {
            
//crecion correcta
      
} else {
            
//falla la creacion       
      
}
    } else {
             
//Carpeta ya existe
    
}
  } 
  #3 (permalink)  
Antiguo 05/01/2012, 03:21
 
Fecha de Ingreso: julio-2008
Ubicación: España
Mensajes: 92
Antigüedad: 15 años, 9 meses
Puntos: 6
Respuesta: Que se cree una carpeta cuando un usuario se registre

Yo lo consigo de forma automática, usando JCK Editor http://extensions.joomla.org/extensi...ion/editors/90

Suerte.
  #4 (permalink)  
Antiguo 05/01/2012, 09:08
 
Fecha de Ingreso: septiembre-2011
Mensajes: 36
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: Que se cree una carpeta cuando un usuario se registre

me he mirado lo del JCK edito, lo he instalado pero despues no se donde encontrar la opcion para hacer que se cree automaticamente una carpeta con el nombre de un usuario registrado.

respecto alo del código muchas gracias (yo estab usando otro pero mas o menos funcionaba) el problema es que no se en que parte del archivo colocarlo (ni siquiera si si es en este archivo en el que tengo que colocarlo)
  #5 (permalink)  
Antiguo 09/01/2012, 02:17
Avatar de zulkas  
Fecha de Ingreso: julio-2011
Mensajes: 126
Antigüedad: 12 años, 9 meses
Puntos: 11
Respuesta: Que se cree una carpeta cuando un usuario se registre

Yo lo pondría justo antes de la linea

Código PHP:
// Redirect to the profile screen. 
¿Por qué? pues ahí ya ha pasado todas las validaciones y también ha grabado correctamente.
  #6 (permalink)  
Antiguo 09/01/2012, 03:36
 
Fecha de Ingreso: julio-2008
Ubicación: España
Mensajes: 92
Antigüedad: 15 años, 9 meses
Puntos: 6
Respuesta: Que se cree una carpeta cuando un usuario se registre

Hola Kaspito

Extensiones / Gestor de plugins / Editor - JoomlaCK / Parámetros avanzados / Use User Folders (si)

Por supuesto, tenerlo activado y seleccionado como editor predefinido.

Saludos.

Etiquetas: directorio, mkdir, nombre, registro, regitration, usuarios, carpetas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:22.