function getUserPermissions($userid = '')
 {
     global $db, $user, $repository;
     if (!$userid && is_object($user)) {
         $userid = $user->id;
     }
     if ($userid) {
         $permtable = $db->getAll("SELECT sotf_user_permissions.object_id, sotf_permissions.permission FROM sotf_user_permissions, sotf_permissions WHERE sotf_user_permissions.user_id = '{$userid}' AND sotf_user_permissions.permission_id = sotf_permissions.id");
         //debug("permtable", $permtable);
         // make an associative array containing the permissions for all objects
         while (list(, $row) = each($permtable)) {
             $permissions[$row["object_id"]][] = $row["permission"];
             // object permission
         }
         $groups = sotf_Group::listGroupsOfUser($userid);
         foreach ($groups as $gid => $gname) {
             $permtable = $db->getAll("SELECT sotf_group_permissions.object_id, sotf_permissions.permission FROM sotf_group_permissions, sotf_permissions WHERE sotf_group_permissions.group_id = '{$gid}' AND sotf_group_permissions.permission_id = sotf_permissions.id");
             // append to associative array containing the permissions for all objects
             while (list(, $row) = each($permtable)) {
                 $permissions[$row["object_id"]][] = $row["permission"];
                 // object permission
             }
             // TODO: remove duplicates
         }
     }
     if ($this->debug) {
         error_log("current permissions", 0);
         if (count($permissions) > 0) {
             foreach ($permissions as $key => $value) {
                 error_log("PERMISSION: {$key} = " . join(' ', $value), 0);
             }
         }
     }
     return $permissions;
 }
Example #2
0
    $url = $_GET['okURL'];
    if (!$url) {
        $url = $config['localPrefix'];
    }
    $page->redirect($url);
    exit;
}
// we need trick for making pages indexed by Google
// therefore we pass some parameters in pathinfo
// after this call getParameter can be used to get these parameters as well
$pathinfoParamExceptions = array('getIcon', 'getJingle', 'getUserFile');
if (!in_array($page->action, $pathinfoParamExceptions)) {
    sotf_Utils::collectPathinfoParams();
}
// just for debugging
$groups = sotf_Group::listGroupsOfUser($user->id);
debug("GROUPS", $groups);
// permissions object is for managing and asking for permissions
$permissions = new sotf_Permission();
//$permissions->debug = true;
// the repository of radio stations
$repository = new sotf_Repository($config['repositoryDir'], $db);
// all controlled vocabularies
$vocabularies = new sotf_Vocabularies($db);
// now you have the following global objects: $config, $db, $userdb, $smarty, $page, $repository, $user, $permission
// is that too many?
// forwarding all $config to smarty is a security risk
// $smarty->assign("CONFIG", $config);
// add basic variables to Smarty
$smarty->assign("NODEID", $config['nodeId']);
$smarty->assign("NODE_NAME", $config['nodeName']);
            $g = (int) substr($g, 2);
            sotf_Group::setGroup($uid, $g, 1);
            debug("TYPE", gettype($g));
            debug("ADD {$g}", $uGroups[$g]);
            unset($uGroups[$g]);
            debug("after REMOVING {$g}", $uGroups);
        }
    }
    // remove unchecked items
    debug("U2", $uGroups);
    foreach ($uGroups as $gid => $rid) {
        sotf_Group::setGroup($uid, $gid, 0, $rid);
    }
    $page->redirect("closeAndRefresh.php");
    exit;
}
// close
$close = sotf_Utils::getParameter('close');
if ($close) {
    $page->redirect("closeAndRefresh.php");
    exit;
}
// generate output
$uGroups = sotf_Group::listGroupsOfUser($uid);
$groups = sotf_Group::listAll(0);
foreach ($groups as $g) {
    $g['rid'] = $uGroups[$g['id']];
    $glist[] = $g;
}
$smarty->assign('GROUPS', $glist);
$page->sendPopup();