Example #1
0
 /**
  * @inheritDoc
  */
 public function createUser(&$params, $mail)
 {
     $baseDir = JPATH_SITE;
     require_once $baseDir . '/components/com_users/models/registration.php';
     $userParams = JComponentHelper::getParams('com_users');
     $model = new UsersModelRegistration();
     $ufID = NULL;
     // get the default usertype
     $userType = $userParams->get('new_usertype');
     if (!$userType) {
         $userType = 2;
     }
     if (isset($params['name'])) {
         $fullname = trim($params['name']);
     } elseif (isset($params['contactID'])) {
         $fullname = trim(CRM_Contact_BAO_Contact::displayName($params['contactID']));
     } else {
         $fullname = trim($params['cms_name']);
     }
     // Prepare the values for a new Joomla user.
     $values = array();
     $values['name'] = $fullname;
     $values['username'] = trim($params['cms_name']);
     $values['password1'] = $values['password2'] = $params['cms_pass'];
     $values['email1'] = $values['email2'] = trim($params[$mail]);
     $lang = JFactory::getLanguage();
     $lang->load('com_users', $baseDir);
     $register = $model->register($values);
     $ufID = JUserHelper::getUserId($values['username']);
     return $ufID;
 }
Example #2
0
 /**
  *  Funkce pro zaregistrování uživatele
  */
 public function registerUser($name, $username, $password, $email)
 {
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_users' . DS . 'models' . DS . 'registration.php';
     require_once JPATH_ROOT . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'component' . DS . 'helper.php';
     $usersModelRegistration = new UsersModelRegistration();
     jimport('joomla.mail.helper');
     jimport('joomla.user.helper');
     $data = array('username' => $username, 'name' => $name, 'email1' => $email, 'password1' => $password, 'password2' => $password, 'block' => 0, 'sendEmail' => 0, 'activation' => 0);
     $usersModelRegistration->register($data);
 }
Example #3
0
 /**
  * Create an useraccount based on the entered data
  *
  * @param array $data
  *
  * @return number|boolean|mixed
  */
 public static function saveRegistration($data)
 {
     //Need to load com_users language file
     $lang = JFactory::getLanguage();
     $tag = $lang->getTag();
     if (!$tag) {
         $tag = 'en-GB';
     }
     $lang->load('com_users', JPATH_ROOT, $tag);
     $data['name'] = $data['first_name'] . ' ' . $data['last_name'];
     $data['password'] = $data['password2'] = $data['password'] = $data['password1'];
     $data['email1'] = $data['email2'] = $data['email'];
     $sendActivationEmail = OSMembershipHelper::getConfigValue('send_activation_email');
     if ($sendActivationEmail) {
         require_once JPATH_ROOT . '/components/com_users/models/registration.php';
         $model = new UsersModelRegistration();
         $ret = $model->register($data);
     } else {
         $params = JComponentHelper::getParams('com_users');
         $useractivation = $params->get('useractivation');
         if ($useractivation == 1 || $useractivation == 2) {
             $data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
             $data['block'] = 1;
         }
         $data['groups'] = array();
         $data['groups'][] = $params->get('new_usertype', 2);
         $user = new JUser();
         if (!$user->bind($data)) {
             die(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
             return false;
         }
         // Store the data.
         if (!$user->save()) {
             die(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
             return false;
         }
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id')->from('#__users')->where('username='******'username']));
     //Need to get the user ID based on username
     $db->setQuery($query);
     return (int) $db->loadResult();
 }
 function register($from_cb = 0, $freeCourse = false)
 {
     global $Itemid, $JLMS_DB, $JLMS_CONFIG, $JLMS_SESSION, $version, $task, $my;
     $reg_success = false;
     $msg = '';
     $username = JRequest::getVar('username');
     $password = JRequest::getVar('password');
     $usersConfig =& JComponentHelper::getParams('com_users');
     $app =& JFactory::getApplication();
     if ($from_cb) {
         global $task;
         $task = 'saveregisters';
         $_REQUEST['task'] = 'saveregisters';
         $_GET['task'] = 'saveregisters';
         $_POST['task'] = 'saveregisters';
         JRequest::setVar('task', $task);
         ob_start();
         global $ueConfig;
         $_CB_joomla_adminpath = $JLMS_CONFIG->get('absolute_path') . "/administrator";
         $_CB_adminpath = $_CB_joomla_adminpath . "/components/com_comprofiler";
         include_once $_CB_adminpath . "/ue_config.php";
         if ($usersConfig->get('allowUserRegistration')) {
             $allowUserRegistration = true;
         } else {
             $allowUserRegistration = false;
         }
         // check if CB registration is allowed
         if (!$allowUserRegistration && (!isset($ueConfig['reg_admin_allowcbregistration']) || $ueConfig['reg_admin_allowcbregistration'] != '1') || $my->id) {
             $msg = _JLMS_REGISTRATION_DISABLED;
             $reg_success = false;
         } else {
             $existingUser = null;
             $query = "SELECT * " . "\n FROM #__users u " . "\n WHERE u.username = '******'";
             $JLMS_DB->setQuery($query);
             $existingUser = $JLMS_DB->loadObjectList();
             // new registration will be failed if user with such username is already exists.
             if (isset($existingUser[0])) {
                 $reg_success = false;
             }
             require_once JPATH_SITE . '/components/com_comprofiler/comprofiler.html.php';
             require_once JPATH_SITE . '/components/com_comprofiler/comprofiler.php';
             $msg = @ob_get_contents();
             $msg = str_replace('<br />', '**br**', $msg);
             $msg = str_replace('</div><div', '**br**', $msg);
             $msg = strip_tags($msg);
             $msg = str_replace('**br**', '<br />', $msg);
             $msg = trim($msg);
             if (substr($msg, 0, 6) == 'alert(') {
                 preg_match('`alert\\(\'(.*)\'\\);(.*)`isU', $msg, $matches2);
                 # <script...>(#our_content#)</script> areas
                 if (isset($matches2[1])) {
                     $msg = $matches2[1];
                 }
             }
             @ob_end_clean();
             $filter =& JFilterInput::getInstance();
             if ($filter->clean($msg) == $filter->clean(_UE_REG_COMPLETE)) {
                 $msg = '';
                 $reg_success = true;
             }
         }
     } else {
         if (JLMS_Jversion() == 2) {
             if (JLMS_J16version()) {
                 $lang =& JFactory::getLanguage();
                 $lang->load('com_users');
                 require_once JPATH_SITE . DS . 'components' . DS . 'com_users' . DS . 'models' . DS . 'registration.php';
                 // Create the controller
                 $model = new UsersModelRegistration();
                 $requestData = JRequest::getVar('jform', array(), 'post', 'array');
                 $username = $requestData['username'];
                 $password = $requestData['password1'];
                 JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms');
                 JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields');
                 $form = $model->getForm();
                 $return = $model->validate($form, $requestData);
                 // Save the data in the session.
                 if ($return === false) {
                     $errors = $model->getErrors();
                     // Push up to three validation messages out to the user.
                     for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
                         $msg .= '<br />' . $errors[$i];
                     }
                     $app->setUserState('users.registration.form.data', $requestData);
                 } else {
                     $return = $model->register($requestData);
                     if ($return === false) {
                         $msg .= '<br />' . JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError());
                         $app->setUserState('users.registration.form.data', $requestData);
                     }
                 }
                 if ($return === 'adminactivate') {
                     $reg_complete_activate_found = true;
                 } else {
                     if ($return === 'useractivate') {
                         $reg_complete_activate_found = true;
                     } else {
                         if ($return !== false) {
                             $reg_success = true;
                             $reg_complete_found = true;
                         }
                     }
                 }
             } else {
                 $lang =& JFactory::getLanguage();
                 $lang->load('com_user');
                 require_once JPATH_SITE . '/components/com_user/controller.php';
                 require_once JPATH_SITE . '/components/com_user/views/register/view.html.php';
                 // Create the controller
                 $controller = new UserController();
                 $controller->_basePath = JPATH_SITE . '/components/com_user';
                 ob_start();
                 $controller->execute('register_save');
                 ob_end_clean();
                 $t = JError::getError(true);
                 $reg_complete_found = false;
                 $reg_complete_activate_found = false;
                 // this variable is not used yet... for future
                 if (isset($t->message) && $t->message == JText::_('REG_COMPLETE')) {
                     $reg_success = true;
                     $reg_complete_found = true;
                 } elseif (isset($t->message) && $t->message == JText::_('REG_COMPLETE_ACTIVATE')) {
                     $reg_complete_activate_found = true;
                 } elseif (isset($controller->_message) && $controller->_message == JText::_('REG_COMPLETE')) {
                     $reg_success = true;
                     $reg_complete_found = true;
                 } elseif (isset($controller->_message) && $controller->_message == JText::_('REG_COMPLETE_ACTIVATE')) {
                     $reg_complete_activate_found = true;
                 }
             }
         }
     }
     $login_success = false;
     if ($reg_success) {
         $login_success = JLMS_UserSessions::doLogin($username, $password);
     }
     $app->set('_messageQueue', null);
     if ($reg_success && $login_success) {
         if ($freeCourse) {
             $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE . "<br />" . _JLMS_LOGIN_SUCCESS . "<br />" . _JLMS_SUBSCRIBE_CONTINUE;
         } else {
             $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE . "<br />" . _JLMS_LOGIN_SUCCESS . "<br />";
         }
     } elseif ($reg_success) {
         $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE;
     } else {
         if ($usersConfig->get('useractivation') && !$reg_success) {
             $msg .= '<br />' . _JLMS_REGISTRATION_ACTIVATION;
         }
     }
     return $msg;
 }
Example #5
0
 /**
  *  Funkce pro přidání nového uživatele do databáze
  */
 public function registerSkautisUser($skautisUserDetails, $skautisPersonDetails = null)
 {
     require_once JPATH_ROOT . '/components/com_users/models/registration.php';
     $db = $this->getDBO();
     //require_once JPATH_ROOT.'/libraries/joomla/application/component/helper.php';
     $usersModelRegistration = new UsersModelRegistration();
     jimport('joomla.mail.helper');
     jimport('joomla.user.helper');
     $password = $this->getSkautisUserPassword($skautisUserDetails);
     //kontrola, jestli není uživatel v některé z tabulek (např. jen změna uživatelského jména
     $db->setQuery('SELECT * FROM #__skautis_users WHERE id_skautis_user='******' LIMIT 1;');
     $skautISUsersRow = $db->loadObject();
     if (!empty($skautISUsersRow)) {
         //uživatel skautISu už se sem přihlašoval, ale s jiným jménem?
         $db->setQuery('SELECT id FROM #__users WHERE id=' . $db->quote($skautISUsersRow->id) . ' LIMIT 1;');
         $usersRow = $db->loadObject();
         if (!$usersRow) {
             //uživatel už neexistuje v tabulce uživatelů
             $db->setQuery('DELETE FROM #__skautis_users WHERE id=' . $db->quote($skautISUsersRow->id) . ' LIMIT 1;');
             $db->query();
         } else {
             $db->setQuery('UPDATE #__users SET username='******' WHERE id=' . $db->quote() . ' LIMIT 1;');
             $db->quote();
             return;
         }
     } else {
         $db->setQuery('SELECT id FROM #__users WHERE username='******' LIMIT 1;');
         $usersRow = $db->loadObject();
         if ($usersRow && is_object($usersRow)) {
             $db->setQuery('INSERT INTO #__skautis_users (id,id_skautis_user,id_person)VALUES(' . $db->quote($usersRow->id) . ',' . $db->quote(@$skautisUserDetails->ID) . ',' . $db->quote(@$skautisUserDetails->ID_Person) . ');');
             $db->query();
             return;
         }
     }
     //--kontrola, jestli není uživatel v některé z tabulek (např. jen změna uživatelského jména
     $email = $skautisUserDetails->UserName . '@skautis.XXX';
     $name = $skautisUserDetails->UserName;
     if ($skautisPersonDetails) {
         if (@$skautisPersonDetails->DisplayName != '') {
             $name = $skautisPersonDetails->DisplayName;
         }
         if ($this->checkEmail(@$skautisPersonDetails->Email)) {
             $email = $skautisPersonDetails->Email;
         }
     }
     $data = array('username' => $skautisUserDetails->UserName, 'name' => $name, 'email1' => $email, 'password1' => $password, 'password2' => $password, 'block' => 0, 'sendEmail' => 0, 'activation' => 0);
     $usersModelRegistration->register($data);
     //zaregistrování doplňujících informací
     $db->setQuery('SELECT id FROM #__users WHERE username='******' LIMIT 1;');
     $userRow = $db->loadObject();
     $db->setQuery('INSERT INTO #__skautis_users (id,id_skautis_user,id_person)VALUES(' . $db->quote($userRow->id) . ',' . $db->quote($skautisUserDetails->ID) . ',' . $db->quote($skautisUserDetails->ID_Person) . ');');
     $db->query();
 }
Example #6
0
<?php

/**
 * @package     Joomla.Site
 * @subpackage  com_users
 *
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
// DIRTY HACK //
require_once JPATH_SITE . '/components/com_users/models/login.php';
require_once JPATH_SITE . '/components/com_users/models/registration.php';
$ul = new UsersModelLogin();
$ur = new UsersModelRegistration();
$loginform = $ul->getForm();
$registrationform = $ur->getForm();
$baseLayoutPath = JPATH_ROOT . '/media/pagestreet/layouts';
$displayData = new stdClass();
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
?>
<div class="com_login">
	<div class="headdds">Anmelden |&nbsp;Registrieren</div>
	<div class="longline"></div>
	<img width="64" alt="53f60fcef9e528193c8c8bf5_lock2.png"
		 src="http://uploads.webflow.com/53d639404c2a19f91f1a2c29/53f60fcef9e528193c8c8bf5_lock2.png"
		 class="log-icon">
	<div class="row lpage">
		<div class="col-md-6 log">
			<div class="logwrap">