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             $oConfig     = oxRegistry::getConfig();
00383             $aAddModules = $this->_aModule['extend'];
00384             $sModuleId   = $this->getId();
00385 
00386             $aInstalledModules = $this->getAllModules();
00387             $aDisabledModules  = $this->getDisabledModules();
00388 
00389             $aModules = $this->mergeModuleArrays($aInstalledModules, $aAddModules);
00390             $aModules = $this->buildModuleChains($aModules);
00391 
00392             $oConfig->setConfigParam('aModules', $aModules);
00393             $oConfig->saveShopConfVar('aarr', 'aModules', $aModules);
00394 
00395             if ( isset($aDisabledModules) && is_array($aDisabledModules) ) {
00396                 $aDisabledModules = array_diff($aDisabledModules, array($sModuleId));
00397                 $oConfig->setConfigParam('aDisabledModules', $aDisabledModules);
00398                 $oConfig->saveShopConfVar('arr', 'aDisabledModules', $aDisabledModules);
00399             }
00400 
00401             // checking if module has tpl blocks and they are installed
00402             if ( !$this->_hasInstalledTemplateBlocks($sModuleId) ) {
00403                 // installing module blocks
00404                 $this->_addTemplateBlocks( $this->getInfo("blocks") );
00405             } else {
00406                 //activate oxblocks
00407                 $this->_changeBlockStatus( $sModuleId, "1" );
00408             }
00409 
00410             // Register new module templates
00411             $this->_addModuleFiles($this->getInfo("files") );
00412 
00413             // Register new module templates
00414             $this->_addTemplateFiles($this->getInfo("templates") );
00415 
00416             // Add module settings
00417             $this->_addModuleSettings($this->getInfo("settings"));
00418 
00419             // Add module version
00420             $this->_addModuleVersion($this->getInfo("version"));
00421 
00422             // Add module events
00423             $this->_addModuleEvents($this->getInfo("events"));
00424 
00425             //resets cache
00426             $this->_resetCache();
00427 
00428 
00429             $this->_callEvent('onActivate', $sModuleId);
00430 
00431             return true;
00432         }
00433         return false;
00434     }
00435 
00443     public function deactivate( $sModuleId = null )
00444     {
00445         $oConfig = $this->getConfig();
00446         if (!isset($sModuleId)) {
00447             $sModuleId = $this->getId();
00448         }
00449         if (isset($sModuleId)) {
00450 
00451             $this->_callEvent( 'onDeactivate', $sModuleId );
00452 
00453             $aDisabledModules = $this->getDisabledModules();
00454 
00455             if (!is_array($aDisabledModules)) {
00456                 $aDisabledModules = array();
00457             }
00458             $aModules = array_merge($aDisabledModules, array( $sModuleId ) );
00459             $aModules = array_unique($aModules);
00460 
00461             $oConfig->saveShopConfVar( 'arr', 'aDisabledModules', $aModules );
00462             $oConfig->setConfigParam( 'aDisabledModules', $aModules );
00463 
00464             //deactivate oxblocks too
00465             $this->_changeBlockStatus( $sModuleId );
00466 
00467             //resets cache
00468             $this->_resetCache();
00469 
00470 
00471             return true;
00472         }
00473         return false;
00474     }
00475 
00484     protected function _callEvent( $sEvent, $sModuleId )
00485     {
00486         $aModuleEvents = $this->getModuleEvents();
00487 
00488         if ( isset( $aModuleEvents[$sModuleId], $aModuleEvents[$sModuleId][$sEvent] ) ) {
00489             $mEvent = $aModuleEvents[$sModuleId][$sEvent];
00490 
00491             if ( is_callable( $mEvent ) ) {
00492                 call_user_func($mEvent);
00493             }
00494         }
00495     }
00496 
00505     protected function _changeBlockStatus( $sModule, $iStatus = 0 )
00506     {
00507         $oDb = oxDb::getDb();
00508         $sShopId   = $this->getConfig()->getShopId();
00509         $oDb->execute( "UPDATE oxtplblocks SET oxactive = '".(int) $iStatus."' WHERE oxmodule =". $oDb->quote( $sModule )."AND oxshopid = '$sShopId'" );
00510     }
00511 
00517     protected function _resetCache()
00518     {
00519         $aTemplates = $this->getTemplates();
00520         $oUtils = oxRegistry::getUtils();
00521         $oUtils->resetTemplateCache($aTemplates);
00522         $oUtils->resetLanguageCache();
00523         $oUtils->resetMenuCache();
00524 
00525         $oUtilsObject = oxUtilsObject::getInstance();
00526         $oUtilsObject->resetModuleVars();
00527     }
00528 
00529 
00537     public function buildModuleChains($aModuleArray)
00538     {
00539         $aModules = array();
00540         if (is_array($aModuleArray)) {
00541             foreach ($aModuleArray as $sClass => $aModuleChain) {
00542                 $aModules[$sClass] = implode('&', $aModuleChain);
00543             }
00544         }
00545         return $aModules;
00546     }
00547 
00557     public function mergeModuleArrays($aAllModuleArray, $aAddModuleArray)
00558     {
00559         if (is_array($aAllModuleArray) && is_array($aAddModuleArray)) {
00560             foreach ($aAddModuleArray as $sClass => $aModuleChain) {
00561                 if (!is_array($aModuleChain)) {
00562                     $aModuleChain = array($aModuleChain);
00563                 }
00564                 if (isset($aAllModuleArray[$sClass])) {
00565                     foreach ($aModuleChain as $sModule) {
00566                         if (!in_array($sModule, $aAllModuleArray[$sClass])) {
00567                             $aAllModuleArray[$sClass][] = $sModule;
00568                         }
00569                     }
00570                 } else {
00571                     $aAllModuleArray[$sClass] = $aModuleChain;
00572                 }
00573             }
00574         }
00575 
00576         return $aAllModuleArray;
00577     }
00578 
00587     public function filterModuleArray($aModules, $sModuleId)
00588     {
00589         $aFilteredModules = array();
00590         foreach ($aModules as $sClass => $aExtend) {
00591             foreach ($aExtend as $sExtendPath) {
00592                 if (strstr($sExtendPath, $sModuleId.'/')) {
00593                     $aFilteredModules[$sClass][] = $sExtendPath;
00594                 }
00595             }
00596         }
00597         return $aFilteredModules;
00598     }
00599 
00607     public function getModulePath( $sModuleId = null )
00608     {
00609         if ( !$sModuleId ) {
00610             $sModuleId = $this->getId();
00611         }
00612 
00613         $aModulePaths = $this->getModulePaths();
00614 
00615         $sModulePath = $aModulePaths[$sModuleId];
00616 
00617         // if still no module dir, try using module ID as dir name
00618         if ( !$sModulePath && is_dir($this->getConfig()->getModulesDir().$sModuleId) ) {
00619             $sModulePath = $sModuleId;
00620         }
00621 
00622         return $sModulePath;
00623     }
00624 
00632     public function getModuleFullPath( $sModuleId )
00633     {
00634         if ( $sModuleDir = $this->getModulePath( $sModuleId ) ) {
00635             return $this->getConfig()->getModulesDir() . $sModuleDir;
00636         }
00637         return false;
00638     }
00639 
00645     public function getAllModules()
00646     {
00647         return $this->getConfig()->getAllModules();
00648     }
00649 
00655     public function getLegacyModules()
00656     {
00657         return $this->getConfig()->getConfigParam('aLegacyModules');
00658     }
00659 
00665     public function getDisabledModules()
00666     {
00667         return $this->getConfig()->getConfigParam('aDisabledModules');
00668     }
00669 
00675     public function getModulePaths()
00676     {
00677         return $this->getConfig()->getConfigParam('aModulePaths');
00678     }
00679 
00685     public function getModuleTemplates()
00686     {
00687         return (array) $this->getConfig()->getConfigParam('aModuleTemplates');
00688     }
00689 
00695     public function getModuleFiles()
00696     {
00697         return (array) $this->getConfig()->getConfigParam('aModuleFiles');
00698     }
00699 
00705     public function getModuleVersions()
00706     {
00707         return (array) $this->getConfig()->getConfigParam('aModuleVersions');
00708     }
00709 
00715     public function getModuleEvents()
00716     {
00717         return (array) $this->getConfig()->getConfigParam('aModuleEvents');
00718     }
00719 
00727     protected function _hasInstalledTemplateBlocks( $sModuleId )
00728     {
00729         $sShopId   = $this->getConfig()->getShopId();
00730         $oDb = oxDb::getDb();
00731         $blRes = $oDb->getOne( "SELECT 1 FROM oxtplblocks WHERE oxmodule = ".$oDb->quote($sModuleId)." AND oxshopid = '$sShopId' LIMIT 1" );
00732         return (bool) $blRes;
00733     }
00734 
00743     protected function _addTemplateBlocks( $aModuleBlocks, $sModuleId = null )
00744     {
00745         if (is_null($sModuleId)) {
00746             $sModuleId = $this->getId();
00747         }
00748 
00749         $sShopId = $this->getConfig()->getShopId();
00750         $oDb     = oxDb::getDb();
00751 
00752         if ( is_array($aModuleBlocks) ) {
00753 
00754             foreach ( $aModuleBlocks as $aValue ) {
00755                 $sOxId = oxUtilsObject::getInstance()->generateUId();
00756 
00757                 $sTemplate = $aValue["template"];
00758                 $iPosition = $aValue["position"]?$aValue["position"]:1;
00759                 $sBlock    = $aValue["block"];
00760                 $sFile     = $aValue["file"];
00761 
00762                 $sSql = "INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`)
00763                          VALUES ('{$sOxId}', 1, '{$sShopId}', ".$oDb->quote($sTemplate).", ".$oDb->quote($sBlock).", ".$oDb->quote($iPosition).", ".$oDb->quote($sFile).", '{$sModuleId}')";
00764 
00765                 $oDb->execute( $sSql );
00766             }
00767         }
00768     }
00769 
00778     protected function _addTemplateFiles( $aModuleTemplates , $sModuleId = null)
00779     {
00780         if (is_null($sModuleId)) {
00781             $sModuleId = $this->getId();
00782         }
00783 
00784         $oConfig    = $this->getConfig();
00785         $aTemplates = $this->getModuleTemplates();
00786         if ( is_array($aModuleTemplates) ) {
00787             $aTemplates[$sModuleId] = $aModuleTemplates;
00788         }
00789 
00790         $oConfig->setConfigParam('aModuleTemplates', $aTemplates);
00791         $oConfig->saveShopConfVar('aarr', 'aModuleTemplates', $aTemplates);
00792     }
00793 
00802     protected function _addModuleVersion( $sModuleVersion, $sModuleId = null)
00803     {
00804         if (is_null($sModuleId)) {
00805             $sModuleId = $this->getId();
00806         }
00807 
00808         $oConfig = $this->getConfig();
00809         $aVersions  = $this->getModuleVersions();
00810         if ( is_array($aVersions) ) {
00811             $aVersions[$sModuleId] = $sModuleVersion;
00812         }
00813 
00814         $oConfig->setConfigParam('aModuleVersions', $aVersions);
00815         $oConfig->saveShopConfVar('aarr', 'aModuleVersions', $aVersions);
00816     }
00817 
00826     protected function _addModuleEvents( $aModuleEvents, $sModuleId = null)
00827     {
00828         if (is_null($sModuleId)) {
00829             $sModuleId = $this->getId();
00830         }
00831 
00832         $oConfig = $this->getConfig();
00833         $aEvents  = $this->getModuleEvents();
00834         if ( is_array($aEvents) ) {
00835             $aEvents[$sModuleId] = $aModuleEvents;
00836         }
00837 
00838         $oConfig->setConfigParam('aModuleEvents', $aEvents);
00839         $oConfig->saveShopConfVar('aarr', 'aModuleEvents', $aEvents);
00840     }
00841 
00850     protected function _addModuleFiles( $aModuleFiles, $sModuleId = null)
00851     {
00852         if (is_null($sModuleId)) {
00853             $sModuleId = $this->getId();
00854         }
00855 
00856         $oConfig = $this->getConfig();
00857         $aFiles  = $this->getModuleFiles();
00858         if ( is_array($aModuleFiles) ) {
00859             $aFiles[$sModuleId] = array_change_key_case($aModuleFiles, CASE_LOWER);
00860         }
00861 
00862         $oConfig->setConfigParam('aModuleFiles', $aFiles);
00863         $oConfig->saveShopConfVar('aarr', 'aModuleFiles', $aFiles);
00864     }
00865 
00874     protected function _addModuleSettings( $aModuleSettings, $sModuleId = null )
00875     {
00876         if (is_null($sModuleId)) {
00877             $sModuleId = $this->getId();
00878         }
00879         $oConfig = $this->getConfig();
00880         $sShopId = $oConfig->getShopId();
00881         $oDb     = oxDb::getDb();
00882 
00883         if ( is_array($aModuleSettings) ) {
00884 
00885             foreach ( $aModuleSettings as $aValue ) {
00886                 $sOxId = oxUtilsObject::getInstance()->generateUId();
00887 
00888                 $sModule     = 'module:'.$sModuleId;
00889                 $sName       = $aValue["name"];
00890                 $sType       = $aValue["type"];
00891                 $sValue      = is_null($oConfig->getConfigParam($sName))?$aValue["value"]:$oConfig->getConfigParam($sName);
00892                 $sGroup      = $aValue["group"];
00893 
00894                 $sConstraints = "";
00895                 if ( $aValue["constraints"] ) {
00896                     $sConstraints = $aValue["constraints"];
00897                 } elseif ( $aValue["constrains"] ) {
00898                     $sConstraints = $aValue["constrains"];
00899                 }
00900 
00901                 $iPosition   = $aValue["position"]?$aValue["position"]:1;
00902 
00903                 $oConfig->setConfigParam($sName, $sValue);
00904                 $oConfig->saveShopConfVar($sType, $sName, $sValue, $sShopId, $sModule);
00905 
00906                 $sDeleteSql = "DELETE FROM `oxconfigdisplay` WHERE OXCFGMODULE=".$oDb->quote($sModule)." AND OXCFGVARNAME=".$oDb->quote($sName);
00907                 $sInsertSql = "INSERT INTO `oxconfigdisplay` (`OXID`, `OXCFGMODULE`, `OXCFGVARNAME`, `OXGROUPING`, `OXVARCONSTRAINT`, `OXPOS`) ".
00908                               "VALUES ('{$sOxId}', ".$oDb->quote($sModule).", ".$oDb->quote($sName).", ".$oDb->quote($sGroup).", ".$oDb->quote($sConstraints).", ".$oDb->quote($iPosition).")";
00909 
00910                 $oDb->execute( $sDeleteSql );
00911                 $oDb->execute( $sInsertSql );
00912             }
00913         }
00914     }
00915 
00923     public function getTemplates( $sModuleId = null )
00924     {
00925         if (is_null($sModuleId)) {
00926             $sModuleId = $this->getId();
00927         }
00928 
00929         if (!$sModuleId) {
00930             return array();
00931         }
00932 
00933         $sShopId   = $this->getConfig()->getShopId();
00934 
00935         $aTemplates = oxDb::getDb()->getCol("SELECT oxtemplate FROM oxtplblocks WHERE oxmodule = '$sModuleId' AND oxshopid = '$sShopId'" );
00936 
00937         return $aTemplates;
00938     }
00939 
00951     public function saveLegacyModule($sModuleId, $sModuleName, $aModuleInfo = null)
00952     {
00953         $aLegacyModules = $this->getLegacyModules();
00954 
00955         if ( !empty( $aModuleInfo ) && is_array($aModuleInfo)) {
00956             $aLegacyModules[$sModuleId]["id"] = $sModuleId;
00957             $aLegacyModules[$sModuleId]["title"] = ( $sModuleName ) ? $sModuleName : $sModuleId;
00958             $aLegacyModules[$sModuleId]['extend'] = array();
00959 
00960             foreach ( $aModuleInfo as $sKey => $sValue ) {
00961                 if ( strpos( $sValue, "=>" ) > 1 ) {
00962                     $aClassInfo    = explode( "=>", $sValue );
00963                     $sClassName    = trim( $aClassInfo[0] );
00964                     $sExtendString = trim( $aClassInfo[1] );
00965                     $aLegacyModules[$sModuleId]['extend'][$sClassName] = $sExtendString;
00966                 }
00967             }
00968         }
00969 
00970         if ( !empty( $aLegacyModules[$sModuleId]['extend'] ) ) {
00971             $this->getConfig()->saveShopConfVar( "aarr", "aLegacyModules", $aLegacyModules );
00972         }
00973         return $sModuleId;
00974     }
00975 
00984     public function updateModuleIds( $sModuleLegacyId, $sModuleId )
00985     {
00986         $oConfig = $this->getConfig();
00987 
00988         // updating module ID in aModulePaths config var
00989         $aModulePaths = $oConfig->getConfigParam( 'aModulePaths' );
00990         $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
00991         unset( $aModulePaths[$sModuleLegacyId] );
00992 
00993         $oConfig->saveShopConfVar( 'aarr', 'aModulePaths', $aModulePaths );
00994 
00995         if ( isset($aModulePaths[$sModuleLegacyId]) ) {
00996             $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
00997             unset( $aModulePaths[$sModuleLegacyId] );
00998             $oConfig->saveShopConfVar( 'aarr', 'aModulePaths', $aModulePaths );
00999         }
01000 
01001         // updating module ID in aDisabledModules config var
01002         $aDisabledModules = $oConfig->getConfigParam( 'aDisabledModules' );
01003 
01004         if ( is_array($aDisabledModules) ) {
01005             $iOldKey = array_search( $sModuleLegacyId, $aDisabledModules );
01006             if ( $iOldKey !== false ) {
01007                 unset( $aDisabledModules[$iOldKey] );
01008                 $aDisabledModules[$iOldKey] = $sModuleId;
01009                 $oConfig->saveShopConfVar( 'arr', 'aDisabledModules', $aDisabledModules );
01010             }
01011         }
01012     }
01013 }