Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getGroups()
- {
- try {
- $db = parse_ini_file('app/config/portal.ini');
- // read the database properties
- $user = isset($db['user']) ? $db['user'] : NULL;
- $pass = isset($db['pass']) ? $db['pass'] : NULL;
- $name = isset($db['name']) ? $db['name'] : NULL;
- $host = isset($db['host']) ? $db['host'] : NULL;
- $port = isset($db['port']) ? $db['port'] : 5432;
- $conn = new PDO("pgsql:dbname={$name};user={$user}; password={$pass};host=$host;port={$port}");
- $results = array();
- $result = $conn->query("select id, groupname, description from user_group");
- if (!empty($result)) {
- while ($row = $result->fetchObject()) {
- $results[] = $row;
- }
- }
- return $results;
- } catch (Exception $e) {
- throw new SoapFault('Client', $e->getMessage());
- }
- }
- public function getUserGroups($login)
- {
- try {
- $db = parse_ini_file('app/config/portal.ini');
- // read the database properties
- $user = isset($db['user']) ? $db['user'] : NULL;
- $pass = isset($db['pass']) ? $db['pass'] : NULL;
- $name = isset($db['name']) ? $db['name'] : NULL;
- $host = isset($db['host']) ? $db['host'] : NULL;
- $port = isset($db['port']) ? $db['port'] : 5432;
- $conn = new PDO("pgsql:dbname={$name};user={$user}; password={$pass};host=$host;port={$port}");
- $results = array();
- $result = $conn->query("SELECT user_id, group_id from user_groups WHERE user_id = (SELECT id from system_user where login='$login')");
- if (!empty($result)) {
- while ($row = $result->fetchObject()) {
- $results[] = $row;
- }
- }
- return $results;
- } catch (Exception $e) {
- throw new SoapFault('Client', $e->getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement