public static function RegisterUser($strUsername, $strEmail, $strPassword, $strRealName) { $objMaxUser = NarroUser::LoadAll(QQ::Clause(QQ::LimitInfo(1, 0), QQ::OrderBy(QQN::NarroUser()->UserId, false))); $objUser = new NarroUser(); $objUser->UserId = $objMaxUser[0]->UserId + 1; $objUser->Username = $strUsername; if ($strRealName) { $objUser->RealName = $strRealName; } $objUser->Email = $strEmail; require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php'; $objHasher = new PasswordHash(8, FALSE); $objUser->Password = $objHasher->HashPassword($strPassword); try { $objUser->Save(); } catch (Exception $objEx) { throw $objEx; } /** * set up default roles */ $objUserRole = new NarroUserRole(); if ($objUser->UserId == 1) { $objUserRole->RoleId = 5; } else { $objUserRole->RoleId = 2; } $objUserRole->UserId = $objUser->UserId; $objUserRole->Save(); return NarroUser::LoadByUsernameAndPassword($strUsername, md5($strPassword)); }