public static function getInstance() { if (null == self::$instance) { self::$instance = new RoleUtils(); } return self::$instance; }
public function __construct() { $this->session = Session::getInstance(); $this->webDBUtils = WebDBUtils::getInstance(); $this->roleUtils = RoleUtils::getInstance(); $this->user = User::getInstance(); $this->pwUtils = PWUtils::getInstance(); }
public function __construct($uid = null) { $this->session = Session::getInstance(); $this->roleUtils = RoleUtils::getInstance(); $this->db = WebDBUtils::getInstance(); $this->pwUtils = PWUtils::getInstance(); $this->load($uid); }
function addUser($app, $role) { $webDBUtils = WebDBUtils::getInstance(); $utils = Utils::getInstance(); $user = User::getInstance(); $pwUtils = PWUtils::getInstance(); $session = Session::getInstance(); $roleUtils = RoleUtils::getInstance(); $mail = $utils->iStr($app->request()->post('mail'), 64); $pass = $utils->iStr($app->request()->post('pass'), 64); $ierr = false; if (false == filter_var($mail, FILTER_VALIDATE_EMAIL)) { $session->addError(L::__('No Email')); $ierr = true; } if (4 > strlen($pass)) { $session->addError(L::__('No Password')); $ierr = true; } if (false != $ierr) { $app->response->redirect(Settings::baseRef . '/tenant-add-user', 303); return; } // rid $rid = $user->getRadioId(); // sets up user data $hash = $pwUtils->generateHash($pass); $targetUser = array('email' => $mail, 'password_hash' => $hash, 'radio_id' => $rid); // adds the user $uid = $webDBUtils->addUser($targetUser); if (false == $uid) { return; } // links the user into the group (RoleUtils::TENANT) $targetUser = new User($uid); switch ($role) { case RoleUtils::TENANT: $res = $targetUser->linkRoleId($roleUtils->getRoleId(RoleUtils::TENANT)); break; case RoleUtils::ADMIN: $res = $targetUser->linkRoleId($roleUtils->getRoleId(RoleUtils::ADMIN)); break; } // registers a stream (radio channel, an icecast mountpoint) $res = $targetUser->registerStream(); // --> return $res; }
public function __construct() { $this->session = Session::getInstance(); $this->roleUtils = RoleUtils::getInstance(); }
$session = Session::getInstance(); $l = readline('Are you sure you want to reset the DB?' . PHP_EOL); $l = readline('Reset the DB?' . PHP_EOL); if ('yyy' != $l) { print 'Never reset the DB.' . PHP_EOL; exit(1); } $rootDBUtilsTest = new RootDBUtilsTest(); $rootDBUtilsTest->setupWebDBUser(); $rootDBUtilsTest->setupUserDB(); $rootDBUtilsTest->setupPlaylistDB(); $rootDBUtilsTest->setupStreamDB(); $rootDBUtilsTest->setupWebDBUserRights(); $roleUtilsTest = new RoleUtilsTest(); $roleUtilsTest->addRoles(); RoleUtils::getInstance()->load(); $webDBUtilsTest = new WebDBUtilsTest(); $webDBUtilsTest->addMockUser('*****@*****.**', 'admin'); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::ADMIN); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::TENANT); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::GUEST); $webDBUtilsTest->listRolesOfUser('*****@*****.**'); $webDBUtilsTest->addMockUser('*****@*****.**', 'test'); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::TENANT); $webDBUtilsTest->listRolesOfUser('*****@*****.**'); $webDBUtilsTest->addMockUser('*****@*****.**', 'test'); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::TENANT); $webDBUtilsTest->listRolesOfUser('*****@*****.**'); $webDBUtilsTest->addStream('radio.0.mp3'); $webDBUtilsTest->addStream('radio.1.mp3'); $webDBUtilsTest->addStream('radio.2.mp3');
public function linkRoleTenant($email) { $d = $this->webDBUtils->getUserByEmail($email); if (false == $d) { $this->printErr('UserTest::linkRoleTenant(): failed: no such user: '******'id']); $res = $user->linkRoleId(RoleUtils::getInstance()->getRoleId(RoleUtils::TENANT)); if (false == $res) { $this->printErr('UserTest::linkRoleTenant(): failed'); $this->printErr($this->session->flushError()); } else { $this->printMsg('UserTest::linkRoleTenant(): succeeded'); print_r($res); print PHP_EOL; } }