function permissions_grant_user($user, $dir, $file, $action)
{
    return true;
    // determine the user permissions of the given user
    $permissions = user_get_permissions($user);
    // determine the permission definitions
    $permdefs = permissions_get();
    // the user with the name "admin" always has admin rights
    if ($action == "admin" && $user == "admin") {
        return true;
    }
    // check if the action is allowed
    return ($permdefs[$action] & $permissions) != 0;
}
Example #2
0
/**
	print out the html permission table to modify user permissions.

	the name of the permission values are determined via the language
	interface. In case of there is no entry in the language table for
	this permission, the function uses the original permission name.
*/
function admin_print_permissions($username)
{
    $permvalues = permissions_get();
    echo "<TABLE>";
    foreach ($permvalues as $name => $value) {
        // determine wether the option is already set
        $checked = permissions_grant_user($username, NULL, NULL, $name) ? "checked" : "";
        $disabled = $username == "admin" && $name == "admin" ? "disabled" : "";
        $desc = $GLOBALS["messages"]["miscpermissions"][$name][0];
        $tooltip = $GLOBALS["messages"]["miscpermissions"][$name][1];
        echo "<TR><TD>\n";
        echo "\t\t<INPUT type=\"checkbox\" title=\"{$tooltip}\" name=\"permsettings[]\" value=\"{$value}\" {$checked} {$disabled} >\n";
        echo isset($desc) ? $desc : $name;
        echo "</INPUT>";
        echo "</TR></TD>";
    }
    echo "</TABLE>";
}