openrat-cms

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

commit cde9eca8f8996aca17188274f3638cc73b47ff15
parent d57b904272be9629bbdc56bb4d1d9b15a543d044
Author: Jan Dankert <devnull@localhost>
Date:   Thu, 16 Aug 2018 00:36:25 +0200

Aufgeräumt: Veraltete Session-Funktionen entfernt, da Projekt,Sprache,Model nicht mehr in der Session gehalten werden.

Diffstat:
modules/cms-core/Dispatcher.class.php | 11+++++++----
modules/cms-core/action/Action.class.php | 2+-
modules/cms-core/action/ElementAction.class.php | 17+++++++++++++----
modules/cms-core/action/FilebrowserAction.class.php | 2++
modules/cms-core/action/FolderAction.class.php | 14++++++++++----
modules/cms-core/action/LanguageAction.class.php | 24------------------------
modules/cms-core/action/LanguagelistAction.class.php | 5-----
modules/cms-core/action/LinkAction.class.php | 4+---
modules/cms-core/action/LoginAction.class.php | 423-------------------------------------------------------------------------------
modules/cms-core/action/ModelAction.class.php | 2--
modules/cms-core/action/ObjectAction.class.php | 11++++++++++-
modules/cms-core/action/PageAction.class.php | 48++++++++++++------------------------------------
modules/cms-core/action/PageelementAction.class.php | 46+++++++++++++++++++++-------------------------
modules/cms-core/action/SearchAction.class.php | 107+++++++++++++++++++++++++++++++++++++------------------------------------------
modules/cms-core/action/StartAction.class.php | 370+------------------------------------------------------------------------------
modules/cms-core/action/TemplateAction.class.php | 7+++++--
modules/cms-core/action/TemplatelistAction.class.php | 10+++-------
modules/cms-core/action/TreeAction.class.php | 30+++++++++++++++---------------
modules/cms-core/action/UrlAction.class.php | 2--
modules/cms-core/model/BaseObject.class.php | 43+++----------------------------------------
modules/cms-core/model/Element.class.php | 8+++++++-
modules/cms-core/model/Folder.class.php | 126++-----------------------------------------------------------------------------
modules/cms-core/model/Language.class.php | 80++++++++-----------------------------------------------------------------------
modules/cms-core/model/Model.class.php | 66------------------------------------------------------------------
modules/cms-core/model/Page.class.php | 3++-
modules/cms-core/model/Project.class.php | 52+++++++++++++++++++++++++++++++++++++++++++++++++---
modules/cms-core/model/Template.class.php | 113++++++++++++++++++++++++++++---------------------------------------------------
modules/cms-macros/macro/LanguageLinksForPage.class.php | 6++++--
modules/cms-ui/action/IndexAction.class.php | 53+++++++++++++++++++++++++++++++++++++++++++++++++----
modules/util/Api.class.php | 4+++-
modules/util/Macro.class.php | 2+-
modules/util/Session.class.php | 129++-----------------------------------------------------------------------------
modules/util/exception/ValidationException.class.php | 26++++++++++++++++++++++++++
modules/util/require.php | 7++++---
34 files changed, 353 insertions(+), 1500 deletions(-)

diff --git a/modules/cms-core/Dispatcher.class.php b/modules/cms-core/Dispatcher.class.php @@ -184,9 +184,6 @@ class Dispatcher Logger::$messageCallback = function () { - $action = Session::get('action'); - if (empty($action)) - $action = '-'; $action = Session::get('action'); if (empty($action)) @@ -323,7 +320,13 @@ class Dispatcher if (!method_exists($do, $subactionMethodName)) throw new BadMethodCallException("Method '$subactionMethodName' does not exist"); - $do->$subactionMethodName(); // <== Executing the Action + try { + $do->$subactionMethodName(); // <== Executing the Action + } + catch (\ValidationException $ve) + { + $do->addValidationError( $ve->fieldName ); + } // The action is able to change its method name. $this->subaction = $do->subActionName; diff --git a/modules/cms-core/action/Action.class.php b/modules/cms-core/action/Action.class.php @@ -229,7 +229,7 @@ namespace cms\action { * @param String $name Name des validierten Eingabefeldes * @param String Textschl�ssel der Fehlermeldung (optional) */ - protected function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array()) + public function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array()) { if (!empty($message)) $this->addNotice('', '', $message, OR_NOTICE_ERROR, $vars, $log); diff --git a/modules/cms-core/action/ElementAction.class.php b/modules/cms-core/action/ElementAction.class.php @@ -4,6 +4,7 @@ namespace cms\action; use cms\model\Element; +use cms\model\Project; use cms\model\Template; use cms\model\Folder; use cms\model\BaseObject; @@ -418,8 +419,12 @@ class ElementAction extends Action case 'name': $names = array(); - - foreach( Template::getAll() as $tid=>$name ) + + $template = new Template( $this->element->templateid ); + $template->load(); + $project = new Project( $template->projectid ); + + foreach( $project->getTemplates() as $tid=>$name ) { $t = new Template( $tid ); $t->load(); @@ -526,9 +531,13 @@ class ElementAction extends Action case 'defaultObjectId': $objects = array(); - + + $template = new Template( $this->element->templateid ); + $template->load(); + $project = new Project( $template->projectid ); + // Ermitteln aller verfuegbaren Objekt-IDs - foreach( Folder::getAllObjectIds() as $id ) + foreach( $project->getAllObjectIds() as $id ) { $o = new BaseObject( $id ); $o->load(); diff --git a/modules/cms-core/action/FilebrowserAction.class.php b/modules/cms-core/action/FilebrowserAction.class.php @@ -30,6 +30,8 @@ use \Html; * @author $Author$ * @version $Revision$ * @package openrat.actions + * + * @deprecated old ckeditor trash */ class FilebrowserAction extends ObjectAction { diff --git a/modules/cms-core/action/FolderAction.class.php b/modules/cms-core/action/FolderAction.class.php @@ -3,6 +3,7 @@ namespace cms\action; use ArchiveTar; +use cms\model\Project; use cms\model\Template; use cms\model\Page; use cms\model\Folder; @@ -985,7 +986,8 @@ class FolderAction extends ObjectAction $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' ); $this->setTemplateVar('maxlength',$maxSizeBytes ); - $all_templates = Template::getAll(); + $project = new Project( $this->folder->projectid ); + $all_templates = $project->getTemplates(); $this->setTemplateVar('templates' ,$all_templates ); if ( count($all_templates) == 0 ) @@ -1095,7 +1097,9 @@ class FolderAction extends ObjectAction public function createpageView() { - $all_templates = Template::getAll(); + $project = new Project( $this->folder->projectid ); + + $all_templates = $project->getTemplates(); $this->setTemplateVar('templates' ,$all_templates ); $this->setTemplateVar('objectid' ,$this->folder->objectid ); @@ -1322,7 +1326,8 @@ class FolderAction extends ObjectAction $this->setTemplateVar('object' ,$list ); $this->setTemplateVar('act_objectid',$this->folder->id); - $rootFolder = new Folder( $this->folder->getRootFolderId() ); + $project = new Project($this->folder->projectid); + $rootFolder = new Folder( $project->getRootObjectId() ); $rootFolder->load(); $this->setTemplateVar('properties' ,$this->folder->getProperties() ); @@ -1335,7 +1340,8 @@ class FolderAction extends ObjectAction public function rootView() { - $rootFolder = new Folder( Folder::getRootFolderId() ); + $project = new Project($this->folder->projectid); + $rootFolder = new Folder( $project->getRootObjectId() ); $rootFolder->load(); $this->setTemplateVar('rootfolderid' ,$rootFolder->id ); diff --git a/modules/cms-core/action/LanguageAction.class.php b/modules/cms-core/action/LanguageAction.class.php @@ -178,30 +178,6 @@ class LanguageAction extends Action - - function checkmenu( $menu ) - { - switch( $menu ) - { - case 'remove': - $actLanguage = Session::getProjectLanguage(); - return - !readonly() && - $this->userIsAdmin() && - isset($this->language) && - count( $this->language->getAll() ) >= 2 && - $actLanguage->languageid != $this->language->languageid; - - case 'add': - return - !readonly() && $this->userIsAdmin(); - - default: - return true; - } - } - - /** * Liefert die Struktur zu diesem Ordner: * - Mit den übergeordneten Ordnern und diff --git a/modules/cms-core/action/LanguagelistAction.class.php b/modules/cms-core/action/LanguagelistAction.class.php @@ -107,13 +107,8 @@ class LanguagelistAction extends Action global $conf; $countryList = $conf['countries']; - $language = Session::getProjectLanguage(); - foreach( $this->project->getLanguageIds() as $id ) { - - if ( $id == $language->languageid ) - continue; $l = new Language( $id ); $l->load(); diff --git a/modules/cms-core/action/LinkAction.class.php b/modules/cms-core/action/LinkAction.class.php @@ -86,7 +86,6 @@ class LinkAction extends ObjectAction $this->link->save(); $this->link->setTimestamp(); - Session::setObject( $this->link ); } } @@ -100,8 +99,7 @@ class LinkAction extends ObjectAction $this->link->save(); $this->link->setTimestamp(); - Session::setObject( $this->link ); - + $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK); } diff --git a/modules/cms-core/action/LoginAction.class.php b/modules/cms-core/action/LoginAction.class.php @@ -546,7 +546,6 @@ class LoginAction extends Action $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); } - $this->metaValues(); } @@ -588,102 +587,11 @@ class LoginAction extends Action } - $this->metaValues(); $this->setTemplateVar('applications',$list); } - - /** - * Ermittelt Meta-Angaben f?r den HTML-Kopf.<br> - * Falls der Browser die Meta-Angaben entsprechend auswertet, k?nnen ?ber feste Browser-Men?s - die Projekt direkt ausgew?hlt werden. - */ - function metaValues() - { - global $conf; - $metaList = array(); - $user = Session::getUser(); - if ( is_object($user) ) - { - // Projekte ermitteln - $projects = $user->projects; - foreach( $projects as $id=>$name ) - { - $metaList[] = array('name' => 'chapter', - 'url' => Html::url('index','project',$id), - 'title'=> $name ); - } - - if ( $this->userIsAdmin() ) - { - $metaList[] = array('name' => 'appendix', - 'url' => Html::url('index','projectmenu',0 ), - 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) ); - - $metaList[] = array('name' => 'chapter', - 'url' => Html::url('index','administration',0), - 'title'=> lang('administration') ); - } - - // Applikationen ermitteln - foreach( $conf['applications'] as $id=>$app ) - { - if ( !is_array($app) ) - continue; - $appUrl = $app['url']; - if ( isset($app['param']) ) - { - $appUrl .= strpos($appUrl,'?')!==false?'&':'?'; - $appUrl .= $app['param'].'='.session_id(); - } - - $metaList[] = array('name' => 'bookmark', - 'url' => $appUrl , - 'title'=> $app['name'] ); - } - } - - $project = Session::getProject(); - if ( is_object($project) && $project->projectid > 0 ) - { - $languages =$project->getLanguages(); - - foreach( $project->getModels() as $modelid=>$modelname ) - { - foreach( $languages as $languageid=>$languagename ) - { - - $metaList[] = array('name' => 'subsection', - 'url' => Html::url('index', - 'project', - $project->projectid, - array('languageid'=>$languageid, - 'modelid' =>$modelid) ), - 'title'=> $modelname.' - '.$languagename - ); - } - } - } - - $metaList[] = array('name' => 'author', - 'url' => $conf['login']['logo']['url'], - 'title'=> $conf['login']['logo']['url'] ); - - $metaList[] = array('name' => 'top', - 'url' => Html::url('index','logout',0 ), - 'title'=> 'Start' ); - - $metaList[] = array('name' => 'contents', - 'url' => Html::url('index','projectmenu',0 ), - 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) ); - - - $this->setTemplateVar('metaList',$metaList); - } - - /** * Open-Id Login, ?berpr?fen der Anmeldung.<br> @@ -1084,35 +992,6 @@ class LoginAction extends Action $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname)); - $this->setStyle( $user->style ); - - $this->evaluateRequestVars(); - - $object = Session::getObject(); - // Falls noch kein Objekt ausgewaehlt, dann das zuletzt ge?nderte benutzen. - if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] ) - { - $objectid = Value::getLastChangedObjectByUserId($user->userid); - if ( BaseObject::available($objectid)) - { - $object = new BaseObject($objectid); - $object->load(); - Session::setObject($object); - - $project = new Project( $object->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } - } - $this->setStyle( $user->style ); // Benutzer-Style setzen $config = Session::getConfig(); @@ -1125,58 +1004,6 @@ class LoginAction extends Action // Entscheiden, welche Perspektive als erstes angezeigt werden soll. $allProjects = Project::getAllProjects(); - - if ( $conf['login']['start']['start_single_project'] && - count($allProjects) == 1 ) - { - // Das einzige Projekt sofort starten. - $projectIds = array_keys($allProjects); - - $project = new Project($projectIds[0]); - $project->load(); - $language = new Language( $project->getDefaultLanguageId() ); - $language->load(); - $model = new Model( $project->getDefaultModelId() ); - $model->load(); - - Session::setProject( $project ); - Session::setProjectLanguage( $language ); - Session::setProjectModel( $model ); - - } - elseif ( $conf['login']['start']['start_lastchanged_object'] ) - { - $user = Session::getUser(); - $objectid = Value::getLastChangedObjectByUserId($user->userid); - if ( BaseObject::available($objectid)) - { - // Das Projekt des zuletzt geänderten Objekts ermitteln - // und dieses Projekt starten. - $o = new BaseObject( $objectid ); - $o->load(); - - $project = new Project($o->projectid); - $project->load(); - $language = new Language( $project->getDefaultLanguageId() ); - $language->load(); - $model = new Model( $project->getDefaultModelId() ); - $model->load(); - - Session::setProject( $project ); - Session::setProjectLanguage( $language ); - Session::setProjectModel( $model ); - } - else - { - // Benutzer hat noch nie eine Änderung durchgefuehrt. - // Erstmal die Startseite anzeigen. - } - } - - else - { - // Erstmal die Startseite anzeigen. - } } } @@ -1193,38 +1020,6 @@ class LoginAction extends Action if ( is_object($user) ) $this->setTemplateVar('login_username',$user->name); - // Ausgew?hlte Objekte merken, um nach dem n?. Login wieder sofort auszuw?hlen. - $o = Session::getObject(); - if ( is_object($o) ) - $this->setTemplateVar('objectid',$o->objectid); - $p = Session::getProject(); - if ( is_object($p) ) - $this->setTemplateVar('projectid',$p->projectid); - $l = Session::getProjectLanguage(); - if ( is_object($l) ) - $this->setTemplateVar('languageid',$l->languageid); - $m = Session::getProjectModel(); - if ( is_object($m) ) - $this->setTemplateVar('modelid',$m->modelid); - $db = db_connection(); - if ( is_object($db) ) - $this->setTemplateVar('dbid',$db->id); - - /* - // Alle Variablen aus der Sitzung entfernen. - session_unset(); - - // Damit wird die Session gel�scht, nicht nur die Session-Daten! - if ( ini_get("session.use_cookies") ) - { - $params = session_get_cookie_params(); - setcookie( session_name(),'', time() - 3600, - $params["path"],$params["domain"],$params["secure"],$params["httponly"] ); - } - - // Loeschen der Session. - session_destroy(); - */ if ( config('security','renew_session_logout') ) $this->recreateSession(); @@ -1280,16 +1075,6 @@ class LoginAction extends Action /** - * Ausw?hlen der Administration. - */ - function administration() - { - Session::setProject( new Project(-1) ); - } - - - - /** * Ausgeben von maschinenlesbaren Benutzerinformationen. * * Diese Funktion dient dem Single-Signon f?r fremde Anwendungen, welche @@ -1399,108 +1184,6 @@ class LoginAction extends Action */ function evaluateRequestVars( $add = array() ) { - global $REQ; - $vars = $REQ + $add; - - $db = db_connection(); - if ( !is_object($db) ) - { - if ( isset($vars[REQ_PARAM_DATABASE_ID]) ) - $this->setDb($vars[REQ_PARAM_DATABASE_ID]); - else - throw new \LogicException('no database available.'); - } - else - { - // Pr�ft, ob die �bergebene Datenbank-Id mit der - // aktuellen �bereinstimmt. - // Falls nicht, muss ein Re-Login erfolgen. - if ( isset($vars[REQ_PARAM_DATABASE_ID]) ) - if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] ) - { - $this->callSubAction('show'); - return; - } - } - - - if ( isset($vars[REQ_PARAM_OBJECT_ID]) && BaseObject::available($vars[REQ_PARAM_OBJECT_ID]) ) - { - $object = new BaseObject( $vars[REQ_PARAM_OBJECT_ID] ); - $object->objectLoadRaw(); - Session::setObject( $object ); - - $project = new Project( $object->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } - elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) ) - { - } - elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) ) - { - $model = new Model( $vars[REQ_PARAM_MODEL_ID] ); - $model->load(); - Session::setProjectModel( $model ); - - $project = new Project( $model->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = Session::getProjectLanguage(); - if ( !is_object($language) || $language->projectid != $project->projectid ) - { - $language = new Language( $project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - } - - $object = Session::getObject(); - $object->objectLoadRaw(); - if ( is_object($object) && $object->projectid == $project->projectid ) - { - $object->objectLoadRaw(); - Session::setObject( $object ); - } - else - { - Session::setObject( '' ); - } - } - elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) ) - { - $project = new Project( $vars[REQ_PARAM_PROJECT_ID] ); - $project->load(); - - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - - $object = Session::getObject(); - if ( is_object($object) && $object->projectid == $project->projectid ) - { - $object->objectLoadRaw(); - Session::setObject( $object ); - } - else - { - Session::setObject( '' ); - } - } } @@ -1603,112 +1286,6 @@ class LoginAction extends Action // Seite ?ndert sich nur 1x pro Session $this->lastModified( $user->loginDate ); - $projectid = intval( $this->getRequestVar('projectid' ) ); - $languageid = intval( $this->getRequestVar('languageid') ); - $modelid = intval( $this->getRequestVar('modelid' ) ); - $objectid = intval( $this->getRequestVar('objectid' ) ); - $elementid = intval( $this->getRequestVar('elementid' ) ); - - if ( $projectid != 0 ) - { - $project = new Project( $projectid ); - $project->load(); - Session::setProject($project); - } - elseif ( $languageid != 0 ) - { - $language = new Language( $languageid ); - $language->load(); - Session::setProjectLanguage($language); - } - elseif ( $modelid != 0 ) - { - $model = new Model( $modelid ); - $model->load(); - Session::setProjectModel($model); - } - elseif ( $objectid != 0 ) - { - $object = new BaseObject( $objectid ); - $object->objectLoad(); - Session::setObject($object); - } - if ( $elementid != 0 ) - { - $element = new Element( $elementid ); - Session::setElement($element); - } - - $project = Session::getProject(); - $object = Session::getObject(); - $elementid = 0; - - if ( is_object($project) ) - { - if ( $project->projectid == PROJECTID_ADMIN ) - { - $project->name = lang('ADMINISTRATION'); - Session::setProject( $project ); - - Session::setProjectLanguage( '' ); - Session::setProjectModel ( '' ); - Session::setObject ( '' ); - } - - $this->setTemplateVar( 'title',$project->name ); - - if ( is_object($object) ) - { - $type = $object->getType(); - - if ( $type == 'page' ) - { - $page = new Page($object->objectid); - $page->load(); - $elementList = $page->getWritableElements(); - if ( count($elementList) == 1 ) - $elementid = current(array_keys($elementList)); - } - - if ( $elementid > 0 ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) ); - else - $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) ); - } - else - { - $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) ); - } - } - elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN ) - { - if ( $this->hasRequestVar('projectid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) ); - elseif ( $this->hasRequestVar('groupid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) ); - elseif ( $this->hasRequestVar('userid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) ); - else - $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) ); - } - else - { - $this->callSubAction( 'projectmenu' ); - } - - - $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) ); - - $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) ); - $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) ); - $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) ); - $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) ); - $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) ); - $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) ); - - $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] ); - - $this->metaValues(); } diff --git a/modules/cms-core/action/ModelAction.class.php b/modules/cms-core/action/ModelAction.class.php @@ -47,8 +47,6 @@ class ModelAction extends Action $this->model = new Model( $this->getRequestId() ); $this->model->load(); - - $this->project = Session::getProject(); } diff --git a/modules/cms-core/action/ObjectAction.class.php b/modules/cms-core/action/ObjectAction.class.php @@ -3,6 +3,7 @@ namespace cms\action; use cms\model\Acl; +use cms\model\Project; use cms\model\User; use cms\model\Group; use cms\model\Page; @@ -43,10 +44,15 @@ class ObjectAction extends Action public $security = SECURITY_USER; private $objectid; + private $baseObject; + public function __construct() { parent::__construct(); + + $this->baseObject = new BaseObject( $this->getRequestId() ); + $this->baseObject->objectLoad(); } public function copyView() @@ -454,7 +460,10 @@ class ObjectAction extends Action $this->setTemplateVar('groups' ,Group::getAll() ); $languages = array(0=>lang('ALL_LANGUAGES')); - $languages += Language::getAll(); + + $project = new Project( $this->baseObject->projectid ); + + $languages += $project->getLanguages(); $this->setTemplateVar('languages',$languages ); $this->setTemplateVar('objectid' ,$o->objectid ); $this->setTemplateVar('action' ,$this->actionName); diff --git a/modules/cms-core/action/PageAction.class.php b/modules/cms-core/action/PageAction.class.php @@ -148,15 +148,14 @@ class PageAction extends ObjectAction function editPost() { $value = new Value(); - $language = Session::getProjectLanguage(); - $value->languageid = $language->languageid; + $value->languageid = $this->page->languageid; $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) - $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); + if ( ! $this->hasRequestVar('elementid') ) + $this->addValidationError('elementid' ); + + $value->element = new Element( $this->getRequestVar('elementid') ); $value->element->load(); $value->publish = false; @@ -275,7 +274,7 @@ class PageAction extends ObjectAction // fuer jede Sprache einzeln gespeichert. if ( $value->element->allLanguages ) { - $project = Session::getProject(); + $project = new Project( $this->page->projectid ); foreach( $project->getLanguageIds() as $languageid ) { $value->languageid = $languageid; @@ -365,7 +364,8 @@ class PageAction extends ObjectAction // $this->setTemplateVar('folder',$folders); $templates = Array(); - foreach( Template::getAll() as $id=>$name ) + $project = new Project( $this->page->projectid ); + foreach( $project->getTemplates() as $id=>$name ) { if ( $id != $this->page->templateid ) $templates[$id]=$name; @@ -710,7 +710,8 @@ class PageAction extends ObjectAction $this->page->public = true; $this->page->load(); - $this->setTemplateVars( $this->page->getProperties() ); + + $this->setTemplateVars( $this->page->getProperties() ); if ( $this->userIsAdmin() ) { @@ -722,7 +723,8 @@ class PageAction extends ObjectAction $this->setTemplateVar('template_name',$template->name); $templates = Array(); - foreach( Template::getAll() as $id=>$name ) + $project = new Project( $this->page->projectid ); + foreach( $project->getTemplates() as $id=>$name ) { if ( $id != $this->page->templateid ) $templates[$id]=$name; @@ -794,32 +796,6 @@ class PageAction extends ObjectAction } - /** - * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden. - * - * @see actionClasses/Action#checkMenu($name) - */ - function checkMenu( $menu ) { - - switch( $menu) - { - case 'changetemplate': - // Template nur austauschbar, wenn es mind. 2 gibt. - return (!readonly() && count(Template::getAll()) > 1); - - case 'aclform': - return !readonly(); - - case 'form': - return !readonly(); - - default: - return true; - - } - } - - /** * Liefert die Struktur zu diesem Ordner: * - Mit den übergeordneten Ordnern und diff --git a/modules/cms-core/action/PageelementAction.class.php b/modules/cms-core/action/PageelementAction.class.php @@ -15,6 +15,7 @@ use Http; use Session; use Transformer; use \Text; +use ValidationException; // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de @@ -481,7 +482,8 @@ class PageelementAction extends Action */ private function editlink() { - $this->setTemplateVar('rootfolderid',Folder::getRootFolderId() ); + $project = new Project($this->page->projectid); + $this->setTemplateVar('rootfolderid',$project->getRootObjectId() ); // Ermitteln, welche Objekttypen verlinkt werden d�rfen. $type = $this->value->element->subtype; @@ -540,7 +542,8 @@ class PageelementAction extends Action $this->setTemplateVar('name' ,$this->value->element->name ); $this->setTemplateVar('desc' ,$this->value->element->desc ); - $this->setTemplateVar('rootfolderid' ,Folder::getRootFolderId() ); + $project = new Project($this->page->projectid); + $this->setTemplateVar('rootfolderid' ,$project->getRootObjectId() ); // Ermitteln, welche Objekttypen verlinkt werden d�rfen. if ( empty($this->value->element->subtype) ) @@ -977,10 +980,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); $value->element->load(); $value->publish = false; @@ -1070,10 +1072,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); $value->element->load(); $value->publish = false; @@ -1193,11 +1194,10 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) - $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); + $value->element = new Element( $this->getRequestVar('elementid') ); $value->element->load(); $value->publish = false; $value->load(); @@ -1236,10 +1236,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); $value->element->load(); $value->publish = false; @@ -1264,10 +1263,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) - $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); + $value->element = new Element( $this->getRequestVar('elementid') ); $value->element->load(); $value->publish = false; @@ -1307,10 +1305,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); $value->element->load(); $value->publish = false; @@ -1335,10 +1332,9 @@ class PageelementAction extends Action $value->objectid = $this->page->objectid; $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - if ( $this->hasRequestVar('elementid') ) + if ( !$this->hasRequestVar('elementid') ) + throw new ValidationException('elementid'); $value->element = new Element( $this->getRequestVar('elementid') ); - else - $value->element = Session::getElement(); $value->element->load(); $value->publish = false; diff --git a/modules/cms-core/action/SearchAction.class.php b/modules/cms-core/action/SearchAction.class.php @@ -134,63 +134,56 @@ class SearchAction extends Action $listObjectIds = array(); $listTemplateIds = array(); - $project = Session::getProject(); - if ( is_object($project) && $project->projectid == -1 ) - { - $resultList = array(); - - $user = User::loadWithName($text); - if ( is_object($user) ) - { - $userResult = array( 'url' => Html::url('template','',$templateid), - 'type' => 'user', - 'name' => $user->name, - 'desc' => lang('NO_DESCRIPTION_AVAILABLE'), - 'lastchange_date' => 0 ); - } - $resultList[] = $userResult; - - $this->setTemplateVar( 'result',$resultList ); - } - else - { - if ( $flag & SEARCH_FLAG_ID && BaseObject::available( intval($text) ) ) - $listObjectIds[] = intval( $text ); - - if ( $flag & SEARCH_FLAG_NAME ) - { - $o = new BaseObject(); - $listObjectIds += $o->getObjectIdsByName( $text ); - } - - if ( $flag & SEARCH_FLAG_DESCRIPTION ) - { - $o = new BaseObject(); - $listObjectIds += $o->getObjectIdsByDescription( $text ); - } - - if ( $flag & SEARCH_FLAG_FILENAME ) - { - $o = new BaseObject(); - $listObjectIds += $o->getObjectIdsByFilename( $text ); - - $f = new File(); - $listObjectIds += $f->getObjectIdsByExtension( $text ); - } - - // Inhalte durchsuchen - if ( $flag & SEARCH_FLAG_VALUE ) - { - $e = new Value(); - $listObjectIds += $e->getObjectIdsByValue( $text ); - - $template = new Template(); - $listTemplateIds += $template->getTemplateIdsByValue( $text ); - } - - $this->explainResult( $listObjectIds, $listTemplateIds ); - } - + $resultList = array(); + + $user = User::loadWithName($text); + if ( is_object($user) ) + { + $userResult = array( 'url' => Html::url('template','',$templateid), + 'type' => 'user', + 'name' => $user->name, + 'desc' => lang('NO_DESCRIPTION_AVAILABLE'), + 'lastchange_date' => 0 ); + } + $resultList[] = $userResult; + + $this->setTemplateVar( 'result',$resultList ); + if ( $flag & SEARCH_FLAG_ID && BaseObject::available( intval($text) ) ) + $listObjectIds[] = intval( $text ); + + if ( $flag & SEARCH_FLAG_NAME ) + { + $o = new BaseObject(); + $listObjectIds += $o->getObjectIdsByName( $text ); + } + + if ( $flag & SEARCH_FLAG_DESCRIPTION ) + { + $o = new BaseObject(); + $listObjectIds += $o->getObjectIdsByDescription( $text ); + } + + if ( $flag & SEARCH_FLAG_FILENAME ) + { + $o = new BaseObject(); + $listObjectIds += $o->getObjectIdsByFilename( $text ); + + $f = new File(); + $listObjectIds += $f->getObjectIdsByExtension( $text ); + } + + // Inhalte durchsuchen + if ( $flag & SEARCH_FLAG_VALUE ) + { + $e = new Value(); + $listObjectIds += $e->getObjectIdsByValue( $text ); + + $template = new Template(); + $listTemplateIds += $template->getTemplateIdsByValue( $text ); + } + + $this->explainResult( $listObjectIds, $listTemplateIds ); + } diff --git a/modules/cms-core/action/StartAction.class.php b/modules/cms-core/action/StartAction.class.php @@ -471,102 +471,10 @@ class StartAction extends Action } - $this->metaValues(); $this->setTemplateVar('applications',$list); } - - /** - * Ermittelt Meta-Angaben f�r den HTML-Kopf.<br> - * Falls der Browser die Meta-Angaben entsprechend auswertet, k�nnen �ber feste Browser-Men�s die Projekt direkt ausgew�hlt werden. - * @Unused - */ - private function metaValues() - { - global $conf; - $metaList = array(); - - $user = Session::getUser(); - if ( is_object($user) ) - { - // Projekte ermitteln - $projects = $user->projects; - foreach( $projects as $id=>$name ) - { - $metaList[] = array('name' => 'chapter', - 'url' => Html::url('index','project',$id), - 'title'=> $name ); - } - - if ( $this->userIsAdmin() ) - { - $metaList[] = array('name' => 'appendix', - 'url' => Html::url('index','projectmenu',0 ), - 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) ); - - $metaList[] = array('name' => 'chapter', - 'url' => Html::url('index','administration',0), - 'title'=> lang('administration') ); - } - - // Applikationen ermitteln - foreach( $conf['applications'] as $id=>$app ) - { - if ( !is_array($app) ) - continue; - $appUrl = $app['url']; - if ( isset($app['param']) ) - { - $appUrl .= strpos($appUrl,'?')!==false?'&':'?'; - $appUrl .= $app['param'].'='.session_id(); - } - - $metaList[] = array('name' => 'bookmark', - 'url' => $appUrl , - 'title'=> $app['name'] ); - } - } - - $project = Session::getProject(); - if ( is_object($project) && $project->projectid > 0 ) - { - $languages =$project->getLanguages(); - - foreach( $project->getModels() as $modelid=>$modelname ) - { - foreach( $languages as $languageid=>$languagename ) - { - - $metaList[] = array('name' => 'subsection', - 'url' => Html::url('index', - 'project', - $project->projectid, - array('languageid'=>$languageid, - 'modelid' =>$modelid) ), - 'title'=> $modelname.' - '.$languagename - ); - } - } - } - - $metaList[] = array('name' => 'author', - 'url' => $conf['login']['logo']['url'], - 'title'=> $conf['login']['logo']['url'] ); - - $metaList[] = array('name' => 'top', - 'url' => Html::url('index','logout',0 ), - 'title'=> 'Start' ); - - $metaList[] = array('name' => 'contents', - 'url' => Html::url('index','projectmenu',0 ), - 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) ); - - - $this->setTemplateVar('metaList',$metaList); - } - - /** * Open-Id Login, �berpr�fen der Anmeldung.<br> @@ -730,33 +638,6 @@ class StartAction extends Action $user = Session::getUser(); $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname)); - - $this->evaluateRequestVars(); - - $object = Session::getObject(); - // Falls noch kein Objekt ausgew�hlt, dann das zuletzt ge�nderte benutzen. - if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] ) - { - $objectid = Value::getLastChangedObjectByUserId($user->userid); - if ( BaseObject::available($objectid)) - { - $object = new BaseObject($objectid); - $object->load(); - Session::setObject($object); - } - - $project = new Project( $object->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } } // Benutzer ist angemeldet @@ -774,38 +655,6 @@ class StartAction extends Action if ( is_object($user) ) $this->setTemplateVar('login_username',$user->name); - // Ausgew�hlte Objekte merken, um nach dem n�. Login wieder sofort auszuw�hlen. - $o = Session::getObject(); - if ( is_object($o) ) - $this->setTemplateVar('objectid',$o->objectid); - $p = Session::getProject(); - if ( is_object($p) ) - $this->setTemplateVar('projectid',$p->projectid); - $l = Session::getProjectLanguage(); - if ( is_object($l) ) - $this->setTemplateVar('languageid',$l->languageid); - $m = Session::getProjectModel(); - if ( is_object($m) ) - $this->setTemplateVar('modelid',$m->modelid); - $db = db_connection(); - if ( is_object($db) ) - $this->setTemplateVar('dbid',$db->id); - - /* - // Alle Variablen aus der Sitzung entfernen. - session_unset(); - - // Damit wird die Session gelöscht, nicht nur die Session-Daten! - if ( ini_get("session.use_cookies") ) - { - $params = session_get_cookie_params(); - setcookie( session_name(),'', time() - 3600, - $params["path"],$params["domain"],$params["secure"],$params["httponly"] ); - } - - // Loeschen der Session. - session_destroy(); - */ if ( config('security','renew_session_logout') ) $this->recreateSession(); @@ -981,120 +830,11 @@ class StartAction extends Action /** * Auswerten der Request-Variablen. - * - * @param Array $add */ private function evaluateRequestVars( $add = array() ) { - global $REQ; - $vars = $REQ + $add; - - $db = db_connection(); - if ( !is_object($db) ) - { - if ( isset($vars[REQ_PARAM_DATABASE_ID]) ) - $this->setDb($vars[REQ_PARAM_DATABASE_ID]); - else - throw new \LogicException('no database available.'); - } - else - { - // Prüft, ob die übergebene Datenbank-Id mit der - // aktuellen übereinstimmt. - // Falls nicht, muss ein Re-Login erfolgen. - if ( isset($vars[REQ_PARAM_DATABASE_ID]) ) - if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] ) - { - $this->callSubAction('show'); - return; - } - } - - - if ( isset($vars[REQ_PARAM_OBJECT_ID]) && BaseObject::available($vars[REQ_PARAM_OBJECT_ID]) ) - { - $object = new BaseObject( $vars[REQ_PARAM_OBJECT_ID] ); - $object->objectLoadRaw(); - // Session::setObject( $object ); // Unnötig - - $project = new Project( $object->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } - elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) ) - { - $language = new Language( $vars[REQ_PARAM_LANGUAGE_ID] ); - $language->load(); - Session::setProjectLanguage( $language ); - - $project = new Project( $language->projectid ); - $project->load(); - Session::setProject( $project ); - - $model = Session::getProjectModel(); - if ( !is_object($model) ) - { - $model = new Model( $project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } - - } - elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) ) - { - $model = new Model( $vars[REQ_PARAM_MODEL_ID] ); - $model->load(); - Session::setProjectModel( $model ); - - $project = new Project( $model->projectid ); - $project->load(); - Session::setProject( $project ); - - $language = Session::getProjectLanguage(); - if ( !is_object($language) || $language->projectid != $project->projectid ) - { - $language = new Language( $project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - } - } - elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) ) - { - $project = new Project( $vars[REQ_PARAM_PROJECT_ID] ); - $project->load(); - - Session::setProject( $project ); - - $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() ); - $language->load(); - Session::setProjectLanguage( $language ); - - $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() ); - $model->load(); - Session::setProjectModel( $model ); - } - } - - - function showtree() - { - Session::set('showtree',true ); } - - function hidetree() - { - Session::set('showtree',false ); - } - function switchuser() { @@ -1183,111 +923,6 @@ class StartAction extends Action // Seite �ndert sich nur 1x pro Session $this->lastModified( $user->loginDate ); - $projectid = intval( $this->getRequestVar('projectid' ) ); - $languageid = intval( $this->getRequestVar('languageid') ); - $modelid = intval( $this->getRequestVar('modelid' ) ); - $objectid = intval( $this->getRequestVar('objectid' ) ); - $elementid = intval( $this->getRequestVar('elementid' ) ); - - if ( $projectid != 0 ) - { - $project = new Project( $projectid ); - $project->load(); - Session::setProject($project); - } - elseif ( $languageid != 0 ) - { - $language = new Language( $languageid ); - $language->load(); - Session::setProjectLanguage($language); - } - elseif ( $modelid != 0 ) - { - $model = new Model( $modelid ); - $model->load(); - Session::setProjectModel($model); - } - elseif ( $objectid != 0 ) - { - $object = new BaseObject( $objectid ); - $object->objectLoad(); - Session::setObject($object); - } - if ( $elementid != 0 ) - { - $element = new Element( $elementid ); - Session::setElement($element); - } - - $project = Session::getProject(); - $object = Session::getObject(); - $elementid = 0; - - if ( is_object($project) ) - { - if ( $project->projectid == PROJECTID_ADMIN ) - { - $project->name = lang('ADMINISTRATION'); - Session::setProject( $project ); - - Session::setProjectLanguage( '' ); - Session::setProjectModel ( '' ); - Session::setObject ( '' ); - } - - $this->setTemplateVar( 'title',$project->name ); - - if ( is_object($object) ) - { - $type = $object->getType(); - - if ( $type == 'page' ) - { - $page = new Page($object->objectid); - $page->load(); - $elementList = $page->getWritableElements(); - if ( count($elementList) == 1 ) - $elementid = current(array_keys($elementList)); - } - - if ( $elementid > 0 ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) ); - else - $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) ); - } - else - { - $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) ); - } - } - elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN ) - { - if ( $this->hasRequestVar('projectid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) ); - elseif ( $this->hasRequestVar('groupid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) ); - elseif ( $this->hasRequestVar('userid') ) - $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) ); - else - $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) ); - } - else - { - $this->callSubAction( 'projectmenu' ); - } - - - $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) ); - - $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) ); - $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) ); - $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) ); - $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) ); - $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) ); - $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) ); - - $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] ); - $this->metaValues(); } @@ -1683,8 +1318,9 @@ class StartAction extends Action */ public function userprojecttimelineView() { - $project = Session::getProject(); - $result = $project->getMyLastChanges(); + //$project = Session::getProject(); + //$result = $project->getMyLastChanges(); + $result = array(); $this->setTemplateVar('timeline', $result); } diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php @@ -4,6 +4,7 @@ namespace cms\action; namespace cms\action; use cms\model\Element; +use cms\model\Project; use cms\model\Template; use cms\model\Page; @@ -480,8 +481,10 @@ class TemplateAction extends Action global $conf_php; $list = array(); - - foreach( Template::getAll() as $id=>$name ) + + $project = new Project( $this->template->projectid ); + + foreach( $project->getTemplates() as $id=>$name ) { $list[$id] = array(); $list[$id]['name'] = $name; diff --git a/modules/cms-core/action/TemplatelistAction.class.php b/modules/cms-core/action/TemplatelistAction.class.php @@ -90,7 +90,7 @@ class TemplatelistAction extends Action */ function addView() { - $this->setTemplateVar( 'templates',Template::getAll() ); + $this->setTemplateVar( 'templates',array() /*Template::getAll()*/ ); $examples = array(); $dir = opendir( 'examples/templates'); @@ -113,11 +113,7 @@ class TemplatelistAction extends Action { // Hinzufuegen eines Templates if ( $this->getRequestVar('name') == '' ) - { - $this->addValidationError('name'); - $this->callSubAction('add'); - return; - } + throw new \ValidationException('name'); // Hinzufuegen eines Templates switch( $this->getRequestVar('type') ) @@ -161,7 +157,7 @@ class TemplatelistAction extends Action $elementMapping[$oldelementId] = $element->elementid; } - $project = Session::getProject(); + $project = new Project( $this->getRequestId('projectid') ); foreach( $project->getModelIds() as $modelid ) { // Template laden diff --git a/modules/cms-core/action/TreeAction.class.php b/modules/cms-core/action/TreeAction.class.php @@ -70,33 +70,34 @@ class TreeAction extends Action */ public function settingsView() { + /* $this->setTemplateVar( 'languages' ,Language::getAll() ); - $this->setTemplateVar( 'languageid',Session::getProjectLanguage()->languageid ); + $this->setTemplateVar( 'languageid',0 ); $this->setTemplateVar( 'models' ,Model::getAll() ); - $this->setTemplateVar( 'modelid' ,Session::getProjectModel()->modelid ); + $this->setTemplateVar( 'modelid' ,0 ); + */ } - + + + /** + * @deprecated + */ public function settingsPost() { - $language = new Language( $this->getRequestVar(REQ_PARAM_LANGUAGE_ID,OR_FILTER_NUMBER) ); - $language->load(); - Session::setProjectLanguage( $language ); - $model = new Model( $this->getRequestVar(REQ_PARAM_MODEL_ID,OR_FILTER_NUMBER) ); - $model->load(); - Session::setProjectModel( $model ); - $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK); $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK); } - + + /** + * @deprecated + */ public function languagePost() { $language = new Language( $this->getRequestId() ); $language->load(); - Session::setProjectLanguage( $language ); - + $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK); } @@ -105,8 +106,7 @@ class TreeAction extends Action { $model = new Model( $this->getRequestId() ); $model->load(); - Session::setProjectModel( $model ); - + $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK); } diff --git a/modules/cms-core/action/UrlAction.class.php b/modules/cms-core/action/UrlAction.class.php @@ -87,7 +87,6 @@ class UrlAction extends ObjectAction $this->url->save(); $this->url->setTimestamp(); - Session::setObject( $this->url ); } } @@ -100,7 +99,6 @@ class UrlAction extends ObjectAction $this->url->url = $this->getRequestVar('url'); $this->url->save(); $this->url->setTimestamp(); - Session::setObject( $this->url ); $this->addNotice('url',$this->url->name,'SAVED',OR_NOTICE_OK); } diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -198,33 +198,6 @@ namespace cms\model { } - /** - * Lesen aller Objekte aus dem aktuellen Projekt - * @return array Alle Objekt-IDs des aktuellen Projektes - */ - function getAllObjectIds() - { - global $SESS; - $db = db_connection(); - - if ( ! isset($this->projectid) ) - { - $project = \Session::getProject(); - $projectid = $project->projectid; - } - else - { - $projectid = $this->projectid; - } - - $sql = $db->sql('SELECT id from {{object}} '. - ' WHERE projectid={projectid}'); - $sql->setInt('projectid', $projectid); - - return $sql->getCol(); - } - - // Kompletten Dateinamen des Objektes erzeugen function full_filename() { @@ -239,23 +212,13 @@ namespace cms\model { } /** - * Pr?fen einer Berechtigung zu diesem Objekt - */ - function checkRight( $type ) - { - return true; - } - - - /** * Pruefen einer Berechtigung zu diesem Objekt */ - function hasRight( $type ) + public function hasRight( $type ) { if ( is_null($this->aclMask) ) { - $project = \Session::getProject(); - $language = \Session::getProjectLanguage(); + $language = $this->languageid; $user = \Session::getUser(); if ( $user->isAdmin ) @@ -317,7 +280,7 @@ SQL /** * Typ des Objektes ermitteln * - * @return String der Typ des Objektes entweder 'folder','file','page' oder 'link' + * @return String der Typ des Objektes entweder 'folder','file','page' oder 'link'. */ function getType() { diff --git a/modules/cms-core/model/Element.class.php b/modules/cms-core/model/Element.class.php @@ -133,8 +133,14 @@ class Element var $subtype = ''; var $withIcon = false; var $dateformat = 'r'; + + /* + * @deprecated use format. + */ var $wiki = false; - var $format = ELEMENT_FORMAT_TEXT; + + public $format = ELEMENT_FORMAT_TEXT; + var $html = false; var $decimals = 0; var $decPoint = '.'; diff --git a/modules/cms-core/model/Folder.class.php b/modules/cms-core/model/Folder.class.php @@ -68,33 +68,7 @@ class Folder extends BaseObject - function getRootFolderId() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT id FROM {{object}}'. - ' WHERE parentid IS NULL'. - ' AND typeid=1'. - ' AND projectid={projectid}' ); - - // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden - if ( isset($this) && isset($this->projectid) ) - { - $sql->setInt('projectid',$this->projectid ); - } - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid ); - } - - // Datenbankabfrage ausfuehren - return $sql->getOne(); - } - - - function hasFilename( $filename ) + public function hasFilename( $filename ) { $db = db_connection(); @@ -324,101 +298,6 @@ class Folder extends BaseObject - /** - * Ermittelt alle Objekte vom gew�nschten Typ, die sic in - * diesem Projekt befinden. - * - * @see objectClasses/Object#getAllObjectIds() - * @param types Array - * @return Liste von Object-Ids - */ - function getAllObjectIds( $types=array('folder','page','link','file') ) - { -// Html::debug($types,'Typen'); - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT id FROM {{object}}'. - ' WHERE projectid={projectid}'. - ' AND ( typeid ={is_folder}' . - ' OR typeid ={is_file}' . - ' OR typeid ={is_page}' . - ' OR typeid ={is_link} )' . - ' ORDER BY orderid ASC' ); - - if (isset($this) && isset($this->projectid)) - { - $projectid = $this->projectid; - } - else - { - $project = \Session::getProject(); - $projectid = $project->projectid; - } - - $sql->setInt('projectid',$projectid); - $sql->setInt('is_folder',in_array('folder',$types)?OR_TYPEID_FOLDER:0); - $sql->setInt('is_file' ,in_array('file' ,$types)?OR_TYPEID_FILE:0); - $sql->setInt('is_page' ,in_array('page' ,$types)?OR_TYPEID_PAGE:0); - $sql->setInt('is_link' ,in_array('link' ,$types)?OR_TYPEID_LINK:0); - - return( $sql->getCol() ); - } - - - public function getRootObjectId() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT id FROM {{object}}'. - ' WHERE parentid IS NULL'. - ' AND projectid={projectid}' ); - - if ( isset($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else $sql->setInt('projectid',$SESS['projectid'] ); - - return( $sql->getOne() ); - } - - - public function getOtherFolders() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT id FROM {{object}}'. - ' WHERE typeid='.OR_TYPEID_FOLDER. - ' and id != {objectid} '. - ' AND projectid={projectid}' ); - $sql->setInt( 'projectid',$this->projectid ); - $sql->setInt( 'objectid' ,$this->objectid ); - - return( $sql->getCol() ); - } - - - function getAllFolders() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT id FROM {{object}}'. - ' WHERE typeid='.OR_TYPEID_FOLDER. - ' AND projectid={projectid}' ); - - if ( !isset($this) || !isset($this->projectid) ) - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - else $sql->setInt( 'projectid',$this->projectid ); - - return( $sql->getCol() ); - } - - function getPages() { $db = db_connection(); @@ -987,8 +866,7 @@ SQL // Variablen setzen. $sql->setInt( 'folderid', $this->objectid ); - $language = \Session::getProjectLanguage(); - $sql->setInt( 'languageid', $language->languageid ); + $sql->setInt( 'languageid', $this->languageid ); return $sql->getAll(); } diff --git a/modules/cms-core/model/Language.class.php b/modules/cms-core/model/Language.class.php @@ -61,56 +61,11 @@ class Language - // Lesen aller Sprachen aus der Datenbank - function getAll() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( "SELECT id,name FROM {{language}} ". - " WHERE projectid = {projectid} ". - " ORDER BY name" ); - - if ( !empty($this) && !empty($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - - return $sql->getAssoc(); - } - - /** - * Ermittelt die Anzahl aller Sprachen zum aktuellen Projekt. - */ - function count() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( <<<SQL - SELECT count(*) FROM {{language}} - WHERE projectid = {projectid} -SQL -); - - if ( !empty($this) && !empty($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - - return $sql->getOne(); - } - - - // Lesen aus der Datenbank - function load() + * Lesen aus der Datenbank. + * + */ + public function load() { $db = \Session::getDatabase(); @@ -131,8 +86,10 @@ SQL } - // Speichern der Sprache in der Datenbank - function save() + /** + * Speichern der Sprache in der Datenbank + */ + public function save() { $db = db_connection(); @@ -219,27 +176,6 @@ SQL } - function getDefaultId() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( 'SELECT id FROM {{language}} '. - ' WHERE projectid={projectid}'. - ' ORDER BY is_default DESC' ); - - if ( isset($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - - return $sql->getOne(); - } - - // Sprache entfernen function delete() { diff --git a/modules/cms-core/model/Model.class.php b/modules/cms-core/model/Model.class.php @@ -67,52 +67,6 @@ class Model /** - * Lesen aller Projektmodelle aus der Datenbank - */ - function getAll() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( "SELECT id,name FROM {{projectmodel}} ". - " WHERE projectid = {projectid} ". - " ORDER BY name" ); - - if ( !empty($this) && !empty($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - - return $sql->getAssoc(); - } - - - - /** - * Bestimmt die Anzahl aller Varianten fuer das aktuelle Projekt. - */ - function count() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( <<<SQL - SELECT count(*) FROM {{projectmodel}} - WHERE projectid = {projectid} -SQL -); - if ( isset($this) ) - $sql->setInt('projectid',$this->projectid ); - else $sql->setInt('projectid',$SESS['projectid'] ); - - return $sql->getOne(); - } - - - /** * Lesen aus der Datenbank */ function load() @@ -196,26 +150,6 @@ SQL } - function getDefaultId() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( 'SELECT id FROM {{projectmodel}} '. - ' WHERE projectid={projectid}'. - ' ORDER BY is_default DESC' ); - if ( isset($this->projectid) ) - $sql->setInt('projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt('projectid',$project->projectid); - } - - return $sql->getOne(); - } - - // Diese Sprache als 'default' markieren. function setDefault() diff --git a/modules/cms-core/model/Page.class.php b/modules/cms-core/model/Page.class.php @@ -279,7 +279,8 @@ class Page extends BaseObject foreach( $this->getElementIds() as $elementid ) { - foreach( Language::getAll() as $lid=>$lname ) + $project = new Project( $this->projectid ); + foreach( $project->getLanguages() as $lid=>$lname ) { $val = new Value(); $val->publish = false; diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php @@ -108,7 +108,7 @@ class Project extends ModelBase * Liefert alle verf?gbaren Projekte. * @return array */ - public function getAllProjects() + public static function getAllProjects() { $db = db_connection(); $sql = $db->sql( 'SELECT id,name FROM {{project}} '. @@ -876,8 +876,7 @@ SQL // Variablen setzen. $sql->setInt( 'projectid', $this->projectid ); - $language = Session::getProjectLanguage(); - $sql->setInt( 'languageid', $language->languageid ); + $sql->setInt( 'languageid', 0 ); $user = Session::getUser(); $sql->setInt( 'userid', $user->userid ); @@ -958,6 +957,53 @@ SQL return $sql->getAll(); } + + /** + * Ermittelt alle Objekte vom gew�nschten Typ, die sic in + * diesem Projekt befinden. + * + * @see objectClasses/Object#getAllObjectIds() + * @param types Array + * @return Liste von Object-Ids + * @deprecated use Project! + */ + public function getAllObjectIds( $types=array('folder','page','link','file') ) + { + $db = db_connection(); + + $stmt = $db->sql('SELECT id FROM {{object}}'. + ' WHERE projectid={projectid}'. + ' AND ( typeid ={is_folder}' . + ' OR typeid ={is_file}' . + ' OR typeid ={is_page}' . + ' OR typeid ={is_link} )' . + ' ORDER BY orderid ASC' ); + + $stmt->setInt('projectid',$this->projectid ); + $stmt->setInt('is_folder',in_array('folder',$types)?OR_TYPEID_FOLDER:0); + $stmt->setInt('is_file' ,in_array('file' ,$types)?OR_TYPEID_FILE:0); + $stmt->setInt('is_page' ,in_array('page' ,$types)?OR_TYPEID_PAGE:0); + $stmt->setInt('is_link' ,in_array('link' ,$types)?OR_TYPEID_LINK:0); + + return( $stmt->getCol() ); + } + + + + public function getAllFolders() + { + $db = db_connection(); + + $stmt = $db->sql('SELECT id FROM {{object}}'. + ' WHERE typeid='.OR_TYPEID_FOLDER. + ' AND projectid={projectid}' ); + + $stmt->setInt( 'projectid',$this->projectid ); + + return( $stmt->getCol() ); + } + + } ?> \ No newline at end of file diff --git a/modules/cms-core/model/Template.class.php b/modules/cms-core/model/Template.class.php @@ -72,42 +72,16 @@ class Template /** - * Ermitteln aller Templates in dem aktuellen Projekt. - * @return Array mit Id:Name - * @deprecated use Project::getTemplates() - */ - function getAll() - { - global $SESS; - $db = db_connection(); - - $sql = $db->sql( 'SELECT id,name FROM {{template}}'. - ' WHERE projectid={projectid}'. - ' ORDER BY name ASC ' ); - if ( isset($this) && isset($this->projectid) ) - $sql->setInt( 'projectid',$this->projectid ); - else - { - $project = \Session::getProject(); - $sql->setInt( 'projectid',$project->projectid ); - } - - return $sql->getAssoc(); - } - - - /** * Laden des Templates aus der Datenbank und f?llen der Objekteigenschaften */ function load() { - global $SESS; $db = db_connection(); - $sql = $db->sql( 'SELECT * FROM {{template}}'. + $stmt = $db->sql( 'SELECT * FROM {{template}}'. ' WHERE id={templateid}' ); - $sql->setInt( 'templateid',$this->templateid ); - $row = $sql->getRow(); + $stmt->setInt( 'templateid',$this->templateid ); + $row = $stmt->getRow(); if ( empty($row) ) throw new \ObjectNotFoundException("Template not found: ".$this->templateid); @@ -115,12 +89,12 @@ class Template $this->name = $row['name' ]; $this->projectid = $row['projectid']; - $sql = $db->sql( 'SELECT * FROM {{templatemodel}}'. + $stmt = $db->sql( 'SELECT * FROM {{templatemodel}}'. ' WHERE templateid={templateid}'. ' AND projectmodelid={modelid}' ); - $sql->setInt( 'templateid',$this->templateid ); - $sql->setInt( 'modelid' ,$this->modelid ); - $row = $sql->getRow(); + $stmt->setInt( 'templateid',$this->templateid ); + $stmt->setInt( 'modelid' ,$this->modelid ); + $row = $stmt->getRow(); if ( isset($row['extension']) ) { @@ -146,23 +120,23 @@ class Template $db = db_connection(); - $sql = $db->sql( 'UPDATE {{template}}'. + $stmt = $db->sql( 'UPDATE {{template}}'. ' SET name={name}'. ' WHERE id={templateid}' ); - $sql->setString( 'name' ,$this->name ); - $sql->setInt ( 'templateid',$this->templateid ); - $sql->query(); + $stmt->setString( 'name' ,$this->name ); + $stmt->setInt ( 'templateid',$this->templateid ); + $stmt->query(); - $sql = $db->sql( 'SELECT COUNT(*) FROM {{templatemodel}}'. + $stmt = $db->sql( 'SELECT COUNT(*) FROM {{templatemodel}}'. ' WHERE templateid={templateid}'. ' AND projectmodelid={modelid}' ); - $sql->setInt ( 'templateid' ,$this->templateid ); - $sql->setInt ( 'modelid' ,$this->modelid ); + $stmt->setInt ( 'templateid' ,$this->templateid ); + $stmt->setInt ( 'modelid' ,$this->modelid ); - if ( intval($sql->getOne()) > 0 ) + if ( intval($stmt->getOne()) > 0 ) { // Vorlagen-Quelltext existiert für diese Varianten schon. - $sql = $db->sql( 'UPDATE {{templatemodel}}'. + $stmt = $db->sql( 'UPDATE {{templatemodel}}'. ' SET extension={extension},'. ' text={src} '. ' WHERE templateid={templateid}'. @@ -171,21 +145,21 @@ class Template else { // Vorlagen-Quelltext wird für diese Varianten neu angelegt. - $sql = $db->sql('SELECT MAX(id) FROM {{templatemodel}}'); - $nextid = intval($sql->getOne())+1; + $stmt = $db->sql('SELECT MAX(id) FROM {{templatemodel}}'); + $nextid = intval($stmt->getOne())+1; - $sql = $db->sql( 'INSERT INTO {{templatemodel}}'. + $stmt = $db->sql( 'INSERT INTO {{templatemodel}}'. ' (id,templateid,projectmodelid,extension,text) '. ' VALUES ({id},{templateid},{modelid},{extension},{src}) '); - $sql->setInt ( 'id',$nextid ); + $stmt->setInt ( 'id',$nextid ); } - $sql->setString( 'extension' ,$this->extension ); - $sql->setString( 'src' ,$this->src ); - $sql->setInt ( 'templateid' ,$this->templateid ); - $sql->setInt ( 'modelid' ,$this->modelid ); + $stmt->setString( 'extension' ,$this->extension ); + $stmt->setString( 'src' ,$this->src ); + $stmt->setInt ( 'templateid' ,$this->templateid ); + $stmt->setInt ( 'modelid' ,$this->modelid ); - $sql->query(); + $stmt->query(); } @@ -198,14 +172,14 @@ class Template { $db = db_connection(); - $sql = $db->sql( 'SELECT templateid FROM {{templatemodel}}'. + $stmt = $db->sql( 'SELECT templateid FROM {{templatemodel}}'. ' WHERE text LIKE {text} '. ' AND projectmodelid={modelid}' ); - $sql->setInt ( 'modelid',$this->modelid ); - $sql->setString( 'text' ,'%'.$text.'%' ); + $stmt->setInt ( 'modelid',$this->modelid ); + $stmt->setString( 'text' ,'%'.$text.'%' ); - return $sql->getCol(); + return $stmt->getCol(); } @@ -218,11 +192,11 @@ class Template { $db = db_connection(); - $sql = $db->sql( 'SELECT id FROM {{element}}'. + $stmt = $db->sql( 'SELECT id FROM {{element}}'. ' WHERE templateid={templateid}'. ' ORDER BY name ASC' ); - $sql->setInt( 'templateid',$this->templateid ); - return $sql->getCol(); + $stmt->setInt( 'templateid',$this->templateid ); + return $stmt->getCol(); } @@ -313,14 +287,14 @@ SQL * Hinzuf?gen eines Elementes * @param String Name des Elementes */ - function addElement( $name,$description='',$type='text' ) + public function addElement( $name,$description='',$type='text' ) { $element = new Element(); $element->name = $name; $element->desc = $description; $element->type = $type; $element->templateid = $this->templateid; - $element->wiki = true; + $element->format = ELEMENT_FORMAT_TEXT; $element->writable = true; $element->add(); } @@ -346,13 +320,6 @@ SQL $sql->setInt ('templateid',$this->templateid ); $sql->setString('name' ,$name ); - // Wenn Projektid nicht vorhanden, dann aus Session lesen - if ( !isset($this->projectid) || intval($this->projectid) == 0 ) - { - $project = \Session::getProject(); - $this->projectid = $project->projectid; - } - $sql->setInt ('projectid' ,$this->projectid ); $sql->query(); @@ -391,15 +358,15 @@ SQL $element->delete(); } - $sql = $db->sql( 'DELETE FROM {{templatemodel}}'. + $stmt = $db->sql( 'DELETE FROM {{templatemodel}}'. ' WHERE templateid={templateid}' ); - $sql->setInt( 'templateid',$this->templateid ); - $sql->query(); + $stmt->setInt( 'templateid',$this->templateid ); + $stmt->query(); - $sql = $db->sql( 'DELETE FROM {{template}}'. + $stmt = $db->sql( 'DELETE FROM {{template}}'. ' WHERE id={templateid}' ); - $sql->setInt( 'templateid',$this->templateid ); - $sql->query(); + $stmt->setInt( 'templateid',$this->templateid ); + $stmt->query(); } diff --git a/modules/cms-macros/macro/LanguageLinksForPage.class.php b/modules/cms-macros/macro/LanguageLinksForPage.class.php @@ -22,6 +22,7 @@ // $Log$ // --------------------------------------------------------------------------- use cms\model\Language; +use cms\model\Project; /** * Erstellen einer Liste von Language-Links auf die selbe Seite @@ -53,9 +54,10 @@ class LanguageLinksForPage extends Macro { // current language $languageId = $this->page->languageid; - + + $project = new Project( $this->page->projectid ); // Schleife ueber alle Inhalte des Root-Ordners - foreach( Language::getAll() as $lid=>$lname) + foreach( $project->getLanguages() as $lid=>$lname) { $l = new Language( $lid ); diff --git a/modules/cms-ui/action/IndexAction.class.php b/modules/cms-ui/action/IndexAction.class.php @@ -3,7 +3,10 @@ namespace cms\action; use \Auth; +use cms\model\BaseObject; +use cms\model\Project; use cms\model\User; +use cms\model\Value; use Exception; use JSON; use JSqueeze; @@ -137,10 +140,7 @@ class IndexAction extends Action $userIsLoggedIn = is_object($user); // Welche Aktion soll ausgeführt werden? - $action = $userIsLoggedIn ? 'start' : 'login'; - if ( $userIsLoggedIn && isset($_REQUEST['action'])) { - $action = $_REQUEST['action']; - } + $action = $this->getStartAction(); $id = $this->getRequestId(); $this->setTemplateVar('action',$action); @@ -744,5 +744,50 @@ class IndexAction extends Action return isset($colors[$colorName])?$colors[$colorName]:$colorName; } + + + private function getStartAction() + { + if ( isset($_REQUEST['action']) ) { + return $_REQUEST['action']; + } + + $user = Session::getUser(); + $userIsLoggedIn = $user != null; + + // Das zuletzt geänderte benutzen. + if ( config('login','start','start_lastchanged_object') ) + { + $objectid = Value::getLastChangedObjectByUserId($user->userid); + + if ( BaseObject::available($objectid)) + { + $object = new BaseObject($objectid); + $object->objectLoad(); + + return $object->getType(); + } + } + + + if ( config('login','start','start_single_project') ) + { + $projects = Project::getAllProjects(); + if ( count($projects) == 1 ) { + // Das einzige Projekt sofort starten. + return 'project'; + } + else{ + return 'projectlist'; + } + } + + + if( !$userIsLoggedIn ) + return 'login'; + + return 'start'; + } + } ?> \ No newline at end of file diff --git a/modules/util/Api.class.php b/modules/util/Api.class.php @@ -16,6 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use cms\model\Folder; +use cms\model\Project; /** @@ -56,7 +57,8 @@ class Api function getRootObjectId() { - return Folder::getRootObjectId(); + $project = new Project( $this->page->projectid); + return $project::getRootObjectId(); } function folderid() diff --git a/modules/util/Macro.class.php b/modules/util/Macro.class.php @@ -88,7 +88,7 @@ class Macro */ public function &getObject() { - return Session::getObject(); + return $this->page; } diff --git a/modules/util/Session.class.php b/modules/util/Session.class.php @@ -9,16 +9,10 @@ use cms\model\User; /** * Session-Funktionen zum Lesen/Schreiben in/von HTTP-Session * In der Session werden folgende Daten abgelegt - * - Ausgewaehltes Projekt - * - Ausgewaehlte Projectsprache - * - Ausgewaehlte Projektvariante * - Angemeldeter Benutzer - * - Auswahlbaum - * - Geladene Sprachelemente - * - Ausgewaehlter Ordner - * - Ausgewaehltes Objekt * - Datenbankobjekt - * Die Methoden dieser Klassen koennen statisch aufgerufen werden + * - Konfiguration + * Die Methoden dieser Klassen koennen statisch aufgerufen werden. * * @author $Author$ * @version $Revision$ @@ -29,7 +23,6 @@ class Session { public static function get( $var ) { - global $SESS; $SESS = &$_SESSION; if ( isset($SESS['ors_'.$var]) ) @@ -40,7 +33,6 @@ class Session public static function set( $var,$value ) { - global $SESS; $SESS = &$_SESSION; $SESS[ 'ors_'.$var ] = $value; } @@ -61,98 +53,6 @@ class Session /** - * @return \cms\model\Model - */ - public static function getProjectModel() - { - return Session::get('project_model'); - } - - public static function setProjectModel( $var ) - { - Session::set('project_model',$var); - } - - - /** - * @return \cms\model\Language - */ - public static function getProjectLanguage() - { - return Session::get('project_language'); - } - - public static function setProjectLanguage( $var ) - { - Session::set('project_language',$var); - } - - - - public static function getObject() - { - return Session::get('object'); - } - - public static function setObject( $var ) - { - Session::set('object',$var); - } - - - /** - * @return \cms\model\Folder - */ - public static function getFolder() - { - return Session::get('folder'); - } - - public static function setFolder( $var ) - { - Session::set('folder',$var); - } - - - - public static function getTree() - { - return Session::get('tree'); - } - - public static function setTree( $var ) - { - Session::set('tree',$var); - } - - - - public static function getElement() - { - return Session::get('element'); - } - - public static function setElement( $var ) - { - Session::set('element',$var); - } - - - /** - * @return \cms\model\Project - */ - public static function getProject() - { - return Session::get('project'); - } - - public static function setProject( $var ) - { - Session::set('project',$var); - } - - - /** * @return User */ public static function getUser() @@ -180,31 +80,6 @@ class Session } - /** - * @return string - */ - public static function getSubaction() - { - return Session::get('subaction'); - } - - public static function setSubaction( $var ) - { - Session::set('subaction',$var); - } - - - public static function getClipboard() - { - return Session::get('clipboard'); - } - - public static function setClipboard( $var ) - { - Session::set('clipboard',$var); - } - - /** * Schliesst die aktuelle Session * diff --git a/modules/util/exception/ValidationException.class.php b/modules/util/exception/ValidationException.class.php @@ -0,0 +1,25 @@ +<?php + +class ValidationException extends Exception +{ + public $fieldName; + + // Die Exception neu definieren, damit die Mitteilung nicht optional ist + public function __construct($fieldName) { + + $this->fieldName = $fieldName; + + // sicherstellen, dass alles korrekt zugewiesen wird + parent::__construct('Field validation: '.$fieldName, 0, null); + } + + // maßgeschneiderte Stringdarstellung des Objektes + public function __toString() { + return __CLASS__ . ": ".$this->fieldName.": '{$this->message}' in {$this->file}({$this->line})\n" + . "{$this->getTraceAsString()}\n"; + } + +} + + +?>+ \ No newline at end of file diff --git a/modules/util/require.php b/modules/util/require.php @@ -1,5 +1,9 @@ <?php +require_once( __DIR__.'/'.'exception/ValidationException.class.php' ); +require_once( __DIR__.'/'.'exception/OpenRatException.class.php' ); +require_once( __DIR__.'/'.'exception/SecurityException.class.php' ); + require_once( __DIR__.'/'.'GlobalFunctions.class.php' ); require_once( __DIR__.'/'.'Http.class.php' ); require_once( __DIR__.'/'.'Html.class.php' ); @@ -14,11 +18,8 @@ require_once( __DIR__.'/'.'JSON.class.php' ); require_once( __DIR__.'/'.'Less.php' ); require_once( __DIR__.'/'.'JSqueeze.class.php' ); require_once( __DIR__.'/'.'Spyc.class.php' ); -require_once( __DIR__.'/'.'exception/OpenRatException.class.php' ); -require_once( __DIR__.'/'.'exception/SecurityException.class.php' ); require_once( __DIR__.'/'.'TreeElement.class.php' ); require_once( __DIR__.'/'.'Tree.class.php'); -require_once( __DIR__.'/'.'Publish.class.php' ); require_once( __DIR__.'/'.'Ftp.class.php' ); require_once( __DIR__.'/'.'Macro.class.php' ); require_once( __DIR__.'/'.'Dynamic.class.php' );