Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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
  • 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:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Frederic Schneider
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Class for change active status of installed plugins, extends PimPluginSetup
 20:  *
 21:  * @package Plugin
 22:  * @subpackage PluginManager
 23:  * @author frederic.schneider
 24:  */
 25: class PimPluginSetupStatus extends PimPluginSetup {
 26: 
 27:     // Classes
 28:     // Class variable for PimPluginCollection
 29:     protected $_PimPluginCollection;
 30: 
 31:     // Class variable for PimPluginRelationsCollection
 32:     protected $_PimPluginRelationsCollection;
 33: 
 34:     // Class variable for cApiNavSubCollection
 35:     protected $_ApiNavSubCollection;
 36: 
 37:     /**
 38:      * Initializing and set variable for PimPluginCollection class
 39:      *
 40:      * @access private
 41:      * @return PimPluginCollection
 42:      */
 43:     private function _setPimPluginCollection() {
 44:         return $this->_PimPluginCollection = new PimPluginCollection();
 45:     }
 46: 
 47:     /**
 48:      * Initializing and set variable for PimPluginRelationsCollection class
 49:      *
 50:      * @access private
 51:      * @return PimPluginRelationsCollection
 52:      */
 53:     private function _setPimPluginRelationsCollection() {
 54:         return $this->_PimPluginRelationsCollection = new PimPluginRelationsCollection();
 55:     }
 56: 
 57:     /**
 58:      * Initializing and set variable for cApiNavSubCollection
 59:      *
 60:      * @access private
 61:      * @return cApiNavSubCollection
 62:      */
 63:     private function _setApiNavSubCollection() {
 64:         return $this->_ApiNavSubCollection = new cApiNavSubCollection();
 65:     }
 66: 
 67:     // Begin of installation routine
 68:     /**
 69:      * Construct function
 70:      *
 71:      * @access public
 72:      * @return void
 73:      */
 74:     public function __construct() {
 75: 
 76:         // Initializing and set classes
 77:         // PluginManager classes
 78:         $this->_setPimPluginCollection();
 79:         $this->_setPimPluginRelationsCollection();
 80: 
 81:         // cApiClasses
 82:         $this->_setApiNavSubCollection();
 83:     }
 84: 
 85:     /**
 86:      * Change plugin active status
 87:      *
 88:      * @access public
 89:      * @param integer $pluginId
 90:      * @return void
 91:      */
 92:     public function changeActiveStatus($pluginId) {
 93: 
 94:         // Build WHERE-Query for *_plugin table with $pluginId as parameter
 95:         $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 96:         $this->_PimPluginCollection->query();
 97:         $plugin = $this->_PimPluginCollection->next();
 98: 
 99:         // Get name of selected plugin and his active status
100:         $pluginName = $plugin->get('name');
101:         $pluginActiveStatus = $plugin->get('active');
102: 
103:         // get relations
104:         $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
105:         $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
106:         $this->_PimPluginRelationsCollection->query();
107: 
108:         if ($pluginActiveStatus == 1) { // Plugin is online and now we change
109:                                         // status to offline
110:             $plugin->set('active', 0);
111:             $plugin->store();
112: 
113:             // If this plugin has some navSub entries, we must also change menu
114:             // status to offline
115:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
116:                 $idnavs = $relation->get('iditem');
117:                 $this->changeNavSubStatus($idnavs, 0);
118:             }
119: 
120:             parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'));
121:         } else { // Plugin is offline and now we change status to online
122:             $plugin->set('active', 1);
123:             $plugin->store();
124: 
125:             // If this plugin has some navSub entries, we must also change menu
126:             // status to online
127:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
128:                 $idnavs = $relation->get('iditem');
129:                 $this->changeNavSubStatus($idnavs, 1);
130:             }
131: 
132:             parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'));
133:         }
134:     }
135: 
136:     /**
137:      * Change *_nav_sub online status
138:      *
139:      * @access private
140:      * @param integer $idnavs (equivalent to column name)
141:      * @param boolean $online (equivalent to column name)
142:      * @return true
143:      */
144:     private function changeNavSubStatus($idnavs, $online) {
145:         $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
146:         $this->_ApiNavSubCollection->query();
147: 
148:         $navSub = $this->_ApiNavSubCollection->next();
149:         $navSub->set('online', cSecurity::toInteger($online));
150:         $navSub->store();
151: 
152:         return true;
153:     }
154: 
155: }
156: ?>
CMS CONTENIDO 4.9.2 API documentation generated by ApiGen 2.8.0