View source
<?php
function og_access_schema() {
$schema = array();
$schema['og_access_post'] = array(
'description' => 'Global properties for group posts.',
'fields' => array(
'nid' => array(
'description' => "The post's {node}.nid.",
'type' => 'int',
'size' => 'normal',
'not null' => TRUE,
),
'og_public' => array(
'description' => 'Is this a public or private post?',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
'not null' => TRUE,
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
function og_access_install() {
drupal_install_schema('og_access');
db_query("UPDATE {system} SET weight = 1 WHERE name = 'og_access'");
}
function og_access_uninstall() {
drupal_uninstall_schema('og_access');
$variables = array(
'og_private_groups',
'og_visibility',
);
foreach ($variables as $variable) {
variable_del($variable);
}
}
function og_access_update_6201() {
$ret = array();
$schema['og_access_post'] = array(
'description' => 'Global properties for group posts.',
'fields' => array(
'nid' => array(
'description' => "The post's {node}.nid.",
'type' => 'int',
'size' => 'normal',
'not null' => TRUE,
),
'og_public' => array(
'description' => 'Is this a public or private post?',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
'not null' => TRUE,
),
),
'primary key' => array(
'nid',
),
);
db_create_table($ret, 'og_access_post', $schema['og_access_post']);
$ret[] = update_sql("INSERT INTO {og_access_post} (nid, og_public) SELECT DISTINCT(nid), (SELECT oga_sub.is_public FROM {og_ancestry} oga_sub WHERE oga_sub.nid = oga.nid LIMIT 1) FROM {og_ancestry} oga");
db_drop_field($ret, 'og_ancestry', 'is_public');
og_ancestry_dedupe($ret);
return $ret;
}