C_NggLegacy_Installer

The NextGEN Gallery C NggLegacy Installer class.

Defined (1)

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

/products/photocrati_nextgen/modules/ngglegacy/module.ngglegacy.php  
  1. class C_NggLegacy_Installer 
  2. function install() 
  3. global $wpdb; 
  4. include_once('admin/install.php'); 
  5.  
  6. $this->remove_transients(); 
  7.  
  8. if (is_multisite()) { 
  9. $network=isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:""; 
  10. $activate=isset($_GET['action'])?$_GET['action']:""; 
  11. $isNetwork=($network=='/wp-admin/network/plugins.php')?true:false; 
  12. $isActivation=($activate=='deactivate')?false:true; 
  13.  
  14. if ($isNetwork and $isActivation) { 
  15. $old_blog = $wpdb->blogid; 
  16. $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs", NULL)); 
  17. foreach ($blogids as $blog_id) { 
  18. switch_to_blog($blog_id); 
  19. nggallery_install($this); 
  20. switch_to_blog($old_blog); 
  21. return; 
  22. // remove the update message 
  23. delete_option( 'ngg_update_exists' ); 
  24. nggallery_install($this); 
  25.  
  26. function uninstall($hard=FALSE) 
  27. include_once('admin/install.php'); 
  28. if ($hard) { 
  29. delete_option('ngg_init_check'); 
  30. delete_option('ngg_update_exists'); 
  31. delete_option( 'ngg_options' ); 
  32. delete_option( 'ngg_db_version' ); 
  33. delete_option( 'ngg_update_exists' ); 
  34. delete_option( 'ngg_next_update' ); 
  35.  
  36. // now remove the capability 
  37. ngg_remove_capability("NextGEN Gallery overview"); 
  38. ngg_remove_capability("NextGEN Use TinyMCE"); 
  39. ngg_remove_capability("NextGEN Upload images"); 
  40. ngg_remove_capability("NextGEN Manage gallery"); 
  41. ngg_remove_capability("NextGEN Edit album"); 
  42. ngg_remove_capability("NextGEN Change style"); 
  43. ngg_remove_capability("NextGEN Change options"); 
  44. ngg_remove_capability("NextGEN Attach Interface"); 
  45.  
  46. $this->remove_transients(); 
  47.  
  48. function remove_transients() 
  49. global $wpdb, $_wp_using_ext_object_cache; 
  50.  
  51. // Fetch all transients 
  52. $query = " 
  53. SELECT option_name FROM {$wpdb->options} 
  54. WHERE option_name LIKE '%ngg_request%' 
  55. "; 
  56. $transient_names = $wpdb->get_col($query);; 
  57.  
  58. // Delete all transients in the database 
  59. $query = " 
  60. DELETE FROM {$wpdb->options} 
  61. WHERE option_name LIKE '%ngg_request%' 
  62. "; 
  63. $wpdb->query($query); 
  64.  
  65. // If using an external caching mechanism, delete the cached items 
  66. if ($_wp_using_ext_object_cache) { 
  67. foreach ($transient_names as $transient) { 
  68. wp_cache_delete($transient, 'transient'); 
  69. wp_cache_delete(substr($transient, 11), 'transient'); 
  70.  
  71. function upgrade_schema($sql) 
  72. global $wpdb; 
  73.  
  74. // upgrade function changed in WordPress 2.3 
  75. require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
  76.  
  77. // add charset & collate like wp core 
  78. $charset_collate = ''; 
  79.  
  80. if ( version_compare($wpdb->get_var("SELECT VERSION() AS `mysql_version`"), '4.1.0', '>=') ) { 
  81. if ( ! empty($wpdb->charset) ) 
  82. $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 
  83. if ( ! empty($wpdb->collate) ) 
  84. $charset_collate .= " COLLATE $wpdb->collate"; 
  85.  
  86. // Add charset to table creation query 
  87. $sql = str_replace($charset_collate, '', str_replace(';', '', $sql)); 
  88.  
  89. // Execute the query 
  90. return dbDelta($sql. ' '. $charset_collate. ';');