Пример #1
0
 /**
  * Enables or disables all plugins, installing if necessary
  *
  * @param int $enabled 
  * Note: This function does not uninstall/delete a plugin.
  */
 public function activateDeactivateDo($h, $plugin, $newStatus = 0)
 {
     // 0 = deactivate, 1 = activate
     // The plugin is already installed. Activate or deactivate according to $enabled (the user's action).
     if ($plugin->plugin_enabled == $newStatus) {
         return false;
     }
     // only update if we're changing the enabled value.
     //$result = \Hotaru\Models\Plugin::updateEnabled($h->plugin->folder, $newStatus, $h->currentUser->id);
     $result = \Hotaru\Models2\Plugin::updateEnabled($h, $plugin->plugin_folder, $newStatus, $h->currentUser->id);
     if ($newStatus == 1) {
         // Activating now...
         // Get plugin version from the database...
         $db_version = \Hotaru\Models2\Plugin::getVersionNumber($h, $plugin->plugin_folder);
         //$db_version = $h->getPluginVersion($plugin->plugin_folder);
         // Get plugin version from the file....
         $plugin_metadata = $this->readPluginMeta($plugin->plugin_folder);
         if (!$plugin_metadata) {
             return false;
         }
         $file_version = $plugin_metadata['version'];
         // If file version is newer the the current plugin version, then upgrade...
         if (version_compare($file_version, $db_version, '>')) {
             $this->upgrade($h);
             // runs the install function and shows "upgraded!" message instead of "installed".
         } else {
             // else simply show an activated message...
             $h->messages[$h->lang("admin_plugins_activated")] = 'green';
         }
         // Force inclusion of a language file (if exists) because the
         // plugin isn't ready to include it itself yet.
         $h->includeLanguage();
     }
     if ($newStatus == 0) {
         $h->messages[$h->lang("admin_plugins_deactivated")] = 'green';
     }
     //$h->pluginHook('activate_deactivate', '', array('enabled' => $newStatus));
     // if save fails then return error
     return true;
 }
Пример #2
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);
     }
 }
Пример #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;
         }
     }
 }
Пример #4
0
if ($h->pageTitle == 'Plugin Management') {
    echo 'class="active"';
}
?>
 role="presentation"><a href="<?php 
echo SITEURL;
?>
admin_index.php?page=plugin_management"><i class="menu-icon fa fa-puzzle-piece"></i><span class="menu-text"><?php 
echo $h->lang("admin_theme_plugins");
?>
</span></a></li>
	
        <?php 
$pluginFunc = new \Libs\PluginFunctions();
//$pluginLinks = \Hotaru\Models\Plugin::getAllActiveNamesOrderByName();
$pluginLinks = \Hotaru\Models2\Plugin::getAllActiveNamesOrderByName($h);
?>
        
        
	<!-- Plugins -->       
        
        <?php 
if ($h->isActive('user_manager')) {
    echo '<li role="presentation" class="nav-header" style="cursor:pointer;" data-toggle="collapse" data-target="#admin_users_list"><a href="#"><i class="menu-icon fa fa-user"></i><span class="menu-text">' . $h->lang("admin_theme_users") . '</span></a>';
    echo '<div id="admin_users_list" class="collapse out">';
    echo '<ul id="users_list">';
    $pluginResult = $h->pluginHook('admin_sidebar_users');
    echo $adminPages->sidebarPluginsList($h, $pluginResult);
    echo '<li><a href="/admin_index.php?page=stats_users">Stats</a></li>';
    echo '</ul>';
    echo '</div>';
Пример #5
0
 /**
  * Calls external site to get latest available hotaru version number
  *
  * @return bool true
  */
 public function plugin_version_getAll($h)
 {
     //		$query_vals = array(
     //		    'api_key' => '',
     //		    'format' => 'json',
     //		    'method' => 'hotaru.plugin.version.getAll'
     //		);
     //$info = $this->sendApiRequest($h, $query_vals, $this->pluginUrl);
     // temp until api can handle children of resources
     //  make array
     $resourceIds = array(1, 2, 3, 4, 6, 12, 14, 16);
     $resourceList = array();
     foreach ($resourceIds as $resourceId) {
         $query_vals = array('hash' => 'r2FBq73aY1dD3yA604cG25AU30HfKyEE', 'format' => 'json', 'action' => 'getResources', 'category_id' => $resourceId);
         $info = $this->sendApiRequest($h, $query_vals, $this->forumUrl);
         if ($info) {
             foreach ($info['resources'] as $resource) {
                 $resourceList[$resource['title']] = $resource;
             }
         }
     }
     $updateQuery = "";
     // Update the plugin in db using resourceName and the array for that from above
     foreach ($resourceList as $plugin) {
         // was hoping to check first whether version number changed but forums returns plugin name not folder
         //if (!isset($h->allPluginDetails['pluginData'][$plugin['title']])) { continue; }
         //if ($plugin['version_string'] > $h->allPluginDetails['pluginData'][$plugin['title']]->plugin_version) {
         //$result = \Hotaru\Models\Plugin::makeUpdate($plugin['title'], $plugin, $h->currentUser->id);
         $result = \Hotaru\Models2\Plugin::makeUpdate($h, $plugin['title'], $plugin, $h->currentUser->id);
         //}
     }
     return true;
 }