View source
<?php
function book_access_enable() {
node_access_rebuild();
}
function book_access_disable() {
book_access_enabled(FALSE);
node_access_rebuild();
}
function book_access_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("\n CREATE TABLE IF NOT EXISTS {book_access} (\n nid int(10) NOT NULL default 0,\n rid int(10) NOT NULL default 0,\n grant_view tinyint(1) unsigned NOT NULL default '0',\n grant_update tinyint(1) unsigned NOT NULL default '0',\n grant_delete tinyint(1) unsigned NOT NULL default '0',\n KEY nid (nid),\n KEY rid (rid)\n );\n ");
break;
case 'pgsql':
db_query("\n CREATE TABLE {book_access} (\n nid int NOT NULL DEFAULT 0,\n rid int NOT NULL DEFAULT 0,\n grant_view smallint NOT NULL DEFAULT 0,\n grant_update smallint NOT NULL DEFAULT 0,\n grant_delete smallint NOT NULL DEFAULT 0,\n PRIMARY KEY (nid, rid)\n );\n ");
break;
}
db_query("UPDATE {system} SET weight = 2 WHERE name = 'book_access'");
}
function book_access_update_1() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 2 WHERE name = 'book_access'");
return $ret;
}
function book_access_uninstall() {
db_query('DROP TABLE {book_access}');
}