XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
UserDeleteAction.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_MODULE_PATH . '/user/forms/UserDeleteForm.class.php';
13
14/***
15 * @internal
16 * This action is for self delete function.
17 *
18 * Site owner want various procedure to this action. Therefore, this action may
19 * have to implement main logic with Delegate only.
20 */
21class User_UserDeleteAction extends User_Action
22{
23 public $mActionForm = null;
24 public $mObject = null;
25
26 public $mSelfDelete = false;
27 public $mSelfDeleteConfirmMessage = '';
28
29 public $_mDoDelete;
30
38 protected function _getPageAction()
39 {
40 return _DELETE;
41 }
42
50 protected function _getPagetitle()
51 {
53 }
54
55 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
56 {
57 $this->mSelfDelete = $moduleConfig['self_delete'];
58 $this->mSelfDeleteConfirmMessage = $moduleConfig['self_delete_confirm'];
59
60 $this->mActionForm =new User_UserDeleteForm();
61 $this->mActionForm->prepare();
62
63 $this->_mDoDelete =new XCube_Delegate('bool &', 'Legacy_Controller', 'XoopsUser');
64 $this->_mDoDelete->register('User_UserDeleteAction._doDelete');
65
66 $this->_mDoDelete->add([&$this, '_doDelete']);
67
68 //
69 // pre condition check
70 //
71 if (!$this->mSelfDelete) {
72 $controller->executeForward(XOOPS_URL . '/');
73 }
74
75 if (is_object($xoopsUser)) {
76 $handler =& xoops_getmodulehandler('users', 'user');
77 $this->mObject =& $handler->get($xoopsUser->get('uid'));
78 }
79 }
80
81 public function isSecure()
82 {
83 return true;
84 }
85
86 public function hasPermission(&$controller, &$xoopsUser, $moduleConfig)
87 {
88 if (1 == $xoopsUser->get('uid')) {
89 return false;
90 }
91
92 return true;
93 }
94
95 public function getDefaultView(&$controller, &$xoopsUser)
96 {
97 return USER_FRAME_VIEW_INPUT;
98 }
99
106 public function execute(&$controller, &$xoopsUser)
107 {
108 $this->mActionForm->fetch();
109 $this->mActionForm->validate();
110
111 if ($this->mActionForm->hasError()) {
112 return $this->getDefaultView($controller, $xoopsUser);
113 }
114
115 $flag = false;
116 $this->_mDoDelete->call(new XCube_Ref($flag), $controller, $xoopsUser);
117
118 if ($flag) {
119 XCube_DelegateUtils::call('Legacy.Event.UserDelete', new XCube_Ref($this->mObject));
120
121 return USER_FRAME_VIEW_SUCCESS;
122 }
123
124 return USER_FRAME_VIEW_ERROR;
125 }
126
135 public function _doDelete(&$flag, $controller, $xoopsUser)
136 {
137 $handler =& xoops_gethandler('member');
138 if ($handler->deleteUser($xoopsUser)) {
139 $handler =& xoops_gethandler('online');
140 $handler->destroy($this->mObject->get('uid'));
141 xoops_notification_deletebyuser($this->mObject->get('uid'));
142
143 $flag = true;
144 }
145
146 $flag |= false;
147 }
148
149 public function executeViewInput(&$controller, &$xoopsUser, &$render)
150 {
151 $render->setTemplateName('user_delete.html');
152 $render->setAttribute('object', $this->mObject);
153 $render->setAttribute('actionForm', $this->mActionForm);
154 $render->setAttribute('self_delete_message', $this->mSelfDeleteConfirmMessage);
155 }
156
157 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
158 {
159 $render->setTemplateName('user_delete_success.html');
160 $render->setAttribute('object', $this->mObject);
161 }
162
163 public function executeViewError(&$controller, &$xoopsUser, &$render)
164 {
165 $controller->executeRedirect(XOOPS_URL . '/', 3, _MD_USER_ERROR_DBUPDATE_FAILED);
166 }
167}
static getUserName( $uid)
execute(&$controller, &$xoopsUser)
_doDelete(&$flag, $controller, $xoopsUser)
[Final] Used for the simple mechanism for common delegation in XCube.