panels_mini.install File Reference

(1.1.2.11 2008/08/05 09:45:43 sdboyer)

Go to the source code of this file.

Functions

 panels_mini_install ()
 panels_mini_uninstall ()
 panels_mini_update_5000 ()
 panels_mini_update_5001 ()
 panels_mini_update_5002 ()
 panels_mini_update_5003 ()


Function Documentation

panels_mini_install (  ) 

Implementation of hook_install().

40100 DEFAULT CHARACTER SET utf8

Definition at line 8 of file panels_mini.install.

00008                                {
00009   switch ($GLOBALS['db_type']) {
00010     case 'pgsql':
00011       db_query(<<<EOT
00012         CREATE TABLE {panels_mini} (
00013           pid integer NOT NULL DEFAULT 0,
00014           name varchar(255) UNIQUE,
00015           category varchar(64),
00016           did integer,
00017           title varchar(128),
00018           requiredcontexts text,
00019           contexts text,
00020           relationships text,
00021           PRIMARY KEY (pid)
00022         );
00023 EOT
00024       );
00025       db_query("CREATE SEQUENCE {panels_mini}_pid_seq;");
00026       db_query("CREATE INDEX {panels_mini}_name_idx ON {panels_mini} (name);");
00027       break;
00028 
00029     case 'mysql':
00030     case 'mysqli':
00031       db_query(<<<EOT
00032         CREATE TABLE {panels_mini} (
00033           pid int(10) NOT NULL DEFAULT 0 PRIMARY KEY,
00034           name varchar(255) UNIQUE,
00035           category varchar(64),
00036           did int(10),
00037           title varchar(128),
00038           contexts longtext,
00039           requiredcontexts longtext,
00040           relationships longtext,
00041           KEY (name)
00042         ) /*!40100 DEFAULT CHARACTER SET utf8 */
00043 EOT
00044       );
00045       break;
00046   }
00047 }

panels_mini_uninstall (  ) 

Implementation of hook_uninstall().

Definition at line 52 of file panels_mini.install.

References panels_delete_display().

00052                                  {
00053   $result = db_query("SELECT * FROM {panels_mini} ORDER BY title");
00054   $panels_exists = db_table_exists('panels_display');
00055   while ($panel_mini = db_fetch_object($result)) {
00056     // Delete all associated displays.
00057     if (!function_exists('panels_delete_display')) {
00058       require_once drupal_get_path('module', 'panels') .'/panels.module';
00059     }
00060     if ($panels_exists) {
00061       panels_delete_display($panel_mini->did);
00062     }
00063 
00064     // Delete all configured blocks.
00065     db_query("DELETE FROM {blocks} WHERE module = 'panels_mini' AND delta = %d", $panel_mini->pid);
00066   }
00067 
00068   // Finally, delete all mini panels.
00069   switch ($GLOBALS['db_type']) {
00070     case 'pgsql':
00071       db_query("DROP TABLE {panels_mini}");
00072       db_query("DROP SEQUENCE {panels_mini}_pid_seq");
00073       break;
00074 
00075     case 'mysql':
00076     case 'mysqli':
00077       db_query("DROP TABLE IF EXISTS {panels_mini}");
00078       break;
00079   }
00080 }

Here is the call graph for this function:

panels_mini_update_5000 (  ) 

Definition at line 82 of file panels_mini.install.

00082                                    {
00083   $ret = array();
00084   switch ($GLOBALS['db_type']) {
00085     case 'pgsql':
00086       db_add_column($ret, 'panels_mini', 'relationships', 'text', array());
00087       db_add_column($ret, 'panels_mini', 'contexts', 'text', array());
00088       db_add_column($ret, 'panels_mini', 'name', 'varchar(255) UNIQUE', array());
00089       break;
00090 
00091     case 'mysql':
00092     case 'mysqli':
00093       $ret[] = update_sql("ALTER TABLE {panels_mini} ADD COLUMN relationships longtext");
00094       $ret[] = update_sql("ALTER TABLE {panels_mini} ADD COLUMN contexts longtext");
00095       $ret[] = update_sql("ALTER TABLE {panels_mini} ADD COLUMN name varchar(255) UNIQUE AFTER pid");
00096       break;
00097   }
00098 
00099   $ret[] = update_sql("CREATE INDEX {panels_mini}_name_idx ON {panels_mini} (name)");
00100   $ret[] = update_sql("UPDATE {panels_mini} SET name = CONCAT('mini_', pid)");
00101 
00102   // Update all existing mini panels, which are being referenced by rid, to
00103   // be referenced by name.
00104   $ret[] = update_sql("UPDATE {blocks} b INNER JOIN {panels_mini} pm on pm.pid = b.delta SET b.delta = pm.name WHERE b.module = 'panels_mini'");
00105 
00106   // Update all existing mini panels that are in panels since we're now using
00107   // a different mechanism to display them
00108   $pids = array();
00109   $result = db_query("SELECT pid, name FROM {panels_mini}");
00110   while ($mini = db_fetch_object($result)) {
00111     $pids[$mini->pid] = $mini->name;
00112   }
00113 
00114   $result = db_query("SELECT * FROM {panels_pane} WHERE configuration LIKE '%panels_mini%' AND type = 'block'");
00115   while ($pane = db_fetch_object($result)) {
00116     $conf = unserialize($pane->configuration);
00117     // double check so we don't make a mistake
00118     if (empty($conf['module']) || $conf['module'] != 'panels_mini') {
00119       continue;
00120     }
00121     unset($conf['module']);
00122     $conf['name'] = $pids[$conf['delta']];
00123     unset($conf['delta']);
00124     // We can't use update_sql because without the safety of %s, serialize gets messed with
00125     // by the code that does prefixing.
00126     db_query("UPDATE {panels_pane} SET type = 'panels_mini', configuration = '%s', subtype = '%s' WHERE pid = %d", serialize($conf), $conf['name'], $pane->pid);
00127   }
00128 
00129   return $ret;
00130 }

panels_mini_update_5001 (  ) 

Definition at line 132 of file panels_mini.install.

00132                                    {
00133   $ret = array();
00134   switch ($GLOBALS['db_type']) {
00135     case 'pgsql':
00136       db_add_column($ret, 'panels_mini', 'requiredcontexts', 'text', array());
00137       break;
00138 
00139     case 'mysql':
00140     case 'mysqli':
00141       $ret[] = update_sql("ALTER TABLE {panels_mini} ADD COLUMN requiredcontexts longtext");
00142   }
00143 
00144   return $ret;
00145 }

panels_mini_update_5002 (  ) 

Get rid of a duplicate index resulting from the CREATE TABLE queries in the install() of panels schema 5214

Definition at line 151 of file panels_mini.install.

00151                                    {
00152   $ret = array();
00153   switch ($GLOBALS['db_type']) {
00154     case 'mysql':
00155     case 'mysqli':
00156       $ret[] = array('success' => TRUE, 'query' => t('It does NOT matter if the following query fails. If it fails, it means you did not have a duplicate \'name_2\' index, and trying to remove a non-existent index does not harm, alter, or otherwise affect your database in any way. If it succeeds, then the duplicate index is gone, and your table is as it should be.'));
00157       $ret[] = update_sql("ALTER TABLE {panels_mini} DROP INDEX name_2");
00158   }
00159   return $ret;
00160 }

panels_mini_update_5003 (  ) 

Add the 'category' field, which allows panels administrators to assign mini panels to custom categories.

Definition at line 167 of file panels_mini.install.

00167                                    {
00168   $ret = array();
00169   switch ($GLOBALS['db_type']) {
00170     case 'pgsql':
00171       db_add_column($ret, 'panels_mini', 'category', 'varchar(64)', array());
00172       break;
00173 
00174     case 'mysql':
00175     case 'mysqli':
00176       $ret[] = update_sql("ALTER TABLE {panels_mini} ADD COLUMN category varchar(64) AFTER name");
00177   }
00178   return $ret;
00179 }


Generated on Thu Sep 9 05:00:18 2010 for Panels 2 by  doxygen 1.5.6