Ejemplo n.º 1
0
 public function getUser($username)
 {
     $user = null;
     if ($this->dbObj != null) {
         $query = "SELECT * FROM users u LEFT JOIN roles r ON u.user_role = r.role_id WHERE user_name='{$username}'";
         $results = $this->dbObj->ExecuteTableQuery($query);
         if (!empty($results)) {
             $user = $results[0];
         }
     } else {
         if (isset($this->config['users'][$username])) {
             $user = $this->config['users'][$username];
             $user['user_name'] = $username;
         }
     }
     return $user;
 }
Ejemplo n.º 2
0
 public function setUser($userData, $update = false)
 {
     if ($this->dbObj == null) {
         $users = $this->get('users');
         $users[$userData['user_name']]['user_password'] = $userData['user_password'];
         $users[$userData['user_name']]['role_name'] = $userData['role_name'];
         $this->set('users', $users);
     } else {
         $sql = "";
         if (!$update) {
             $sql = "INSERT INTO users (user_name, user_password, user_role) VALUES ";
             $sql .= "('{$userData['user_name']}'";
             $sql .= ", '{$userData['user_password']}'";
             $sql .= ", '{$userData['user_role']}')";
         } else {
             $sql = "UPDATE users SET ";
             $sql .= "user_password='******'user_password']}'";
             $sql .= ", user_role='{$userData['user_role']}'";
             $sql .= " WHERE user_name='{$userData['user_name']}'";
         }
         $this->dbObj->ExecuteNonQuery($sql);
     }
 }
Ejemplo n.º 3
0
 /**
  * Loads configuration from the DB.
  *
  * @param DB $dbObj Database connection object
  * @return array Loaded configuration
  */
 private function loadConfigurationFromDb($dbObj, $configPhpFileDir, $alreadyLoadedConfig, $configFileMapping)
 {
     $loadedConfig = $this->loadConfigurationFromPhpFile($configPhpFileDir, $alreadyLoadedConfig, $configFileMapping);
     $getRolesQry = "SELECT * FROM roles";
     $results = $dbObj->ExecuteTableQuery($getRolesQry);
     foreach ($results as $row) {
         $loadedConfig['roles'][] = $row['role_name'];
     }
     return $loadedConfig;
 }