| webmaster@1 | 1 <?php | 
| franck@19 | 2 // $Id: blogapi.install,v 1.1.2.2 2009/01/06 15:46:36 goba Exp $ | 
| webmaster@9 | 3 | 
| webmaster@9 | 4 /** | 
| webmaster@9 | 5  * Implementation of hook_install(). | 
| webmaster@9 | 6  */ | 
| webmaster@9 | 7 function blogapi_install() { | 
| webmaster@9 | 8   // Create tables. | 
| webmaster@9 | 9   drupal_install_schema('blogapi'); | 
| webmaster@9 | 10 } | 
| webmaster@9 | 11 | 
| webmaster@9 | 12 /** | 
| webmaster@9 | 13  * Implementation of hook_uninstall(). | 
| webmaster@9 | 14  */ | 
| webmaster@9 | 15 function blogapi_uninstall() { | 
| webmaster@9 | 16   // Remove tables. | 
| webmaster@9 | 17   drupal_uninstall_schema('blogapi'); | 
| webmaster@9 | 18 } | 
| webmaster@9 | 19 | 
| webmaster@9 | 20 | 
| webmaster@9 | 21 /** | 
| webmaster@9 | 22  * Implementation of hook_schema(). | 
| webmaster@9 | 23  */ | 
| webmaster@9 | 24 function blogapi_schema() { | 
| webmaster@9 | 25   //This table was introduced in Drupal 6.4 | 
| webmaster@9 | 26   $schema['blogapi_files'] = array( | 
| franck@19 | 27     'description' => 'Stores information for files uploaded via the blogapi.', | 
| webmaster@9 | 28     'fields' => array( | 
| webmaster@9 | 29       'fid' => array( | 
| franck@19 | 30         'description' => 'Primary Key: Unique file ID.', | 
| webmaster@9 | 31         'type' => 'serial', | 
| webmaster@9 | 32       ), | 
| webmaster@9 | 33       'uid' => array( | 
| franck@19 | 34         'description' => 'The {users}.uid of the user who is associated with the file.', | 
| webmaster@9 | 35         'type' => 'int', | 
| webmaster@9 | 36         'unsigned' => TRUE, | 
| webmaster@9 | 37         'not null' => TRUE, | 
| webmaster@9 | 38         'default' => 0), | 
| webmaster@9 | 39       'filepath' => array( | 
| franck@19 | 40         'description' => 'Path of the file relative to Drupal root.', | 
| webmaster@9 | 41         'type' => 'varchar', | 
| webmaster@9 | 42         'length' => 255, | 
| webmaster@9 | 43         'not null' => TRUE, | 
| webmaster@9 | 44         'default' => ''), | 
| webmaster@9 | 45       'filesize' => array( | 
| franck@19 | 46         'description' => 'The size of the file in bytes.', | 
| webmaster@9 | 47         'type' => 'int', | 
| webmaster@9 | 48         'unsigned' => TRUE, | 
| webmaster@9 | 49         'not null' => TRUE, | 
| webmaster@9 | 50         'default' => 0), | 
| webmaster@9 | 51     ), | 
| webmaster@9 | 52     'primary key' => array('fid'), | 
| webmaster@9 | 53     'indexes' => array( | 
| webmaster@9 | 54       'uid' => array('uid'), | 
| webmaster@9 | 55     ), | 
| webmaster@9 | 56   ); | 
| webmaster@9 | 57 | 
| webmaster@9 | 58   return $schema; | 
| webmaster@9 | 59 } | 
| webmaster@1 | 60 | 
| webmaster@1 | 61 /** | 
| webmaster@1 | 62  * @defgroup updates-5.x-to-6.x Blog API updates from 5.x to 6.x | 
| webmaster@1 | 63  * @{ | 
| webmaster@1 | 64  */ | 
| webmaster@1 | 65 | 
| webmaster@1 | 66 /** | 
| webmaster@1 | 67  * Inform users about the new permission. | 
| webmaster@1 | 68  */ | 
| webmaster@1 | 69 function blogapi_update_6000() { | 
| webmaster@1 | 70   drupal_set_message("Blog API module does not depend on blog module's permissions anymore, but provides its own 'administer content with blog api' permission instead. Until <a href=\"". url('admin/user/permissions', array('fragment' => 'module-blogapi')) .'">this permission is assigned</a> to at least one user role, only the site administrator will be able to use Blog API features.'); | 
| webmaster@1 | 71   return array(); | 
| webmaster@1 | 72 } | 
| webmaster@1 | 73 | 
| webmaster@9 | 74 | 
| webmaster@9 | 75 /** | 
| webmaster@9 | 76  * Add blogapi_files table to enable size restriction for BlogAPI file uploads. | 
| webmaster@9 | 77  * | 
| webmaster@9 | 78  * This table was introduced in Drupal 6.4. | 
| webmaster@9 | 79  */ | 
| webmaster@9 | 80 function blogapi_update_6001() { | 
| webmaster@9 | 81     $schema['blogapi_files'] = array( | 
| franck@19 | 82     'description' => 'Stores information for files uploaded via the blogapi.', | 
| webmaster@9 | 83     'fields' => array( | 
| webmaster@9 | 84       'fid' => array( | 
| franck@19 | 85         'description' => 'Primary Key: Unique file ID.', | 
| webmaster@9 | 86         'type' => 'serial', | 
| webmaster@9 | 87       ), | 
| webmaster@9 | 88       'uid' => array( | 
| franck@19 | 89         'description' => 'The {users}.uid of the user who is associated with the file.', | 
| webmaster@9 | 90         'type' => 'int', | 
| webmaster@9 | 91         'unsigned' => TRUE, | 
| webmaster@9 | 92         'not null' => TRUE, | 
| webmaster@9 | 93         'default' => 0), | 
| webmaster@9 | 94       'filepath' => array( | 
| franck@19 | 95         'description' => 'Path of the file relative to Drupal root.', | 
| webmaster@9 | 96         'type' => 'varchar', | 
| webmaster@9 | 97         'length' => 255, | 
| webmaster@9 | 98         'not null' => TRUE, | 
| webmaster@9 | 99         'default' => ''), | 
| webmaster@9 | 100       'filesize' => array( | 
| franck@19 | 101         'description' => 'The size of the file in bytes.', | 
| webmaster@9 | 102         'type' => 'int', | 
| webmaster@9 | 103         'unsigned' => TRUE, | 
| webmaster@9 | 104         'not null' => TRUE, | 
| webmaster@9 | 105         'default' => 0), | 
| webmaster@9 | 106     ), | 
| webmaster@9 | 107     'primary key' => array('fid'), | 
| webmaster@9 | 108     'indexes' => array( | 
| webmaster@9 | 109       'uid' => array('uid'), | 
| webmaster@9 | 110     ), | 
| webmaster@9 | 111   ); | 
| webmaster@9 | 112 | 
| webmaster@9 | 113   $ret = array(); | 
| webmaster@9 | 114 | 
| webmaster@9 | 115   if (!db_table_exists('blogapi_files')) { | 
| webmaster@9 | 116     db_create_table($ret, 'blogapi_files', $schema['blogapi_files']); | 
| webmaster@9 | 117   } | 
| webmaster@9 | 118   return $ret; | 
| webmaster@9 | 119 } | 
| webmaster@9 | 120 | 
| webmaster@1 | 121 /** | 
| webmaster@1 | 122  * @} End of "defgroup updates-5.x-to-6.x" | 
| webmaster@1 | 123  * The next series of updates should start at 7000. | 
| webmaster@1 | 124  */ | 
| webmaster@9 | 125 |