Example #1
0
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$users = sotf_User::listUsers();
$smarty->assign('USERS', $users);
$smarty->display("listUsers.htm");
Example #2
0
// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: admin.php 554 2006-04-12 10:37:20Z buddhafly $
 * Authors: András Micsik 
 */
require "init.inc.php";
$smarty->assign('PAGETITLE', $page->getlocalized('AdminPage'));
$page->forceLogin();
//$page->errorURL = "admin.php";
checkPerm('node', 'change');
if (sotf_Utils::getParameter('del')) {
    $uid = sotf_Utils::getParameter('uid');
    $user = new sotf_User($uid);
    debug("Deleting user {$uid}", $user->username);
    $user->delete();
    $page->redirect('adminUsers.php');
    $page->logRequest();
    exit;
}
$pattern = sotf_Utils::getParameter('pattern');
$count = sotf_User::countUsers($pattern);
$limit = $page->splitList($count, $scriptUrl . "?pattern=" . urlencode($pattern));
$users = sotf_User::listUsers($limit["from"], $limit["maxresults"], $pattern);
foreach ($users as $user) {
    $user['groups'] = join(', ', sotf_Group::getGroupNames($user['id']));
    $ulist[] = $user;
}
$smarty->assign('USERS', $ulist);
$smarty->assign('PATTERN', $pattern);
$page->send();
 /**
  * Adds the user to a group in a station.
  *
  * @param	string	$username	Userid
  * @param	string	$group	ID of the group
  * @param	string	$station	Station
  * @return	boolean	Returns true if succeeded
  * @use	$db
  */
 function addUserToGroup($username, $group, $station)
 {
     global $db;
     $username = sotf_Utils::clean($username);
     $group = sotf_Utils::clean($group);
     $station = sotf_Utils::clean($station);
     $users = sotf_User::listUsers();
     if (in_array($username, $users)) {
         $user = $db->getOne("SELECT username FROM sotf_user_group WHERE username='******' AND station='{$station}' AND group_id='{$group}'");
         if (!$user) {
             $db->query("INSERT INTO sotf_user_group (username, station, group_id) VALUES('{$username}', '{$station}', '{$group}')");
             return true;
         }
     }
     return false;
 }