nggallery_install

Creates all tables for the gallery called during register_activation hook.

Description

nggallery_install( $installer ); 

Parameters (1)

0. $installer
The installer.

Usage

  1. if ( !function_exists( 'nggallery_install' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/install.php'; 
  3.  
  4. // The installer. 
  5. $installer = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = nggallery_install($installer); 
  9.  

Defined (1)

The function is defined in the following location(s).

/products/photocrati_nextgen/modules/ngglegacy/admin/install.php  
  1. function nggallery_install($installer) 
  2.  
  3. global $wpdb , $wp_roles, $wp_version; 
  4.  
  5. // Set the capabilities for the administrator 
  6. $role = get_role('administrator'); 
  7. // We need this role, no other chance 
  8. if ( empty($role) ) { 
  9. update_option( "ngg_init_check", __('Sorry, NextGEN Gallery works only with a role called administrator', "nggallery") ); 
  10. return; 
  11.  
  12. $role->add_cap('NextGEN Gallery overview'); 
  13. $role->add_cap('NextGEN Use TinyMCE'); 
  14. $role->add_cap('NextGEN Upload images'); 
  15. $role->add_cap('NextGEN Manage gallery'); 
  16. $role->add_cap('NextGEN Manage tags'); 
  17. $role->add_cap('NextGEN Manage others gallery'); 
  18. $role->add_cap('NextGEN Edit album'); 
  19. $role->add_cap('NextGEN Change style'); 
  20. $role->add_cap('NextGEN Change options'); 
  21. $role->add_cap('NextGEN Attach Interface'); 
  22.  
  23. $nggpictures = $wpdb->prefix . 'ngg_pictures'; 
  24. $nggallery = $wpdb->prefix . 'ngg_gallery'; 
  25. $nggalbum = $wpdb->prefix . 'ngg_album'; 
  26.  
  27. // Create pictures table 
  28. $sql = "CREATE TABLE " . $nggpictures . " ( 
  29. pid BIGINT(20) NOT NULL AUTO_INCREMENT ,  
  30. image_slug VARCHAR(255) NOT NULL ,  
  31. post_id BIGINT(20) DEFAULT '0' NOT NULL ,  
  32. galleryid BIGINT(20) DEFAULT '0' NOT NULL ,  
  33. filename VARCHAR(255) NOT NULL ,  
  34. description MEDIUMTEXT NULL ,  
  35. alttext MEDIUMTEXT NULL ,  
  36. imagedate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',  
  37. exclude TINYINT NULL DEFAULT '0' ,  
  38. sortorder BIGINT(20) DEFAULT '0' NOT NULL ,  
  39. meta_data LONGTEXT,  
  40. extras_post_id BIGINT(20) DEFAULT '0' NOT NULL,  
  41. PRIMARY KEY (pid),  
  42. KEY extras_post_id_key (extras_post_id) 
  43. );"; 
  44. $installer->upgrade_schema($sql); 
  45.  
  46. // Create gallery table 
  47. $sql = "CREATE TABLE " . $nggallery . " ( 
  48. gid BIGINT(20) NOT NULL AUTO_INCREMENT ,  
  49. name VARCHAR(255) NOT NULL ,  
  50. slug VARCHAR(255) NOT NULL ,  
  51. path MEDIUMTEXT NULL ,  
  52. title MEDIUMTEXT NULL ,  
  53. galdesc MEDIUMTEXT NULL ,  
  54. pageid BIGINT(20) DEFAULT '0' NOT NULL ,  
  55. previewpic BIGINT(20) DEFAULT '0' NOT NULL ,  
  56. author BIGINT(20) DEFAULT '0' NOT NULL ,  
  57. extras_post_id BIGINT(20) DEFAULT '0' NOT NULL,  
  58. PRIMARY KEY (gid),  
  59. KEY extras_post_id_key (extras_post_id) 
  60. )"; 
  61. $installer->upgrade_schema($sql); 
  62.  
  63. // Create albums table 
  64. $sql = "CREATE TABLE " . $nggalbum . " ( 
  65. id BIGINT(20) NOT NULL AUTO_INCREMENT ,  
  66. name VARCHAR(255) NOT NULL ,  
  67. slug VARCHAR(255) NOT NULL ,  
  68. previewpic BIGINT(20) DEFAULT '0' NOT NULL ,  
  69. albumdesc MEDIUMTEXT NULL ,  
  70. sortorder LONGTEXT NOT NULL,  
  71. pageid BIGINT(20) DEFAULT '0' NOT NULL,  
  72. extras_post_id BIGINT(20) DEFAULT '0' NOT NULL,  
  73. PRIMARY KEY (id),  
  74. KEY extras_post_id_key (extras_post_id) 
  75. )"; 
  76. $installer->upgrade_schema($sql); 
  77.  
  78. // check one table again, to be sure 
  79. if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggpictures'" ) ) { 
  80. update_option( "ngg_init_check", __('NextGEN Gallery : Tables could not created, please check your database settings', "nggallery") ); 
  81. return; 
  82.  
  83. // if all is passed , save the DBVERSION 
  84. add_option("ngg_db_version", NGG_DBVERSION); 
  85.