예제 #1
0
 private function getPluginActiveTypesAndFolders()
 {
     if ($this->memCache) {
         $memCacheAllPluginDetails = $this->memCache->read('allPluginDetails');
         $memCachePlugins = $this->memCache->read('plugins');
         if ($memCacheAllPluginDetails && $memCachePlugins) {
             $this->allPluginDetails = $memCacheAllPluginDetails;
             $this->plugins = $memCachePlugins;
             return true;
         }
     }
     $pluginsRawData = \Hotaru\Models2\Plugin::getAllDetails($this);
     $this->allPluginDetails['pluginData'] = array();
     if ($pluginsRawData) {
         foreach ($pluginsRawData as $plugin) {
             $this->allPluginDetails['pluginData'][$plugin->plugin_folder] = $plugin;
             $this->allPluginDetails['pluginFolderIndexOnClass'][$plugin->plugin_class] = $plugin->plugin_folder;
         }
     }
     // hooks
     //$h->allPluginDetails['hooks'] = \Hotaru\Models\Pluginhook::getAllEnabled();
     $this->allPluginDetails['hooks'] = \Hotaru\Models2\Pluginhook::getAllEnabled($this);
     // turn this into an index based array as it runs faster than later calling an array_in func
     // we are going to be using isset funcs later with this
     // http://nickology.com/2012/07/03/php-faster-array-lookup-than-using-in_array/
     if ($this->allPluginDetails['hooks']) {
         foreach ($this->allPluginDetails['hooks'] as $hook) {
             $this->allPluginDetails['hookdata'][$hook->plugin_hook][$hook->plugin_folder] = 1;
         }
     }
     // this was the old function here originally just getting the active plugins
     //$plugins = \Hotaru\Models\Plugin::getAllActiveNames()->toArray();
     //$plugins = \Hotaru\Models2\Plugin::getAllActiveNames($this);
     $plugins = $this->allPluginDetails['pluginData'];
     //[$plugin->plugin_folder] = $plugin;
     foreach ($plugins as $plugin) {
         if ($plugin->plugin_enabled) {
             if ($plugin->plugin_type) {
                 $this->plugins['activeTypes'][$plugin->plugin_type] = 1;
             }
             $this->plugins['activeFolders'][$plugin->plugin_folder] = 1;
         }
     }
     if ($this->memCache) {
         $this->memCache->write('allPluginDetails', $this->allPluginDetails, 10000);
         $this->memCache->write('plugins', $this->plugins, 10000);
     }
 }
예제 #2
0
 /**
  * Delete plugin from table_plugins, pluginhooks and pluginsettings
  *
  * @param int $upgrade flag to disable message
  */
 public function uninstall($h, $upgrade = 0, $clearCache = true)
 {
     if ($clearCache) {
         // Clear the database cache to ensure plugins and hooks are up-to-date.
         $h->deleteFiles(CACHE . 'db_cache');
         // Clear the css/js cache to ensure this plugin's files are removed
         $h->deleteFiles(CACHE . 'css_js_cache');
         // Clear the language cache to ensure any new language files get included
         $h->clearCache('lang_cache', false);
         $h->messages['db, css, language caches cleared'] = 'alert-info';
     }
     if ($upgrade == 0) {
         // don't delete plugin when we're upgrading
         $h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINS . " WHERE plugin_folder = %s", $h->plugin->folder));
     }
     \Hotaru\Models2\Pluginhook::removeHook($h, $h->plugin->folder);
     //$h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINHOOKS . " WHERE plugin_folder = %s", $h->plugin->folder));
     // Settings aren't deleted anymore, but a user can do so manually from Admin->Maintenance
     //$h->db->query($h->db->prepare("DELETE FROM " . TABLE_PLUGINSETTINGS . " WHERE plugin_folder = %s", $h->plugin->folder));
     $h->pluginHook('uninstall_plugin', $h->plugin->folder);
     if ($upgrade == 0) {
         $h->messages[$h->lang("admin_plugins_uninstall_done")] = 'green';
     }
     // Re-sort all orders and remove any accidental gaps
     $this->refreshPluginOrder($h);
     $this->sortPluginHooks($h);
 }
예제 #3
0
 /**
  * Store all plugin details for ALL PLUGINS info in memory. This is a single query
  * per page load unless cached. Every thing else then draws what it needs from memory.
  */
 public static function getAllPluginDetails($h)
 {
     // to much overhead to call it like this and leave as object.
     // but if we change to array and make list below as that then we have to convert all other uses to array as well
     // $pluginsRawData = \Hotaru\Models\Plugin::getAllDetails();
     // NB both active and nonactive need to be read in
     //  $sql = "SELECT * FROM " . TABLE_PLUGINS . " ORDER BY plugin_order ASC";
     //  $pluginsRawData = $h->db->get_results($sql);
     //print "getAllPluginDetails *** <br/>*****<br/>*** <br/>*****<br/>";
     $pluginsRawData = \Hotaru\Models2\Plugin::getAllDetails($h);
     $h->allPluginDetails['pluginData'] = array();
     if ($pluginsRawData) {
         foreach ($pluginsRawData as $plugin) {
             $h->allPluginDetails['pluginData'][$plugin->plugin_folder] = $plugin;
             $h->allPluginDetails['pluginFolderIndexOnClass'][$plugin->plugin_class] = $plugin->plugin_folder;
         }
     }
     // hooks
     //$h->allPluginDetails['hooks'] = \Hotaru\Models\Pluginhook::getAllEnabled();
     $h->allPluginDetails['hooks'] = \Hotaru\Models2\Pluginhook::getAllEnabled($h);
     //print_r($h->allPluginDetails['hooks']);
     // turn this into an index based array as it runs faster than later calling an array_in func
     // we are going to be using isset funcs later with this
     // http://nickology.com/2012/07/03/php-faster-array-lookup-than-using-in_array/
     if ($h->allPluginDetails['hooks']) {
         foreach ($h->allPluginDetails['hooks'] as $hooks) {
             $h->allPluginDetails['hookdata'][$hooks->plugin_hook][$hooks->plugin_folder] = 1;
         }
     }
 }