Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • PimPlugin
  • PimPluginArchiveExtractor
  • PimPluginCollection
  • PimPluginRelations
  • PimPluginRelationsCollection
  • PimPluginSetup
  • PimPluginSetupInstall
  • PimPluginSetupStatus
  • PimPluginSetupUninstall
  • PimPluginSetupUpdate
  • PimPluginViewDependencies
  • PimPluginViewNavSub
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains abstract class for change status of installed plugins
  4:  *
  5:  * @package Plugin
  6:  * @subpackage PluginManager
  7:  * @author Frederic Schneider
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Class for change active status of installed plugins, extends PimPluginSetup
 18:  *
 19:  * @package Plugin
 20:  * @subpackage PluginManager
 21:  * @author frederic.schneider
 22:  */
 23: class PimPluginSetupStatus extends PimPluginSetup {
 24: 
 25:     // Classes
 26:     // Class variable for PimPluginCollection
 27:     protected $_PimPluginCollection;
 28: 
 29:     // Class variable for PimPluginRelationsCollection
 30:     protected $_PimPluginRelationsCollection;
 31: 
 32:     // Class variable for cApiNavSubCollection
 33:     protected $_ApiNavSubCollection;
 34: 
 35:     /**
 36:      * Initializing and set variable for PimPluginCollection class
 37:      *
 38:      * @return PimPluginCollection
 39:      */
 40:     private function _setPimPluginCollection() {
 41:         return $this->_PimPluginCollection = new PimPluginCollection();
 42:     }
 43: 
 44:     /**
 45:      * Initializing and set variable for PimPluginRelationsCollection class
 46:      *
 47:      * @return PimPluginRelationsCollection
 48:      */
 49:     private function _setPimPluginRelationsCollection() {
 50:         return $this->_PimPluginRelationsCollection = new PimPluginRelationsCollection();
 51:     }
 52: 
 53:     /**
 54:      * Initializing and set variable for cApiNavSubCollection
 55:      *
 56:      * @return cApiNavSubCollection
 57:      */
 58:     private function _setApiNavSubCollection() {
 59:         return $this->_ApiNavSubCollection = new cApiNavSubCollection();
 60:     }
 61: 
 62:     // Begin of installation routine
 63:     /**
 64:      * Construct function
 65:      */
 66:     public function __construct() {
 67: 
 68:         // Initializing and set classes
 69:         // PluginManager classes
 70:         $this->_setPimPluginCollection();
 71:         $this->_setPimPluginRelationsCollection();
 72: 
 73:         // cApiClasses
 74:         $this->_setApiNavSubCollection();
 75:     }
 76: 
 77:     /**
 78:      * Change plugin active status
 79:      *
 80:      * @param int $pluginId
 81:      */
 82:     public function changeActiveStatus($pluginId) {
 83: 
 84:         // Set pluginId
 85:         self::setPluginId($pluginId);
 86: 
 87:         // Build WHERE-Query for *_plugin table with $pluginId as parameter
 88:         $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 89:         $this->_PimPluginCollection->query();
 90:         $plugin = $this->_PimPluginCollection->next();
 91: 
 92:         // Get name of selected plugin and his active status
 93:         $pluginName = $plugin->get('name');
 94:         $pluginActiveStatus = $plugin->get('active');
 95: 
 96:         // Get relations
 97:         $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 98:         $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
 99:         $this->_PimPluginRelationsCollection->query();
100: 
101:         if ($pluginActiveStatus == 1) { // Plugin is online and now we change
102:                                         // status to offline
103: 
104:             // Dependencies check
105:             $this->_updateCheckDependencies();
106: 
107:             $plugin->set('active', 0);
108:             $plugin->store();
109: 
110:             // If this plugin has some navSub entries, we must also change menu
111:             // status to offline
112:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
113:                 $idnavs = $relation->get('iditem');
114:                 $this->_changeNavSubStatus($idnavs, 0);
115:             }
116: 
117:             parent::info(sprintf(i18n('The plugin <strong>%s</strong> has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'), $pluginName));
118:         } else { // Plugin is offline and now we change status to online
119:             $plugin->set('active', 1);
120:             $plugin->store();
121: 
122:             // If this plugin has some navSub entries, we must also change menu
123:             // status to online
124:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
125:                 $idnavs = $relation->get('iditem');
126:                 $this->_changeNavSubStatus($idnavs, 1);
127:             }
128: 
129:             parent::info(sprintf(i18n('The plugin <strong>%s</strong> has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'), $pluginName));
130:         }
131:     }
132: 
133:     /**
134:      * Check dependencies to other plugins (dependencies-Tag at plugin.xml)
135:      */
136:     private function _updateCheckDependencies() {
137: 
138:         // Call checkDepenendencies function at PimPlugin class
139:         // Function returns true or false
140:         $result = $this->checkDependencies();
141: 
142:         // Show an error message when dependencies could be found
143:         if ($result === false) {
144:             parent::error(sprintf(i18n('This plugin is required by the plugin <strong>%s</strong>, so you can not deactivate it.', 'pim'), parent::_getPluginName()));
145:         }
146:     }
147: 
148:     /**
149:      * Change *_nav_sub online status
150:      *
151:      * @param int $idnavs (equivalent to column name)
152:      * @param bool $online (equivalent to column name)
153:      * @return  bool true
154:      */
155:     private function _changeNavSubStatus($idnavs, $online) {
156:         $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
157:         $this->_ApiNavSubCollection->query();
158: 
159:         $navSub = $this->_ApiNavSubCollection->next();
160:         $navSub->set('online', cSecurity::toInteger($online));
161:         $navSub->store();
162: 
163:         return true;
164:     }
165: 
166: }
167: ?>
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0