Esempio n. 1
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     // Set some initial user values
     $user->set('id', 0);
     $user->set('usertype', '');
     $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     $date =& JFactory::getDate();
     $user->set('registerDate', $date->toMySQL());
     // If user activation is turned on, we need to set the activation information
     $useractivation = $usersConfig->get('useractivation');
     if ($useractivation == '1') {
         jimport('joomla.user.helper');
         $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
         $user->set('block', '1');
     }
     // If there was an error with registration, set the message and display form
     if (!$user->save()) {
         JError::raiseWarning('', JText::_($user->getError()));
         $this->register();
         return false;
     }
     // Send registration confirmation mail
     $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     UserController::_sendMail($user, $password);
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == 1) {
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     $this->setRedirect('index.php', $message);
 }
Esempio n. 2
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('SYSTEM_TOKEN_INVALID'));
     $providerid = JRequest::getInt('providerid', '0', 'method');
     $externalid = JRequest::getVar('externalid', '', 'method', 'string');
     $aliasemail = JRequest::getVar('email', '', 'method', 'string');
     $label = JRequest::getVar('label', '', 'method', 'string');
     $force = JRequest::getInt('force', '0', 'method');
     $zonalId = JRequest::getInt('zonal', UserHelper::ZONAL_NOT_DEFINED, 'method');
     $email2 = JRequest::getString('email2', '', 'method');
     $birthday = JRequest::getString('birthdate', '', 'method');
     $sex = JRequest::getString('sex', 'M', 'method');
     $username = JRequest::getString('usernamer', '', 'method');
     if ($zonalId == UserHelper::ZONAL_NOT_DEFINED) {
         $notZonalMessage = JText::_('SYSTEM_ZONAL_NOT_DEFINED');
         $baseUrl = "option=com_user&view=register&map=0";
         UserHelper::showMessage(ERROR, $notZonalMessage, $baseUrl);
         return;
     }
     $db =& JFactory::getDBO();
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     $userClone = clone $user;
     $useractivation = (int) $usersConfig->get('useractivation');
     //$block = ($useractivation == 1) ? '1' : '0';
     $block = $useractivation;
     $userid = $this->getUserId($db, $user);
     $userExists = $this->userExists($db, $user);
     $requestNewAlias = true;
     if ($userExists) {
         $message = JText::_('SYSTEM_MESSAGE_ERROR_USER_EXISTS');
         UserHelper::showMessage(ERROR, $message);
     }
     if (!$userExists || $force == 1) {
         $password = JRequest::getString('passwordt', '', 'post', JREQUEST_ALLOWRAW);
         $username = JRequest::getString('usernamer', '', 'method');
         // if ($password == '' && $externalid != '' && $providerid != 0){
         if ($password == '') {
             $password = JUserHelper::genRandomPassword();
             $block = '0';
         }
         // Set some initial user values
         $user->set('id', 0);
         $user->set('usertype', '');
         $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
         $date =& JFactory::getDate();
         $user->set('registerDate', $date->toMySQL());
         $user->set('password', md5($password));
         $user->set('username', $username);
         // If user activation is turned on, we need to set the activation information
         if ($useractivation == '1') {
             jimport('joomla.user.helper');
             $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
             $user->set('block', $block);
         }
         // If there was an error with registration, set the message and display form
         if (!$user->save()) {
             JError::raiseWarning('', JText::_($user->getError()));
             $message = JText::_('SYSTEM_MESSAGE_ERROR_REGISTER');
             UserHelper::showMessage(ERROR, $message);
             return false;
         }
         $userid = $this->getRUserId($db, $user->get('username'));
         $userExists = true;
         // registramos los datos extras en la tabla de com_aapu
         // pbtenemos el id del atributo sexo
         $atributesModel = new AapuModelAttributes();
         $atributesModel->setWhere("a.name='sex'");
         $sexData = $atributesModel->getData(true, true);
         $sexId = $sexData->id;
         // obtenemos el id del atributo birthday
         $atributesModel->setWhere("a.name='birthday'");
         $birthdayData = $atributesModel->getData(true, true);
         $birthdayId = $birthdayData->id;
         // obtenemos el id del atributo zonal
         $atributesModel->setWhere("a.name='zonal'");
         $zonalData = $atributesModel->getData(true, true);
         $zonaId = $zonalData->id;
         $atributesModel->setWhere("a.name='email2'");
         $emailData = $atributesModel->getData(true, true);
         $emailId = $emailData->id;
         $dataSex = array('value' => $sex, 'object_id' => $userid, 'object_type' => 'TABLE', 'object_name' => '#__users', 'attribute_id' => $sexId);
         $dataBirthday = array('value_date' => $birthday, 'object_id' => $userid, 'object_type' => 'TABLE', 'object_name' => '#__users', 'attribute_id' => $birthdayId);
         $dataZonal = array('value_int' => $zonalId, 'object_id' => $userid, 'object_type' => 'TABLE', 'object_name' => '#__users', 'attribute_id' => $zonaId);
         $dataEmail2 = array('value' => $email2, 'object_id' => $userid, 'object_type' => 'TABLE', 'object_name' => '#__users', 'attribute_id' => $emailId);
         $attributesEntityModel = new AapuModelAttribute_entity();
         // If there was an error with registration, set the message and display form
         if (!$attributesEntityModel->store(false, false, $dataSex) || !$attributesEntityModel->store(false, false, $dataBirthday) || !$attributesEntityModel->store(false, false, $dataZonal) || !$attributesEntityModel->store(false, false, $dataEmail2)) {
             JError::raiseWarning('', JText::_($user->getError()));
             $message = JText::_('SYSTEM_MESSAGE_ERROR_REGISTER');
             UserHelper::showMessage(ERROR, $message);
             return false;
         }
         // Send registration confirmation mail
         $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
         //Disallow control chars in the email
         UserController::_sendMail($user, $password);
     }
     ######### agregado por G2P ##############
     ##### testing ##########
     if ($userExists && $externalid != '' && $providerid != 0) {
         // hay que agregar un alias
         // $userid = $this->getUserId($db, $user);
         try {
             $externalid = urldecode($externalid);
             $this->insertAlias($block, $userid, $externalid, $user->get('providerid'), $label, $aliasemail);
             $requestNewAlias = false;
             // Send registration confirmation mail
             $selectpass = '******' . $userid;
             $db->setQuery($selectpass);
             $dbpass = $db->loadObject();
             $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $dbpass->password);
             //Disallow control chars in the email
             $userClone->set('activation', $passphrase);
         } catch (Exception $ex) {
             $message = JText::_("SYSTEM_ALIAS_REGISTERED");
             UserHelper::showMessage(ERROR, $message);
         }
         //UserController::_sendMail($userClone, $password);
     } else {
         // tomo los valores especificos del proveedor externo
         $epProveedor = JRequest::getVar('selprovider', '', 'method', 'string');
         if ($epProveedor && $epProveedor != 'Zonales') {
             $epUserData = array();
             $epUserData['epusername'] = JRequest::getVar('epusername', '', 'method', 'string');
             $epUserData['epprovider'] = $epProveedor;
             $epUserData['userid'] = $userid;
             $this->login($epUserData);
         }
     }
     //$return = 'index.php' . ($requestNewAlias) ? '?option=com_alias&view=alias&userid=' . $userid .'&'. JUtility::getToken() . '=1' : '';
     ############## fin #####################
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == '1') {
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     $this->endAuthentication();
     // fin ------
     UserHelper::showMessage(SUCCESS, $message);
 }
Esempio n. 3
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $providerid = JRequest::getInt('providerid', '0', 'method');
     $externalid = JRequest::getVar('externalid', '', 'method', 'string');
     $force = JRequest::getInt('force', '0', 'method');
     $db =& JFactory::getDBO();
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     $userClone = clone $user;
     $useractivation = (int) $usersConfig->get('useractivation');
     $this->logme($db, 'user activation es: ' . $useractivation);
     //$block = ($useractivation == 1) ? '1' : '0';
     $block = $useractivation;
     $this->logme($db, 'fecha de nacimiento: ' . $user->get('birthdate'));
     $this->logme($db, 'nombre completo: ' . $user->get('name'));
     $this->logme($db, 'nombre de usuario: ' . $user->get('username'));
     $this->logme($db, 'email: ' . $user->get('email'));
     $this->logme($db, 'email2: ' . $user->get('email2'));
     $this->logme($db, 'sexo: ' . $user->get('sex'));
     $userid = $this->getUserId($db, $user);
     $userExists = $this->userExists($db, $user);
     $requestNewAlias = true;
     $this->logme($db, 'usuario existe: ' . $userExists);
     if (!$userExists || $force == 1) {
         $this->logme($db, 'no existe o force');
         $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
         // if ($password == '' && $externalid != '' && $providerid != 0){
         if ($password == '') {
             $password = JUserHelper::genRandomPassword();
             $block = '0';
         }
         // Set some initial user values
         $user->set('id', 0);
         $user->set('usertype', '');
         $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
         $date =& JFactory::getDate();
         $user->set('registerDate', $date->toMySQL());
         $user->set('password', md5($password));
         $this->logme($db, 'se va a chequear activacion');
         // If user activation is turned on, we need to set the activation information
         if ($useractivation == '1') {
             jimport('joomla.user.helper');
             $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
             $user->set('block', $block);
         }
         $this->logme($db, 'se lo va a guardar');
         // If there was an error with registration, set the message and display form
         if (!$user->save()) {
             $this->logme($db, 'no se lo pudo guardar');
             JError::raiseWarning('', JText::_($user->getError()));
             $this->register();
             return false;
         }
         $this->logme($db, 'se lo guardo exitosamente');
         $userid = $this->getUserId($db, $user);
         $userExists = true;
         // Send registration confirmation mail
         $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
         //Disallow control chars in the email
         UserController::_sendMail($user, $password);
     }
     $this->logme($db, 'por el alias');
     ######### agregado por G2P ##############
     ##### testing ##########
     $this->logme($db, 'el external id es: ' . $externalid);
     $this->logme($db, 'el provider id es: ' . $providerid);
     if ($userExists && $externalid != '' && $providerid != 0) {
         // hay que agregar un alias
         $this->logme($db, 'vamos a gregar un alias');
         // $userid = $this->getUserId($db, $user);
         $externalid = urldecode($externalid);
         $this->insertAlias($block, $userid, $externalid, $user->get('providerid'));
         $this->logme($db, 'alias agregado');
         $requestNewAlias = false;
         // Send registration confirmation mail
         $selectpass = '******' . $userid;
         $db->setQuery($selectpass);
         $dbpass = $db->loadObject();
         $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $dbpass->password);
         //Disallow control chars in the email
         $userClone->set('activation', $passphrase);
         //UserController::_sendMail($userClone, $password);
     }
     //$return = 'index.php' . ($requestNewAlias) ? '?option=com_alias&view=alias&userid=' . $userid .'&'. JUtility::getToken() . '=1' : '';
     ############## fin #####################
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == '1') {
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     // tomo los valores especificos del proveedor externo
     $epProveedor = JRequest::getVar('selprovider', '', 'method', 'string');
     if ($epProveedor != 'Zonales') {
         $epUserData = array();
         $epUserData['epusername'] = JRequest::getVar('epusername', '', 'method', 'string');
         $epUserData['epprovider'] = $epProveedor;
         $epUserData['userid'] = $userid;
         $this->login($epUserData);
     }
     $this->endAuthentication();
     // fin ------
     $this->setRedirect('index.php', $message);
 }
Esempio n. 4
0
 /**
  * Function to create a user of Joomla.
  *  
  * @param array  $params associated array 
  * @param string $mail email id for cms user
  *
  * @return uid if user exists, false otherwise
  * 
  * @access public
  * @static
  */
 static function createJoomlaUser(&$params, $mail)
 {
     $userParams =& JComponentHelper::getParams('com_users');
     // get the default usertype
     $userType = $userParams->get('new_usertype');
     if (!$usertype) {
         $usertype = 'Registered';
     }
     $acl =& JFactory::getACL();
     // Prepare the values for a new Joomla! user.
     $values = array();
     $values['name'] = trim($params['cms_name']);
     $values['username'] = trim($params['cms_name']);
     $values['password'] = $params['cms_pass'];
     $values['password2'] = $params['cms_confirm_pass'];
     $values['email'] = trim($params[$mail]);
     $values['gid'] = $acl->get_group_id('', $userType);
     $values['sendEmail'] = 1;
     $useractivation = $userParams->get('useractivation');
     if ($useractivation == 1) {
         jimport('joomla.user.helper');
         // block the User
         $values['block'] = 1;
         $values['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
     } else {
         // don't block the user
         $values['block'] = 0;
     }
     // Get an empty JUser instance.
     $user =& JUser::getInstance(0);
     $user->bind($values);
     // Store the Joomla! user.
     if (!$user->save()) {
         // Error can be accessed via $user->getError();
         return false;
     }
     //since civicrm don't have own tokens to use in user
     //activation email. we have to use com_user tokens, CRM-5809
     $lang =& JFactory::getLanguage();
     $lang->load('com_user');
     require_once 'components/com_user/controller.php';
     UserController::_sendMail($user, $user->password2);
     return $user->get('id');
 }
Esempio n. 5
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     $input = JFactory::getApplication()->input;
     global $mainframe;
     // Check for request forgeries
     JSession::checkToken() or jexit('Invalid Token');
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway = $mainframe->getPathway();
     $config = JFactory::getConfig();
     $authorize = JFactory::getACL();
     $document = JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig = JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('COM_CITRUSCART_ACCESS_FORBIDDEN'));
         return;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind($input->getArray($_POST), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     // Set some initial user values
     $user->set('id', 0);
     $user->set('usertype', $newUsertype);
     $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     $date = JFactory::getDate();
     $user->set('registerDate', $date->toSql());
     // If user activation is turned on, we need to set the activation information
     // $useractivation = $usersConfig->get( 'useractivation' );
     // We aren't using activation for Citruscart so the process isn't interrupted for the user
     //        if ($useractivation == '1')
     //        {
     //            jimport('joomla.user.helper');
     //            $user->set('activation', JApplication::getHash( JUserHelper::genRandomPassword()) );
     //            $user->set('block', '1');
     //        }
     // If there was an error with registration, set the message and display form
     if (!$user->save()) {
         JError::raiseWarning('', JText::_($user->getError()));
         $this->register();
         return false;
     }
     // Send registration confirmation mail
     $password = $input->getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     UserController::_sendMail($user, $password);
     // Everything went fine, set relevant message depending upon user activation state and display message
     //        if ( $useractivation == 1 ) {
     //            $message  = JText::_('COM_CITRUSCART_REG_COMPLETE_ACTIVATE');
     //        } else {
     //            $message = JText::_('COM_CITRUSCART_REG_COMPLETE');
     //        }
     $message = JText::_('COM_CITRUSCART_REG_COMPLETE');
     // if there is a return URL base64encoded, then redirect to there
     if ($return = $input->get('return', '', 'method', 'base64')) {
         $return = base64_decode($return);
         if (!JURI::isInternal($return)) {
             $return = '';
         }
     }
     if (!empty($return)) {
         $credentials = array();
         $credentials['username'] = $input->get('username', '', 'method', 'username');
         $credentials['password'] = $input->getString('password', '', 'post', JREQUEST_ALLOWRAW);
         $options = array();
         $options['remember'] = $input->getBool('remember', false);
         $options['return'] = $return;
         //preform the login action ?
         $success = $mainframe->login($credentials, $options);
         JFactory::getApplication()->redirect($return);
     }
     $this->setRedirect('index.php', $message);
 }
Esempio n. 6
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // do civicrm validation here
     require_once 'administrator/components/com_civicrm/civicrm.settings.php';
     require_once 'CRM/Core/Config.php';
     $civiConfig =& CRM_Core_Config::singleton();
     $civiConfig->formKeyDisable = true;
     require_once 'CRM/Core/BAO/UFGroup.php';
     $errors = CRM_Core_BAO_UFGroup::isValid(null, null, true);
     if (is_array($errors)) {
         $msg = null;
         foreach ($errors as $name => $error) {
             $msg .= "{$name}: {$error}<br/>";
         }
         JError::raiseWarning('', JText::_($msg));
         $this->register();
         return false;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     // Set some initial user values
     $user->set('id', 0);
     $user->set('usertype', '');
     $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     $date =& JFactory::getDate();
     $user->set('registerDate', $date->toMySQL());
     // If user activation is turned on, we need to set the activation information
     $useractivation = $usersConfig->get('useractivation');
     if ($useractivation == '1') {
         jimport('joomla.user.helper');
         $user->set('activation', md5(JUserHelper::genRandomPassword()));
         $user->set('block', '1');
     }
     // If there was an error with registration, set the message and display form
     if (!$user->save()) {
         JError::raiseWarning('', JText::_($user->getError()));
         $this->register();
         return false;
     }
     // Send registration confirmation mail
     $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     UserController::_sendMail($user, $password);
     // if this was a successful save, call civicrm code to save the contact
     if ($user->id) {
         require_once 'CRM/Core/BAO/UFMatch.php';
         CRM_Core_BAO_UFMatch::synchronize($user, true, 'Joomla', 'Individual');
         $userID = CRM_Core_BAO_UFMatch::getContactId($user->id);
         if ($userID) {
             require_once 'CRM/Core/BAO/UFGroup.php';
             CRM_Core_BAO_UFGroup::getEditHTML($userID, null, 2, true, false, null, false, 'Individual');
             $session =& CRM_Core_Session::singleton();
             $session->reset();
         }
     }
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == 1) {
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     //TODO :: this needs to be replace by raiseMessage
     JError::raiseNotice('', $message);
     $this->register();
 }