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
  • 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:  * @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:      * @return PimPluginCollection
 41:      */
 42:     private function _setPimPluginCollection() {
 43:         return $this->_PimPluginCollection = new PimPluginCollection();
 44:     }
 45: 
 46:     /**
 47:      * Initializing and set variable for PimPluginRelationsCollection class
 48:      *
 49:      * @return PimPluginRelationsCollection
 50:      */
 51:     private function _setPimPluginRelationsCollection() {
 52:         return $this->_PimPluginRelationsCollection = new PimPluginRelationsCollection();
 53:     }
 54: 
 55:     /**
 56:      * Initializing and set variable for cApiNavSubCollection
 57:      *
 58:      * @return cApiNavSubCollection
 59:      */
 60:     private function _setApiNavSubCollection() {
 61:         return $this->_ApiNavSubCollection = new cApiNavSubCollection();
 62:     }
 63: 
 64:     // Begin of installation routine
 65:     /**
 66:      * Construct function
 67:      */
 68:     public function __construct() {
 69: 
 70:         // Initializing and set classes
 71:         // PluginManager classes
 72:         $this->_setPimPluginCollection();
 73:         $this->_setPimPluginRelationsCollection();
 74: 
 75:         // cApiClasses
 76:         $this->_setApiNavSubCollection();
 77:     }
 78: 
 79:     /**
 80:      * Change plugin active status
 81:      *
 82:      * @param int $pluginId
 83:      */
 84:     public function changeActiveStatus($pluginId) {
 85: 
 86:         // Build WHERE-Query for *_plugin table with $pluginId as parameter
 87:         $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 88:         $this->_PimPluginCollection->query();
 89:         $plugin = $this->_PimPluginCollection->next();
 90: 
 91:         // Get name of selected plugin and his active status
 92:         $pluginName = $plugin->get('name');
 93:         $pluginActiveStatus = $plugin->get('active');
 94: 
 95:         // get relations
 96:         $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 97:         $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
 98:         $this->_PimPluginRelationsCollection->query();
 99: 
100:         if ($pluginActiveStatus == 1) { // Plugin is online and now we change
101:                                         // status to offline
102:             $plugin->set('active', 0);
103:             $plugin->store();
104: 
105:             // If this plugin has some navSub entries, we must also change menu
106:             // status to offline
107:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
108:                 $idnavs = $relation->get('iditem');
109:                 $this->changeNavSubStatus($idnavs, 0);
110:             }
111: 
112:             parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'));
113:         } else { // Plugin is offline and now we change status to online
114:             $plugin->set('active', 1);
115:             $plugin->store();
116: 
117:             // If this plugin has some navSub entries, we must also change menu
118:             // status to online
119:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
120:                 $idnavs = $relation->get('iditem');
121:                 $this->changeNavSubStatus($idnavs, 1);
122:             }
123: 
124:             parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'));
125:         }
126:     }
127: 
128:     /**
129:      * Change *_nav_sub online status
130:      *
131:      * @param int $idnavs (equivalent to column name)
132:      * @param bool $online (equivalent to column name)
133:      * @return  bool true
134:      */
135:     private function changeNavSubStatus($idnavs, $online) {
136:         $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
137:         $this->_ApiNavSubCollection->query();
138: 
139:         $navSub = $this->_ApiNavSubCollection->next();
140:         $navSub->set('online', cSecurity::toInteger($online));
141:         $navSub->store();
142: 
143:         return true;
144:     }
145: 
146: }
147: ?>
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0