1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_LEGACY_PATH . "/admin/actions/AbstractModuleInstallAction.class.php";
14: require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
15: require_once XOOPS_LEGACY_PATH . "/admin/forms/ModuleUninstallForm.class.php";
16:
17:
18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64:
65: class Legacy_ModuleUninstallAction extends Legacy_Action
66: {
67: 68: 69: 70:
71: var $mUninstallSuccess = null;
72:
73: 74: 75: 76:
77: var $mUninstallFail = null;
78:
79: 80: 81: 82:
83: var $mXoopsModule = null;
84:
85: 86: 87: 88:
89: var $mInstaller = null;
90:
91: function Legacy_ModuleUninstallAction($flag)
92: {
93: parent::Legacy_Action($flag);
94:
95: $this->mUninstallSuccess =new XCube_Delegate();
96: $this->mUninstallSuccess->register('Legacy_ModuleUninstallAction.UninstallSuccess');
97:
98: $this->mUninstallFail =new XCube_Delegate();
99: $this->mUninstallFail->register('Legacy_ModuleUninstallAction.UninstallFail');
100: }
101:
102: function prepare(&$controller, &$xoopsUser)
103: {
104: $dirname = $controller->mRoot->mContext->mRequest->getRequest('dirname');
105:
106: $handler =& xoops_gethandler('module');
107: $this->mXoopsModule =& $handler->getByDirname($dirname);
108:
109: if (!(is_object($this->mXoopsModule) && $this->mXoopsModule->get('isactive') == 0)) {
110: return false;
111: }
112: $this->mXoopsModule->loadInfoAsVar($dirname);
113:
114: $this->_setupActionForm();
115:
116: $this->mInstaller =& $this->_getInstaller();
117:
118:
119:
120:
121: $this->mInstaller->setCurrentXoopsModule($this->mXoopsModule);
122:
123: return true;
124: }
125:
126: function &_getInstaller()
127: {
128: $dirname = $this->mXoopsModule->get('dirname');
129: $installer =& Legacy_ModuleInstallUtils::createUninstaller($dirname);
130: return $installer;
131: }
132:
133: function _setupActionForm()
134: {
135: $this->mActionForm =new Legacy_ModuleUninstallForm();
136: $this->mActionForm->prepare();
137: }
138:
139: function getDefaultView(&$controller, &$xoopsUser)
140: {
141: $this->mActionForm->load($this->mXoopsModule);
142:
143: return LEGACY_FRAME_VIEW_INPUT;
144: }
145:
146: function execute(&$controller, &$xoopsUser)
147: {
148: if (isset($_REQUEST['_form_control_cancel'])) {
149: return LEGACY_FRAME_VIEW_CANCEL;
150: }
151:
152: $this->mActionForm->fetch();
153: $this->mActionForm->validate();
154:
155: if ($this->mActionForm->hasError()) {
156: return $this->getDefaultView($controller, $xoopsUser);
157: }
158:
159: $this->mInstaller->setForceMode($this->mActionForm->get('force'));
160: $this->mInstaller->executeUninstall();
161:
162: return LEGACY_FRAME_VIEW_SUCCESS;
163: }
164:
165: function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
166: {
167: if (!$this->mInstaller->mLog->hasError()) {
168: $this->mUninstallSuccess->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
169: XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Success'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
170: }
171: else {
172: $this->mUninstallFail->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
173: XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Fail'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
174: }
175:
176: $renderer->setTemplateName("module_uninstall_success.html");
177: $renderer->setAttribute('module',$this->mXoopsModule);
178: $renderer->setAttribute('log', $this->mInstaller->mLog->mMessages);
179: }
180:
181: function executeViewInput(&$controller, &$xoopsUser, &$renderer)
182: {
183: $renderer->setTemplateName("module_uninstall.html");
184: $renderer->setAttribute('actionForm', $this->mActionForm);
185: $renderer->setAttribute('module', $this->mXoopsModule);
186: $renderer->setAttribute('currentVersion', round($this->mXoopsModule->get('version') / 100, 2));
187: }
188:
189: function executeViewCancel(&$controller, &$xoopsUser, &$renderer)
190: {
191: $controller->executeForward("./index.php?action=ModuleList");
192: }
193: }
194:
195: ?>
196: