openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 0b2eed85b7ce29cb47f184b85de0b61b2969b9cd
parent 775a1361f0bb2865dcf96a7d5fce53715249f80d
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 14 Mar 2021 23:51:49 +0100

Refactoring: Using the ValidationException where possible.

Diffstat:
Mmodules/cms/Dispatcher.class.php | 8++++----
Mmodules/cms/action/Action.class.php | 51+++++++++++++++++++++++++++------------------------
Mmodules/cms/action/file/FileCompressAction.class.php | 5++++-
Mmodules/cms/action/file/FileExtractAction.class.php | 2+-
Mmodules/cms/action/file/FileUncompressAction.class.php | 2+-
Mmodules/cms/action/folder/FolderAdvancedAction.class.php | 10+++-------
Mmodules/cms/action/folder/FolderCreatefileAction.class.php | 5+++--
Mmodules/cms/action/folder/FolderCreateimageAction.class.php | 5+++--
Mmodules/cms/action/grouplist/GrouplistAddAction.class.php | 17++++++-----------
Mmodules/cms/action/image/ImageSizeAction.class.php | 6+++---
Mmodules/cms/action/login/LoginLoginAction.class.php | 56++++++++++++++++----------------------------------------
Mmodules/cms/action/login/LoginPasswordcodeAction.class.php | 8+++-----
Mmodules/cms/action/login/LoginRegistercodeAction.class.php | 8+-------
Mmodules/cms/action/object/ObjectAclformAction.class.php | 20++++----------------
Mmodules/cms/action/pageelement/PageelementDiffAction.class.php | 9+++------
Mmodules/cms/action/profile/ProfileEditAction.class.php | 15++++-----------
Mmodules/cms/action/profile/ProfilePwAction.class.php | 45++++++++++++++++++++-------------------------
Mmodules/cms/action/project/ProjectAdvancedAction.class.php | 3++-
Mmodules/cms/action/project/ProjectPropAction.class.php | 40+++++++++++++++++-----------------------
Mmodules/cms/ui/UI.class.php | 2+-
Mmodules/language/Language_CN.class.php | 2+-
Mmodules/language/Language_DE.class.php | 2+-
Mmodules/language/Language_EN.class.php | 2+-
Mmodules/language/Language_ES.class.php | 2+-
Mmodules/language/Language_FR.class.php | 2+-
Mmodules/language/Language_IT.class.php | 2+-
Mmodules/language/Language_RU.class.php | 2+-
Mmodules/language/Messages.class.php | 2+-
Mmodules/language/language.yml | 2+-
Mmodules/util/exception/UIException.class.php | 7+++++--
Mmodules/util/exception/ValidationException.class.php | 4++--
31 files changed, 142 insertions(+), 204 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -340,7 +340,7 @@ class Dispatcher catch (ValidationException $ve) { // The validation exception is catched here - $do->addValidationError( $ve->fieldName,$ve->key ); + $do->addValidationError( $ve->fieldName,$ve->key,$ve->params ); if ( !$this->request->isAction ) // Validation exceptions should only be thrown in POST requests. @@ -373,7 +373,7 @@ class Dispatcher $enabledDbids = array_keys( $enabledDatabases ); if ( ! $enabledDbids ) - throw new UIException(Messages::DATABASE_CONNECTION_ERROR, 'No database configured.',new DatabaseException('No database configured' ) ); + throw new UIException(Messages::DATABASE_CONNECTION_ERROR, 'No database configured.', [], new DatabaseException('No database configured')); $possibleDbIds = []; @@ -404,7 +404,7 @@ class Dispatcher } catch(\Exception $e) { - throw new UIException(Messages::DATABASE_CONNECTION_ERROR, "Could not connect to DB ".$dbid, $e); + throw new UIException(Messages::DATABASE_CONNECTION_ERROR, "Could not connect to DB " . $dbid, [], $e); } // Is this the first time we are connected to this database in this session? @@ -454,7 +454,7 @@ class Dispatcher $adminDb->id = $dbid; } catch (\Exception $e) { - throw new UIException('DATABASE_ERROR_CONNECTION', $e->getMessage(),$e); + throw new UIException('DATABASE_ERROR_CONNECTION', $e->getMessage(), [], $e); } $updater->update($adminDb); diff --git a/modules/cms/action/Action.class.php b/modules/cms/action/Action.class.php @@ -6,6 +6,7 @@ use cms\base\Configuration; use cms\base\Language as L; use cms\model\ModelBase; use cms\model\User; +use language\Messages; use logger\Logger; use util\Cookie; use util\ClassUtils; @@ -38,10 +39,14 @@ abstract class Action */ abstract function checkAccess(); + + protected $errors = []; + protected $notices = []; + protected $output = []; + protected $status = Action::NOTICE_OK; + protected $success = true; + protected $templateVars = [ - 'errors' => [], - 'notices' => [], - 'output' => [] ]; /** @@ -83,20 +88,18 @@ abstract class Action */ protected function setTemplateVar($varName, $value) { - $this->templateVars['output'][$varName] = $value; + $this->output[ $varName ] = $value; } /** * Setzt eine Liste von Variablen f�r die Oberfl�che. * - * @param array $varList Assoziatives Array + * @param array $varList Output variables */ protected function setTemplateVars($varList) { - foreach ($varList as $name => $value) { - $this->setTemplateVar($name, $value); - } + $this->output += $varList; } @@ -106,12 +109,12 @@ abstract class Action * @param String $name Name des validierten Eingabefeldes * @param String Textschl�ssel der Fehlermeldung (optional) */ - public function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array()) + public function addValidationError($name, $message = Messages::COMMON_VALIDATION_ERROR, $vars = array() ) { - if (!empty($message)) - $this->addNotice('', 0, '', $message, Action::NOTICE_ERROR, $vars, $log); + if ( ! empty($message) ) + $this->addErrorFor( null, $message, $vars ); - $this->templateVars['errors'][] = $name; + $this->errors[] = $name; } @@ -187,22 +190,15 @@ abstract class Action */ private function addNotice($type, $id, $name, $text, $status = Action::NOTICE_OK, $vars = array(), $log = array()) { - if ($status === true) - $status = Action::NOTICE_OK; - elseif ($status === false) - $status = Action::NOTICE_ERROR; - - $this->templateVars['notice_status'] = $status; - $this->templateVars['status'] = $status; - $this->templateVars['success'] = ($status == Action::NOTICE_ERROR ? 'false' : 'true'); + $this->status = ($status == Action::NOTICE_ERROR) ? Action::NOTICE_ERROR : $status; + $this->success = $this->success && $status != Action::NOTICE_ERROR; if ( is_array($log) ) $log = implode("\n",$log); - if (!is_array($vars)) - $vars = array($vars); + $vars = (array) $vars; - $this->templateVars['notices'][] = [ + $this->notices[] = [ 'type' => $type, 'id' => $id , 'name' => $name, @@ -221,7 +217,14 @@ abstract class Action */ public function getOutputData() { - return $this->templateVars; + return [ + 'output' => $this->output, // output data + 'notices' => $this->notices, // notices + 'errors' => $this->errors, // fieldnames with validation errors + 'status' => $this->status, // notice status + 'notice_status' => $this->status, // same as above, historical reasons + 'success' => $this->success, // success, true if there are no errors and no notices with status error. + ]; } diff --git a/modules/cms/action/file/FileCompressAction.class.php b/modules/cms/action/file/FileCompressAction.class.php @@ -6,9 +6,11 @@ use cms\action\Method; use cms\action\RequestParams; use cms\model\File; use language\Messages; +use util\exception\ValidationException; class FileCompressAction extends FileAction implements Method { + public function view() { $formats = array(); foreach( $this->getCompressionTypes() as $t ) @@ -16,6 +18,7 @@ class FileCompressAction extends FileAction implements Method { $this->setTemplateVar('formats' ,$formats ); } + public function post() { $format = $this->request->getAlphanum('format'); @@ -63,7 +66,7 @@ class FileCompressAction extends FileAction implements Method { break; default: - throw new \util\exception\UIException('unknown compress type: ' . $format ); + throw new ValidationException('format'); } $this->addNoticeFor( $this->file, Messages::DONE); diff --git a/modules/cms/action/file/FileExtractAction.class.php b/modules/cms/action/file/FileExtractAction.class.php @@ -81,7 +81,7 @@ class FileExtractAction extends FileAction implements Method { break; default: - throw new \util\exception\UIException('cannot extract file with extension: ' . $this->file->extension ); + throw new \util\exception\UIException([]'cannot extract file with extension: ' . $this->file->extension); } } } diff --git a/modules/cms/action/file/FileUncompressAction.class.php b/modules/cms/action/file/FileUncompressAction.class.php @@ -65,7 +65,7 @@ class FileUncompressAction extends FileAction implements Method { break; default: - throw new \util\exception\UIException('','cannot uncompress file with extension: ' . $this->file->extension ); + throw new \util\exception\UIException('', 'cannot uncompress file with extension: ' . $this->file->extension, []); } $this->addNoticeFor( $this->file, Messages::DONE ); diff --git a/modules/cms/action/folder/FolderAdvancedAction.class.php b/modules/cms/action/folder/FolderAdvancedAction.class.php @@ -14,6 +14,7 @@ use cms\model\Project; use cms\model\Url; use language\Messages; use util\ArchiveTar; +use util\exception\SecurityException; use util\Html; @@ -121,14 +122,9 @@ class FolderAdvancedAction extends FolderAction implements Method { if ( ( $type=='link' && $f->hasRight( Permission::ACL_CREATE_LINK ) ) || ( ( $type=='move' || $type == 'copy' ) && ( $f->hasRight(Permission::ACL_CREATE_FOLDER) || $f->hasRight(Permission::ACL_CREATE_FILE) || $f->hasRight(Permission::ACL_CREATE_PAGE) ) ) ) - { - // OK - } + ; // OK else - { - $this->addValidationError('targetobjectid','no_rights'); - return; - } + throw new SecurityException('no_rights'); break; default: diff --git a/modules/cms/action/folder/FolderCreatefileAction.class.php b/modules/cms/action/folder/FolderCreatefileAction.class.php @@ -6,6 +6,7 @@ use cms\model\BaseObject; use cms\model\File; use cms\model\Permission; use language\Messages; +use util\exception\ValidationException; use util\Http; use util\Upload; @@ -44,8 +45,8 @@ class FolderCreatefileAction extends FolderAction implements Method { if ( !$ok ) { - $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error); - return; + $this->addWarningFor( $this->folder,Messages::COMMON_VALIDATION_ERROR,[],$http->error); + throw new ValidationException( 'url' ); } $file->desc = $description; diff --git a/modules/cms/action/folder/FolderCreateimageAction.class.php b/modules/cms/action/folder/FolderCreateimageAction.class.php @@ -6,6 +6,7 @@ use cms\model\BaseObject; use cms\model\Image; use cms\model\Permission; use language\Messages; +use util\exception\ValidationException; use util\Http; use util\Upload; @@ -44,8 +45,8 @@ class FolderCreateimageAction extends FolderAction implements Method { if ( !$ok ) { - $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error); - return; + $this->addWarningFor( $this->folder,Messages::COMMON_VALIDATION_ERROR,[],$http->error); + throw new ValidationException( 'url' ); } $image->desc = $description; diff --git a/modules/cms/action/grouplist/GrouplistAddAction.class.php b/modules/cms/action/grouplist/GrouplistAddAction.class.php @@ -11,16 +11,11 @@ class GrouplistAddAction extends GrouplistAction implements Method { } public function post() { - if ( $this->request->getText('name') != '') - { - $this->group = new Group(); - $this->group->name = $this->request->getText('name'); - $this->group->persist(); - $this->addNoticeFor( $this->group, Messages::ADDED); - } - else - { - $this->addValidationError('name'); - } + + $this->group = new Group(); + $this->group->name = $this->request->getRequiredText('name'); + $this->group->persist(); + + $this->addNoticeFor( $this->group, Messages::ADDED); } } diff --git a/modules/cms/action/image/ImageSizeAction.class.php b/modules/cms/action/image/ImageSizeAction.class.php @@ -6,6 +6,7 @@ use cms\action\Method; use cms\model\Image; use cms\model\Permission; use language\Messages; +use util\exception\ValidationException; class ImageSizeAction extends ImageAction implements Method { public function getRequiredPermission() { @@ -59,9 +60,8 @@ class ImageSizeAction extends ImageAction implements Method { ! $this->request->has('width' ) && ! $this->request->has('height') ) { - $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' ); - $this->addValidationError('height',''); - return; + $this->addWarningFor(null,Messages::INPUT_NEW_IMAGE_SIZE); + throw new ValidationException('width' ); } if ( $this->request->has('copy') ) diff --git a/modules/cms/action/login/LoginLoginAction.class.php b/modules/cms/action/login/LoginLoginAction.class.php @@ -17,6 +17,7 @@ use security\Password; use util\Browser; use util\exception\ObjectNotFoundException; use util\exception\SecurityException; +use util\exception\ValidationException; use util\Mail; use util\Session; use util\text\TextMessage; @@ -97,17 +98,9 @@ class LoginLoginAction extends LoginAction implements Method { $passwordConfig = Configuration::subset(['security','password']); if ( $newPassword1 != $newPassword2 ) - { - $this->addValidationError('password1',Messages::PASSWORDS_DO_NOT_MATCH); - $this->addValidationError('password2',''); - return; - } + throw new ValidationException('password2',Messages::PASSWORDS_DO_NOT_MATCH); elseif ( strlen($newPassword1) < $passwordConfig->get('min_length',10) ) - { - $this->addValidationError('password1',Messages::PASSWORD_MINLENGTH,array('minlength'=>$passwordConfig->get('min_length',10))); - $this->addValidationError('password2',''); - return; - } + throw new ValidationException('password1',Messages::PASSWORD_MINLENGTH,array('minlength'=>$passwordConfig->get('min_length',10))); else { // Kennwoerter identisch und lang genug. @@ -120,27 +113,15 @@ class LoginLoginAction extends LoginAction implements Method { } } - if ( $authResult & Auth::STATUS_TOKEN_NEEDED ) { + if ( $authResult & Auth::STATUS_TOKEN_NEEDED ) // Token falsch. - $this->addErrorFor(null,Messages::LOGIN_FAILED_TOKEN_FAILED ); - $this->addValidationError('user_token',''); - return; - } + throw new ValidationException('user_token',Messages::LOGIN_FAILED_TOKEN_FAILED ); if ( $authResult & Auth::STATUS_PW_EXPIRED ) { - if ( $authResult & Auth::STATUS_FAILED ) { - + if ( $authResult & Auth::STATUS_FAILED ) // Anmeldung gescheitert, Benutzer muss Kennwort ?ndern. - $this->addErrorFor( null,Messages::LOGIN_FAILED_MUSTCHANGEPASSWORD); - $this->addValidationError('password1',''); - $this->addValidationError('password2',''); - return; - } - - if ( $authResult & Auth::STATUS_FAILED ) { - $this->addWarningFor(null,Messages::LOGIN_FAILED_MUSTCHANGEPASSWORD); - } + throw new ValidationException('password1',Messages::LOGIN_FAILED_MUSTCHANGEPASSWORD); } $ip = getenv("REMOTE_ADDR"); @@ -153,11 +134,6 @@ class LoginLoginAction extends LoginAction implements Method { ] )); - // Anmeldung gescheitert. - $this->addErrorFor( null,Messages::LOGIN_FAILED, ['name' => $loginName] ); - $this->addValidationError('login_name' , ''); - $this->addValidationError('login_password', ''); - // Increase fail counter $user = User::loadWithName($loginName,User::AUTH_TYPE_INTERNAL); @@ -191,8 +167,12 @@ class LoginLoginAction extends LoginAction implements Method { } } } + + // Login failed. + throw new ValidationException('login_password',Messages::LOGIN_FAILED, ['name' => $loginName] ); } - else if ( $authResult & Auth::STATUS_SUCCESS ) { + + if ( $authResult & Auth::STATUS_SUCCESS ) { Logger::info(TextMessage::create('Login successful for user ${0}', [$loginName])); @@ -231,11 +211,7 @@ class LoginLoginAction extends LoginAction implements Method { // Anmeldung gescheitert. Logger::warn( TextMessage::create('user ${0} authenticated successful, but not found in internal user table',[$loginName]) ); - $this->addErrorFor(null,Messages::LOGIN_FAILED, ['name' => $loginName ]); - $this->addValidationError('login_name' , ''); - $this->addValidationError('login_password', ''); - - return; + throw new ValidationException('login_password',Messages::LOGIN_FAILED,['name' => $loginName ]); } } @@ -272,10 +248,10 @@ class LoginLoginAction extends LoginAction implements Method { $config['language']['language_code'] = $user->language; Session::setConfig( $config ); - } - else { - throw new \LogicException('Auth module must return either SUCCESS or FAIL, but got '.$authResult); + + return; // everything ok, user logged in. } + throw new \LogicException('Auth module must return either SUCCESS or FAIL, but got '.$authResult); } } diff --git a/modules/cms/action/login/LoginPasswordcodeAction.class.php b/modules/cms/action/login/LoginPasswordcodeAction.class.php @@ -6,6 +6,7 @@ use cms\model\User; use language\Messages; use logger\Logger; use security\Password; +use util\exception\ValidationException; use util\Mail; use util\Session; @@ -20,11 +21,8 @@ class LoginPasswordcodeAction extends LoginAction implements Method { if ( $this->request->getText("code")=='' || Session::get(Session::KEY_PASSWORD_COMMIT_CODE) != $this->request->getText("code") ) - { - $this->addValidationError('code','PASSWORDCODE_NOT_MATCH'); - return; - } - + throw new ValidationException( 'code',Messages::PASSWORDCODE_NOT_MATCH ); + $user = User::loadWithName( $username,User::AUTH_TYPE_INTERNAL ); if ( $user && $user->isValid() ) diff --git a/modules/cms/action/login/LoginRegistercodeAction.class.php b/modules/cms/action/login/LoginRegistercodeAction.class.php @@ -40,13 +40,7 @@ class LoginRegistercodeAction extends LoginAction implements Method { // Best?tigungscode stimmt ?berein. // Neuen Benutzer anlegen. - if ( !$this->request->has('username') ) - { - $this->addValidationError('username'); - return; - } - - $user = User::loadWithName( $this->request->getText('username'),User::AUTH_TYPE_INTERNAL ); + $user = User::loadWithName( $this->request->getRequiredText('username'),User::AUTH_TYPE_INTERNAL ); if ( $user ) throw new ValidationException('username',Messages::USER_ALREADY_IN_DATABASE ); diff --git a/modules/cms/action/object/ObjectAclformAction.class.php b/modules/cms/action/object/ObjectAclformAction.class.php @@ -11,6 +11,7 @@ use cms\model\Group; use cms\model\Project; use cms\model\User; use language\Messages; +use util\exception\ValidationException; class ObjectAclformAction extends ObjectAction implements Method { public function getRequiredPermission() @@ -52,25 +53,13 @@ class ObjectAclformAction extends ObjectAction implements Method { switch( $this->request->getText('type') ) { case 'user': - $permission->userid = $this->request->getText('userid' ); + $permission->userid = $this->request->getRequiredNumber('userid' ); $permission->type = Permission::TYPE_USER; - if ( $permission->userid <= 0 ) - { - $this->addValidationError('type' ); - $this->addValidationError('userid',''); - return; - } break; case 'group': - $permission->groupid = $this->request->getText('groupid'); + $permission->groupid = $this->request->getRequiredNumber('groupid'); $permission->type = Permission::TYPE_GROUP; - if ( $permission->groupid <= 0 ) - { - $this->addValidationError('type' ); - $this->addValidationError('groupid',''); - return; - } break; case 'all': $permission->type = Permission::TYPE_AUTH; @@ -79,8 +68,7 @@ class ObjectAclformAction extends ObjectAction implements Method { $permission->type = Permission::TYPE_GUEST; break; default: - $this->addValidationError('type'); - return; + throw new ValidationException('type'); } $permission->languageid = $this->request->getLanguageId(); diff --git a/modules/cms/action/pageelement/PageelementDiffAction.class.php b/modules/cms/action/pageelement/PageelementDiffAction.class.php @@ -5,6 +5,7 @@ use cms\action\PageelementAction; use cms\generator\PublishEdit; use cms\generator\PublishPreview; use cms\model\Value; +use util\exception\ValidationException; use util\Text; class PageelementDiffAction extends PageelementAction implements Method { @@ -13,13 +14,9 @@ class PageelementDiffAction extends PageelementAction implements Method { $value1id = $this->request->getNumber('compareid'); $value2id = $this->request->getNumber('withid' ); - // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen + // Wenn Value1-Id = Value2-Id if ( $value1id == $value2id ) - { - $this->addValidationError('compareid' ); - $this->addValidationError('withid' ,''); - return; - } + throw new ValidationException('withid' ); // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen if ( $value1id > $value2id ) diff --git a/modules/cms/action/profile/ProfileEditAction.class.php b/modules/cms/action/profile/ProfileEditAction.class.php @@ -44,7 +44,7 @@ class ProfileEditAction extends ProfileAction implements Method { } public function post() { - $this->user->fullname = $this->request->getText('fullname'); + $this->user->fullname = $this->request->getRequiredText('fullname'); $this->user->tel = $this->request->getText('tel' ); $this->user->desc = $this->request->getText('desc' ); $this->user->style = $this->request->getText('style' ); @@ -56,16 +56,9 @@ class ProfileEditAction extends ProfileAction implements Method { Session::setUser( $this->user ); - if ( !empty($this->user->fullname) ) - { - $this->user->persist(); - $this->addNoticeFor( $this->user,Messages::SAVED); - } - else - { - $this->addValidationError('fullname'); - } - + $this->user->persist(); + $this->addNoticeFor( $this->user,Messages::SAVED); + // Ausgewählte Sprache sofort verwenden. $l = $this->request->getText('language'); diff --git a/modules/cms/action/profile/ProfilePwAction.class.php b/modules/cms/action/profile/ProfilePwAction.class.php @@ -5,6 +5,7 @@ use cms\action\ProfileAction; use cms\base\Configuration; use cms\model\User; use language\Messages; +use util\exception\ValidationException; use util\Mail; class ProfilePwAction extends ProfileAction implements Method { @@ -21,37 +22,31 @@ class ProfilePwAction extends ProfileAction implements Method { public function post() { + $pwMinLength = Configuration::subset(['security','password'])->get('min_length',10); if ( $this->user->type != User::AUTH_TYPE_INTERNAL ) throw new \LogicException('password change only possible for internal users.'); if ( ! $this->user->checkPassword( $this->request->getText('act_password') ) ) - { - $this->addValidationError('act_password'); - } - elseif ( $this->request->getText('password1') == '' ) - { - $this->addValidationError('password1'); - } - elseif ( $this->request->getText('password1') != $this->request->getText('password2') ) - { - $this->addValidationError('password2','PASSWORDS_DO_NOT_MATCH'); - } - elseif ( strlen($this->request->getText('password1'))<$pwMinLength ) - { - $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=> $pwMinLength)); - } - else - { - $this->user->setPassword( $this->request->getText('password1') ); - $this->addNoticeFor( $this->user,Messages::SAVED); - - // Send mail to user to inform about the new password. - if ( $this->user->mail ) { - $mail = new Mail( $this->user->mail,Messages::MAIL_PASSWORD_CHANGE_SUCCESS_SUBJECT,Messages::MAIL_PASSWORD_CHANGE_SUCCESS); - $mail->send(); - } + throw new ValidationException('act_password'); + + if ( $this->request->getText('password1') == '' ) + throw new ValidationException('password1'); + + if ( $this->request->getText('password1') != $this->request->getText('password2') ) + throw new ValidationException('password2', Messages::PASSWORDS_DO_NOT_MATCH); + + if ( strlen($this->request->getText('password1'))<$pwMinLength ) + throw new ValidationException('password1',Messages::PASSWORD_MINLENGTH,array('minlength'=> $pwMinLength)); + + $this->user->setPassword( $this->request->getText('password1') ); + $this->addNoticeFor( $this->user,Messages::SAVED); + + // Send mail to user to inform about the new password. + if ( $this->user->mail ) { + $mail = new Mail( $this->user->mail,Messages::MAIL_PASSWORD_CHANGE_SUCCESS_SUBJECT,Messages::MAIL_PASSWORD_CHANGE_SUCCESS); + $mail->send(); } } } diff --git a/modules/cms/action/project/ProjectAdvancedAction.class.php b/modules/cms/action/project/ProjectAdvancedAction.class.php @@ -3,6 +3,7 @@ namespace cms\action\project; use cms\action\Method; use cms\action\ProjectAction; use language\Messages; +use util\exception\ValidationException; class ProjectAdvancedAction extends ProjectAction implements Method { public function view() { @@ -24,7 +25,7 @@ class ProjectAdvancedAction extends ProjectAction implements Method { break; default: - $this->addValidationError('type'); + throw new ValidationException('type'); } } } diff --git a/modules/cms/action/project/ProjectPropAction.class.php b/modules/cms/action/project/ProjectPropAction.class.php @@ -17,29 +17,23 @@ class ProjectPropAction extends ProjectAction implements Method { } public function post() { - if ( $this->request->getText('name') != '') - { - $this->project->name = $this->request->getAlphanum('name' ); - $this->project->url = $this->request->getAlphanum('url' ); - $this->project->target_dir = $this->request->getRaw('target_dir' ); - $this->project->ftp_url = $this->request->getRaw('ftp_url' ); - $this->project->ftp_passive = $this->request->getRaw('ftp_passive' ); - $this->project->cmd_after_publish = $this->request->getRaw('cmd_after_publish' ); - $this->project->content_negotiation = $this->request->getNumber('content_negotiation' ); - $this->project->cut_index = $this->request->getNumber('cut_index' ); - $this->project->publishFileExtension = $this->request->getNumber('publishFileExtension' ); - $this->project->publishPageExtension = $this->request->getNumber('publishPageExtension' ); - $this->project->linkAbsolute = $this->request->getNumber('linksAbsolute' ); - $this->addNoticeFor($this->project,Messages::SAVED); - $this->project->save(); // speichern - - $root = new Folder( $this->project->getRootObjectId() ); - $root->setTimestamp(); - } - else - { - $this->addValidationError('name'); - } + $this->project->name = $this->request->getRequiredText('name' ); + $this->project->url = $this->request->getAlphanum('url' ); + $this->project->target_dir = $this->request->getRaw('target_dir' ); + $this->project->ftp_url = $this->request->getRaw('ftp_url' ); + $this->project->ftp_passive = $this->request->getRaw('ftp_passive' ); + $this->project->cmd_after_publish = $this->request->getRaw('cmd_after_publish' ); + $this->project->content_negotiation = $this->request->getNumber('content_negotiation' ); + $this->project->cut_index = $this->request->getNumber('cut_index' ); + $this->project->publishFileExtension = $this->request->getNumber('publishFileExtension' ); + $this->project->publishPageExtension = $this->request->getNumber('publishPageExtension' ); + $this->project->linkAbsolute = $this->request->getNumber('linksAbsolute' ); + + $this->addNoticeFor($this->project,Messages::SAVED); + $this->project->save(); // speichern + + $root = new Folder( $this->project->getRootObjectId() ); + $root->setTimestamp(); } } diff --git a/modules/cms/ui/UI.class.php b/modules/cms/ui/UI.class.php @@ -69,7 +69,7 @@ class UI Http::noContent(); } catch (UIException $e) { Logger::warn( $e ); - throw new LogicException(L::lang($e->key),0, $e); + throw new LogicException(L::lang($e->key,$e->params),0, $e); } catch (SecurityException $e) { Logger::info($e); Http::noContent(); diff --git a/modules/language/Language_CN.class.php b/modules/language/Language_CN.class.php @@ -1355,6 +1355,6 @@ Thank you.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_DE.class.php b/modules/language/Language_DE.class.php @@ -1360,6 +1360,6 @@ Vielen Dank.', 'GROUP_PARENT'=>'Übergeordnete Gruppe', 'UNSAVED_CHANGES_CONFIRM'=>'Sie haben ungespeicherte Änderungen. Möchten Sie diese Ansicht tatsächlich verlassen?', 'PROGRESS'=>'Vorgang wird ausgeführt', -'REFERENZES'=>'Referenzen', +'REFERENCES'=>'Referenzen', ];} } \ No newline at end of file diff --git a/modules/language/Language_EN.class.php b/modules/language/Language_EN.class.php @@ -1355,6 +1355,6 @@ Thank you.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_ES.class.php b/modules/language/Language_ES.class.php @@ -1380,6 +1380,6 @@ MENU_INDEX_ADMINISTRATION_DESC =', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_FR.class.php b/modules/language/Language_FR.class.php @@ -1356,6 +1356,6 @@ Merci.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_IT.class.php b/modules/language/Language_IT.class.php @@ -1356,6 +1356,6 @@ Gracias.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_RU.class.php b/modules/language/Language_RU.class.php @@ -1356,6 +1356,6 @@ if you do not know where this mail comes from, please ignore it.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', -'REFERENZES'=>'References', +'REFERENCES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Messages.class.php b/modules/language/Messages.class.php @@ -1309,5 +1309,5 @@ class Messages { const GROUP_PARENT = 'GROUP_PARENT'; const UNSAVED_CHANGES_CONFIRM = 'UNSAVED_CHANGES_CONFIRM'; const PROGRESS = 'PROGRESS'; - const REFERENZES = 'REFERENZES'; + const REFERENCES = 'REFERENCES'; } \ No newline at end of file diff --git a/modules/language/language.yml b/modules/language/language.yml @@ -6494,6 +6494,6 @@ UNSAVED_CHANGES_CONFIRM: PROGRESS: en: Work in progress de: Vorgang wird ausgeführt -REFERENZES: +REFERENCES: de: Referenzen en: References \ No newline at end of file diff --git a/modules/util/exception/UIException.class.php b/modules/util/exception/UIException.class.php @@ -7,11 +7,14 @@ class UIException extends Exception { public $key; + public $params; + // Die Exception neu definieren, damit die Mitteilung nicht optional ist - public function __construct($key, $message, Exception $previous = null) + public function __construct($key, $message, $params, Exception $previous = null) { - $this->key = $key; + $this->key = $key; + $this->params = $params; // sicherstellen, dass alles korrekt zugewiesen wird parent::__construct($message, 0, $previous); diff --git a/modules/util/exception/ValidationException.class.php b/modules/util/exception/ValidationException.class.php @@ -8,12 +8,12 @@ class ValidationException extends UIException public $fieldName; // Die Exception neu definieren, damit die Mitteilung nicht optional ist - public function __construct($fieldName,$key='COMMON_VALIDATION_ERROR') + public function __construct($fieldName,$key='COMMON_VALIDATION_ERROR',$params = [] ) { $this->fieldName = $fieldName; // sicherstellen, dass alles korrekt zugewiesen wird - parent::__construct( $key, ''); + parent::__construct($key, '', $params ); } // maßgeschneiderte Stringdarstellung des Objektes