Exemplo n.º 1
0
 /**
  * Sends a password reset request confirmation to the
  * specified e-mail address with the specified token.
  *
  * @since	1.5
  * @param	string	An e-mail address
  * @param	string	An md5 hashed randomly generated string
  * @return	bool	True on success/false on failure
  */
 function _sendConfirmationMail($email, $token)
 {
     $config =& JFactory::getConfig();
     $uri =& JFactory::getURI();
     $url = JURI::base() . 'index.php?option=com_user&view=reset&layout=confirm&map=0';
     $sitename = $config->getValue('sitename');
     // Set the e-mail parameters
     $from = $config->getValue('mailfrom');
     $fromname = $config->getValue('fromname');
     $subject = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TITLE', $sitename);
     $body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $sitename, $token, $url);
     // Send the e-mail
     if (!JUtility::sendMail($from, $fromname, $email, $subject, $body)) {
         $message = JText::_('ERROR_SENDING_CONFIRMATION_EMAIL');
         $this->setError($message);
         UserHelper::showMessage(ERROR, $message);
         return false;
     }
     return true;
 }
Exemplo 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);
 }
Exemplo n.º 3
0
 /**
  * Sends a username reminder to the e-mail address
  * specified containing the specified username.
  *
  * @since	1.5
  * @param	string	A user's e-mail address
  * @param	string	A user's username
  * @return	bool	True on success/false on failure
  */
 function _sendReminderMail($email, $username)
 {
     $config =& JFactory::getConfig();
     $uri =& JFactory::getURI();
     $url = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_user&view=zlogin&map=0', false);
     $from = $config->getValue('mailfrom');
     $fromname = $config->getValue('fromname');
     $subject = JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename'));
     $body = JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $username, $url);
     if (!JUtility::sendMail($from, $fromname, $email, $subject, $body)) {
         $message = JText::_('ERROR_SENDING_REMINDER_EMAIL');
         $this->setError($message);
         UserHelper::showMessage(ERROR, $message);
         return false;
     }
     return true;
 }