PHP Method User::CreateUser, codiad Code Examples

This page contains top rated real world PHP examples of method User::CreateUser from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: processing.php Project: diedsmiling/busenika
0
             $account->MailOutPassword = $account->MailIncPassword;
             $account->MailOutHost = $settings->WmServerHost;
             $account->MailOutPort = $WMConsole->Settings->OutPort;
         }
         $WMConsole->Disconnect();
     } else {
         printErrorAndExit($WMConsole->GetError(), $xmlRes);
     }
 }
 $validate = $account->ValidateData();
 if ($validate !== true) {
     printErrorAndExit($validate, $xmlRes);
 } else {
     $processor =& new MailProcessor($account);
     if ($account->MailProtocol == MAILPROTOCOL_WMSERVER && $settings->WmAllowManageXMailAccounts || $processor->MailStorage->Connect(true)) {
         $user =& User::CreateUser();
         if ($user != null) {
             $account->IdUser = $user->Id;
         }
         $folderSync = FOLDERSYNC_AllEntireMessages;
         if ($account->MailProtocol == MAILPROTOCOL_IMAP4) {
             $folderSync = FOLDERSYNC_AllHeadersOnly;
         }
         $inboxSyncType = $settings->AllowDirectMode && $settings->DirectModeIsDefault ? FOLDERSYNC_DirectMode : $folderSync;
         if ($user != null && $user->CreateAccount($account, $inboxSyncType)) {
             $_SESSION[ACCOUNT_ID] = $account->Id;
             $_SESSION[USER_ID] = $account->IdUser;
             $_SESSION[SESSION_LANG] = $account->DefaultLanguage;
             $sendSettingsList = true;
         } else {
             if ($user != null) {
Example #2
Show file File: profiles.php Project: alexpagnoni/ampoliros
0
function pass_adduser($eventData)
{
    global $env, $amp_locale, $hui_mainstatus;
    if ($eventData['passworda'] == $eventData['passwordb']) {
        $temp_user = new User($env['ampdb'], $env['currentsiteserial']);
        $user_data['siteid'] = $env['currentsiteserial'];
        $user_data['groupid'] = $eventData['groupid'];
        $user_data['username'] = $eventData['username'] . ($GLOBALS['gEnv']['core']['edition'] == AMP_EDITION_ASP ? '@' . $env['currentsiteid'] : '');
        $user_data['password'] = $eventData['passworda'];
        $user_data['fname'] = $eventData['fname'];
        $user_data['lname'] = $eventData['lname'];
        $user_data['email'] = $eventData['email'];
        $user_data['otherdata'] = $eventData['other'];
        $temp_user->CreateUser($user_data);
    }
}
Example #3
Show file File: user_controller.php Project: apanly/meet-you
0
<?php

header("Access-Control-Allow-Origin:*");
require_once '../../public/config/config.php';
require_once '../../class/user.class.php';
$newUser = new User();
$controller = @$_GET['controller'];
switch ($controller) {
    case 'reg':
        echo $newUser->CreateUser($newUser);
        break;
    case 'login':
        echo $newUser->login();
        break;
    case 'logout':
        session_start();
        unset($_SESSION['user_id']);
        session_destroy();
        break;
    case 'upInfo':
        echo $newUser->SaveUser();
        break;
    case 'getInfo':
        if ($newUser->GetUserByID($newUser)) {
            echo json_encode($newUser->GetUserByID($newUser));
        } else {
            echo 0;
        }
        break;
    case 'add':
        $friendId = $_GET['friendId'];
Example #4
Show file File: UserManagement.php Project: name256/crm42
0
<?php 
// **********************Closes the Content Column and begins Info Column ****************************//
$page->printContentColumnEnd();
// **********************Start code for Info Column ****************************//
?>
<!--<div id="content_column_header">
	<h2>Invite a new user: </h2>
        <?php 
echo $user->invite_user_form_html();
?>
</div>-->

<div class="form_bg">
<div class="form_main">
<?php 
if ($_POST[submit] == 'add user') {
    $user->CreateUser('server');
} else {
    $user->CreateUser('local');
}
//$iU = $_POST["inviteUser"];
//if( $iU == "yes"){
//    $user_email = $_POST["email_id"];
//    $user->invite_users( array( array( "email" => $user_email )));
//}
?>
 
</div>
</div>
<?php 
$page->displayPageBottom();
Example #5
Show file File: mailadm.php Project: diedsmiling/busenika
0
             if (isset($_POST['fm_keep_for_x_days']) && (int) $_POST['fm_keep_for_x_days'] == 1) {
                 $mailmode = MAILMODE_KeepMessagesOnServer;
                 $p++;
             }
             if (isset($_POST['fm_delete_messages_from_trash']) && (int) $_POST['fm_delete_messages_from_trash'] == 1) {
                 $mailmode = MAILMODE_DeleteMessageWhenItsRemovedFromTrash;
                 $p++;
             }
             if ($p == 2) {
                 $mailmode = MAILMODE_KeepMessagesOnServerAndDeleteMessageWhenItsRemovedFromTrash;
             }
         }
     }
     $account->MailMode = $mailmode;
 }
 $user =& User::CreateUser($account);
 if (!$user) {
     $_SESSION['divmess'] = '<font color="red"><b>' . getGlobalError() . '</b></font>';
     $ref = 'mailadm.php?mode=wm_edit&uid=-1';
 } else {
     $account->IdUser = $user->Id;
     $account->DefaultAccount = true;
     $folderSync = FOLDERSYNC_AllEntireMessages;
     if ($account->MailProtocol == MAILPROTOCOL_IMAP4) {
         $folderSync = FOLDERSYNC_AllHeadersOnly;
     }
     $folderSync = $settings->AllowDirectMode && $settings->DirectModeIsDefault ? FOLDERSYNC_DirectMode : $folderSync;
     if (!$user->CreateAccount($account, $folderSync)) {
         User::DeleteUserSettings($user->Id);
         $_SESSION['divmess'] = '<font color="red"><b>' . getGlobalError() . '</b></font>';
         $ref = 'mailadm.php?mode=wm_edit&uid=-1';
Example #6
Show file File: class_login.php Project: JDevelopers/Mail
0
 /**
  * @param Settings $_settings
  * @param MySqlStorage $_dbStorage
  * @param CWebMailLoginInfo $loginInfo
  * @param Account $refAccount
  * @param string $errorString
  */
 function Init(&$_settings, &$_dbStorage, &$loginInfo, &$refAccount, &$errorString)
 {
     $accountCustomValues = array();
     $_log =& CLog::CreateInstance();
     $_isNoLoginField = false;
     $_sendSettingsList = false;
     /* custom class */
     wm_Custom::StaticUseMethod('ChangeLoginInfoBeforeInit', array(&$loginInfo));
     $_infoEmail = trim($loginInfo->getEmail());
     $_infoLogin = trim($loginInfo->getLogin());
     $_infoPassword = $loginInfo->getPassword();
     $_infoAdvancedLogin = $loginInfo->getAdvancedLogin();
     $_infoLang = trim($loginInfo->getLanguage());
     $_domain = $loginInfo->getDomainsSelectValue();
     $_email = $_login = $_optLogin = '';
     if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) {
         $_email = $_infoEmail;
         $_login = $_infoLogin;
     } else {
         switch ($_settings->HideLoginMode) {
             case 0:
                 $_email = $_infoEmail;
                 $_login = $_infoLogin;
                 break;
             case 10:
                 $_email = $_infoEmail;
                 $_isNoLoginField = true;
                 $_emailAddress = new EmailAddress();
                 $_emailAddress->SetAsString($_email);
                 $_optLogin = $_emailAddress->GetAccountName();
                 break;
             case 11:
                 $_email = $_infoEmail;
                 $_isNoLoginField = true;
                 $_optLogin = $_email;
                 break;
             case 20:
             case 21:
                 $_login = $_infoLogin;
                 $loginArray = ConvertUtils::ParseEmail($_login);
                 if (20 == $_settings->HideLoginMode) {
                     if (is_array($loginArray) && 2 === count($loginArray)) {
                         $_email = $_login;
                     } else {
                         $_email = $_login . '@';
                         $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional;
                     }
                 } else {
                     $_email = is_array($loginArray) && 2 === count($loginArray) ? $loginArray[0] . '@' : $_login . '@';
                     $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional;
                 }
                 break;
             case 22:
             case 23:
                 $loginArray = ConvertUtils::ParseEmail($_infoLogin);
                 $_login = is_array($loginArray) && isset($loginArray[0]) ? $loginArray[0] . '@' : $_infoLogin . '@';
                 $_login .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional;
                 $_email = $_login;
         }
     }
     /* custom class */
     wm_Custom::StaticUseMethod('ChangeLoginDuringInit', array(&$_login, &$_email));
     $bReturn = true;
     wm_Custom::StaticUseMethod('LdapCustomLoginFunction', array(&$_login, &$_email, &$_infoPassword, &$accountCustomValues, &$errorString, &$bReturn));
     if (!$bReturn) {
         return false;
     }
     $_loginArray = null;
     if (USE_DB) {
         if ($_isNoLoginField) {
             $_loginArray =& Account::LoadFromDbOnlyByEmail($_email);
             if (is_array($_loginArray) && count($_loginArray) > 3) {
                 $_eAccount =& Account::LoadFromDb((int) $_loginArray[0]);
                 if ($_eAccount) {
                     if ($_loginArray[5]) {
                         $errorString = 'Your account is inactive, please contact the system administrator on this.';
                         return false;
                     }
                     $_login = ConvertUtils::DecodePassword($_loginArray[1], $_eAccount) == $_infoPassword ? $_loginArray[4] : $_optLogin;
                 } else {
                     $_login = $_optLogin;
                 }
             } else {
                 $_login = $_optLogin;
             }
             /* custom class */
             wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email));
         } else {
             /* custom class */
             wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email));
             $_loginArray =& Account::LoadFromDbByLogin($_email, $_login);
             if ($_loginArray[4]) {
                 $errorString = 'Your account is inactive, please contact the system administrator on this.';
                 return false;
             }
         }
     }
     if (!$_dbStorage || !$_dbStorage->Connect()) {
         $_sendSettingsList = false;
         $errorString = getGlobalError();
         return false;
     }
     if ($_loginArray === false) {
         $errorString = getGlobalError();
         return false;
     } else {
         if ($_loginArray === null) {
             if ($_settings->AllowNewUsersRegister) {
                 if (!NumOLCallBackFunction($_settings, $_dbStorage, $errorString)) {
                     return false;
                 }
                 $_account = new Account();
                 $_account->DefaultAccount = true;
                 $_account->Email = $_email;
                 $_account->MailIncLogin = $_login;
                 $_account->MailIncPassword = $_infoPassword;
                 if (strlen($_infoLang) > 0) {
                     $_account->DefaultLanguage = $_infoLang;
                 }
                 $_account->CustomValues = $accountCustomValues;
                 if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) {
                     $_account->MailProtocol = $loginInfo->getMailProtocol();
                     $_account->MailIncPort = $loginInfo->getMailIncPort();
                     $_account->MailOutPort = $loginInfo->getMailOutPort();
                     $_account->MailOutAuthentication = $loginInfo->getMailOutAuth();
                     $_account->MailIncHost = $loginInfo->getMailIncHost();
                     $_account->MailOutHost = $loginInfo->getMailOutHost();
                 } else {
                     $_account->MailProtocol = (int) $_settings->IncomingMailProtocol;
                     $_account->MailIncPort = (int) $_settings->IncomingMailPort;
                     $_account->MailOutPort = (int) $_settings->OutgoingMailPort;
                     $_account->MailOutAuthentication = (bool) $_settings->ReqSmtpAuth;
                     $_account->MailIncHost = $_settings->IncomingMailServer;
                     $_account->MailOutHost = $_settings->OutgoingMailServer;
                 }
                 if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) {
                     $_account->MailIncPassword = DEMOACCOUNTPASS;
                 }
                 /* custom class */
                 wm_Custom::StaticUseMethod('InitLdapSettingsAccountOnLogin', array(&$_account));
                 if (0 < strlen($_infoLang)) {
                     $_account->DefaultLanguage = $_infoLang;
                 }
                 /* custom class */
                 wm_Custom::StaticUseMethod('ChangeAccountBeforeCreateOnLogin', array(&$_account));
                 if (USE_DB) {
                     $_domain =& $_dbStorage->SelectDomainByName(EmailAddress::GetDomainFromEmail($_account->Email));
                     if (null !== $_domain) {
                         $_domain->UpdateAccount($_account, $_settings);
                     }
                 }
                 $_validate = $_account->ValidateData();
                 if ($_validate !== true) {
                     $errorString = $_validate;
                     return false;
                 } else {
                     if ($_account->IsInternal) {
                         $errorString = ErrorPOP3IMAP4Auth;
                         $_log->WriteLine('LOGIN Error: IsInternal = true', LOG_LEVEL_WARNING);
                         return false;
                     }
                     $_processor = new MailProcessor($_account);
                     if ($_processor->MailStorage->Connect(true)) {
                         $_user =& User::CreateUser($_account);
                         if ($_user && $_account) {
                             if (!USE_DB) {
                                 $_account->Id = 1;
                             }
                             $_account->IdUser = $_user->Id;
                         }
                         $_inboxSyncType = $_account->GetDefaultFolderSync($_settings);
                         if ($_user != null && $_user->CreateAccount($_account, $_inboxSyncType, false, $_processor->MailStorage)) {
                             if ($_settings->EnableMobileSync && function_exists('mcrypt_encrypt')) {
                                 // create Funambol user for loginable user
                                 require_once WM_ROOTPATH . 'common/class_funambol_sync_users.php';
                                 $fnSyncUsers = new FunambolSyncUsers($_account);
                                 $fnSyncUsers->PerformSync();
                             }
                             $_SESSION[ACCOUNT_ID] = $_account->Id;
                             $_SESSION[USER_ID] = $_account->IdUser;
                             $_SESSION[SESSION_LANG] = $_account->DefaultLanguage;
                             $_sendSettingsList = true;
                             if (!USE_DB) {
                                 Account::SaveInSession($_account);
                             }
                             $_log->WriteEvent('User login', $_account);
                             self::AfterLoginAction($_account, $_processor, $_settings);
                         } else {
                             if ($_user) {
                                 User::DeleteUserSettings($_user->Id);
                             }
                             $_error = getGlobalError();
                             $_error = strlen($_error) > 0 ? $_error : CantCreateUser;
                             $errorString = $_error;
                             return false;
                         }
                     } else {
                         $errorString = getGlobalError();
                         return false;
                     }
                 }
             } else {
                 $_log->WriteLine('LOGIN Error: AllowNewUsersRegister = false', LOG_LEVEL_WARNING);
                 $errorString = ErrorPOP3IMAP4Auth;
                 return false;
             }
         } else {
             if ($_loginArray[2] == 0) {
                 $errorString = PROC_CANT_LOG_NONDEF;
                 return false;
             } else {
                 if (USE_DB) {
                     $_newAccount =& Account::LoadFromDb($_loginArray[0]);
                     if (!$_newAccount) {
                         $errorString = getGlobalError();
                         return false;
                     } else {
                         $_deleted = $_dbStorage->GetAUserDeleted($_newAccount->IdUser);
                         if (false === $_deleted) {
                             $errorString = getGlobalError();
                             return false;
                         } else {
                             if (1 === $_deleted) {
                                 $errorString = ErrorMaximumUsersLicenseIsExceeded;
                                 return false;
                             }
                         }
                         $_mailIncPass = $_infoPassword;
                         if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) {
                             $_mailIncPass = DEMOACCOUNTPASS;
                         }
                         $_useLangUpdate = false;
                         if (strlen($_infoLang) > 0 && $_newAccount->DefaultLanguage != $_infoLang) {
                             $_newAccount->DefaultLanguage = $_infoLang;
                             $_useLangUpdate = true;
                         }
                         $_account = null;
                         $bIsPasswordCorrect = ConvertUtils::DecodePassword($_loginArray[1], $_newAccount) == $_mailIncPass;
                         $_account =& $_newAccount;
                         $_account->MailIncPassword = $_mailIncPass;
                         $_newprocessor = new MailProcessor($_account);
                         if ($_newprocessor->MailStorage->Connect(true)) {
                             if (!$bIsPasswordCorrect && !$_account->Update()) {
                                 return ErrorPOP3IMAP4Auth;
                             }
                             $_SESSION[ACCOUNT_ID] = $_account->Id;
                             $_SESSION[USER_ID] = $_account->IdUser;
                             $_SESSION[SESSION_LANG] = $_account->DefaultLanguage;
                             $tempFiles =& CTempFiles::CreateInstance($_account);
                             $tempFiles->ClearAccount();
                             unset($tempFiles);
                             $_sendSettingsList = true;
                             $_log->WriteEvent('User login', $_account);
                             if ($_account->MailProtocol == MAILPROTOCOL_IMAP4 && $_account->ImapQuota === 1) {
                                 $quota = $_newprocessor->GetQuota();
                                 if ($quota !== false && $quota !== $_account->MailboxLimit) {
                                     $_account->MailboxLimit = GetGoodBigInt($quota);
                                     $_account->UpdateMailBoxLimit();
                                 }
                             }
                             self::AfterLoginAction($_account, $_newprocessor, $_settings);
                         } else {
                             $errorString = ErrorPOP3IMAP4Auth;
                             return false;
                         }
                     }
                 }
             }
         }
     }
     if ($_sendSettingsList && USE_DB) {
         if (!$_dbStorage->UpdateLastLoginAndLoginsCount($_account->IdUser)) {
             $_sendSettingsList = false;
             $errorString = getGlobalError();
             return false;
         }
     }
     if (isset($_account)) {
         $refAccount = $_account;
     }
     return true;
 }
Example #7
Show file File: class_processorswitch.php Project: JDevelopers/Mail
0
 function DoRegistration()
 {
     $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null;
     $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId);
     $isGdSupport = @function_exists('imagecreatefrompng');
     $captcha = $_xmlObj->GetParamTagValueByName('captcha');
     if ($isGdSupport && (!isset($_SESSION['captcha_keystring']) || $captcha != $_SESSION['captcha_keystring'])) {
         CXmlProcessing::PrintErrorAndExit(CaptchaError, $_xmlRes);
     }
     if (true) {
         $_login = trim($_xmlObj->GetParamTagValueByName('login'));
         $_domainName = trim($_xmlObj->GetParamTagValueByName('domain'));
         $_domain =& $_dbStorage->SelectDomainByName($_domainName);
         if (!$_domain) {
             CXmlProcessing::PrintErrorAndExit(RegDomainNotExist, $_xmlRes);
         }
         $_email = $_login . '@' . $_domainName;
         $_loginArray =& Account::LoadFromDbOnlyByEmail($_email);
         if (is_array($_loginArray) && count($_loginArray) > 3) {
             CXmlProcessing::PrintErrorAndExit(RegAccountExist, $_xmlRes);
         }
         $_password = trim($_xmlObj->GetParamTagValueByName('pass'));
         $_lang = trim($_xmlObj->GetParamTagValueByName('lang'));
         $_timezone = trim($_xmlObj->GetParamTagValueByName('timezone'));
         $_account = new Account();
         $_account->DefaultAccount = true;
         $_account->Email = $_email;
         $_account->MailIncLogin = $_email;
         $_account->MailIncPassword = $_password;
         $_account->DefaultLanguage = $_lang;
         $_account->DefaultTimeZone = $_timezone;
         $_account->FriendlyName = trim($_xmlObj->GetParamTagValueByName('name'));
         $_account->Delimiter = '.';
         $_account->Question1 = trim($_xmlObj->GetParamTagValueByName('question_1'));
         $_account->Answer1 = trim($_xmlObj->GetParamTagValueByName('answer_1'));
         $_account->Question2 = trim($_xmlObj->GetParamTagValueByName('question_2'));
         $_account->Answer2 = trim($_xmlObj->GetParamTagValueByName('answer_2'));
         $_domain->UpdateAccount($_account, $_settings);
         $_validate = $_account->ValidateData();
         if ($_validate !== true) {
             CXmlProcessing::PrintErrorAndExit($_validate, $_xmlRes);
         } else {
             if ($_account->IsInternal) {
                 require_once WM_ROOTPATH . 'common/class_exim.php';
                 if (!CExim::CreateUserShell($_login, $_domainName, $_account->MailboxLimit)) {
                     CXmlProcessing::PrintErrorAndExit(CantCreateUser, $_xmlRes);
                 }
                 $_dbStorage->InsertAccountData($_account);
             }
             $_processor = new MailProcessor($_account);
             if ($_processor->MailStorage->Connect(true)) {
                 $_user =& User::CreateUser($_account);
                 if ($_user && $_account) {
                     $_account->IdUser = $_user->Id;
                 }
                 $_inboxSyncType = $_account->GetDefaultFolderSync($_settings);
                 if ($_user != null && $_user->CreateAccount($_account, $_inboxSyncType, false, $_processor->MailStorage)) {
                     $_SESSION[ACCOUNT_ID] = $_account->Id;
                     $_SESSION[USER_ID] = $_account->IdUser;
                     $_SESSION[SESSION_LANG] = $_account->DefaultLanguage;
                 } else {
                     if ($_user) {
                         User::DeleteUserSettings($_user->Id);
                     }
                     $_error = getGlobalError();
                     $_error = strlen($_error) > 0 ? $_error : CantCreateUser;
                     CXmlProcessing::PrintErrorAndExit($_error, $_xmlRes);
                 }
             } else {
                 if ($_account->IsInternal) {
                     $_dbStorage->DeleteOnlyAccountData($_account->Id);
                     CExim::DeleteUserShell($_login, $_domainName);
                 }
                 CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes);
             }
         }
         $_regNode = new XmlDomNode('registration');
         if ($_xmlObj->GetParamValueByName('sign_me') && $_account) {
             $_regNode->AppendAttribute('id_acct', $_account->Id);
             $_regNode->AppendChild(new XmlDomNode('hash', md5(ConvertUtils::EncodePassword($_account->MailIncPassword, $_account)), true));
         }
         $_xmlRes->XmlRoot->AppendChild($_regNode);
     } else {
         CXmlProcessing::PrintErrorAndExit('error', $_xmlRes);
     }
 }
Example #8
Show file File: portal.php Project: heshuxian/mofang
0
 public function registration()
 {
     $data = array();
     $data['site_name'] = $this->config->item('site_name');
     $data['pageTitle'] = '注册';
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('txtUsername', '用户名', 'trim|required');
         $this->form_validation->set_rules('txtPassword', "密码", 'required');
         $this->form_validation->set_rules('txtConfirmPassword', "确认密码", 'required');
         $this->form_validation->set_rules('txtFullName', "用户全名", 'required');
         $this->form_validation->set_rules('txtEmail', "邮箱", 'required');
         if ($this->form_validation->run()) {
             $username = $this->input->post('txtUsername');
             $password = $this->input->post('txtPassword');
             $full_name = $this->input->post('txtFullName');
             $email = $this->input->post('txtEmail');
             if (User::CreateUser($username, $password, $full_name, 'user', $email)) {
                 $data['msg'] = "注册用户成功!";
                 redirect("/portal");
             } else {
                 $data['msg'] = "注册新用户失败,请重试!";
             }
         }
         $data['msg'] = "注册新用户失败";
     }
     $data['scriptExtra'] = '<script type="text/javascript" src="/public/js/jquery.validate.min.js"></script>';
     $data['scriptExtra'] .= '<script type="text/javascript" src="/public/js/registration.js"></script>';
     $this->load->view('/portal/registration', $data);
 }
Example #9
Show file File: integr.php Project: diedsmiling/busenika
0
 /**
  * @param Account $account
  * @return bool
  */
 function CreateUserFromAccount(&$account)
 {
     $account->DefaultAccount = true;
     $null = null;
     $this->Account =& $account;
     $processor =& new MailProcessor($account);
     if ($processor && $processor->MailStorage->Connect()) {
         $dbStorage =& DbStorageCreator::CreateDatabaseStorage($null);
         if ($dbStorage && $dbStorage->Connect()) {
             $validate = $account->ValidateData();
             if ($validate !== true) {
                 $this->SetError($validate);
                 return false;
             } else {
                 $inboxSync = $account->MailProtocol == MAILPROTOCOL_IMAP4 ? FOLDERSYNC_AllHeadersOnly : FOLDERSYNC_NewEntireMessages;
                 $user =& User::CreateUser();
                 if ($user == null) {
                     $this->SetError();
                     return false;
                 } else {
                     if ($user->CreateAccount($account, $inboxSync)) {
                         return true;
                     } else {
                         User::DeleteUserSettings($user->Id);
                     }
                 }
             }
         }
     }
     $this->SetError();
     return false;
 }