/[drupal]/contributions/modules/authorship/authorship.install
ViewVC logotype

Diff of /contributions/modules/authorship/authorship.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8, Thu Jan 3 16:23:39 2008 UTC revision 1.9, Sat Oct 11 12:22:16 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: authorship.install,v 1.7 2007/07/12 22:21:22 karpuz Exp $  // $Id: authorship.install,v 1.5.2.1 2007/07/12 22:05:55 karpuz Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 10  Line 10 
10   * AjK, June 2006   * AjK, June 2006
11   */   */
12    
13  if (!function_exists('authorship_install')) {  /**
14    function authorship_install() {   * v6.x-dev written by matt_b
15      $created = FALSE;   */
     switch ($GLOBALS['db_type']) {  
       case 'mysql':  
       case 'mysqli':  
         $query1 = db_query("CREATE TABLE IF NOT EXISTS {node_authorship} (".  
                            "nid INT(10) NOT NULL DEFAULT 0,".  
                            "cid INT(10) NOT NULL DEFAULT 0,".  
                            "authorship VARCHAR(255) NOT NULL DEFAULT '',".  
                            "profile_real_name INT(2) DEFAULT 0, ".  
                            "PRIMARY KEY (nid, cid),".  
                            "INDEX(authorship(8))".  
                            ") /*!40100 DEFAULT CHARACTER SET utf8 */");  
         if($query1) {  
           $created = TRUE;  
         }  
         break;  
   
       case 'pgsql':  
         $query1 = db_query("CREATE TABLE {node_authorship} (".  
                            "nid INT NOT NULL DEFAULT 0,".  
                            "cid INT NOT NULL DEFAULT 0,".  
                            "authorship VARCHAR(255) NOT NULL DEFAULT '',".  
                            "profile_real_name SMALLINT DEFAULT 0, ".  
                            "PRIMARY KEY (nid, cid))");  
         $query2 =  db_query("CREATE INDEX node_authorship_idx ON {node_authorship} (authorship);");  
         if($query1 && $query2) {  
           $created = TRUE;  
         }  
         break;  
     } // end switch  
   
     // sink module's weight to the deepest depths of the module_list()  
     db_query("UPDATE {system} SET weight = %d WHERE name = '%s'",  
       1001, 'node_authorship');  
   
     // provide the user with some install feedback  
     if ($created) {  
       drupal_set_message(t('Authorship database tables installed'));  
     }  
     else {  
       drupal_set_message(t('Table install for Authorship was unsuccessful.'));  
     }  
   } // end function  
 } // end !function_exists()  
16    
17    function authorship_schema() {
18            $schema['node_authorship'] = array(
19                    'fields' => array(
20                             'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
21                             'cid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
22                             'authorship' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
23                             'profile_real_name' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '2')),
24                    'primary key' => array('nid', 'cid'),
25                    'indexes' => array(
26                             'authorship' => array(array('authorship', 8))),
27            );
28    
29            return $schema;
30    }
31    
32    /*
33    This need to be converted.  For the moment, this module assumes that the latest 5.x version was used
34    
35  function authorship_update_1() {  function authorship_update_1() {
36    $items = array();    $items = array();
# Line 78  function authorship_update_2() { Line 52  function authorship_update_2() {
52    $items[] = update_sql("ALTER TABLE {node_authorship} ADD PRIMARY KEY (nid, cid)");    $items[] = update_sql("ALTER TABLE {node_authorship} ADD PRIMARY KEY (nid, cid)");
53    return $items;    return $items;
54  }  }
   
 /**  
 * Implementation of hook_uninstall().  
55  */  */
56    
57    function authorship_install() {
58      // Create my tables.
59      drupal_install_schema('authorship');
60    }
61    
62  function authorship_uninstall() {  function authorship_uninstall() {
   if(db_table_exists('{node_authorship}')) {  
      db_query('DROP TABLE {node_authorship}');  
   }  
   // delete variables  
   $node_types = node_get_types('names');  
   $node_types = array_keys($node_types);  
   $node_types[] = 'comment';  
   foreach($node_types as $node_type) {  
     variable_del('authorship_real_name_' . $node_type);  
     variable_del('authorship_' . $node_type);  
   }  
 }  
63      // Drop my tables.
64      drupal_uninstall_schema('authorship');
65    }
66    ?>

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.2