XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
ModuleUninstallAction.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15require_once XOOPS_LEGACY_PATH . '/admin/actions/AbstractModuleInstallAction.class.php';
16require_once XOOPS_LEGACY_PATH . '/admin/class/ModuleInstallUtils.class.php';
17require_once XOOPS_LEGACY_PATH . '/admin/forms/ModuleUninstallForm.class.php';
18
19
67class Legacy_ModuleUninstallAction extends Legacy_Action
68{
73 public $mUninstallSuccess = null;
74
79 public $mUninstallFail = null;
80
85 public $mXoopsModule = null;
86
91 public $mInstaller = null;
92
97 public $mActionForm = null;
98
99 public function __construct($flag)
100 {
101 parent::__construct($flag);
102
103 $this->mUninstallSuccess =new XCube_Delegate();
104 $this->mUninstallSuccess->register('Legacy_ModuleUninstallAction.UninstallSuccess');
105
106 $this->mUninstallFail =new XCube_Delegate();
107 $this->mUninstallFail->register('Legacy_ModuleUninstallAction.UninstallFail');
108 }
109
110 public function prepare(&$controller, &$xoopsUser)
111 {
112 $dirname = $controller->mRoot->mContext->mRequest->getRequest('dirname');
113
114 $handler =& xoops_gethandler('module');
115 $this->mXoopsModule =& $handler->getByDirname($dirname);
116
117 if (!(is_object($this->mXoopsModule) && 0 == $this->mXoopsModule->get('isactive'))) {
118 return false;
119 }
120 $this->mXoopsModule->loadInfoAsVar($dirname);
121
122 $this->_setupActionForm();
123
124 $this->mInstaller =& $this->_getInstaller();
125
126 //
127 // Set the current object.
128 //
129 $this->mInstaller->setCurrentXoopsModule($this->mXoopsModule);
130
131 return true;
132 }
133
134 public function &_getInstaller()
135 {
136 $dirname = $this->mXoopsModule->get('dirname');
137 $installer =& Legacy_ModuleInstallUtils::createUninstaller($dirname);
138 return $installer;
139 }
140
141 public function _setupActionForm()
142 {
143 $this->mActionForm =new Legacy_ModuleUninstallForm();
144 $this->mActionForm->prepare();
145 }
146
147 public function getDefaultView(&$controller, &$xoopsUser)
148 {
149 $this->mActionForm->load($this->mXoopsModule);
150
151 return LEGACY_FRAME_VIEW_INPUT;
152 }
153
154 public function execute(&$controller, &$xoopsUser)
155 {
156 if (isset($_REQUEST['_form_control_cancel'])) {
157 return LEGACY_FRAME_VIEW_CANCEL;
158 }
159
160 $this->mActionForm->fetch();
161 $this->mActionForm->validate();
162
163 if ($this->mActionForm->hasError()) {
164 return $this->getDefaultView($controller, $xoopsUser);
165 }
166
167 $this->mInstaller->setForceMode($this->mActionForm->get('force'));
168 $this->mInstaller->executeUninstall();
169
170 return LEGACY_FRAME_VIEW_SUCCESS;
171 }
172
173 public function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
174 {
175 if (!$this->mInstaller->mLog->hasError()) {
176 $this->mUninstallSuccess->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
177 XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Success'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
178 XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.Success', new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
179 } else {
180 $this->mUninstallFail->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
181 XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Fail'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
182 XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.Fail', new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
183 }
184
185 $renderer->setTemplateName('module_uninstall_success.html');
186 $renderer->setAttribute('module', $this->mXoopsModule);
187 $renderer->setAttribute('log', $this->mInstaller->mLog->mMessages);
188 }
189
190 public function executeViewInput(&$controller, &$xoopsUser, &$renderer)
191 {
192 $renderer->setTemplateName('module_uninstall.html');
193 $renderer->setAttribute('actionForm', $this->mActionForm);
194 $renderer->setAttribute('module', $this->mXoopsModule);
195 $renderer->setAttribute('currentVersion', round($this->mXoopsModule->get('version') / 100, 2)); // !Fix version TODO revision
196 }
197
198 public function executeViewCancel(&$controller, &$xoopsUser, &$renderer)
199 {
200 $controller->executeForward('./index.php?action=ModuleList');
201 }
202}
Module Uninstall function having possibility to extend by module developers.
[Final] Used for the simple mechanism for common delegation in XCube.