_setMessage('Your profile has been updated', static::MSG_UPDATED); $lockMessage = 'Your profile is currently being edited by "%firstName% %lastName%" %userRoleTitle%. ' . 'Please try again later.'; $this->_setMessage($lockMessage, static::MSG_LOCKED); $this->_setBackUrl($this->_getRedirectUrl()); return $this; } protected function _initAction() { $defaultAction = $this->getConfig('defaultAction'); if (!in_array($defaultAction, $this->_actions)) { throw new Qs_Exception('Default action is not set properly'); } $this->_defaultAction = $defaultAction; return parent::_initAction(); } protected function _getLog() { if (null === $this->_log) { parent::_getLog(); $this->_log->setAction('edit', 'Headed to Edit Profile'); $this->_log->setAction('update', 'Profile has been updated'); } return $this->_log; } protected function _callAction() { $this->_getDataObj()->setPrimarykey($this->_doc->getAuthData('id')); parent::_callAction(); } protected function _initFromForm(\Qs_Form $form) { $this->_newPassword = $form->getElement('password')->getValue(); return parent::_initFromForm($form); } protected function _postUpdate() { $this->_updateCredential(); return parent::_postUpdate(); } protected function _updateCredential() { if (!empty($this->_newPassword)) { $data = $this->_doc->getAuth()->getStorage()->read(); $data['credential'] = $this->_newPassword; $this->_doc->getAuth()->getStorage()->write($data); } return $this; } protected function _getRedirectUrl() { $redirectUrl = Qs_SiteMap::findFirst(null, ['type' => 'User\\'], ['defaultAction' => 'view'], 'url'); if (!$redirectUrl) { /** * якщо немає сторінки з блоком інформації про юзера, то робимо перехід на першу сторінку в юзерського меню */ $redirectUrl = Qs_SiteMap::findFirst(['isAccountNavigation' => 'y'], null, null, 'url'); } if (!$redirectUrl) { $redirectUrl = BASE_URL_LANGUAGE . '/' . PARENT_PAGE; } return $redirectUrl; } }