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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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:         // Set pluginId
 87:         self::setPluginId($pluginId);
 88: 
 89:         // Build WHERE-Query for *_plugin table with $pluginId as parameter
 90:         $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
 91:         $this->_PimPluginCollection->query();
 92:         $plugin = $this->_PimPluginCollection->next();
 93: 
 94:         // Get name of selected plugin and his active status
 95:         $pluginName = $plugin->get('name');
 96:         $pluginActiveStatus = $plugin->get('active');
 97: 
 98:         // Get relations
 99:         $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
100:         $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
101:         $this->_PimPluginRelationsCollection->query();
102: 
103:         if ($pluginActiveStatus == 1) { // Plugin is online and now we change
104:                                         // status to offline
105: 
106:             // Dependencies check
107:             $this->_updateCheckDependencies();
108: 
109:             $plugin->set('active', 0);
110:             $plugin->store();
111: 
112:             // If this plugin has some navSub entries, we must also change menu
113:             // status to offline
114:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
115:                 $idnavs = $relation->get('iditem');
116:                 $this->_changeNavSubStatus($idnavs, 0);
117:             }
118: 
119:             parent::info(sprintf(i18n('The plugin <strong>%s</strong> has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'), $pluginName));
120:         } else { // Plugin is offline and now we change status to online
121:             $plugin->set('active', 1);
122:             $plugin->store();
123: 
124:             // If this plugin has some navSub entries, we must also change menu
125:             // status to online
126:             while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
127:                 $idnavs = $relation->get('iditem');
128:                 $this->_changeNavSubStatus($idnavs, 1);
129:             }
130: 
131:             parent::info(sprintf(i18n('The plugin <strong>%s</strong> has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'), $pluginName));
132:         }
133:     }
134: 
135:     /**
136:      * Check dependencies to other plugins (dependencies-Tag at plugin.xml)
137:      */
138:     private function _updateCheckDependencies() {
139: 
140:         // Call checkDepenendencies function at PimPlugin class
141:         // Function returns true or false
142:         $result = $this->checkDependencies();
143: 
144:         // Show an error message when dependencies could be found
145:         if ($result === false) {
146:             parent::error(sprintf(i18n('This plugin is required by the plugin <strong>%s</strong>, so you can not deactivate it.', 'pim'), parent::_getPluginName()));
147:         }
148:     }
149: 
150:     /**
151:      * Change *_nav_sub online status
152:      *
153:      * @param int $idnavs (equivalent to column name)
154:      * @param bool $online (equivalent to column name)
155:      * @return  bool true
156:      */
157:     private function _changeNavSubStatus($idnavs, $online) {
158:         $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
159:         $this->_ApiNavSubCollection->query();
160: 
161:         $navSub = $this->_ApiNavSubCollection->next();
162:         $navSub->set('online', cSecurity::toInteger($online));
163:         $navSub->store();
164: 
165:         return true;
166:     }
167: 
168: }
169: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen