t('Handles the hierarchy of og'), 'fields' => array( 'gid' => array( 'description' => t('The ID for a group.'), 'type' => 'int', 'not null' => TRUE), 'parent' => array( 'description' => t('The gid of the parent group.'), 'type' => 'int', 'not null' => TRUE, 'default' => 0), ), 'primary key' => array('gid', 'parent'), ); return $schema; } function og_subgroups_install() { drupal_install_schema('og_subgroups'); } function og_subgroups_uninstall() { drupal_uninstall_schema('og_subgroups'); // Delete variables $variables = array( 'og_subgroups_propagate_content', 'og_subgroups_propagate_members', 'og_subgroups_propagate_demote', ); foreach ($variables as $variable) { variable_del($variable); } } /** * Helper function migrate users with og_subgroups 5.x-3 to 5.x-4. */ // function og_subgroups_migrate() { // // Get all nodes from og_ancestry that nid and group_nid are both group nodes. // $all_groups = db_query("SELECT oga.nid AS gid, oga.group_nid AS parent FROM {og_ancestry} oga INNER JOIN {og} og ON og.nid = oga.nid"); // $migrate = FALSE; // while ($group = db_fetch_object($all_groups)) { // $migrate = TRUE; // db_query('INSERT INTO {og_subgroups} (gid, parent) VALUES (%d, %d)', $group->gid, $group->parent); // } // if ($migrate) { // $ret = array( // 'query' => t('Groups from versions prior to 5.x-4 were migrated.'), // 'success' => TRUE, // ); // return $ret; // } // } /** * Update path for versions prior to 5.x-4. */ // function og_subgroups_update_1() { // $ret = array(); // switch ($GLOBALS['db_type']) { // case 'mysql': // case 'mysqli': // db_query("CREATE TABLE {og_subgroups} ( // gid int(11) NOT NULL, // parent int(11) NOT NULL, // PRIMARY KEY (gid, parent) // ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); // break; // case 'pgsql': // db_query("CREATE TABLE {og_ancestry} ( // gid int NOT NULL, // parent int NOT NULL, // PRIMARY KEY (gid, parent));"); // db_query("CREATE INDEX {og_subgroups}_gid_idx ON {og_subgroups} (gid);"); // db_query("CREATE INDEX {og_subgroups}_parent_idx ON {og_subgroups} (parent);"); // break; // } // $ret[] = array( // 'query' => t('{og_subgroups} table was installed.'), // 'success' => TRUE, // ); // $ret[] = og_subgroups_migrate(); // return $ret; // }