View source
<?php
function block_access_delete_roles($module, $perm, $delta = null) {
$sql = "\n DELETE FROM {block_access_roles} \n WHERE module = '%s'\n AND permission = '%s'\n ";
$args = array(
$module,
$perm,
);
if ($delta !== null) {
$sql .= "AND delta = '%s'";
$args[] = $delta;
}
else {
$sql .= "AND delta IS NULL";
}
db_query($sql, $args);
}
function block_access_add_role($rid, $module, $perm, $delta = null) {
db_query("\n INSERT INTO {block_access_roles}\n (\n rid,\n module,\n delta,\n permission\n )\n VALUES\n (\n %d,\n '%s',\n '%s',\n '%s'\n )", $rid, $module, $delta, $perm);
}
function block_access_get_roles($module, $perm, $delta = null) {
$sql = "\n SELECT rid\n FROM {block_access_roles}\n WHERE module = '%s'\n AND permission = '%s'\n ";
$args = array(
$module,
$perm,
);
if ($delta) {
$sql2 = $sql;
$sql .= "AND delta = '%s'";
$args[] = $delta;
}
$result = db_query($sql, $args);
$ret = array();
while ($rid = db_result($result)) {
$ret[] = $rid;
}
if ($delta && empty($ret)) {
$result = db_query($sql2, $module, $perm);
while ($rid = db_result($result)) {
$ret[] = $rid;
}
}
return $ret;
}
function block_access_get_module($module) {
$sql = "\n SELECT rid, permission\n FROM {block_access_roles}\n WHERE module = '%s'\n AND delta = ''";
$result = db_query($sql, $module);
$ret = array();
while ($ob = db_fetch_object($result)) {
if (isset($ret[$ob->rid])) {
$ret[$ob->rid][] = $ob->permission;
}
else {
$ret[$ob->rid] = array(
$ob->permission,
);
}
}
return $ret;
}