og_blueprints.install File Reference

Go to the source code of this file.

Functions

 _og_blueprints_update_sql ($sql)
 Smarter implementation of update_sql() that allows for args to be passed through the normal db_query escaping functions.
 og_blueprints_enable ()
 Implementation of hook_enable().
 og_blueprints_install ()
 og_blueprints_uninstall ()


Function Documentation

_og_blueprints_update_sql ( sql  ) 

So, mostly nicked from db_query()

Definition at line 168 of file og_blueprints.install.

00168                                          {
00169   $args = func_get_args();
00170   array_shift($args);
00171   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00172     $args = $args[0];
00173   }  
00174   $result = db_query($sql, $args);
00175   _db_query_callback($args, TRUE);
00176   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $sql);
00177   return array('success' => $result !== FALSE, 'query' => check_plain($query));
00178 }

og_blueprints_enable (  ) 

Definition at line 159 of file og_blueprints.install.

00159                                 {
00160     drupal_set_message(t('OG Blueprints has been installed. You can begin configuring your blueprint bundles at the !link administrative menu.', array('!link' => l(t('OG Blueprints'), 'admin/og/og_blueprints'))));
00161 }

og_blueprints_install (  ) 

40100 DEFAULT CHARACTER SET utf8

40100 DEFAULT CHARACTER SET utf8

40100 DEFAULT CHARACTER SET utf8

40100 DEFAULT CHARACTER SET utf8

Definition at line 4 of file og_blueprints.install.

00004                                  {
00005   switch ($GLOBALS['db_type']) {
00006     case 'mysql':
00007     case 'mysqli':
00008       db_query(<<<EOT
00009         CREATE TABLE {og_bundle} (
00010         grouptype varchar(32) NOT NULL,
00011         bid int(11) PRIMARY KEY,
00012         vid int(11) NOT NULL DEFAULT 0,
00013         release_id int(4) NULL, 
00014         KEY (vid),
00015         KEY bvid (bid, vid)
00016       ) /*!40100 DEFAULT CHARACTER SET utf8 */
00017 EOT
00018       );
00019 
00020       db_query(<<<EOT
00021         CREATE TABLE {og_bundle_revision} (
00022         bid int(11) NOT NULL,
00023         vid int(11) PRIMARY KEY AUTO_INCREMENT,
00024         release_id int(4) NULL,
00025         release_name varchar(128) NULL,
00026         timestamp int(11) NULL,
00027         KEY bvid (vid, bid),
00028         KEY release_idx (vid, release_id)
00029       ) /*!40100 DEFAULT CHARACTER SET utf8 */
00030 EOT
00031       );
00032       
00033       db_query(<<<EOT
00034         CREATE TABLE {og_blueprint} (
00035         bid int(11) NOT NULL,
00036         vid int(11) NOT NULL,
00037         bpid int(11) NOT NULL,
00038         bpname varchar(32) NOT NULL,
00039         did int(11) NOT NULL DEFAULT 0,
00040         linked int(1) DEFAULT 1,
00041         enabled int(1) DEFAULT 0,
00042         published int(1) DEFAULT 0,
00043         default_page int(1) DEFAULT 0,
00044         page_title varchar(255) NOT NULL,
00045         path varchar(100) NOT NULL,
00046         show_blocks int(1) DEFAULT 1,
00047         weight int(4) DEFAULT 0,
00048         PRIMARY KEY (bpid, bid, vid),
00049         KEY rev_idx (vid),
00050         KEY bp_idx (bpid, bpname)
00051       ) /*!40100 DEFAULT CHARACTER SET utf8 */
00052 EOT
00053       );
00054       
00055       db_query(<<<EOT
00056         CREATE TABLE {og_blueprint_control} (
00057         bid int(11) NOT NULL,
00058         vid int(11) NOT NULL,
00059         bpid int(11) NOT NULL,
00060         nid int(11) NOT NULL,
00061         did_link int(1) NOT NULL DEFAULT 1,
00062         PRIMARY KEY (nid, bpid),
00063         KEY bvid (bid, vid),
00064         KEY linked (nid, bpid, did_link)
00065       ) /*!40100 DEFAULT CHARACTER SET utf8 */
00066 EOT
00067       );
00068       break;
00069       
00070     case 'pgsql':
00071       db_query(<<<EOT
00072         CREATE TABLE {og_bundle} (
00073         grouptype varchar(32) NOT NULL,
00074         bid integer(11) NOT NULL,
00075         vid integer(11) NOT NULL DEFAULT 0,
00076         release_id integer(4) NULL,
00077         PRIMARY KEY bid
00078       );
00079 EOT
00080       );
00081       db_query("CREATE SEQUENCE {og_bundle}_bid_seq;");
00082       db_query("CREATE INDEX {og_bundle}_bvid ON {og_bundle} (bid, vid);");
00083       db_query("CREATE INDEX {og_bundle}_vid ON {og_bundle} (vid);");
00084       db_query(<<<EOT
00085         CREATE TABLE {og_bundle_revision} (
00086         bid int(11) NOT NULL,
00087         vid int(11) NOT NULL,        
00088         release_id integer(4) NOT NULL DEFAULT 0,
00089         release_name varchar(128),
00090         timestamp integer(11) NULL,
00091         PRIMARY KEY (vid)
00092       );
00093 EOT
00094       );
00095       db_query("CREATE SEQUENCE {og_bundle_revision}_vid_seq;");
00096       db_query("CREATE INDEX {og_bundle_revision}_bvid ON {og_bundle_revision} (vid, bid);");
00097       db_query("CREATE INDEX {og_bundle_revision}_release_idx ON {og_bundle_revision} (vid, release_id);");
00098       db_query(<<<EOT
00099         CREATE TABLE {og_blueprint} (
00100         bid int(11) NOT NULL,
00101         vid int(11) NOT NULL,
00102         bpid int(11) NOT NULL,        
00103         bpname varchar(32) NOT NULL,
00104         did int(11) NOT NULL DEFAULT 0,
00105         linked int(1) DEFAULT 1,
00106         enabled int(1) DEFAULT 0,
00107         published int(1) DEFAULT 0,
00108         default_page int(1) DEFAULT 0,
00109         page_title varchar(255) NOT NULL,
00110         show_blocks int(1) DEFAULT 1,
00111         path varchar(100) NOT NULL,
00112         weight int(4) DEFAULT 0,
00113         PRIMARY KEY (bid, vid, bpid)
00114       );
00115 EOT
00116       );
00117       db_query("CREATE INDEX {og_blueprint}_revision_idx ON {og_blueprint} (bpname, bpid);");
00118       db_query("CREATE INDEX {og_blueprint}_bvid ON {og_blueprint} (bid, vid);");
00119       db_query("CREATE INDEX {og_blueprint}_rev_idx ON {og_blueprint} (vid);");
00120       db_query(<<<EOT
00121         CREATE TABLE {og_blueprint_control} (
00122         bid integer(11) NOT NULL,
00123         vid integer(11) NOT NULL,
00124         bpid integer(11) NOT NULL,
00125         nid integer(11) NOT NULL,
00126         did_link integer(1) NOT NULL DEFAULT 1,
00127         PRIMARY KEY (nid, bpid)
00128       );
00129 EOT
00130       );
00131       db_query("CREATE INDEX {og_blueprint_control}_linked ON {og_blueprint_control} (nid, bpid, did_link);");
00132       break;
00133   }
00134   $bid = db_next_id("{og_bundle}_bid");
00135   db_query("INSERT INTO {og_bundle} (grouptype, bid, vid) VALUES ('%s', 1, 1)", 'master');
00136   db_query("INSERT INTO {og_bundle_revision} (vid, bid) VALUES (1, 1)");
00137   variable_set('og_blueprints_mode', 0);
00138 }

og_blueprints_uninstall (  ) 

Definition at line 140 of file og_blueprints.install.

00140                                    {
00141   db_query('DROP TABLE {og_bundle}');
00142   db_query('DROP TABLE {og_bundle_revision}');
00143   db_query('DROP TABLE {og_blueprint}');
00144   db_query('DROP TABLE {og_blueprint_control}');
00145   if (in_array($GLOBALS['db_type'], array('mysql', 'mysqli'))) {
00146     db_query("DELETE FROM {sequences} WHERE name IN ('{og_bundle}_bid', '{og_blueprint}_bpid')");
00147   }
00148   // Delete variables
00149   $variables = array('og_blueprints_mode', 'og_blueprints_list');
00150   foreach ($variables as $variable) {
00151     variable_del($variable);
00152   }
00153 }


Generated on Sun May 18 20:36:51 2008 for Organic Groups Blueprints by  doxygen 1.5.5