function createAdminUser($email_address) { //create user entity $u = owa_coreAPI::entityFactory('base.user'); // check to see if an admin user already exists $u->getByColumn('role', 'admin'); $id_check = $u->get('id'); // if not then proceed if (empty($id_check)) { //Check to see if user name already exists $u->getByColumn('user_id', 'admin'); $id = $u->get('id'); // Set user object Params if (empty($id)) { $password = $u->generateRandomPassword(); $u->set('user_id', 'admin'); $u->set('role', 'admin'); $u->set('real_name', ''); $u->set('email_address', $email_address); $u->set('password', owa_lib::encryptPassword($password)); $u->set('creation_date', time()); $u->set('last_update_date', time()); $ret = $u->create(); owa_coreAPI::debug("Admin user created successfully."); return $password; } else { owa_coreAPI::debug($this->getMsg(3306)); } } else { owa_coreAPI::debug("Admin user already exists."); } }
function generateRandomPassword() { return substr(owa_lib::encryptPassword(microtime()), 0, 6); }
/** * Simple Password Encryption Scheme * * @param string $password * @return string */ function encryptPassword($password) { return owa_lib::encryptPassword($password); }