openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f260f4aef302b24dad35050de289d740c2b933d6
parent dd8c79427b0f61c077c9ce47d61bb37578bcba29
Author: Jan Dankert <devnull@localhost>
Date:   Sat,  9 Dec 2017 23:58:30 +0100

In Klasse Project.class.php aufgeräumt und doppelte Methoden entfernt.

Diffstat:
action/LoginAction.class.php | 2+-
action/ProjectAction.class.php | 2+-
action/ProjectlistAction.class.php | 4++--
action/StartAction.class.php | 2+-
action/TitleAction.class.php | 2+-
action/WebdavAction.class.php | 4++--
model/Project.class.php | 25++++++++++++-------------
util/AdministrationTree.class.php | 212++++++++++++++++++++++++++++++++++++++++----------------------------------------
8 files changed, 126 insertions(+), 127 deletions(-)

diff --git a/action/LoginAction.class.php b/action/LoginAction.class.php @@ -1528,7 +1528,7 @@ class LoginAction extends Action Session::setObject( '' ); } } - elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::available($vars[REQ_PARAM_PROJECT_ID]) ) + elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) ) { $project = new Project( $vars[REQ_PARAM_PROJECT_ID] ); $project->load(); diff --git a/action/ProjectAction.class.php b/action/ProjectAction.class.php @@ -82,7 +82,7 @@ class ProjectAction extends Action // Projekte ermitteln $list = array(); - foreach( Project::getAll() as $id=>$name ) + foreach(Project::getAllProjects() as $id=> $name ) { $list[$id] = array(); $list[$id]['url' ] = Html::url('project','edit',$id); diff --git a/action/ProjectlistAction.class.php b/action/ProjectlistAction.class.php @@ -53,7 +53,7 @@ class ProjectlistAction extends Action // Projekte ermitteln $list = array(); - foreach( Project::getAll() as $id=>$name ) + foreach(Project::getAllProjects() as $id=> $name ) { $list[$id] = array(); $list[$id]['id' ] = $id; @@ -66,7 +66,7 @@ class ProjectlistAction extends Action function addView() { - $this->setTemplateVar( 'projects',Project::getAll() ); + $this->setTemplateVar( 'projects',Project::getAllProjects() ); } diff --git a/action/StartAction.class.php b/action/StartAction.class.php @@ -1074,7 +1074,7 @@ class StartAction extends Action Session::setProjectLanguage( $language ); } } - elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::available($vars[REQ_PARAM_PROJECT_ID]) ) + elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) ) { $project = new Project( $vars[REQ_PARAM_PROJECT_ID] ); $project->load(); diff --git a/action/TitleAction.class.php b/action/TitleAction.class.php @@ -62,7 +62,7 @@ class TitleAction extends Action if ( is_object($project) ) { $this->setTemplateVar('projectname',$project->name); - $this->setTemplateVar('projects' ,Project::getAll() ); + $this->setTemplateVar('projects' ,Project::getAllProjects() ); } diff --git a/action/WebdavAction.class.php b/action/WebdavAction.class.php @@ -446,7 +446,7 @@ class WebdavAction extends Action if ( $this->requestType == 'projectlist' ) { - foreach( Project::getAll() as $projectName ) + foreach(Project::getAllProjects() as $projectName ) { $objektinhalt = array(); $z = 30*365.25*24*60*60; @@ -897,7 +897,7 @@ class WebdavAction extends Action $inhalte[] = $objektinhalt; - foreach( Project::getAll() as $projectid=>$projectName ) + foreach(Project::getAllProjects() as $projectid=> $projectName ) { $project = new Project( $projectid ); $rootObjectId = $project->getRootObjectId(); diff --git a/model/Project.class.php b/model/Project.class.php @@ -35,9 +35,12 @@ class Project /** - * Stellt fest, ob die angegebene Id existiert. + * Stellt fest, ob die angegebene Projekt-Id existiert. + * @param $id int Projekt-Id + * @return boolean + * */ - public function available( $id ) + public function isAvailable($id ) { $db = db_connection(); @@ -49,15 +52,11 @@ class Project } - // Liefert alle verf?gbaren Projekte - public function getAll() - { - return Project::getAllProjects(); - } - - - // Liefert alle verf?gbaren Projekte - public function getAllProjects() + /** + * Liefert alle verf?gbaren Projekte. + * @return array + */ + public function getAllProjects() { $db = db_connection(); $sql = $db->sql( 'SELECT id,name FROM {{project}} '. @@ -67,8 +66,8 @@ class Project } - // Liefert alle verf?gbaren Projekt-Ids - public function getAllProjectIds() + // Liefert alle verf?gbaren Projekt-Ids + public function getAllProjectIds() { $db = db_connection(); $sql = $db->sql( 'SELECT id FROM {{project}} '. diff --git a/util/AdministrationTree.class.php b/util/AdministrationTree.class.php @@ -78,9 +78,9 @@ class AdministrationTree extends AbstractTree $treeElement->icon = 'userlist'; $treeElement->type = 'userandgroups'; - $this->addTreeElement( $treeElement ); + $this->addTreeElement( $treeElement ); // $this->userandgroups(0);; - + if ( $conf_config['enable'] ) { $treeElement = new TreeElement(); @@ -143,7 +143,7 @@ class AdministrationTree extends AbstractTree function projects( ) { // Schleife ueber alle Projekte - foreach( Project::getAll() as $id=>$name ) + foreach(Project::getAllProjects() as $id=> $name ) { $treeElement = new TreeElement(); @@ -163,109 +163,109 @@ class AdministrationTree extends AbstractTree - function project( $projectid ) - { - $project = new Project( $projectid ); - - // Hoechster Ordner der Projektstruktur - $folder = new Folder( $project->getRootObjectId() ); - $folder->load(); - - - // Ermitteln, ob der Benutzer Projektadministrator ist - // Projektadministratoren haben das Recht, im Root-Ordner die Eigenschaften zu aendern. - if ( $folder->hasRight( ACL_PROP ) ) - $this->userIsProjectAdmin = true; - - if ( $folder->hasRight( ACL_READ ) ) - { - $treeElement = new TreeElement(); - $treeElement->id = $folder->objectid; - // $treeElement->text = $folder->name; - $treeElement->text = lang('FOLDER_ROOT'); - $treeElement->description = lang('FOLDER_ROOT_DESC'); - $treeElement->icon = 'folder'; - $treeElement->action = 'folder'; - $treeElement->url = Html::url( 'folder','',$folder->objectid,array(REQ_PARAM_TARGET=>'content') ); - $treeElement->target = 'content'; - $treeElement->type = 'folder'; - $treeElement->internalId = $folder->objectid; - $this->addTreeElement( $treeElement ); - } - - - if ( $this->userIsProjectAdmin ) - { - // Templates - $treeElement = new TreeElement(); - $treeElement->id = 0; - $treeElement->text = lang('GLOBAL_TEMPLATES'); - $treeElement->url = Html::url('template','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); - $treeElement->description= lang('GLOBAL_TEMPLATES_DESC'); - $treeElement->icon = 'templatelist'; - $treeElement->action = 'templatelist'; - $treeElement->target = 'content'; - $treeElement->type = 'templates'; - $this->addTreeElement( $treeElement ); - } - - - // Sprachen - $treeElement = new TreeElement(); - $treeElement->description= ''; - $treeElement->id = 0; - $treeElement->action = 'languagelist'; - $treeElement->text = lang('GLOBAL_LANGUAGES'); - $treeElement->url = Html::url('language','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); - $treeElement->icon = 'languagelist'; - $treeElement->description= lang('GLOBAL_LANGUAGES_DESC'); - $treeElement->target = 'content'; - - // Nur fuer Projekt-Administratoren aufklappbar - if ( $this->userIsProjectAdmin ) - $treeElement->type = 'languages'; - - $this->addTreeElement( $treeElement ); - - - // Projektmodelle - $treeElement = new TreeElement(); - $treeElement->description= ''; - - // Nur fuer Projekt-Administratoren aufklappbar - if ( $this->userIsProjectAdmin ) - $treeElement->type = 'models'; - - $treeElement->id = 0; - $treeElement->description= lang('GLOBAL_MODELS_DESC'); - $treeElement->text = lang('GLOBAL_MODELS'); - $treeElement->url = Html::url('model','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); - $treeElement->action = 'modellist'; - $treeElement->icon = 'modellist'; - $treeElement->target = 'content'; - $this->addTreeElement( $treeElement ); - - - // Sonstiges - // $treeElement = new TreeElement(); - // $treeElement->text = lang('GLOBAL_OTHER'); - // $treeElement->description= lang('GLOBAL_OTHER_DESC'); - // $treeElement->icon = 'other'; - // $treeElement->type = 'other'; - // $this->addTreeElement( $treeElement ); - - // Suche - $treeElement = new TreeElement(); - $treeElement->id = 0; - $treeElement->text = lang('GLOBAL_SEARCH'); - $treeElement->url = Html::url('search','',0,array(REQ_PARAM_TARGET=>'content')); - $treeElement->action = 'search'; - $treeElement->icon = 'search'; - $treeElement->description = lang('GLOBAL_SEARCH_DESC'); - $treeElement->target = 'content'; - $this->addTreeElement( $treeElement ); - - } + function project( $projectid ) + { + $project = new Project( $projectid ); + + // Hoechster Ordner der Projektstruktur + $folder = new Folder( $project->getRootObjectId() ); + $folder->load(); + + + // Ermitteln, ob der Benutzer Projektadministrator ist + // Projektadministratoren haben das Recht, im Root-Ordner die Eigenschaften zu aendern. + if ( $folder->hasRight( ACL_PROP ) ) + $this->userIsProjectAdmin = true; + + if ( $folder->hasRight( ACL_READ ) ) + { + $treeElement = new TreeElement(); + $treeElement->id = $folder->objectid; + // $treeElement->text = $folder->name; + $treeElement->text = lang('FOLDER_ROOT'); + $treeElement->description = lang('FOLDER_ROOT_DESC'); + $treeElement->icon = 'folder'; + $treeElement->action = 'folder'; + $treeElement->url = Html::url( 'folder','',$folder->objectid,array(REQ_PARAM_TARGET=>'content') ); + $treeElement->target = 'content'; + $treeElement->type = 'folder'; + $treeElement->internalId = $folder->objectid; + $this->addTreeElement( $treeElement ); + } + + + if ( $this->userIsProjectAdmin ) + { + // Templates + $treeElement = new TreeElement(); + $treeElement->id = 0; + $treeElement->text = lang('GLOBAL_TEMPLATES'); + $treeElement->url = Html::url('template','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); + $treeElement->description= lang('GLOBAL_TEMPLATES_DESC'); + $treeElement->icon = 'templatelist'; + $treeElement->action = 'templatelist'; + $treeElement->target = 'content'; + $treeElement->type = 'templates'; + $this->addTreeElement( $treeElement ); + } + + + // Sprachen + $treeElement = new TreeElement(); + $treeElement->description= ''; + $treeElement->id = 0; + $treeElement->action = 'languagelist'; + $treeElement->text = lang('GLOBAL_LANGUAGES'); + $treeElement->url = Html::url('language','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); + $treeElement->icon = 'languagelist'; + $treeElement->description= lang('GLOBAL_LANGUAGES_DESC'); + $treeElement->target = 'content'; + + // Nur fuer Projekt-Administratoren aufklappbar + if ( $this->userIsProjectAdmin ) + $treeElement->type = 'languages'; + + $this->addTreeElement( $treeElement ); + + + // Projektmodelle + $treeElement = new TreeElement(); + $treeElement->description= ''; + + // Nur fuer Projekt-Administratoren aufklappbar + if ( $this->userIsProjectAdmin ) + $treeElement->type = 'models'; + + $treeElement->id = 0; + $treeElement->description= lang('GLOBAL_MODELS_DESC'); + $treeElement->text = lang('GLOBAL_MODELS'); + $treeElement->url = Html::url('model','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); + $treeElement->action = 'modellist'; + $treeElement->icon = 'modellist'; + $treeElement->target = 'content'; + $this->addTreeElement( $treeElement ); + + + // Sonstiges + // $treeElement = new TreeElement(); + // $treeElement->text = lang('GLOBAL_OTHER'); + // $treeElement->description= lang('GLOBAL_OTHER_DESC'); + // $treeElement->icon = 'other'; + // $treeElement->type = 'other'; + // $this->addTreeElement( $treeElement ); + + // Suche + $treeElement = new TreeElement(); + $treeElement->id = 0; + $treeElement->text = lang('GLOBAL_SEARCH'); + $treeElement->url = Html::url('search','',0,array(REQ_PARAM_TARGET=>'content')); + $treeElement->action = 'search'; + $treeElement->icon = 'search'; + $treeElement->description = lang('GLOBAL_SEARCH_DESC'); + $treeElement->target = 'content'; + $this->addTreeElement( $treeElement ); + + }