commit 79f67d098041c9548ed6afaf52349b8113b1fada
parent 28adebb69e9f7e97c3631d15f8eccd5d53b30fba
Author: Jan Dankert <develop@jandankert.de>
Date: Thu, 10 Sep 2020 18:30:16 +0200
Some code cleanup, killing the old "checkMenu()"-methods.
Diffstat:
17 files changed, 40 insertions(+), 210 deletions(-)
diff --git a/modules/cms/action/FileAction.class.php b/modules/cms/action/FileAction.class.php
@@ -564,39 +564,6 @@ class FileAction extends ObjectAction
- function checkMenu( $name )
- {
- $archiveTypes = $this->getArchiveTypes();
- $compressionTypes = $this->getCompressionTypes();
-
- switch( $name )
- {
- case 'uncompress':
- return !readonly() && in_array($this->file->extension,$compressionTypes);
-
- case 'compress':
- return !readonly() && !in_array($this->file->extension,$compressionTypes);
-
- case 'extract':
- return !readonly() && in_array($this->file->extension,$archiveTypes);
-
- case 'size':
- return !readonly() && $this->file->isImage();
-
- case 'editvalue':
- return !readonly() && substr($this->file->mimeType(),0,5)=='text/';
-
- case 'aclform':
- return !readonly();
-
- default:
- return true;
- }
- }
-
-
-
-
public function removeView()
{
$this->setTemplateVar( 'name',$this->file->filename );
diff --git a/modules/cms/action/FolderAction.class.php b/modules/cms/action/FolderAction.class.php
@@ -2,6 +2,7 @@
namespace cms\action;
+use language\Messages;
use util\ArchiveTar;
use cms\model\Acl;
use cms\model\Image;
@@ -1308,36 +1309,6 @@ class FolderAction extends ObjectAction
- public function checkMenu( $name )
- {
- switch( $name)
- {
- case 'createfolder':
- return !readonly() && $this->folder->hasRight(Acl::ACL_CREATE_FOLDER);
-
- case 'createfile':
- return !readonly() && $this->folder->hasRight(Acl::ACL_CREATE_FILE);
-
- case 'createlink':
- return !readonly() && $this->folder->hasRight(Acl::ACL_CREATE_LINK);
-
- case 'createpage':
- return !readonly() && $this->folder->hasRight(Acl::ACL_CREATE_PAGE);
-
- case 'remove':
- return !readonly() && count($this->folder->getObjectIds()) == 0;
-
- case 'select':
- case 'order':
- case 'aclform':
- return !readonly();
-
- default:
- return true;
- }
- }
-
-
/**
* Shows the folder content as html.
*/
@@ -1386,18 +1357,15 @@ class FolderAction extends ObjectAction
public function removePost()
{
- if ( !$this->hasRequestVar('delete') )
- throw new \util\exception\ValidationException("delete");
-
if ( $this->hasRequestVar( 'withChildren'))
$this->folder->deleteAll(); // Delete with children
else
if ( $this->folder->hasChildren() )
- throw new \util\exception\ValidationException("withChildren");
+ throw new \util\exception\ValidationException("withChildren",Messages::CONTAINS_CHILDREN);
else
$this->folder->delete(); // Only delete current folder.
- $this->addNotice('folder',$this->folder->filename,'DELETED',OR_NOTICE_OK);
+ $this->addNoticeFor($this->folder, Messages::DELETED);
}
}
\ No newline at end of file
diff --git a/modules/cms/action/ProfileAction.class.php b/modules/cms/action/ProfileAction.class.php
@@ -272,27 +272,6 @@ class ProfileAction extends BaseAction
- /**
- * @param String $name Menüpunkt
- * @return boolean true, falls Menüpunkt zugelassen
- */
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'pwchange':
- // Die Funktion "Kennwort setzen" ist nur aktiv, wenn als Authentifizierungs-Backend
- // auch die interne Benutzerdatenbank eingesetzt wird.
- return @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
-
- default:
- return true;
- }
- }
-
/**
* Setzt eine Sprache für den Benutzer.
*
diff --git a/modules/cms/action/ProjectAction.class.php b/modules/cms/action/ProjectAction.class.php
@@ -358,29 +358,7 @@ class ProjectAction extends BaseAction
}
-
-
- /**
- * @param String $name Menüpunkt
- * @return boolean true, falls Menüpunkt zugelassen
- */
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'remove':
- return !readonly();
- case 'maintenance':
- return !readonly();
-
- default:
- return true;
- }
- }
-
-
+
/**
* Ermittelt die letzten Änderungen, die im aktuellen Projekt gemacht worden sind.
*/
diff --git a/modules/cms/action/RequestParams.class.php b/modules/cms/action/RequestParams.class.php
@@ -151,7 +151,17 @@ namespace cms\action {
}
- /**
+ public function getRequiredRequestId( $varName ) {
+
+ $id = intval($this->getRequestVar($this->getRequestVar( $varName )));
+
+ if ( $id == 0 )
+ throw new ValidationException($varName);
+
+ return $id;
+ }
+
+ /**
* Ermittelt die aktuelle Id aus dem Request.<br>
* Um welche ID es sich handelt, ist abh�ngig von der Action.
*
diff --git a/modules/cms/action/StartAction.class.php b/modules/cms/action/StartAction.class.php
@@ -928,46 +928,6 @@ class StartAction extends BaseAction
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'applications':
- // Men�punkt "Anwendungen" wird nur angezeigt, wenn weitere Anwendungen
- // konfiguriert sind.
- return count(@$conf['applications']) > 0;
-
- case 'register': // Registrierung
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- return @$conf['login']['register'] && @$conf['security']['auth']['type'] == 'database';
-
- case 'password': // Kennwort vergessen
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- // Deaktiviert, falls LDAP-Lookup aktiviert ist.
- return @$conf['login']['send_password'] && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
-
- case 'administration':
- // "Administration" nat�rlich nur f�r Administratoren.
- return $this->userIsAdmin();
-
- case 'login':
- return !@$conf['login']['nologin'];
-
- case 'logout':
- return true;
-
- case 'projectmenu':
- return true;
-
- default:
- return false;
- }
- }
-
-
/**
* Maske anzeigen, um Benutzer zu registrieren.
*/
diff --git a/modules/cms/action/UserAction.class.php b/modules/cms/action/UserAction.class.php
@@ -10,6 +10,7 @@ use cms\model\BaseObject;
use cms\model\Language;
+use language\Messages;
use util\Http;
use security\Base2n;
use \security\Password;
@@ -106,26 +107,21 @@ class UserAction extends BaseAction
- function removePost()
+ public function removePost()
{
- if ( $this->hasRequestVar('confirm') )
- {
- $this->user->delete();
- $this->addNotice('user',$this->user->name,'DELETED','ok');
- }
- else
- {
- $this->addValidationError('confirm');
- return;
- }
+ $this->user->delete();
+ $this->addNoticeFor( $this->user ,Messages::DELETED);
}
- function addgrouptouser()
+ public function addgrouptouserPost()
{
- $this->user->addGroup( $this->getRequestVar('groupid') );
-
- $this->addNotice('user',$this->user->name,'ADDED','ok');
+ $group = new Group( $this->request->getRequiredRequestId('groupid' ) );
+ $group->load();
+
+ $this->user->addGroup( $group->groupid );
+
+ $this->addNoticeFor( $this->user, Messages::ADDED);
}
@@ -149,7 +145,7 @@ class UserAction extends BaseAction
*
* @access private
*/
- function mailPw( $pw )
+ protected function mailPw( $pw )
{
$to = $this->user->fullname.' <'.$this->user->mail.'>';
$mail = new Mail($to,'USER_MAIL');
@@ -318,17 +314,6 @@ class UserAction extends BaseAction
+ array('totpToken'=>Password::getTOTPCode($this->user->otpSecret))
);
- //$this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
-
- //$this->setTemplateVar('timezone_list',timezone_identifiers_list() );
-
- //$languages = explode(',',Config()->subset('i18n')->is('available'));
- //foreach($languages as $id=>$name)
- //{
- // unset($languages[$id]);
- // $languages[$name] = $name;
- //}
- //$this->setTemplateVar('language_list',$languages);
}
@@ -479,36 +464,6 @@ class UserAction extends BaseAction
}
- /**
- * @param String $name Men�punkt
- * @return boolean
- */
- function checkMenu( $menu )
- {
- global $conf;
-
- switch( $menu )
- {
- case 'add':
- case 'remove':
- return !readonly();
-
- case 'addgroup':
- return !readonly() && count($this->user->getOtherGroups()) > 0;
-
- case 'groups':
- return !readonly() && count(Group::getAll()) > 0;
-
- case 'pw':
- return !readonly()
- && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
- }
-
- return true;
- }
-
-
/**
* Wechselt zu einem ausgewählten User.
* @throws \ObjectNotFoundException
diff --git a/modules/cms/model/User.class.php b/modules/cms/model/User.class.php
@@ -551,6 +551,8 @@ SQL
'WHERE id={userid}' );
$sql->setInt ('userid',$this->userid );
$sql->query();
+
+ $this->userid = null;
}
diff --git a/modules/language/Messages.class.php b/modules/language/Messages.class.php
@@ -396,6 +396,7 @@ class Messages {
const DELETED = 'DELETED';
const DELETE = 'DELETE';
const DELETE_WITH_CHILDREN = 'DELETE_WITH_CHILDREN';
+ const CONTAINS_CHILDREN = 'CONTAINS_CHILDREN';
const DIFFERENCES_DESC = 'DIFFERENCES_DESC';
const DIFFERENCES = 'DIFFERENCES';
const DOWN = 'DOWN';
diff --git a/modules/language/lang-cn.php b/modules/language/lang-cn.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'was deleted',
'DELETE'=>'Delete',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Show differences between 2 Revisions',
'DIFFERENCES'=>'Differences',
'DOWN'=>'down',
diff --git a/modules/language/lang-de.php b/modules/language/lang-de.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'wurde gelöscht.',
'DELETE'=>'Löschen',
'DELETE_WITH_CHILDREN'=>'Löschen mit Unterelementen',
+'CONTAINS_CHILDREN'=>'Enthält Inhalt',
'DIFFERENCES_DESC'=>'Sie können sich die Unterschiede zwischen 2 Versionen anzeigen lassen',
'DIFFERENCES'=>'Unterschiede',
'DOWN'=>'runter',
diff --git a/modules/language/lang-en.php b/modules/language/lang-en.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'was deleted',
'DELETE'=>'Delete',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Show differences between 2 Revisions',
'DIFFERENCES'=>'Differences',
'DOWN'=>'down',
diff --git a/modules/language/lang-es.php b/modules/language/lang-es.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'fue suprimida',
'DELETE'=>'Effacement',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Montrer les différences entre 2 révisions',
'DIFFERENCES'=>'Différences',
'DOWN'=>'vers le bas',
diff --git a/modules/language/lang-fr.php b/modules/language/lang-fr.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'a été supprimé',
'DELETE'=>'Effacement',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Montrer les différences entre 2 révisions',
'DIFFERENCES'=>'Différences',
'DOWN'=>'vers le bas',
diff --git a/modules/language/lang-it.php b/modules/language/lang-it.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'è stata cancellata',
'DELETE'=>'Cancelación',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Demostrar las diferencias entre 2 revisiones',
'DIFFERENCES'=>'Diferencias',
'DOWN'=>'abajo',
diff --git a/modules/language/lang-ru.php b/modules/language/lang-ru.php
@@ -396,6 +396,7 @@ function language() { return array(
'DELETED'=>'удалена',
'DELETE'=>'Delete',
'DELETE_WITH_CHILDREN'=>'Delete with children',
+'CONTAINS_CHILDREN'=>'Contains content',
'DIFFERENCES_DESC'=>'Show differences between 2 Revisions',
'DIFFERENCES'=>'Differences',
'DOWN'=>'down',
diff --git a/modules/language/language.yml b/modules/language/language.yml
@@ -1948,6 +1948,9 @@ DELETE:
DELETE_WITH_CHILDREN:
de: Löschen mit Unterelementen
en: Delete with children
+CONTAINS_CHILDREN:
+ de: Enthält Inhalt
+ en: Contains content
DESCRIPTION:
de: Beschreibung
en: Description