oxmodule.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxModule extends oxSuperCfg
00008 {
00014     protected $_aModule = array();
00015 
00021     protected $_blMetadata   = false;
00022 
00028     protected $_blRegistered = false;
00029 
00035     protected $_blFile       = false;
00036 
00042     protected $_blLegacy     = false;
00043 
00051     public function setModuleData( $aModule )
00052     {
00053         $this->_aModule = $aModule;
00054     }
00055 
00063     public function load( $sModuleId )
00064     {
00065         if ( $this->loadModule($sModuleId) ) return true;
00066 
00067         if ( $this->loadLegacyModule($sModuleId) ) return true;
00068 
00069         if ( $this->loadUnregisteredModule($sModuleId) ) return true;
00070 
00071         return false;
00072     }
00073 
00081     public function loadByDir( $sModuleDir )
00082     {
00083         $sModuleId    = null;
00084         $aModulePaths = $this->getModulePaths();
00085 
00086         if ( is_array($aModulePaths) ) {
00087             $sModuleId = array_search( $sModuleDir, $aModulePaths);
00088         }
00089 
00090         // if no module id defined, using module dir as id
00091         if ( !$sModuleId ) {
00092             $sModuleId = $sModuleDir;
00093         }
00094 
00095         return $this->load( $sModuleId );
00096     }
00097 
00105     public function loadModule( $sModuleId )
00106     {
00107         $sModulePath = $this->getModuleFullPath( $sModuleId );
00108         $sMetadataPath = $sModulePath . "/metadata.php";
00109 
00110         if ( $sModulePath && file_exists( $sMetadataPath ) && is_readable( $sMetadataPath ) ) {
00111             $aModule = array();
00112             include $sMetadataPath;
00113             $this->_aModule = $aModule;
00114             $this->_blLegacy      = false;
00115             $this->_blRegistered  = true;
00116             $this->_blMetadata    = true;
00117             $this->_blFile        = false;
00118             $this->_aModule['active'] = $this->isActive() || !$this->isExtended();
00119             return true;
00120         }
00121         return false;
00122     }
00123 
00131     public function loadLegacyModule( $sModuleId )
00132     {
00133         $aLegacyModules = $this->getLegacyModules();
00134         $sModuleDir = $this->getModulePath( $sModuleId );
00135 
00136         // registered legacy module
00137         if ( isset( $aLegacyModules[$sModuleId] ) ) {
00138             $this->_aModule = $aLegacyModules[$sModuleId];
00139             $this->_blLegacy      = true;
00140             $this->_blRegistered  = true;
00141             $this->_blMetadata    = false;
00142             $this->_blFile        = empty( $sModuleDir );
00143             $this->_aModule['active'] = $this->isActive();
00144             return true;
00145         }
00146         return false;
00147     }
00148 
00156     public function loadUnregisteredModule( $sModuleId )
00157     {
00158         $sModulePath = $this->getModuleFullPath( $sModuleId );
00159 
00160         if ( !$sModulePath ) {
00161             $sModulePath = $this->getConfig()->getModulesDir() . $sModuleId;
00162         }
00163 
00164         if ( file_exists( $sModulePath ) && is_readable( $sModulePath ) ) {
00165             $aModules = $this->getAllModules();
00166 
00167             $this->_aModule = array();
00168             $this->_aModule['id'] = $sModuleId;
00169             $this->_aModule['title'] = $sModuleId;
00170             $this->_aModule['extend'] = $this->buildModuleChains( $this->filterModuleArray( $aModules, $sModuleId ) );
00171             $this->_blLegacy      = true;
00172             $this->_blRegistered  = false;
00173             $this->_blMetadata    = false;
00174             $this->_blFile        = !is_dir($this->getConfig()->getModulesDir() . $sModuleId );
00175             $this->_aModule['active'] = $this->isActive();
00176             return true;
00177         }
00178         return false;
00179     }
00180 
00186     public function getDescription()
00187     {
00188         $iLang = oxRegistry::getLang()->getTplLanguage();
00189 
00190         return $this->getInfo( "description", $iLang );
00191     }
00192 
00198     public function getTitle()
00199     {
00200         $iLang = oxRegistry::getLang()->getTplLanguage();
00201 
00202         return $this->getInfo( "title", $iLang );
00203     }
00204 
00210     public function getId()
00211     {
00212         return $this->_aModule['id'];
00213     }
00214 
00222     public function getIdByPath( $sModule )
00223     {
00224         $myConfig     = $this->getConfig();
00225         $aModulePaths = $myConfig->getConfigParam( 'aModulePaths' );
00226         $sModuleId    = null;
00227         if (is_array( $aModulePaths )) {
00228             foreach ($aModulePaths as $sId => $sPath) {
00229                 if (strpos($sModule, $sPath."/") === 0 ) {
00230                     $sModuleId = $sId;
00231                 }
00232             }
00233         }
00234         if (!$sModuleId) {
00235             $sModuleId = substr( $sModule, 0, strpos( $sModule, "/" ) );
00236         }
00237         if (!$sModuleId) {
00238             $sModuleId = $sModule;
00239         }
00240         return $sModuleId;
00241     }
00242 
00252     public function getInfo( $sName, $iLang = null )
00253     {
00254         if (isset($this->_aModule[$sName])) {
00255 
00256             if ( $iLang !== null && is_array($this->_aModule[$sName]) ) {
00257                 $sValue = null;
00258 
00259                 $sLang = oxRegistry::getLang()->getLanguageAbbr( $iLang );
00260 
00261                 if ( !empty($this->_aModule[$sName]) ) {
00262                     if ( !empty( $this->_aModule[$sName][$sLang] ) ) {
00263                         $sValue = $this->_aModule[$sName][$sLang];
00264                     } elseif ( !empty( $this->_aModule['lang'] ) ) {
00265                         // trying to get value according default language
00266                         $sValue = $this->_aModule[$sName][$this->_aModule['lang']];
00267                     } else {
00268                         // returning first array value
00269                         $sValue = reset( $this->_aModule[$sName] );
00270                     }
00271 
00272                     return $sValue;
00273                 }
00274             } else {
00275                 return $this->_aModule[$sName];
00276             }
00277         }
00278     }
00279 
00285     public function isActive()
00286     {
00287         $blActive = false;
00288         $sId = $this->getId();
00289         if (isset($sId)) {
00290             if ( is_array($this->_aModule['extend']) && !empty($this->_aModule['extend']) ) {
00291                 $aAddModules = $this->_aModule['extend'];
00292                 $aInstalledModules = $this->getAllModules();
00293                 $iClCount = count($aAddModules);
00294                 $iActive  = 0;
00295 
00296                 foreach ($aAddModules as $sClass => $sModule) {
00297                     if ( (isset($aInstalledModules[$sClass]) && in_array($sModule, $aInstalledModules[$sClass])) ) {
00298                         $iActive ++;
00299                     }
00300                 }
00301                 $blActive = $iClCount > 0 && $iActive == $iClCount;
00302 
00303                 $aDisabledModules = $this->getDisabledModules();
00304                 if ( $blActive && ( is_array($aDisabledModules) && in_array($sId, $aDisabledModules) ) ) {
00305                     $blActive = false;
00306                 }
00307             } else {
00308                 //handling modules that does not extend any class
00309                 $aDisabledModules = $this->getDisabledModules();
00310                 if ( is_array($aDisabledModules) && !in_array($sId, $aDisabledModules) ) {
00311                     $blActive = true;
00312                 }
00313             }
00314         }
00315 
00316         return $blActive;
00317     }
00318 
00319 
00325     public function isExtended()
00326     {
00327         if ( $this->hasMetadata() && !empty( $this->_aModule['extend'] ) ) {
00328             return true;
00329         }
00330 
00331         return false;
00332     }
00333 
00339     public function isLegacy()
00340     {
00341         return $this->_blLegacy;
00342     }
00343 
00349     public function isRegistered()
00350     {
00351         return $this->_blRegistered;
00352     }
00353 
00359     public function hasMetadata()
00360     {
00361         return $this->_blMetadata;
00362     }
00363 
00369     public function isFile()
00370     {
00371         return $this->_blFile;
00372     }
00373 
00379     public function activate()
00380     {
00381         if ( isset( $this->_aModule['extend'] ) && is_array( $this->_aModule['extend'] ) ) {
00382 
00383             $oConfig     = oxRegistry::getConfig();
00384             $aAddModules = $this->_aModule['extend'];
00385             $sModuleId   = $this->getId();
00386 
00387             $aInstalledModules = $this->getAllModules();
00388             $aDisabledModules  = $this->getDisabledModules();
00389 
00390             $aModules = $this->mergeModuleArrays($aInstalledModules, $aAddModules);
00391             $aModules = $this->buildModuleChains($aModules);
00392 
00393             $oConfig->setConfigParam('aModules', $aModules);
00394             $oConfig->saveShopConfVar('aarr', 'aModules', $aModules);
00395 
00396             if ( isset($aDisabledModules) && is_array($aDisabledModules) ) {
00397                 $aDisabledModules = array_diff($aDisabledModules, array($sModuleId));
00398                 $oConfig->setConfigParam('aDisabledModules', $aDisabledModules);
00399                 $oConfig->saveShopConfVar('arr', 'aDisabledModules', $aDisabledModules);
00400             }
00401 
00402             // checking if module has tpl blocks and they are installed
00403             if ( !$this->_hasInstalledTemplateBlocks($sModuleId) ) {
00404                 // installing module blocks
00405                 $this->_addTemplateBlocks( $this->getInfo("blocks") );
00406             } else {
00407                 //activate oxblocks
00408                 $this->_changeBlockStatus( $sModuleId, "1" );
00409             }
00410 
00411             // Register new module templates
00412             $this->_addModuleFiles($this->getInfo("files") );
00413 
00414             // Register new module templates
00415             $this->_addTemplateFiles( $this->getInfo("templates") );
00416 
00417             // Add module settings
00418             $this->_addModuleSettings($this->getInfo("settings"));
00419 
00420             // Add module version
00421             $this->_addModuleVersion($this->getInfo("version"));
00422 
00423             // Add module events
00424             $this->_addModuleEvents($this->getInfo("events"));
00425 
00426             //resets cache
00427             $this->_resetCache();
00428 
00429 
00430             $this->_callEvent('onActivate', $sModuleId);
00431 
00432             return true;
00433         }
00434         return false;
00435     }
00436 
00444     public function deactivate( $sModuleId = null )
00445     {
00446         $oConfig = $this->getConfig();
00447         if (!isset($sModuleId)) {
00448             $sModuleId = $this->getId();
00449         }
00450         if (isset($sModuleId)) {
00451 
00452             $this->_callEvent( 'onDeactivate', $sModuleId );
00453 
00454             $aDisabledModules = $this->getDisabledModules();
00455 
00456             if (!is_array($aDisabledModules)) {
00457                 $aDisabledModules = array();
00458             }
00459             $aModules = array_merge($aDisabledModules, array( $sModuleId ) );
00460             $aModules = array_unique($aModules);
00461 
00462             $oConfig->saveShopConfVar( 'arr', 'aDisabledModules', $aModules );
00463             $oConfig->setConfigParam( 'aDisabledModules', $aModules );
00464 
00465             //deactivate oxblocks too
00466             $this->_changeBlockStatus( $sModuleId );
00467 
00468             //resets cache
00469             $this->_resetCache();
00470 
00471 
00472             return true;
00473         }
00474         return false;
00475     }
00476 
00485     protected function _callEvent( $sEvent, $sModuleId )
00486     {
00487         $aModuleEvents = $this->getModuleEvents();
00488 
00489         if ( isset( $aModuleEvents[$sModuleId], $aModuleEvents[$sModuleId][$sEvent] ) ) {
00490             $mEvent = $aModuleEvents[$sModuleId][$sEvent];
00491 
00492             if ( is_callable( $mEvent ) ) {
00493                 call_user_func($mEvent);
00494             }
00495         }
00496     }
00497 
00506     protected function _changeBlockStatus( $sModule, $iStatus = 0 )
00507     {
00508         $oDb = oxDb::getDb();
00509         $sShopId   = $this->getConfig()->getShopId();
00510         $oDb->execute( "UPDATE oxtplblocks SET oxactive = '".(int) $iStatus."' WHERE oxmodule =". $oDb->quote( $sModule )."AND oxshopid = '$sShopId'" );
00511     }
00512 
00518     protected function _resetCache()
00519     {
00520         $aTemplates = $this->getTemplates();
00521         $oUtils = oxRegistry::getUtils();
00522         $oUtils->resetTemplateCache($aTemplates);
00523         $oUtils->resetLanguageCache();
00524         $oUtils->resetMenuCache();
00525 
00526         $oUtilsObject = oxUtilsObject::getInstance();
00527         $oUtilsObject->resetModuleVars();
00528 
00529         $this->_clearApcCache();
00530     }
00531 
00532 
00540     public function buildModuleChains($aModuleArray)
00541     {
00542         $aModules = array();
00543         if (is_array($aModuleArray)) {
00544             foreach ($aModuleArray as $sClass => $aModuleChain) {
00545                 $aModules[$sClass] = implode('&', $aModuleChain);
00546             }
00547         }
00548         return $aModules;
00549     }
00550 
00560     public function mergeModuleArrays($aAllModuleArray, $aAddModuleArray)
00561     {
00562         if (is_array($aAllModuleArray) && is_array($aAddModuleArray)) {
00563             foreach ($aAddModuleArray as $sClass => $aModuleChain) {
00564                 if (!is_array($aModuleChain)) {
00565                     $aModuleChain = array($aModuleChain);
00566                 }
00567                 if (isset($aAllModuleArray[$sClass])) {
00568                     foreach ($aModuleChain as $sModule) {
00569                         if (!in_array($sModule, $aAllModuleArray[$sClass])) {
00570                             $aAllModuleArray[$sClass][] = $sModule;
00571                         }
00572                     }
00573                 } else {
00574                     $aAllModuleArray[$sClass] = $aModuleChain;
00575                 }
00576             }
00577         }
00578 
00579         return $aAllModuleArray;
00580     }
00581 
00590     public function filterModuleArray($aModules, $sModuleId)
00591     {
00592         $aFilteredModules = array();
00593         foreach ($aModules as $sClass => $aExtend) {
00594             foreach ($aExtend as $sExtendPath) {
00595                 if (strstr($sExtendPath, $sModuleId.'/')) {
00596                     $aFilteredModules[$sClass][] = $sExtendPath;
00597                 }
00598             }
00599         }
00600         return $aFilteredModules;
00601     }
00602 
00610     public function getModulePath( $sModuleId = null )
00611     {
00612         if ( !$sModuleId ) {
00613             $sModuleId = $this->getId();
00614         }
00615 
00616         $aModulePaths = $this->getModulePaths();
00617 
00618         $sModulePath = $aModulePaths[$sModuleId];
00619 
00620         // if still no module dir, try using module ID as dir name
00621         if ( !$sModulePath && is_dir($this->getConfig()->getModulesDir().$sModuleId) ) {
00622             $sModulePath = $sModuleId;
00623         }
00624 
00625         return $sModulePath;
00626     }
00627 
00635     public function getModuleFullPath( $sModuleId )
00636     {
00637         if ( $sModuleDir = $this->getModulePath( $sModuleId ) ) {
00638             return $this->getConfig()->getModulesDir() . $sModuleDir;
00639         }
00640         return false;
00641     }
00642 
00648     public function getAllModules()
00649     {
00650         return $this->getConfig()->getAllModules();
00651     }
00652 
00658     public function getLegacyModules()
00659     {
00660         return $this->getConfig()->getConfigParam('aLegacyModules');
00661     }
00662 
00668     public function getDisabledModules()
00669     {
00670         return $this->getConfig()->getConfigParam('aDisabledModules');
00671     }
00672 
00678     public function getModulePaths()
00679     {
00680         return $this->getConfig()->getConfigParam('aModulePaths');
00681     }
00682 
00688     public function getModuleTemplates()
00689     {
00690         return (array) $this->getConfig()->getConfigParam('aModuleTemplates');
00691     }
00692 
00698     public function getModuleFiles()
00699     {
00700         return (array) $this->getConfig()->getConfigParam('aModuleFiles');
00701     }
00702 
00708     public function getModuleVersions()
00709     {
00710         return (array) $this->getConfig()->getConfigParam('aModuleVersions');
00711     }
00712 
00718     public function getModuleEvents()
00719     {
00720         return (array) $this->getConfig()->getConfigParam('aModuleEvents');
00721     }
00722 
00730     protected function _hasInstalledTemplateBlocks( $sModuleId )
00731     {
00732         $sShopId   = $this->getConfig()->getShopId();
00733         $oDb = oxDb::getDb();
00734         $blRes = $oDb->getOne( "SELECT 1 FROM oxtplblocks WHERE oxmodule = ".$oDb->quote($sModuleId)." AND oxshopid = '$sShopId' LIMIT 1" );
00735         return (bool) $blRes;
00736     }
00737 
00746     protected function _addTemplateBlocks( $aModuleBlocks, $sModuleId = null )
00747     {
00748         if (is_null($sModuleId)) {
00749             $sModuleId = $this->getId();
00750         }
00751 
00752         $sShopId = $this->getConfig()->getShopId();
00753         $oDb     = oxDb::getDb();
00754 
00755         if ( is_array($aModuleBlocks) ) {
00756 
00757             foreach ( $aModuleBlocks as $aValue ) {
00758                 $sOxId = oxUtilsObject::getInstance()->generateUId();
00759 
00760                 $sTemplate = $aValue["template"];
00761                 $iPosition = $aValue["position"]?$aValue["position"]:1;
00762                 $sBlock    = $aValue["block"];
00763                 $sFile     = $aValue["file"];
00764 
00765                 $sSql = "INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`)
00766                          VALUES ('{$sOxId}', 1, '{$sShopId}', ".$oDb->quote($sTemplate).", ".$oDb->quote($sBlock).", ".$oDb->quote($iPosition).", ".$oDb->quote($sFile).", '{$sModuleId}')";
00767 
00768                 $oDb->execute( $sSql );
00769             }
00770         }
00771     }
00772 
00781     protected function _addTemplateFiles( $aModuleTemplates , $sModuleId = null)
00782     {
00783         if (is_null($sModuleId)) {
00784             $sModuleId = $this->getId();
00785         }
00786 
00787         $oConfig    = $this->getConfig();
00788         $aTemplates = $this->getModuleTemplates();
00789         if ( is_array($aModuleTemplates) ) {
00790             $aTemplates[$sModuleId] = $aModuleTemplates;
00791         }
00792 
00793         $oConfig->setConfigParam('aModuleTemplates', $aTemplates);
00794         $oConfig->saveShopConfVar('aarr', 'aModuleTemplates', $aTemplates);
00795     }
00796 
00805     protected function _addModuleVersion( $sModuleVersion, $sModuleId = null)
00806     {
00807         if (is_null($sModuleId)) {
00808             $sModuleId = $this->getId();
00809         }
00810 
00811         $oConfig = $this->getConfig();
00812         $aVersions  = $this->getModuleVersions();
00813         if ( is_array($aVersions) ) {
00814             $aVersions[$sModuleId] = $sModuleVersion;
00815         }
00816 
00817         $oConfig->setConfigParam('aModuleVersions', $aVersions);
00818         $oConfig->saveShopConfVar('aarr', 'aModuleVersions', $aVersions);
00819     }
00820 
00829     protected function _addModuleEvents( $aModuleEvents, $sModuleId = null)
00830     {
00831         if (is_null($sModuleId)) {
00832             $sModuleId = $this->getId();
00833         }
00834 
00835         $oConfig = $this->getConfig();
00836         $aEvents  = $this->getModuleEvents();
00837         if ( is_array($aEvents) ) {
00838             $aEvents[$sModuleId] = $aModuleEvents;
00839         }
00840 
00841         $oConfig->setConfigParam('aModuleEvents', $aEvents);
00842         $oConfig->saveShopConfVar('aarr', 'aModuleEvents', $aEvents);
00843     }
00844 
00853     protected function _addModuleFiles( $aModuleFiles, $sModuleId = null)
00854     {
00855         if (is_null($sModuleId)) {
00856             $sModuleId = $this->getId();
00857         }
00858 
00859         $oConfig = $this->getConfig();
00860         $aFiles  = $this->getModuleFiles();
00861         if ( is_array($aModuleFiles) ) {
00862             $aFiles[$sModuleId] = array_change_key_case($aModuleFiles, CASE_LOWER);
00863         }
00864 
00865         $oConfig->setConfigParam('aModuleFiles', $aFiles);
00866         $oConfig->saveShopConfVar('aarr', 'aModuleFiles', $aFiles);
00867     }
00868 
00877     protected function _addModuleSettings( $aModuleSettings, $sModuleId = null )
00878     {
00879         if (is_null($sModuleId)) {
00880             $sModuleId = $this->getId();
00881         }
00882         $oConfig = $this->getConfig();
00883         $sShopId = $oConfig->getShopId();
00884         $oDb     = oxDb::getDb();
00885 
00886         if ( is_array($aModuleSettings) ) {
00887 
00888             foreach ( $aModuleSettings as $aValue ) {
00889                 $sOxId = oxUtilsObject::getInstance()->generateUId();
00890 
00891                 $sModule     = 'module:'.$sModuleId;
00892                 $sName       = $aValue["name"];
00893                 $sType       = $aValue["type"];
00894                 $sValue      = is_null($oConfig->getConfigParam($sName))?$aValue["value"]:$oConfig->getConfigParam($sName);
00895                 $sGroup      = $aValue["group"];
00896 
00897                 $sConstraints = "";
00898                 if ( $aValue["constraints"] ) {
00899                     $sConstraints = $aValue["constraints"];
00900                 } elseif ( $aValue["constrains"] ) {
00901                     $sConstraints = $aValue["constrains"];
00902                 }
00903 
00904                 $iPosition   = $aValue["position"]?$aValue["position"]:1;
00905 
00906                 $oConfig->setConfigParam($sName, $sValue);
00907                 $oConfig->saveShopConfVar($sType, $sName, $sValue, $sShopId, $sModule);
00908 
00909                 $sDeleteSql = "DELETE FROM `oxconfigdisplay` WHERE OXCFGMODULE=".$oDb->quote($sModule)." AND OXCFGVARNAME=".$oDb->quote($sName);
00910                 $sInsertSql = "INSERT INTO `oxconfigdisplay` (`OXID`, `OXCFGMODULE`, `OXCFGVARNAME`, `OXGROUPING`, `OXVARCONSTRAINT`, `OXPOS`) ".
00911                               "VALUES ('{$sOxId}', ".$oDb->quote($sModule).", ".$oDb->quote($sName).", ".$oDb->quote($sGroup).", ".$oDb->quote($sConstraints).", ".$oDb->quote($iPosition).")";
00912 
00913                 $oDb->execute( $sDeleteSql );
00914                 $oDb->execute( $sInsertSql );
00915             }
00916         }
00917     }
00918 
00926     public function getTemplates( $sModuleId = null )
00927     {
00928         if (is_null($sModuleId)) {
00929             $sModuleId = $this->getId();
00930         }
00931 
00932         if (!$sModuleId) {
00933             return array();
00934         }
00935 
00936         $sShopId   = $this->getConfig()->getShopId();
00937 
00938         $aTemplates = oxDb::getDb()->getCol("SELECT oxtemplate FROM oxtplblocks WHERE oxmodule = '$sModuleId' AND oxshopid = '$sShopId'" );
00939 
00940         return $aTemplates;
00941     }
00942 
00954     public function saveLegacyModule($sModuleId, $sModuleName, $aModuleInfo = null)
00955     {
00956         $aLegacyModules = $this->getLegacyModules();
00957 
00958         if ( !empty( $aModuleInfo ) && is_array($aModuleInfo)) {
00959             $aLegacyModules[$sModuleId]["id"] = $sModuleId;
00960             $aLegacyModules[$sModuleId]["title"] = ( $sModuleName ) ? $sModuleName : $sModuleId;
00961             $aLegacyModules[$sModuleId]['extend'] = array();
00962 
00963             foreach ( $aModuleInfo as $sKey => $sValue ) {
00964                 if ( strpos( $sValue, "=>" ) > 1 ) {
00965                     $aClassInfo    = explode( "=>", $sValue );
00966                     $sClassName    = trim( $aClassInfo[0] );
00967                     $sExtendString = trim( $aClassInfo[1] );
00968                     $aLegacyModules[$sModuleId]['extend'][$sClassName] = $sExtendString;
00969                 }
00970             }
00971         }
00972 
00973         if ( !empty( $aLegacyModules[$sModuleId]['extend'] ) ) {
00974             $this->getConfig()->saveShopConfVar( "aarr", "aLegacyModules", $aLegacyModules );
00975         }
00976         return $sModuleId;
00977     }
00978 
00987     public function updateModuleIds( $sModuleLegacyId, $sModuleId )
00988     {
00989         $oConfig = $this->getConfig();
00990 
00991         // updating module ID in aModulePaths config var
00992         $aModulePaths = $oConfig->getConfigParam( 'aModulePaths' );
00993         $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
00994         unset( $aModulePaths[$sModuleLegacyId] );
00995 
00996         $oConfig->saveShopConfVar( 'aarr', 'aModulePaths', $aModulePaths );
00997 
00998         if ( isset($aModulePaths[$sModuleLegacyId]) ) {
00999             $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
01000             unset( $aModulePaths[$sModuleLegacyId] );
01001             $oConfig->saveShopConfVar( 'aarr', 'aModulePaths', $aModulePaths );
01002         }
01003 
01004         // updating module ID in aDisabledModules config var
01005         $aDisabledModules = $oConfig->getConfigParam( 'aDisabledModules' );
01006 
01007         if ( is_array($aDisabledModules) ) {
01008             $iOldKey = array_search( $sModuleLegacyId, $aDisabledModules );
01009             if ( $iOldKey !== false ) {
01010                 unset( $aDisabledModules[$iOldKey] );
01011                 $aDisabledModules[$iOldKey] = $sModuleId;
01012                 $oConfig->saveShopConfVar( 'arr', 'aDisabledModules', $aDisabledModules );
01013             }
01014         }
01015     }
01016 
01020     protected function _clearApcCache()
01021     {
01022         if ( extension_loaded( 'apc' ) && ini_get( 'apc.enabled' ) ) {
01023             apc_clear_cache();
01024         }
01025     }
01026 }