openrat-cms

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

commit aae322aca73c407ac4f7b02e674d6f701f47cf2e
parent 198e275165c6e5cfb0c41d7b8d4eec795af8d143
Author: dankert <devnull@localhost>
Date:   Mon, 27 Dec 2010 23:47:00 +0100

Action-Klassen verschieben: actionClasses -> action

Diffstat:
action/.htaccess | 3+++
action/BackgroundAction.class.php | 125+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/BackgroundAction.ini.php | 5+++++
action/BorderAction.class.php | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/BorderAction.ini.php | 5+++++
action/ClipboardAction.class.php | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ElementAction.class.php | 636+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ElementAction.ini.php | 36++++++++++++++++++++++++++++++++++++
action/EmptyAction.class.php | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/EmptyAction.ini.php | 9+++++++++
action/FileAction.class.php | 715+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/FileAction.ini.php | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/FilebrowserAction.class.php | 253+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/FilebrowserAction.ini.php | 19+++++++++++++++++++
action/FolderAction.class.php | 1228+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/FolderAction.ini.php | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/GroupAction.class.php | 349+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/GroupAction.ini.php | 44++++++++++++++++++++++++++++++++++++++++++++
action/LanguageAction.class.php | 287+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/LanguageAction.ini.php | 37+++++++++++++++++++++++++++++++++++++
action/LinkAction.class.php | 203+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/LinkAction.ini.php | 44++++++++++++++++++++++++++++++++++++++++++++
action/LoginAction.class.php | 1677+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/LoginAction.ini.php | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/MainAction.class.php | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/MainAction.ini.php | 47+++++++++++++++++++++++++++++++++++++++++++++++
action/MainmenuAction.class.php | 558+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/MainmenuAction.ini.php | 50++++++++++++++++++++++++++++++++++++++++++++++++++
action/ModelAction.class.php | 226+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ModelAction.ini.php | 34++++++++++++++++++++++++++++++++++
action/ObjectAction.class.php | 344+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/PageAction.class.php | 810+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/PageAction.ini.php | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/PageelementAction.class.php | 1351+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/PageelementAction.ini.php | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ProfileAction.class.php | 298+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ProfileAction.ini.php | 43+++++++++++++++++++++++++++++++++++++++++++
action/ProjectAction.class.php | 319+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/ProjectAction.ini.php | 39+++++++++++++++++++++++++++++++++++++++
action/SearchAction.class.php | 249+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/SearchAction.ini.php | 27+++++++++++++++++++++++++++
action/StartAction.class.php | 1666+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/StartAction.ini.php | 21+++++++++++++++++++++
action/StatusAction.class.php | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/StatusAction.ini.php | 7+++++++
action/TemplateAction.class.php | 691+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TemplateAction.ini.php | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TitleAction.class.php | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TitleAction.ini.php | 6++++++
action/TransferAction.class.php | 242+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TreeAction.class.php | 249+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TreeAction.ini.php | 22++++++++++++++++++++++
action/TreetitleAction.class.php | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/TreetitleAction.ini.php | 11+++++++++++
action/UserAction.class.php | 429+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/UserAction.ini.php | 41+++++++++++++++++++++++++++++++++++++++++
action/WebdavAction.class.php | 1196+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
action/WebdavAction.ini.php | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
actionClasses/.htaccess | 3---
actionClasses/BackgroundAction.class.php | 125-------------------------------------------------------------------------------
actionClasses/BackgroundAction.ini.php | 5-----
actionClasses/BorderAction.class.php | 124-------------------------------------------------------------------------------
actionClasses/BorderAction.ini.php | 5-----
actionClasses/ClipboardAction.class.php | 58----------------------------------------------------------
actionClasses/ElementAction.class.php | 636-------------------------------------------------------------------------------
actionClasses/ElementAction.ini.php | 36------------------------------------
actionClasses/EmptyAction.class.php | 74--------------------------------------------------------------------------
actionClasses/EmptyAction.ini.php | 9---------
actionClasses/FileAction.class.php | 714-------------------------------------------------------------------------------
actionClasses/FileAction.ini.php | 90-------------------------------------------------------------------------------
actionClasses/FilebrowserAction.class.php | 253-------------------------------------------------------------------------------
actionClasses/FilebrowserAction.ini.php | 19-------------------
actionClasses/FolderAction.class.php | 1228-------------------------------------------------------------------------------
actionClasses/FolderAction.ini.php | 123-------------------------------------------------------------------------------
actionClasses/GroupAction.class.php | 349-------------------------------------------------------------------------------
actionClasses/GroupAction.ini.php | 44--------------------------------------------
actionClasses/LanguageAction.class.php | 287-------------------------------------------------------------------------------
actionClasses/LanguageAction.ini.php | 37-------------------------------------
actionClasses/LinkAction.class.php | 203-------------------------------------------------------------------------------
actionClasses/LinkAction.ini.php | 44--------------------------------------------
actionClasses/LoginAction.class.php | 1677-------------------------------------------------------------------------------
actionClasses/LoginAction.ini.php | 104-------------------------------------------------------------------------------
actionClasses/MainAction.class.php | 98-------------------------------------------------------------------------------
actionClasses/MainAction.ini.php | 47-----------------------------------------------
actionClasses/MainmenuAction.class.php | 558-------------------------------------------------------------------------------
actionClasses/MainmenuAction.ini.php | 50--------------------------------------------------
actionClasses/ModelAction.class.php | 226-------------------------------------------------------------------------------
actionClasses/ModelAction.ini.php | 34----------------------------------
actionClasses/ObjectAction.class.php | 344-------------------------------------------------------------------------------
actionClasses/PageAction.class.php | 810-------------------------------------------------------------------------------
actionClasses/PageAction.ini.php | 81-------------------------------------------------------------------------------
actionClasses/PageelementAction.class.php | 1351-------------------------------------------------------------------------------
actionClasses/PageelementAction.ini.php | 52----------------------------------------------------
actionClasses/ProfileAction.class.php | 298-------------------------------------------------------------------------------
actionClasses/ProfileAction.ini.php | 43-------------------------------------------
actionClasses/ProjectAction.class.php | 319-------------------------------------------------------------------------------
actionClasses/ProjectAction.ini.php | 39---------------------------------------
actionClasses/SearchAction.class.php | 249-------------------------------------------------------------------------------
actionClasses/SearchAction.ini.php | 27---------------------------
actionClasses/StartAction.class.php | 1666-------------------------------------------------------------------------------
actionClasses/StartAction.ini.php | 20--------------------
actionClasses/StatusAction.class.php | 78------------------------------------------------------------------------------
actionClasses/StatusAction.ini.php | 7-------
actionClasses/TemplateAction.class.php | 691-------------------------------------------------------------------------------
actionClasses/TemplateAction.ini.php | 71-----------------------------------------------------------------------
actionClasses/TitleAction.class.php | 96-------------------------------------------------------------------------------
actionClasses/TitleAction.ini.php | 6------
actionClasses/TransferAction.class.php | 242-------------------------------------------------------------------------------
actionClasses/TreeAction.class.php | 249-------------------------------------------------------------------------------
actionClasses/TreeAction.ini.php | 22----------------------
actionClasses/TreetitleAction.class.php | 79-------------------------------------------------------------------------------
actionClasses/TreetitleAction.ini.php | 11-----------
actionClasses/UserAction.class.php | 429-------------------------------------------------------------------------------
actionClasses/UserAction.ini.php | 41-----------------------------------------
actionClasses/WebdavAction.class.php | 1196-------------------------------------------------------------------------------
actionClasses/WebdavAction.ini.php | 53-----------------------------------------------------
116 files changed, 15832 insertions(+), 15830 deletions(-)

diff --git a/action/.htaccess b/action/.htaccess @@ -0,0 +1,2 @@ +order deny,allow +deny from all+ \ No newline at end of file diff --git a/action/BackgroundAction.class.php b/action/BackgroundAction.class.php @@ -0,0 +1,124 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.2 2006-06-16 21:26:29 dankert +// Methode maxAge(), setzen von Expires-Headern im HTTP-Header. +// +// Revision 1.1 2006/01/11 22:38:33 dankert +// Neue Aktionsklassen f?r neue Darstellungsart +// +// Revision 1.21 2005/04/16 21:35:23 dankert +// Uebergabe von Loginfehlern als normale Hinweismeldung +// +// Revision 1.20 2005/03/13 16:39:00 dankert +// Neue Methoden, um Baum ein- und auszublenden +// +// Revision 1.19 2005/02/17 19:21:00 dankert +// Titelanzeige geaendert +// +// Revision 1.18 2005/01/27 00:03:57 dankert +// Variable "nopublish" an das Template liefern +// +// Revision 1.17 2005/01/23 11:13:54 dankert +// Schalter "nologin" beruecksichtigen +// +// Revision 1.16 2005/01/14 21:41:23 dankert +// Aufruf von lastModified() fuer Conditional-GET +// +// Revision 1.15 2005/01/04 21:42:09 dankert +// Uebertragen von MOTD +// +// Revision 1.14 2004/12/29 20:19:55 dankert +// Korrektur +// +// Revision 1.13 2004/12/28 22:58:39 dankert +// Fuellen Variablen logo* fuer Loginmaske +// +// Revision 1.12 2004/12/26 20:20:17 dankert +// Bei Logout entfernen aller Session-Variablen +// +// Revision 1.11 2004/12/26 18:49:58 dankert +// Projektname im Seiten-Titel +// +// Revision 1.10 2004/12/25 22:11:20 dankert +// Logo-Bild ueber Parameter +// +// Revision 1.9 2004/12/19 21:57:02 dankert +// Korrektur bei direktem Objektaufruf in object() +// +// Revision 1.8 2004/12/19 14:54:31 dankert +// language() und model() korrigiert +// +// Revision 1.7 2004/12/18 00:16:26 dankert +// language_read() entfernt +// +// Revision 1.6 2004/12/15 23:23:27 dankert +// div. neue Methoden +// +// Revision 1.5 2004/11/28 18:26:15 dankert +// Anpassen an neue Sprachdatei-Konventionen +// +// Revision 1.4 2004/11/15 21:34:05 dankert +// Korrektur fuer Administrationsmodus +// +// Revision 1.3 2004/11/10 22:36:45 dankert +// Laden von Projektklassen und Lesen/Schreiben von/nach Session +// +// Revision 1.2 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse fuer Hintergrund + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class BackgroundAction extends Action +{ + var $defaultSubAction = 'show'; + + function show() + { + global $conf; + global $PHP_AUTH_USER; + global $PHP_AUTH_PW; + + $user = Session::getUser(); + + // Seite �ndert sich nur 1x pro Session + $this->lastModified( $user->loginDate ); + + $this->setTemplateVar( 'stylesheet',$user->style ); + $this->setTemplateVar( 'css_body_class','background' ); + + $this->maxAge( 4*60*60 ); // 1 Stunde Browsercache + } +} + +?>+ \ No newline at end of file diff --git a/action/BackgroundAction.ini.php b/action/BackgroundAction.ini.php @@ -0,0 +1,5 @@ + +[default] +goto=show + +[show] diff --git a/action/BorderAction.class.php b/action/BorderAction.class.php @@ -0,0 +1,123 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.2 2006-06-16 21:26:29 dankert +// Methode maxAge(), setzen von Expires-Headern im HTTP-Header. +// +// Revision 1.1 2006/01/11 22:38:33 dankert +// Neue Aktionsklassen f?r neue Darstellungsart +// +// Revision 1.21 2005/04/16 21:35:23 dankert +// Uebergabe von Loginfehlern als normale Hinweismeldung +// +// Revision 1.20 2005/03/13 16:39:00 dankert +// Neue Methoden, um Baum ein- und auszublenden +// +// Revision 1.19 2005/02/17 19:21:00 dankert +// Titelanzeige geaendert +// +// Revision 1.18 2005/01/27 00:03:57 dankert +// Variable "nopublish" an das Template liefern +// +// Revision 1.17 2005/01/23 11:13:54 dankert +// Schalter "nologin" beruecksichtigen +// +// Revision 1.16 2005/01/14 21:41:23 dankert +// Aufruf von lastModified() fuer Conditional-GET +// +// Revision 1.15 2005/01/04 21:42:09 dankert +// Uebertragen von MOTD +// +// Revision 1.14 2004/12/29 20:19:55 dankert +// Korrektur +// +// Revision 1.13 2004/12/28 22:58:39 dankert +// Fuellen Variablen logo* fuer Loginmaske +// +// Revision 1.12 2004/12/26 20:20:17 dankert +// Bei Logout entfernen aller Session-Variablen +// +// Revision 1.11 2004/12/26 18:49:58 dankert +// Projektname im Seiten-Titel +// +// Revision 1.10 2004/12/25 22:11:20 dankert +// Logo-Bild ueber Parameter +// +// Revision 1.9 2004/12/19 21:57:02 dankert +// Korrektur bei direktem Objektaufruf in object() +// +// Revision 1.8 2004/12/19 14:54:31 dankert +// language() und model() korrigiert +// +// Revision 1.7 2004/12/18 00:16:26 dankert +// language_read() entfernt +// +// Revision 1.6 2004/12/15 23:23:27 dankert +// div. neue Methoden +// +// Revision 1.5 2004/11/28 18:26:15 dankert +// Anpassen an neue Sprachdatei-Konventionen +// +// Revision 1.4 2004/11/15 21:34:05 dankert +// Korrektur fuer Administrationsmodus +// +// Revision 1.3 2004/11/10 22:36:45 dankert +// Laden von Projektklassen und Lesen/Schreiben von/nach Session +// +// Revision 1.2 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + +/** + * Action-Klasse fuer das Anzeigen eines Randes + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class BorderAction extends Action +{ + var $defaultSubAction = 'show'; + + function show() + { + global $conf; + global $PHP_AUTH_USER; + global $PHP_AUTH_PW; + + $user = Session::getUser(); + + // Seite �ndert sich nur 1x pro Session + $this->lastModified( $user->loginDate ); + + $this->setTemplateVar( 'stylesheet',$user->style ); + $this->setTemplateVar( 'css_body_class','border' ); + + $this->maxAge( 4*60*60 ); // 1 Stunde Browsercache + } +} + +?>+ \ No newline at end of file diff --git a/action/BorderAction.ini.php b/action/BorderAction.ini.php @@ -0,0 +1,5 @@ + +[default] +goto=show + +[show] diff --git a/action/ClipboardAction.class.php b/action/ClipboardAction.class.php @@ -0,0 +1,57 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse fuer die Start-Action + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class ClipboardAction extends Action +{ + var $defaultSubAction = 'show'; + + + function show() + { + global $conf; + $o = Session::getClipboard(); + if ( is_object($o)) + { + $o->load(); + $this->setTemplateVar('object',$o); + } + } + + + function set() + { + global $conf; + $o = new Object( $this->getRequestId() ); + Session::setClipboard( $o ); + $this->callSubAction( 'show' ); + + } +} + +?>+ \ No newline at end of file diff --git a/action/ElementAction.class.php b/action/ElementAction.class.php @@ -0,0 +1,635 @@ +<?php +// OpenRat Content Management System +// Copyright (C) 2002-2010 Jan Dankert +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** + * Action-Klasse fuer die Bearbeitung eines Template-Elementes. + * + * @author Jan Dankert + * @package openrat.actions + */ +class ElementAction extends Action +{ + var $element; + + /** + * Konstruktor + */ + function ElementAction() + { + if ( $this->getRequestId() == 0 ) + die('no element-id available'); + + $this->element = new Element( $this->getRequestId() ); + $this->element->load(); + + $this->setTemplateVar( 'elementid' ,$this->element->elementid ); + } + + + + /** + * Umbenennen des Elementes + */ + function savename() + { + $this->element->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM); + $this->element->desc = $this->getRequestVar('description','all' ); + + $this->element->save(); + $this->element->load(); + + $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK); + } + + + + /** + * Umbenennen des Elementes + */ + function remove() + { + $this->setTemplateVar( 'name' ,$this->element->name ); + } + + + /** + * Entfernen des Elementes + */ + function delete() + { + if ( !$this->hasRequestVar('confirm') ) + { + $this->addValidationError('confirm'); + return; + } + + $type = $this->getRequestVar('type','abc'); + + if ( $type == 'value' ) + { + $this->element->deleteValues(); + $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK); + } + elseif ( $type == 'all' ) + { + $this->element->delete(); + $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK); + } + } + + + + /** + * Aendern des Element-Typs + */ + function savetype() + { + if ( !$this->userIsAdmin() && $this->getRequestVar('type') == 'code' ) + { + // Code-Elemente fuer Nicht-Administratoren nicht benutzbar + $this->addNotice('element',$this->template->name,'CANCELED',OR_NOTICE_ERROR); + } + else + { + // Neuen Typ setzen und speichern + $this->element->setType( $this->getRequestVar('type') ); + $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK); + } + } + + + /** + * Anzeigen des Elementes + */ + function name() + { + + // Name und Beschreibung + $this->setTemplateVar('name' ,$this->element->name); + + $this->setTemplateVar('description',$this->element->desc); + } + + + + function type() + { + // Die verschiedenen Element-Typen + $types = array(); + + foreach( $this->element->getAvailableTypes() as $t ) + $types[ $t ] = 'EL_'.$t; + + // Code-Element nur fuer Administratoren (da voller Systemzugriff!) + if ( !$this->userIsAdmin() ) + unset( $types['code'] ); + + // Liste aller Elementtypen + $this->setTemplateVar('types',$types); + + // Aktueller Typ + $this->setTemplateVar('type',$this->element->type); + } + + + /** + * Auswahlmaske f�r weitere Einstellungen zum Template-Element. + * + */ + function properties() + { + global $conf; + + // Abhaengig vom aktuellen Element-Typ die Eigenschaften anzeigen + $properties = $this->element->getRelatedProperties(); + + foreach( $this->element->getRelatedProperties() as $propertyName ) + { + switch( $propertyName ) + { + case 'withIcon': + $this->setTemplateVar('with_icon' ,$this->element->withIcon ); + break; + + case 'allLanguages': + $this->setTemplateVar('all_languages',$this->element->allLanguages); + break; + + case 'writable': + $this->setTemplateVar('writable' ,$this->element->writable ); + break; + + case 'subtype': + + $convertToLang = false; + switch( $this->element->type ) + { + case 'info': + $subtypes = Array('db_id', + 'db_name', + 'project_id', + 'project_name', + 'language_id', + 'language_iso', + 'language_name', + 'page_id', + 'page_name', + 'page_desc', + 'page_fullfilename', + 'page_filename', + 'page_extension', + 'edit_url', + 'edit_fullurl', + 'lastch_user_username', + 'lastch_user_fullname', + 'lastch_user_mail', + 'lastch_user_desc', + 'lastch_user_tel', + 'create_user_username', + 'create_user_fullname', + 'create_user_mail', + 'create_user_desc', + 'create_user_tel', + 'act_user_username', + 'act_user_fullname', + 'act_user_mail', + 'act_user_desc', + 'act_user_tel' ); + $convertToLang = true; + break; + + case 'infodate': + case 'linkdate': + $subtypes = Array('date_published', + 'date_saved', + 'date_created' ); + $convertToLang = true; + break; + + case 'link': + $subtypes = Array( + 'file', + 'image', + 'image_data_uri', + 'page', + 'link' ); + $convertToLang = true; + break; + + case 'linkinfo': + $subtypes = Array('width', + 'height', + 'id', + 'name', + 'description', + 'mime-type', + 'lastch_user_username', + 'lastch_user_fullname', + 'lastch_user_mail', + 'lastch_user_desc', + 'lastch_user_tel', + 'create_user_username', + 'create_user_fullname', + 'create_user_mail', + 'create_user_desc', + 'create_user_tel', + 'filename', + 'full_filename' ); + $convertToLang = true; + break; + + case 'insert': + $subtypes = Array('inline', + 'ssi' ); + $convertToLang = true; + break; + + case 'dynamic': + + $files = Array(); + $handle = opendir ('./dynamicClasses'); + while ( $file = readdir($handle) ) + { + $file = substr($file,0,strlen($file)-10); + if ( $file != '' ) + $files[$file] = $file; + } + closedir($handle); + + $subtypes = $files; + break; + + default: + $subtypes = array(); + break; + } + + if ( $convertToLang ) + { + foreach( $subtypes as $t=>$v ) + { + unset($subtypes[$t]); + $subtypes[$v] = lang('EL_'.$this->element->type.'_'.$v); + } + } + + // Variable $subtype muss existieren, um Anzeige des Feldes zu erzwingen. + if (!isset($this->element->subtype)) + $this->element->subtype=''; + + $this->setTemplateVar('subtypes',$subtypes ); + $this->setTemplateVar('subtype' ,$this->element->subtype); + + break; + + + case 'dateformat': + + $ini_date_format = $conf['date']['format']; + $dateformat = array(); + + $this->setTemplateVar('dateformat',''); + + foreach($ini_date_format as $idx=>$d) + { + if ( strpos($d,'%')!==FALSE ) + $dateformat[$idx] = strftime($d); + else + $dateformat[$idx] = date($d); + if ( $d == $this->element->dateformat ) + $this->setTemplateVar('dateformat',$idx); + } + + $this->setTemplateVar('dateformats',$dateformat); + + break; + + + // Eigenschaften Text und Text-Absatz + case 'defaultText': + + switch( $this->element->type ) + { + case 'longtext': + $this->setTemplateVar('default_longtext',$this->element->defaultText ); + break; + + case 'select': + case 'text': + $this->setTemplateVar('default_text' ,$this->element->defaultText ); + break; + } + break; + + + case 'htmlwiki': + if ( !$this->element->wiki && !$this->element->html ) + $format = 'none'; + elseif ( $this->element->wiki && !$this->element->html ) + $format = 'wiki'; + elseif ( !$this->element->wiki && $this->element->html ) + $format = 'html'; + elseif ( $this->element->wiki && $this->element->html ) + $format = 'wiki,html'; + + $this->setTemplateVar('format', $format ); + + $formatlist = array(); + $formatlist['none' ] = 'raw'; // Nur Text, ohne Auszeichnungen + // Für einfache Textelemente gibt es keinen HTML-Editor + if ( $this->element->type == 'longtext' ) + $formatlist['html' ] = 'html'; // Text mit HTML-Editor + $formatlist['wiki' ] = 'wiki'; // Text mit Markup, HTML nicht erlaubt + $formatlist['wiki,html'] = 'wikihtml'; // Text mit Markup, HTML erlaubt + + foreach( $formatlist as $t=>$v ) + $formatlist[$t] = array('lang'=>'EL_PROP_'.$v); + + $this->setTemplateVar('formatlist', $formatlist ); + //Html::debug($this->templateVars); + break; + + case 'linktype': + $this->setTemplateVar('linktype', $this->element->wiki ); + $this->setTemplateVar('linktypelist', array('page','file','link') ); + //Html::debug($this->templateVars); + break; + + case 'prefix': + $t = new Template( $this->element->templateid ); + + $elements = array(); + foreach( $t->getElements() as $element ) + { + if ( $element->type == 'link' ) + $elements[$element->name] = $element->name; + } + unset($t); + + $this->setTemplateVar('linkelements',$elements ); + + list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%'); + $this->setTemplateVar('linkelement',$linkElementName ); + + break; + + case 'name': + + $names = array(); + + foreach( Template::getAll() as $tid=>$name ) + { + $t = new Template( $tid ); + $t->load(); + + foreach( $t->getElements() as $element ) + { + if ( !in_array($element->type,array('copy','linkinfo','link')) ) + $names[$element->name] = $t->name.' - '.$element->name.' ('.lang('EL_'.$element->type).')'; + } + unset($t); + } + + + $this->setTemplateVar('names',$names ); + + list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%'); + $this->setTemplateVar('name',$targetElementName ); + break; + + // Eigenschaften PHP-Code + case 'code': + + switch( $this->element->type ) + { + + case 'select': + $this->setTemplateVar('select_items',$this->element->code ); + break; + + case 'dynamic': + + $className = $this->element->subtype; + $fileName = OR_DYNAMICCLASSES_DIR.'/'.$className.'.class.'.PHP_EXT; + + if ( is_file( $fileName ) ) + { + require( $fileName ); + + if ( class_exists($className) ) + { + $dynEl = new $className; + + $desc = array(); + + $description = $dynEl->description; + $paramList = array(); + + $old = $this->element->getDynamicParameters(); + $parameters = ''; + + foreach( get_object_vars($dynEl) as $paramName=>$paramDesc ) + { + if ( isset( $dynEl->$paramName ) ) + { + if ( is_object($dynEl->$paramName)) + continue; + if ( is_array($dynEl->$paramName)) + continue; + if ( in_array($paramName,array('output'))) + continue; + $paramList[$paramName] = $dynEl->$paramName; + + $parameters .= $paramName.':'; + if ( !empty($old[$paramName]) ) + $parameters .= $old[$paramName]; + else + $parameters .= $dynEl->$paramName; + $parameters .= "\n"; + } + } + + $this->setTemplateVar('dynamic_class_description',$dynEl->description ); + $this->setTemplateVar('dynamic_class_parameters' ,$paramList ); + $this->setTemplateVar('parameters' ,$parameters ); + } + } + + break; + + case 'code': + if ( $conf['security']['disable_dynamic_code'] ) + $this->addNotice('element',$this->element->name,'CODE_DISABLED',OR_NOTICE_WARN); + + $this->setTemplateVar('code',$this->element->code); + break; + } + break; + + + case 'decimals': + $this->setTemplateVar('decimals' ,$this->element->decimals ); + break; + + case 'decPoint': + $this->setTemplateVar('dec_point' ,$this->element->decPoint ); + break; + + case 'thousandSep': + $this->setTemplateVar('thousand_sep' ,$this->element->thousandSep ); + break; + + + // Eigenschaften Link + case 'defaultObjectId': + + $objects = array(); + + // Ermitteln aller verfuegbaren Objekt-IDs + foreach( Folder::getAllObjectIds() as $id ) + { + $o = new Object( $id ); + $o->load(); + + switch( $this->element->type ) + { + case 'list': + if ( !$o->isFolder ) + continue 2; + break; + + case 'link': + if ( !$o->isPage && !$o->isFile && !$o->isLink ) + continue 2; + break; + + default: + continue 2; + } + + $objects[ $id ] = lang( $o->getType() ).': '; + + if ( !$o->isRoot ) + { + $f = new Folder( $o->parentid ); + $f->load(); + $names = $f->parentObjectNames(false,true); + foreach( $names as $fid=>$name ) + $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH); + $objects[ $id ] .= implode( FILE_SEP,$names ); + } + + $objects[ $id ] .= FILE_SEP.$o->name; + } + + asort( $objects ); // Sortieren + + $this->setTemplateVar('objects',$objects); + + $this->setTemplateVar('default_objectid',$this->element->defaultObjectId); + + break; + + + case 'folderObjectId': + + $folders = array(); + + // Ermitteln aller verf?gbaren Objekt-IDs + foreach( Folder::getAllFolders() as $id ) + { + $o = new Object( $id ); + $o->load(); + + $folders[ $id ] = ''; + if ( !$o->isRoot ) + { + $f = new Folder( $o->parentid ); + $f->load(); + $names = $f->parentObjectNames(true,true); + foreach( $names as $fid=>$name ) + $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH); + $folders[ $id ] = implode( ' &raquo; ',$names ); + $folders[ $id ] .= ' &raquo; '; + } + $folders[ $id ] .= $o->name; + } + + asort( $folders ); // Sortieren + + $this->setTemplateVar('folders',$folders); + + $this->setTemplateVar('folderobjectid' ,$this->element->folderObjectId ); + + break; + + default: + $this->message('ERROR','not an element property: '.$propertyName ); + } + } + } + + + + /** + * Speichern der Element-Eigenschaften + */ + function saveproperties() + { + global $conf; + $ini_date_format = $conf['date']['format']; + + if ( $this->hasRequestVar('dateformat')) + $this->element->dateformat = $ini_date_format[$this->getRequestVar('dateformat')]; + $this->element->subtype = $this->getRequestVar('subtype'); + + if ( $this->hasRequestVar('default_longtext')) + $this->element->defaultText = $this->getRequestVar('default_longtext',OR_FILTER_RAW); + else + $this->element->defaultText = $this->getRequestVar('default_text',OR_FILTER_ALPHANUM); + $this->element->wiki = in_array('wiki',explode(',',$this->getRequestVar('format'))); + $this->element->html = in_array('html',explode(',',$this->getRequestVar('format'))); + $this->element->withIcon = $this->getRequestVar('with_icon') != ''; + $this->element->allLanguages = $this->getRequestVar('all_languages') != ''; + $this->element->writable = $this->getRequestVar('writable') != ''; + $this->element->decimals = $this->getRequestVar('decimals'); + $this->element->decPoint = $this->getRequestVar('dec_point'); + $this->element->thousandSep = $this->getRequestVar('thousand_sep'); + $this->element->folderObjectId = $this->getRequestVar('folderobjectid' ); + $this->element->defaultObjectId = $this->getRequestVar('default_objectid'); + if ( $this->hasRequestVar('select_items')) + $this->element->code = $this->getRequestVar('select_items'); + else + $this->element->code = $this->getRequestVar('code' ,'raw'); + + if ( $this->hasRequestVar('name') ) + $this->element->name = $this->getRequestVar('name'); + + if ( $this->hasRequestVar('linkelement') ) + $this->element->setPrefix( $this->getRequestVar('linkelement') ); + + if ( $this->hasRequestVar('parameters')) + $this->element->code = $this->getRequestVar('parameters',OR_FILTER_RAW); + +// Html::debug($this->element); + $this->element->save(); + $this->addNotice('element',$this->element->name,'SAVED'); + + } +} + +?>+ \ No newline at end of file diff --git a/action/ElementAction.ini.php b/action/ElementAction.ini.php @@ -0,0 +1,35 @@ + +[default] +goto=name + +[name] +target=savename +menu=edit + +[type] +target=savetype +menu=edit + +[properties] +target=saveproperties +menu=edit + +[saveproperties] +goto=name + +[savename] +goto=name + +[savetype] +goto=name + +[remove] +menu=edit +target=delete + +[delete] +goto=name + +[menu] +;edit=name,type,properties,remove +menu=name,type,properties,remove+ \ No newline at end of file diff --git a/action/EmptyAction.class.php b/action/EmptyAction.class.php @@ -0,0 +1,73 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse fuer eine leere Seite. + * + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class EmptyAction extends Action +{ + var $defaultSubAction = 'show'; + + + + function EmptyAction() + { + global $conf; + global $PHP_AUTH_USER; + global $PHP_AUTH_PW; + + $user = Session::getUser(); + + // Seite ndert sich nur 1x pro Session + $this->lastModified( $user->loginDate ); + + + $this->maxAge( 4*60*60 ); // 1 Stunde Browsercache + + } + + + + function background() + { + } + + + + function border() + { + } + + + + function blank() + { + } +} + +?>+ \ No newline at end of file diff --git a/action/EmptyAction.ini.php b/action/EmptyAction.ini.php @@ -0,0 +1,9 @@ + +[default] +goto=blank + +[border] + +[blank] + +[background] diff --git a/action/FileAction.class.php b/action/FileAction.class.php @@ -0,0 +1,714 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse zum Bearbeiten einer Datei + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class FileAction extends ObjectAction +{ + var $file; + var $defaultSubAction = 'show'; + + /** + * Konstruktor + */ + function FileAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->file = new File( $this->getRequestId() ); + $this->file->load(); + Session::setObject( $this->file ); + } + else + { + $this->file = Session::getObject(); + } + + $folder = new Folder( $this->file->parentid ); + $folder->filenames = false; + $folder->load(); + $path = array(); + foreach( $folder->parentObjectNames(true,true) as $id=>$name ) + { + $path[] = array('key'=>'','name'=>$name,'title'=>$name,'url'=>Html::url('folder','show',$id),'type'=>'folder'); + } + $path[] = array('key'=>'','name'=>$this->file->name,'title'=>$this->file->description,'xurl'=>Html::url('file','show',$this->file->id),'type'=>'file'); + $this->setTemplateVar('path',$path); + } + + + /** + * Ersetzt den Inhalt mit einer anderen Datei + */ + function replace() + { + $upload = new Upload(); + + $this->file->filename = $upload->filename; + $this->file->extension = $upload->extension; + $this->file->size = $upload->size; + $this->file->save(); + + $this->file->value = $upload->value; + $this->file->saveValue(); + $this->file->setTimestamp(); + + //$setTemplateVar('tree_refresh',true); + $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok'); + } + + + function savevalue() + { + $this->file->value = $this->getRequestVar('value',OR_FILTER_RAW); + $this->file->saveValue(); + + $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok'); + $this->file->setTimestamp(); + } + + + /** + * Abspeichern der Eigenschaften zu dieser Datei. + * + */ + function saveprop() + { + // Eigenschaften speichern + $this->file->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME); + $this->file->name = $this->getRequestVar('name' ,OR_FILTER_FULL ); + $this->file->extension = $this->getRequestVar('extension' ,OR_FILTER_FILENAME); + $this->file->desc = $this->getRequestVar('description',OR_FILTER_FULL ); + + $this->file->save(); + $this->file->setTimestamp(); + $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok'); + } + + + + /** + * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt + * auf die Standardausgabe geschrieben + */ + function show() + { + $this->setTemplateVar('preview_url',Html::url('file','preview',$this->file->objectid,array('target'=>'none') ) ); + } + + + /** + * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt + * auf die Standardausgabe geschrieben + */ + function preview() + { + $this->lastModified( $this->file->lastchangeDate ); + + if ( $this->file->extension == 'gz' ) + { + global $conf; + $mime_types = $conf['mime-types']; + + $pos = strrpos($this->file->filename,'.'); + if ( $pos === false ) + $ext = ''; + else + $ext = substr($this->file->filename,$pos+1); + + $ext = strtolower($ext); + + if ( !empty($mime_types[$ext]) ) + $mime_type = $mime_types[$ext]; + else + // Wenn kein Mime-Type gefunden, dann Standartwert setzen + $mime_type = OR_FILE_DEFAULT_MIMETYPE; + + header('Content-Type: '.$mime_type ); + header('Content-Encoding: gzip' ); + } + else + { + // Angabe Content-Type + header('Content-Type: '.$this->file->mimeType() ); + } + + header('X-File-Id: ' .$this->file->fileid ); + header('X-Id: ' .$this->file->id ); + + // Angabe Content-Disposition + // - Bild soll "inline" gezeigt werden + // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte + header('Content-Disposition: inline; filename='.$this->file->filenameWithExtension() ); + header('Content-Transfer-Encoding: binary' ); + header('Content-Description: '.$this->file->name ); + + $this->file->write(); // Bild aus Datenbank laden + + // Groesse des Bildes in Bytes + // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen + header('Content-Length: '.filesize($this->file->tmpfile()) ); + + if ( ( config('publish','enable_php_in_file_content')=='auto' && $this->file->getRealExtension()=='php') || + config('publish','enable_php_in_file_content')===true ) + require( $this->file->tmpfile() ); + else + readfile( $this->file->tmpfile() ); + exit; + } + + + function imageFormat() + { + if ( ! function_exists( 'imagetypes' ) ) + return 0; + + $ext = strtolower($this->file->getRealExtension()); + $types = imagetypes(); + $formats = array( 'gif' =>IMG_GIF, + 'jpg' =>IMG_JPG, + 'jpeg'=>IMG_JPG, + 'png' =>IMG_PNG ); + + if ( !isset($formats[$ext]) ) + return 0; + + if ( $types & $formats[$ext] ) + return $formats[$ext]; + + return 0; + } + + + + function imageExt() + { + switch( $this->imageFormat() ) + { + case IMG_GIF: + return 'GIF'; + case IMG_JPG: + return 'JPEG'; + case IMG_PNG: + return 'PNG'; + } + } + + + + function imageFormats() + { + if ( ! function_exists( 'imagetypes' ) ) + return array(); + + $types = imagetypes(); + $formats = array( IMG_GIF => 'gif', + IMG_JPG => 'jpeg', + IMG_PNG => 'png' ); + $formats2 = $formats; + + foreach( $formats as $b=>$f ) + if ( !($types & $b) ) + unset( $formats2[$b] ); + + return $formats2; + } + + + /** + * Bildgroesse eines Bildes aendern + */ + function resize() + { + $width = intval($this->getRequestVar('width' )); + $height = intval($this->getRequestVar('height' )); + $jpegcompression = $this->getRequestVar('jpeg_compression') ; + $format = $this->getRequestVar('format' ) ; + $factor = $this->getRequestVar('factor' ) ; + + if ( $this->getRequestVar('type') == 'input' && + ! $this->hasRequestVar('width' ) && + ! $this->hasRequestVar('height') ) + { + $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' ); + $this->addValidationError('height',''); + $this->callSubAction('size'); + return; + } + + if ( $this->hasRequestVar('copy') ) + { + // Datei neu anlegen. + $imageFile = new File($this->file->objectid); + $imageFile->load(); + $imageFile->name = lang('copy_of').' '.$imageFile->name; + $imageFile->desription = lang('copy_of').' '.$imageFile->description; + $imageFile->filename = $imageFile->filename.'_resized_'.time(); + $imageFile->add(); + $imageFile->copyValueFromFile( $this->file->objectid ); + } + else + { + $imageFile = $this->file; + } + + if ( $this->getRequestVar('type') == 'factor') + { + $width = 0; + $height = 0; + } + else + { + $factor = 1; + } + + $imageFile->write(); + + $imageFile->imageResize( intval($width),intval($height),$factor,$this->imageFormat(),$format,$jpegcompression ); + $imageFile->setTimestamp(); + $imageFile->save(); // Um z.B. Groesse abzuspeichern + $imageFile->saveValue(); + + $this->addNotice($imageFile->getType(),$imageFile->name,'IMAGE_RESIZED','ok'); + } + + + function prop() + { + + global $conf; + + if ( $this->file->filename == $this->file->objectid ) + $this->file->filename = ''; + + // Eigenschaften der Datei uebertragen + $this->setTemplateVars( $this->file->getProperties() ); + + $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' ); + $this->setTemplateVar('full_filename',$this->file->full_filename()); + + if ( is_file($this->file->tmpfile())) + { + $this->setTemplateVar('cache_filename' ,$this->file->tmpfile()); + $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile())); + } + + // Alle Seiten mit dieser Datei ermitteln + $pages = $this->file->getDependentObjectIds(); + + $list = array(); + foreach( $pages as $id ) + { + $o = new Object( $id ); + $o->load(); + $list[$id] = array(); + $list[$id]['url' ] = Html::url('main','page',$id); + $list[$id]['name'] = $o->name; + } + asort( $list ); + $this->setTemplateVar('pages',$list); + $this->setTemplateVar('edit_filename',$conf['filename']['edit']); + } + + + /** + * Anzeigen des Inhaltes + */ + function edit() + { + global $conf; + // MIME-Types aus Datei lesen + $this->setTemplateVars( $this->file->getProperties() ); + } + + + /** + * Anzeigen des Inhaltes + */ + function upload() + { + } + + + /** + * Anzeigen des Inhaltes + */ + function editvalue() + { + global $conf; + // MIME-Types aus Datei lesen + $this->setTemplateVars( $this->file->getProperties() ); + $this->setTemplateVar('value',$this->file->loadValue()); + } + + + /** + * Anzeigen des Inhaltes + */ + function size() + { + $this->setTemplateVars( $this->file->getProperties() ); + + $format = $this->imageFormat(); + + if ( $format == 0 ) + { + $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN); + } + + $formats = $this->imageFormats(); + + if ( empty($formats) ) + $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN); + + $sizes = array(); + foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s ) + $sizes[strval($s/100)] = $s.'%'; + + $jpeglist = array(); + for ($i=10; $i<=95; $i+=5) + $jpeglist[$i]=$i.'%'; + + $this->setTemplateVar('factors' ,$sizes ); + $this->setTemplateVar('jpeglist' ,$jpeglist ); + $this->setTemplateVar('formats' ,$formats ); + $this->setTemplateVar('format' ,$format ); + $this->setTemplateVar('factor' ,1 ); + + $this->file->getImageSize(); + $this->setTemplateVar('width' ,$this->file->width ); + $this->setTemplateVar('height',$this->file->height ); + $this->setTemplateVar('type' ,'input' ); + } + + + /** + * Anzeigen des Inhaltes + */ + function extractView() + { + $this->setTemplateVars( $this->file->getProperties() ); + + $imageFormat = $this->imageFormat(); + } + + + /** + * Anzeigen des Inhaltes + */ + function uncompressView() + { + } + + + /** + * Anzeigen des Inhaltes + */ + function uncompressAction() + { + switch( $this->file->extension ) + { + case 'gz': + if ( $this->getRequestVar('replace') ) + { + if ( strcmp(substr($this->file->loadValue(),0,2),"\x1f\x8b")) + { + Http::serverError("Not GZIP format (See RFC 1952)"); + } + $method = ord(substr($this->file->loadValue(),2,1)); + if ( $method != 8 ) + { + Http::serverError("Unknown GZIP method: $method"); + } + $this->file->value = gzinflate( substr($this->file->loadValue(),10)); + $this->file->parse_filename( $this->file->filename ); + $this->file->save(); + $this->file->saveValue(); + } + else + { + $newFile = new File(); + $newFile->name = $this->file->name; + $newFile->parentid = $this->file->parentid; + $newFile->value = gzinflate( substr($this->file->loadValue(),10)); + $newFile->parse_filename( $this->file->filename ); + $newFile->add(); + } + + break; + + case 'bz2': + if ( $this->getRequestVar('replace') ) + { + $this->file->value = bzdecompress($this->file->loadValue()); + $this->file->parse_filename( $this->file->filename ); + $this->file->save(); + $this->file->saveValue(); + } + else + { + $newFile = new File(); + $newFile->name = $this->file->name; + $newFile->parentid = $this->file->parentid; + $newFile->value = bzdecompress( $this->file->loadValue() ); + $newFile->parse_filename( $this->file->filename ); + $newFile->add(); + } + + break; + + default: + die( 'cannot uncompress file with extension: '.$this->file->extension ); + } + + $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK); + $this->callSubAction('edit'); + } + + + + /** + * Anzeigen des Inhaltes + */ + function extractAction() + { + switch( $this->file->extension ) + { + case 'tar': + $folder = new Folder(); + $folder->parentid = $this->file->parentid; + $folder->name = $this->file->name; + $folder->filename = $this->file->filename; + $folder->add(); + + $tar = new ArchiveTar(); + $tar->openTAR( $this->file->loadValue() ); + + foreach( $tar->files as $file ) + { + $newFile = new File(); + $newFile->name = $file['name']; + $newFile->parentid = $folder->objectid; + $newFile->value = $file['file']; + $newFile->parse_filename( $file['name'] ); + $newFile->lastchangeDate = $file['time']; + $newFile->add(); + + $this->addNotice('file',$newFile->name,'ADDED'); + } + + unset($tar); + + break; + + case 'zip': + + $folder = new Folder(); + $folder->parentid = $this->file->parentid; + $folder->name = $this->file->name; + $folder->filename = $this->file->filename; + $folder->description = $this->file->fullFilename; + $folder->add(); + + $zip = new ArchiveUnzip(); + $zip->open( $this->file->loadValue() ); + + $lista = $zip->getList(); + + if(sizeof($lista)) foreach($lista as $fileName=>$trash){ + + + $newFile = new File(); + $newFile->name = basename($fileName); + $newFile->description = 'Extracted: '.$this->file->fullFilename.' -> '.$fileName; + $newFile->parentid = $folder->objectid; + $newFile->parse_filename( basename($fileName) ); + + $newFile->value = $zip->unzip($fileName); + $newFile->add(); + + $this->addNotice('file',$newFile->name,'ADDED'); + unset($newFile); + } + + $zip->close(); + unset($zip); + + break; + + default: + die( 'cannot extract file with extension: '.$this->file->extension ); + } + $this->callSubAction('edit'); + } + + + + /** + * Anzeigen des Inhaltes + */ + function compressView() + { + $formats = array(); + foreach( $this->getCompressionTypes() as $t ) + $formats[$t] = lang('compression_'.$t); + + $this->setTemplateVar('formats' ,$formats ); + } + + + + /** + * Anzeigen des Inhaltes + */ + function compressAction() + { + $format = $this->getRequestVar('format',OR_FILTER_ALPHANUM); + + switch( $format ) + { + case 'gz': + if ( $this->getRequestVar('replace',OR_FILTER_NUMBER)=='1' ) + { + $this->file->value = gzencode( $this->file->loadValue(),1 ); + $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP ); + $this->file->save(); + $this->file->saveValue(); + + } + else + { + $newFile = new File(); + $newFile->name = $this->file->name; + $newFile->parentid = $this->file->parentid; + $newFile->value = gzencode( $this->file->loadValue(),1 ); + $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP ); + $newFile->add(); + } + + break; + + case 'bzip2': + if ( $this->getRequestVar('replace')=='1' ) + { + $this->file->value = bzcompress( $this->file->loadValue() ); + $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' ); + $this->file->save(); + $this->file->saveValue(); + + } + else + { + $newFile = new File(); + $newFile->name = $this->file->name; + $newFile->parentid = $this->file->parentid; + $newFile->value = bzcompress( $this->file->loadValue() ); + $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' ); + $newFile->add(); + } + + break; + default: + die( 'unknown compress type: '.$format ); + } + + $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK); + $this->callSubAction('edit'); + } + + + /** + * Datei veroeffentlichen + */ + function pubView() + { + } + + + /** + * Datei veroeffentlichen + */ + function pubAction() + { + $this->file->publish(); + $this->file->publish->close(); + + $this->addNotice('file',$this->file->fullFilename,'PUBLISHED'.($this->file->publish->ok?'':'_ERROR'),$this->file->publish->ok,array(),$this->file->publish->log); + } + + + + function getCompressionTypes() + { + $compressionTypes = array(); + if ( function_exists('gzencode' ) ) $compressionTypes[] = 'gz'; + //if ( function_exists('gzencode' ) ) $compressionTypes[] = 'zip'; + if ( function_exists('bzipcompress') ) $compressionTypes[] = 'bz2'; + return $compressionTypes; + } + + function getArchiveTypes() + { + $archiveTypes = array(); + $archiveTypes[] = 'tar'; + $archiveTypes[] = 'zip'; + return $archiveTypes; + } + + + + 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; + } + } +} + +?>+ \ No newline at end of file diff --git a/action/FileAction.ini.php b/action/FileAction.ini.php @@ -0,0 +1,89 @@ + +[default] +goto=show + +[show] +menu=edit + +[preview] +direct=true + +[edit] +menu=edit + +[replace] +menu=edit +goto=edit + +[editvalue] +menu=edit +target=savevalue + +[savevalue] +goto=show + +[prop] +menu=prop +target=saveprop +editable=true + +[saveprop] +goto=prop + +[size] +menu=prop +target=resize +editable=true + +[remove] +menu=prop +target=delete + +[delete] +goto=prop + +[resize] +goto=prop + +[pub] +write=true +menu=pub + +; Die Aktionen "rights", "aclform", "addacl" und "delacl" sind +; f�r Seiten,Ordner,Links und Dateien identisch. +[rights] +menu=rights +action=object +editable=true + +[aclform] +menu=rights +target=addacl +action=object + +[addacl] +goto=rights + +[delacl] +goto=rights + + +[compress] +menu=edit +write=true + +[uncompress] +menu=edit +write=true + +[extract] +menu=edit +write=true + +[menu] +actions=show,edit,editvalue,compress,uncompress,extract,pub,prop,size,rights,aclform +edit=show,edit,editvalue,compress,uncompress,extract,pub,prop,size,rights,aclform +prop=show,edit,editvalue,compress,uncompress,extract,pub,prop,size,rights,aclform +rights=show,edit,editvalue,compress,uncompress,extract,pub,prop,size,rights,aclform +pub=show,edit,editvalue,compress,uncompress,extract,pub,prop,size,rights,aclform +menu=show,edit,editvalue,compress,uncompress,extract,pub,prop,rights+ \ No newline at end of file diff --git a/action/FilebrowserAction.class.php b/action/FilebrowserAction.class.php @@ -0,0 +1,252 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse zum Bearbeiten einer Datei + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class FilebrowserAction extends ObjectAction +{ + var $command; + var $resourceType; + + /** + * Ordner + * + * @var String + */ + var $currentFolder; + + /** + * Aktueller Ordner + * + * @var Object + */ + var $folder; + + /** + * Konstruktor + */ + function FilebrowserAction() + { + if ( $this->getRequestId() != 0 ) + { + $fid = $this->getRequestId(); + } + else + { + $project = Session::getProject(); + $fid = $project->getRootObjectId(); + } + + $this->folder = new Folder( $fid ); + $this->folder->load(); + + + } + + + + /** + * + */ + function show() + { + Http::notAuthorized('no subaction found'); + } + + + /** + * Datei-Upload. + * + */ + function directupload() + { + $upload = new Upload( $this->getRequestVar('name','abc') ); + + if ( !$upload->isValid() ) + { + echo 'Upload failed, reason: '.$upload->error; + } + else + { + $file = new File(); + $file->parentid = $this->folder->objectid; + $file->name = $upload->filename; + $file->filename = $upload->filename; + $file->extension = $upload->extension; + $file->value = $upload->value; + $file->add(); + + $newId = $file->objectid; + $newUrl = str_replace('&amp;','&',Html::url('file','show',$newId,array('oid'=>'__OID__'.$newId.'__'))); + + echo '<script type="text/javascript">' ; + echo 'window.parent.CKEDITOR.tools.callFunction('.$this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER).",'".$newUrl."','');</script>"; + echo '</script>' ; + echo 'OK' ; + } + + } + + + function browse() + { + global $conf_php; + $funcNum = $this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER); + + if ( ! $this->folder->isRoot ) + $this->setTemplateVar('up_url',Html::url('filebrowser','browse',$this->folder->parentid,array('CKEditorFuncNum'=>$funcNum))); + + $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) ); + + $list = array(); + + // Schleife ueber alle Objekte in diesem Ordner + foreach( $this->folder->getObjects() as $o ) + { + $id = $o->objectid; + + if ( $o->hasRight(ACL_READ) ) + { + $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); + $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); + $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); + if ( $list[$id]['desc'] == '' ) + $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id; + + $list[$id]['type'] = $o->getType(); + + $list[$id]['icon' ] = $o->getType(); + $list[$id]['class'] = $o->getType(); + if ( $o->isFolder ) + $list[$id]['url' ] = Html::url('filebrowser','browse',$id,array('CKEditorFuncNum'=>$funcNum) ); + else + $list[$id]['url' ] = "javascript:window.top.opener.CKEDITOR.tools.callFunction($funcNum,'".Html::url('file','show',$id,array('oid'=>'__OID__'.$id.'__'))."','');window.top.close();window.top.opener.focus();"; + + + + if ( $o->getType() == 'file' ) + { + $file = new File( $id ); + $file->load(); + $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB'; + + if ( $file->isImage() ) + { + $list[$id]['icon' ] = 'image'; + $list[$id]['class'] = 'image'; + //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige + } +// if ( substr($file->mimeType(),0,5) == 'text/' ) +// $list[$id]['icon'] = 'text'; + } + + $list[$id]['date'] = $o->lastchangeDate; + $list[$id]['user'] = $o->lastchangeUser; + } + } + + $this->setTemplateVar('object' ,$list ); + $this->setTemplateVar('CKEditorFuncNum',$funcNum ); + $this->setTemplateVar('token',token() ); + $this->setTemplateVar('id',$this->folder->objectid ); + } + + + function addfolder() + { + + $filename = $this->getRequestVar('name'); + + if ( empty($filename) ) + { + $this->addNotice('folder',$this->name,'ADDED',OR_NOTICE_ERROR); + } + elseif( !$this->folder->hasRight(ACL_CREATE_FOLDER) ) + { + $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR); + } + elseif( $this->folder->hasFilename( $filename ) ) + { + $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR); + + } + else + { + $newFolder = new Folder(); + $newFolder->parentid = $this->folder->objectid; + $newFolder->filename = $filename; + $newFolder->name = $filename; + $newFolder->add(); + + $this->addNotice('folder',$this->folder->name,'ADDED',OR_NOTICE_OK); + } + } + + + + function upload() + { + if ( $this->hasRequestVar('name') ) + $name = $this->getRequestVar('name','abc'); + else + $name = 'file'; + + $upload = new Upload($name); + + if ( !$upload->isValid() ) + { + Html::debug($upload); + $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error); + return; + } + // Pr�fen der maximal erlaubten Dateigr��e. + elseif ( $upload->size < 0 ) + { + // Maximale Dateigr��e ist �berschritten + $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED'); + return; + } + elseif( $upload->size > 0 ) + { + $file = new File(); + $file->desc = ''; + $file->filename = $upload->filename; + $file->name = $upload->filename; + $file->extension = $upload->extension; + $file->size = $upload->size; + $file->parentid = $this->folder->objectid; + + $file->value = $upload->value; + + $file->add(); // Datei hinzufuegen + $this->folder->setTimestamp(); + $this->addNotice('file',$file->name,'ADDED','ok'); + } + } +} + +?>+ \ No newline at end of file diff --git a/action/FilebrowserAction.ini.php b/action/FilebrowserAction.ini.php @@ -0,0 +1,18 @@ + +[default] +goto=show + +[directupload] +direct=true + +[browse] +menu=browse + +[upload] +goto=browse + +[addfolder] +goto=browse + +[menu] +browse=browse+ \ No newline at end of file diff --git a/action/FolderAction.class.php b/action/FolderAction.class.php @@ -0,0 +1,1227 @@ +<?php +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse zum Bearbeiten eines Ordners + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class FolderAction extends ObjectAction +{ + var $defaultSubAction = 'show'; + var $folder; + + function FolderAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->folder = new Folder( $this->getRequestId() ); + $this->folder->load(); + Session::setObject( $this->folder ); + } + else + { + $this->folder = Session::getObject(); + } + + // Datum letzte Aenderung an Browser uebertragen + //$this->lastModified( $this->folder->lastchangeDate ); + } + + + + /** + * Neues Objekt anlegen.<br> + * Dies kann ein(e) Verzeichnis, Seite, Verkn�pfung oder Datei sein.<br> + */ + function createnew() + { + global $conf; + $type = $this->getRequestVar('type' ); + + switch( $type ) + { + case 'folder': + $name = $this->getRequestVar('folder_name'); + + if ( !empty($name) ) + { + $f = new Folder(); + $f->name = $name; + $f->parentid = $this->folder->objectid; + $f->add(); + $this->folder->setTimestamp(); + $this->addNotice('folder',$f->name,'ADDED','ok'); + } + else + { + $this->addValidationError('folder_name'); + $this->callSubAction('create'); + } + break; + + case 'file': + $upload = new Upload(); + + if ( !$upload->isValid() ) + { + $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error); + $this->callSubAction('createfile'); + return; + } + // Pr�fen der maximal erlaubten Dateigr��e. + elseif ( $upload->size > $this->maxFileSize() ) + { + // Maximale Dateigr��e ist �berschritten + $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED'); + $this->callSubAction('createfile'); + return; + } + elseif( $upload->size > 0 ) + { + $file = new File(); + $file->desc = ''; + $file->filename = $upload->filename; + $file->name = $upload->filename; + $file->extension = $upload->extension; + $file->size = $upload->size; + $file->parentid = $this->folder->objectid; + + $file->value = $upload->value; + + $file->add(); // Datei hinzufuegen + $this->folder->setTimestamp(); + $this->addNotice('file',$file->name,'ADDED','ok'); + } + + break; + + case 'page': + + $name = $this->getRequestVar('page_name'); + if ( !empty($name) ) + { + $page = new Page(); + $page->name = $name; + $page->templateid = $this->getRequestVar('page_templateid'); + $page->parentid = $this->folder->objectid; + $page->add(); + $this->folder->setTimestamp(); + + $this->addNotice('page',$page->name,'ADDED','ok'); + } + else + { + $this->addValidationError('page_name'); + $this->callSubAction('create'); + } + break; + + case 'link': + + $name = $this->getRequestVar('link_name'); + if ( !empty($name) ) + { + $link = new Link(); + $link->name = $name; + $link->parentid = $this->folder->objectid; + + $link->isLinkToObject = false; + $link->url = $name; + + $link->add(); + $this->folder->setTimestamp(); + + $this->addNotice('link',$link->name,'ADDED','ok'); + } + else + { + $this->addValidationError('link_name'); + $this->callSubAction('create'); + } + + break; + + default: + $this->addValidationError('type'); + $this->callSubAction('create'); + + } + + } + + + + function createnewfolder() + { + $type = $this->getRequestVar('type' ); + $name = $this->getRequestVar('name' ); + $filename = $this->getRequestVar('filename' ); + $description = $this->getRequestVar('description'); + + if ( !empty($name) ) + { + $f = new Folder(); + $f->name = $name; + $f->filename = $name; + $f->desc = $description; + $f->parentid = $this->folder->objectid; + + $f->add(); + $this->addNotice('folder',$f->name,'ADDED','ok'); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('createfolder'); + } + + $this->folder->setTimestamp(); + } + + + + function createnewfile() + { + $type = $this->getRequestVar('type' ); + $name = $this->getRequestVar('name' ); + $filename = $this->getRequestVar('filename' ); + $description = $this->getRequestVar('description'); + + $file = new File(); + + if ( $this->hasRequestVar('url') ) + { + $url = $this->getRequestVar('url'); + $http = new Http(); + $http->setUrl( $url ); + + $ok = $http->request(); + + if ( !$ok ) + { + $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error); + $this->callSubAction('createfile'); + return; + } + + $file->desc = $description; + $file->filename = basename($url); + $file->name = !empty($name)?$name:basename($url); + $file->size = strlen($http->body); + $file->value = $http->body; + $file->parentid = $this->folder->objectid; + } + else + { + $upload = new Upload(); + + if ( !$upload->isValid() ) + { + $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error); + $this->callSubAction('createfile'); + return; + } + + $file->desc = $description; + $file->filename = $upload->filename; + $file->name = !empty($name)?$name:$upload->filename; + $file->extension = $upload->extension; + $file->size = $upload->size; + $file->parentid = $this->folder->objectid; + + $file->value = $upload->value; + } + + $file->add(); // Datei hinzufuegen + $this->addNotice('file',$file->name,'ADDED','ok'); + + $this->folder->setTimestamp(); + + $this->setTemplateVar('tree_refresh',true); + } + + + + function createnewlink() + { + $type = $this->getRequestVar('type' ); + $name = $this->getRequestVar('name' ); + $filename = $this->getRequestVar('filename' ); + $description = $this->getRequestVar('description'); + + if ( !empty($name) ) + { + $link = new Link(); + $link->name = $name; + $link->desc = $description; + $link->parentid = $this->folder->objectid; + + $link->isLinkToObject = false; + $link->url = $this->getRequestVar('name'); + + $this->addNotice('link',$link->name,'ADDED','ok'); + + $link->add(); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('createlink'); + return; + } + + $this->folder->setTimestamp(); + } + + + + function createnewpage() + { + $type = $this->getRequestVar('type' ); + $name = $this->getRequestVar('name' ); + $filename = $this->getRequestVar('filename' ); + $description = $this->getRequestVar('description'); + + if ( $this->getRequestVar('name') != '' ) + { + $page = new Page(); + $page->name = $name; + $page->desc = $description; + $page->filename = $filename; + $page->templateid = $this->getRequestVar('templateid'); + $page->parentid = $this->folder->objectid; + + $this->addNotice('page',$page->name,'ADDED','ok'); + $page->add(); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('createpage'); + return; + } + + $this->folder->setTimestamp(); + } + + + + /** + * Abspeichern der Ordner-Eigenschaften. Ist der Schalter "delete" gesetzt, wird + * der Ordner stattdessen gel?scht. + */ + function saveprop() + { + // Ordnereigenschaften speichern + if ( $this->getRequestVar('name') != '' ) + $this->folder->name = $this->getRequestVar('name' ,'full'); + elseif ($this->getRequestVar('filename') != '' ) + $this->folder->name = $this->getRequestVar('filename',OR_FILTER_ALPHANUM); + else + { + $this->addValidationError('name'); + $this->addValidationError('filename'); + $this->callSubAction('prop'); + return; + } + + $this->folder->filename = $this->getRequestVar('filename' ,OR_FILTER_ALPHANUM); + $this->folder->desc = $this->getRequestVar('description','full' ); + $this->folder->save(); + $this->addNotice($this->folder->getType(),$this->folder->name,'PROP_SAVED','ok'); + } + + + /** + * Abspeichern der Ordner-Eigenschaften. Ist der Schalter "delete" gesetzt, wird + * der Ordner stattdessen gel?scht. + */ + function delete() + { + if ( $this->getRequestVar('delete') != '' ) + { + // Ordner l?schen + $this->folder->delete(); + $this->addNotice($this->folder->getType(),$this->folder->name,lang('DELETED'),'ok'); + } + } + + + // Reihenfolge von Objekten aendern + function changesequence() + { + $ids = $this->folder->getObjectIds(); + $seq = 0; + foreach( $ids as $id ) + { + $seq++; // Sequenz um 1 erhoehen + + // Die beiden Ordner vertauschen + if ( $id == $this->getRequestVar('objectid1') ) + $id = $this->getRequestVar('objectid2'); + elseif ( $id == $this->getRequestVar('objectid2') ) + $id = $this->getRequestVar('objectid1'); + + $o = new Object( $id ); + $o->setOrderId( $seq ); + + unset( $o ); // Selfmade Garbage Collection :-) + } + + $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok'); + $this->folder->setTimestamp(); + + // Ordner anzeigen + $this->callSubAction('order'); + + } + + + /** + * Verschieben/Kopieren/Loeschen/Verknuepfen von mehreren Dateien in diesem Ordner. + * + * Es werden alle ausgew�hlten Dateien nochmal angezeigt. + * Abh�ngig von der ausgew�hlten Aktion wird eine weitere Auswahl ben�tigt. + */ + function edit() + { + $type = $this->getRequestVar('type'); // Typ der Aktion, z.B "copy" oder "move" + + switch( $type ) + { + case 'move': + case 'copy': + case 'link': + // Liste von m�glichen Zielordnern anzeigen + + $otherfolder = array(); + foreach( $this->folder->getAllFolders() as $id ) + { + $f = new Folder( $id ); + + // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen + // von Verkn�pfungen vorhanden sein. + // + // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung + // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein. + if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) || + ( ( $type=='move' || $type == 'copy' ) && + ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) ) + // Zielordner hinzuf�gen + $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) ); + } + + // Zielordner-Liste alphabetisch sortieren + asort( $otherfolder ); + + $this->setTemplateVar('folder',$otherfolder); + + break; + + case 'archive': + $this->setTemplateVar('ask_filename',''); + break; + + case 'delete': + $this->setTemplateVar('ask_commit',''); + break; + + default: + $this->addValidationError('type'); + return; + + } // switch + + $ids = $this->folder->getObjectIds(); + $objectList = array(); + + foreach( $ids as $id ) + { + // Nur, wenn Objekt ausgewaehlt wurde + if ( !$this->hasRequestVar('obj'.$id) ) + continue; + + $o = new Object( $id ); + $o->load(); + + // F�r die gew�nschte Aktion m�ssen pro Objekt die entsprechenden Rechte + // vorhanden sein. + if ( $type == 'copy' && $o->hasRight( ACL_READ ) || + $type == 'move' && $o->hasRight( ACL_DELETE ) || + $type == 'link' && $o->hasRight( ACL_READ ) || + $type == 'archive' && $o->hasRight( ACL_READ ) || + $type == 'delete' && $o->hasRight( ACL_DELETE ) ) + $objectList[ $id ] = $o->getProperties(); + } + + $this->setTemplateVar('type' ,$type ); + $this->setTemplateVar('objectlist',$objectList ); + + // Komma-separierte Liste von ausgew�hlten Objekt-Ids erzeugen + $this->setTemplateVar('ids',join(array_keys($objectList),',') ); + } + + + + /** + * Verschieben/Kopieren/Loeschen/Verknuepfen von mehreren Dateien in diesem Ordner + */ + function multiple() + { + $type = $this->getRequestVar('type'); + $ids = explode(',',$this->getRequestVar('ids')); + $targetObjectId = $this->getRequestVar('targetobjectid'); + + if ( $type == 'archive' ) + { + require_once('serviceClasses/ArchiveTar.class.php'); + $tar = new ArchiveTar(); + $tar->files = array(); + + foreach( $ids as $id ) + { + $o = new Object( $id ); + $o->load(); + + if ( $o->isFile ) + { + $file = new File($id); + $file->load(); + + // Datei dem Archiv hinzufügen. + $info = array(); + $info['name'] = $file->filenameWithExtension(); + $info['file'] = $file->loadValue(); + $info['mode'] = 0600; + $info['size'] = $file->size; + $info['time'] = $file->lastchangeDate; + $info['user_id' ] = 1000; + $info['group_id'] = 1000; + $info['user_name' ] = 'nobody'; + $info['group_name'] = 'nobody'; + + $tar->numFiles++; + $tar->files[]= $info; + } + else + { + // Was anderes als Dateien ignorieren. + $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN); + } + + } + + // TAR speichern. + $tarFile = new File(); + $tarFile->name = lang('GLOBAL_ARCHIVE').' '.$this->getRequestVar('filename'); + $tarFile->filename = $this->getRequestVar('filename'); + $tarFile->extension = 'tar'; + $tarFile->parentid = $this->folder->objectid; + + $tar->__generateTAR(); + $tarFile->value = $tar->tar_file; + $tarFile->add(); + } + else + { + foreach( $ids as $id ) + { + $o = new Object( $id ); + $o->load(); + + switch( $type ) + { + case 'move': + if ( $o->isFolder ) + { + $f = new Folder( $id ); + $allsubfolders = $f->getAllSubFolderIds(); + + // Wenn + // - Das Zielverzeichnis sich nicht in einem Unterverzeichnis des zu verschiebenen Ordners liegt + // und + // - Das Zielverzeichnis nicht der zu verschiebene Ordner ist + // dann verschieben + if ( !in_array($targetObjectId,$allsubfolders) && $id != $targetObjectId ) + { + $this->addNotice($o->getType(),$o->name,'MOVED','ok'); + //$o->setParentId( $targetObjectId ); + } + else + { + $this->addNotice($o->getType(),$o->name,'ERROR','error'); + } + } + else + { + $o->setParentId( $targetObjectId ); + $this->addNotice($o->getType(),$o->name,'MOVED','ok'); + } + break; + + case 'copy': + switch( $o->getType() ) + { + case 'folder': + // Ordner zur Zeit nicht kopieren + // Funktion waere zu verwirrend + $this->addNotice($o->getType(),$o->name,'CANNOT_COPY_FOLDER','error'); + break; + + case 'file': + $f = new File( $id ); + $f->load(); + $f->filename = ''; + $f->name = lang('COPY_OF').' '.$f->name; + $f->parentid = $targetObjectId; + $f->add(); + $f->copyValueFromFile( $id ); + $this->addNotice($o->getType(),$o->name,'COPIED','ok'); + break; + + case 'page': + $p = new Page( $id ); + $p->load(); + $p->filename = ''; + $p->name = lang('COPY_OF').' '.$p->name; + $p->parentid = $targetObjectId; + $p->add(); + $p->copyValuesFromPage( $id ); + $this->addNotice($o->getType(),$o->name,'COPIED','ok'); + break; + + case 'link': + $l = new Link( $id ); + $l->load(); + $l->filename = ''; + $l->name = lang('COPY_OF').' '.$l->name; + $l->parentid = $targetObjectId; + $l->add(); + $this->addNotice($o->getType(),$o->name,'COPIED','ok'); + break; + + default: + die('fatal: what type to delete?'); + } + $notices[] = lang('COPIED'); + break; + + case 'link': + + if ( $o->isFile || + $o->isPage ) // Nur Seiten oder Dateien sind verknuepfbar + { + $link = new Link(); + $link->parentid = $targetObjectId; + + $link->linkedObjectId = $id; + $link->isLinkToObject = true; + $link->name = lang('LINK_TO').' '.$o->name; + $link->add(); + $this->addNotice($o->getType(),$o->name,'LINKED','ok'); + } + else + { + $this->addNotice($o->getType(),$o->name,'ERROR','error'); + } + break; + + case 'delete': + + if ( $this->hasRequestVar('commit') ) + { + switch( $o->getType() ) + { + case 'folder': + $f = new Folder( $id ); + $f->deleteAll(); + break; + + case 'file': + $f = new File( $id ); + $f->delete(); + break; + + case 'page': + $p = new Page( $id ); + $p->load(); + $p->delete(); + break; + + case 'link': + $l = new Link( $id ); + $l->delete(); + break; + + default: + Http::serverError('Internal Error while deleting: What type to delete?'); + } + $this->addNotice($o->getType(),$o->name,'DELETED',OR_NOTICE_OK); + } + else + { + $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN); + } + + break; + + default: + $this->addNotice($o->getType(),$o->name,'ERROR','error'); + } + + } + } + + $this->folder->setTimestamp(); + + // Ordner anzeigen + $this->callSubAction('show'); + } + + + // Reihenfolge von Objekten aendern + function reorder() + { + $type = $this->getRequestVar('type'); + + switch( $type ) + { + case 'type': + $ids = $this->folder->getObjectIdsByType(); + break; + + case 'name': + $ids = $this->folder->getObjectIdsByName(); + break; + + case 'lastchange': + $ids = $this->folder->getObjectIdsByLastChange(); + break; + + case 'flip': + $ids = $this->folder->getObjectIds(); + $ids = array_reverse( $ids ); // Reihenfolge drehen + + break; + + default: + Http::sendStatus(400,'Bad request','Unknown reordertype: '.$type ); + } + + // Und jetzt die neu ermittelte Reihenfolge speichern + $seq = 0; + foreach( $ids as $id ) + { + $seq++; // Sequenz um 1 erhoehen + + $o = new Object( $id ); + $o->setOrderId( $seq ); + + unset( $o ); + } + $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok'); + + $this->folder->setTimestamp(); + } + + + function settop() + { + $o = new Object( $this->getRequestVar('objectid1') ); + $o->setOrderId( 1 ); + + $ids = $this->folder->getObjectIds(); + $seq = 1; + + foreach( $ids as $id ) + { + if ( $id != $this->getRequestVar('objectid1') ) + { + $seq++; // Sequenz um 1 erhoehen + + $o = new Object( $id ); + $o->setOrderId( $seq ); + + unset( $o ); // Selfmade Garbage Collection :-) + } + } + + $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok'); + $this->folder->setTimestamp(); + + // Ordner anzeigen + $this->callSubAction('order'); + } + + + function setbottom() + { + $ids = $this->folder->getObjectIds(); + $seq = 0; + + foreach( $ids as $id ) + { + if ( $id != $this->getRequestVar('objectid1') ) + { + $seq++; // Sequenz um 1 erhoehen + + $o = new Object( $id ); + $o->setOrderId( $seq ); + + unset( $o ); // Selfmade Garbage Collection :-) + } + } + + $seq++; // Sequenz um 1 erhoehen + $o = new Object( $this->getRequestVar('objectid1') ); + $o->setOrderId( $seq ); + + $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok'); + $this->folder->setTimestamp(); + + // Ordner anzeigen + $this->callSubAction('order'); + + } + + + function create() + { + // Maximale Dateigroesse. + $maxSizeBytes = $this->maxFileSize(); + $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' ); + $this->setTemplateVar('maxlength',$maxSizeBytes ); + + $all_templates = Template::getAll(); + $this->setTemplateVar('templates' ,$all_templates ); + + if ( count($all_templates) == 0 ) + $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN); + + $this->setTemplateVar('objectid' ,$this->folder->objectid ); + } + + + + function createfolder() + { + $this->setTemplateVar('objectid' ,$this->folder->objectid ); + } + + + + /** + * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br> + * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br> + * + * @return Integer maximale Dateigroesse in Bytes + */ + function maxFileSize() + { + global $conf; + + // When querying memory size values: + // Many ini memory size values, such as upload_max_filesize, + // are stored in the php.ini file in shorthand notation. + // ini_get() will return the exact string stored in the php.ini file + // and NOT its integer equivalent. + $sizes = array(10*1024*1024*1024); // Init with 10GB enough? :) + + foreach( array('upload_max_filesize','post_max_size','memory_limit') as $var ) + { + $v = $this->stringToBytes(ini_get($var)); + + if ($v > 0 ) + $sizes[] = $v; + } + + $confMaxSize = intval($conf['content']['file']['max_file_size'])*1024; + if ( $confMaxSize > 0 ) + $sizes[] = $confMaxSize; + + return min($sizes); + } + + + /** + * Hochladen einer Datei. + * + */ + function createfile() + { + // Maximale Dateigroesse. + $maxSizeBytes = $this->maxFileSize(); + $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' ); + $this->setTemplateVar('maxlength',$maxSizeBytes ); + + $this->setTemplateVar('objectid',$this->folder->objectid ); + } + + + /** + * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie + * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br> + * <br> + * Quelle: http://de.php.net/manual/de/function.ini-get.php + * + * @param String Abgek�rzter Bytewert + * @return Integer Byteanzahl + */ + function stringToBytes($val) + { + $val = trim($val); + $last = strtolower($val{strlen($val)-1}); + // Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden! + switch($last) + { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return intval($val); + } + + + + function createlink() + { + $this->setTemplateVar('objectid' ,$this->folder->objectid ); + } + + + function createpage() + { + $all_templates = Template::getAll(); + $this->setTemplateVar('templates' ,$all_templates ); + $this->setTemplateVar('objectid' ,$this->folder->objectid ); + + if ( count($all_templates) == 0 ) + $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN); + } + + + /** + * Anzeige aller Objekte in diesem Ordner. + * @return unknown_type + */ + function show() + { + global $conf_php; + + if ( ! $this->folder->isRoot ) + $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid)); + + $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) ); + + $list = array(); + + // Schleife ueber alle Objekte in diesem Ordner + foreach( $this->folder->getObjects() as $o ) + { + $id = $o->objectid; + + if ( $o->hasRight(ACL_READ) ) + { + $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); + $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); + $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); + if ( $list[$id]['desc'] == '' ) + $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id; + + $list[$id]['type'] = $o->getType(); + + $list[$id]['icon' ] = $o->getType(); + $list[$id]['class'] = $o->getType(); + $list[$id]['url' ] = Html::url($o->getType(),'',$id); + + if ( $o->getType() == 'file' ) + { + $file = new File( $id ); + $file->load(); + $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB'; + + if ( $file->isImage() ) + { + $list[$id]['icon' ] = 'image'; + $list[$id]['class'] = 'image'; + //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige + } +// if ( substr($file->mimeType(),0,5) == 'text/' ) +// $list[$id]['icon'] = 'text'; + } + + $list[$id]['date'] = $o->lastchangeDate; + $list[$id]['user'] = $o->lastchangeUser; + } + } + + $this->setTemplateVar('object' ,$list ); + } + + + function select() + { + global $conf_php; + + $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) ); + + $list = array(); + + // Schleife ueber alle Objekte in diesem Ordner + foreach( $this->folder->getObjects() as $o ) + { + $id = $o->objectid; + + if ( $o->hasRight(ACL_READ) ) + { + $list[$id]['id'] = 'obj'.$id; + $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); + $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); + $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); + if ( $list[$id]['desc'] == '' ) + $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc']; + + $list[$id]['type'] = $o->getType(); + + $list[$id]['icon'] = $o->getType(); + + if ( $o->getType() == 'file' ) + { + $file = new File( $id ); + $file->load(); + $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB'; + + if ( substr($file->mimeType(),0,6) == 'image/' ) + $list[$id]['icon'] = 'image'; +// if ( substr($file->mimeType(),0,5) == 'text/' ) +// $list[$id]['icon'] = 'text'; + } + + $list[$id]['url' ] = Html::url($o->getType(),'',$id); + $list[$id]['date'] = date( lang('DATE_FORMAT'),$o->lastchangeDate ); + $list[$id]['user'] = $o->lastchangeUser; + + if ( $this->hasRequestVar("markall") || $this->hasRequestVar('obj'.$id) ) + $this->setTemplateVar('obj'.$id,'1'); + } + } + + if ( $this->folder->hasRight(ACL_WRITE) ) + { + // Alle anderen Ordner ermitteln + $otherfolder = array(); + foreach( $this->folder->getAllFolders() as $id ) + { + $f = new Folder( $id ); + if ( $f->hasRight( ACL_WRITE ) ) + $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) ); + } + asort( $otherfolder ); + + $this->setTemplateVar('folder',$otherfolder); + + // URLs zum Umsortieren der Eintraege + $this->setTemplateVar('order_url' ,Html::url('folder','order',$this->folder->id) ); + } + + $actionList = array(); + $actionList[] = 'copy'; + $actionList[] = 'link'; + $actionList[] = 'archive'; + + if ( $this->folder->hasRight(ACL_WRITE) ) + { + $actionList[] = 'move'; + $actionList[] = 'delete'; + } + + $this->setTemplateVar('actionlist',$actionList ); + $this->setTemplateVar('defaulttype',$this->getRequestVar('type','alpha')); + + $this->setTemplateVar('object' ,$list ); + $this->setTemplateVar('act_objectid',$this->folder->id); + } + + + + + + + function order() + { + global $conf_php; + + $list = array(); + $last_objectid = 0; + + // Schleife ueber alle Objekte in diesem Ordner + foreach( $this->folder->getObjects() as $o ) + { + $id = $o->objectid; + + if ( $o->hasRight(ACL_READ) ) + { + $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); + $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); + $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); + if ( $list[$id]['desc'] == '' ) + $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc']; + + $list[$id]['type'] = $o->getType(); + + $list[$id]['icon'] = $o->getType(); + + if ( $o->getType() == 'file' ) + { + $file = new File( $id ); + $file->load(); + $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB'; + + if ( $file->isImage() ) + $list[$id]['icon'] = 'image'; + } + + $list[$id]['url' ] = Html::url($o->getType(),'',$id); + $list[$id]['date'] = $o->lastchangeDate; + $list[$id]['user'] = $o->lastchangeUser; + + if ( $last_objectid != 0 && $o->hasRight(ACL_WRITE) ) + { + $list[$id ]['upurl' ] = Html::url('folder','changesequence',0,array( + 'objectid1'=>$id, + 'objectid2'=>$last_objectid)); + $list[$last_objectid]['downurl' ] = $list[$id]['upurl']; + $list[$last_objectid]['bottomurl'] = Html::url('folder','setbottom',0,array( + 'objectid1'=>$last_objectid)); + $list[$id ]['topurl' ] = Html::url('folder','settop',0,array( + 'objectid1'=>$id)); + } + + $last_objectid = $id; + } + } + + $this->setTemplateVar('flip_url' ,Html::url('folder','reorder',0,array('type'=>'flip' )) ); + $this->setTemplateVar('orderbyname_url' ,Html::url('folder','reorder',0,array('type'=>'name' )) ); + $this->setTemplateVar('orderbytype_url' ,Html::url('folder','reorder',0,array('type'=>'type' )) ); + $this->setTemplateVar('orderbylastchange_url',Html::url('folder','reorder',0,array('type'=>'lastchange')) ); + $this->setTemplateVar('object' ,$list ); + $this->setTemplateVar('act_objectid',$this->folder->id); + } + + + + function prop() + { + $this->setTemplateVars( $this->folder->getProperties() ); + $this->setTemplateVar( 'full_filename',$this->folder->full_filename() ); + } + + + function remove() + { + $this->setTemplateVars( $this->folder->getProperties() ); + } + + + function pubView() + { + // Schalter nur anzeigen, wenn sinnvoll + $this->setTemplateVar('files' ,count($this->folder->getFiles()) > 0 ); + $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 ); + $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 ); + + //$this->setTemplateVar('clean' ,$this->folder->isRoot ); + // Gefaehrliche Option, da dies bestehende Dateien, die evtl. nicht zum CMS gehören, überschreibt. + // Daher deaktiviert. + $this->setTemplateVar('clean' ,false ); + } + + + function pubAction() + { + if ( !$this->folder->hasRight( ACL_PUBLISH ) ) + die('no rights for publish'); + + $subdirs = ( $this->hasRequestVar('subdirs') ); + $pages = ( $this->hasRequestVar('pages' ) ); + $files = ( $this->hasRequestVar('files' ) ); + + $publish = new Publish(); + + $this->folder->publish = &$publish; + $this->folder->publish( $pages,$files,$subdirs ); + $this->folder->publish->close(); + + $list = array(); + foreach( $publish->publishedObjects as $o ) + $list[] = $o['full_filename']; + + if ( !$publish->ok ) + $this->addNotice('folder',$this->folder->name,'PUBLISHED_ERROR',OR_NOTICE_ERROR,array(),$publish->log); + else + $this->addNotice('folder',$this->folder->name,'PUBLISHED',OR_NOTICE_OK,array(),$list); + + // Wenn gewuenscht, das Zielverzeichnis aufraeumen + if ( $this->hasRequestVar('clean') ) + $publish->clean(); + } + + + + function checkMenu( $name ) + { + switch( $name) + { + case 'createfolder': + return !readonly() && $this->folder->hasRight(ACL_CREATE_FOLDER); + + case 'createfile': + return !readonly() && $this->folder->hasRight(ACL_CREATE_FILE); + + case 'createlink': + return !readonly() && $this->folder->hasRight(ACL_CREATE_LINK); + + case 'createpage': + return !readonly() && $this->folder->hasRight(ACL_CREATE_PAGE); + + case 'remove': + return !readonly() && count($this->folder->getObjectIds()) == 0; + + case 'select': + case 'order': + case 'aclform': + return !readonly(); + + default: + return true; + } + } +}+ \ No newline at end of file diff --git a/action/FolderAction.ini.php b/action/FolderAction.ini.php @@ -0,0 +1,123 @@ + +[default] +goto=show + +[show] +menu=show + +[select] +target=multiple +menu=show + +[edit] +menu=show + +[multiple] +goto=show + +[prop] +menu=prop +target=saveprop +editable=true + +[saveprop] +goto=prop + +[remove] +menu=prop +target=delete + +[delete] +goto=show + +[order] +menu=show + +[reorder] +menu=show +goto=order + +; Die Aktionen "rights", "aclform", "addacl" und "delacl" sind +; f�r Seiten,Ordner,Links und Dateien identisch. +[rights] +menu=rights +editable=true +action=object +target=inherit + +[aclform] +menu=rights +target=addacl +action=object + +[addacl] +goto=rights + +[delacl] +goto=rights + +[inherit] +goto=rights + + +[pub] +menu=pub +write=true + +[create] +target=createnew +menu=new + +[createfolder] +target=createnewfolder +menu=new + +[createlink] +target=createnewlink +menu=new + +[createfile] +target=createnewfile +menu=new + +[createpage] +target=createnewpage +menu=new + +[createnewfolder] +goto=createfolder + +[createnewfile] +goto=createfile + +[createnewpage] +goto=createpage + +[createnewlink] +goto=createlink + +[createnew] +goto=create + +[changesequence] +goto=order + +[settop] +goto=order + +[setbottom] +goto=order + +[menu] +;pub=pub +;show=show,select,order +;new=create,createfolder,createfile,createpage,createlink +;prop=prop +;rights=rights,aclform + +pub=show,select,order,create,pub,prop,rights,aclform +show=show,select,order,create,pub,prop,rights,aclform +new=show,select,order,create,pub,prop,rights,aclform +prop=show,select,order,create,pub,prop,rights,aclform +rights=show,select,order,create,pub,prop,rights,aclform +menu=show,select,order,create,pub,prop,rights diff --git a/action/GroupAction.class.php b/action/GroupAction.class.php @@ -0,0 +1,348 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse zum Bearbeiten einer Benutzergruppe. + * + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class GroupAction extends Action +{ + var $group; + var $defaultSubAction = 'edit'; + + + function GroupAction() + { + if ( !$this->userIsAdmin() ) + die('you are not an admin'); + + if ( $this->getRequestId() != 0 ) + { + $this->group = new Group( $this->getRequestId() ); + $this->group->load(); + $this->setTemplateVar( 'groupid',$this->group->groupid ); + } + } + + + + function removeAction() + { + if ( $this->hasRequestVar('confirm') ) + { + $this->group->delete(); + + $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK); + } + else + { + $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN); + } + } + + + + function removeView() + { + $this->setTemplateVars( $this->group->getProperties() ); + } + + + + function editAction() + { + if ( $this->getRequestVar('name') != '' ) + { + $this->group->name = $this->getRequestVar('name'); + + $this->group->save(); + + $this->addNotice('group',$this->group->name,'SAVED','ok'); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('edit'); + } + } + + + function addView() + { + } + + + function addAction() + { + if ( $this->getRequestVar('name') != '') + { + $this->group = new Group(); + $this->group->name = $this->getRequestVar('name'); + $this->group->add(); + $this->addNotice('group',$this->group->name,'ADDED','ok'); + $this->callSubAction('listing'); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('add'); + } + } + + + function adduser() + { + $this->setTemplateVar('users',$this->group->getOtherUsers()); + } + + + /** + * Benutzer zur Gruppe hinzuf�gen.<br> + * Es kann eine Liste oder eine einzelne Person zur Gruppe hinzugef�gt werden. + */ + function addusertogroup() + { + $userid = $this->getRequestVar('userid'); + + if ( is_array($userid)) + { + // Im Request steht eine Liste von User-Ids. + foreach( $userid as $uid ) + { + $this->group->addUser( $uid ); + } + $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OR_NOTICE_OK,array('count'=>count($userid))); + } + elseif( intval($userid) > 0 ) + { + // Nur 1 Benutzer hinzuf�gen. + $this->group->addUser( intval($userid) ); + $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OK_NOTICE_OK,array('count'=>'1')); + } + else + { + // Es wurde kein Benutzer ausgew�hlt. + $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN); + } + } + + + + /** + * Einen Benutzer aus der Gruppe entfernen. + */ + function deluser() + { + $this->group->delUser( intval($this->getRequestVar('userid')) ); + + $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK); + } + + + + /** + * Liste aller Gruppen. + */ + function listing() + { + $list = array(); + + foreach( Group::getAll() as $id=>$name ) + { + $list[$id] = array(); + $list[$id]['url' ] = Html::url('main','group',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit')); + $list[$id]['name'] = $name; + } + + $this->setTemplateVar('el', $list); + } + + + function editView() + { + $this->setTemplateVars( $this->group->getProperties() ); + } + + + + /** + * Dummy-Funktion. + */ + function memberships() + { + } + + + + /** + * Liste aller Benutzer in dieser Gruppe. + * + */ + function usersView() + { + // Mitgliedschaften ermitteln + // + $userliste = array(); + + $allUsers = User::listAll(); + + $actualGroupUsers = $this->group->getUsers(); + + foreach( $allUsers as $id=>$name ) + { + $hasUser = array_key_exists($id,$actualGroupUsers); + $varName = 'user'.$id; + $userliste[$id] = array('name' => $name, + 'id' => $id, + 'var' => $varName, + 'member' => $hasUser + ); + $this->setTemplateVar($varName,$hasUser); + } + $this->setTemplateVar('memberships',$userliste); + + global $conf; + if ($conf['security']['authorize']['type']=='ldap') + $this->addNotice('group',$this->group->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN); + } + + + function usersAction() + { + $allUsers = User::listAll(); + $groupUsers = $this->group->getUsers(); + + foreach( $allUsers as $id=>$name ) + { + $hasUser = array_key_exists($id,$groupUsers); + + if ( !$hasUser && $this->hasRequestVar('user'.$id) ) + { + $this->group->addUser($id); + $this->addNotice('user',$name,'ADDED'); + } + + if ( $hasUser && !$this->hasRequestVar('user'.$id) ) + { + $this->group->delUser($id); + $this->addNotice('user',$name,'DELETED'); + } + } + } + + + + + + /** + * Anzeigen der Benutzerrechte + */ + function rights() + { + $rights = $this->group->getAllAcls(); + + $projects = array(); + + foreach( $rights as $acl ) + { + if ( !isset($projects[$acl->projectid])) + { + $projects[$acl->projectid] = array(); + $p = new Project($acl->projectid); + $p->load(); + $projects[$acl->projectid]['projectname'] = $p->name; + $projects[$acl->projectid]['rights' ] = array(); + } + + $right = array(); + + if ( $acl->languageid > 0 ) + { + $language = new Language($acl->languageid); + $language->load(); + $right['languagename'] = $language->name; + } + else + { + $right['languagename'] = lang('ALL_LANGUAGES'); + } + + + $o = new Object($acl->objectid); + $o->objectLoad(); + $right['objectname'] = $o->name; + $right['objectid' ] = $o->objectid; + $right['objecttype'] = $o->getType(); + + if ( $acl->groupid > 0 ) + { + $group = new Group($acl->groupid); + $group->load(); + $right['groupname'] = $group->name; + } + else + { + // Berechtigung f�r "alle". + } + + $right['bits'] = $acl->getProperties(); + + $projects[$acl->projectid]['rights'][] = $right; + } + + $this->setTemplateVar('projects' ,$projects ); + + $this->setTemplateVar('show',Acl::getAvailableRights() ); + } + + + + /** + * Men�. + * + * @param String $menu Men�eintrag. + * @return boolean TRUE, wenn Men�eintrag aktiv ist. + */ + function checkMenu( $menu ) + { + switch( $menu ) + { + case 'remove': + case 'add': + return !readonly(); + + case 'users': + return true; + case 'adduser': + // Benutzer k�nnen nur hinzugef�gt werden, wenn noch nicht alle + // in der Gruppe sind. + return !readonly() && count($this->group->getOtherUsers()) > 0; + default: + return true; + } + } +}+ \ No newline at end of file diff --git a/action/GroupAction.ini.php b/action/GroupAction.ini.php @@ -0,0 +1,43 @@ + +admin=true + +[default] +goto=listing + +[add] +menu=listing +write=true + +[listing] +menu=listing + +[remove] +menu=edit +write=true + +[edit] +menu=edit +editable=true +write=true + +[deluser] +goto=users + +[memberships] +goto=users + +[users] +menu=memberships +editable=true +write=true + +[rights] +menu=rights + +[menu] +listing=listing,add +users=users,adduser +edit=edit,remove +memberships=users +rights=rights +menu=listing,add,users,adduser,edit,remove,users,rights+ \ No newline at end of file diff --git a/action/LanguageAction.class.php b/action/LanguageAction.class.php @@ -0,0 +1,286 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.11 2007-05-24 19:47:48 dankert +// Direktes Ausw?hlen von Sprache/Modell in der Projektauswahlliste. +// +// Revision 1.10 2007-05-08 21:16:20 dankert +// Korrektur und Erweiterung von Hinzuf?gen/Bearbeiten von Sprachen. +// +// Revision 1.9 2007/01/21 22:26:45 dankert +// Korreketur beim Hinzuf?gen/Entfernen von Sprachen. +// +// Revision 1.8 2006/01/29 17:18:59 dankert +// Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden +// +// Revision 1.7 2004/12/25 20:50:13 dankert +// Korrektur Sprach-Aenderung +// +// Revision 1.6 2004/12/19 14:55:00 dankert +// Korrektur der Laenderlisten +// +// Revision 1.5 2004/12/13 22:17:51 dankert +// URL-Korrektur +// +// Revision 1.4 2004/11/27 13:06:44 dankert +// Ausgabe von Meldungen +// +// Revision 1.3 2004/11/10 22:37:23 dankert +// Korrektur Auswahl-Url +// +// Revision 1.2 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse f?r die Bearbeitung einer Sprache + * @version $Id$ + * @author $Author$ + * @package openrat.actions + */ +class LanguageAction extends Action +{ + var $defaultSubAction = 'listing'; + + /** + * Zu bearbeitende Sprache, wird im Kontruktor instanziiert + * @type Language + */ + var $language; + var $project; + + + /** + * Konstruktor + */ + function LanguageAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->language = new Language( $this->getRequestId() ); + $this->language->load(); + } + + $this->project = Session::getProject(); + } + + + /** + * Sprache hinzufuegen + */ + function add() + { + global $conf; + $countryList = $conf['countries']; + + foreach( $this->project->getLanguageIds() as $id ) + { + if ( $id == $this->language->languageid ) + continue; + + $l = new Language( $id ); + $l->load(); + + unset( $countryList[$l->isoCode] ); + } + + asort( $countryList ); + $this->setTemplateVar('isocodes' ,$countryList ); + } + + + function addlanguage() + { + global $conf; + $countryList = $conf['countries']; + + // Hinzufuegen einer Sprache + $iso = $this->getRequestVar('isocode'); + $language = new Language(); + $language->projectid = $this->project->projectid; + $language->isoCode = $iso; + $language->name = $countryList[$iso]; + $language->add(); + } + + + /** + * Setzen der Sprache als Standardsprache. + * Diese Sprache wird benutzt beim Ausw?hlen des Projektes sowie + * als Default-Sprache bei mehrsprachigen Webseiten ("content-negotiation") + */ + function setdefault() + { + $this->language->setDefault(); + } + + + + /** + * Anzeigen der L�schbest�tigungs-Maske. + */ + function remove() + { + $this->setTemplateVar('name' ,$this->language->name ); + } + + + /** + * L�schen der Sprache. + */ + function delete() + { + if ( $this->getRequestVar('confirm') == '1' ) + $this->language->delete(); + } + + + /** + * Speichern der Sprache + */ + function save() + { + global $conf; + + if ( $this->hasRequestVar('name') ) + { + $this->language->name = $this->getRequestVar('name' ); + $this->language->isoCode = $this->getRequestVar('isocode'); + } + else + { + $countryList = $conf['countries']; + $iso = $this->getRequestVar('isocode'); + $this->language->name = $countryList[$iso]; + $this->language->isoCode = strtolower( $iso ); + } + + $this->language->save(); + } + + + + function listing() + { + global $conf; + $countryList = $conf['countries']; + + $list = array(); + + $actLanguage = Session::getProjectLanguage(); + $this->setTemplateVar('act_languageid',$actLanguage->languageid); + + foreach( $this->project->getLanguageIds() as $id ) + { + $l = new Language( $id ); + $l->load(); + + unset( $countryList[strtoupper($l->isoCode)] ); + + $list[$id] = array(); + $list[$id]['name' ] = $l->name; + $list[$id]['isocode'] = $l->isoCode; + + if ( $this->userIsAdmin() ) + { + $list[$id]['url' ] = Html::url('main','language',$id, + array(REQ_PARAM_TARGETSUBACTION=>'edit') ); + + if ( ! $l->isDefault ) + $list[$id]['default_url'] = Html::url( 'language','setdefault',$id ); + } + + if ( $actLanguage->languageid != $l->languageid ) + $list[$id]['select_url'] = Html::url( 'index','language',$id ); + } + +// if ( $this->userIsAdmin() ) +// { +// asort($countryList); +// $this->setTemplateVar('isocodes',$countryList); +// } + + $this->setTemplateVar('el',$list); + } + + + + function edit() + { + global $conf; + $countryList = $conf['countries']; + + foreach( $this->project->getLanguageIds() as $id ) + { + if ( $id == $this->language->languageid ) + continue; + + $l = new Language( $id ); + $l->load(); + + unset( $countryList[$l->isoCode] ); + } + + asort( $countryList ); + $this->setTemplateVar('isocodes' ,$countryList ); + $this->setTemplateVar('isocode' ,strtoupper($this->language->isoCode) ); + } + + + + function advanced() + { + $this->setTemplateVar('isocode',$this->language->isoCode); + $this->setTemplateVar('name' ,$this->language->name ); + } + + + + + + 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; + } + } +}+ \ No newline at end of file diff --git a/action/LanguageAction.ini.php b/action/LanguageAction.ini.php @@ -0,0 +1,36 @@ + +[setdefault] +goto=listing + +[listing] +menu=listing + +[edit] +menu=edit +target=save + +[advanced] +menu=edit +target=save + +[add] +menu=listing +target=addlanguage + +[remove] +menu=edit +target=delete + +[delete] +goto=listing + +[save] +goto=listing + +[addlanguage] +goto=listing + +[menu] +listing=listing,add +edit=edit,advanced,remove +menu=listing,add,edit,advanced,remove+ \ No newline at end of file diff --git a/action/LinkAction.class.php b/action/LinkAction.class.php @@ -0,0 +1,202 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.10 2009-03-22 21:49:08 dankert +// Subaction "showprop" entfernt, da in "prop" mit aufgegangen. +// +// Revision 1.9 2006/06/02 19:49:06 dankert +// Bearbeiten von Verkn?pfungen +// +// Revision 1.8 2006/01/29 17:18:58 dankert +// Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden +// +// Revision 1.7 2006/01/23 23:10:45 dankert +// *** empty log message *** +// +// Revision 1.6 2004/12/20 22:04:25 dankert +// kein Lesen der Benutzer +// +// Revision 1.5 2004/12/15 23:23:11 dankert +// Anpassung an Session-Funktionen +// +// Revision 1.4 2004/11/24 21:28:36 dankert +// "Verschieben" entfernt +// +// Revision 1.3 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.2 2004/04/30 20:31:47 dankert +// Berechtigungen anzeigen +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse f?r Verkn?pfungen + * @version $Id$ + * @author $Author$ + * @package openrat.actions + */ +class LinkAction extends ObjectAction +{ + var $link; + var $defaultSubAction = 'prop'; + + /** + * Konstruktor + */ + function LinkAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->link = new Link( $this->getRequestId() ); + $this->link->load(); + Session::setObject( $this->link ); + } + else + { + $this->link = Session::getObject(); + } + } + + + + function remove() + { + $this->setTemplateVars( $this->link->getProperties() ); + } + + + + function delete() + { + if ( $this->hasRequestVar("delete") ) + { + $this->link->delete(); + $this->addNotice('link',$this->link->name,'DELETED'); + } + } + + + + /** + * Abspeichern der Eigenschaften + */ + function saveprop() + { + // Wenn Name gefuellt, dann Datenbank-Update + if ( $this->getRequestVar('name') != '' ) + { + // Eigenschaften speichern + $this->link->name = $this->getRequestVar('name' ,'full'); + $this->link->desc = $this->getRequestVar('description','full'); + + $this->link->save(); + $this->link->setTimestamp(); + Session::setObject( $this->link ); + } + } + + + /** + * Abspeichern der Eigenschaften + */ + function save() + { + if( $this->getRequestVar('type') != '' ) + { + if ( $this->getRequestVar('type') == 'link' ) + { + $this->link->isLinkToObject = true; + $this->link->isLinkToUrl = false; + $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); + } + else + { + $this->link->isLinkToObject = false; + $this->link->isLinkToUrl = true; + $this->link->url = $this->getRequestVar('url'); + } + + $this->link->save(); + $this->link->setTimestamp(); + Session::setObject( $this->link ); + + $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK); + } + else + { + $this->addNotice('link',$this->link->name,'NOT_SAVED',OR_NOTICE_WARN); + } + } + + + function showprop() + { + $this->setTemplateVars( $this->link->getProperties() ); + } + + + + function edit() + { + $this->setTemplateVars( $this->link->getProperties() ); + + // Typ der Verkn?pfung + $this->setTemplateVar('type' ,$this->link->getType() ); + $this->setTemplateVar('targetobjectid',$this->link->linkedObjectId); + $this->setTemplateVar('url' ,$this->link->url ); + + // Alle verlinkbaren Objekte anzeigen + $list = array(); + + foreach( Object::getAllObjectIds() as $oid ) + { + $o = new Object( $oid ); + $o->load(); + + if ( $o->isFile || + $o->isPage ) + { + $folder = new Folder( $o->parentid ); + $folder->linknames = false; + $folder->load(); + $list[$oid] = lang( $o->getType() ).': '; + $list[$oid] .= implode( FILE_SEP,$folder->parentObjectNames( false,true ) ); + $list[$oid] .= FILE_SEP.$o->name; + } + } + asort( $list ); + $this->setTemplateVar('objects',$list); + } + + + + function prop() + { + $this->setTemplateVars( $this->link->getProperties() ); + $this->setTemplateVar('act_linkobjectid',$this->link->linkedObjectId); + } +}+ \ No newline at end of file diff --git a/action/LinkAction.ini.php b/action/LinkAction.ini.php @@ -0,0 +1,43 @@ + +[default] +goto=prop + +[edit] +menu=edit +target=save + +[save] +goto=edit + +[prop] +menu=prop +target=saveprop +editable=true + +[saveprop] +goto=prop + +[delete] +goto=prop + +[rights] +menu=rights +action=object +editable=true + +[aclform] +menu=rights +target=addacl +action=object + +[addacl] +goto=rights + +[delacl] +goto=rights + +[menu] +edit=edit +prop=prop +rights=rights,aclform +menu=edit,prop,rights+ \ No newline at end of file diff --git a/action/LoginAction.class.php b/action/LoginAction.class.php @@ -0,0 +1,1676 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +define('PROJECTID_ADMIN',-1); + +/** + * Action-Klasse fuer die Start-Action + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class LoginAction extends Action +{ + var $mustChangePassword = false; + + function setDb( $dbid ) + { + global $conf; + + if ( !isset($conf['database'][$dbid] )) + Http::serverError( 'unknown DB-Id: '.$dbid ); + + $db = db_connection(); + if ( is_object($db) ) + { + $db->rollback(); + } + + $db = new DB( $conf['database'][$dbid] ); + $db->id = $dbid; + $db->start(); + Session::setDatabase( $db ); + } + + + + function checkForDb() + { + global $conf; + $dbid = $this->getRequestVar('dbid'); + + if ( $dbid != '' ) + $this->setDb( $dbid ); + } + + + + function setDefaultDb() + { + if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) ) + { + $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID); + } + else + { + global $conf; + + if ( !isset($conf['database']['default']) ) + Http::serverError('default-database not set'); + + $dbid = $conf['database']['default']; + } + + $this->setDb( $dbid ); + } + + + + private function checkLogin( $name,$pw,$pw1,$pw2 ) + { + Logger::debug( "login user $name" ); + + global $conf; + global $SESS; + + unset( $SESS['user'] ); + + + $db = db_connection(); + + if ( !is_object($db) || !$db->available ) + { + $this->addNotice('database',$db->conf['comment'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error)); + //$this->callSubAction('showlogin'); + return false; + } + + // Zeichensatz der Datenbank benutzen + if ( isset($db->conf['charset']) ) + $charset = $db->conf['charset']; + else + $charset = 'US-ASCII'; + $this->setCharset($charset); + + + $ip = getenv("REMOTE_ADDR"); + + $user = new User(); + $user->name = $name; + + $ok = $user->checkPassword( $pw ); + + $this->mustChangePassword = $user->mustChangePassword; + + if ( $this->mustChangePassword ) + { + // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen. + // Wir versuchen hier, das neue zu setzen (sofern eingegeben). + if ( empty($pw1) ) + { + } + elseif ( $pw1 != $pw2 ) + { + $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH'); + $this->addValidationError('password2',''); + } + elseif ( strlen($pw2) < $conf['security']['password']['min_length'] ) + { + $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length'])); + $this->addValidationError('password2',''); + } + else + { + // Kennw�rter identisch und lang genug. + $user->setPassword( $pw1,true ); + + // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen. + $ok = true; + $this->mustChangePassword = false; + $user->mustChangePassword = false; + } + } + + // Falls Login erfolgreich + if ( $ok ) + { + // Login war erfolgreich! + $user->load(); + $user->setCurrent(); + Logger::info( 'login successful' ); + + return true; + } + else + { + Logger::info( "login for user $name failed" ); + + return false; + } + } + + + + /** + * Anzeigen der Loginmaske. + * + * Es wird nur die Loginmaske angezeigt. + * Hier nie "304 not modified" setzen, da sonst keine + * Login-Fehlermeldung erscheinen kann + */ + function loginView() + { + global $conf; + $sso = $conf['security']['sso']; + $ssl = $conf['security']['ssl']; + + $ssl_trust = false; + $ssl_user_var = ''; + extract( $ssl, EXTR_PREFIX_ALL, 'ssl' ); + + if ( $sso['enable'] ) + { + $authid = $this->getRequestVar( $sso['auth_param_name']); + + if ( empty( $authid) ) + Http::notAuthorized( 'no authorization data (no auth-id)'); + + if ( $sso['auth_param_serialized'] ) + $authid = unserialize( $authid ); + + $purl = parse_url($sso['url']); + // Verbindung zu URL herstellen. + $errno=0; $errstr=''; + $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30); + if ( !$fp ) + { + echo "Connection failed: $errstr ($errno)"; + } + else + { + $http_get = $purl['path']; + if ( !empty($purl['query']) ) + $http_get .= '?'.$purl['query']; + + $header = array(); + + $header[] = "GET $http_get HTTP/1.0"; + $header[] ="Host: ".$purl['host']; + $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)"; + $header[] = "Connection: Close"; + + if ( $sso['cookie'] ) + { + $cookie = 'Cookie: '; + if ( is_array($authid)) + foreach( $authid as $cookiename=>$cookievalue) + $cookie .= $cookiename.'='.$cookievalue."; "; + else + $cookie .= $sso['cookie_name'].'='.$authid; + + $header[] = $cookie; + } + +// Html::debug($header); + fputs ($fp, implode("\r\n",$header)."\r\n\r\n"); + + $inhalt=array(); + while (!feof($fp)) { + $inhalt[] = fgets($fp,128); + } + fclose($fp); + + $html = implode('',$inhalt); +// Html::debug($html); + if ( !preg_match($sso['expect_regexp'],$html) ) + Http::notAuthorized('auth failed'); + $treffer=0; + if ( !preg_match($sso['username_regexp'],$html,$treffer) ) + Http::notAuthorized('auth failed'); + if ( !isset($treffer[1]) ) + Http::notAuthorized('authorization failed'); + + $username = $treffer[1]; + +// Html::debug( $treffer ); + $this->setDefaultDb(); + + $user = User::loadWithName( $username ); + + if ( ! $user->isValid( )) + Http::notAuthorized('authorization failed: user not found: '.$username); + + $user->setCurrent(); + + $this->callSubAction('show'); + } + } + + elseif ( $ssl_trust ) + { + if ( empty($ssl_user_var) ) + Http::serverError( 'please set environment variable name in ssl-configuration.' ); + + $username = getenv( $ssl_user_var ); + + if ( empty($username) ) + Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' ); + + $this->setDefaultDb(); + + $user = User::loadWithName( $username ); + + if ( !$user->isValid() ) + Http::serverError( 'unknown username: '.$username ); + + $user->setCurrent(); + + $this->callSubAction('show'); + } + + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = array('key' =>$dbname, + 'value'=>Text::maxLength($dbconf['comment']), + 'title'=>$dbconf['comment'].' ('.$dbconf['host'].')' ); + } + + $openid_provider = array(); + foreach( explode(',',$conf['security']['openid']['provider']) as $provider ) + $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name'); + $this->setTemplateVar('openid_providers',$openid_provider); + $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity')); + //$this->setTemplateVar('openid_provider','identity'); + + + if ( empty($dbids) ) + $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN); + + if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) ) + $this->setTemplateVar('login_name',$_COOKIE['or_username']); + + if ( !isset($this->templateVars['login_name']) ) + $this->setTemplateVar('login_name',@$conf['security']['default']['username']); + + if ( $this->templateVars['login_name']== @$conf['security']['default']['username']) + $this->setTemplateVar('login_password',@$conf['security']['default']['password']); + + $this->setTemplateVar( 'dbids',$dbids ); + + $db = Session::getDatabase(); + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + elseif( isset($this->templateVars['actid']) ) + ; + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + + + // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen. + $ssl_user_var = $conf['security']['ssl']['user_var']; + if ( !empty($ssl_user_var) ) + { + $username = getenv( $ssl_user_var ); + + if ( empty($username) ) + { + echo lang('ERROR_LOGIN_BROKEN_SSL_CERT'); + Logger::warn( 'no username in SSL client certificate (var='.$ssl_user_var.').' ); + exit; + } + + // Benutzername ist in Eingabemaske unveränderlich + $this->setTemplateVar('force_username',$username); + } + + $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) ); + + $this->setTemplateVar('register' ,$conf['login' ]['register' ]); + $this->setTemplateVar('send_password',$conf['login' ]['send_password']); + } + + + + /** + * Erzeugt ein Projekt-Auswahlmenue. + */ + function projectmenu() + { + $user = Session::getUser(); + + if ( $user->mustChangePassword ) + { + $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' ); + $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern. + } + + + // Diese Seite gilt pro Sitzung. + $this->lastModified( $user->loginDate ); + + // Projekte ermitteln + $projects = $user->projects; + + $list = array(); + + foreach( $projects as $id=>$name ) + { + $p = array(); + $p['url' ] = Html::url('index','project',$id); + $p['name'] = $name; + $p['id' ] = $id; + + $tmpProject = new Project( $id ); + $p['defaultmodelid' ] = $tmpProject->getDefaultModelId(); + $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId(); + $p['models' ] = $tmpProject->getModels(); + $p['languages' ] = $tmpProject->getLanguages(); + + $list[] = $p; + } + + $this->setTemplateVar('projects',$list); + + if ( empty($list) ) + { + // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben. + if ( $this->userIsAdmin() ) + // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen + $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + else + // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf�gung steht + $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + } + + $this->metaValues(); + } + + + + /** + * Erzeugt eine Anwendungsliste. + */ + function applications() + { + global $conf; + + // Diese Seite gilt pro Sitzung. + $user = Session::getUser(); + $userGroups = $user->getGroups(); + $this->lastModified( $user->loginDate ); + + // Applikationen ermitteln + $list = array(); + foreach( $conf['applications'] as $id=>$app ) + { + if ( !is_array($app) ) + continue; + + if ( isset($app['group']) ) + if ( !in_array($app['group'],$userGroups) ) + continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden. + + $p = array(); + $p['url'] = $app['url']; + $p['description'] = @$app['description']; + if ( isset($app['param']) ) + { + $p['url'] .= strpos($p['url'],'?')!==false?'&':'?'; + $p['url'] .= $app['param'].'='.session_id(); + } + $p['name'] = $app['name']; + + $list[] = $p; + } + + + $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> + * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br> + * Kapitel "4.4. check_authentication"<br> + * <br> + * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br> + * Wir befinden uns nun im darauf folgenden Request des Browsers.<br> + * <br> + * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der + * Benutzer angemeldet.<br> + */ + function openid() + { + global $conf; + $openId = Session::get('openid'); + + if ( !$openId->checkAuthentication() ) + { + $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + //Html::debug($openId); + + // Anmeldung wurde mit "is_valid:true" best�tigt. + // Der Benutzer ist jetzt eingeloggt. + $username = $openId->getUserFromIdentiy(); + + if ( empty($username) ) + { + // Es konnte kein Benutzername ermittelt werden. + $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + $user = User::loadWithName( $username ); + + if ( $user->userid <=0) + { + // Benutzer ist (noch) nicht vorhanden. + if ( $conf['security']['openid']['add']) // Anlegen? + { + $user->name = $username; + $user->add(); + + $user->mail = $openId->info['email']; + $user->fullname = $openId->info['fullname']; + $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht) + } + else + { + // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht). + $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + } + else + { + // Benutzer ist bereits vorhanden. + if ( @$conf['security']['openid']['update_user']) + { + $user->fullname = $openId->info['fullname']; + $user->mail = $openId->info['email']; + $user->save(); + } + } + + $user->setCurrent(); // Benutzer ist jetzt in der Sitzung. + } + + + /** + * Login. + */ + function loginAction() + { + global $conf; + + $this->checkForDb(); + Session::setUser(''); + + if ( $conf['login']['nologin'] ) + Http::notAuthorized('login disabled'); + + $openid_user = $this->getRequestVar('openid_url' ); + $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM); + $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM); + $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM); + $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM); + + // Cookie setzen + setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) ); + + // Login mit Open-Id. + if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) ) + { + $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user); + + if ( ! $openId->login() ) + { + $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + Session::set('openid',$openId); + $openId->redirect(); + die('Unreachable Code'); + } + + + // Ermitteln, ob der Baum angezeigt werden soll + // Ist die Breite zu klein, dann wird der Baum nicht angezeigt + //Session::set('showtree',intval($this->getRequestVar('screenwidth')) > $conf['interface']['min_width'] ); + + $loginOk = $this->checkLogin( $loginName, + $loginPassword, + $newPassword1, + $newPassword2 ); + + if ( !$loginOk ) + { + // Anmeldung nicht erfolgreich + sleep(3); + + if ( $this->mustChangePassword ) + { + // Anmeldung gescheitert, Benutzer muss Kennwort �ndern. + $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' ); + $this->addValidationError('password1',''); + $this->addValidationError('password2',''); + } + else + { + // Anmeldung gescheitert. + $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) ); + $this->addValidationError('login_name' ,''); + $this->addValidationError('login_password',''); + } + + Logger::debug("Login failed for user '$loginName'"); + + //$this->callSubAction('login'); + return; + } + else + { + Logger::debug("Login successful for user '$loginName'"); + + // Anmeldung erfolgreich. + if ( config('security','renew_session_login') ) + $this->recreateSession(); + + $user = Session::getUser(); + $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 ausgew�hlt, dann das zuletzt ge�nderte benutzen. + if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] ) + { + $objectid = Value::getLastChangedObjectByUserId($user->userid); + if ( Object::available($objectid)) + { + $object = new Object($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->refresh(); // Benutzer ist angemeldet: Andere Views könnte das interessieren. + $this->updateView('content','start','projectmenu'); + + } + + + /** + * Benutzer meldet sich ab. + */ + function logoutAction() + { + global $conf; + + $user = Session::getUser(); + 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(); + + session_unset(); + + if ( @$conf['theme']['compiler']['compile_at_logout'] ) + { + foreach( $conf['action'] as $actionName => $actionConfig ) + { + foreach( $actionConfig as $subActionName=>$subaction ) + { + if ( is_array($subaction) && + !isset($subaction['goto' ]) && + !isset($subaction['direct']) && + !isset($subaction['action']) && + !isset($subaction['alias' ]) && + $subActionName != 'menu' ) + { + $engine = new TemplateEngine(); + $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName); + } + } + } + } + + // Umleiten auf eine definierte URL.s + $redirect_url = @$conf['security']['logout']['redirect_url']; + + if ( !empty($redirect_url) ) + { + header('Location: '.$redirect_url); + exit; + } + } + + + + /** + * Benutzer meldet sich ab. + */ + function logoutView() + { + } + + + /** + * 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 + * die Benutzerinformationen des angemeldeten Benutzers aus dieser + * Anwendung auslesen k�nnen. + */ + function userinfo() + { + $user = Session::getUser(); + $info = array('username' => $user->name, + 'fullname' => $user->fullname, + 'mail' => $user->mail, + 'telephone' => $user->tel, + 'style' => $user->style, + 'admin' => $user->isAdmin?'true':'false', + 'ldap' => $user->ldap_dn, + 'groups' => implode(',',$user->getGroups()), + 'description'=> $user->desc + ); + + // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die + // Informationen per XML aus. + if ( $this->hasRequestVar('xml') ) + { + header('Content-Type: text/xml'); + echo '<userinfo>'; + foreach( $info as $n=>$i ) + echo '<'.$n.'>'.$i.'</'.$n.'>'."\n"; + echo '</userinfo>'; + + } + + // Sonst normale Textausgabe im INI-Datei-Format. + else + { + header('Content-Type: text/plain'); + foreach( $info as $n=>$i ) + echo $n.'="'.$i."\"\n"; + } + + exit; // Fertig. + } + + + function project() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) ); + + Session::setUser( $user ); + } + + + function object() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) ); + + Session::setUser( $user ); + } + + + function language() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) ); + } + + + function model() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) ); + + $user = Session::getUser(); + } + + + /** + * Auswerten der Request-Variablen. + * + * @param Array $add + */ + 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 + Http::serverError('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]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) ) + { + $object = new Object( $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]) ) + { + $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 ); + } + + $object = Session::getObject(); + if ( is_object($object) && $object->projectid == $project->projectid ) + { + $object->objectLoadRaw(); + Session::setObject( $object ); + } + else + { + Session::setObject( '' ); + } + } + 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::available($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( '' ); + } + } + } + + + function showtree() + { + Session::set('showtree',true ); + } + + + function hidetree() + { + Session::set('showtree',false ); + } + + + function switchuser() + { + $user = Session::getUser(); + + if ( ! $user->isAdmin ) + Http::notAuthorized(""); + + $this->recreateSession(); + + $newUser = new User( $this->getRequestId() ); + $newUser->load(); + + $newUser->setCurrent(); + } + + + function show() + { + global $conf; + global $PHP_AUTH_USER; + global $PHP_AUTH_PW; + + $user = Session::getUser(); + // Gast-Login + if ( ! is_object($user) ) + { + if ( $conf['security']['guest']['enable'] ) + { + $this->setDefaultDb(); + $username = $conf['security']['guest']['user']; + $user = User::loadWithName($username); + if ( $user->userid > 0 ) + $user->setCurrent(); + else + { + Logger::warn('Guest login failed, user not found: '.$username); + $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) ); + $user = null; + } + } + } + + if ( ! is_object($user) ) + { + switch( $conf['security']['login']['type'] ) + { + + // Authorization ueber HTTP + // + case 'http': + $ok = false; + + if ( isset($_SERVER['PHP_AUTH_USER']) ) + { + $this->setDefaultDb(); + $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] ); + } + + if ( ! $ok ) + { + header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' ); + header( 'HTTP/1.0 401 Unauthorized' ); + echo 'Authorization Required!'; + exit; + } + break; + + case 'form': + // Benutzer ist nicht angemeldet + $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske + return; + break; + + default: + Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' ); + } + } + + if ( $user->mustChangePassword ) + { + $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' ); + $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern. + } + + // 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 Object( $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(); + } + + + + 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. + */ + function register() + { + + } + + + /** + * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen. + * Maske anzeigen, damit Benuter Registriercode anzeigen kann. + */ + function registercode() + { + $email_address = $this->getRequestVar('mail','mail'); + + if ( ! Mail::checkAddress($email_address) ) + { + $this->addValidationError('mail'); + $this->setTemplateVar('mail',$email_address); + $this->callSubAction('register'); + return; + } + + + srand ((double)microtime()*1000003); + $registerCode = rand(); + + Session::set('registerCode',$registerCode ); + + // E-Mail and die eingegebene Adresse verschicken + $mail = new Mail($email_address, + 'register_commit_code','register_commit_code'); + $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable + + if ( $mail->send() ) + { + $this->addNotice('','','mail_sent',OR_NOTICE_OK); + } + else + { + $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); + $this->callSubAction('register'); + return; + } + } + + + + function registeruserdata() + { + global $conf; + + Session::set('registerMail',$this->getRequestVar('mail') ); + // TODO: Attribut "Password" abfragen + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = $dbconf['comment']; + } + + $this->setTemplateVar( 'dbids',$dbids ); + + $db = Session::getDatabase(); + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + } + + + /** + * Benutzerregistierung. + * Benutzer hat Best�tigungscode erhalten und eingegeben. + */ + function registercommit() + { + global $conf; + $this->checkForDb(); + + $origRegisterCode = Session::get('registerCode'); + $inputRegisterCode = $this->getRequestVar('code'); + + if ( $origRegisterCode != $inputRegisterCode ) + { + // Best�tigungscode stimmt nicht. + $this->addValidationError('code','code_not_match'); + $this->callSubAction('registeruserdata'); + return; + } + + // Best�tigungscode stimmt �berein. + // Neuen Benutzer anlegen. + + if ( !$this->hasRequestVar('username') ) + { + $this->addValidationError('username'); + $this->callSubAction('registeruserdata'); + return; + } + + $user = User::loadWithName( $this->getRequestVar('username') ); + if ( $user->isValid() ) + { + $this->addValidationError('username','USER_ALREADY_IN_DATABASE'); + $this->callSubAction('registeruserdata'); + return; + } + + if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] ) + { + $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length'])); + $this->callSubAction('registeruserdata'); + return; + } + + $newUser = new User(); + $newUser->name = $this->getRequestVar('username'); + $newUser->add(); + + $newUser->mail = Session::get('registerMail'); + $newUser->save(); + + $newUser->setPassword( $this->getRequestVar('password'),true ); + + $this->addNotice('user',$newUser->name,'user_added','ok'); + } + + + + /** + * Vergessenes Kennwort zusenden lassen. + */ + function password() + { + global $conf; + + // TODO: Attribut "Password" abfragen + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = $dbconf['comment']; + } + + $this->setTemplateVar( 'dbids',$dbids ); + + + $db = Session::getDatabase(); + + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + + } + + + /* + function changepassword() + { + } + */ + + + /* + function setnewpassword() + { + $oldPw = $this->getRequestVar('password_old' ); + $newPw1 = $this->getRequestVar('password_new_1'); + $newPw2 = $this->getRequestVar('password_new_2'); + + if ( $newPw1 == $newPw2 ) + { + // Aktuellen Benutzer aus der Sitzung ermitteln + $user = $this->getUserFromSession(); + + // Altes Kennwort pr�fen. + $ok = $user->checkPassword( $oldPw ); + + if ( $ok ) // Altes Kennwort ist ok. + { + $user->setPassword( $newPw1 ); // Setze neues Kennwort + $user->mustChangePassword = false; + Session::setUser($user); + $this->addNotice('user',$user->name,'password_set','ok'); + } + else + { + // Altes Kennwort falsch. + $this->addNotice('user',$user->name,'password_error','error'); + } + } + else + { + // Beide neuen Kennw�rter stimmen nicht �berein + $this->addNotice('user',$user->name,'passwords_not_match','error'); + } + } + */ + + + /** + * Einen Kennwort-Anforderungscode an den Benutzer senden. + */ + function passwordcode() + { + if ( !$this->hasRequestVar('username') ) + { + $this->addValidationError('username'); + $this->callSubAction('password'); + return; + } + + $this->checkForDb(); + + $user = User::loadWithName( $this->getRequestVar("username") ); + // Html::debug($user); + if ( $user->isValid() ) + { + srand ((double)microtime()*1000003); + $code = rand(); + $this->setSessionVar("password_commit_code",$code); + + $eMail = new Mail( $user->mail,'password_commit_code' ); + $eMail->setVar('name',$user->getName()); + $eMail->setVar('code',$code); + if ( $eMail->send() ) + $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK); + else + $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error); + + } + else + { + //$this->addNotice('','user','username_not_found'); + // Trotzdem vort�uschen, eine E-Mail zu senden, damit die G�ltigkeit + // eines Benutzernamens nicht von au�en gepr�ft werden kann. + // + $this->addNotice('user',$this->getRequestVar("username"),'mail_sent'); + sleep(5); + } + + $this->setSessionVar("password_commit_name",$user->name); + } + + + + /** + * Anzeige Formular zum Eingeben des Kennwort-Codes. + * + */ + function passwordinputcode() + { + + } + + + /** + * Neues Kennwort erzeugen und dem Benutzer zusenden. + */ + function passwordcommit() + { + $username = $this->getSessionVar("password_commit_name"); + + if ( $this->getRequestVar("code")=='' || + $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") ) + { + $this->addValidationError('code','PASSWORDCODE_NOT_MATCH'); + $this->callSubAction('passwordinputcode'); + return; + } + + $user = User::loadWithName( $username ); + + if ( !$user->isValid() ) + { + // Benutzer konnte nicht geladen werden. + $this->addNotice('user',$username,'error',OR_NOTICE_ERROR); + return; + } + + $newPw = User::createPassword(); // Neues Kennwort erzeugen. + + $eMail = new Mail( $user->mail,'password_new' ); + $eMail->setVar('name' ,$user->getName()); + $eMail->setVar('password',$newPw ); + + if ( $eMail->send() ) + { + $user->setPassword( $newPw, false ); // Kennwort muss beim n�. Login ge�ndert werden. + $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK); + } + else + { + // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den + // Code per E-Mail erhalten hat. + $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error); + } + } + + + /** + * Erzeugt eine neue Sitzung. + */ + function recreateSession() + { + + // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht. + if ( version_compare(phpversion(),"4.3.2","<") ) + { + $randlen = 32; + $randval = "0123456789abcdefghijklmnopqrstuvwxyz"; + $newid = ""; + for ($i = 1; $i <= $randlen; $i++) + { + $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1); + } + session_id( $newid ); + } + elseif( version_compare(phpversion(),"4.3.2","==") ) + { + session_regenerate_id(); + + // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt. + if ( ini_get("session.use_cookies") ) + setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" ); + } + elseif ( version_compare(phpversion(),"5.1.0",">") ) + { + session_regenerate_id(true); + } + else + { + // 5.1.0 > PHP >= 4.3.3 + } + } + +} + + +?>+ \ No newline at end of file diff --git a/action/LoginAction.ini.php b/action/LoginAction.ini.php @@ -0,0 +1,104 @@ + +admin=false + + +[default] +goto=show + +[logout] +guest=true +goto=login +write=get +clear=tree + +[switchuser] +goto=show + +[object] +goto=show +guest=true + +[language] +goto=show + +[model] +goto=show + +[applications] +menu=menu + +[userinfo] +direct=true + +[project] +goto=show + +[register] +menu=login +target=registercode +guest=true + +[registercode] +goto=registeruserdata +guest=true + +[registeruserdata] +menu=login +target=registercommit +guest=true + +[registercommit] +menu=login +goto=showlogin +guest=true + +[password] +menu=login +target=passwordcode +guest=true + +[passwordcode] +guest=true +goto=passwordinputcode + +[passwordinputcode] +menu=login +target=passwordcommit +guest=true + +[passwordcommit] +menu=login +goto=showlogin +guest=true + +[administration] +goto=show + +[login] +menu=login +write=true +guest=true +;goto=projectmenu + +[projectmenu] + +[openid] +guest=true +goto=show + +[projectmenu] +menu=menu + +[changepassword] +menu=menu +target=setnewpassword + +[setnewpassword] +menu=menu +goto=projectmenu + +[show] +guest=true + +[menu] +menu =login diff --git a/action/MainAction.class.php b/action/MainAction.class.php @@ -0,0 +1,97 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.11 2007-12-21 23:21:40 dankert +// Beim Aufruf von "Administration" oder "Projekt" mit leerer Seite starten. +// +// Revision 1.10 2007/01/21 15:35:44 dankert +// Requestparameter-Namen aus Konstanten lesen. +// +// Revision 1.9 2006/02/27 19:17:50 dankert +// Parameter "targetSubAction" auswerten. +// +// Revision 1.8 2006/01/23 23:10:46 dankert +// *** empty log message *** +// +// Revision 1.7 2006/01/11 22:52:24 dankert +// URLs f?r neue Frames setzen +// +// Revision 1.6 2005/01/14 21:41:23 dankert +// Aufruf von lastModified() fuer Conditional-GET +// +// Revision 1.5 2004/12/19 14:55:50 dankert +// Bestimmte Paramer weiterleiten +// +// Revision 1.4 2004/12/15 23:23:47 dankert +// Html::url()-Parameter angepasst +// +// Revision 1.3 2004/11/27 13:07:05 dankert +// *** empty log message *** +// +// Revision 1.2 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse fuer die Darstellung des Unter-Framesets + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class MainAction extends Action +{ + function show() + { + $doActionName = $this->subActionName; + + $user = Session::getUser(); + if ( is_object($user) && isset($user->loginDate) ) + $this->lastModified( $user->loginDate ); + + $doSubActionName = $this->getRequestVar( REQ_PARAM_TARGETSUBACTION ); + + // Bestimmte Parameter weiterleiten + $params = array(); + + foreach( array('elementid') as $p ) + { + if ( $this->getRequestVar( $p ) != '' ) + $params[ $p ] = $this->getRequestVar( $p ); + } + + // Variablen fuellen + $this->setTemplateVar('frame_src_main_menu' ,Html::url( 'mainmenu' ,$doActionName ,$this->getRequestId(),$params ) ); + $this->setTemplateVar('frame_src_main_main' ,Html::url( $doActionName,$doSubActionName,$this->getRequestId(),$params ) ); + $this->setTemplateVar('frame_src_border' ,Html::url( 'border' ) ); + $this->setTemplateVar('frame_src_background',Html::url( 'background' ) ); + } + +} + + +?>+ \ No newline at end of file diff --git a/action/MainAction.ini.php b/action/MainAction.ini.php @@ -0,0 +1,47 @@ + +[element] +alias=show + +[file] +alias=show + +[empty] +alias=show + +[folder] +alias=show + +[group] +alias=show + +[language] +alias=show + +[link] +alias=show + +[model] +alias=show + +[page] +alias=show + +[pageelement] +alias=show + +[project] +alias=show + +[search] +alias=show + +[show] + +[template] +alias=show + +[transfer] +alias=show + +[user] +alias=show diff --git a/action/MainmenuAction.class.php b/action/MainmenuAction.class.php @@ -0,0 +1,557 @@ +<?php +// OpenRat Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse fuer die Darstellung des Untermenues. + * + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class MainmenuAction extends Action +{ + var $subActionList = array(); + var $path = array(); + var $search = false; + var $obj; + + + function MainmenuAction() + { + $this->setTemplateVar('type',$this->getRequestVar(REQ_PARAM_SUBACTION) ); + + + switch( $this->getRequestVar( REQ_PARAM_SUBACTION) ) + { + case 'page': + case 'pageelement': + case 'file': + case 'link': + case 'folder': + case 'language': + case 'model': + case 'template': + case 'element': + $this->addSubAction( 'show' ,-1 ); + $this->addSubAction( 'create',-1 ); + $this->addSubAction( 'edit' ,-1 ); + $this->addSubAction( 'el' ,-1 ); + $this->addSubAction( 'pub' ,-1 ); + $this->addSubAction( 'prop' ,-1 ); + $this->addSubAction( 'src' ,-1 ); + $this->addSubAction( 'rights',-1 ); + $this->search = true; + break; + + case 'project': + case 'user': + case 'group': + $this->addSubAction( 'listing' ,-1 ); + $this->addSubAction( 'add' ,-1 ); + $this->addSubAction( 'edit' ,-1 ); + $this->addSubAction( 'memberships',-1 ); + $this->addSubAction( 'pw' ,-1 ); + $this->addSubAction( 'rights' ,-1 ); + $this->addSubAction( 'phpinfo' ,-1 ); + break; + + case 'blank': + default: + $this->setTemplateVar('windowMenu',array() ); + $this->setTemplateVar('text' ,'' ); + } + } + + + function addSubAction( $name,$aclbit=0 ) + { + // Wenn $aclbit nicht vorhanden oder die entsprechende Berechtigung vorhanden ist, + // dann Men�punkt erg�nzen. + if ( $aclbit==-1 ) + $url = ''; + elseif ( $aclbit==0 || $this->obj->hasRight($aclbit) ) + $url = Html::url($this->subActionName,$name,$this->getRequestId() ); + else + $url = ''; + $this->subActionList[ $name ] = array( 'text' =>'MENU_'.strtoupper($name), + 'title'=>'MENU_'.strtoupper($name).'_DESC', + 'key' =>strtoupper(lang('ACCESSKEY_MAIN_'.strtoupper($name))), + 'url' =>$url ); + } + + + function element() + { + $this->subActionName = 'element'; + $this->setTemplateVar('type','element' ); + + $element = new Element( $this->getRequestId() ); + $element->load(); + + //global $REQ; + //$REQ['id'] = $element->templateid; + + $template = new Template( $element->templateid ); + $template->load(); + + $this->addPath( lang('templates'),lang('templates'),Html::url('main','template',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),''); + $this->addPath( $template->name,lang('TEMPLATE'),Html::url('main','template',$template->templateid),''); + $this->setTemplateVar('text',$element->name ); + + //$this->addSubaction('listing'); + //$this->addSubaction('show' ); + //$this->addSubaction('edit' ); + //$this->addSubaction('el' ); + //if ( $this->writable ) + // $this->addSubaction('src' ); + //$this->addSubaction('prop' ); + + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + function addPath( $name,$title,$url,$type ) + { + $this->path[$name] = array('name' =>$name , + 'title'=>$title, + 'url' =>$url , + 'type' =>$type ); + } + + + function template() + { + if ( $this->getRequestId() != 0 ) + { + $template = new Template( $this->getRequestId() ); + $template->load(); + $this->setTemplateVar('text',$template->name ); + $this->addPath( lang('templates'),lang('templates'),Html::url('main','template',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),''); + + $this->addSubaction('show' ); +// $this->addSubaction('edit' ); + $this->addSubaction('src' ); + $this->addSubaction('el' ); + $this->addSubaction('prop' ); + } + else + { + $this->setTemplateVar('text',lang('templates') ); + } + + $this->setTemplateVar('param' ,'templateid'); + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + + function pageelement() + { + $page = Session::getObject(); + if ( !is_object($page) || $page->objectid != $this->getRequestId() ) + { + $page = new Page( $this->getRequestId() ); + Session::setObject( $page ); + $page->load(); + } + + $folder = new Folder( $page->parentid ); + $folder->filenames = false; + $folder->load(); + + foreach( $folder->parentObjectNames(true,true) as $id=>$name ) + $this->addPath($name,$name,Html::url('main','folder',$id),'folder'); + + $this->addPath($page->name,$page->name,Html::url('main','page',$page->id),'page'); + + // Ermitteln Namen des Elementes + $element = new Element( $this->getRequestVar('elementid')); + $element->load(); + $this->setTemplateVar('text',$element->name); + +// $this->obj = &$page; +// $this->addSubAction('show' ,ACL_READ ); +// $this->addSubAction('edit' ,ACL_WRITE ); +// $this->addSubAction('el' ,ACL_WRITE ); +// $this->addSubAction('form' ,ACL_WRITE ); + +// $this->addSubAction('pub' ,ACL_PUBLISH ); +// $this->addSubAction('prop' ,ACL_PROP ); +// $this->addSubAction('src' ,ACL_PROP ); +// $this->addSubAction('rights',ACL_GRANT ); + + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + + function page() + { + $page = Session::getObject(); + if ( !is_object($page) || $page->objectid != $this->getRequestId() ) + { + $page = new Page( $this->getRequestId() ); + Session::setObject( $page ); + } + $page->load(); + $this->lastModified( $page->lastchangeDate ); + + $this->setTemplateVar('nr' ,$page->objectid); + $this->setTemplateVar('actionid',$page->objectid); + + $folder = new Folder( $page->parentid ); + $folder->filenames = false; + $folder->load(); + + foreach( $folder->parentObjectNames(true,true) as $id=>$name ) + $this->addPath($name,$name,Html::url('main','folder',$id),'folder'); + +// $others = $folder->getObjects(); +// $o2 = array(); +// foreach( $others as $o ) +// if ( $o->isPage ) +// $o2[$o->objectid] = Text::maxLength($o->name,25); +// +// $this->setTemplateVar('otherObjects',$o2); + + // Ermitteln Namen der Seite + $this->setTemplateVar('text',$page->name); + + $this->obj = &$page; + $this->addSubAction('show' ,ACL_READ ); + $this->addSubAction('edit' ,ACL_WRITE ); + $this->addSubAction('el' ,ACL_WRITE ); +// $this->addSubAction('form' ,ACL_WRITE ); + + $this->addSubAction('pub' ,ACL_PUBLISH ); + $this->addSubAction('prop' ,ACL_PROP ); + $this->addSubAction('src' ,ACL_PROP ); + $this->addSubAction('rights',ACL_GRANT ); + + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + + function user() + { + global $conf; + + $this->addSubaction('add' ); + + // Liste immer anzeigen, da es ja mind. 1 Benutzer gibt. + $this->addSubaction('listing'); + + if ( $this->getRequestId() != 0 ) + { + $this->addPath( lang('USER'),lang('USER'),Html::url('main','user',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'user'); + $user = new User( $this->getRequestId() ); + $user->load(); + + $this->setTemplateVar('text',$user->name); + + $this->addSubaction('edit' ); + $this->addSubaction('memberships' ); + + // Kennwortaenderung ist nur sinnvoll, wenn kein LDAP verwendet wird + if ( @$conf['security']['auth']['type'] == 'database' && + ( empty($user->ldap_dn) || + !@$conf['security']['auth']['userdn']) ) + $this->addSubaction('pw' ); + + $this->addSubaction('rights' ); + } + else + { + $this->setTemplateVar('text',lang('USERS')); + } + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param' ,'userid' ); + } + + + + function group() + { + + $this->addSubaction('listing' ); + $this->addSubaction('add' ); + + if ( $this->getRequestId() != 0 ) + { + $group = new Group( $this->getRequestId() ); + $group->load(); + $this->setTemplateVar('text',$group->name); + + $this->addPath( lang('GROUPS'),lang('GROUPS'),Html::url('main','group',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'group'); + $this->addSubaction('memberships'); + $this->addSubaction('edit' ); + $this->addSubaction('rights' ); + } + else + { + $this->setTemplateVar('text',lang('GROUPS')); + } + + $this->setTemplateVar('windowMenu',$this->subActionList); + + $this->setTemplateVar('param' ,'groupid' ); + } + + + function file() + { + $file = new File( $this->getRequestId() ); + $file->load(); + $this->lastModified( $file->lastchangeDate ); + + $folder = new Folder( $file->parentid ); + $folder->filenames = false; + $folder->load(); + + $this->setTemplateVar('nr',$this->getSessionVar('objectid')); + + foreach( $folder->parentObjectNames(true,true) as $id=>$name ) + { + $this->addPath($name,$name,Html::url('main','folder',$id),'folder'); + } + + $this->setTemplateVar('text' ,$file->name); + + $this->setTemplateVar('id','o'.$file->objectid); + + $this->obj = &$file; + $this->addSubAction('show' ,ACL_READ ); + + $this->addSubAction('edit' ,ACL_WRITE ); + + $this->addSubAction('pub' ,ACL_PUBLISH ); + $this->addSubAction('prop' ,ACL_PROP ); + $this->addSubAction('rights',ACL_GRANT ); + + $this->setTemplateVar('windowMenu',$this->subActionList); + + $this->setTemplateVar('param','objectid'); + } + + + + function prefs() + { + $this->addSubaction('show'); + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param','conf'); + } + + + + function link() + { + // Ermitteln Sprache + $link = new Link( $this->getRequestId() ); + $link->load(); + + $folder = new Folder( $link->parentid ); + $folder->filenames = false; + $folder->load(); + + $this->setTemplateVar('nr',$this->getSessionVar('objectid')); + + foreach( $folder->parentObjectNames(true,true) as $id=>$name ) + $this->addPath($name,$name,Html::url('main','folder',$id),'folder'); + + $this->setTemplateVar('text' ,$link->name); + + $this->setTemplateVar('id','o'.$link->objectid); + + $this->obj = &$link; + $this->addSubAction('edit' ,ACL_WRITE); + $this->addSubAction('prop' ,ACL_PROP ); + $this->addSubAction('rights',ACL_GRANT); + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param','objectid'); + } + + + + function folder() + { + $folder = Session::getObject(); + if ( !is_object($folder) || $folder->objectid != $this->getRequestId() ) + { + $folder = new Folder( $this->getRequestId() ); + Session::setObject( $folder ); + } + $folder = new Folder( $folder->objectid ); + $folder->load(); + $this->obj = &$folder; + $this->setTemplateVar('nr',$folder->objectid); + + $this->lastModified( $folder->lastchangeDate ); + + foreach( $folder->parentObjectNames(true,false) as $id=>$name ) + $this->addPath($name,$name,Html::url('main','folder',$id),'folder'); + + $this->setTemplateVar('text',$folder->name); + + $this->addSubAction('show',ACL_READ ); + + $this->addSubAction('create',ACL_CREATE_FOLDER ); + $this->addSubAction('create',ACL_CREATE_FILE ); + $this->addSubAction('create',ACL_CREATE_PAGE ); + $this->addSubAction('create',ACL_CREATE_LINK ); + $this->addSubaction('el',-1 ); + + $this->addSubAction('pub' ,ACL_PUBLISH ); + + if ( !$folder->isRoot ) + $this->addSubAction('prop',ACL_PROP ); + + $this->addSubAction('rights',ACL_GRANT); + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param','objectid'); + } + + + function project() + { + $this->setTemplateVar('path',array() ); + + //$this->addSubaction('listing'); + $this->addSubaction('add' ); + $this->addSubaction('phpinfo'); + + if ( $this->getRequestId() > 0 ) + { + $this->addSubaction('edit'); + + $project = new Project( $this->getRequestId() ); + $project->load(); + $this->setTemplateVar('text',$project->name ); + $this->addPath( lang('PROJECTS'),lang('PROJECTS'),Html::url('main','project',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'user'); + } + else + { + $this->setTemplateVar('text',lang('PROJECTS') ); + } + + if ( count( Project::getAllProjectIds() ) > 0 ) + $this->addSubAction('listing'); + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param','projectid'); + } + + + function language() + { + //$this->addSubaction('listing'); + + if ( $this->userIsAdmin() && $this->getRequestId()>0 ) + { + $language = new Language($this->getRequestId()); + $language->load(); + $this->addPath( lang('LANGUAGES'),lang('LANGUAGES'),Html::url('main','language',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),''); + $this->addSubaction('edit'); + $this->setTemplateVar('text',$language->name); + } + else + { + $this->setTemplateVar('text',lang('LANGUAGES')); + } + + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param',REQ_PARAM_LANGUAGE_ID); + } + + + + function model() + { + //$this->addSubaction('listing'); + + if ( $this->userIsAdmin() && $this->getRequestId()>0 ) + { + $model = new Model( $this->getRequestId() ); + $model->load(); + $this->addPath( lang('MODELS'),lang('MODELS'),Html::url('main','model',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),''); + $this->addSubaction('edit'); + $this->setTemplateVar('text',$model->name); + } + else + { + $this->setTemplateVar('text',lang('MODELS')); + } + + $this->setTemplateVar('param','modelid'); + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + function search() + { + $this->addSubaction('prop' ); + $this->addSubaction('content'); + $this->setTemplateVar('text',lang('SEARCH')); + $this->setTemplateVar('windowMenu',$this->subActionList); + $this->setTemplateVar('param','objectid'); + } + + + function transfer() + { + $this->addSubaction('import'); + $this->setTemplateVar('windowMenu',$this->subActionList); + } + + + function show() + { + $this->setTemplateVar('windowIcons',array( array('url' =>Html::url('index','projectmenu'), + 'target'=>'_top', + 'type' =>'min'), + array('url' =>Html::url('index','logout'), + 'target'=>'_top', + 'type' =>'close') + ) ); + $this->setTemplateVar('actionid',$this->getRequestId() ); + + if ( $this->subActionName == 'pageelement') + $this->setTemplateVar('action','page'); + else + $this->setTemplateVar('action',$this->subActionName ); + + $this->setTemplateVar('name' ,$this->subActionName); + $this->setTemplateVar('css_body_class','menu' ); + + $this->setTemplateVar('path' ,$this->path ); + } + + + + function blank() + { + } +} + +?>+ \ No newline at end of file diff --git a/action/MainmenuAction.ini.php b/action/MainmenuAction.ini.php @@ -0,0 +1,50 @@ + +[default] +goto=show + +[empty] +alias=show + +[element] +goto=show + +[file] +goto=show + +[folder] +goto=show + +[group] +goto=show + +[language] +goto=show + +[link] +goto=show + +[model] +goto=show + +[page] +goto=show + +[pageelement] +goto=show + +[project] +goto=show + +[search] +goto=show + +[show] + +[template] +goto=show + +[transfer] +goto=show + +[user] +goto=show diff --git a/action/ModelAction.class.php b/action/ModelAction.class.php @@ -0,0 +1,225 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.10 2007-05-08 20:25:58 dankert +// Erweiterung der Methode "checkmenu()" +// +// Revision 1.9 2007-05-08 20:21:03 dankert +// ?berschreiben der Methode "checkmenu()" +// +// Revision 1.8 2007-04-08 21:18:16 dankert +// Korrektur URL in listing() +// +// Revision 1.7 2007/01/21 22:27:49 dankert +// Direkt Punkt "Bearbeiten" ?ffnen. +// +// Revision 1.6 2006/01/29 17:18:58 dankert +// Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden +// +// Revision 1.5 2004/12/19 14:55:27 dankert +// Anpassung von urls +// +// Revision 1.4 2004/12/13 22:17:51 dankert +// URL-Korrektur +// +// Revision 1.3 2004/05/07 21:37:31 dankert +// Url ?ber Html::url erzeugen +// +// Revision 1.2 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse zum Bearbeiten eines Projetmodells + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class ModelAction extends Action +{ + var $defaultSubAction = 'listing'; + var $model; + + + function ModelAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->model = new Model( $this->getRequestId() ); + $this->model->load(); + } + + $this->project = Session::getProject(); + } + + + function add() + { + } + + + function addmodel() + { + $model = new Model(); + $model->projectid = $this->project->projectid; + $model->name = $this->getRequestVar('name'); + $model->add(); + + // Wenn kein Namen eingegeben, dann einen setzen. + if ( empty($model->name) ) + { + // Name ist "Variante <id>" + $model->name = lang('MODEL').' '.$model->modelid; + $model->save(); + } + } + + + + /** + * Entfernen der Variante.<br> + * Es wird ein Best�tigungsdialog angezeigt. + */ + function remove() + { + $this->model->load(); + + $this->setTemplateVar( 'name',$this->model->name ); + } + + + /** + * Löschen des Models. + */ + function delete() + { + if ( $this->hasRequestVar('confirm') ) + { + $this->model->delete(); + $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); + } + else + { + $this->addNotice('model',$this->model->name,'NOTHING_DONE',OR_NOTICE_WARN); + } + } + + + + // Speichern eines Modells + function save() + { + if ( $this->getRequestVar('name') != '' ) + { + $this->model->name = $this->getRequestVar('name'); + $this->model->save(); + $this->addNotice('model',$this->model->name,'SAVED','ok'); + } + else + { + $this->addNotice('model',$this->model->name,'NOT_SAVED','error'); + } + + // Baum aktualisieren +// $this->setTemplateVar('tree_refresh',true); + } + + + function setdefault() + { + if ( !$this->userIsAdmin() ) exit(); + + $this->model->setDefault(); + + $this->callSubAction('listing'); + } + + + function listing() + { + global $conf_php; + $actModel = Session::getProjectModel(); + +// $var['act_modelid'] = $this->getSessionVar('modelid'); + + $list = array(); + foreach( $this->project->getModelIds() as $id ) + { + $m = new Model( $id ); + $m->load(); + + $list[$id]['name'] = $m->name; + + if ( $this->userIsAdmin() ) + $list[$id]['url' ] = Html::url('main','model',$id, + array(REQ_PARAM_TARGETSUBACTION=>'edit') ); + + if ( ! $m->isDefault && $this->userIsAdmin() ) + $list[$id]['default_url'] = Html::url('model','setdefault',$id); + + if ( $actModel->modelid != $m->modelid ) + $list[$id]['select_url' ] = Html::url('index','model',$id); + } + $this->setTemplateVar( 'el',$list ); + $this->setTemplateVar( 'add',$this->userIsAdmin() ); + } + + + /** + * Bearbeiten der Variante. + * Ermitteln aller Eigenschaften der Variante. + */ + function edit() + { + $this->model->load(); + + $this->setTemplateVars( $this->model->getProperties() ); + } + + + function checkmenu( $menu ) + { + switch( $menu ) + { + case 'remove': + $actModel = Session::getProjectModel(); + return + !readonly() && + $this->userIsAdmin() && + is_object($this->model) && + count( $this->model->getAll() ) >= 2 && + $actModel->modelid != $this->model->modelid; + + case 'add': + return + !readonly() && $this->userIsAdmin(); + + default: + return true; + } + } +}+ \ No newline at end of file diff --git a/action/ModelAction.ini.php b/action/ModelAction.ini.php @@ -0,0 +1,33 @@ + +[default] +goto=listing + +[setdefault] +goto=listing + +[listing] +menu=listing + +[edit] +menu=edit +target=save + +[remove] +menu=edit +target=delete + +[delete] +goto=listing + +[save] +goto=edit + +[addmodel] +goto=listing + +[add] +menu=listing +target=addmodel + +[menu] +menu=listing,add,edit,remove+ \ No newline at end of file diff --git a/action/ObjectAction.class.php b/action/ObjectAction.class.php @@ -0,0 +1,343 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.12 2009-03-22 21:13:22 dankert +// Rechte-Seite auch für Nicht-Ordner editierbar, damit Rechte löschbar sind. +// +// Revision 1.11 2009-03-19 04:36:42 dankert +// Neue Methode "inherit()". +// +// Revision 1.10 2009-03-19 02:02:43 dankert +// Keine ererbten Rechte anzeigen. +// +// Revision 1.9 2009-03-06 13:00:40 dankert +// Zeichenketten 'action' und 'subaction' durch Konstanten ersetzt. +// +// Revision 1.8 2007-11-09 20:41:51 dankert +// Hinweismeldungen setzen. +// +// Revision 1.7 2007-10-29 23:29:17 dankert +// Konstanten f?r Request-Variablen. +// +// Revision 1.6 2006/01/29 17:25:07 dankert +// Methode setWindowMenu() entfernt +// +// Revision 1.5 2006/01/23 23:10:46 dankert +// *** empty log message *** +// +// Revision 1.4 2004/12/19 14:56:33 dankert +// Abfrage von Rechten +// +// Revision 1.3 2004/11/28 19:25:38 dankert +// Anpassen an neue Sprachdatei-Konventionen +// +// Revision 1.2 2004/11/28 16:55:20 dankert +// Berechtigungen f?r "alle" hinzufuegen +// +// Revision 1.1 2004/11/27 13:08:22 dankert +// Neu: Beinhaltet objekt?bergreifende Methoden. Die Klassen File,Page,Link und Folder erben nun von dieser Klasse +// +// Revision 1.9 2004/11/10 22:36:16 dankert +// Dateioperationen, Verschieben/Kopieren/Verknuepfen von mehreren Objekten in einem Arbeitsschritt +// +// Revision 1.8 2004/10/14 22:57:44 dankert +// Neue Verknuepfungen mit dem Linknamen als Url vorbelegen +// +// Revision 1.7 2004/10/13 21:18:50 dankert +// Neue Links zum Verschieben nach ganz oben/unten +// +// Revision 1.6 2004/05/07 21:30:59 dankert +// Korrektur up_url +// +// Revision 1.5 2004/05/07 21:29:16 dankert +// Url ?ber Html::url erzeugen +// +// Revision 1.4 2004/05/02 14:49:37 dankert +// Einf?gen package-name (@package) +// +// Revision 1.3 2004/04/28 20:01:52 dankert +// Ordner l?schen erm?glichen +// +// Revision 1.2 2004/04/24 16:57:13 dankert +// Korrektur: pub() +// +// Revision 1.1 2004/04/24 15:14:52 dankert +// Initiale Version +// +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse zum Bearbeiten eines Ordners + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class ObjectAction extends Action +{ + var $objectid; + + + /** + * ACL zu einem Objekt setzen + * + * @access public + */ + function addacl() + { + $acl = new Acl(); + + $acl->objectid = $this->getRequestId(); + + // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an + // diesem Objekt die ACLs zu aendern. + $o = new Object( $acl->objectid ); + + if ( !$o->hasRight( ACL_GRANT ) ) + die('uh?'); // Scheiss Hacker. + + // Handelt es sich um eine Benutzer- oder Gruppen ACL? + switch( $this->getRequestVar('type') ) + { + case 'user': + $acl->userid = $this->getRequestVar('userid' ); + + if ( $acl->userid <= 0 ) + { + $this->addValidationError('type' ); + $this->addValidationError('userid',''); + $this->callSubAction('aclform'); + return; + } + break; + case 'group': + $acl->groupid = $this->getRequestVar('groupid'); + if ( $acl->groupid <= 0 ) + { + $this->addValidationError('type' ); + $this->addValidationError('groupid',''); + $this->callSubAction('aclform'); + return; + } + break; + case 'all': + break; + default: + $this->addValidationError('type'); + $this->callSubAction('aclform'); + return; + } + + $acl->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID); + + $acl->write = ( $this->hasRequestVar('write' ) ); + $acl->prop = ( $this->hasRequestVar('prop' ) ); + $acl->delete = ( $this->hasRequestVar('delete' ) ); + $acl->release = ( $this->hasRequestVar('release' ) ); + $acl->publish = ( $this->hasRequestVar('publish' ) ); + $acl->create_folder = ( $this->hasRequestVar('create_folder') ); + $acl->create_file = ( $this->hasRequestVar('create_file' ) ); + $acl->create_link = ( $this->hasRequestVar('create_link' ) ); + $acl->create_page = ( $this->hasRequestVar('create_page' ) ); + $acl->grant = ( $this->hasRequestVar('grant' ) ); + $acl->transmit = ( $this->hasRequestVar('transmit' ) ); + + $acl->add(); + + // Falls die Berechtigung vererbbar ist, dann diese sofort an + // Unterobjekte vererben. + if ( $acl->transmit ) + { + $folder = new Folder( $acl->objectid ); + $oids = $folder->getObjectIds(); + foreach( $folder->getAllSubfolderIds() as $sfid ) + { + $subfolder = new Folder( $sfid ); + $oids = array_merge($oids,$subfolder->getObjectIds()); + } + + foreach( $oids as $oid ) + { + $acl->objectid = $oid; + $acl->add(); + } + } + + + + + $this->addNotice('','','ADDED',OR_NOTICE_OK); + + $o->setTimestamp(); + } + + + + /** + * Alle Rechte anzeigen + */ + function rights() + { +// $this->actionName = 'object'; + $o = Session::getObject(); + $o->objectLoadRaw(); + $this->setTemplateVar( 'show',$o->getRelatedAclTypes() ); + $this->setTemplateVar( 'type',$o->getType() ); + + $acllist = array(); + + /* + foreach( $o->getAllInheritedAclIds() as $aclid ) + { + $acl = new Acl( $aclid ); + $acl->load(); + $key = 'au'.$acl->username.'g'.$acl->groupname.'a'.$aclid; + $acllist[$key] = $acl->getProperties(); + } + */ + + foreach( $o->getAllAclIds() as $aclid ) + { + $acl = new Acl( $aclid ); + $acl->load(); + $key = 'bu'.$acl->username.'g'.$acl->groupname.'a'.$aclid; + $acllist[$key] = $acl->getProperties(); + $acllist[$key]['delete_url'] = Html::url($this->actionName,'delacl',$o->objectid,array('aclid'=>$aclid)); + } + ksort( $acllist ); + + $this->setTemplateVar('acls',$acllist ); + + $this->setTemplateVars( $o->getAssocRelatedAclTypes() ); + } + + + + /** + * + * @return unknown_type + */ + function inherit() + { + $log = array(); + + if ( ! $this->hasRequestVar('inherit') ) + { + $this->addNotice('folder',$this->name,'NOTHING_DONE',OR_NOTICE_WARN); + return; + } + + + $folder = $this->folder; + $aclids = $folder->getAllAclIds(); + + $newAclList = array(); + foreach( $aclids as $aclid ) + { + $acl = new Acl( $aclid ); + $acl->load(); + if ( $acl->transmit ) + $newAclList[] = $acl; + } + $log[] = 'inheriting '.count($newAclList).' acls'; + + $oids = $folder->getObjectIds(); + + foreach( $folder->getAllSubfolderIds() as $sfid ) + { + $subfolder = new Folder( $sfid ); + + $oids = array_merge($oids,$subfolder->getObjectIds()); + } + + foreach( $oids as $oid ) + { + $object = new Object( $oid ); + + // Die alten ACLs des Objektes löschen. + foreach( $object->getAllAclIds() as $aclid ) + { + $acl = new Acl( $aclid ); + $acl->objectid = $oid; + $acl->delete(); + $log[] = 'removing acl '.$aclid.' for object '.$oid; + } + + // Vererbbare ACLs des aktuellen Ordners anwenden. + foreach( $newAclList as $newAcl ) + { + $newAcl->objectid = $oid; + $newAcl->add(); + $log[] = 'adding new acl '.$newAcl->aclid.' for object '.$oid; + } + } + + $this->addNotice('folder',$this->folder->name,'SAVED',OR_NOTICE_OK,array(),$log); + } + + + /** + * Formular anzeigen, um Rechte hinzufuegen + */ + function aclform() + { + $o = Session::getObject(); + $o->objectLoadRaw(); + + $this->setTemplateVars( $o->getAssocRelatedAclTypes() ); + $this->setTemplateVar( 'show',$o->getRelatedAclTypes() ); + + $this->setTemplateVar('users' ,User::listAll() ); + $this->setTemplateVar('groups' ,Group::getAll() ); + + $languages = array(0=>lang('ALL_LANGUAGES')); + $languages += Language::getAll(); + $this->setTemplateVar('languages',$languages ); + $this->setTemplateVar('objectid' ,$o->objectid ); + $this->setTemplateVar('action' ,$this->actionName); + } + + + + /** + * Entfernen einer ACL + * + * @access protected + */ + function delacl() + { + $acl = new Acl($this->getRequestVar('aclid')); + $acl->objectid = $this->getRequestId(); + + // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an + // diesem Objekt die ACLs zu aendern. + $o = new Object( $this->getRequestId() ); + + if ( !$o->hasRight( ACL_GRANT ) ) + die('ehm?'); // Da wollte uns wohl einer vereimern. + + $acl->delete(); // Weg mit der ACL + + $this->addNotice('','','DELETED',OR_NOTICE_OK); + } +}+ \ No newline at end of file diff --git a/action/PageAction.class.php b/action/PageAction.class.php @@ -0,0 +1,809 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// + +/** + * Action-Klasse zum Bearbeiten einer Seite + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class PageAction extends ObjectAction +{ + var $page; + var $defaultSubAction = 'show'; + + + function PageAction() + { + if ( $this->getRequestId() != 0 ) + { + $this->page = new Page( $this->getRequestId() ); + $this->page->load(); + Session::setObject( $this->page ); + } + else + { + $this->page = Session::getObject(); + } + + // Hier kann leider nicht das Datum der letzten Änderung verwendet werden, + // da sich die Seite auch danach ändern kann, z.B. durch Includes anderer + // Seiten oder Änderung einer Vorlage oder Änderung des Dateinamens einer + // verlinkten Datei. + $this->lastModified( time() ); + } + + + /** + * Alle Daten aus dem Formular speichern + */ + function saveform() + { + $this->page->public = true; + $this->page->simple = true; + + foreach( $this->page->getElements() as $elementid=>$name ) + { + if ( $this->hasRequestVar('saveid'.$elementid) ) + { + $value = new Value(); + $value->objectid = $this->page->objectid; + $value->pageid = Page::getPageIdFromObjectId( $value->objectid ); + $value->element = new Element( $elementid ); + $value->element->load(); + $value->publish = false; + $value->load(); + + // Eingegebenen Inhalt aus dem Request lesen + $inhalt = $this->getRequestVar( 'id'.$elementid ); + + // Den Inhalt speichern. + switch( $value->element->type ) + { + case 'number': + $value->number = $inhalt * pow(10,$value->element->decimals); + break; + + case 'date': + $value->date = strtotime( $inhalt ); + break; + + case 'text': + case 'longtext': + case 'select': + $value->text = $inhalt; + break; + + case 'link': + case 'list': + case 'insert': + $value->linkToObjectId = intval($inhalt); + break; + } + + $value->page = &$this->page; + + // Ermitteln, ob Inhalt sofort freigegeben werden kann und soll + if ( $this->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') ) + $value->publish = true; + else + $value->publish = false; + +// Html::debug($inhalt,'Eingabe'); +// Html::debug($value,'Inhalt'); + + // Inhalt speichern. + // Inhalt in allen Sprachen gleich? + if ( $value->element->allLanguages ) + { + // Inhalt fuer jede Sprache einzeln speichern. + $p = new Project(); + foreach( $p->getLanguageIds() as $languageid ) + { + $value->languageid = $languageid; + $value->save(); + } + } + else + { + // sonst nur 1x speichern (fuer die aktuelle Sprache) + $value->languageid = $this->getSessionVar(REQ_PARAM_LANGUAGE_ID); + $value->save(); + } + } + } + $this->page->setTimestamp(); // "Letzte Aenderung" setzen + + if ( $this->hasRequestVar('publish') ) + $this->callSubAction( 'pubnow' ); + else + $this->callSubAction( 'el' ); + } + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function elsave() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals); + $value->linkToObjectId = intval($this->getRequestVar('linkobjectid')); + $value->text = $this->getRequestVar('text'); + + // Vorschau anzeigen + if ( $value->element->type=='longtext' && ($this->hasRequestVar('preview')||$this->hasRequestVar('addmarkup')) ) + { + if ( $this->hasRequestVar('preview') ) + { + $value->page = $this->page; + $value->simple = false; + $value->page->languageid = $value->languageid; + $value->page->load(); + $value->generate(); + $this->setTemplateVar('preview_text',$value->value ); + } + + if ( $this->hasRequestVar('addmarkup') ) + { + $addText = $this->getRequestVar('addtext'); + + if ( !empty($addText) ) // Nur, wenn ein Text eingegeben wurde + { + $addText = $this->getRequestVar('addtext'); + + if ( $this->hasRequestVar('strong') ) + $value->text .= '*'.$addText.'*'; + + if ( $this->hasRequestVar('emphatic') ) + $value->text .= '_'.$addText.'_'; + + if ( $this->hasRequestVar('link') ) + $value->text .= '"'.$addText.'"->"'.$this->getRequestVar('objectid').'"'; + } + + if ( $this->hasRequestVar('table') ) + $value->text .= "|$addText | |\n|$addText | |\n|$addText | |\n"; + + if ( $this->hasRequestVar('list') ) + $value->text .= "\n- ".$addText."\n".'- '.$addText."\n".'- '.$addText."\n"; + + if ( $this->hasRequestVar('numlist') ) + $value->text .= "\n# ".$addText."\n".'# '.$addText."\n".'# '.$addText."\n"; + + if ( $this->hasRequestVar('image') ) + $value->text .= '{'.$this->getRequestVar('objectid').'}'; + } + + // Ermitteln aller verlinkbaren Objekte (fuer Editor) + $objects = array(); + + foreach( Folder::getAllObjectIds() as $id ) + { + $o = new Object( $id ); + $o->load(); + + if ( $o->getType() != 'folder' ) + { + $f = new Folder( $o->parentid ); + $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': '; + $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) ); + $objects[ $id ] .= FILE_SEP.$o->name; + } + } + asort($objects); + $this->setTemplateVar( 'objects' ,$objects ); + + $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) ); + $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) ); + $this->setTemplateVar( 'html' ,$value->element->html ); + $this->setTemplateVar( 'wiki' ,$value->element->wiki ); + $this->setTemplateVar( 'text' ,$value->text ); + $this->setTemplateVar( 'name' ,$value->element->name ); + $this->setTemplateVar( 'desc' ,$value->element->desc ); + $this->setTemplateVar( 'objectid',$this->page->objectid ); + return; + } + + if ( $this->hasRequestVar('year') ) // Wird ein Datum gespeichert? + { + // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden + if ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') ) + $value->date = strtotime($this->getRequestVar('ansidate') ); + else + // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen + $value->date = mktime( $this->getRequestVar('hour' ), + $this->getRequestVar('minute'), + $this->getRequestVar('second'), + $this->getRequestVar('month' ), + $this->getRequestVar('day' ), + $this->getRequestVar('year' ) ); + } + else $value->date = 0; // Datum nicht gesetzt. + + $value->text = $this->getRequestVar('text'); + + $value->page = new Page( $value->objectid ); + $value->page->load(); + + // Inhalt sofort freigegeben, wenn + // - Recht vorhanden + // - Freigabe gewuenscht + if ( $value->page->hasRight( ACL_RELEASE ) && $this->getRequestVar('release')!='' ) + $value->publish = true; + else + $value->publish = false; + + // Inhalt speichern + + // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt + // fuer jede Sprache einzeln gespeichert. + if ( $value->element->allLanguages ) + { + $project = Session::getProject(); + foreach( $project->getLanguageIds() as $languageid ) + { + $value->languageid = $languageid; + $value->save(); + } + } + else + { + // sonst nur 1x speichern (fuer die aktuelle Sprache) + $value->save(); + } + + $this->page->setTimestamp(); // "Letzte Aenderung" setzen + + // Falls ausgewaehlt die Seite sofort veroeffentlichen + if ( $this->hasRequestVar('publish') ) + $this->callSubAction( 'pubnow' ); // Weiter zum veroeffentlichen + else + $this->callSubAction( 'el' ); // Element-Liste anzeigen + } + + + + /** + * Eigenschaften der Seite speichern + */ + function propAction() + { + if ( $this->getRequestVar('name')!='' ) + { + $this->page->name = $this->getRequestVar('name' ,OR_FILTER_FULL ); + $this->page->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME); + $this->page->desc = $this->getRequestVar('description',OR_FILTER_FULL ); + + $this->page->save(); + $this->addNotice($this->page->getType(),$this->page->name,'PROP_SAVED','ok'); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('prop'); + } + } + + + + /** + * Die Eigenschaften der Seite anzeigen + */ + function propView() + { + $this->setTemplateVar('id',$this->page->objectid); + + $this->page->public = true; + $this->page->load(); + $this->page->full_filename(); + + if ( $this->page->filename == $this->page->objectid ) + $this->page->filename = ''; + + $this->setTemplateVars( $this->page->getProperties() ); + + if ( $this->userIsAdmin() ) + { + $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid)); + } + + $template = new Template( $this->page->templateid ); + $template->load(); + $this->setTemplateVar('template_name',$template->name); + + // Alle Ordner ermitteln +// $this->setTemplateVar('act_folderobjectid',$this->page->parentid); +// +// $folders = array(); +// $folder = new Folder( $this->page->parentid ); + +// foreach( $folder->getOtherFolders() as $oid ) +// { +// $f = new Folder( $oid ); +// $folders[$oid] = implode( FILE_SEP,$f->parentObjectNames(true,true) ); +// } +// asort( $folders ); +// $this->setTemplateVar('folder',$folders); + + $templates = Array(); + foreach( Template::getAll() as $id=>$name ) + { + if ( $id != $this->page->templateid ) + $templates[$id]=$name; + } + $this->setTemplateVar('templates',$templates); + } + + + + /** + * Austauschen der Vorlage vorbereiten + * + * Es wird ein Formualr erzeugt, in dem der Benutzer auswaehlen kann, welche Elemente + * in welches Element uebernommen werden sollen + */ + function changetemplateselectelements() + { + $newTemplateId = intval($this->getRequestVar('templateid')); + + if ( $newTemplateId != 0 ) + { + $this->setTemplateVar('newTemplateId',$newTemplateId ); + + $oldElements = array(); + $oldTemplate = new Template( $this->page->templateid ); + $newTemplate = new Template( $newTemplateId ); + + foreach( $oldTemplate->getElementIds() as $elementid ) + { + $e = new Element( $elementid ); + $e->load(); + + if ( !$e->isWritable() ) + continue; + + $oldElement = array(); + $oldElement['name'] = $e->name.' - '.lang('EL_'.$e->type ); + $oldElement['id' ] = $e->elementid; + + $newElements = Array(); + $newElements[0] = lang('ELEMENT_DELETE_VALUES'); + + foreach( $newTemplate->getElementIds() as $newelementid ) + { + $ne = new Element( $newelementid ); + $ne->load(); + + // Nur neue Elemente anbieten, deren Typ identisch ist + if ( $ne->type == $e->type ) + $newElements[$newelementid] = lang('ELEMENT').': '.$ne->name.' - '.lang('EL_'.$e->type ); + } + $oldElement['newElementsName'] = 'from'.$e->elementid; + $oldElement['newElementsList'] = $newElements; + $oldElements[$elementid] = $oldElement; + } + $this->setTemplateVar('elements',$oldElements ); + } + else + { + $this->callSubAction('prop'); + } + } + + + + /** + * Die Vorlage der Seite austauschen + * + * Die Vorlage wird ausgetauscht, die Inhalte werden gemaess der Benutzereingaben kopiert + */ + function replacetemplate() + { + $newTemplateId = intval($this->getRequestVar('newTemplateId')); + $replaceElementMap = Array(); + + $oldTemplate = new Template( $this->page->templateid ); + foreach( $oldTemplate->getElementIds() as $elementid ) + $replaceElementMap[$elementid] = $this->getRequestVar('from'.$elementid); + + if ( $newTemplateId != 0 ) + { + $this->page->replaceTemplate( $newTemplateId,$replaceElementMap ); + $this->addNotice('page',$this->page->name,'SAVED',OR_NOTICE_OK); + } + else + $this->addNotice('page',$this->page->name,'NOT_SAVED',OR_NOTICE_WARN); + } + + + + + /** + * Alle Elemente der Seite anzeigen + */ + function el() + { + $this->page->public = true; + $this->page->simple = true; + $this->page->generate_elements(); + + $list = array(); + + // Schleife ueber alle Inhalte der Seite + foreach( $this->page->values as $id=>$value ) + { + // Element wird nur angezeigt, wenn es editierbar ist + if ( $value->element->isWritable() ) + { + $list[$id] = array(); + $list[$id]['name'] = $value->element->name; + $list[$id]['url' ] = Html::url( 'pageelement','edit' ,$this->page->id,array('elementid'=>$id,'mode'=>'edit') ); + $list[$id]['desc'] = $value->element->desc; + $list[$id]['type'] = $value->element->type; + + $list[$id]['archive_count'] = intval($value->getCountVersions()); + if ( $list[$id]['archive_count'] > 0 ) + $list[$id]['archive_url'] = Html::url( 'pageelement','archive',$this->page->id,array('elementid'=>$id) ); + + // Maximal 50 Stellen des Inhaltes anzeigen + $list[$id]['value'] = Text::maxLaenge( 50,$value->value ); + } + } + + $this->setTemplateVar('el',$list); + } + + + /** + * Alle editierbaren Felder in einem Formular bereitstellen + */ + function form() + { + global $conf_php; + + $this->page->public = false; + $this->page->simple = true; + $this->page->generate_elements(); + + $list = array(); + + foreach( $this->page->values as $id=>$value ) + { + if ( $value->element->isWritable() ) + { + $list[$id] = array(); + $list[$id]['name'] = $value->element->name; + $list[$id]['desc'] = $value->element->desc; + $list[$id]['type'] = $value->element->type; + $list[$id]['id' ] = 'id'.$value->element->elementid; + $list[$id]['saveid'] = 'saveid'.$value->element->elementid; + + switch( $value->element->type ) + { + case 'text': + case 'longtext': + $list[$id]['value'] = $value->text; + break; + + case 'date': + $list[$id]['value'] = date( 'Y-m-d H:i:s',$value->date ); + break; + + case 'number': + $list[$id]['value'] = $value->number / pow(10,$value->element->decimals); + break; + + case 'select': + $list[$id]['list' ] = $value->element->getSelectItems(); + $list[$id]['value'] = $value->text; + break; + + case 'link': + $objects = array(); + + foreach( Folder::getAllObjectIds() as $oid ) + { + $o = new Object( $oid ); + $o->load(); + + if ( $o->getType() != 'folder' ) + { + $f = new Folder( $o->parentid ); + $f->load(); + + $objects[ $oid ] = lang( $o->getType() ).': '; + $objects[ $oid ] .= implode( ' &raquo; ',$f->parentObjectNames(false,true) ); + $objects[ $oid ] .= ' &raquo; '.$o->name; + } + } + + asort( $objects ); // Sortieren + + $list[$id]['list' ] = $objects; + $list[$id]['value'] = $value->linkToObjectId; + break; + + case 'list': + $objects = array(); + foreach( Folder::getAllFolders() as $oid ) + { + $f = new Folder( $oid ); + $f->load(); + + $objects[ $oid ] = lang( $f->getType() ).': '; + $objects[ $oid ] .= implode( ' &raquo; ',$f->parentObjectNames(false,true) ); + } + + asort( $objects ); // Sortieren + + $this->setTemplateVar('list' ,$objects); + $this->setTemplateVar('value',$this->value->linkToObjectId); + + break; + } + } + } + + $this->setTemplateVar( 'release',$this->page->hasRight(ACL_RELEASE) ); + $this->setTemplateVar( 'publish',$this->page->hasRight(ACL_PUBLISH) ); + + $this->setWindowMenu( 'elements' ); + $this->setTemplateVar('el',$list); + } + + + + /** + * Seite anzeigen + */ + function show() + { + $this->setTemplateVar('preview_url',Html::url('page','preview',$this->page->objectid,array('target'=>'none') ) ); + } + + /** + * Seite anzeigen + */ + function preview() + { + Logger::debug("preview von seite"); + // Seite definieren + $this->page->load(); + $this->page->generate(); + $this->page->write(); + + header('Content-Type: '.$this->page->mimeType().'; charset='.$this->getCharset() ); + + // HTTP-Header mit Sprachinformation setzen. + $language = Session::getProjectLanguage(); + header('Content-Language: '.$language->isoCode); + + Logger::debug("preview von seite: ".$this->page->tmpfile() ); + + // Wenn + if ( ( config('publish','enable_php_in_page_content')=='auto' && $this->page->template->extension == 'php') || + config('publish','enable_php_in_page_content')===true ) + require( $this->page->tmpfile() ); + else + readfile( $this->page->tmpfile() ); + } + + + + /** + * Die Seite im Bearbeitungsmodus anzeigen + * + * Bei editierbaren Feldern wird ein Editor-Ikon vorangestellt. + */ + function edit() + { + // Editier-Icons anzeigen + $this->page->icons = true; + + $this->page->load(); + $this->page->generate(); + $this->page->write(); + + header('Content-Type: '.$this->page->mimeType().'; charset='.$this->getCharset() ); + + // HTTP-Header mit Sprachinformation setzen. + $language = Session::getProjectLanguage(); + header('Content-Language: '.$language->isoCode); + + + // Wenn + if ( ( config('publish','enable_php_in_page_content')=='auto' && $this->page->template->extension == 'php') || + config('publish','enable_php_in_page_content')===true ) + require( $this->page->tmpfile() ); + else + readfile( $this->page->tmpfile() ); + + // Inhalt ist ausgegeben... Skript beenden. + exit; + } + + + + /** + * Den Quellcode der Seite anzeigen + * + * Alle HTML-Sonderzeichen werden maskiert + */ + function src() + { + $language = Session::getProjectLanguage(); + $model = Session::getProjectModel(); + + $this->page->languageid = $language->languageid; + $this->page->modelid = $model->modelid; + + $this->page->withLanguage = config('publish','filename_language') == 'always' || count(Language::count()) > 1; + $this->page->withModel = config('publish','filename_type' ) == 'always' || count(Model::count() ) > 1; + + $this->page->public = true; + $this->page->load(); + + $src = $this->page->generate(); + + // HTML Highlighting + + //$src = preg_replace( '|<(.+)( .+)?'.'>|Us' , '<strong>&lt;$1</strong>$2<strong>&gt;</strong>', $src); + //$src = preg_replace( '|([a-zA-Z]+)="(.+)"|Us' , '<em>$1</em>=<var>"$2"</var>' , $src); + $src = htmlentities($src); + + $this->setTemplateVar('src',$src); + } + + + + + /** + * Die Eigenschaften der Seite anzeigen + */ + function changetemplate() + { + $this->page->public = true; + $this->page->load(); + + $this->setTemplateVars( $this->page->getProperties() ); + + if ( $this->userIsAdmin() ) + { + $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid)); + } + + $template = new Template( $this->page->templateid ); + $template->load(); + $this->setTemplateVar('template_name',$template->name); + + $templates = Array(); + foreach( Template::getAll() as $id=>$name ) + { + if ( $id != $this->page->templateid ) + $templates[$id]=$name; + } + $this->setTemplateVar('templates',$templates); + } + + + + + + /** + * Seite veroeffentlichen + * + * Es wird ein Formular angzeigt, mit dem die Seite veroeffentlicht + * werden kann + */ + function pubView() + { + } + + + + /** + * Seite veroeffentlichen + * + * Die Seite wird generiert. + */ + function pubAction() + { + if ( !$this->page->hasRight( ACL_PUBLISH ) ) + Http::notAuthorized( 'no right for publish' ); + + $this->page->public = true; + $this->page->publish(); + $this->page->publish->close(); + +// foreach( $this->page->publish->publishedObjects as $o ) +// { +// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); +// } + + $this->addNotice('page',$this->page->fullFilename,'PUBLISHED'.($this->page->publish->ok?'':'_ERROR'),$this->page->publish->ok,array(),$this->page->publish->log); + } + + + function setWindowMenu( $type ) { + switch( $type) + { + case 'elements': + $menu = array( array('subaction'=>'el' ,'text'=>'all'), + array('subaction'=>'form','text'=>'change' ) ); + $this->setTemplateVar('windowMenu',$menu); + break; + case 'acl': + $menu = array( array('subaction'=>'rights' ,'text'=>'show'), + array('subaction'=>'aclform','text'=>'add' ) ); + $this->setTemplateVar('windowMenu',$menu); + break; + + } + } + + + /** + * 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; + + } + } + +} + +?>+ \ No newline at end of file diff --git a/action/PageAction.ini.php b/action/PageAction.ini.php @@ -0,0 +1,80 @@ + +[default] +goto=show + +;[remove] +;menu=prop +;target=delete + +;[delete] +;target=prop + +[show] +menu=elements + +[preview] +direct=true + +[edit] +direct=true + +[el] +menu=elements + +[form] +target=saveform +menu=elements + +[pub] +menu=pub +write=true + +[saveform] +goto=el + +[prop] +menu=prop +write=true +target=prop +editable=true + +[changetemplate] +menu=prop +target=changetemplateselectelements + +[changetemplateselectelements] +menu=prop +target=replacetemplate + +[replacetemplate] +goto=prop + +[src] +menu=src + +; Die Aktionen "rights", "aclform", "addacl" und "delacl" sind +; f�r Seiten,Ordner,Links und Dateien identisch. +[rights] +menu=rights +action=object +editable=true + +[aclform] +menu=rights +target=addacl +action=object + +[addacl] +goto=rights + +[delacl] +goto=rights + + +[menu] +menu=show,pub,el,prop,src,rights +pub=show,pub,el,form,rights,prop,changetemplate,src +elements=show,pub,el,form,rights,prop,changetemplate,src +rights=show,pub,el,form,rights,prop,changetemplate,src +src=show,pub,el,form,rights,prop,changetemplate,src +prop=show,pub,el,form,rights,prop,changetemplate,src+ \ No newline at end of file diff --git a/action/PageelementAction.class.php b/action/PageelementAction.class.php @@ -0,0 +1,1350 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse zum Bearbeiten eines Seitenelementes + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class PageelementAction extends Action +{ + var $defaultSubAction = 'edit'; + + + /** + * Enthaelt das Seitenobjekt + * @type Object + */ + var $page; + + /** + * Enthaelt das Elementobjekt + * @type Object + */ + var $element; + + + /** + * Enth�lt den Inhalt + * + * @var Object + */ + var $value; + + + + /** + * Konstruktor + */ + function PageelementAction() + { + $this->value = new Value(); + + $this->page = Session::getObject(); + + if ( $this->getRequestId() != 0 ) + { + $this->page = new Page( $this->getRequestId() ); + $this->page->load(); + Session::setObject( $this->page ); + } + else + { + $this->page = Session::getObject(); + } + + if ( $this->hasRequestVar('elementid') ) + { + $this->element = new Element( $this->getRequestVar('elementid',OR_FILTER_NUMBER) ); + Session::setElement( $this->element ); + } + else + { + $this->element = Session::getElement(); + } + } + + + + /** + * Anzeigen des Element-Inhaltes. + */ + function prop() + { + $language = Session::getProjectLanguage(); + $this->value->languageid = $language->languageid; + $this->value->objectid = $this->page->objectid; + $this->value->pageid = $this->page->pageid; + $this->value->page = $this->page; + $this->value->simple = false; + $this->value->element = &$this->element; + $this->value->element->load(); + $this->value->publish = false; + $this->value->load(); + + $this->setTemplateVar('name' ,$this->value->element->name ); + $this->setTemplateVar('description' ,$this->value->element->desc ); + $this->setTemplateVar('elementid' ,$this->value->element->elementid); + $this->setTemplateVar('element_type',$this->value->element->type ); + + if ( $this->value->element->type == 'longtext' && $this->value->element->wiki ) + { + $this->setTemplateVar('text',$this->value->text); + } + + $user = new User( $this->value->lastchangeUserId ); + $user->load(); + $this->setTemplateVar('lastchange_user',$user); + $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp); + + $t = new Template( $this->page->templateid ); + $t->load(); + $this->setTemplateVar('template_name',$t->name ); + $this->setTemplateVar('template_url' ,Html::url('template','prop',$t->templateid) ); + + $this->setTemplateVar('element_name' ,$this->value->element->name ); + $this->setTemplateVar('element_url' ,Html::url('element','name',$this->value->element->elementid) ); + + } + + + + /** + * Normaler Editiermodus. + * + * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. + */ + function edit() + { + $language = Session::getProjectLanguage(); + $this->value->languageid = $language->languageid; + $this->value->objectid = $this->page->objectid; + $this->value->pageid = $this->page->pageid; + $this->value->element = &$this->element; + $this->value->element->load(); + $this->value->publish = false; + + if ( intval($this->value->valueid)!=0 ) + $this->value->loadWithId(); + else + $this->value->load(); + + $this->setTemplateVar('name' ,$this->value->element->name ); + $this->setTemplateVar('desc' ,$this->value->element->desc ); + $this->setTemplateVar('elementid',$this->value->element->elementid); + $this->setTemplateVar('type' ,$this->value->element->type ); + $this->setTemplateVar('value_time',time() ); + + + $this->value->page = new Page( $this->page->objectid ); + $this->value->page->languageid = $this->value->languageid; + $this->value->page->load(); + + $this->setTemplateVar( 'objectid',$this->value->page->objectid ); + + if ( $this->value->page->hasRight(ACL_RELEASE) ) + $this->setTemplateVar( 'release',true ); + if ( $this->value->page->hasRight(ACL_PUBLISH) ) + $this->setTemplateVar( 'publish',false ); + + $funktionName = 'edit'.$this->value->element->type; + + if ( ! method_exists($this,$funktionName) ) + Http::serverError('Method does not exist: PageElementAction#'.$funktionName ); + + $this->$funktionName(); // Aufruf der Funktion "edit<Elementtyp>()". + } + + + + /** + * Datum bearbeiten. + * + */ + function editdate() + { + global $conf; + $date = $this->value->date; + + // Wenn Datum nicht vorhanden... + if ( $date == 0 ) + // ... dann aktuelles Datum (gerundet auf 1 Minute) verwenden + $date = intval(time()/60)*60; + + $this->setTemplateVar('ansidate',date( 'Y-m-d H:i:s',$date ) ); + $this->setTemplateVar('date' ,$date); + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + + + // Wenn Datum nicht vorhanden, dann aktuelles Datum verwenden + if ( $this->hasRequestVar('year') ) + { + $date = mktime( $this->getRequestVar('hour'), + $this->getRequestVar('minute'), + $this->getRequestVar('second'), + $this->getRequestVar('month'), + $this->getRequestVar('day'), + $this->getRequestVar('year') ); + } + $year = intval(date('Y',$date)); + $month = intval(date('n',$date)); + $day = intval(date('j',$date)); + $hour = intval(date('G',$date)); + $minute = intval(date('i',$date)); + $second = intval(date('s',$date)); + $this->setTemplateVar('year' ,$year ); + $this->setTemplateVar('month' ,$month ); + $this->setTemplateVar('day' ,$day ); + $this->setTemplateVar('hour' ,$hour ); + $this->setTemplateVar('minute',$minute ); + $this->setTemplateVar('second',$second ); + + $this->setTemplateVar('monthname',lang('DATE_MONTH'.date('n',$date)) ); + $this->setTemplateVar('yearname' ,date('Y',$date) ); + + + // Zwischenberechnungen + $heuteTag = intval(date('j')); + $monatLetzterTag = intval(date('t',$date)); + $monatErsterDatum = $date-(($day-1)*86400); + $wocheNr = date( 'W',$monatErsterDatum ); + $wochentagErster = date( 'w',$monatErsterDatum ); + + + $weekdayOffset = intval($conf['editor']['calendar']['weekday_offset']); + + // Alle Wochentage + $weekdays = array(); + for ( $i=0; $i<=6; $i++ ) + { + $wday = ($i+$weekdayOffset)%7; + $weekdays[$wday] = lang('DATE_WEEKDAY'.$wday); + } + + $this->setTemplateVar('weekdays',$weekdays); + + + $monat = array(); + $d = 0; + $begin = false; + do + { + $woche = array(); // Neue Woche + + for ( $i=0; $i<=6; $i++ ) // Alle Wochentage der Woche + { + $wday = ($i+$weekdayOffset)%7; + $tag = array(); // Neuer Tag + + if (!$begin && $wday == $wochentagErster) + $begin = true; + + if ( $begin && $d < $monatLetzterTag ) + { + $d++; + $tag['nr'] = $d; + $tag['today'] = ($year==date('Y') && $month==date('n') && $d==$heuteTag); + if ($d != $day) + $tag['url'] = Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>$year , + 'month' =>$month , + 'day' =>$d , + 'hour' =>$hour , + 'minute'=>$minute, + 'second'=>$second ) ); + else + $tag['url'] = ''; + } + else + { + $tag['nr' ]=''; + $tag['today' ]=false; + $tag['url' ]=''; + } + $woche[] = $tag; + + } + $monat[$wocheNr] = $woche; + $wocheNr++; + } + while( $d < $monatLetzterTag-1 ); + // Html::debug($monat); + $this->setTemplateVar('weeklist',$monat); + + $this->setTemplateVar('actdate' ,date( lang('DATE_FORMAT'),$date ) ); + $this->setTemplateVar('todayurl',Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>date('Y'), + 'month' =>date('n'), + 'day' =>date('j'), + 'hour' =>date('G'), + 'minute'=>date('i'), + 'second'=>date('s') ) ) ); + $this->setTemplateVar('lastyearurl',Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>$year-1, + 'month' =>$month , + 'day' =>$day , + 'hour' =>$hour , + 'minute'=>$minute, + 'second'=>$second ) ) ); + $this->setTemplateVar('nextyearurl',Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>$year+1 , + 'month' =>$month , + 'day' =>$day , + 'hour' =>$hour , + 'minute'=>$minute, + 'second'=>$second ) ) ); + $this->setTemplateVar('lastmonthurl',Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>$year , + 'month' =>$month-1, + 'day' =>$day , + 'hour' =>$hour , + 'minute'=>$minute, + 'second'=>$second ) ) ); + $this->setTemplateVar('nextmonthurl',Html::url( 'pageelement','edit','', + array('elementid'=>$this->element->elementid,'mode'=>'edit', + 'year' =>$year , + 'month' =>$month+1, + 'day' =>$day , + 'hour' =>$hour , + 'minute'=>$minute, + 'second'=>$second ) ) ); + + // $this->setTemplateVar('date' ,$date); + + + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + + + $all_years = array(); + $all_months = array(); + $all_days = array(); + $all_hours = array(); + $all_minutes = array(); + for( $i=$year-100; $i<=$year+100;$i++ ) $all_years [$i] = $i; + for( $i=1; $i<=12; $i++ ) $all_months [$i] = lang('DATE_MONTH'.$i); + for( $i=1; $i<=31; $i++ ) $all_days [$i] = str_pad($i,2,'0',STR_PAD_LEFT); + for( $i=0; $i<=23; $i++ ) $all_hours [$i] = str_pad($i,2,'0',STR_PAD_LEFT); + for( $i=0; $i<=59; $i++ ) $all_minutes[$i] = str_pad($i,2,'0',STR_PAD_LEFT); + + $this->setTemplateVar('all_years' ,$all_years ); + $this->setTemplateVar('all_months' ,$all_months ); + $this->setTemplateVar('all_days' ,$all_days ); + $this->setTemplateVar('all_hours' ,$all_hours ); + $this->setTemplateVar('all_minutes',$all_minutes); + $this->setTemplateVar('all_seconds',$all_minutes); + } + + + + /** + * Verkn�pfung bearbeiten. + * + */ + function editlink() + { + + // Ermitteln, welche Objekttypen verlinkt werden d�rfen. + $type = $this->value->element->subtype; + + if ( substr($type,0,5) == 'image' ) + $type = 'file'; + + if ( !in_array($type,array('file','page','link')) ) + $types = array('file','page','link'); + else + $types = array($type); + + $objects = array(); + + foreach( Folder::getAllObjectIds($types) as $id ) + { + $o = new Object( $id ); + $o->load(); + + // if ( in_array( $o->getType(),$types )) + // { + $f = new Folder( $o->parentid ); + // $f->load(); + + $objects[ $id ] = lang( $o->getType() ).': '; + $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) ); + $objects[ $id ] .= FILE_SEP.$o->name; + // } + } + + asort( $objects ); // Sortieren + + $this->setTemplateVar('objects' ,$objects); + $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId); + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else + $this->setTemplateVar('old_pageaction','show' ); + } + + + + function link() + { + $language = Session::getProjectLanguage(); + $this->value->languageid = $language->languageid; + $this->value->objectid = $this->page->objectid; + $this->value->pageid = $this->page->pageid; + $this->value->element = &$this->element; + $this->value->element->load(); + $this->value->publish = false; + $this->value->load(); + + $this->setTemplateVar('name' ,$this->value->element->name ); + $this->setTemplateVar('desc' ,$this->value->element->desc ); + + // Ermitteln, welche Objekttypen verlinkt werden d�rfen. + if ( empty($this->value->element->subtype) ) + $types = array('page','file','link'); // Fallback: Alle erlauben :) + else + $types = explode(',',$this->value->element->subtype ); + + $objects = array(); + + $objects[ 0 ] = lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt" + + $t = new Template( $this->page->templateid ); + + foreach( $t->getDependentObjectIds() as $id ) + { + $o = new Object( $id ); + $o->load(); + + // if ( in_array( $o->getType(),$types )) + // { + $f = new Folder( $o->parentid ); + // $f->load(); + + $objects[ $id ] = lang( $o->getType() ).': '; + $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) ); + $objects[ $id ] .= FILE_SEP.$o->name; + // } + } + + asort( $objects ); // Sortieren + + $this->setTemplateVar('objects' ,$objects); + $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId); + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + + $this->value->page = new Page( $this->page->objectid ); + $this->value->page->languageid = $this->value->languageid; + $this->value->page->load(); + + $this->setTemplateVar( 'release',$this->value->page->hasRight(ACL_RELEASE) ); + $this->setTemplateVar( 'publish',$this->value->page->hasRight(ACL_PUBLISH) ); + + $this->setTemplateVar( 'objectid',$this->value->page->objectid ); + } + + + + /** + * Auswahlbox. + * + */ + function editselect() + { + $this->setTemplateVar( 'items',$this->value->element->getSelectItems() ); + $this->setTemplateVar( 'text' ,$this->value->text ); + + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + } + + + + /** + * Einf�gen-Element. + * + */ + function editlist() + { + $this->editinsert(); + } + + + + /** + * Einf�gen-Element. + * + */ + function editinsert() + { + // Auswahl ueber alle Elementtypen + $objects = array(); + foreach( Folder::getAllFolders() as $id ) + { + $f = new Folder( $id ); + $f->load(); + + $objects[ $id ] = lang( $f->getType() ).': '; + $objects[ $id ] .= implode( ' &raquo; ',$f->parentObjectNames(false,true) ); + } + + asort( $objects ); // Sortieren + + $this->setTemplateVar('objects' ,$objects); + $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId); + + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + } + + + + /** + * Zahl bearbeiten. + * + */ + function editnumber() + { + $this->setTemplateVar('number',$this->value->number / pow(10,$this->value->element->decimals) ); + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + } + + + /** + * Ein Element der Seite bearbeiten + * + * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. + */ + function editlongtext() + { + if ($this->value->element->wiki) + $this->setTemplateVar( 'editor','wiki' ); + elseif ($this->value->element->html) + $this->setTemplateVar( 'editor','html' ); + else + $this->setTemplateVar( 'editor','text' ); + + if ( !isset($this->templateVars['text'])) + // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits + // einen Text eingegeben hat (Vorschaufunktion). + $this->setTemplateVar( 'text',$this->linkifyOIDs( $this->value->text ) ); + + if (! $this->isEditMode() ) + { + $this->value->generate(); // Inhalt erzeugen. + $this->setTemplateVar('text',$this->linkifyOIDs( $this->value->value )); + } + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + + + + if ( $this->element->wiki ) + { + $project = Session::getProject(); + $languages = $project->getLanguages(); + + if ( count($languages) > 1 ) + { + $languages[$this->value->languageid] = $languages[$this->value->languageid].' *'; + $this->setTemplateVar('languages',$languages); + } + + if ( $this->hasRequestVar('otherlanguageid') ) + { + $lid = $this->getRequestVar('otherlanguageid'); + $otherValue = new Value(); + $otherValue->languageid = $lid; + $otherValue->pageid = $this->value->pageid; + $otherValue->element = $this->value->element; + $otherValue->publish = $this->value->publish; + $otherValue->load(); + $this->setTemplateVar('languagetext' ,wordwrap($otherValue->text,100) ); + $this->setTemplateVar('languagename' ,$languages[$lid] ); + $this->setTemplateVar('otherlanguageid',$lid ); + } + + if ( !isset($this->templateVars['text'])) + // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits + // einen Text eingegeben hat (Vorschaufunktion). + $this->setTemplateVar( 'text',$this->value->text ); + } + + } + + + + /** + * Ein Element der Seite bearbeiten + * + * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. + */ + function edittext() + { + $this->setTemplateVar( 'text',$this->value->text ); + + if ( $this->getSessionVar('pageaction') != '' ) + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + else $this->setTemplateVar('old_pageaction','show' ); + } + + + + /** + * Benutzen eines alten Inhaltes + */ + function usevalue() + { + $this->value->valueid = $this->getRequestVar('valueid'); + } + + + + /** + * Freigeben eines Inhaltes + */ + function release() + { + $this->value->valueid = intval($this->getRequestVar('valueid')); + $this->value->loadWithId(); + + if ( $this->value->pageid != $this->page->pageid ) + die( 'cannot release, bad page' ); + + // Pruefen, ob Berechtigung zum Freigeben besteht + if ( !$this->page->hasRight(ACL_RELEASE) ) + die( 'cannot release, no right' ); + + // Inhalt freigeben + $this->value->release(); + } + + + /** + * Erzeugt eine Liste aller Versionsst?nde zu diesem Inhalt + */ + function archive() + { + $this->page->public = true; + $this->page->simple = true; + $this->page->load(); + $this->value->page = &$this->page; + + $this->value->simple = true; + $language = Session::getProjectLanguage(); + $this->value->languageid = $language->languageid; + $this->value->objectid = $this->page->objectid; + $this->value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); + $this->value->element = &$this->element; + $this->value->element->load(); + + $list = array(); + // $version_list = array(); + $lfd_nr = 0; + + foreach( $this->value->getVersionList() as $value ) + { + $lfd_nr++; + $value->element = &$this->element; + $value->page = &$this->page; + $value->simple = true; + $value->generate(); + + + // $date = date( lang('DATE_FORMAT'),$value->lastchangeTimeStamp); + + // if ( in_array( $this->element->type,array('text','longtext') ) ) + // $version_list[ $value->valueid ] = '('.$lfd_nr.') '.$date; + + $zeile = array( 'value' => Text::maxLaenge( 50,$value->value), + 'date' => $value->lastchangeTimeStamp, + 'lfd_nr' => $lfd_nr, + 'id' => $value->valueid, + 'user' => $value->lastchangeUserName ); + + // Nicht aktive Inhalte k�nnen direkt bearbeitet werden und sind + // nach dem Speichern dann wieder aktiv (nat�rlich als n�chster/neuer Inhalt) + if ( ! $value->active ) + $zeile['useUrl'] = Html::url('pageelement','usevalue',$this->page->objectid,array('valueid' =>$value->valueid,'mode'=>'edit')); + + // Freigeben des Inhaltes. + // Nur das aktive Inhaltselement kann freigegeben werden. Nat�rlich auch nur, + // wenn es nicht schon freigegeben ist. + if ( ! $value->publish && $value->active ) + $zeile['releaseUrl'] = Html::url('pageelement','release',$this->page->objectid,array('valueid' =>$value->valueid )); + + $zeile['public'] = $value->publish; + $zeile['active'] = $value->active; + + $list[$lfd_nr] = $zeile; + + } + + if ( in_array( $this->value->element->type, array('longtext') ) && $lfd_nr >= 2 ) + { + $this->setTemplateVar('compareid',$list[$lfd_nr-1]['id']); + $this->setTemplateVar('withid' ,$list[$lfd_nr ]['id']); + } + + $this->setTemplateVar('name' ,$value->element->name); + $this->setTemplateVar('el' ,$list ); + } + + + /** + * Vergleicht 2 Versionen eines Inhaltes + */ + function diff() + { + $value1id = $this->getRequestVar('compareid'); + $value2id = $this->getRequestVar('withid' ); + + // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen + if ( $value1id == $value2id ) + { + $this->addValidationError('compareid' ); + $this->addValidationError('withid' ,''); + $this->callSubAction('archive'); + return; + } + + // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen + if ( $value1id > $value2id ) + list($value1id,$value2id) = array( $value2id,$value1id ); + + + $value1 = new Value( $value1id ); + $value2 = new Value( $value2id ); + $value1->valueid = $value1id; + $value2->valueid = $value2id; + + $value1->loadWithId(); + $value2->loadWithId(); + + $this->setTemplateVar('date_left' ,$value1->lastchangeTimeStamp); + $this->setTemplateVar('date_right',$value2->lastchangeTimeStamp); + + $text1 = explode("\n",$value1->text); + $text2 = explode("\n",$value2->text); + + // Unterschiede feststellen. + $res_diff = Text::diff($text1,$text2); + + list( $text1,$text2 ) = $res_diff; + + $diff = array(); + $i = 0; + while( isset($text1[$i]) || isset($text2[$i]) ) + { + $line = array(); + + if ( isset($text1[$i]['text']) ) + $line['left'] = $text1[$i]; + + if ( isset($text2[$i]['text']) ) + $line['right'] = $text2[$i]; + + $i++; + $diff[] = $line; + } + $this->setTemplateVar('diff',$diff ); + } + + + + /** + * Ein Element der Seite speichern. + */ + function save() + { + $this->element->load(); + $type = $this->element->type; + + if ( empty($type)) + die('Error: No element type available.'); + + $funktionName = 'save'.$type; + + $this->$funktionName(); // Aufruf Methode "save<ElementTyp>()" + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savetext() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + if ( $this->hasRequestVar('linkobjectid') ) + $value->linkToObjectId = $this->getRequestVar('linkobjectid'); + else + $value->text = $this->getRequestVar('text','raw'); + + $this->afterSave($value); + } + + + + /** + * Nach dem Speichern weitere Dinge ausfuehren.<br> + * - Inhalt freigeben<br> + * - Seite veroeffentlichen<br> + * - Inhalt fuer andere Sprachen speichern<br> + * - Hinweis ueber erfolgtes Speichern ausgeben<br> + * <br> + * Nicht zu verwechseln mit <i>Aftershave</i> :) + */ + function afterSave( $value ) + { + $value->page = new Page( $value->objectid ); + $value->page->load(); + + + // Inhalt sofort freigegeben, wenn + // - Recht vorhanden + // - Freigabe gewuenscht + if ( $value->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') ) + $value->publish = true; + else + $value->publish = false; + + // Up-To-Date-Check + $lastChangeTime = $value->getLastChangeTime(); + if ( $lastChangeTime > $this->getRequestVar('value_time') ) + { + $this->addNotice('pageelement',$value->element->name,'CONCURRENT_VALUE_CHANGE',OR_NOTICE_WARN,array('last_change_time'=>date(lang('DATE_FORMAT'),$lastChangeTime))); + } + + // Inhalt speichern + + // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt + // fuer jede Sprache einzeln gespeichert. + if ( $value->element->allLanguages ) + { + $project = Session::getProject(); + foreach( $project->getLanguageIds() as $languageid ) + { + $value->languageid = $languageid; + $value->save(); + } + } + else + { + // sonst nur 1x speichern (fuer die aktuelle Sprache) + $value->save(); + } + + $this->addNotice('pageelement',$value->element->name,'SAVED',OR_NOTICE_OK); + $this->page->setTimestamp(); // "Letzte Aenderung" setzen + + // Falls ausgewaehlt die Seite sofort veroeffentlichen + if ( $value->page->hasRight( ACL_PUBLISH ) && $this->hasRequestVar('publish') ) + { + $this->page->publish(); + $this->addNotice('pageelement',$value->element->name,'PUBLISHED',OR_NOTICE_OK); + } + } + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savelongtext() + { + global $conf; + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + + if ( $this->hasRequestVar('linkobjectid') ) + $value->linkToObjectId = $this->getRequestVar('linkobjectid'); + else + $value->text = $this->compactOIDs( $this->getRequestVar('text','raw') ); + + // Vorschau anzeigen + if ( $this->hasRequestVar('preview' ) || + $this->hasRequestVar('addmarkup') ) + { + $inputText = $this->getRequestVar('text','raw'); + + if ( $this->hasRequestVar('preview') ) + { + $value->page = $this->page; + $value->simple = false; + $value->page->languageid = $value->languageid; + $value->page->load(); + $value->generate(); + $this->setTemplateVar('preview',$value->value ); + } + + if ( $this->hasRequestVar('addmarkup') ) + { + $conf_tags = $conf['editor']['text-markup']; + + if ( $this->hasRequestVar('addtext') ) // Nur, wenn ein Text eingegeben wurde + { + $addText = $this->getRequestVar('addtext','raw'); + + if ( $this->hasRequestVar('strong') ) + $inputText .= $conf_tags['strong-begin'].$addText.$conf_tags['strong-end']; + + if ( $this->hasRequestVar('emphatic') ) + $inputText .= $conf_tags['emphatic-begin'].$addText.$conf_tags['emphatic-end']; + + if ( $this->hasRequestVar('link') ) + $inputText .= '"'.$addText.'"'.$conf_tags['linkto'].'"'.$this->parseOID($this->getRequestVar('objectid')).'"'; + } + + if ( $this->hasRequestVar('table') ) + $inputText .= "\n". + $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n". + $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n". + $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n"; + + if ( $this->hasRequestVar('list') ) + $inputText .= "\n". + $conf_tags['list-unnumbered'].' '.$addText."\n". + $conf_tags['list-unnumbered'].' '.$addText."\n". + $conf_tags['list-unnumbered'].' '.$addText."\n"; + + if ( $this->hasRequestVar('numlist') ) + $inputText .= "\n". + $conf_tags['list-numbered'].' '.$addText."\n". + $conf_tags['list-numbered'].' '.$addText."\n". + $conf_tags['list-numbered'].' '.$addText."\n"; + + if ( $this->hasRequestVar('image') ) + $inputText .= $conf_tags['image-begin'].$this->parseOID($this->getRequestVar('objectid')).$conf_tags['image-end']; + } + + // Ermitteln aller verlinkbaren Objekte (fuer Editor) + /* + $objects = array(); + + foreach( Folder::getAllObjectIds() as $id ) + { + $o = new Object( $id ); + $o->load(); + + if ( $o->getType() != 'folder' ) + { + $f = new Folder( $o->parentid ); + $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': '; + $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) ); + $objects[ $id ] .= FILE_SEP.$o->name; + } + } + asort($objects); + $this->setTemplateVar( 'objects' ,$objects ); + */ + + $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) ); + $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) ); + $this->setTemplateVar( 'html' ,$value->element->html ); + $this->setTemplateVar( 'wiki' ,$value->element->wiki ); + $this->setTemplateVar( 'text' ,$inputText ); + $this->setTemplateVar( 'name' ,$value->element->name ); + $this->setTemplateVar( 'desc' ,$value->element->desc ); + $this->setTemplateVar( 'objectid',$this->page->objectid ); + + $this->setTemplateVar( 'mode' ,'edit' ); + } + else + { + $this->afterSave($value); + } + + } + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savedate() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + if ( $this->hasRequestVar('linkobjectid') ) + $value->linkToObjectId = $this->getRequestVar('linkobjectid'); + elseif ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') ) + // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden + $value->date = strtotime($this->getRequestVar('ansidate') ); + else + // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen + $value->date = mktime( $this->getRequestVar('hour' ), + $this->getRequestVar('minute'), + $this->getRequestVar('second'), + $this->getRequestVar('month' ), + $this->getRequestVar('day' ), + $this->getRequestVar('year' ) ); + + $this->afterSave($value); + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function saveselect() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + $value->text = $this->getRequestVar('text'); + + $this->afterSave($value); + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savelink() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + if ( $this->hasRequestVar('linkurl') ) + $value->linkToObjectId = $this->parseOID($this->getRequestVar('linkurl')); + else + $value->linkToObjectId = intval($this->getRequestVar('linkobjectid')); + + $this->afterSave($value); + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savelist() + { + $this->saveinsert(); + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function saveinsert() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + $value->linkToObjectId = intval($this->getRequestVar('linkobjectid')); + + $this->afterSave($value); + } + + + + /** + * Element speichern + * + * Der Inhalt eines Elementes wird abgespeichert + */ + function savenumber() + { + $value = new Value(); + $language = Session::getProjectLanguage(); + $value->languageid = $language->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(); + + $value->element->load(); + $value->publish = false; + $value->load(); + + if ( $this->hasRequestVar('linkobjectid') ) + $value->linkToObjectId = $this->getRequestVar('linkobjectid'); + else + $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals); + + $this->afterSave($value); + } + + + function exportlongtext() + { + $types = array(); + + foreach( array('odf','plaintext') as $type ) + { + $types[$type] = lang('FILETYPE_'.$type); + } + + $this->setTemplateVar('types',$types); + } + + + function importlongtext() + { + $types = array(); + + foreach( array('odf','plaintext') as $type ) + { + $types[$type] = lang('FILETYPE_'.$type); + } + $this->setTemplateVar('types',$types); + } + + + function doexportlongtext() + { + $type = $this->getRequestVar('type'); + switch($type) + { + case 'odf': + + // Angabe Content-Type + // header('Content-Type: '.$this->file->mimeType()); + // header('X-File-Id: '.$this->file->fileid); + + // header('Content-Disposition: inline; filename='.$this->id.'.odt'); + header('Content-Transfer-Encoding: binary'); + // header('Content-Description: '.$this->file->name); + + echo $this->createOdfDocument(); + + exit; + + default: + } + + exit; + } + + + /** + * ODF erzeugen.<br> + * vorerst ZURUECKGESTELLT! + * + * @return unknown + */ + function createOdfDocument() + { + // TODO: ODF ist nicht ganz ohne. + $transformer = new Transformer(); + $transformer->text = $this->value->text; + $transformer->type = 'odf'; + $transformer->transform(); + return $transformer->text; + } + + + + /** + * Men�eintr�ge aktivieren/deaktivieren. + * + * @param String $name + * @return boolean + */ + function checkMenu( $name ) + { + $type = $this->element->type; + + switch( $name ) + { + case 'edit': + case 'prop': + return true; + + case 'archive': + // Archiv ist nur verf�gbar, wenn es mind. 1 Version des Inhaltes gibt. + + if ( $this->subActionName!='diff' && is_object($this->value) ) + return $this->value->getCountVersions() > 0; + else + return true; + + case 'link': + // Verkn�pfung zu anderen Seiten ist nur m�glich f�r + // Datum, Text, Textabsatz, Ganzzahl. + return in_array($type,array('date','text','longtext','number')); + + default: + return false; + } + } + + + function linkifyOIDs( $text ) + { + foreach( Text::parseOID($text) as $oid=>$t ) + { + $url = $this->page->path_to_object($oid); + $text = str_replace($t,'"'.$url.'"',$text); + } + + return $text; + } + + + function compactOIDs( $text ) + { + foreach( Text::parseOID($text) as $oid=>$t ) + { + $text = str_replace($t,'"?__OID__'.$oid.'__"',$text); + } + + return $text; + } + + + function parseOID( $text ) + { + $treffer = array(); + preg_match_all('/(.*)__OID__([0-9]+)__(.*)/', $text, $treffer,PREG_SET_ORDER); + + $oid = $treffer[0][2]; + + if ( !empty($oid) ) + return $oid; + else + return intval($text); + } +} + +?>+ \ No newline at end of file diff --git a/action/PageelementAction.ini.php b/action/PageelementAction.ini.php @@ -0,0 +1,51 @@ + +[default] +goto=edit + +[usevalue] +menu=edit +goto=edit + +[doimport] +goto=edit + +[doexport] +direct=true + +[import] +menu=edit + +[link] +menu=edit +target=save + +[export] +menu=edit + +[diff] +menu=edit +target=archive + +[archive] +menu=edit +target=diff + +[release] +goto=archive + +[edit] +menu=edit +target=save +editable=true + +[prop] +menu=edit + +[save] +goto=edit + +[menu] +menu=edit,prop,link,import,export,archive + +;import/export haben wir noch nicht +;menu=edit,prop,link,import,export,archive+ \ No newline at end of file diff --git a/action/ProfileAction.class.php b/action/ProfileAction.class.php @@ -0,0 +1,297 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse zum Bearbeiten des Benutzerprofiles + * + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class ProfileAction extends Action +{ + var $user; + var $defaultSubAction = 'edit'; + + /** + * Konstruktor. + * Setzen der Benutzer-Objektes. + */ + function ProfileAction() + { + $this->user = Session::getUser(); + } + + + /** + * Abspeichern des Profiles + */ + function saveprofile() + { + $this->user->fullname = $this->getRequestVar('fullname'); + $this->user->tel = $this->getRequestVar('tel' ); + $this->user->desc = $this->getRequestVar('desc' ); + $this->user->style = $this->getRequestVar('style' ); + + $this->setStyle( $this->user->style ); // Style sofort anwenden + + if ( !empty($this->user->fullname) ) + { + $this->user->save(); + $this->addNotice('user',$this->user->name,'SAVED','ok'); + } + else + { + $this->addValidationError('fullname'); + $this->callSubAction('edit'); + } + } + + + + /** + * Benutzer-Einstellungen anzeigen. + * Diese Einstellungen werden im Cookie gespeichert. + */ + function settingsView() + { + foreach( array('always_edit','ignore_ok_notices','timezone_offset','language') as $name ) + $this->setTemplateVar($name,Text::clean(isset($_COOKIE['or_'.$name])?$_COOKIE['or_'.$name]:'','abcdefghijklmnopqrstuvwxyz0123456789 .')); + + //Html::debug(Text::clean($_COOKIE['or_'.$name],'0123456789 .')); + $timezone_list = array(); + //$timezone_list[ '' ] = 'SERVER ('.(date('Z')>=0?'+':'').intval(date('Z')/3600).':00)'; + + global $conf; + $tzlist = $conf['date']['timezone']; + if ( !is_array($tzlist))$tzlist = array(); + foreach ($tzlist as $offset=>$name) + $timezone_list[$offset] = $name.' ('.vorzeichen(intval($offset/60)).':00)'.($offset==date('Z')/60?' *':''); + + $this->setTemplateVar('timezone_list',$timezone_list); + $languages = explode(',',$conf['i18n']['available']); + foreach($languages as $id=>$name) + { + unset($languages[$id]); + $languages[$name] = $name; + } + $this->setTemplateVar('language_list',$languages); + } + + + + /** + * Speichern der Benutzereinstellungen. + */ + function settingsAction() + { + foreach( array('always_edit','ignore_ok_notices','timezone_offset','language') as $name ) + { + // Prüfen, ob Checkbox aktiviert wurde. + if ( $this->hasRequestVar($name)) + { + // Cookie setzen + setcookie('or_'.$name,$this->getRequestVar($name,OR_FILTER_ALPHANUM),time()+(60*60*24*30*12*2)); + $_COOKIE['or_'.$name] = $this->getRequestVar($name,OR_FILTER_ALPHANUM); + } + else + { + // Cookie loeschen + setcookie('or_'.$name,'', time()-3600); + unset($_COOKIE['or_'.$name]); + } + } + + $this->addNotice('user',$this->user->name,'SAVED','ok'); + } + + + + /** + * Anzeigen einer Maske zum Ändern des Kennwortes. + */ + function pwchange() + { + } + + + + /** + * Anzeige einer Maske zum Ändern der E-Mail-Adresse + */ + function mail() + { + } + + + + /* + * Es wird eine E-Mail mit einem Freischaltcode an die eingegebene Adresse geschickt. + */ + function mailcode() + { + srand ((double)microtime()*1000003); + $code = rand(); // Zufalls-Freischaltcode erzeugen + $newMail = $this->getRequestVar('mail'); + + if ( empty($newMail) ) + { + // Keine E-Mail-Adresse eingegeben. + $this->addValidationError('mail'); + return; + } + else + { + // Der Freischaltcode wird in der Sitzung gespeichert. + Session::set('mailChangeCode',$code ); + Session::set('mailChangeMail',$newMail); + + // E-Mail an die neue Adresse senden. + $mail = new Mail( $newMail,'mail_change_code' ); + $mail->setVar('code',$code ); + $mail->setVar('name',$this->user->getName()); + + if ( $mail->send() ) + { + $this->addNotice('user',$this->user->name,'mail_sent',OR_NOTICE_OK); // Meldung + } + else + { + $this->addNotice('user',$this->user->name,'mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); // Meldung + $this->callSubAction('mail'); + return; + } + } + } + + + + /** + * Anzeige einer Maske, in die der Freischaltcode für das + * Ändern der E-Mail-Adresse eingetragen werden muss. + */ + function confirmmail() + { + } + + + + /** + * Abspeichern der neuen E-Mail-Adresse + */ + function savemail() + { + $sessionCode = Session::get('mailChangeCode'); + $newMail = Session::get('mailChangeMail'); + $inputRegisterCode = $this->getRequestVar('code'); + + if ( $sessionCode == $inputRegisterCode ) + { + // Best�tigungscode stimmt �berein. + // E-Mail-Adresse �ndern. + $this->user->mail = $newMail; + $this->user->save(); + + $this->addNotice('user',$this->user->name,'SAVED',OR_NOTICE_OK); + } + else + { + // Best�tigungscode stimmt nicht. + $this->addValidationError('code','code_not_match'); + $this->callSubAction('confirmmail'); + } + + } + + + + function savepw() + { + if ( ! $this->user->checkPassword( $this->getRequestVar('act_password') ) ) + { + $this->addValidationError('act_password'); + $this->callSubAction('pwchange'); + } + elseif ( $this->getRequestVar('password1') == '' ) + { + $this->addValidationError('password1'); + $this->callSubAction('pwchange'); + } + elseif ( $this->getRequestVar('password1') != $this->getRequestVar('password2') ) + { + $this->addValidationError('password2','PASSWORDS_DO_NOT_MATCH'); + $this->callSubAction('pwchange'); + } + else + { + $this->user->setPassword( $this->getRequestVar('password1') ); + $this->addNotice('user',$this->user->name,'SAVED','ok'); + } + } + + + + /** + * Anzeige aller Benutzer-Eigenschaften. + */ + function edit() + { + $this->setTemplateVars( $this->user->getProperties() ); + + $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() ); + } + + + + /** + * Anzeige aller Gruppen des angemeldeten Benutzers. + * + */ + function groups() + { + $this->setTemplateVar( 'groups',$this->user->getGroups() ); + } + + + + /** + * @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; + } + } + +}+ \ No newline at end of file diff --git a/action/ProfileAction.ini.php b/action/ProfileAction.ini.php @@ -0,0 +1,42 @@ + +[default] +goto=edit + +[edit] +target=saveprofile +menu=edit +editable=true + +[groups] +menu=edit + +[pwchange] +target=savepw +menu=edit + +[mail] +target=mailcode +menu=edit + +[mailcode] +goto=confirmmail + +[confirmmail] +target=savemail +menu=edit + +[savemail] +goto=edit + +[savepw] +goto=edit + +[saveprofile] +goto=edit + +[settings] +menu=edit +write=true + +[menu] +menu=edit,settings,pwchange,mail,groups+ \ No newline at end of file diff --git a/action/ProjectAction.class.php b/action/ProjectAction.class.php @@ -0,0 +1,318 @@ +<?php +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse zum Bearbeiten eines Projektes + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ +class ProjectAction extends Action +{ + var $project; + var $defaultSubAction = 'listing'; + + + function ProjectAction() + { + if ( $this->getRequestId()!=0 ) + { + $this->project = new Project( $this->getRequestId() ); + $this->project->load(); + } + + + } + + + function editAction() + { + if ( $this->getRequestVar('name') != '') + { + $this->project->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM); + $this->project->target_dir = $this->getRequestVar('target_dir' ,OR_FILTER_RAW ); + $this->project->ftp_url = $this->getRequestVar('ftp_url' ,OR_FILTER_RAW ); + $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,OR_FILTER_RAW ); + $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,OR_FILTER_RAW ); + $this->project->content_negotiation = $this->getRequestVar('content_negotiation',OR_FILTER_NUMBER ); + $this->project->cut_index = $this->getRequestVar('cut_index' ,OR_FILTER_NUMBER ); + + $this->addNotice('project',$this->project->name,'SAVED','ok'); + $this->project->save(); // speichern + + $root = new Folder( $this->project->getRootObjectId() ); + $root->setTimestamp(); + } + else + { + $this->addValidationError('name'); + $this->callSubAction('edit'); + } + } + + + + function addView() + { + $this->setTemplateVar( 'projects',Project::getAll() ); + } + + + /** + * Projekt hinzufuegen. + * + */ + function addAction() + { + if ( !$this->hasRequestVar('type') ) + { + $this->addValidationError('type'); + $this->callSubAction('add'); + return; + } + else + { + switch( $this->getRequestVar('type') ) + { + case 'empty': + if ( !$this->hasRequestVar('name') ) + { + $this->addValidationError('name'); + $this->callSubAction('add'); + return; + } + $this->project = new Project(); + $this->project->name = $this->getRequestVar('name'); + $this->project->add(); + $this->addNotice('project',$this->project->name,'ADDED'); + break; + case 'copy': + $db = db_connection(); + $project = new Project($this->getRequestVar('projectid')); + $project->load(); + $project->export($db->id); + $this->addNotice('project',$project->name,'DONE'); + break; + default: + Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') ); + } + + } + } + + + /** + * Liste aller Projekte anzeigen. + * + */ + function listing() + { + global $conf_php; + + // Projekte ermitteln + $list = array(); + + foreach( Project::getAll() as $id=>$name ) + { + $list[$id] = array(); + $list[$id]['url' ] = Html::url('project','edit',$id); + $list[$id]['use_url' ] = Html::url('tree' ,'load',0 ,array('projectid'=>$id,'target'=>'tree')); + $list[$id]['name' ] = $name; + } + $this->setTemplateVar('el',$list); + } + + + /** + * Auswaehlen und starten eines Projektes. + */ + function select() + { + $user = Session::getUser(); + $projects = $user->projects; + + // Administrator sieht Administrationsbereich + if ( $user->isAdmin ) + $projects = array_merge( array("-1"=>lang('ADMINISTRATION')),$projects ); + + // Projekte ermitteln + $list = array(); + + foreach( $projects as $id=>$name ) + { + $list[$id] = array(); + $list[$id]['url' ] = Html::url('index','project',$id); + $list[$id]['name'] = $name; + } + $this->setTemplateVar('el',$list); + } + + + /** + * Anzeige der Eigenschaften des Projektes. + */ + function editView() + { + // Projekt laden + $this->setTemplateVars( $this->project->getProperties() ); + + } + + + function removeView() + { + $this->setTemplateVar( 'name',$this->project->name ); + } + + + function removeAction() + { + if ( !$this->hasRequestVar('delete') ) + { + $this->addValidationError('delete'); + return; + } + + // Gesamtes Projekt loeschen + $this->project->delete(); + + $this->setTemplateVar('tree_refresh',true); + $this->addNotice('project',$this->project->name,'DELETED'); + } + + + + /** + * Anzeige View fuer Wartung. + */ + function maintenanceView() + { + } + + + + /** + * Wartung durchfuehren. + */ + function maintenanceAction() + { + switch( $this->getRequestVar('type') ) + { + case 'check_files': + $this->project->checkLostFiles(); + $this->addNotice('project',$this->project->name,'DONE'); + break; + + case 'check_limit': + $this->project->checkLimit(); + $this->addNotice('project',$this->project->name,'DONE'); + break; + + default: + $this->addValidationError('type'); + return; + } + } + + + + /** + * Projekt exportieren. + */ + function exportView() + { + + } + + + /** + * Projekt exportieren. + */ + function exportAction() + { + $db = db_connection(); + $this->setTemplateVar( 'dbid',$db->id ); + + global $conf; + $dbids = array(); + + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled']) + $dbids[$dbname] = $dbconf['comment']; + } + $this->setTemplateVar( 'dbids',$dbids ); + + + if ( $this->hasRequestVar('ok') ) + { + $this->project->export( $this->getRequestVar('dbid') ); + + $this->addNotice('project',$this->project->name,'DONE'); + $this->setTemplateVar('done',true); + } + } + + + + /** + * Ausgabe PHPINFO. + * + */ + function phpinfo() + { + global $conf; + if ( !@$conf['security']['show_system_info'] ) + Http::sendStatus(403,'Forbidden','Display of system information is disabled by configuration'); + + phpinfo(); + } + + + + + function info() + { + $this->setTemplateVar( 'info', $this->project->info() ); + } + + + + + /** + * @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; + } + } + +}+ \ No newline at end of file diff --git a/action/ProjectAction.ini.php b/action/ProjectAction.ini.php @@ -0,0 +1,39 @@ + +; Only admins are allowed to change project settings +admin=true + +[phpinfo] +direct=true + +[default] +goto=listing + +[listing] +menu=list + +[remove] +menu=edit +write=true + +[maintenance] +menu=edit +write=true + +[export] +menu=edit +write=true + +[edit] +menu=edit +editable=true +write=true + +[add] +menu=list +write=true + +[info] +menu=edit + +[menu] +menu=listing,add,edit,remove,info,export,maintenance diff --git a/action/SearchAction.class.php b/action/SearchAction.class.php @@ -0,0 +1,248 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + +/** + * Action-Klasse fuer die Suchfunktion. + * + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class SearchAction extends Action +{ + /** + * leerer Kontruktor + */ + function SearchAction() + { + } + + + /** + * Durchf?hren der Suche + * und Anzeige der Ergebnisse + */ + function searchcontent() + { + global $conf_php; + + $listObjectIds = array(); + $listTemplateIds = array(); + + switch( $this->getRequestVar('type') ) + { + case 'value': + $e = new Value(); + $language = Session::getProjectLanguage(); + $e->languageid = $language->languageid; + + $listObjectIds = $e->getObjectIdsByValue( $this->getRequestVar('text') ); + + $template = new Template(); + $listTemplateIds = $template->getTemplateIdsByValue( $this->getRequestVar('text') ); + break; + + case 'lastchange_user': + $e = new Value(); + + $language = Session::getProjectLanguage(); + $e->languageid = $language->languageid; + + $listObjectIds = $e->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') ); + break; + } + + + $this->explainResult( $listObjectIds, $listTemplateIds ); + + } + + + + /** + * + */ + function explainResult( $listObjectIds, $listTemplateIds ) + { + $resultList = array(); + + foreach( $listObjectIds as $objectid ) + { + $o = new Object( $objectid ); + $o->load(); + $resultList[$objectid] = array(); + $resultList[$objectid]['url'] = Html::url($o->getType(),'',$objectid); + $resultList[$objectid]['type'] = $o->getType(); + $resultList[$objectid]['name'] = $o->name; + $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate; + + if ( $o->desc != '' ) + $resultList[$objectid]['desc'] = $o->desc; + else + $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + } + + foreach( $listTemplateIds as $templateid ) + { + $t = new Template( $templateid ); + $t->load(); + $resultList['t'.$templateid] = array(); + $resultList['t'.$templateid]['url' ] = Html::url('template','',$templateid); + $resultList['t'.$templateid]['type'] = 'template'; + $resultList['t'.$templateid]['name'] = $t->name; + $resultList['t'.$templateid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $resultList['t'.$templateid]['lastchange_date'] = 0; + } + + $this->setTemplateVar( 'result',$resultList ); + } + + + /** + * Durchf?hren der Suche + * und Anzeige der Ergebnisse + */ + function searchprop() + { + global $conf_php; + + $listObjectIds = array(); + $listTemplateIds = array(); + + switch( $this->getRequestVar('type') ) + { + case 'id': + $o = new Object(); + if ( $o->isObjectId($this->getRequestVar('text')) ) + $listObjectIds[] = $this->getRequestVar('text'); + break; + + case 'filename': + $o = new Object(); + $listObjectIds = $o->getObjectIdsByFilename( $this->getRequestVar('text') ); + + $f = new File(); + $listObjectIds += $f->getObjectIdsByExtension( $this->getRequestVar('text') ); + break; + + case 'name': + $o = new Object(); + $listObjectIds = $o->getObjectIdsByName( $this->getRequestVar('text') ); + break; + + case 'description': + $o = new Object(); + $listObjectIds = $o->getObjectIdsByDescription( $this->getRequestVar('text') ); + break; + + case 'create_user': + $o = new Object(); + $listObjectIds = $o->getObjectIdsByCreateUserId( $this->getRequestVar('userid') ); + break; + + case 'lastchange_user': + $o = new Object(); + $listObjectIds = $o->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') ); + break; + + default: + die('search method unknown: '.$this->getRequestVar('type') ); + } + + $this->explainResult( $listObjectIds, $listTemplateIds ); + } + + + /** + * Durchf?hren der Suche + * und Anzeige der Ergebnisse + */ + function quicksearch() + { + global $conf; + + $listObjectIds = array(); + $listTemplateIds = array(); + + $text = $this->getRequestVar('search'); + + $o = new Object(); + if ( Object::available( intval($text) ) ) + $listObjectIds[] = intval( $text ); + + if ( $conf['search']['quicksearch']['search_name'] ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByName( $text ); + } + + if ( $conf['search']['quicksearch']['search_description'] ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByDescription( $text ); + } + + if ( $conf['search']['quicksearch']['search_filename'] ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByFilename( $text ); + + $f = new File(); + $listObjectIds += $f->getObjectIdsByExtension( $text ); + } + + // Inhalte durchsuchen + if ( $conf['search']['quicksearch']['search_content'] ) + { + $e = new Value(); + $listObjectIds += $e->getObjectIdsByValue( $text ); + + $template = new Template(); + $listTemplateIds += $template->getTemplateIdsByValue( $text ); + } + + $this->explainResult( $listObjectIds, $listTemplateIds ); + } + + + function prop() + { + $user = Session::getUser(); + $this->setTemplateVar( 'users' ,User::listAll() ); + $this->setTemplateVar( 'act_userid',$user->userid ); + } + + + function content() + { + $user = Session::getUser(); + $this->setTemplateVar( 'users' ,User::listAll() ); + $this->setTemplateVar( 'act_userid',$user->userid ); + } + + function result() + { + } +} + +?>+ \ No newline at end of file diff --git a/action/SearchAction.ini.php b/action/SearchAction.ini.php @@ -0,0 +1,27 @@ + +[default] +goto=prop + +[quicksearch] +menu=search +goto=result + +[result] +menu=search + +[prop] +menu=search +target=searchprop + +[content] +menu=search +target=searchcontent + +[searchcontent] +goto=result + +[searchprop] +goto=result + +[menu] +menu=prop,content diff --git a/action/StartAction.class.php b/action/StartAction.class.php @@ -0,0 +1,1665 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +if ( !defined('PROJECTID_ADMIN') ) + define('PROJECTID_ADMIN',-1); + +/** + * Action-Klasse fuer die Start-Action + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class StartAction extends Action +{ + var $mustChangePassword = false; + + function setDb( $dbid ) + { + global $conf; + + if ( !isset($conf['database'][$dbid] )) + Http::serverError( 'unknown DB-Id: '.$dbid ); + + $db = db_connection(); + if ( is_object($db) ) + { + $db->rollback(); + } + + $db = new DB( $conf['database'][$dbid] ); + $db->id = $dbid; + $db->start(); + Session::setDatabase( $db ); + } + + + + function checkForDb() + { + global $conf; + $dbid = $this->getRequestVar('dbid'); + + if ( $dbid != '' ) + $this->setDb( $dbid ); + } + + + + function setDefaultDb() + { + if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) ) + { + $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID); + } + else + { + global $conf; + + if ( !isset($conf['database']['default']) ) + Http::serverError('default-database not set'); + + $dbid = $conf['database']['default']; + } + + $this->setDb( $dbid ); + } + + + + function checkLogin( $name,$pw,$pw1,$pw2 ) + { + Logger::debug( "login user $name" ); + + global $conf; + global $SESS; + + unset( $SESS['user'] ); + + + $db = db_connection(); + + if ( !$db->available ) + { + $this->addNotice('database',$db->conf['comment'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error)); + $this->callSubAction('showlogin'); + return false; + } + + $ip = getenv("REMOTE_ADDR"); + + $user = new User(); + $user->name = $name; + + $ok = $user->checkPassword( $pw ); + + $this->mustChangePassword = $user->mustChangePassword; + + if ( $this->mustChangePassword ) + { + // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen. + // Wir versuchen hier, das neue zu setzen (sofern eingegeben). + if ( empty($pw1) ) + { + } + elseif ( $pw1 != $pw2 ) + { + $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH'); + $this->addValidationError('password2',''); + } + elseif ( strlen($pw2) < $conf['security']['password']['min_length'] ) + { + $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length'])); + $this->addValidationError('password2',''); + } + else + { + // Kennw�rter identisch und lang genug. + $user->setPassword( $pw1,true ); + + // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen. + $ok = true; + $this->mustChangePassword = false; + $user->mustChangePassword = false; + } + } + + // Falls Login erfolgreich + if ( $ok ) + { + // Login war erfolgreich! + $user->load(); + $user->setCurrent(); + Logger::info( 'login successful' ); + + return true; + } + else + { + Logger::info( "login for user $name failed" ); + + return false; + } + } + + + + /** + * Anzeigen der Loginmaske. + * + * Es wird nur die Loginmaske angezeigt. + * Hier nie "304 not modified" setzen, da sonst keine + * Login-Fehlermeldung erscheinen kann + */ + function loginView() + { + global $conf; + $sso = $conf['security']['sso']; + $ssl = $conf['security']['ssl']; + + $ssl_trust = false; + $ssl_user_var = ''; + extract( $ssl, EXTR_PREFIX_ALL, 'ssl' ); + + if ( $sso['enable'] ) + { + $authid = $this->getRequestVar( $sso['auth_param_name']); + + if ( empty( $authid) ) + Http::notAuthorized( 'no authorization data (no auth-id)'); + + if ( $sso['auth_param_serialized'] ) + $authid = unserialize( $authid ); + + $purl = parse_url($sso['url']); + // Verbindung zu URL herstellen. + $errno=0; $errstr=''; + $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30); + if ( !$fp ) + { + echo "Connection failed: $errstr ($errno)"; + } + else + { + $http_get = $purl['path']; + if ( !empty($purl['query']) ) + $http_get .= '?'.$purl['query']; + + $header = array(); + + $header[] = "GET $http_get HTTP/1.0"; + $header[] ="Host: ".$purl['host']; + $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)"; + $header[] = "Connection: Close"; + + if ( $sso['cookie'] ) + { + $cookie = 'Cookie: '; + if ( is_array($authid)) + foreach( $authid as $cookiename=>$cookievalue) + $cookie .= $cookiename.'='.$cookievalue."; "; + else + $cookie .= $sso['cookie_name'].'='.$authid; + + $header[] = $cookie; + } + +// Html::debug($header); + fputs ($fp, implode("\r\n",$header)."\r\n\r\n"); + + $inhalt=array(); + while (!feof($fp)) { + $inhalt[] = fgets($fp,128); + } + fclose($fp); + + $html = implode('',$inhalt); +// Html::debug($html); + if ( !preg_match($sso['expect_regexp'],$html) ) + Http::notAuthorized('auth failed'); + $treffer=0; + if ( !preg_match($sso['username_regexp'],$html,$treffer) ) + Http::notAuthorized('auth failed'); + if ( !isset($treffer[1]) ) + Http::notAuthorized('authorization failed'); + + $username = $treffer[1]; + +// Html::debug( $treffer ); + $this->setDefaultDb(); + + $user = User::loadWithName( $username ); + + if ( ! $user->isValid( )) + Http::notAuthorized('authorization failed: user not found: '.$username); + + $user->setCurrent(); + + $this->callSubAction('show'); + } + } + + elseif ( $ssl_trust ) + { + if ( empty($ssl_user_var) ) + Http::serverError( 'please set environment variable name in ssl-configuration.' ); + + $username = getenv( $ssl_user_var ); + + if ( empty($username) ) + Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' ); + + $this->setDefaultDb(); + + $user = User::loadWithName( $username ); + + if ( !$user->isValid() ) + Http::serverError( 'unknown username: '.$username ); + + $user->setCurrent(); + + $this->callSubAction('show'); + } + + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = array('key' =>$dbname, + 'value'=>Text::maxLength($dbconf['comment']), + 'title'=>$dbconf['comment'].' ('.$dbconf['host'].')' ); + } + + $openid_provider = array(); + foreach( explode(',',$conf['security']['openid']['provider']) as $provider ) + $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name'); + $this->setTemplateVar('openid_providers',$openid_provider); + $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity')); + //$this->setTemplateVar('openid_provider','identity'); + + + if ( empty($dbids) ) + $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN); + + if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) ) + $this->setTemplateVar('login_name',$_COOKIE['or_username']); + + if ( !isset($this->templateVars['login_name']) ) + $this->setTemplateVar('login_name',@$conf['security']['default']['username']); + + if ( $this->templateVars['login_name']== @$conf['security']['default']['username']) + $this->setTemplateVar('login_password',@$conf['security']['default']['password']); + + $this->setTemplateVar( 'dbids',$dbids ); + + $db = Session::getDatabase(); + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + elseif( isset($this->templateVars['actid']) ) + ; + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + + + // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen. + $ssl_user_var = $conf['security']['ssl']['user_var']; + if ( !empty($ssl_user_var) ) + { + $username = getenv( $ssl_user_var ); + + if ( empty($username) ) + { + echo lang('ERROR_LOGIN_BROKEN_SSL_CERT'); + Logger::warn( 'no username in SSL client certificate (var='.$ssl_user_var.').' ); + exit; + } + + // Benutzername ist in Eingabemaske unveränderlich + $this->setTemplateVar('force_username',$username); + } + + $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) ); + $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) ); + + $this->setTemplateVar('register' ,$conf['login' ]['register' ]); + $this->setTemplateVar('send_password',$conf['login' ]['send_password']); + } + + + + /** + * Erzeugt ein Projekt-Auswahlmenue. + */ + function projectmenu() + { + $user = Session::getUser(); + + if ( $user->mustChangePassword ) + { + $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' ); + $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern. + } + + + // Diese Seite gilt pro Sitzung. + $this->lastModified( $user->loginDate ); + + // Projekte ermitteln + $projects = $user->projects; + + $list = array(); + + foreach( $projects as $id=>$name ) + { + $p = array(); + $p['url' ] = Html::url('tree','load',0,array('projectid'=>$id,'target'=>'tree')); + $p['name'] = $name; + $p['id' ] = $id; + + $tmpProject = new Project( $id ); + $p['defaultmodelid' ] = $tmpProject->getDefaultModelId(); + $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId(); + $p['models' ] = $tmpProject->getModels(); + $p['languages' ] = $tmpProject->getLanguages(); + + $list[] = $p; + } + + $this->setTemplateVar('projects',$list); + + if ( empty($list) ) + { + // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben. + if ( $this->userIsAdmin() ) + // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen + $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + else + // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf�gung steht + $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + } + + $this->metaValues(); + } + + + + /** + * Erzeugt eine Anwendungsliste. + */ + function applications() + { + global $conf; + + // Diese Seite gilt pro Sitzung. + $user = Session::getUser(); + $userGroups = $user->getGroups(); + $this->lastModified( $user->loginDate ); + + // Applikationen ermitteln + $list = array(); + foreach( $conf['applications'] as $id=>$app ) + { + if ( !is_array($app) ) + continue; + + if ( isset($app['group']) ) + if ( !in_array($app['group'],$userGroups) ) + continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden. + + $p = array(); + $p['url'] = $app['url']; + $p['description'] = @$app['description']; + if ( isset($app['param']) ) + { + $p['url'] .= strpos($p['url'],'?')!==false?'&':'?'; + $p['url'] .= $app['param'].'='.session_id(); + } + $p['name'] = $app['name']; + + $list[] = $p; + } + + + $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> + * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br> + * Kapitel "4.4. check_authentication"<br> + * <br> + * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br> + * Wir befinden uns nun im darauf folgenden Request des Browsers.<br> + * <br> + * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der + * Benutzer angemeldet.<br> + */ + function openid() + { + global $conf; + $openId = Session::get('openid'); + + if ( !$openId->checkAuthentication() ) + { + $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + //Html::debug($openId); + + // Anmeldung wurde mit "is_valid:true" best�tigt. + // Der Benutzer ist jetzt eingeloggt. + $username = $openId->getUserFromIdentiy(); + + if ( empty($username) ) + { + // Es konnte kein Benutzername ermittelt werden. + $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + $user = User::loadWithName( $username ); + + if ( $user->userid <=0) + { + // Benutzer ist (noch) nicht vorhanden. + if ( $conf['security']['openid']['add']) // Anlegen? + { + $user->name = $username; + $user->add(); + + $user->mail = $openId->info['email']; + $user->fullname = $openId->info['fullname']; + $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht) + } + else + { + // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht). + $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + } + else + { + // Benutzer ist bereits vorhanden. + if ( @$conf['security']['openid']['update_user']) + { + $user->fullname = $openId->info['fullname']; + $user->mail = $openId->info['email']; + $user->save(); + } + } + + $user->setCurrent(); // Benutzer ist jetzt in der Sitzung. + } + + + /** + * Login. + */ + function loginAction() + { + global $conf; + + $this->checkForDb(); + Session::setUser(''); + + if ( $conf['login']['nologin'] ) + Http::notAuthorized('login disabled'); + + $openid_user = $this->getRequestVar('openid_url' ); + $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM); + $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM); + $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM); + $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM); + + // Cookie setzen + setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) ); + + // Login mit Open-Id. + if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) ) + { + $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user); + + if ( ! $openId->login() ) + { + $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) ); + $this->addValidationError('openid_url',''); + $this->callSubAction('showlogin'); + return; + } + + Session::set('openid',$openId); + $openId->redirect(); + die('Unreachable Code'); + } + + + // Ermitteln, ob der Baum angezeigt werden soll + // Ist die Breite zu klein, dann wird der Baum nicht angezeigt + Session::set('showtree',intval($this->getRequestVar('screenwidth')) > $conf['interface']['min_width'] ); + + $loginOk = $this->checkLogin( $loginName, + $loginPassword, + $newPassword1, + $newPassword2 ); + + if ( !$loginOk ) + { + // Anmeldung nicht erfolgreich + sleep(3); + + if ( $this->mustChangePassword ) + { + // Anmeldung gescheitert, Benutzer muss Kennwort �ndern. + $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' ); + $this->addValidationError('password1',''); + $this->addValidationError('password2',''); + } + else + { + // Anmeldung gescheitert. + $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) ); + $this->addValidationError('login_name' ,''); + $this->addValidationError('login_password',''); + } + + Logger::debug("Login failed for user '$loginName'"); + + $this->callSubAction('login'); + return; + } + else + { + Logger::debug("Login successful for user '$loginName'"); + + // Anmeldung erfolgreich. + if ( config('security','renew_session_login') ) + $this->recreateSession(); + + $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 ( Object::available($objectid)) + { + $object = new Object($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->refresh(); // Benutzer ist angemeldet: Andere Views könnte das interessieren. + } + + + /** + * Benutzer meldet sich ab. + */ + function logoutAction() + { + global $conf; + + $user = Session::getUser(); + 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(); + + session_unset(); + + if ( @$conf['theme']['compiler']['compile_at_logout'] ) + { + foreach( $conf['action'] as $actionName => $actionConfig ) + { + foreach( $actionConfig as $subActionName=>$subaction ) + { + if ( is_array($subaction) && + !isset($subaction['goto' ]) && + !isset($subaction['direct']) && + !isset($subaction['action']) && + !isset($subaction['alias' ]) && + $subActionName != 'menu' ) + { + $engine = new TemplateEngine(); + $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName); + } + } + } + } + + // Umleiten auf eine definierte URL.s + $redirect_url = @$conf['security']['logout']['redirect_url']; + + if ( !empty($redirect_url) ) + { + header('Location: '.$redirect_url); + exit; + } + } + + + + /** + * Benutzer meldet sich ab. + */ + function logoutView() + { + } + + + /** + * 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 + * die Benutzerinformationen des angemeldeten Benutzers aus dieser + * Anwendung auslesen k�nnen. + */ + function userinfo() + { + $user = Session::getUser(); + $info = array('username' => $user->name, + 'fullname' => $user->fullname, + 'mail' => $user->mail, + 'telephone' => $user->tel, + 'style' => $user->style, + 'admin' => $user->isAdmin?'true':'false', + 'ldap' => $user->ldap_dn, + 'groups' => implode(',',$user->getGroups()), + 'description'=> $user->desc + ); + + // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die + // Informationen per XML aus. + if ( $this->hasRequestVar('xml') ) + { + header('Content-Type: text/xml'); + echo '<userinfo>'; + foreach( $info as $n=>$i ) + echo '<'.$n.'>'.$i.'</'.$n.'>'."\n"; + echo '</userinfo>'; + + } + + // Sonst normale Textausgabe im INI-Datei-Format. + else + { + header('Content-Type: text/plain'); + foreach( $info as $n=>$i ) + echo $n.'="'.$i."\"\n"; + } + + exit; // Fertig. + } + + + function project() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) ); + + Session::setUser( $user ); + } + + + function object() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) ); + + Session::setUser( $user ); + } + + + function language() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) ); + } + + + function model() + { + $user = Session::getUser(); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } + + $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) ); + + $user = Session::getUser(); + } + + + /** + * Auswerten der Request-Variablen. + * + * @param Array $add + */ + 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 + Http::serverError('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]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) ) + { + $object = new Object( $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]) ) + { + $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 ); + } + + $object = Session::getObject(); + if ( is_object($object) && $object->projectid == $project->projectid ) + { + $object->objectLoadRaw(); + Session::setObject( $object ); + } + else + { + Session::setObject( '' ); + } + } + 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::available($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( '' ); + } + } + } + + + function showtree() + { + Session::set('showtree',true ); + } + + + function hidetree() + { + Session::set('showtree',false ); + } + + + function switchuser() + { + $user = Session::getUser(); + + if ( ! $user->isAdmin ) + Http::notAuthorized(""); + + $this->recreateSession(); + + $newUser = new User( $this->getRequestId() ); + $newUser->load(); + + $newUser->setCurrent(); + } + + + function show() + { + global $conf; + global $PHP_AUTH_USER; + global $PHP_AUTH_PW; + + $user = Session::getUser(); + // Gast-Login + if ( ! is_object($user) ) + { + if ( $conf['security']['guest']['enable'] ) + { + $this->setDefaultDb(); + $username = $conf['security']['guest']['user']; + $user = User::loadWithName($username); + if ( $user->userid > 0 ) + $user->setCurrent(); + else + { + Logger::warn('Guest login failed, user not found: '.$username); + $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) ); + $user = null; + } + } + } + + if ( ! is_object($user) ) + { + switch( $conf['security']['login']['type'] ) + { + + // Authorization ueber HTTP + // + case 'http': + $ok = false; + + if ( isset($_SERVER['PHP_AUTH_USER']) ) + { + $this->setDefaultDb(); + $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] ); + } + + if ( ! $ok ) + { + header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' ); + header( 'HTTP/1.0 401 Unauthorized' ); + echo 'Authorization Required!'; + exit; + } + break; + + case 'form': + // Benutzer ist nicht angemeldet + $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske + return; + break; + + default: + Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' ); + } + } + + if ( $user->mustChangePassword ) + { + $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' ); + $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern. + } + + // 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 Object( $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(); + } + + + + 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. + */ + function register() + { + + } + + + /** + * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen. + * Maske anzeigen, damit Benuter Registriercode anzeigen kann. + */ + function registercode() + { + $email_address = $this->getRequestVar('mail','mail'); + + if ( ! Mail::checkAddress($email_address) ) + { + $this->addValidationError('mail'); + $this->setTemplateVar('mail',$email_address); + $this->callSubAction('register'); + return; + } + + + srand ((double)microtime()*1000003); + $registerCode = rand(); + + Session::set('registerCode',$registerCode ); + + // E-Mail and die eingegebene Adresse verschicken + $mail = new Mail($email_address, + 'register_commit_code','register_commit_code'); + $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable + + if ( $mail->send() ) + { + $this->addNotice('','','mail_sent',OR_NOTICE_OK); + } + else + { + $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); + $this->callSubAction('register'); + return; + } + } + + + + function registeruserdata() + { + global $conf; + + Session::set('registerMail',$this->getRequestVar('mail') ); + // TODO: Attribut "Password" abfragen + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = $dbconf['comment']; + } + + $this->setTemplateVar( 'dbids',$dbids ); + + $db = Session::getDatabase(); + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + } + + + /** + * Benutzerregistierung. + * Benutzer hat Best�tigungscode erhalten und eingegeben. + */ + function registercommit() + { + global $conf; + $this->checkForDb(); + + $origRegisterCode = Session::get('registerCode'); + $inputRegisterCode = $this->getRequestVar('code'); + + if ( $origRegisterCode != $inputRegisterCode ) + { + // Best�tigungscode stimmt nicht. + $this->addValidationError('code','code_not_match'); + $this->callSubAction('registeruserdata'); + return; + } + + // Best�tigungscode stimmt �berein. + // Neuen Benutzer anlegen. + + if ( !$this->hasRequestVar('username') ) + { + $this->addValidationError('username'); + $this->callSubAction('registeruserdata'); + return; + } + + $user = User::loadWithName( $this->getRequestVar('username') ); + if ( $user->isValid() ) + { + $this->addValidationError('username','USER_ALREADY_IN_DATABASE'); + $this->callSubAction('registeruserdata'); + return; + } + + if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] ) + { + $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length'])); + $this->callSubAction('registeruserdata'); + return; + } + + $newUser = new User(); + $newUser->name = $this->getRequestVar('username'); + $newUser->add(); + + $newUser->mail = Session::get('registerMail'); + $newUser->save(); + + $newUser->setPassword( $this->getRequestVar('password'),true ); + + $this->addNotice('user',$newUser->name,'user_added','ok'); + } + + + + /** + * Vergessenes Kennwort zusenden lassen. + */ + function password() + { + global $conf; + + // TODO: Attribut "Password" abfragen + foreach( $conf['database'] as $dbname=>$dbconf ) + { + if ( is_array($dbconf) && $dbconf['enabled'] ) + $dbids[$dbname] = $dbconf['comment']; + } + + $this->setTemplateVar( 'dbids',$dbids ); + + + $db = Session::getDatabase(); + + if ( is_object($db) ) + $this->setTemplateVar('actdbid',$db->id); + else + $this->setTemplateVar('actdbid',$conf['database']['default']); + + } + + + /* + function changepassword() + { + } + */ + + + /* + function setnewpassword() + { + $oldPw = $this->getRequestVar('password_old' ); + $newPw1 = $this->getRequestVar('password_new_1'); + $newPw2 = $this->getRequestVar('password_new_2'); + + if ( $newPw1 == $newPw2 ) + { + // Aktuellen Benutzer aus der Sitzung ermitteln + $user = $this->getUserFromSession(); + + // Altes Kennwort pr�fen. + $ok = $user->checkPassword( $oldPw ); + + if ( $ok ) // Altes Kennwort ist ok. + { + $user->setPassword( $newPw1 ); // Setze neues Kennwort + $user->mustChangePassword = false; + Session::setUser($user); + $this->addNotice('user',$user->name,'password_set','ok'); + } + else + { + // Altes Kennwort falsch. + $this->addNotice('user',$user->name,'password_error','error'); + } + } + else + { + // Beide neuen Kennw�rter stimmen nicht �berein + $this->addNotice('user',$user->name,'passwords_not_match','error'); + } + } + */ + + + /** + * Einen Kennwort-Anforderungscode an den Benutzer senden. + */ + function passwordcode() + { + if ( !$this->hasRequestVar('username') ) + { + $this->addValidationError('username'); + $this->callSubAction('password'); + return; + } + + $this->checkForDb(); + + $user = User::loadWithName( $this->getRequestVar("username") ); + // Html::debug($user); + if ( $user->isValid() ) + { + srand ((double)microtime()*1000003); + $code = rand(); + $this->setSessionVar("password_commit_code",$code); + + $eMail = new Mail( $user->mail,'password_commit_code' ); + $eMail->setVar('name',$user->getName()); + $eMail->setVar('code',$code); + if ( $eMail->send() ) + $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK); + else + $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error); + + } + else + { + //$this->addNotice('','user','username_not_found'); + // Trotzdem vort�uschen, eine E-Mail zu senden, damit die G�ltigkeit + // eines Benutzernamens nicht von au�en gepr�ft werden kann. + // + $this->addNotice('user',$this->getRequestVar("username"),'mail_sent'); + sleep(5); + } + + $this->setSessionVar("password_commit_name",$user->name); + } + + + + /** + * Anzeige Formular zum Eingeben des Kennwort-Codes. + * + */ + function passwordinputcode() + { + + } + + + /** + * Neues Kennwort erzeugen und dem Benutzer zusenden. + */ + function passwordcommit() + { + $username = $this->getSessionVar("password_commit_name"); + + if ( $this->getRequestVar("code")=='' || + $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") ) + { + $this->addValidationError('code','PASSWORDCODE_NOT_MATCH'); + $this->callSubAction('passwordinputcode'); + return; + } + + $user = User::loadWithName( $username ); + + if ( !$user->isValid() ) + { + // Benutzer konnte nicht geladen werden. + $this->addNotice('user',$username,'error',OR_NOTICE_ERROR); + return; + } + + $newPw = User::createPassword(); // Neues Kennwort erzeugen. + + $eMail = new Mail( $user->mail,'password_new' ); + $eMail->setVar('name' ,$user->getName()); + $eMail->setVar('password',$newPw ); + + if ( $eMail->send() ) + { + $user->setPassword( $newPw, false ); // Kennwort muss beim n�. Login ge�ndert werden. + $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK); + } + else + { + // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den + // Code per E-Mail erhalten hat. + $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error); + } + } + + + /** + * Erzeugt eine neue Sitzung. + */ + function recreateSession() + { + + // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht. + if ( version_compare(phpversion(),"4.3.2","<") ) + { + $randlen = 32; + $randval = "0123456789abcdefghijklmnopqrstuvwxyz"; + $newid = ""; + for ($i = 1; $i <= $randlen; $i++) + { + $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1); + } + session_id( $newid ); + } + elseif( version_compare(phpversion(),"4.3.2","==") ) + { + session_regenerate_id(); + + // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt. + if ( ini_get("session.use_cookies") ) + setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" ); + } + elseif ( version_compare(phpversion(),"5.1.0",">") ) + { + session_regenerate_id(true); + } + else + { + // 5.1.0 > PHP >= 4.3.3 + } + } + +} + + +?>+ \ No newline at end of file diff --git a/action/StartAction.ini.php b/action/StartAction.ini.php @@ -0,0 +1,21 @@ + +admin=false + +[default] +goto=projectmenu + +[applications] +menu=menu + +[userinfo] +direct=true + +[administration] +menu=menu + +[projectmenu] +menu=menu +clear=tree + +[menu] +menu=projectmenu,applications diff --git a/action/StatusAction.class.php b/action/StatusAction.class.php @@ -0,0 +1,77 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// OpenRat Content Management System +// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- + + +/** + * Action-Klasse fuer die Statusleiste + * @author $Author$ + * @version $Revision$ + * @package openrat.actions + */ + +class StatusAction extends Action +{ + /** + */ + function show() + { + global $conf; + $metaList = array(); + + $user = Session::getUser(); + if ( is_object($user) ) + { + // Projekte ermitteln