Beispiel #1
0
function show_permission_list($template_name)
{
    global $TPL;
    $roles = permission::get_roles();
    if ($_REQUEST["submit"] || $_REQUEST["filter"] != "") {
        $where = " where tableName like '%" . db_esc($_REQUEST["filter"]) . "%' ";
        // TODO: Add filtering to permission list
    }
    $db = new db_alloc();
    $db->query("SELECT * FROM permission {$where} ORDER BY tableName, sortKey");
    while ($db->next_record()) {
        $permission = new permission();
        $permission->read_db_record($db);
        $permission->set_values();
        $TPL["actions"] = $permission->describe_actions();
        $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd";
        $TPL["roleName"] = $roles[$TPL["roleName"]];
        include_template($template_name);
    }
}
Beispiel #2
0
    foreach ($ops as $v) {
        $table_name_options[$v] = $v;
    }
    $TPL["tableNameOptions"] = page::select_options($table_name_options, $permission->get_value("tableName"));
    include_template("templates/permissionTableM.tpl");
    exit;
}
if ($_POST["save"]) {
    $permission->set_value("actions", $actions);
    $permission->set_value("comment", rtrim($permission->get_value("comment")));
    $permission->save();
    alloc_redirect($TPL["url_alloc_permissionList"]);
} else {
    if ($_POST["delete"]) {
        $permission->delete();
        alloc_redirect($TPL["url_alloc_permissionList"]);
    }
}
// necessary
$permission->select();
$TPL["roleNameOptions"] = page::select_options(permission::get_roles(), $permission->get_value("roleName"));
$table_name = $_POST["tableName"] or $table_name = $permission->get_value("tableName");
$entity = new $table_name();
foreach ($entity->permissions as $value => $label) {
    if (($permission->get_value("actions") & $value) == $value) {
        $sel[] = $value;
    }
}
$TPL["actionOptions"] = page::select_options($entity->permissions, $sel);
$TPL["main_alloc_title"] = "Edit Permission - " . APPLICATION_NAME;
include_template("templates/permissionM.tpl");