/** * Create an administrator account * * @param array $params Database access data and other parameters * @param bool $silentMode Do not display any output during installing * * @return bool */ function doCreateAdminAccount(&$params, $silentMode = false) { global $error; $result = true; if ($silentMode) { ob_start(); } $login = get_magic_quotes_gpc() ? trim(stripslashes($params['login'])) : $params['login']; $password = get_magic_quotes_gpc() ? trim(stripslashes($params["password"])) : $params["password"]; if (empty($login) || empty($password)) { $result = false; $errorMsg = fatal_error(xtr('Login and password can\'t be empty.'), 'params', 'empty admin login or password'); } else { $password = md5($password); } $profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findByLogin($login); if (is_null($profile)) { // Register default admin account $profile = new \XLite\Model\Profile(); $profile->setLogin($login); echo xtr('Registering primary administrator profile...'); } else { // Account already exists echo xtr('Updating primary administrator profile...'); } // Add banner for Paypal express checkout on the admin dashboard if ('ru' !== XLITE_EDITION_LNG && class_exists('\\XLite\\Module\\CDev\\Paypal\\Main')) { $expressCheckout = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC); $expressCheckout->setSetting('email', $login); $expressCheckout->setEnabled(true); \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'CDev\\Paypal', 'name' => 'show_admin_welcome', 'value' => 'Y')); } $profile->setPassword($password); $profile->setAccessLevel(100); $profile->enable(); $role = \XLite\Core\Database::getRepo('XLite\\Model\\Role')->findOneRoot(); $profile->addRoles($role); $profile->create(); $role->addProfiles($profile); \XLite\Core\Database::getEM()->persist($role); \XLite\Core\Database::getEM()->flush(); if ($silentMode) { ob_end_clean(); } return $result; }
/** * Create missed LiteCommerce accounts * * @return void */ protected function createMissedLCAccounts() { foreach ($this->drupalAccounts as $k => $account) { if ($this->checkUserAccountsPerStepCounter()) { $profile = new \XLite\Model\Profile(); $profile->setLogin($account->mail); $profile->setCmsProfileId($account->uid); $profile->setCmsName(\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getCMSName()); $profile->setStatus(1 === intval($account->status) ? 'E' : 'D'); $pass = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->generatePassword(); $profile->setPassword(md5($pass)); $user = user_load($account->uid); if (user_access(\XLite\Module\CDev\DrupalConnector\Drupal\Profile::LC_DRUPAL_ADMIN_ROLE_NAME, $user)) { $profile->setAccessLevel(\XLite\Core\Auth::getInstance()->getAdminAccessLevel()); } $profile->create(); unset($this->drupalAccounts[$k]); } else { break; } } }
/** * Create an administrator account * * @param array $params Database access data and other parameters * @param bool $silentMode Do not display any output during installing * * @return bool */ function doCreateAdminAccount(&$params, $silentMode = false) { global $error; $result = true; if ($silentMode) { ob_start(); } $login = get_magic_quotes_gpc() ? trim(stripslashes($params['login'])) : $params['login']; $password = get_magic_quotes_gpc() ? trim(stripslashes($params["password"])) : $params["password"]; if (empty($login) || empty($password)) { $result = false; $errorMsg = fatal_error(xtr('Login and password can\'t be empty.')); } else { $password = md5($password); } $profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findByLogin($login); if (is_null($profile)) { // Register default admin account $profile = new \XLite\Model\Profile(); $profile->setLogin($login); echo xtr('Registering primary administrator profile...'); } else { // Account already exists echo xtr('Updating primary administrator profile...'); } $profile->setPassword($password); $profile->setAccessLevel(100); $profile->enable(); $role = \XLite\Core\Database::getRepo('XLite\\Model\\Role')->findOneByName('Administrator'); $profile->addRoles($role); $profile->create(); $role->addProfiles($profile); \XLite\Core\Database::getEM()->persist($role); \XLite\Core\Database::getEM()->flush(); if ($silentMode) { ob_end_clean(); } return $result; }