XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
UserEditAction.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_MODULE_PATH . '/user/class/AbstractEditAction.class.php';
13require_once XOOPS_MODULE_PATH . '/user/admin/forms/UserAdminEditForm.class.php';
14
16{
17 public function _getId()
18 {
19 return xoops_getrequest('uid');
20 }
21
22 public function &_getHandler()
23 {
24 $handler =& xoops_getmodulehandler('users');
25 return $handler;
26 }
27
28 public function _setupActionForm()
29 {
30 $this->mActionForm =new User_UserAdminEditForm();
31 $this->mActionForm->prepare();
32 }
33
34 public function _setupObject()
35 {
36 $id = $this->_getId();
37
38 $this->mObjectHandler = $this->_getHandler();
39
40 $this->mObject =& $this->mObjectHandler->get($id);
41
42 if (null == $this->mObject && $this->isEnableCreate()) {
43 $root =& XCube_Root::getSingleton();
44 $this->mObject =& $this->mObjectHandler->create();
45 $this->mObject->set('timezone_offset', $root->mContext->getXoopsConfig('server_TZ'));
46 }
47 }
48
49 public function executeViewInput(&$controller, &$xoopsUser, &$render)
50 {
51 $render->setTemplateName('user_edit.html');
52 $render->setAttribute('actionForm', $this->mActionForm);
53
54 //
55 // Get some objects for input form.
56 //
57 $tzoneHandler =& xoops_gethandler('timezone');
58 $timezones =& $tzoneHandler->getObjects();
59
60 $render->setAttribute('timezones', $timezones);
61
62 $rankHandler =& xoops_getmodulehandler('ranks');
63 $ranks =& $rankHandler->getObjects(new Criteria('rank_special', 1));
64
65 $render->setAttribute('ranks', $ranks);
66
67 $groupHandler =& xoops_gethandler('group');
68 $groups =& $groupHandler->getObjects(null, true);
69
70 $groupOptions = [];
71 foreach ($groups as $gid => $group) {
72 $groupOptions[$gid] = $group->getVar('name');
73 }
74
75 $render->setAttribute('groupOptions', $groupOptions);
76
77 //
78 // umode option
79 //
80 $umodeOptions = ['nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED];
81 $render->setAttribute('umodeOptions', $umodeOptions);
82
83 //
84 // uorder option
85 //
86 $uorderOptions = [0 => _OLDESTFIRST, 1 => _NEWESTFIRST];
87 $render->setAttribute('uorderOptions', $uorderOptions);
88
89 //
90 // notify option
91 //
92
93 //
94 // TODO Because abstract message catalog style is not decided, we load directly.
95 //
96 $root =& XCube_Root::getSingleton();
97 $root->mLanguageManager->loadPageTypeMessageCatalog('notification');
98 require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
99
100 // Check the PM service has been installed.
101 $service =& $root->mServiceManager->getService('privateMessage');
102
103 $methodOptions = [];
104 $methodOptions[XOOPS_NOTIFICATION_METHOD_DISABLE] = _NOT_METHOD_DISABLE;
105 if (null != $service) {
106 $methodOptions[XOOPS_NOTIFICATION_METHOD_PM] = _NOT_METHOD_PM;
107 }
108 $methodOptions[XOOPS_NOTIFICATION_METHOD_EMAIL] = _NOT_METHOD_EMAIL;
109
110 $render->setAttribute('notify_methodOptions', $methodOptions);
111
112 $modeOptions = [
113 XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS,
114 XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
115 XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN
116 ];
117 $render->setAttribute('notify_modeOptions', $modeOptions);
118 }
119
120 public function _doExecute()
121 {
122 $ret = parent::_doExecute();
123 $this->mActionForm->set('uid', $this->mObject->get('uid'));
124 if (true === $ret) {
125 XCube_DelegateUtils::call('Legacy_Profile.SaveProfile', new XCube_Ref($ret), $this->mActionForm);
126 }
127 return $ret;
128 }
129
130 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
131 {
132 $controller->executeForward('./index.php?action=UserList');
133 }
134
135 public function executeViewError(&$controller, &$xoopsUser, &$render)
136 {
137 $controller->executeRedirect('index.php', 1, _MD_USER_ERROR_DBUPDATE_FAILED);
138 }
139
140 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
141 {
142 $controller->executeForward('./index.php?action=UserList');
143 }
144}