public function uninstall($aParams, $bAutoDisable = false)
 {
     $bAutoDisable = $bAutoDisable || isset($aParams['auto_disable']) && (bool) $aParams['auto_disable'];
     $bHtmlResponce = isset($aParams['html_response']) && (bool) $aParams['html_response'];
     //--- Check whether the module was already uninstalled ---//
     if (!$this->oDb->isModule($this->_aConfig['home_uri'])) {
         return array('message' => _t('_adm_err_modules_already_uninstalled'), 'result' => false);
     }
     if ($bAutoDisable) {
         $aResultDisable = $this->disable($aParams);
         if (!$aResultDisable['result']) {
             return $aResultDisable;
         }
     }
     $aResult = array();
     bx_alert('system', 'before_uninstall', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     if ($aResult && !$aResult['result']) {
         return $aResult;
     }
     //--- Check for dependent modules ---//
     $bDependent = false;
     $aDependents = $this->oDb->getDependent($this->_aConfig['home_uri']);
     if (is_array($aDependents) && !empty($aDependents)) {
         $bDependent = true;
         $sMessage = '<br />' . _t('_adm_err_modules_wrong_dependency_uninstall') . '<br />';
         foreach ($aDependents as $aDependent) {
             $sMessage .= $aDependent['title'] . '<br />';
         }
     }
     if ($bDependent) {
         return array('message' => $this->_displayResult('check_dependencies', false, $sMessage, $bHtmlResponce), 'result' => false);
     }
     $aResult = $this->_perform('uninstall', $aParams);
     if ($aResult['result']) {
         $iModuleId = $this->oDb->deleteModule($this->_aConfig);
         $sTitleKey = BxDolModule::getTitleKey($this->_aConfig['home_uri']);
         $oLanguages = BxDolStudioLanguagesUtils::getInstance();
         $oLanguages->deleteLanguageString($sTitleKey);
         $oLanguages->compileLanguage();
         $this->oDb->cleanMemory('sys_modules_' . $this->_aConfig['home_uri']);
         $this->oDb->cleanMemory('sys_modules_' . $iModuleId);
         $this->oDb->cleanMemory('sys_modules');
         if (!empty($this->_aConfig['uninstall_success'])) {
             $this->_perform('uninstall_success', $aParams);
         }
     } else {
         if (!empty($this->_aConfig['uninstall_failed'])) {
             $this->_perform('uninstall_failed', $aParams);
         }
     }
     if ($bAutoDisable) {
         $aResult['result'] = $aResultDisable['result'] & $aResult['result'];
         $aResult['message'] = $aResultDisable['message'] . $aResult['message'];
     }
     bx_alert('system', 'uninstall', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     return $aResult;
 }
Example #2
0
 function getTitle($sUri)
 {
     return _t(BxDolModule::getTitleKey($sUri));
 }
Example #3
0
 function uninstall($aParams)
 {
     $oModuleDb = new BxDolModuleDb();
     $sTitle = _t('_adm_txt_modules_operation_uninstall', $this->_aConfig['title']);
     //--- Check whether the module was already installed ---//
     if (!$oModuleDb->isModule($this->_aConfig['home_uri'])) {
         return array('operation_title' => $sTitle, 'message' => _t('_adm_txt_modules_already_uninstalled'), 'result' => false);
     }
     //--- Check for dependent modules ---//
     $bDependent = false;
     $aDependents = $oModuleDb->getDependent($this->_aConfig['home_uri']);
     if (is_array($aDependents) && !empty($aDependents)) {
         $bDependent = true;
         $sMessage = '<br />-- -- ' . _t('_adm_txt_modules_has_dependents') . '<br />';
         foreach ($aDependents as $aDependent) {
             $sMessage .= '-- -- ' . $aDependent['title'] . '<br />';
         }
     }
     if ($bDependent) {
         return array('operation_title' => $sTitle, 'message' => $this->_displayResult('check_dependencies', false, $sMessage), 'result' => false);
     }
     $aResult = $this->_perform('uninstall', 'Uninstallation');
     if ($aResult['result']) {
         $iModuleId = (int) $oModuleDb->getOne("SELECT `id` FROM `sys_modules` WHERE `vendor`='" . $this->_aConfig['vendor'] . "' AND `path`='" . $this->_aConfig['home_dir'] . "' LIMIT 1");
         $oModuleDb->query("DELETE FROM `sys_modules` WHERE `vendor`='" . $this->_aConfig['vendor'] . "' AND `path`='" . $this->_aConfig['home_dir'] . "' LIMIT 1");
         $oModuleDb->query("DELETE FROM `sys_modules_file_tracks` WHERE `module_id`='" . $iModuleId . "'");
         deleteStringFromLanguage(BxDolModule::getTitleKey($this->_aConfig['home_uri']));
         compileLanguage();
         $GLOBALS['MySQL']->cleanMemory('sys_modules_' . $this->_aConfig['home_uri']);
         $GLOBALS['MySQL']->cleanMemory('sys_modules_' . $iModuleId);
         $GLOBALS['MySQL']->cleanMemory('sys_modules');
     }
     $aResult['operation_title'] = $sTitle;
     return $aResult;
 }