1: <?php
2: 3: 4: 5:
6:
7: if (!defined('XOOPS_ROOT_PATH')) exit();
8:
9: require_once XOOPS_MODULE_PATH . "/user/class/AbstractEditAction.class.php";
10: require_once XOOPS_MODULE_PATH . "/user/forms/EditUserForm.class.php";
11:
12: define ('USER_COOKIE_KEEP_TIME', 31536000);
13:
14: 15: 16:
17: class User_EditUserAction extends User_AbstractEditAction
18: {
19: 20: 21:
22: var $mUserCookie = "";
23:
24: function prepare(&$controller, &$xoopsUser, $moduleConfig)
25: {
26: parent::prepare($controller, $xoopsUser, $moduleConfig);
27: $this->mUserCookie = $moduleConfig['usercookie'];
28: }
29:
30: function _getId()
31: {
32: $root =& XCube_Root::getSingleton();
33: $uid = is_object($root->mContext->mXoopsUser) ? $root->mContext->mXoopsUser->get('uid') : 0;
34:
35: return isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : $uid;
36: }
37:
38: function &_getHandler()
39: {
40: $handler =& xoops_getmodulehandler('users', 'user');
41: return $handler;
42: }
43:
44: 45: 46: 47: 48: 49:
50: function _setupActionForm()
51: {
52: $this->mActionForm =new User_EditUserForm($this->mConfig);
53: $this->mActionForm->prepare();
54: }
55:
56: 57: 58: 59: 60: 61: 62:
63: protected function _getPagetitle()
64: {
65: return Legacy_Utils::getUserName($this->_getId());
66: }
67:
68: function isEnableCreate()
69: {
70: return false;
71: }
72:
73: function isSecure()
74: {
75: return true;
76: }
77:
78: 79: 80: 81: 82: 83:
84: function hasPermission(&$controller, &$xoopsUser, $moduleConfig)
85: {
86: if (!is_object($this->mObject)) {
87: return false;
88: }
89:
90: if ($controller->mRoot->mContext->mUser->isInRole('Module.user.Admin')) {
91: return true;
92: }
93:
94: return ($this->mObject->get('uid') == $xoopsUser->get('uid'));
95: }
96:
97: function _doExecute()
98: {
99: if ($this->mObjectHandler->insert($this->mObject)) {
100: if ($this->mActionForm->get('usercookie')) {
101: setcookie($this->mUserCookie, $this->mObject->getShow('uname'), time() + USER_COOKIE_KEEP_TIME);
102: }
103: else {
104: setcookie($this->mUserCookie);
105: }
106: $ret = false;
107: XCube_DelegateUtils::call('Legacy_Profile.SaveProfile', new XCube_Ref($ret), $this->mActionForm);
108: return $ret;
109: }
110: else {
111: return false;
112: }
113: }
114:
115: function executeViewInput(&$controller, &$xoopsUser, &$render)
116: {
117: $render->setTemplateName("user_edituser.html");
118: $render->setAttribute("actionForm", $this->mActionForm);
119: $render->setAttribute("thisUser", $this->mObject);
120: $render->setAttribute("currentUser", $xoopsUser);
121: $render->setAttribute("allow_chgmail", $this->mConfig['allow_chgmail']);
122:
123: $handler =& xoops_gethandler('timezone');
124: $timezoneArr =& $handler->getObjects();
125: $render->setAttribute('timezones', $timezoneArr);
126:
127:
128:
129:
130: $umodeOptions = array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED);
131: $render->setAttribute('umodeOptions', $umodeOptions);
132:
133:
134:
135:
136: $uorderOptions = array(0 => _OLDESTFIRST, 1 => _NEWESTFIRST);
137: $render->setAttribute('uorderOptions', $uorderOptions);
138:
139:
140:
141:
142:
143:
144:
145:
146: $root =& XCube_Root::getSingleton();
147: $root->mLanguageManager->loadPageTypeMessageCatalog('notification');
148: require_once XOOPS_ROOT_PATH . "/include/notification_constants.php";
149:
150:
151: $root =& XCube_Root::getSingleton();
152: $service =& $root->mServiceManager->getService('privateMessage');
153:
154: $methodOptions = array();
155: $methodOptions[XOOPS_NOTIFICATION_METHOD_DISABLE] = _NOT_METHOD_DISABLE;
156: if ($service != null) {
157: $methodOptions[XOOPS_NOTIFICATION_METHOD_PM] = _NOT_METHOD_PM;
158: }
159: $methodOptions[XOOPS_NOTIFICATION_METHOD_EMAIL] = _NOT_METHOD_EMAIL;
160:
161: $render->setAttribute('notify_methodOptions', $methodOptions);
162:
163: $modeOptions = array(
164: XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS,
165: XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
166: XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN
167: );
168:
169: $render->setAttribute('notify_modeOptions', $modeOptions);
170: $this->_setDatepicker();
171: }
172:
173: protected function _setDatepicker()
174: {
175: $headerScript = XCube_Root::getSingleton()->mContext->getAttribute('headerScript');
176: $headerScript->addScript('$(".datepicker").each(function(){$(this).datepicker({dateFormat: "'._JSDATEPICKSTRING.'"});});');
177: }
178:
179: function executeViewSuccess(&$controller,&$xoopsUser,&$render)
180: {
181: $controller->executeForward(XOOPS_URL . '/userinfo.php?uid=' . $this->mObject->getShow('uid'));
182: }
183:
184: function executeViewError(&$controller, &$xoopsUser, &$render)
185: {
186: $controller->executeRedirect(XOOPS_URL . '/', 1, _MD_USER_ERROR_DBUPDATE_FAILED);
187: }
188: }
189:
190: ?>
191: