commit aae322aca73c407ac4f7b02e674d6f701f47cf2e
parent 198e275165c6e5cfb0c41d7b8d4eec795af8d143
Author: dankert <devnull@localhost>
Date: Mon, 27 Dec 2010 23:47:00 +0100
Action-Klassen verschieben: actionClasses -> action
Diffstat:
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( ' » ',$names );
+ $folders[ $id ] .= ' » ';
+ }
+ $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('&','&',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( ' » ',$f->parentObjectNames(false,true) );
+ $objects[ $oid ] .= ' » '.$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( ' » ',$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><$1</strong>$2<strong>></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( ' » ',$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
+ $projects = $user->projects;
+ $this->setTemplateVar('projects',$projects);
+ }
+
+ $project = Session::getProject();
+ if ( is_object($project) )
+ {
+ if ( $project->projectid > 0 )
+ {
+ $this->setTemplateVar('projectid',$project->projectid);
+ $this->setTemplateVar('languages',$project->getLanguages());
+ $language = Session::getProjectLanguage();
+ if ( is_object($language) )
+ $this->setTemplateVar('languageid',$language->languageid);
+ $this->setTemplateVar('models' ,$project->getModels() );
+ $model = Session::getProjectModel();
+ if ( is_object($model) )
+ $this->setTemplateVar('modelid',$model->modelid);
+
+ // TODO: Nur Projekt-Admins
+ $this->setTemplateVar('templates',$project->getTemplates());
+ }
+ else
+ {
+ $this->setTemplateVar('users' ,User::listAll() );
+ $this->setTemplateVar('groups',Group::getAll() );
+ }
+ }
+
+ }
+
+}
+
+
+?>+
\ No newline at end of file
diff --git a/action/StatusAction.ini.php b/action/StatusAction.ini.php
@@ -0,0 +1,7 @@
+
+admin=false
+
+[default]
+goto=show
+
+[show]
diff --git a/action/TemplateAction.class.php b/action/TemplateAction.class.php
@@ -0,0 +1,690 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2009 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; 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 Seitenvorlage.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+
+class TemplateAction extends Action
+{
+ var $defaultSubAction = 'show';
+ var $template;
+ var $element;
+
+
+ function TemplateAction()
+ {
+ if ( $this->getRequestId() != 0 )
+ {
+ $this->template = new Template( $this->getRequestId() );
+ $this->template->load();
+ $this->setTemplateVar( 'templateid',$this->template->templateid );
+ }
+ else
+ {
+ $this->defaultSubAction = 'listing';
+ }
+
+ if ( intval($this->getRequestVar('elementid')) != 0 )
+ {
+ $this->element = new Element( $this->getRequestVar('elementid') );
+ $this->element->load();
+ $this->setTemplateVar( 'elementid',$this->element->elementid );
+ }
+ }
+
+
+ function savesrc()
+ {
+ // Speichern des Quelltextes
+ //
+ $text = $this->getRequestVar('src','raw');
+
+ foreach( $this->template->getElementNames() as $elid=>$elname )
+ {
+ $text = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}',$text );
+ $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFEMPTY:' .$elid.':BEGIN}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFEMPTY:' .$elid.':END}}' ,$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFNOTEMPTY:'.$elid.':BEGIN}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFNOTEMPTY:'.$elid.':END}}' ,$text );
+ }
+
+ $this->template->src = $text;
+ $this->template->save();
+ $this->template->load();
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+
+ function srcaddelement()
+ {
+ $text = $this->template->src;
+
+ switch( $this->getRequestVar('type') )
+ {
+ case 'addelement':
+ $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
+ break;
+
+ case 'addicon':
+ $text .= "\n".'{{->'.$this->getRequestVar('writable_elementid').'}}';
+ break;
+
+ case 'addifempty':
+ $text .= "\n".'{{IFEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
+ break;
+
+ case 'addifnotempty':
+ $text .= "\n".'{{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
+ break;
+
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('srcelement');
+ return;
+ }
+
+ $this->template->src = $text;
+
+ $this->template->save();
+ $this->template->load();
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+ // Speichern der Template-Eigenschaftens
+ //
+ function savename()
+ {
+
+ if ($this->getRequestVar('name') == "")
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('name');
+ return;
+ }
+ else
+ {
+ $this->template->name = $this->getRequestVar('name');
+ $this->template->save();
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+ }
+
+
+ // Speichern der Template-Eigenschaftens
+ //
+ function delete()
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->template->delete();
+ $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN);
+ }
+ }
+
+
+ /**
+ * Entfernen der Vorlage
+ */
+ function remove()
+ {
+ $this->setTemplateVar('name',$this->template->name);
+ }
+
+
+ /**
+ * Anzeigen aller Seiten der Vorlage.
+ */
+ function pages()
+ {
+ $pages = array();
+ $pageids = $this->template->getDependentObjectIds();
+
+ foreach( $pageids as $pageid )
+ {
+ $page = new Page($pageid);
+ $page->load();
+
+ $pages[$pageid] = $page->name;
+ }
+
+ $this->setTemplateVar('pages',$pages);
+ }
+
+
+ // Speichern der Dateiendung
+ //
+ function saveextension()
+ {
+ if ( $this->getRequestVar('type') == "list" )
+ $this->template->extension = $this->getRequestVar('extension');
+ else
+ $this->template->extension = $this->getRequestVar('extensiontext');
+
+ $this->template->save();
+ $this->addNotice('template',$this->template->name,'SAVED','ok');
+ }
+
+
+ function addel()
+ {
+ // Die verschiedenen Element-Typen
+ $types = array();
+
+ foreach( Element::getAvailableTypes() as $t )
+ {
+ $types[ $t ] = 'EL_'.$t;
+ }
+
+ // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
+ if ( !$this->userIsAdmin() )
+ unset( $types['code'] );
+
+ $this->setTemplateVar('types',$types);
+ }
+
+
+
+ /*
+ * Neues Element hinzufuegen.
+ */
+ function addelement()
+ {
+
+ $name = $this->getRequestVar('name',OR_FILTER_ALPHANUM);
+ if ( empty($name) )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('addel');
+ return;
+ }
+
+ $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('type') );
+ $this->setTemplateVar('tree_refresh',true);
+
+ if ( $this->hasRequestVar('addtotemplate') )
+ {
+ $elnames = $this->template->getElementNames();
+ $elid = array_search($name,$elnames);
+ $this->template->src .= "\n".'{{'.$elid.'}}';
+ $this->template->save();
+ }
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+ /**
+ * Vorlage hinzuf�gen.
+ */
+ function add()
+ {
+ $this->setTemplateVar( 'templates',Template::getAll() );
+
+ $examples = array();
+ $dir = opendir( 'examples/templates');
+ while( $file = readdir($dir) )
+ {
+ if ( substr($file,0,1) != '.')
+ {
+ $examples[$file] = $file;
+ }
+ }
+
+ $this->setTemplateVar( 'examples',$examples );
+ }
+
+
+
+ function addtemplate()
+ {
+ // Hinzufuegen eines Templates
+ if ( $this->getRequestVar('name') == '' )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ return;
+ }
+
+ // Hinzufuegen eines Templates
+ switch( $this->getRequestVar('type') )
+ {
+ case 'empty':
+
+ $template = new Template();
+ $template->add( $this->getRequestVar('name') );
+ $this->addNotice('template',$template->name,'ADDED','ok');
+ break;
+
+ case 'copy':
+
+ $copy_templateid = intval($this->getRequestVar('templateid') );
+
+ if ( $copy_templateid == 0 )
+ {
+ $this->addValidationError('templateid');
+ $this->callSubAction('add');
+ return;
+ }
+
+ $template = new Template();
+ $template->add( $this->getRequestVar('name') );
+ $this->addNotice('template',$template->name,'ADDED','ok');
+
+ $copy_template = new Template( $copy_templateid );
+ $copy_template->load();
+ foreach( $copy_template->getElements() as $element )
+ {
+ $element->load();
+ $element->templateid = $template->templateid;
+ $element->add();
+ $element->save();
+ }
+
+ $this->addNotice('template',$copy_template->name,'COPIED','ok');
+
+ break;
+
+ case 'example':
+
+ $template = new Template();
+
+ $model = Session::getProjectModel();
+ $template->modelid = $model->modelid;
+
+ $template->add( $this->getRequestVar('name') );
+
+ $example = parse_ini_file('examples/templates/'.$this->getRequestVar('example'),true);
+
+ foreach( $example as $exampleKey=>$exampleElement )
+ {
+ if ( !is_array($exampleElement) )
+ {
+ $template->$exampleKey = $exampleElement;
+ }
+ else
+ {
+ $element = new Element();
+ $element->templateid = $template->templateid;
+ $element->name = $exampleKey;
+ $element->writable = true;
+ $element->add();
+
+ foreach( $exampleElement as $ePropName=>$ePropValue)
+ $element->$ePropName = $ePropValue;
+
+ $element->defaultText = str_replace(';',"\n",$element->defaultText);
+ $element->save();
+// Html::debug($element,"Element");
+ }
+ }
+// Html::debug($template,"Template");
+ $template->name = $this->getRequestVar('name');
+ $template->src = str_replace(';',"\n",$template->src);
+
+ foreach( $template->getElementNames() as $elid=>$elname )
+ {
+ $template->src = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}' ,$template->src );
+ $template->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$template->src );
+ }
+
+ $template->save();
+ $this->addNotice('template',$template->name,'ADDED','ok');
+
+ break;
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('add');
+ return;
+ }
+
+
+ $this->setTemplateVar('tree_refresh',true);
+ }
+
+
+ function prop()
+ {
+ }
+
+
+
+ /**
+ * Eigenschaften einer Vorlage anzeigen
+ */
+ function name()
+ {
+ $this->setTemplateVar('name' ,$this->template->name );
+ $this->setTemplateVar('extension',$this->template->extension );
+ $this->setTemplateVar('mime_type',$this->template->mimeType() );
+ }
+
+
+
+ /**
+ * Eigenschaften einer Vorlage anzeigen
+ */
+ function extension()
+ {
+
+ global $conf;
+ $mime_types = array();
+ foreach( $conf['mime-types'] as $ext=>$type )
+ $mime_types[$ext] = $ext.' - '.$type;
+
+ $this->setTemplateVar('mime_types',$mime_types);
+
+ $this->setTemplateVar('extension' ,$this->template->extension);
+ $this->setTemplateVar('extensiontext',$this->template->extension);
+
+ if ( isset($mime_types[$this->template->extension]) )
+ $this->setTemplateVar('type','list');
+ else
+ $this->setTemplateVar('type','text');
+ }
+
+
+
+ /**
+ * Voransicht einer Vorlage
+ */
+ function show()
+ {
+ $text = $this->template->src;
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+ $url = Html::url( 'element','edit',$this->template->templateid,array('elementid'=>$elid));
+
+ $text = str_replace('{{'.$elid.'}}',$element->name,
+ $text );
+ $text = str_replace('{{->'.$elid.'}}','',
+ $text );
+
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}','',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}','',
+ $text );
+
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}','',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}','',
+ $text );
+
+ unset( $element );
+ }
+
+ echo $text;
+
+ exit();
+ }
+
+
+ /**
+ * Bearbeiten einer Vorlage
+ */
+ function edit()
+ {
+ $text = htmlentities( $this->template->src );
+ $text = str_replace("\n",'<br/>',$text);
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+ $url = Html::url( 'element','name',$elid );
+
+ $text = str_replace('{{'.$elid.'}}',
+ '<a href="'.$url.'" class="el_'.
+ $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
+ $element->name.'}}</a>',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '<a href="'.$url.'" class="el_'.
+ $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
+ $element->name.'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ unset( $element );
+ }
+
+ $this->setTemplateVar('text',$text);
+ }
+
+
+ // Anzeigen der Template-Elemente
+ //
+ function el()
+ {
+ global $conf_php;
+ $list = array();
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $list[$elid] = array();
+ $list[$elid]['url' ] = Html::url('element','name',$elid);
+ $list[$elid]['name'] = $element->name;
+ $list[$elid]['desc'] = $element->desc;
+ $list[$elid]['type'] = $element->type;
+
+ unset( $element );
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+
+ function srcelement()
+ {
+ $elements = array();
+ $writable_elements = array();
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $elements[$elid] = $element->name;
+
+ if ( $element->isWritable() )
+ $writable_elements[$elid] = $element->name;
+ }
+
+ $this->setTemplateVar('elements' ,$elements );
+ $this->setTemplateVar('writable_elements',$writable_elements);
+ }
+
+
+
+ /**
+ * Anzeigen des Template-Quellcodes
+ */
+ function src()
+ {
+ if ( $this->isEditMode() )
+ {
+ $text = $this->template->src;
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $text = str_replace('{{'.$elid.'}}',
+ '{{'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '{{->'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
+ }
+
+ $this->setTemplateVar( 'src',$text );
+ }
+ else
+ {
+ $text = htmlentities( $this->template->src );
+ $text = str_replace("\n",'<br/>',$text);
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+ $url = Html::url( 'element','name',$elid );
+
+ $text = str_replace('{{'.$elid.'}}',
+ '<a href="'.$url.'" class="el_'.
+ $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
+ $element->name.'}}</a>',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '<a href="'.$url.'" class="el_'.
+ $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
+ $element->name.'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ unset( $element );
+ }
+
+ $this->setTemplateVar('src',$text);
+ }
+
+ }
+
+
+ // Anzeigen aller Templates
+ //
+ function listing()
+ {
+ global $conf_php;
+
+ $list = array();
+
+ foreach( Template::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['name'] = $name;
+ $list[$id]['url' ] = Html::url('main','template',$id,array(REQ_PARAM_TARGETSUBACTION=>'el'));
+ }
+
+// $var['templatemodelid'] = htmlentities( $id );
+// $var['text'] = htmlentities( $text );
+ $this->setTemplateVar('templates',$list);
+ }
+
+
+ /**
+ * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
+ *
+ * @see actionClasses/Action#checkMenu($name)
+ */
+ function checkMenu( $menu ) {
+
+ switch( $menu)
+ {
+ case 'srcelement':
+ // Platzhalter nur hinzufuegbar, wenn es welche gibt.
+ return is_object($this->template) &&
+ (count($this->template->getElementIds()) > 0);
+
+ case 'remove':
+ // Entfernen von Templates nur dann erlaubt, wenn keine Seiten auf diesem Template basieren.
+ return is_object($this->template) &&
+ (count($this->template->getDependentObjectIds()) == 0);
+
+ case 'pages':
+ // Anzeige von Seiten nur dann sinnvoll, wenn es auch Seiten gibt.
+ return is_object($this->template) &&
+ (count($this->template->getDependentObjectIds()) > 0);
+
+ case 'add':
+ case 'addel':
+ return !readonly();
+
+ default:
+ return true;
+
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/action/TemplateAction.ini.php b/action/TemplateAction.ini.php
@@ -0,0 +1,70 @@
+[default]
+goto=listing
+
+[listing]
+menu=listing
+
+[add]
+menu=listing
+target=addtemplate
+
+[addtemplate]
+goto=listing
+
+[show]
+direct=true
+
+[prop]
+goto=name
+
+[el]
+menu=el
+
+[addel]
+menu=el
+target=addelement
+
+[addelement]
+goto=el
+
+[src]
+menu=edit
+target=savesrc
+editable=true
+
+[srcelement]
+menu=edit
+target=srcaddelement
+
+[srcaddelement]
+goto=src
+
+[savesrc]
+goto=src
+
+[name]
+menu=prop
+target=savename
+
+[savename]
+goto=name
+
+[saveextension]
+goto=name
+
+[extension]
+menu=prop
+target=saveextension
+
+[remove]
+menu=prop
+target=delete
+
+[delete]
+goto=listing
+
+[pages]
+menu=prop
+
+[menu]
+menu=listing,name,extension,pages,remove,el,src+
\ No newline at end of file
diff --git a/action/TitleAction.class.php b/action/TitleAction.class.php
@@ -0,0 +1,95 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2009 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.
+
+
+/**
+ * Actionklasse zum Anzeigen der Titelleiste.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class TitleAction extends Action
+{
+ /**
+ * Fuellen der Variablen und Anzeigen der Titelleiste
+ */
+ function show()
+ {
+ $this->setTemplateVar('buildinfo',OR_TITLE.' '.OR_VERSION.' - build '.config('build','build') );
+
+ $db = Session::getDatabase();
+ $this->setTemplateVar('dbname',$db->conf['comment'].(readonly()?' ('.lang('readonly').')':''));
+
+ $databases = array();
+ global $conf;
+ foreach( $conf['database'] as $dbid=>$dbconf )
+ if ( $dbconf['enabled'])
+ $databases[$dbid] = $dbconf['comment'];
+ $this->setTemplateVar('databases',$databases);
+
+ $user = Session::getUser();
+ $this->setTemplateVar('username' ,$user->name );
+ $this->setTemplateVar('userfullname',$user->fullname);
+
+ $project = Session::getProject();
+ if ( is_object($project) )
+ {
+ $this->setTemplateVar('projectname',$project->name);
+ $this->setTemplateVar('projects' ,Project::getAll() );
+ }
+
+
+
+ $language = Session::getProjectLanguage();
+ if ( is_object($language) )
+ {
+ $this->setTemplateVar('languagename',$language->name);
+ $this->setTemplateVar('languages',Language::getAll() );
+ }
+
+ $model = Session::getProjectModel();
+ if ( is_object($model) )
+ {
+ $this->setTemplateVar('modelname',$model->name);
+ $this->setTemplateVar('models' ,Model::getAll() );
+ }
+
+ // Urls zum Benutzerprofil und zum Abmelden
+ //$this->setTemplateVar('profile_url',Html::url( 'profile' ));
+ //$this->setTemplateVar('logout_url' ,Html::url( 'index','logout' ));
+
+ if ( Session::get('showtree') )
+ {
+ $this->setTemplateVar('showtree_url' ,Html::url('index','hidetree') );
+ $this->setTemplateVar('showtree_text',lang('HIDETREE') );
+ }
+ else
+ {
+ $this->setTemplateVar('showtree_url' ,Html::url('index','showtree') );
+ $this->setTemplateVar('showtree_text',lang('SHOWTREE') );
+ }
+
+ if ( config('interface','session','auto_extend') )
+ {
+ $this->setTemplateVar('refresh_url' ,Html::url('title','show') );
+ $this->setTemplateVar('refresh_timeout',ini_get('session.gc_maxlifetime')-60 );
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/action/TitleAction.ini.php b/action/TitleAction.ini.php
@@ -0,0 +1,5 @@
+
+[default]
+goto=show
+
+[show]+
\ No newline at end of file
diff --git a/action/TransferAction.class.php b/action/TransferAction.class.php
@@ -0,0 +1,241 @@
+<?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.5 2004-12-26 20:20:57 dankert
+// Bei erstem Aufruf Fehlermeldung vermeiden
+//
+// Revision 1.4 2004/11/28 23:55:36 dankert
+// addNotice()
+//
+// Revision 1.3 2004/05/02 14:49:37 dankert
+// Einf?gen package-name (@package)
+//
+// Revision 1.2 2004/04/24 20:30:23 dankert
+// addslashes() entfernt
+//
+// Revision 1.1 2004/04/24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Action-Klasse fuer Dateitransfers
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class TransferAction extends Action
+{
+ var $defaultSubAction = 'import';
+
+
+ function TransferAction()
+ {
+ }
+
+
+ function import()
+ {
+ $folderName = $this->getRequestVar('local_folder');
+
+ if ( $folderName != '' )
+ {
+ $dir = @opendir( $folderName );
+
+ if ( !is_resource( $dir ) )
+ {
+ $this->addNotice('file',"directory '$folderName' not readable",'ERROR','error');
+ }
+ else
+ {
+ while( $filename = readdir($dir) )
+ {
+ $full_filename = $folderName.'/'.$filename;
+
+ if ( $filename != "." &&
+ $filename != ".." &&
+ is_file($full_filename) )
+ {
+ $file = new File();
+ $file->parentid = intval( $this->getRequestVar('objectid') );
+ $file->parse_filename( basename($filename) );
+ $file->name = $file->filename;
+ $file->desc = '';
+
+ // Datei lesen
+ $f = fopen( $full_filename,'r' );
+ $file->value = fread($f,filesize($full_filename));
+ fclose( $f );
+
+ $file->add();
+ $this->addNotice('file',$file->name,'IMPORTED','ok');
+
+ unset( $file );
+ }
+ }
+ closedir( $dir );
+ }
+ }
+
+ $folders = array();
+
+ $folder = new Folder();
+ foreach( $folder->getAllFolders() as $objectid )
+ {
+ $f = new Folder( $objectid );
+ $folders[$objectid] = implode( FILE_SEP,$f->parentObjectNames(true,true) );
+ }
+
+ asort( $folders );
+ $this->setTemplateVar( 'folders',$folders );
+ }
+
+
+// function export()
+// {
+// if ( isset($REQ['folderid']) && isset($REQ['local_folder']) )
+// {
+// if ( !is_dir( $REQ['local_folder'] ) )
+// {
+// $var['log'] = 'directory not found';
+// }
+// else
+// {
+// $var['log'] = "reading projectfolder ...\n";
+//
+// $sql = new Sql( 'SELECT * FROM {t_file}'.
+// ' WHERE folderid={folderid}' );
+// $sql->setInt('folderid',$REQ['folderid']);
+// $files = $db->getCol( $sql->query );
+//
+// foreach( $files as $fileid )
+// {
+// $file = new File();
+// $file->fileid = $fileid;
+// $file->load();
+//
+// $full_filename = $REQ['local_folder'].'/'.$file->filename;
+// if ( $file->extension != '' )
+// $full_filename .= '.'.$file->extension;
+// $var['log'] .= "saving $full_filename\n";
+//
+// // Datei lesen
+// $f = fopen( $file->tmpfile(),'r' );
+// $value = fread($f,filesize($file->tmpfile()));
+// fclose( $f );
+//
+// // Datei lesen
+// $f = fopen( $full_filename,'w' );
+// fwrite( $f,$value );
+// fclose( $f );
+//
+// unset( $file );
+// }
+// }
+// }
+//
+//
+// $folders = array();
+//
+// $folder = new Folder();
+// foreach( $folder->getAllFolders() as $objectid )
+// {
+// $f = new Folder( $objectid );
+// $folders[$objectid] = implode( ' » ',$f->parentObjectNames(true,true) );
+// }
+//
+// asort( $folders );
+// $this->setTemplateVar( 'folders',$folders );
+//
+//
+// $this->forward( 'transfer_export' );
+// }
+
+
+// function copyproject()
+// {
+// if ( isset($REQ['folderid']) && isset($REQ['local_folder']) )
+// {
+// if ( !is_dir( $REQ['local_folder'] ) )
+// {
+// $var['log'] = 'directory not found';
+// }
+// else
+// {
+// $var['log'] = "reading projectfolder ...\n";
+//
+// $sql = new Sql( 'SELECT * FROM {t_file}'.
+// ' WHERE folderid={folderid}' );
+// $sql->setInt('folderid',$REQ['folderid']);
+// $files = $db->getCol( $sql->query );
+//
+// foreach( $files as $fileid )
+// {
+// $file = new File();
+// $file->fileid = $fileid;
+// $file->load();
+//
+// $full_filename = $REQ['local_folder'].'/'.$file->filename;
+// if ( $file->extension != '' )
+// $full_filename .= '.'.$file->extension;
+// $var['log'] .= "saving $full_filename\n";
+//
+// // Datei lesen
+// $f = fopen( $file->tmpfile(),'r' );
+// $value = fread($f,filesize($file->tmpfile()));
+// fclose( $f );
+//
+// // Datei lesen
+// $f = fopen( $full_filename,'w' );
+// fwrite( $f,$value );
+// fclose( $f );
+//
+// unset( $file );
+// }
+// }
+// }
+//
+//
+// $sql = new Sql( 'SELECT id FROM {t_folder}' );
+// $sql->setInt('projectid',$projectid);
+// $folders = $db->getCol( $sql->query );
+//
+// $var['folders'] = array();
+//
+// foreach( $folders as $folderid )
+// {
+// $folder = new Folder( $folderid );
+// $folder->load();
+// $folder->filenames = false;
+// $var['folders'][$folderid] = implode(' » ',$folder->parentfolder( true,true ));
+// }
+//
+// asort( $var['folders'] );
+//
+// $this->forward( 'transfer_copyproject' );
+// }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/action/TreeAction.class.php b/action/TreeAction.class.php
@@ -0,0 +1,248 @@
+<?php
+// ---------------------------------------------------------------------------
+// DaCMS 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 zum Laden/Anzeigen des Navigations-Baumes
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class TreeAction extends Action
+{
+ var $tree;
+
+
+ /**
+ * ?ffnen aller Baumelemente
+ */
+ function openall()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->all();
+ Session::setTree( $this->tree );
+ }
+
+
+// function refresh()
+// {
+// $this->tree = Session::getTree();
+// $this->tree->refresh();
+// Session::setTree( $this->tree );
+// }
+
+
+ /**
+ * ?ffnen eines Baumelementes
+ */
+ function open()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->open( $this->getRequestId() );
+ Session::setTree( $this->tree );
+ }
+
+
+ /**
+ * Schlie?en eines Baumelementes
+ */
+ function close()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->close( $this->getRequestId() );
+ Session::setTree( $this->tree );
+ }
+
+
+ /**
+ * Neues Laden des Baumes
+ */
+ function loadAction()
+ {
+ global $SESS;
+
+ $projectid = $this->getRequestVar('projectid');
+
+ if ( $projectid == -1 )
+ {
+ $this->tree = new AdministrationTree();
+ Session::setProjectLanguage(null);
+ Session::setProjectModel(null);
+ Session::setProject(null);
+ }
+ else
+ {
+ $project = new Project($projectid);
+ $project->load();
+ Session::setProject($project);
+
+ $this->tree = new ProjectTree();
+ $this->tree->projectId = $projectid;
+
+ $language = new Language( Language::getDefaultId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( Model::getDefaultId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+
+ Session::setTree( $this->tree );
+ }
+
+
+ public function loadView()
+ {
+
+ }
+
+ /**
+ * Liefert ein Array mit allen Zeilen des Baumes.
+ *
+ * Ruft sich intern rekursiv auf.
+ *
+ * @param $elId
+ * @param $tiefe
+ * @param $isLast
+ * @return unknown_type
+ */
+ function outputElement( $elId,$tiefe,$isLast )
+ {
+ $treeElement = $this->tree->elements[$elId];
+
+ $zeilen = array();
+ $zeile = array();
+
+ global $class;
+ $zeile['class'] = $class;
+ if ( $this->getRequestId() == $elId )
+ $zeile['class'] = 'opened';
+ if ( $this->getRequestId() == $elId )
+ $class ='active';
+
+ if ( !isset($tree_last) )
+ $tree_last=array();
+
+ $zeile['cols'] = array();
+
+ for ( $i=1; $i<=$tiefe-1; $i++ )
+ {
+ if ( $isLast[$i] )
+ $zeile['cols'][] = 'blank';
+ else
+ $zeile['cols'][] = 'line';
+ }
+
+ if ( $tiefe == 0 )
+ {
+ }
+ elseif ( $treeElement->type != "" )
+ {
+ if ( count($treeElement->subElementIds) == 0 )
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'plus_end';
+ else $zeile['image'] = 'plus';
+
+ $zeile['image_url' ] = Html::url('tree','open',$elId);
+ $zeile['image_url_desc'] = lang('TREE_OPEN_ELEMENT');
+ }
+ else
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'minus_end';
+ else $zeile['image'] = 'minus';
+
+ $zeile['image_url' ] = Html::url('tree','close',$elId);
+ $zeile['image_url_desc'] = lang('TREE_CLOSE_ELEMENT');
+ }
+ }
+ else
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'none_end';
+ else $zeile['image'] = 'none';
+ }
+
+
+
+ $zeile['icon'] = $treeElement->icon;
+ $zeile['text'] = $treeElement->text;
+ $zeile['desc'] = $treeElement->description;
+ $zeile['name'] = $elId;
+
+ // Url setzen
+ if ( $treeElement->url != "" )
+ $zeile['url'] = $treeElement->url;
+
+ // HTML-Target setzen
+ if ( $treeElement->target != "" )
+ $zeile['target'] = $treeElement->target;
+ else
+ $zeile['target'] = 'cms_main';
+
+ $zeile['colspan'] = 20 - count( $zeile['cols'] ) - intval(isset($zeile['image']));
+
+ $zeilen[] = $zeile;
+ // Rekursiv alle Unter-Elemente lesen
+ $nr = 0;
+ foreach( $this->tree->elements[$elId]->subElementIds as $subElementId )
+ {
+ $nr++;
+ if ( $nr == count($this->tree->elements[$elId]->subElementIds) )
+ $isLast[$tiefe+1] = true;
+ else $isLast[$tiefe+1] = false;
+
+ // Rekursiver Aufruf
+ $zeilen = array_merge( $zeilen,$this->outputElement( $subElementId,$tiefe+1,$isLast ) );
+ }
+
+ if ( $this->getRequestId() == $elId )
+ $class ='';
+
+ return $zeilen;
+ }
+
+
+ /**
+ * Anzeigen des Baumes
+ */
+ function show()
+ {
+ $project = Session::getProject();
+ if ( is_object($project) )
+ {
+ $this->setTemplateVar('projectname',$project->name);
+ }
+
+ $this->tree = Session::getTree();
+
+ if ( $this->getRequestVar('target')!='tree' )
+ $this->tree->refresh();
+
+ $var = array();
+ $var['zeilen'] = $this->outputElement( 0,0,array() );
+
+ $this->setTemplateVars( $var );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/action/TreeAction.ini.php b/action/TreeAction.ini.php
@@ -0,0 +1,22 @@
+
+[default]
+goto=show
+
+[show]
+
+[load]
+write=get
+goto=show
+clear=content
+
+[openall]
+goto=show
+
+[open]
+goto=show
+
+[close]
+goto=show
+
+;[refresh]
+;goto=show
diff --git a/action/TreetitleAction.class.php b/action/TreetitleAction.class.php
@@ -0,0 +1,78 @@
+<?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 zur Darstellung des Projekt-Auswahlmenues
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+define('PROJECTID_ADMIN',-1);
+
+class TreetitleAction extends Action
+{
+ var $defaultSubAction = 'show';
+
+ function show()
+ {
+ // Das aktuelle Projekt voreinstellen
+ $project = Session::getProject();
+
+ if ( $project->projectid == PROJECTID_ADMIN )
+ {
+ $this->setTemplateVar( 'text',lang('GLOBAL_ADMINISTRATION') );
+ $this->setTemplateVar( 'type','administration' );
+ }
+ else
+ {
+ $this->setTemplateVar( 'text',$project->name );
+ $this->setTemplateVar( 'type','project' );
+
+// // Ermitteln Sprache
+// $language = Session::getProjectLanguage();
+//
+// $windowMenu[] = array( 'text'=>lang('GLOBAL_LANGUAGE').' ('.$language->name.')',
+// 'url' =>Html::url('main','language'),
+// 'target'=>'cms_main' );
+//
+// // Ermitteln Projektmodell
+// $model = Session::getProjectModel();
+//
+// $windowMenu[] = array( 'text'=>lang('GLOBAL_MODEL').' ('.$model->name.')',
+// 'url' =>Html::url('main','model'),
+// 'target'=>'cms_main' );
+ }
+ }
+
+
+ function checkMenu( $name )
+ {
+ switch( $name )
+ {
+ case 'administration':
+ return $this->userIsAdmin();
+ default:
+ return true;
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/action/TreetitleAction.ini.php b/action/TreetitleAction.ini.php
@@ -0,0 +1,10 @@
+
+[default]
+goto=show
+
+[show]
+menu=project
+menuaction=index
+
+[menu]
+project=projectmenu,administration+
\ No newline at end of file
diff --git a/action/UserAction.class.php b/action/UserAction.class.php
@@ -0,0 +1,428 @@
+<?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 Benutzers
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class UserAction extends Action
+{
+ var $user;
+ var $defaultSubAction = 'edit';
+
+
+ function UserAction()
+ {
+ if ( !$this->userIsAdmin() )
+ die('you are not an admin');
+
+ if ( $this->getRequestId() != 0 )
+ {
+ $this->user = new User( $this->getRequestId() );
+ $this->user->load();
+ $this->setTemplateVar('userid',$this->user->userid);
+ }
+ }
+
+
+ function editAction()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ // Benutzer speichern
+ $this->user->name = $this->getRequestVar('name' );
+ $this->user->fullname = $this->getRequestVar('fullname');
+ $this->user->isAdmin = $this->hasRequestVar('is_admin');
+ $this->user->ldap_dn = $this->getRequestVar('ldap_dn' );
+ $this->user->tel = $this->getRequestVar('tel' );
+ $this->user->desc = $this->getRequestVar('desc' );
+
+ global $conf;
+ if ( @$conf['security']['user']['show_admin_mail'] )
+ $this->user->mail = $this->getRequestVar('mail' );
+
+ $this->user->style = $this->getRequestVar('style' );
+
+ $this->user->save();
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('edit');
+ }
+ }
+
+
+
+ function removeView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+ }
+
+
+
+ function removeAction()
+ {
+ if ( $this->hasRequestVar('confirm') )
+ {
+ $this->user->delete();
+ $this->addNotice('user',$this->user->name,'DELETED','ok');
+ }
+ else
+ {
+ $this->addValidationError('confirm');
+ return;
+ }
+ }
+
+
+ function addView()
+ {
+ }
+
+
+
+ function addAction()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $this->user = new User();
+ $this->user->add( $this->getRequestVar('name') );
+ $this->addNotice('user',$this->user->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ }
+ }
+
+
+ function addgrouptouser()
+ {
+ $this->user->addGroup( $this->getRequestVar('groupid') );
+
+ $this->addNotice('user',$this->user->name,'ADDED','ok');
+ }
+
+
+ function addgroup()
+ {
+ // Alle hinzufuegbaren Gruppen ermitteln
+ $this->setTemplateVar('groups',$this->user->getOtherGroups());
+ }
+
+
+ function delgroup()
+ {
+ $this->user->delGroup( $this->getRequestVar('groupid') );
+
+ $this->addNotice('user',$this->user->name,'DELETED','ok');
+ }
+
+
+ /**
+ * Das Kennwort wird an den Benutzer geschickt
+ *
+ * @access private
+ */
+ function mailPw( $pw )
+ {
+ $to = $this->user->fullname.' <'.$this->user->mail.'>';
+ $mail = new Mail($to,'USER_MAIL');
+
+ $mail->setVar('username',$this->user->name );
+ $mail->setVar('password',$pw );
+ $mail->setVar('name' ,$this->user->getName() );
+
+ $mail->send();
+ }
+
+
+ /**
+ * Aendern des Kennwortes
+ */
+ function pwAction()
+ {
+ global $conf;
+
+ $pw1 = $this->getRequestVar('password1');
+ $pw2 = $this->getRequestVar('password2');
+
+ // Zufaelliges Kennwort erzeugen
+ if ( $this->hasRequestVar('random') && $this->hasRequestVar('email') )
+ {
+ $pw1 = $this->user->createPassword();
+ $pw2 = $pw1;
+ }
+
+ if ( strlen($pw1)<intval($conf['security']['password']['min_length']) )
+ {
+ $this->addValidationError('password1');
+ return;
+ }
+ elseif ( $pw1 != $pw2 )
+ {
+ $this->addValidationError('password2');
+ return;
+ }
+ else
+ {
+ // Kennwoerter identisch und lang genug
+ $this->user->setPassword($pw1,!$this->hasRequestVar('timeout') ); // Kennwort setzen
+
+ // E-Mail mit dem neuen Kennwort an Benutzer senden
+ if ( $this->hasRequestVar('email') && !empty($this->user->mail) && $conf['mail']['enabled'] )
+ {
+ $this->mailPw( $pw1 );
+ $this->addNotice('user',$this->user->name,'MAIL_SENT','ok');
+ }
+
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+ }
+
+ }
+
+
+
+ function listing()
+ {
+ $list = array();
+
+ foreach( User::getAllUsers() as $user )
+ {
+ $list[$user->userid] = $user->getProperties();
+ $list[$user->userid]['url' ] = Html::url('main','user',$user->userid,
+ array(REQ_PARAM_TARGETSUBACTION=>'edit') );
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Eigenschaften des Benutzers anzeigen
+ */
+ function editView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
+
+ $gravatarConfig = config('interface','gravatar');
+
+ $this->setTemplateVar( 'image', 'about:blank' );
+ if ( is_array($gravatarConfig) )
+ {
+ extract($gravatarConfig);
+
+ if ( isset($enable) && $enable && !empty($this->user->mail) )
+ {
+ $url = 'http://www.gravatar.com/avatar/'.md5($this->user->mail).'?';
+ if ( isset($size))
+ $url .= '&s='.$size;
+ if ( isset($default))
+ $url .= '&d='.$default;
+ if ( isset($rating))
+ $url .= '&r='.$rating;
+
+ $this->setTemplateVar( 'image', $url );
+ }
+ }
+
+ }
+
+
+ function memberships()
+ {
+ }
+
+
+ function groupsView()
+ {
+ $gruppenListe = array();
+
+ $allGroups = Group::getAll();
+ $userGroups = $this->user->getGroups();
+
+ foreach( $allGroups as $id=>$name )
+ {
+
+ $hasGroup = array_key_exists($id,$userGroups);
+ $varName = 'group'.$id;
+ $gruppenListe[$id] = array('name' =>$name,
+ 'id' =>$id,
+ 'var' =>$varName,
+ 'member' =>$hasGroup
+ );
+ $this->setTemplateVar($varName,$hasGroup);
+ }
+ $this->setTemplateVar('memberships',$gruppenListe);
+
+ global $conf;
+ if ($conf['security']['authorize']['type']=='ldap')
+ $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
+ }
+
+
+ function groupsAction()
+ {
+ $allGroups = Group::getAll();
+ $userGroups = $this->user->getGroups();
+
+ foreach( $allGroups as $id=>$name )
+ {
+ $hasGroup = array_key_exists($id,$userGroups);
+
+ if ( !$hasGroup && $this->hasRequestVar('group'.$id) )
+ {
+ $this->user->addGroup($id);
+ $this->addNotice('group',$name,'ADDED');
+ }
+
+ if ( $hasGroup && !$this->hasRequestVar('group'.$id) )
+ {
+ $this->user->delGroup($id);
+ $this->addNotice('group',$name,'DELETED');
+ }
+ }
+ }
+
+
+ /**
+ * Aendern des Kennwortes
+ */
+ function pwView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+ }
+
+
+ /**
+ * Anzeigen der Benutzerrechte
+ */
+ function rights()
+ {
+ $rights = $this->user->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->userid > 0 )
+ {
+ $user = new User($acl->userid);
+ $user->load();
+ $right['username'] = $user->name;
+ }
+ elseif ( $acl->groupid > 0 )
+ {
+ $group = new Group($acl->groupid);
+ $group->load();
+ $right['groupname'] = $group->name;
+ }
+ else
+ {
+ // Berechtigung f�r "alle".
+ }
+
+// $show = array();
+// foreach( $acl->getProperties() as $p=>$set)
+// $show[$p] = $set;
+//
+// $right['show'] = $show;
+ $right['bits'] = $acl->getProperties();
+
+ $projects[$acl->projectid]['rights'][] = $right;
+ }
+
+ $this->setTemplateVar('projects' ,$projects );
+
+ $this->setTemplateVar('show',Acl::getAvailableRights() );
+
+ if ( $this->user->isAdmin )
+ $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',OR_NOTICE_WARN);
+ }
+
+
+ /**
+ * @param String $name Men�punkt
+ * @return boolean
+ */
+ function checkMenu( $menu )
+ {
+ global $conf;
+
+ switch( $menu )
+ {
+ case 'add':
+ case 'remove':
+ return !readonly();
+
+ case 'addgroup':
+ return !readonly() && count($this->user->getOtherGroups()) > 0;
+
+ case 'groups':
+ return !readonly() && count(Group::getAll()) > 0;
+
+ case 'pw':
+ return !readonly()
+ && @$conf['security']['auth']['type'] == 'database'
+ && !@$conf['security']['auth']['userdn'];
+ }
+
+ return true;
+ }
+
+
+}+
\ No newline at end of file
diff --git a/action/UserAction.ini.php b/action/UserAction.ini.php
@@ -0,0 +1,41 @@
+
+admin=true
+
+[default]
+goto=listing
+
+[listing]
+menu=listing
+
+[add]
+menu=listing
+write=true
+
+[edit]
+menu=edit
+editable=true
+write=true
+
+[remove]
+menu=edit
+write=true
+
+[memberships]
+goto=groups
+
+; Gruppenzugehoerigkeiten
+[groups]
+menu=memberships
+editable=true
+write=yes
+
+[pw]
+menu=pw
+write=true
+
+[rights]
+menu=rights
+
+[menu]
+menu=listing,add,edit,remove,groups,pw,rights
+;info=show,mail
diff --git a/action/WebdavAction.class.php b/action/WebdavAction.class.php
@@ -0,0 +1,1195 @@
+<?php
+
+
+/**
+ * Action-Klasse fuer WebDAV.<br>
+ *
+ * Das virtuelle Ordnersystem dieses CMS kann über das WebDAV-Protokoll
+ * dargestellt werden.
+ *
+ * Diese Klasse nimmt die Anfragen von WebDAV-Clients entgegen, zerlegt die
+ * Anfrage und erzeugt eine Antwort, die im HTTP-Body zurück übertragen
+ * wird.
+ * <br>
+ * WebDAV ist spezifiziert in der RFC 2518.<br>
+ * Siehe <code>http://www.ietf.org/rfc/rfc2518.txt</code><br>
+ *
+ * Implementiert wird DAV-Level 1 (d.h. ohne LOCK).
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+
+class WebdavAction extends Action
+{
+ // Zahlreiche Instanzvariablen, die im Konstruktor
+ // beim Zerlegen der Anfrag gefüllt werden.
+ var $defaultSubAction = 'show';
+ var $database;
+ var $depth;
+ var $project;
+ var $folder;
+ var $obj;
+ var $filename;
+ var $pathnames = array();
+ var $uri;
+ var $headers;
+ var $requestType;
+ var $request;
+ var $destination = null;
+ var $fullSkriptName;
+ var $create;
+ var $readonly;
+ var $maxFileSize;
+ var $webdav_conf;
+ var $overwrite = false;
+
+
+ /**
+ * Im Kontruktor wird der Request analysiert und ggf. eine Authentifzierung
+ * durchgefuehrt.
+ */
+ function WebdavAction()
+ {
+ if (!defined('E_STRICT'))
+ define('E_STRICT', 2048);
+
+ // Nicht notwendig, da wir den Error-Handler umbiegen:
+ error_reporting(0); // PHP-Fehlermeldungen zerstoeren XML-Dokument, daher ausschalten.
+
+ // PHP-Fehler ins Log schreiben, damit die Ausgabe nicht zerstoert wird.
+ if (version_compare(PHP_VERSION, '5.0.0', '>'))
+ set_error_handler('webdavErrorHandler',E_ERROR | E_WARNING);
+ else
+ set_error_handler('webdavErrorHandler');
+
+ global $conf;
+ $this->webdav_conf = $conf['webdav'];
+
+ if ( $this->webdav_conf['compliant_to_redmond'] )
+ header('MS-Author-Via: DAV' ); // Extrawurst fuer MS-Clients.
+
+ if ( $this->webdav_conf['expose_openrat'] )
+ header('X-Dav-powered-by: OpenRat CMS'); // Bandbreite verschwenden :)
+
+ Logger::trace( 'WEBDAV: URI='.$_SERVER['REQUEST_URI']);
+
+ if ( !$conf['webdav']['enable'])
+ {
+ Logger::warn( 'WEBDAV is disabled by configuration' );
+ $this->httpStatus('403 Forbidden');
+ exit;
+ }
+
+ $this->create = $this->webdav_conf['create'];
+ $this->readonly = $this->webdav_conf['readonly'];
+ $this->maxFileSize = $this->webdav_conf['max_file_size'];
+
+ Logger::debug( 'WEBDAV method is '.$_GET['subaction'] );
+
+ $this->headers = getallheaders();
+ /* DAV compliant servers MUST support the "0", "1" and
+ * "infinity" behaviors. By default, the PROPFIND method without a Depth
+ * header MUST act as if a "Depth: infinity" header was included. */
+ if ( !isset($this->headers['Depth']) )
+ $this->depth = 1;
+ elseif ( strtolower($this->headers['Depth'])=='infinity')
+ $this->depth = 1;
+ else
+ $this->depth = intval($this->headers['Depth']);
+
+ if ( isset($this->headers['Destination']) )
+ $this->destination = $this->headers['Destination'];
+
+ if ( isset($this->headers['Overwrite']) )
+ $this->overwrite = $this->headers['Overwrite'] == 'T';
+
+ // Pr�fen, ob Benutzer angemeldet ist.
+ $user = $this->getUserFromSession();
+
+ // Authentisierung erzwingen (außer bei Methode OPTIONS).
+ // For the motivation for not checking OPTIONS requests see
+ // http://pear.php.net/bugs/bug.php?id=5363
+ if ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] != 'options' )
+ {
+ Logger::debug( 'Checking Authentication' );
+
+ if ( !is_object(Session::getDatabase()) )
+ $this->setDefaultDb();
+
+ $ok = false;
+ if ( isset($_SERVER['PHP_AUTH_USER']) )
+ {
+ $user = new User();
+ $user->name = $_SERVER['PHP_AUTH_USER'];
+
+ $ok = $user->checkPassword( $_SERVER['PHP_AUTH_PW'] );
+
+ if ( $ok )
+ {
+ $user->load();
+ $user->setCurrent();
+ $this->redirectWithSessionId();
+ }
+ }
+
+ if ( !$ok )
+ {
+ // Client ist nicht angemeldet, daher wird nun die
+ // Authentisierung angefordert.
+ Logger::debug( 'Requesting Client to authenticate' );
+ header('WWW-Authenticate: Basic realm="'.OR_TITLE.'"');
+ $this->httpStatus('401 Unauthorized');
+ exit;
+ }
+ }
+ elseif ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] == 'options' )
+ {
+ $this->setDefaultDb();
+ }
+
+
+ $this->fullSkriptName = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'/';
+
+ if ( $this->webdav_conf['session_in_uri'] )
+ $sos = 1+strlen(session_id())+strlen($this->webdav_conf['session_in_uri_prefix']);
+ else
+ $sos = 0;
+
+ // URL parsen.
+ $uri = substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']) + $sos);
+
+ Logger::debug( 'WebDAV: URI="'.$uri.'"' );
+
+ $uri = $this->parseURI( $uri );
+ $this->requestType = $uri['type' ];
+ $this->folder = $uri['folder' ];
+ $this->obj = $uri['object' ];
+ $this->project = $uri['project'];
+
+ $this->fullSkriptName .= implode('/',$uri['path']);
+
+ if ( is_object($this->obj) && $this->obj->isFolder )
+ $this->fullSkriptName .= '/';
+
+ /*
+ * Verzeichnisse muessen mit einem '/' enden. Falls nicht, Redirect aussfuehren.
+ *
+ * RFC 2518, 5.2 Collection Resources, Page 11:
+ * "For example, if a client invokes a
+ * method on http://foo.bar/blah (no trailing slash), the resource
+ * http://foo.bar/blah/ (trailing slash) may respond as if the operation
+ * were invoked on it, and should return a content-location header with
+ * http://foo.bar/blah/ in it. In general clients SHOULD use the "/"
+ * form of collection names."
+ */
+ if ( is_object($this->obj) &&
+ $this->obj->isFolder &&
+ $_GET['subaction'] == 'get' &&
+ substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1 ) != '/' )
+ {
+ Logger::debug( 'WebDAV: Redirecting lame client to slashyfied URL' );
+
+ header('HTTP/1.1 302 Moved Temporarily');
+ header('Location: '.$_SERVER['REQUEST_URI'].'/');
+ exit;
+ }
+
+ // Falls vorhanden, den "Destination"-Header parsen.
+ if ( isset($_SERVER['HTTP_DESTINATION']) )
+ {
+ $destUri = parse_url( $_SERVER['HTTP_DESTINATION'] );
+
+ $uri = substr($destUri['path'],strlen($_SERVER['SCRIPT_NAME'])+$sos);
+
+ // URL parsen.
+ $this->destination = $this->parseURI( $uri );
+ }
+
+ // Den Request-BODY aus der Standardeingabe lesen.
+ $this->request = implode('',file('php://input'));
+ }
+
+
+
+ /**
+ * Falls ein WebDAV-Client keine Cookies setzen kann (was HTTP/1.1 eigentlich
+ * der Fall sein sollte), kann die Session-Id in die URL eingetragen
+ * werden. Dies muss in der Konfiguration aktiviert werden.
+ */
+ function redirectWithSessionId()
+ {
+ if ( $this->webdav_conf['session_in_uri'] )
+ {
+ header('Location: '.dirname($_SERVER['REQUEST_URI']).'/'. $this->webdav_conf['session_in_uri_prefix'].session_id().'/'.basename($_SERVER['REQUEST_URI']));
+ //$this->httpStatus('303 See Other');
+ $this->httpStatus('302 Moved');
+ }
+ }
+
+
+
+ /**
+ * Da im WebDAV-Request keine Datenbank-Id angegeben werden kann, benutzen
+ * wir hier die Standard-Datenbank.
+ */
+ function setDefaultDb()
+ {
+ global $conf;
+
+ if ( !isset($conf['database']['default']) )
+ {
+ Logger::error('No default database in configuration');
+ $this->httpStatus('500 Internal Server Error - no default-database in configuration');
+ }
+
+ $dbid = $conf['database']['default'];
+
+ $db = new DB( $conf['database'][$dbid] );
+ $db->id = $dbid;
+ Session::setDatabase( $db );
+ }
+
+
+
+ function allowed_methods()
+ {
+
+ if ($this->readonly)
+ return array('OPTIONS','HEAD','GET','PROPFIND'); // Readonly-Modus
+ else
+ // PROPPATCH unterstuetzen wir garnicht, aber lt. Spec sollten wir das.
+ return array('OPTIONS','HEAD','GET','PROPFIND','DELETE','PUT','COPY','MOVE','MKCOL','PROPPATCH');
+ }
+
+
+
+ /**
+ * HTTP-Methode OPTIONS.<br>
+ * <br>
+ * Es werden die verfuegbaren Methoden ermittelt und ausgegeben.
+ */
+ function options()
+ {
+ header('DAV: 1'); // Wir haben DAV-Level 1.
+ header('Allow: '.implode(', ',$this->allowed_methods()) );
+
+ $this->httpStatus( '200 OK' );
+ }
+
+
+
+ /**
+ * Setzt einen HTTP-Status.<br>
+ * <br>
+ * Es wird ein HTTP-Status gesetzt, zus�tzlich wird der Status in den Header "X-WebDAV-Status" geschrieben.<br>
+ * Ist der Status nicht 200 oder 207 (hier folgt ein BODY), wird das Skript beendet.
+ */
+ function httpStatus( $status = true )
+ {
+ if ( $status === true )
+ $status = '200 OK';
+
+ Logger::debug('WEBDAV: HTTP-Status: '.$status);
+
+ header('HTTP/1.1 '.$status);
+ header('X-WebDAV-Status: '.$status,true);
+
+ // RFC 2616 (HTTP/1.1), Section 10.4.6 "405 Method Not Allowed" says:
+ // "[...] The response MUST include an
+ // Allow header containing a list of valid methods for the requested
+ // resource."
+ //
+ // RFC 2616 (HTTP/1.1), Section 14.7 "Allow" says:
+ // "[...] An Allow header field MUST be
+ // present in a 405 (Method Not Allowed) response."
+ if ( substr($status,0,3) == '405' )
+ header('Allow: '.implode(', ',$this->allowed_methods()) );
+ }
+
+
+
+ /**
+ * WebDav-HEAD-Methode.
+ */
+ function head()
+ {
+ if ( $this->obj == null )
+ {
+ $this->httpStatus( '404 Not Found' );
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isPage )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isLink )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isFile )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ }
+
+
+
+ /**
+ * WebDav-GET-Methode.
+ * Die gew�nschte Datei wird geladen und im HTTP-Body mitgeliefert.
+ */
+ function get()
+ {
+ if ( $this->obj->isFolder )
+ $this->getDirectory();
+ elseif( $this->obj->isPage )
+ {
+ $this->httpStatus( '200 OK' );
+
+ header('Content-Type: text/html');
+
+ $page = new Page( $this->obj->objectid );
+ $page->load();
+ echo '<html><head><title>OpenRat WEBDAV Access</title></head>';
+ echo '<body>';
+ echo '<h1>'.$page->full_filename().'</h1>';
+ echo '<pre>';
+ echo 'No Content available';
+ echo '</pre>';
+ echo '</body>';
+ echo '</html>';
+ }
+ elseif( $this->obj->isLink )
+ {
+ $this->httpStatus( '200 OK' );
+
+ header('Content-Type: text/plain');
+
+ $link = new Link( $this->obj->objectid );
+ $link->load();
+ echo 'url: ' .$link->url ."\n";
+ echo 'target-id: '.$link->linkedObjectId."\n";
+ }
+ elseif( $this->obj->isFile )
+ {
+ $this->httpStatus( '200 OK' );
+
+ $file = new File( $this->obj->objectid );
+ $file->load();
+
+ header('Content-Type: '.$file->mimeType() );
+ header('X-File-Id: '.$file->fileid );
+
+ // Angabe Content-Disposition
+ // - Bild soll "inline" gezeigt werden
+ // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
+ header('Content-Disposition: inline; filename='.$file->filenameWithExtension() );
+ header('Content-Transfer-Encoding: binary' );
+ header('Content-Description: '.$file->name );
+
+ $file->write(); // Bild aus Datenbank laden und in temporäre Datei schreiben
+
+ // Groesse des Bildes in Bytes
+ // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
+ header('Content-Length: '.filesize($file->tmpfile()) );
+ readfile( $file->tmpfile() );
+ }
+ }
+
+
+
+ /**
+ * Erzeugt ein Unix-�hnliche Ausgabe des Verzeichnisses als HTML.
+ */
+ function getDirectory()
+ {
+ $this->httpStatus( '200 OK' );
+
+ // Verzeichnis ausgeben
+ header('Content-Type: text/html');
+ $nl = "\n";
+ $titel = 'Index of '.htmlspecialchars($this->fullSkriptName);
+ $format = "%15s %-19s %-s\n";
+
+ echo '<html><head><title>'.$titel.'</title></head>';
+ echo '<body>';
+ echo '<h1>'.$titel.'</h1>'.$nl;
+ echo '<pre>';
+
+ printf($format, "Size", "Last modified", "Filename");
+
+ if ( $this->requestType == 'projectlist' )
+ {
+ foreach( Project::getAll() as $projectName )
+ {
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $z;
+ $objektinhalt['size' ] = 1;
+ echo '<a href="'.$this->fullSkriptName.'/'.$projectName.'"> </a>';
+ }
+ }
+ elseif( $this->requestType == 'object' ) // Verzeichnisinhalt
+ {
+ $objects = $this->folder->getObjects();
+
+ foreach( $objects as $object )
+ {
+ printf($format,
+ number_format(1),
+ strftime("%Y-%m-%d %H:%M:%S",$object->lastchangeDate ),
+ '<a href="'.$object->filename.'">'.$object->filename.'</a>');
+ echo $nl;
+ }
+ }
+
+ echo '</pre>';
+ echo '</body>';
+ echo '</html>';
+ }
+
+
+
+ /**
+ * Die Methode LOCK sollte garnicht aufgerufen werden, da wir nur
+ * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 412 (Precondition failed)
+ */
+ function lock()
+ {
+ $this->httpStatus('412 Precondition failed');
+ $this->options();
+ }
+
+
+
+ /**
+ * Die Methode UNLOCK sollte garnicht aufgerufen werden, da wir nur
+ * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 412 (Precondition failed)
+ */
+ function unlock()
+ {
+ $this->httpStatus('412 Precondition failed');
+ $this->options();
+ }
+
+
+
+ /**
+ * Die Methode POST ist bei WebDav nicht sinnvoll.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 405 (Method Not Allowed)
+ */
+ function post()
+ {
+ // Die Methode POST ist bei Webdav nicht sinnvoll.
+ $this->httpStatus('405 Method Not Allowed' );
+ }
+
+
+
+ /**
+ * Verzeichnis anlegen.
+ */
+ function mkcol()
+ {
+
+ if ( !empty($this->request) )
+ {
+ $this->httpStatus('415 Unsupported Media Type' ); // Kein Body erlaubt
+ }
+ elseif ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
+ }
+ elseif ( !$this->folder->hasRight( ACL_CREATE_FOLDER ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
+ }
+ elseif ( $this->obj == null )
+ {
+ // Die URI ist noch nicht vorhanden
+ $f = new Folder();
+ $f->filename = basename($this->fullSkriptName);
+ $f->parentid = $this->folder->objectid;
+ $f->projectid = $this->project->projectid;
+ $f->add();
+ $this->httpStatus('201 Created');
+ }
+ else
+ {
+ // MKCOL ist nicht moeglich, wenn die URI schon existiert.
+ Logger::warn('MKCOL-Request to an existing resource');
+ $this->httpStatus('405 Method Not Allowed' );
+ }
+ }
+
+
+
+ /**
+ * Objekt l�schen.
+ */
+ function delete()
+ {
+ if ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
+ }
+ else
+ {
+ if ( $this->obj == null )
+ {
+ // Nicht existente URIs kann man auch nicht loeschen.
+ $this->httpStatus('404 Not Found' );
+ }
+ elseif ( ! $this->obj->hasRight( ACL_DELETE ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf die Resource nicht loeschen
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ $f = new Folder( $this->obj->objectid );
+ $f->deleteAll();
+ $this->httpStatus( true ); // OK
+ Logger::debug('Deleted folder with id '.$this->obj->objectid );
+ }
+ elseif ( $this->obj->isFile )
+ {
+ $f = new File( $this->obj->objectid );
+ $f->delete();
+ $this->httpStatus( true ); // OK
+ }
+ elseif ( $this->obj->isPage )
+ {
+ $p = new Page( $this->obj->objectid );
+ $p->delete();
+ $this->httpStatus( true ); // OK
+ }
+ elseif ( $this->obj->isLink )
+ {
+ $l = new Link( $this->obj->objectid );
+ $l->delete();
+ $this->httpStatus( true ); // OK
+ }
+
+ }
+ }
+
+
+
+ /**
+ * Kopieren eines Objektes.<br>
+ * Momentan ist nur das Kopieren einer Datei implementiert.<br>
+ * Das Kopieren von Ordnern, Verkn�pfungen und Seiten ist nicht moeglich.
+ */
+ function copy()
+ {
+ if ( $this->readonly || !$this->create )
+ {
+ Logger::error('WEBDAV: COPY request, but readonly or no creating');
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif( $this->obj == null )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ Logger::error('WEBDAV: COPY request, but Source not found');
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif ( $this->destination == null )
+ {
+ Logger::error('WEBDAV: COPY request, but no "Destination:"-Header');
+ // $this->httpStatus('405 Not Allowed' );
+ $this->httpStatus('412 Precondition failed');
+ }
+ else
+ {
+ // URL parsen.
+ $dest = $this->destination;
+ $destinationProject = $dest['project'];
+ $destinationFolder = $dest['folder' ];
+ $destinationObject = $dest['object' ];
+
+ if ( $dest['type'] != 'object' )
+ {
+ Logger::debug('WEBDAV: COPY request, but "Destination:"-Header mismatch');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( $this->project->projectid != $destinationProject->projectid )
+ {
+ // Kopieren in anderes Projekt nicht moeglich.
+ Logger::debug('WEBDAV: COPY request denied, project does not match');
+ $this->httpStatus('403 Forbidden');
+ }
+ elseif ( $destinationObject != null )
+ {
+ Logger::debug('WEBDAV: COPY request denied, Destination exists. Overwriting is not supported');
+ $this->httpStatus('403 Forbidden');
+ }
+ elseif ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isFolder)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Folder-Copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isLink)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Link copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isPage)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Page copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ else
+ {
+ $f = new File();
+ $f->filename = basename($_SERVER['HTTP_DESTINATION']);
+ $f->name = '';
+ $f->parentid = $destinationFolder->objectid;
+ $f->projectid = $this->project->projectid;
+ $f->add();
+ $f->copyValueFromFile( $this->obj->objectid );
+
+ Logger::debug('WEBDAV: COPY request accepted' );
+ // Objekt wird in anderen Ordner kopiert.
+ $this->httpStatus('201 Created' );
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Verschieben eines Objektes.<br>
+ * <br>
+ * Folgende Operationen sind m�glich:<br>
+ * - Unbenennen eines Objektes (alle Typen)<br>
+ * - Verschieben eines Objektes (alle Typen) in einen anderen Ordner.<br>
+ */
+ function move()
+ {
+ if ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden - Readonly Mode' ); // Schreibgeschuetzt
+ }
+ elseif ( !$this->create )
+ {
+ $this->httpStatus('403 Forbidden - No creation' ); // Schreibgeschuetzt
+ }
+ elseif( $this->obj == null )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ $this->httpStatus('404 Not Found' );
+ }
+ elseif( is_object($this->obj) && ! $this->obj->hasRight( ACL_WRITE ) )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
+ $this->httpStatus('403 Forbidden' );
+ }
+ elseif ( $this->destination == null )
+ {
+ Logger::error('WEBDAV: MOVE request, but no "Destination:"-Header');
+ // $this->httpStatus('405 Not Allowed' );
+ $this->httpStatus('412 Precondition failed');
+ }
+ else
+ {
+ $dest = $this->destination;
+ $destinationProject = $dest['project'];
+ $destinationFolder = $dest['folder' ];
+ $destinationObject = $dest['object' ];
+
+ if ( $dest['type'] != 'object' )
+ {
+ Logger::debug('WEBDAV: MOVE request, but "Destination:"-Header mismatch');
+ $this->httpStatus('405 Not Allowed');
+ return;
+ }
+
+ if ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
+ {
+ Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
+ $this->httpStatus('403 Forbidden' );
+ }
+
+ if ( $destinationObject != null )
+ {
+ Logger::debug('WEBDAV: MOVE request denied, destination exists');
+ $this->httpStatus('412 Precondition Failed');
+ return;
+ }
+
+ if ( $this->project->projectid != $destinationProject->projectid )
+ {
+ // Verschieben in anderes Projekt nicht moeglich.
+ Logger::debug('WEBDAV: MOVE request denied, project does not match');
+ $this->httpStatus('405 Not Allowed');
+ return;
+ }
+
+ if ( $this->folder->objectid == $destinationFolder->objectid )
+ {
+ Logger::debug('WEBDAV: MOVE request accepted, object renamed');
+ // Resource bleibt in gleichem Ordner.
+ $this->obj->filename = basename($_SERVER['HTTP_DESTINATION']);
+ $this->obj->objectSave(false);
+ $this->httpStatus('201 Created' );
+ return;
+ }
+
+ if ( $destinationFolder->isFolder )
+ {
+ Logger::debug('WEBDAV: MOVE request accepted, Destination: '.$destinationFolder->filename );
+ // Objekt wird in anderen Ordner verschoben.
+ $this->obj->setParentId( $destinationFolder->objectid );
+ $this->httpStatus('201 Created' );
+ return;
+ }
+
+ Logger::warn('WEBDAV: MOVE request failed' );
+ $this->httpStatus('500 Internal Server Error' );
+ }
+ }
+
+
+
+ /**
+ * Anlegen oder �berschreiben Dateien �ber PUT.<br>
+ * Dateien k�nnen neu angelegt und �berschrieben werden.<br>
+ * <br>
+ * Seiten k�nnen nicht �berschrieben werden. Wird versucht,
+ * eine Seite mit PUT zu �berschreiben, wird der Status "405 Not Allowed" gemeldet.<br>
+ */
+ function put()
+ {
+ // TODO: 409 (Conflict) wenn �bergeordneter Ordner nicht da.
+
+ if ( $this->webdav_conf['readonly'] )
+ {
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif ( strlen($this->request) > $this->maxFileSize*1000 )
+ {
+ // Maximale Dateigroesse ueberschritten.
+ // Der Status 207 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :)
+ $this->httpStatus('507 Insufficient Storage' );
+ }
+ elseif ( $this->obj == null )
+ {
+ // Neue Datei anlegen
+ if ( !$this->webdav_conf['create'] )
+ {
+ Logger::warn('WEBDAV: Creation of files not allowed by configuration' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+
+ if ( ! $this->folder->hasRight( ACL_CREATE_FILE ) )
+ {
+ $this->httpStatus('403 Forbidden');
+ return;
+ }
+
+ $file = new File();
+ $file->filename = basename($this->fullSkriptName);
+ $file->extension = '';
+ $file->size = strlen($this->request);
+ $file->parentid = $this->folder->objectid;
+ $file->projectid = $this->project->projectid;
+ $file->value = $this->request;
+ $file->add();
+ $this->httpStatus('201 Created');
+ return;
+ }
+ elseif ( $this->obj->isFile )
+ {
+ if ( ! $this->obj->hasRight( ACL_WRITE ) )
+ {
+ Logger::debug('PUT failed, parent folder not writable by user' );
+ $this->httpStatus('403 Forbidden');
+ return;
+ }
+
+ // Bestehende Datei ueberschreiben.
+ $file = new File( $this->obj->objectid );
+ $file->saveValue( $this->request );
+ $file->setTimestamp();
+ $this->httpStatus('204 No Content');
+ Logger::debug('PUT ok, file is created' );
+ return;
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ Logger::error('PUT on folder is not supported, use PROPFIND. Lame client?' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+ else
+ {
+ // Fuer andere Objekttypen (Links, Seiten) ist kein PUT moeglich.
+ Logger::warn('PUT only available for files, pages and links are ignored' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+ }
+
+
+
+ /**
+ * WebDav-Methode PROPFIND.
+ *
+ * Diese Methode wird
+ * - beim Ermitteln von Verzeichnisinhalten und
+ * - beim Ermitteln von Metainformationen zu einer Datei
+ * verwendet.
+ *
+ * Das Ergebnis wird in einer XML-Zeichenkette geliefert.
+ */
+ function propfind()
+ {
+ switch( $this->requestType )
+ {
+ case 'projectlist': // Projektliste
+
+ $inhalte = array();
+
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $z;
+ $objektinhalt['size' ] = 1;
+ $objektinhalt['name' ] = $this->fullSkriptName;
+ $objektinhalt['displayname' ] = '';
+ $objektinhalt['type'] = 'folder';
+
+ $inhalte[] = $objektinhalt;
+
+ foreach( Project::getAll() as $projectid=>$projectName )
+ {
+ $project = new Project( $projectid );
+ $rootObjectId = $project->getRootObjectId();
+ $folder = new Folder( $rootObjectId );
+ $folder->load();
+
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $folder->lastchangeDate;
+ $objektinhalt['size' ] = $project->size();
+ $objektinhalt['name' ] = $this->fullSkriptName.$projectName.'/';
+ $objektinhalt['displayname' ] = $projectName;
+ $objektinhalt['type'] = 'folder';
+ $inhalte[] = $objektinhalt;
+ }
+
+ $this->multiStatus( $inhalte );
+ break;
+
+ case 'object': // Verzeichnisinhalt
+
+ if ( $this->obj == null )
+ {
+ // Objekt existiert nicht.
+ Logger::trace( 'WEBDAV: PROPFIND of non-existent object');
+ $this->httpStatus('404 Not Found');
+ return;
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ if ( ! $this->obj->hasRight( ACL_READ ))
+ {
+ Logger::debug( 'Folder '.$this->obj->objectid.': access denied');
+ $this->httpStatus('403 Forbidden');
+ }
+
+ $inhalte = array();
+
+ $objektinhalt = array();
+ $objektinhalt['createdate' ] = $this->obj->createDate;
+ $objektinhalt['lastchangedate'] = $this->obj->lastchangeDate;
+ $objektinhalt['name' ] = $this->fullSkriptName;
+ $objektinhalt['displayname' ] = basename($this->fullSkriptName);
+ $objektinhalt['type' ] = 'folder';
+ $objektinhalt['size' ] = 0;
+ $inhalte[] = $objektinhalt;
+
+ if ( $this->depth > 0 )
+ {
+ $objects = $this->folder->getObjects();
+ foreach( $objects as $object )
+ {
+ if ( ! $object->hasRight( ACL_READ ))
+ continue;
+
+ //$object->loadRaw();
+ $objektinhalt = array();
+ $objektinhalt['createdate' ] = $object->createDate;
+ $objektinhalt['lastchangedate'] = $object->lastchangeDate;
+ $objektinhalt['displayname' ] = $object->filename;
+
+ switch( $object->getType() )
+ {
+
+ case OR_TYPE_FOLDER:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename.'/';
+ $objektinhalt['type'] = 'folder';
+ $objektinhalt['size'] = 0;
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_FILE:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $file = new File($object->objectid);
+ $file->load();
+ $objektinhalt['size'] = $file->size;
+ $objektinhalt['mime'] = 'application/x-non-readable';
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_LINK:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $objektinhalt['size'] = 0;
+ $objektinhalt['mime'] = 'application/x-non-readable';
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_PAGE:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $objektinhalt['size'] = 0;
+ $inhalte[] = $objektinhalt;
+ break;
+ default:
+ }
+ }
+ }
+ Logger::trace( 'WEBDAV: PROPFIND-2');
+
+// if ( count($inhalte)==0 )
+// $inhalte[] = array('createdate'=>0,'lastchangedate'=>0,'name'=>'empty','size'=>0,'type'=>'file');
+
+ Logger::trace('Anzahl Dateien:'.count($inhalte));
+ $this->multiStatus( $inhalte );
+ }
+ else
+ {
+ $object = $this->obj;
+ Logger::trace( 'WEBDAV: PROPFIND of file');
+ $objektinhalt = array();
+ $objektinhalt = array();
+ $objektinhalt['name'] = $this->fullSkriptName.'/'.$object->filename.'/';
+ $objektinhalt['displayname'] = $object->filename;
+ $objektinhalt['createdate' ] = $object->createDate;
+ $objektinhalt['lastchangedate'] = $object->lastchangeDate;
+ $file = new File( $this->obj->objectid );
+ $file->load();
+ $objektinhalt['size' ] = $file->size;
+ $objektinhalt['type' ] = 'file';
+
+
+ $this->multiStatus( array($objektinhalt) );
+ }
+ break;
+
+ default:
+ Logger::warn('Internal Error, unknown request type: '. $this->requestType);
+ $this->httpStatus('500 Internal Server Error');
+ }
+ }
+
+
+ /**
+ * Webdav-Methode PROPPATCH ist nicht implementiert.
+ */
+ function proppatch()
+ {
+ // TODO: Multistatus erzeugen.
+ // Evtl. ist '409 Conflict' besser?
+ $this->httpStatus('405 Not Allowed');
+ }
+
+
+ /**
+ * Erzeugt einen Multi-Status.
+ * @access private
+ */
+ function multiStatus( $files )
+ {
+ $this->httpStatus('207 Multi-Status');
+ header('Content-Type: text/xml; charset=utf-8');
+
+ $response = '';
+ $response .= '<?xml version="1.0" encoding="utf-8" ?>';
+ $response .= '<d:multistatus xmlns:d="DAV:">';
+
+ foreach( $files as $file )
+ $response .= $this->getResponse( $file['name'],$file );
+
+ $response .= '</d:multistatus>';
+ Logger::trace('PROPFIND: '.$response);
+
+ $response = utf8_encode($response);
+
+ header('Content-Length: '.strlen($response));
+ echo $response;
+ }
+
+
+ /**
+ * Erzeugt ein "response"-Element, welches in ein "multistatus"-element verwendet werden kann.
+ */
+ function getResponse( $file,$options )
+ {
+ // TODO: Nur angeforderte Elemente erzeugen.
+ $response = '';
+ $response .= '<d:response>';
+ $response .= '<d:href>'.$file.'</d:href>';
+ $response .= '<d:propstat>';
+ $response .= '<d:prop>';
+ // $response .= '<d:source></d:source>';
+ $response .= '<d:creationdate>'.date('r',$options['createdate']).'</d:creationdate>';
+ $response .= '<d:displayname>'.$options['displayname'].'</d:displayname>';
+ $response .= '<d:getcontentlength>'.$options['size'].'</d:getcontentlength>';
+ $response .= '<d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">'.date('r',$options['lastchangedate']).'</d:getlastmodified>';
+
+ if ( $options['type'] == 'folder')
+ $response .= '<d:resourcetype><d:collection/></d:resourcetype>';
+ else
+ $response .= '<d:resourcetype />';
+
+ $response .= '<d:categories />';
+ $response .= '<d:fields></d:fields>';
+
+
+
+// $response .= '<d:getcontenttype>text/html</d:getcontenttype>';
+// $response .= '<d:getcontentlength />';
+// $response .= '<d:getcontentlanguage />';
+// $response .= '<d:executable />';
+// $response .= '<d:resourcetype>';
+// $response .= '<d:collection />';
+// $response .= '</d:resourcetype>';
+// $response .= '<d:getetag />';
+
+ $response .= '</d:prop>';
+ $response .= '<d:status>HTTP/1.1 200 OK</d:status>';
+ $response .= '</d:propstat>';
+ $response .= '</d:response>';
+
+ return $response;
+ }
+
+
+
+ /**
+ * URI parsen.
+ */
+ function parseURI( $uri )
+ {
+ // Ergebnis initialisieren (damit alle Schl�ssel vorhanden sind)
+ $ergebnis = array('type' => null,
+ 'project' => null,
+ 'path' => array(),
+ 'folder' => null,
+ 'object' => null );
+
+ Logger::trace( 'WEBDAV: Parsen der URI '.$uri);
+ $uriParts = explode('/',$uri);
+
+ $nr = 0;
+ $f = null;
+ $o = null;
+ $ergebnis['type'] = 'projectlist';
+
+ foreach( $uriParts as $uriPart )
+ {
+ if ( empty( $uriPart))
+ continue;
+
+ $ergebnis['path'][] = $uriPart;
+
+ if ( $f == null )
+ {
+ // URI='/project/'
+ // Name des Projektes in der URL, es wird das Projekt geladen.
+ $ergebnis['type'] = 'object';
+
+ $p = new Project();
+ $p->name = $uriPart;
+ Logger::trace("Projektname: ".$p->name);
+ $p->loadByName();
+ $ergebnis['project'] = $p;
+ // Das Projekt hat weder Sprache noch Variante gesetzt.
+ //Session::setProjectLanguage( new Language( $this->project->getDefaultLanguageId() ) );
+ //Session::setProjectModel ( new Model ( $this->project->getDefaultModelId() ) );
+
+ $oid = $p->getRootObjectId();
+
+ $f = new Folder($oid);
+ $ergebnis['object'] = $f;
+ $ergebnis['folder'] = $f;
+
+ }
+ else
+ {
+ if ( $ergebnis['object'] == null )
+ {
+ $this->httpStatus('409 Conflict');
+ exit;
+ }
+
+ $oid = $f->getObjectIdByFileName($uriPart);
+
+ if ( $oid == 0 )
+ {
+ Logger::trace( 'WEBDAV: URL-Part does not exist: '.$uriPart);
+ $ergebnis['object'] = null;
+ }
+ else
+ {
+ Logger::trace( 'Teil '.$uriPart);
+ $o = new Object($oid);
+ $o->load();
+ $ergebnis['object'] = $o;
+
+ if ( $o->isFolder )
+ {
+ $f = new Folder($oid);
+ $ergebnis['folder'] = $f;
+ }
+ }
+ }
+ }
+
+ return $ergebnis;
+ }
+}
+
+
+
+/**
+ * Fehler-Handler fuer WEBDAV.<br>
+ * Bei einem Laufzeitfehler ist eine Ausgabe des Fehlers auf der Standardausgabe sinnlos,
+ * da der WebDAV-Client dies nicht lesen oder erkennen kann.
+ * Daher wird der Fehler-Handler umgebogen, so dass nur ein Logeintrag sowie ein
+ * Server-Fehler erzeugt wird.
+ */
+function webdavErrorHandler($errno, $errstr, $errfile, $errline)
+{
+ Logger::warn('WEBDAV ERROR: '.$errno.'/'.$errstr.'/file:'.$errfile.'/line:'.$errline);
+
+ // Wir teilen dem Client mit, dass auf dem Server was schief gelaufen ist.
+ WebdavAction::httpStatus('500 Internal Server Error, WebDAV-Request failed with "'.$errstr.'"');
+}
+
+?>+
\ No newline at end of file
diff --git a/action/WebdavAction.ini.php b/action/WebdavAction.ini.php
@@ -0,0 +1,53 @@
+
+[default]
+goto=none
+guest=true
+
+[get]
+direct=true
+guest=true
+
+[head]
+direct=true
+guest=true
+
+[put]
+direct=true
+guest=true
+
+[mkcol]
+direct=true
+guest=true
+
+[delete]
+direct=true
+guest=true
+
+[copy]
+direct=true
+guest=true
+
+[move]
+direct=true
+guest=true
+
+[options]
+direct=true
+guest=true
+
+[propfind]
+direct=true
+guest=true
+
+[proppatch]
+direct=true
+guest=true
+
+[lock]
+direct=true
+guest=true
+
+[unlock]
+direct=true
+guest=true
+
diff --git a/actionClasses/.htaccess b/actionClasses/.htaccess
@@ -1,2 +0,0 @@
-order deny,allow
-deny from all-
\ No newline at end of file
diff --git a/actionClasses/BackgroundAction.class.php b/actionClasses/BackgroundAction.class.php
@@ -1,124 +0,0 @@
-<?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/actionClasses/BackgroundAction.ini.php b/actionClasses/BackgroundAction.ini.php
@@ -1,5 +0,0 @@
-
-[default]
-goto=show
-
-[show]
diff --git a/actionClasses/BorderAction.class.php b/actionClasses/BorderAction.class.php
@@ -1,123 +0,0 @@
-<?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/actionClasses/BorderAction.ini.php b/actionClasses/BorderAction.ini.php
@@ -1,5 +0,0 @@
-
-[default]
-goto=show
-
-[show]
diff --git a/actionClasses/ClipboardAction.class.php b/actionClasses/ClipboardAction.class.php
@@ -1,57 +0,0 @@
-<?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/actionClasses/ElementAction.class.php b/actionClasses/ElementAction.class.php
@@ -1,635 +0,0 @@
-<?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( ' » ',$names );
- $folders[ $id ] .= ' » ';
- }
- $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/actionClasses/ElementAction.ini.php b/actionClasses/ElementAction.ini.php
@@ -1,35 +0,0 @@
-
-[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/actionClasses/EmptyAction.class.php b/actionClasses/EmptyAction.class.php
@@ -1,73 +0,0 @@
-<?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/actionClasses/EmptyAction.ini.php b/actionClasses/EmptyAction.ini.php
@@ -1,9 +0,0 @@
-
-[default]
-goto=blank
-
-[border]
-
-[blank]
-
-[background]
diff --git a/actionClasses/FileAction.class.php b/actionClasses/FileAction.class.php
@@ -1,713 +0,0 @@
-<?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');
- }
- $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/actionClasses/FileAction.ini.php b/actionClasses/FileAction.ini.php
@@ -1,89 +0,0 @@
-
-[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,size,rights-
\ No newline at end of file
diff --git a/actionClasses/FilebrowserAction.class.php b/actionClasses/FilebrowserAction.class.php
@@ -1,252 +0,0 @@
-<?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('&','&',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/actionClasses/FilebrowserAction.ini.php b/actionClasses/FilebrowserAction.ini.php
@@ -1,18 +0,0 @@
-
-[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/actionClasses/FolderAction.class.php b/actionClasses/FolderAction.class.php
@@ -1,1227 +0,0 @@
-<?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/actionClasses/FolderAction.ini.php b/actionClasses/FolderAction.ini.php
@@ -1,123 +0,0 @@
-
-[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/actionClasses/GroupAction.class.php b/actionClasses/GroupAction.class.php
@@ -1,348 +0,0 @@
-<?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/actionClasses/GroupAction.ini.php b/actionClasses/GroupAction.ini.php
@@ -1,43 +0,0 @@
-
-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/actionClasses/LanguageAction.class.php b/actionClasses/LanguageAction.class.php
@@ -1,286 +0,0 @@
-<?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/actionClasses/LanguageAction.ini.php b/actionClasses/LanguageAction.ini.php
@@ -1,36 +0,0 @@
-
-[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/actionClasses/LinkAction.class.php b/actionClasses/LinkAction.class.php
@@ -1,202 +0,0 @@
-<?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/actionClasses/LinkAction.ini.php b/actionClasses/LinkAction.ini.php
@@ -1,43 +0,0 @@
-
-[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/actionClasses/LoginAction.class.php b/actionClasses/LoginAction.class.php
@@ -1,1676 +0,0 @@
-<?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 ( !$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/actionClasses/LoginAction.ini.php b/actionClasses/LoginAction.ini.php
@@ -1,104 +0,0 @@
-
-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/actionClasses/MainAction.class.php b/actionClasses/MainAction.class.php
@@ -1,97 +0,0 @@
-<?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/actionClasses/MainAction.ini.php b/actionClasses/MainAction.ini.php
@@ -1,47 +0,0 @@
-
-[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/actionClasses/MainmenuAction.class.php b/actionClasses/MainmenuAction.class.php
@@ -1,557 +0,0 @@
-<?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/actionClasses/MainmenuAction.ini.php b/actionClasses/MainmenuAction.ini.php
@@ -1,50 +0,0 @@
-
-[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/actionClasses/ModelAction.class.php b/actionClasses/ModelAction.class.php
@@ -1,225 +0,0 @@
-<?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/actionClasses/ModelAction.ini.php b/actionClasses/ModelAction.ini.php
@@ -1,33 +0,0 @@
-
-[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/actionClasses/ObjectAction.class.php b/actionClasses/ObjectAction.class.php
@@ -1,343 +0,0 @@
-<?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/actionClasses/PageAction.class.php b/actionClasses/PageAction.class.php
@@ -1,809 +0,0 @@
-<?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( ' » ',$f->parentObjectNames(false,true) );
- $objects[ $oid ] .= ' » '.$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( ' » ',$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><$1</strong>$2<strong>></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/actionClasses/PageAction.ini.php b/actionClasses/PageAction.ini.php
@@ -1,80 +0,0 @@
-
-[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/actionClasses/PageelementAction.class.php b/actionClasses/PageelementAction.class.php
@@ -1,1350 +0,0 @@
-<?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( ' » ',$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/actionClasses/PageelementAction.ini.php b/actionClasses/PageelementAction.ini.php
@@ -1,51 +0,0 @@
-
-[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/actionClasses/ProfileAction.class.php b/actionClasses/ProfileAction.class.php
@@ -1,297 +0,0 @@
-<?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/actionClasses/ProfileAction.ini.php b/actionClasses/ProfileAction.ini.php
@@ -1,42 +0,0 @@
-
-[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/actionClasses/ProjectAction.class.php b/actionClasses/ProjectAction.class.php
@@ -1,318 +0,0 @@
-<?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/actionClasses/ProjectAction.ini.php b/actionClasses/ProjectAction.ini.php
@@ -1,39 +0,0 @@
-
-; 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/actionClasses/SearchAction.class.php b/actionClasses/SearchAction.class.php
@@ -1,248 +0,0 @@
-<?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/actionClasses/SearchAction.ini.php b/actionClasses/SearchAction.ini.php
@@ -1,27 +0,0 @@
-
-[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/actionClasses/StartAction.class.php b/actionClasses/StartAction.class.php
@@ -1,1665 +0,0 @@
-<?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/actionClasses/StartAction.ini.php b/actionClasses/StartAction.ini.php
@@ -1,20 +0,0 @@
-
-admin=false
-
-[default]
-goto=projectmenu
-
-[applications]
-menu=menu
-
-[userinfo]
-direct=true
-
-[administration]
-menu=menu
-
-[projectmenu]
-menu=menu
-
-[menu]
-menu=projectmenu,applications
diff --git a/actionClasses/StatusAction.class.php b/actionClasses/StatusAction.class.php
@@ -1,77 +0,0 @@
-<?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
- $projects = $user->projects;
- $this->setTemplateVar('projects',$projects);
- }
-
- $project = Session::getProject();
- if ( is_object($project) )
- {
- if ( $project->projectid > 0 )
- {
- $this->setTemplateVar('projectid',$project->projectid);
- $this->setTemplateVar('languages',$project->getLanguages());
- $language = Session::getProjectLanguage();
- if ( is_object($language) )
- $this->setTemplateVar('languageid',$language->languageid);
- $this->setTemplateVar('models' ,$project->getModels() );
- $model = Session::getProjectModel();
- if ( is_object($model) )
- $this->setTemplateVar('modelid',$model->modelid);
-
- // TODO: Nur Projekt-Admins
- $this->setTemplateVar('templates',$project->getTemplates());
- }
- else
- {
- $this->setTemplateVar('users' ,User::listAll() );
- $this->setTemplateVar('groups',Group::getAll() );
- }
- }
-
- }
-
-}
-
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/StatusAction.ini.php b/actionClasses/StatusAction.ini.php
@@ -1,7 +0,0 @@
-
-admin=false
-
-[default]
-goto=show
-
-[show]
diff --git a/actionClasses/TemplateAction.class.php b/actionClasses/TemplateAction.class.php
@@ -1,690 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2009 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; 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 Seitenvorlage.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-
-class TemplateAction extends Action
-{
- var $defaultSubAction = 'show';
- var $template;
- var $element;
-
-
- function TemplateAction()
- {
- if ( $this->getRequestId() != 0 )
- {
- $this->template = new Template( $this->getRequestId() );
- $this->template->load();
- $this->setTemplateVar( 'templateid',$this->template->templateid );
- }
- else
- {
- $this->defaultSubAction = 'listing';
- }
-
- if ( intval($this->getRequestVar('elementid')) != 0 )
- {
- $this->element = new Element( $this->getRequestVar('elementid') );
- $this->element->load();
- $this->setTemplateVar( 'elementid',$this->element->elementid );
- }
- }
-
-
- function savesrc()
- {
- // Speichern des Quelltextes
- //
- $text = $this->getRequestVar('src','raw');
-
- foreach( $this->template->getElementNames() as $elid=>$elname )
- {
- $text = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}',$text );
- $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFEMPTY:' .$elid.':BEGIN}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFEMPTY:' .$elid.':END}}' ,$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFNOTEMPTY:'.$elid.':BEGIN}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFNOTEMPTY:'.$elid.':END}}' ,$text );
- }
-
- $this->template->src = $text;
- $this->template->save();
- $this->template->load();
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
-
- function srcaddelement()
- {
- $text = $this->template->src;
-
- switch( $this->getRequestVar('type') )
- {
- case 'addelement':
- $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
- break;
-
- case 'addicon':
- $text .= "\n".'{{->'.$this->getRequestVar('writable_elementid').'}}';
- break;
-
- case 'addifempty':
- $text .= "\n".'{{IFEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
- break;
-
- case 'addifnotempty':
- $text .= "\n".'{{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
- break;
-
- default:
- $this->addValidationError('type');
- $this->callSubAction('srcelement');
- return;
- }
-
- $this->template->src = $text;
-
- $this->template->save();
- $this->template->load();
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
- // Speichern der Template-Eigenschaftens
- //
- function savename()
- {
-
- if ($this->getRequestVar('name') == "")
- {
- $this->addValidationError('name');
- $this->callSubAction('name');
- return;
- }
- else
- {
- $this->template->name = $this->getRequestVar('name');
- $this->template->save();
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
- }
-
-
- // Speichern der Template-Eigenschaftens
- //
- function delete()
- {
- if ( $this->getRequestVar('delete') != '' )
- {
- $this->template->delete();
- $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN);
- }
- }
-
-
- /**
- * Entfernen der Vorlage
- */
- function remove()
- {
- $this->setTemplateVar('name',$this->template->name);
- }
-
-
- /**
- * Anzeigen aller Seiten der Vorlage.
- */
- function pages()
- {
- $pages = array();
- $pageids = $this->template->getDependentObjectIds();
-
- foreach( $pageids as $pageid )
- {
- $page = new Page($pageid);
- $page->load();
-
- $pages[$pageid] = $page->name;
- }
-
- $this->setTemplateVar('pages',$pages);
- }
-
-
- // Speichern der Dateiendung
- //
- function saveextension()
- {
- if ( $this->getRequestVar('type') == "list" )
- $this->template->extension = $this->getRequestVar('extension');
- else
- $this->template->extension = $this->getRequestVar('extensiontext');
-
- $this->template->save();
- $this->addNotice('template',$this->template->name,'SAVED','ok');
- }
-
-
- function addel()
- {
- // Die verschiedenen Element-Typen
- $types = array();
-
- foreach( Element::getAvailableTypes() as $t )
- {
- $types[ $t ] = 'EL_'.$t;
- }
-
- // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
- if ( !$this->userIsAdmin() )
- unset( $types['code'] );
-
- $this->setTemplateVar('types',$types);
- }
-
-
-
- /*
- * Neues Element hinzufuegen.
- */
- function addelement()
- {
-
- $name = $this->getRequestVar('name',OR_FILTER_ALPHANUM);
- if ( empty($name) )
- {
- $this->addValidationError('name');
- $this->callSubAction('addel');
- return;
- }
-
- $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('type') );
- $this->setTemplateVar('tree_refresh',true);
-
- if ( $this->hasRequestVar('addtotemplate') )
- {
- $elnames = $this->template->getElementNames();
- $elid = array_search($name,$elnames);
- $this->template->src .= "\n".'{{'.$elid.'}}';
- $this->template->save();
- }
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
- /**
- * Vorlage hinzuf�gen.
- */
- function add()
- {
- $this->setTemplateVar( 'templates',Template::getAll() );
-
- $examples = array();
- $dir = opendir( 'examples/templates');
- while( $file = readdir($dir) )
- {
- if ( substr($file,0,1) != '.')
- {
- $examples[$file] = $file;
- }
- }
-
- $this->setTemplateVar( 'examples',$examples );
- }
-
-
-
- function addtemplate()
- {
- // Hinzufuegen eines Templates
- if ( $this->getRequestVar('name') == '' )
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- return;
- }
-
- // Hinzufuegen eines Templates
- switch( $this->getRequestVar('type') )
- {
- case 'empty':
-
- $template = new Template();
- $template->add( $this->getRequestVar('name') );
- $this->addNotice('template',$template->name,'ADDED','ok');
- break;
-
- case 'copy':
-
- $copy_templateid = intval($this->getRequestVar('templateid') );
-
- if ( $copy_templateid == 0 )
- {
- $this->addValidationError('templateid');
- $this->callSubAction('add');
- return;
- }
-
- $template = new Template();
- $template->add( $this->getRequestVar('name') );
- $this->addNotice('template',$template->name,'ADDED','ok');
-
- $copy_template = new Template( $copy_templateid );
- $copy_template->load();
- foreach( $copy_template->getElements() as $element )
- {
- $element->load();
- $element->templateid = $template->templateid;
- $element->add();
- $element->save();
- }
-
- $this->addNotice('template',$copy_template->name,'COPIED','ok');
-
- break;
-
- case 'example':
-
- $template = new Template();
-
- $model = Session::getProjectModel();
- $template->modelid = $model->modelid;
-
- $template->add( $this->getRequestVar('name') );
-
- $example = parse_ini_file('examples/templates/'.$this->getRequestVar('example'),true);
-
- foreach( $example as $exampleKey=>$exampleElement )
- {
- if ( !is_array($exampleElement) )
- {
- $template->$exampleKey = $exampleElement;
- }
- else
- {
- $element = new Element();
- $element->templateid = $template->templateid;
- $element->name = $exampleKey;
- $element->writable = true;
- $element->add();
-
- foreach( $exampleElement as $ePropName=>$ePropValue)
- $element->$ePropName = $ePropValue;
-
- $element->defaultText = str_replace(';',"\n",$element->defaultText);
- $element->save();
-// Html::debug($element,"Element");
- }
- }
-// Html::debug($template,"Template");
- $template->name = $this->getRequestVar('name');
- $template->src = str_replace(';',"\n",$template->src);
-
- foreach( $template->getElementNames() as $elid=>$elname )
- {
- $template->src = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}' ,$template->src );
- $template->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$template->src );
- }
-
- $template->save();
- $this->addNotice('template',$template->name,'ADDED','ok');
-
- break;
- default:
- $this->addValidationError('type');
- $this->callSubAction('add');
- return;
- }
-
-
- $this->setTemplateVar('tree_refresh',true);
- }
-
-
- function prop()
- {
- }
-
-
-
- /**
- * Eigenschaften einer Vorlage anzeigen
- */
- function name()
- {
- $this->setTemplateVar('name' ,$this->template->name );
- $this->setTemplateVar('extension',$this->template->extension );
- $this->setTemplateVar('mime_type',$this->template->mimeType() );
- }
-
-
-
- /**
- * Eigenschaften einer Vorlage anzeigen
- */
- function extension()
- {
-
- global $conf;
- $mime_types = array();
- foreach( $conf['mime-types'] as $ext=>$type )
- $mime_types[$ext] = $ext.' - '.$type;
-
- $this->setTemplateVar('mime_types',$mime_types);
-
- $this->setTemplateVar('extension' ,$this->template->extension);
- $this->setTemplateVar('extensiontext',$this->template->extension);
-
- if ( isset($mime_types[$this->template->extension]) )
- $this->setTemplateVar('type','list');
- else
- $this->setTemplateVar('type','text');
- }
-
-
-
- /**
- * Voransicht einer Vorlage
- */
- function show()
- {
- $text = $this->template->src;
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = Html::url( 'element','edit',$this->template->templateid,array('elementid'=>$elid));
-
- $text = str_replace('{{'.$elid.'}}',$element->name,
- $text );
- $text = str_replace('{{->'.$elid.'}}','',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}','',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}','',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}','',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}','',
- $text );
-
- unset( $element );
- }
-
- echo $text;
-
- exit();
- }
-
-
- /**
- * Bearbeiten einer Vorlage
- */
- function edit()
- {
- $text = htmlentities( $this->template->src );
- $text = str_replace("\n",'<br/>',$text);
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = Html::url( 'element','name',$elid );
-
- $text = str_replace('{{'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
- $element->name.'}}</a>',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
- $element->name.'}}</a>',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- unset( $element );
- }
-
- $this->setTemplateVar('text',$text);
- }
-
-
- // Anzeigen der Template-Elemente
- //
- function el()
- {
- global $conf_php;
- $list = array();
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $list[$elid] = array();
- $list[$elid]['url' ] = Html::url('element','name',$elid);
- $list[$elid]['name'] = $element->name;
- $list[$elid]['desc'] = $element->desc;
- $list[$elid]['type'] = $element->type;
-
- unset( $element );
- }
- $this->setTemplateVar('el',$list);
- }
-
-
-
- function srcelement()
- {
- $elements = array();
- $writable_elements = array();
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $elements[$elid] = $element->name;
-
- if ( $element->isWritable() )
- $writable_elements[$elid] = $element->name;
- }
-
- $this->setTemplateVar('elements' ,$elements );
- $this->setTemplateVar('writable_elements',$writable_elements);
- }
-
-
-
- /**
- * Anzeigen des Template-Quellcodes
- */
- function src()
- {
- if ( $this->isEditMode() )
- {
- $text = $this->template->src;
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $text = str_replace('{{'.$elid.'}}',
- '{{'.$element->name.'}}',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '{{->'.$element->name.'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- }
-
- $this->setTemplateVar( 'src',$text );
- }
- else
- {
- $text = htmlentities( $this->template->src );
- $text = str_replace("\n",'<br/>',$text);
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = Html::url( 'element','name',$elid );
-
- $text = str_replace('{{'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
- $element->name.'}}</a>',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
- $element->name.'}}</a>',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- unset( $element );
- }
-
- $this->setTemplateVar('src',$text);
- }
-
- }
-
-
- // Anzeigen aller Templates
- //
- function listing()
- {
- global $conf_php;
-
- $list = array();
-
- foreach( Template::getAll() as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['name'] = $name;
- $list[$id]['url' ] = Html::url('main','template',$id,array(REQ_PARAM_TARGETSUBACTION=>'el'));
- }
-
-// $var['templatemodelid'] = htmlentities( $id );
-// $var['text'] = htmlentities( $text );
- $this->setTemplateVar('templates',$list);
- }
-
-
- /**
- * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
- *
- * @see actionClasses/Action#checkMenu($name)
- */
- function checkMenu( $menu ) {
-
- switch( $menu)
- {
- case 'srcelement':
- // Platzhalter nur hinzufuegbar, wenn es welche gibt.
- return is_object($this->template) &&
- (count($this->template->getElementIds()) > 0);
-
- case 'remove':
- // Entfernen von Templates nur dann erlaubt, wenn keine Seiten auf diesem Template basieren.
- return is_object($this->template) &&
- (count($this->template->getDependentObjectIds()) == 0);
-
- case 'pages':
- // Anzeige von Seiten nur dann sinnvoll, wenn es auch Seiten gibt.
- return is_object($this->template) &&
- (count($this->template->getDependentObjectIds()) > 0);
-
- case 'add':
- case 'addel':
- return !readonly();
-
- default:
- return true;
-
- }
- }
-
-}-
\ No newline at end of file
diff --git a/actionClasses/TemplateAction.ini.php b/actionClasses/TemplateAction.ini.php
@@ -1,70 +0,0 @@
-[default]
-goto=listing
-
-[listing]
-menu=listing
-
-[add]
-menu=listing
-target=addtemplate
-
-[addtemplate]
-goto=listing
-
-[show]
-direct=true
-
-[prop]
-goto=name
-
-[el]
-menu=el
-
-[addel]
-menu=el
-target=addelement
-
-[addelement]
-goto=el
-
-[src]
-menu=edit
-target=savesrc
-editable=true
-
-[srcelement]
-menu=edit
-target=srcaddelement
-
-[srcaddelement]
-goto=src
-
-[savesrc]
-goto=src
-
-[name]
-menu=prop
-target=savename
-
-[savename]
-goto=name
-
-[saveextension]
-goto=name
-
-[extension]
-menu=prop
-target=saveextension
-
-[remove]
-menu=prop
-target=delete
-
-[delete]
-goto=listing
-
-[pages]
-menu=prop
-
-[menu]
-menu=listing,name,extension,pages,remove,el,src-
\ No newline at end of file
diff --git a/actionClasses/TitleAction.class.php b/actionClasses/TitleAction.class.php
@@ -1,95 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2009 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.
-
-
-/**
- * Actionklasse zum Anzeigen der Titelleiste.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class TitleAction extends Action
-{
- /**
- * Fuellen der Variablen und Anzeigen der Titelleiste
- */
- function show()
- {
- $this->setTemplateVar('buildinfo',OR_TITLE.' '.OR_VERSION.' - build '.config('build','build') );
-
- $db = Session::getDatabase();
- $this->setTemplateVar('dbname',$db->conf['comment'].(readonly()?' ('.lang('readonly').')':''));
-
- $databases = array();
- global $conf;
- foreach( $conf['database'] as $dbid=>$dbconf )
- if ( $dbconf['enabled'])
- $databases[$dbid] = $dbconf['comment'];
- $this->setTemplateVar('databases',$databases);
-
- $user = Session::getUser();
- $this->setTemplateVar('username' ,$user->name );
- $this->setTemplateVar('userfullname',$user->fullname);
-
- $project = Session::getProject();
- if ( is_object($project) )
- {
- $this->setTemplateVar('projectname',$project->name);
- $this->setTemplateVar('projects' ,Project::getAll() );
- }
-
-
-
- $language = Session::getProjectLanguage();
- if ( is_object($language) )
- {
- $this->setTemplateVar('languagename',$language->name);
- $this->setTemplateVar('languages',Language::getAll() );
- }
-
- $model = Session::getProjectModel();
- if ( is_object($model) )
- {
- $this->setTemplateVar('modelname',$model->name);
- $this->setTemplateVar('models' ,Model::getAll() );
- }
-
- // Urls zum Benutzerprofil und zum Abmelden
- //$this->setTemplateVar('profile_url',Html::url( 'profile' ));
- //$this->setTemplateVar('logout_url' ,Html::url( 'index','logout' ));
-
- if ( Session::get('showtree') )
- {
- $this->setTemplateVar('showtree_url' ,Html::url('index','hidetree') );
- $this->setTemplateVar('showtree_text',lang('HIDETREE') );
- }
- else
- {
- $this->setTemplateVar('showtree_url' ,Html::url('index','showtree') );
- $this->setTemplateVar('showtree_text',lang('SHOWTREE') );
- }
-
- if ( config('interface','session','auto_extend') )
- {
- $this->setTemplateVar('refresh_url' ,Html::url('title','show') );
- $this->setTemplateVar('refresh_timeout',ini_get('session.gc_maxlifetime')-60 );
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/TitleAction.ini.php b/actionClasses/TitleAction.ini.php
@@ -1,5 +0,0 @@
-
-[default]
-goto=show
-
-[show]-
\ No newline at end of file
diff --git a/actionClasses/TransferAction.class.php b/actionClasses/TransferAction.class.php
@@ -1,241 +0,0 @@
-<?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.5 2004-12-26 20:20:57 dankert
-// Bei erstem Aufruf Fehlermeldung vermeiden
-//
-// Revision 1.4 2004/11/28 23:55:36 dankert
-// addNotice()
-//
-// Revision 1.3 2004/05/02 14:49:37 dankert
-// Einf?gen package-name (@package)
-//
-// Revision 1.2 2004/04/24 20:30:23 dankert
-// addslashes() entfernt
-//
-// Revision 1.1 2004/04/24 15:14:52 dankert
-// Initiale Version
-//
-// ---------------------------------------------------------------------------
-
-
-/**
- * Action-Klasse fuer Dateitransfers
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class TransferAction extends Action
-{
- var $defaultSubAction = 'import';
-
-
- function TransferAction()
- {
- }
-
-
- function import()
- {
- $folderName = $this->getRequestVar('local_folder');
-
- if ( $folderName != '' )
- {
- $dir = @opendir( $folderName );
-
- if ( !is_resource( $dir ) )
- {
- $this->addNotice('file',"directory '$folderName' not readable",'ERROR','error');
- }
- else
- {
- while( $filename = readdir($dir) )
- {
- $full_filename = $folderName.'/'.$filename;
-
- if ( $filename != "." &&
- $filename != ".." &&
- is_file($full_filename) )
- {
- $file = new File();
- $file->parentid = intval( $this->getRequestVar('objectid') );
- $file->parse_filename( basename($filename) );
- $file->name = $file->filename;
- $file->desc = '';
-
- // Datei lesen
- $f = fopen( $full_filename,'r' );
- $file->value = fread($f,filesize($full_filename));
- fclose( $f );
-
- $file->add();
- $this->addNotice('file',$file->name,'IMPORTED','ok');
-
- unset( $file );
- }
- }
- closedir( $dir );
- }
- }
-
- $folders = array();
-
- $folder = new Folder();
- foreach( $folder->getAllFolders() as $objectid )
- {
- $f = new Folder( $objectid );
- $folders[$objectid] = implode( FILE_SEP,$f->parentObjectNames(true,true) );
- }
-
- asort( $folders );
- $this->setTemplateVar( 'folders',$folders );
- }
-
-
-// function export()
-// {
-// if ( isset($REQ['folderid']) && isset($REQ['local_folder']) )
-// {
-// if ( !is_dir( $REQ['local_folder'] ) )
-// {
-// $var['log'] = 'directory not found';
-// }
-// else
-// {
-// $var['log'] = "reading projectfolder ...\n";
-//
-// $sql = new Sql( 'SELECT * FROM {t_file}'.
-// ' WHERE folderid={folderid}' );
-// $sql->setInt('folderid',$REQ['folderid']);
-// $files = $db->getCol( $sql->query );
-//
-// foreach( $files as $fileid )
-// {
-// $file = new File();
-// $file->fileid = $fileid;
-// $file->load();
-//
-// $full_filename = $REQ['local_folder'].'/'.$file->filename;
-// if ( $file->extension != '' )
-// $full_filename .= '.'.$file->extension;
-// $var['log'] .= "saving $full_filename\n";
-//
-// // Datei lesen
-// $f = fopen( $file->tmpfile(),'r' );
-// $value = fread($f,filesize($file->tmpfile()));
-// fclose( $f );
-//
-// // Datei lesen
-// $f = fopen( $full_filename,'w' );
-// fwrite( $f,$value );
-// fclose( $f );
-//
-// unset( $file );
-// }
-// }
-// }
-//
-//
-// $folders = array();
-//
-// $folder = new Folder();
-// foreach( $folder->getAllFolders() as $objectid )
-// {
-// $f = new Folder( $objectid );
-// $folders[$objectid] = implode( ' » ',$f->parentObjectNames(true,true) );
-// }
-//
-// asort( $folders );
-// $this->setTemplateVar( 'folders',$folders );
-//
-//
-// $this->forward( 'transfer_export' );
-// }
-
-
-// function copyproject()
-// {
-// if ( isset($REQ['folderid']) && isset($REQ['local_folder']) )
-// {
-// if ( !is_dir( $REQ['local_folder'] ) )
-// {
-// $var['log'] = 'directory not found';
-// }
-// else
-// {
-// $var['log'] = "reading projectfolder ...\n";
-//
-// $sql = new Sql( 'SELECT * FROM {t_file}'.
-// ' WHERE folderid={folderid}' );
-// $sql->setInt('folderid',$REQ['folderid']);
-// $files = $db->getCol( $sql->query );
-//
-// foreach( $files as $fileid )
-// {
-// $file = new File();
-// $file->fileid = $fileid;
-// $file->load();
-//
-// $full_filename = $REQ['local_folder'].'/'.$file->filename;
-// if ( $file->extension != '' )
-// $full_filename .= '.'.$file->extension;
-// $var['log'] .= "saving $full_filename\n";
-//
-// // Datei lesen
-// $f = fopen( $file->tmpfile(),'r' );
-// $value = fread($f,filesize($file->tmpfile()));
-// fclose( $f );
-//
-// // Datei lesen
-// $f = fopen( $full_filename,'w' );
-// fwrite( $f,$value );
-// fclose( $f );
-//
-// unset( $file );
-// }
-// }
-// }
-//
-//
-// $sql = new Sql( 'SELECT id FROM {t_folder}' );
-// $sql->setInt('projectid',$projectid);
-// $folders = $db->getCol( $sql->query );
-//
-// $var['folders'] = array();
-//
-// foreach( $folders as $folderid )
-// {
-// $folder = new Folder( $folderid );
-// $folder->load();
-// $folder->filenames = false;
-// $var['folders'][$folderid] = implode(' » ',$folder->parentfolder( true,true ));
-// }
-//
-// asort( $var['folders'] );
-//
-// $this->forward( 'transfer_copyproject' );
-// }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/TreeAction.class.php b/actionClasses/TreeAction.class.php
@@ -1,248 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// DaCMS 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 zum Laden/Anzeigen des Navigations-Baumes
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class TreeAction extends Action
-{
- var $tree;
-
-
- /**
- * ?ffnen aller Baumelemente
- */
- function openall()
- {
- $this->tree = Session::getTree();
- $this->tree->all();
- Session::setTree( $this->tree );
- }
-
-
-// function refresh()
-// {
-// $this->tree = Session::getTree();
-// $this->tree->refresh();
-// Session::setTree( $this->tree );
-// }
-
-
- /**
- * ?ffnen eines Baumelementes
- */
- function open()
- {
- $this->tree = Session::getTree();
- $this->tree->open( $this->getRequestId() );
- Session::setTree( $this->tree );
- }
-
-
- /**
- * Schlie?en eines Baumelementes
- */
- function close()
- {
- $this->tree = Session::getTree();
- $this->tree->close( $this->getRequestId() );
- Session::setTree( $this->tree );
- }
-
-
- /**
- * Neues Laden des Baumes
- */
- function loadAction()
- {
- global $SESS;
-
- $projectid = $this->getRequestVar('projectid');
-
- if ( $projectid == -1 )
- {
- $this->tree = new AdministrationTree();
- Session::setProjectLanguage(null);
- Session::setProjectModel(null);
- Session::setProject(null);
- }
- else
- {
- $project = new Project($projectid);
- $project->load();
- Session::setProject($project);
-
- $this->tree = new ProjectTree();
- $this->tree->projectId = $projectid;
-
- $language = new Language( Language::getDefaultId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( Model::getDefaultId() );
- $model->load();
- Session::setProjectModel( $model );
- }
-
- Session::setTree( $this->tree );
- }
-
-
- public function loadView()
- {
-
- }
-
- /**
- * Liefert ein Array mit allen Zeilen des Baumes.
- *
- * Ruft sich intern rekursiv auf.
- *
- * @param $elId
- * @param $tiefe
- * @param $isLast
- * @return unknown_type
- */
- function outputElement( $elId,$tiefe,$isLast )
- {
- $treeElement = $this->tree->elements[$elId];
-
- $zeilen = array();
- $zeile = array();
-
- global $class;
- $zeile['class'] = $class;
- if ( $this->getRequestId() == $elId )
- $zeile['class'] = 'opened';
- if ( $this->getRequestId() == $elId )
- $class ='active';
-
- if ( !isset($tree_last) )
- $tree_last=array();
-
- $zeile['cols'] = array();
-
- for ( $i=1; $i<=$tiefe-1; $i++ )
- {
- if ( $isLast[$i] )
- $zeile['cols'][] = 'blank';
- else
- $zeile['cols'][] = 'line';
- }
-
- if ( $tiefe == 0 )
- {
- }
- elseif ( $treeElement->type != "" )
- {
- if ( count($treeElement->subElementIds) == 0 )
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'plus_end';
- else $zeile['image'] = 'plus';
-
- $zeile['image_url' ] = Html::url('tree','open',$elId);
- $zeile['image_url_desc'] = lang('TREE_OPEN_ELEMENT');
- }
- else
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'minus_end';
- else $zeile['image'] = 'minus';
-
- $zeile['image_url' ] = Html::url('tree','close',$elId);
- $zeile['image_url_desc'] = lang('TREE_CLOSE_ELEMENT');
- }
- }
- else
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'none_end';
- else $zeile['image'] = 'none';
- }
-
-
-
- $zeile['icon'] = $treeElement->icon;
- $zeile['text'] = $treeElement->text;
- $zeile['desc'] = $treeElement->description;
- $zeile['name'] = $elId;
-
- // Url setzen
- if ( $treeElement->url != "" )
- $zeile['url'] = $treeElement->url;
-
- // HTML-Target setzen
- if ( $treeElement->target != "" )
- $zeile['target'] = $treeElement->target;
- else
- $zeile['target'] = 'cms_main';
-
- $zeile['colspan'] = 20 - count( $zeile['cols'] ) - intval(isset($zeile['image']));
-
- $zeilen[] = $zeile;
- // Rekursiv alle Unter-Elemente lesen
- $nr = 0;
- foreach( $this->tree->elements[$elId]->subElementIds as $subElementId )
- {
- $nr++;
- if ( $nr == count($this->tree->elements[$elId]->subElementIds) )
- $isLast[$tiefe+1] = true;
- else $isLast[$tiefe+1] = false;
-
- // Rekursiver Aufruf
- $zeilen = array_merge( $zeilen,$this->outputElement( $subElementId,$tiefe+1,$isLast ) );
- }
-
- if ( $this->getRequestId() == $elId )
- $class ='';
-
- return $zeilen;
- }
-
-
- /**
- * Anzeigen des Baumes
- */
- function show()
- {
- $project = Session::getProject();
- if ( is_object($project) )
- {
- $this->setTemplateVar('projectname',$project->name);
- }
-
- $this->tree = Session::getTree();
-
- if ( $this->getRequestVar('target')!='tree' )
- $this->tree->refresh();
-
- $var = array();
- $var['zeilen'] = $this->outputElement( 0,0,array() );
-
- $this->setTemplateVars( $var );
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/TreeAction.ini.php b/actionClasses/TreeAction.ini.php
@@ -1,22 +0,0 @@
-
-[default]
-goto=show
-
-[show]
-
-[load]
-write=get
-goto=show
-clear=content
-
-[openall]
-goto=show
-
-[open]
-goto=show
-
-[close]
-goto=show
-
-;[refresh]
-;goto=show
diff --git a/actionClasses/TreetitleAction.class.php b/actionClasses/TreetitleAction.class.php
@@ -1,78 +0,0 @@
-<?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 zur Darstellung des Projekt-Auswahlmenues
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-define('PROJECTID_ADMIN',-1);
-
-class TreetitleAction extends Action
-{
- var $defaultSubAction = 'show';
-
- function show()
- {
- // Das aktuelle Projekt voreinstellen
- $project = Session::getProject();
-
- if ( $project->projectid == PROJECTID_ADMIN )
- {
- $this->setTemplateVar( 'text',lang('GLOBAL_ADMINISTRATION') );
- $this->setTemplateVar( 'type','administration' );
- }
- else
- {
- $this->setTemplateVar( 'text',$project->name );
- $this->setTemplateVar( 'type','project' );
-
-// // Ermitteln Sprache
-// $language = Session::getProjectLanguage();
-//
-// $windowMenu[] = array( 'text'=>lang('GLOBAL_LANGUAGE').' ('.$language->name.')',
-// 'url' =>Html::url('main','language'),
-// 'target'=>'cms_main' );
-//
-// // Ermitteln Projektmodell
-// $model = Session::getProjectModel();
-//
-// $windowMenu[] = array( 'text'=>lang('GLOBAL_MODEL').' ('.$model->name.')',
-// 'url' =>Html::url('main','model'),
-// 'target'=>'cms_main' );
- }
- }
-
-
- function checkMenu( $name )
- {
- switch( $name )
- {
- case 'administration':
- return $this->userIsAdmin();
- default:
- return true;
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/TreetitleAction.ini.php b/actionClasses/TreetitleAction.ini.php
@@ -1,10 +0,0 @@
-
-[default]
-goto=show
-
-[show]
-menu=project
-menuaction=index
-
-[menu]
-project=projectmenu,administration-
\ No newline at end of file
diff --git a/actionClasses/UserAction.class.php b/actionClasses/UserAction.class.php
@@ -1,428 +0,0 @@
-<?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 Benutzers
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class UserAction extends Action
-{
- var $user;
- var $defaultSubAction = 'edit';
-
-
- function UserAction()
- {
- if ( !$this->userIsAdmin() )
- die('you are not an admin');
-
- if ( $this->getRequestId() != 0 )
- {
- $this->user = new User( $this->getRequestId() );
- $this->user->load();
- $this->setTemplateVar('userid',$this->user->userid);
- }
- }
-
-
- function editAction()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- // Benutzer speichern
- $this->user->name = $this->getRequestVar('name' );
- $this->user->fullname = $this->getRequestVar('fullname');
- $this->user->isAdmin = $this->hasRequestVar('is_admin');
- $this->user->ldap_dn = $this->getRequestVar('ldap_dn' );
- $this->user->tel = $this->getRequestVar('tel' );
- $this->user->desc = $this->getRequestVar('desc' );
-
- global $conf;
- if ( @$conf['security']['user']['show_admin_mail'] )
- $this->user->mail = $this->getRequestVar('mail' );
-
- $this->user->style = $this->getRequestVar('style' );
-
- $this->user->save();
- $this->addNotice('user',$this->user->name,'SAVED','ok');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('edit');
- }
- }
-
-
-
- function removeView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
- }
-
-
-
- function removeAction()
- {
- if ( $this->hasRequestVar('confirm') )
- {
- $this->user->delete();
- $this->addNotice('user',$this->user->name,'DELETED','ok');
- }
- else
- {
- $this->addValidationError('confirm');
- return;
- }
- }
-
-
- function addView()
- {
- }
-
-
-
- function addAction()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- $this->user = new User();
- $this->user->add( $this->getRequestVar('name') );
- $this->addNotice('user',$this->user->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- }
- }
-
-
- function addgrouptouser()
- {
- $this->user->addGroup( $this->getRequestVar('groupid') );
-
- $this->addNotice('user',$this->user->name,'ADDED','ok');
- }
-
-
- function addgroup()
- {
- // Alle hinzufuegbaren Gruppen ermitteln
- $this->setTemplateVar('groups',$this->user->getOtherGroups());
- }
-
-
- function delgroup()
- {
- $this->user->delGroup( $this->getRequestVar('groupid') );
-
- $this->addNotice('user',$this->user->name,'DELETED','ok');
- }
-
-
- /**
- * Das Kennwort wird an den Benutzer geschickt
- *
- * @access private
- */
- function mailPw( $pw )
- {
- $to = $this->user->fullname.' <'.$this->user->mail.'>';
- $mail = new Mail($to,'USER_MAIL');
-
- $mail->setVar('username',$this->user->name );
- $mail->setVar('password',$pw );
- $mail->setVar('name' ,$this->user->getName() );
-
- $mail->send();
- }
-
-
- /**
- * Aendern des Kennwortes
- */
- function pwAction()
- {
- global $conf;
-
- $pw1 = $this->getRequestVar('password1');
- $pw2 = $this->getRequestVar('password2');
-
- // Zufaelliges Kennwort erzeugen
- if ( $this->hasRequestVar('random') && $this->hasRequestVar('email') )
- {
- $pw1 = $this->user->createPassword();
- $pw2 = $pw1;
- }
-
- if ( strlen($pw1)<intval($conf['security']['password']['min_length']) )
- {
- $this->addValidationError('password1');
- return;
- }
- elseif ( $pw1 != $pw2 )
- {
- $this->addValidationError('password2');
- return;
- }
- else
- {
- // Kennwoerter identisch und lang genug
- $this->user->setPassword($pw1,!$this->hasRequestVar('timeout') ); // Kennwort setzen
-
- // E-Mail mit dem neuen Kennwort an Benutzer senden
- if ( $this->hasRequestVar('email') && !empty($this->user->mail) && $conf['mail']['enabled'] )
- {
- $this->mailPw( $pw1 );
- $this->addNotice('user',$this->user->name,'MAIL_SENT','ok');
- }
-
- $this->addNotice('user',$this->user->name,'SAVED','ok');
- }
-
- }
-
-
-
- function listing()
- {
- $list = array();
-
- foreach( User::getAllUsers() as $user )
- {
- $list[$user->userid] = $user->getProperties();
- $list[$user->userid]['url' ] = Html::url('main','user',$user->userid,
- array(REQ_PARAM_TARGETSUBACTION=>'edit') );
- }
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Eigenschaften des Benutzers anzeigen
- */
- function editView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
-
- $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
-
- $gravatarConfig = config('interface','gravatar');
-
- $this->setTemplateVar( 'image', 'about:blank' );
- if ( is_array($gravatarConfig) )
- {
- extract($gravatarConfig);
-
- if ( isset($enable) && $enable && !empty($this->user->mail) )
- {
- $url = 'http://www.gravatar.com/avatar/'.md5($this->user->mail).'?';
- if ( isset($size))
- $url .= '&s='.$size;
- if ( isset($default))
- $url .= '&d='.$default;
- if ( isset($rating))
- $url .= '&r='.$rating;
-
- $this->setTemplateVar( 'image', $url );
- }
- }
-
- }
-
-
- function memberships()
- {
- }
-
-
- function groupsView()
- {
- $gruppenListe = array();
-
- $allGroups = Group::getAll();
- $userGroups = $this->user->getGroups();
-
- foreach( $allGroups as $id=>$name )
- {
-
- $hasGroup = array_key_exists($id,$userGroups);
- $varName = 'group'.$id;
- $gruppenListe[$id] = array('name' =>$name,
- 'id' =>$id,
- 'var' =>$varName,
- 'member' =>$hasGroup
- );
- $this->setTemplateVar($varName,$hasGroup);
- }
- $this->setTemplateVar('memberships',$gruppenListe);
-
- global $conf;
- if ($conf['security']['authorize']['type']=='ldap')
- $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
- }
-
-
- function groupsAction()
- {
- $allGroups = Group::getAll();
- $userGroups = $this->user->getGroups();
-
- foreach( $allGroups as $id=>$name )
- {
- $hasGroup = array_key_exists($id,$userGroups);
-
- if ( !$hasGroup && $this->hasRequestVar('group'.$id) )
- {
- $this->user->addGroup($id);
- $this->addNotice('group',$name,'ADDED');
- }
-
- if ( $hasGroup && !$this->hasRequestVar('group'.$id) )
- {
- $this->user->delGroup($id);
- $this->addNotice('group',$name,'DELETED');
- }
- }
- }
-
-
- /**
- * Aendern des Kennwortes
- */
- function pwView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
- }
-
-
- /**
- * Anzeigen der Benutzerrechte
- */
- function rights()
- {
- $rights = $this->user->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->userid > 0 )
- {
- $user = new User($acl->userid);
- $user->load();
- $right['username'] = $user->name;
- }
- elseif ( $acl->groupid > 0 )
- {
- $group = new Group($acl->groupid);
- $group->load();
- $right['groupname'] = $group->name;
- }
- else
- {
- // Berechtigung f�r "alle".
- }
-
-// $show = array();
-// foreach( $acl->getProperties() as $p=>$set)
-// $show[$p] = $set;
-//
-// $right['show'] = $show;
- $right['bits'] = $acl->getProperties();
-
- $projects[$acl->projectid]['rights'][] = $right;
- }
-
- $this->setTemplateVar('projects' ,$projects );
-
- $this->setTemplateVar('show',Acl::getAvailableRights() );
-
- if ( $this->user->isAdmin )
- $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',OR_NOTICE_WARN);
- }
-
-
- /**
- * @param String $name Men�punkt
- * @return boolean
- */
- function checkMenu( $menu )
- {
- global $conf;
-
- switch( $menu )
- {
- case 'add':
- case 'remove':
- return !readonly();
-
- case 'addgroup':
- return !readonly() && count($this->user->getOtherGroups()) > 0;
-
- case 'groups':
- return !readonly() && count(Group::getAll()) > 0;
-
- case 'pw':
- return !readonly()
- && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
- }
-
- return true;
- }
-
-
-}-
\ No newline at end of file
diff --git a/actionClasses/UserAction.ini.php b/actionClasses/UserAction.ini.php
@@ -1,41 +0,0 @@
-
-admin=true
-
-[default]
-goto=listing
-
-[listing]
-menu=listing
-
-[add]
-menu=listing
-write=true
-
-[edit]
-menu=edit
-editable=true
-write=true
-
-[remove]
-menu=edit
-write=true
-
-[memberships]
-goto=groups
-
-; Gruppenzugehoerigkeiten
-[groups]
-menu=memberships
-editable=true
-write=yes
-
-[pw]
-menu=pw
-write=true
-
-[rights]
-menu=rights
-
-[menu]
-menu=listing,add,edit,remove,groups,pw,rights
-;info=show,mail
diff --git a/actionClasses/WebdavAction.class.php b/actionClasses/WebdavAction.class.php
@@ -1,1195 +0,0 @@
-<?php
-
-
-/**
- * Action-Klasse fuer WebDAV.<br>
- *
- * Das virtuelle Ordnersystem dieses CMS kann über das WebDAV-Protokoll
- * dargestellt werden.
- *
- * Diese Klasse nimmt die Anfragen von WebDAV-Clients entgegen, zerlegt die
- * Anfrage und erzeugt eine Antwort, die im HTTP-Body zurück übertragen
- * wird.
- * <br>
- * WebDAV ist spezifiziert in der RFC 2518.<br>
- * Siehe <code>http://www.ietf.org/rfc/rfc2518.txt</code><br>
- *
- * Implementiert wird DAV-Level 1 (d.h. ohne LOCK).
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-
-class WebdavAction extends Action
-{
- // Zahlreiche Instanzvariablen, die im Konstruktor
- // beim Zerlegen der Anfrag gefüllt werden.
- var $defaultSubAction = 'show';
- var $database;
- var $depth;
- var $project;
- var $folder;
- var $obj;
- var $filename;
- var $pathnames = array();
- var $uri;
- var $headers;
- var $requestType;
- var $request;
- var $destination = null;
- var $fullSkriptName;
- var $create;
- var $readonly;
- var $maxFileSize;
- var $webdav_conf;
- var $overwrite = false;
-
-
- /**
- * Im Kontruktor wird der Request analysiert und ggf. eine Authentifzierung
- * durchgefuehrt.
- */
- function WebdavAction()
- {
- if (!defined('E_STRICT'))
- define('E_STRICT', 2048);
-
- // Nicht notwendig, da wir den Error-Handler umbiegen:
- error_reporting(0); // PHP-Fehlermeldungen zerstoeren XML-Dokument, daher ausschalten.
-
- // PHP-Fehler ins Log schreiben, damit die Ausgabe nicht zerstoert wird.
- if (version_compare(PHP_VERSION, '5.0.0', '>'))
- set_error_handler('webdavErrorHandler',E_ERROR | E_WARNING);
- else
- set_error_handler('webdavErrorHandler');
-
- global $conf;
- $this->webdav_conf = $conf['webdav'];
-
- if ( $this->webdav_conf['compliant_to_redmond'] )
- header('MS-Author-Via: DAV' ); // Extrawurst fuer MS-Clients.
-
- if ( $this->webdav_conf['expose_openrat'] )
- header('X-Dav-powered-by: OpenRat CMS'); // Bandbreite verschwenden :)
-
- Logger::trace( 'WEBDAV: URI='.$_SERVER['REQUEST_URI']);
-
- if ( !$conf['webdav']['enable'])
- {
- Logger::warn( 'WEBDAV is disabled by configuration' );
- $this->httpStatus('403 Forbidden');
- exit;
- }
-
- $this->create = $this->webdav_conf['create'];
- $this->readonly = $this->webdav_conf['readonly'];
- $this->maxFileSize = $this->webdav_conf['max_file_size'];
-
- Logger::debug( 'WEBDAV method is '.$_GET['subaction'] );
-
- $this->headers = getallheaders();
- /* DAV compliant servers MUST support the "0", "1" and
- * "infinity" behaviors. By default, the PROPFIND method without a Depth
- * header MUST act as if a "Depth: infinity" header was included. */
- if ( !isset($this->headers['Depth']) )
- $this->depth = 1;
- elseif ( strtolower($this->headers['Depth'])=='infinity')
- $this->depth = 1;
- else
- $this->depth = intval($this->headers['Depth']);
-
- if ( isset($this->headers['Destination']) )
- $this->destination = $this->headers['Destination'];
-
- if ( isset($this->headers['Overwrite']) )
- $this->overwrite = $this->headers['Overwrite'] == 'T';
-
- // Pr�fen, ob Benutzer angemeldet ist.
- $user = $this->getUserFromSession();
-
- // Authentisierung erzwingen (außer bei Methode OPTIONS).
- // For the motivation for not checking OPTIONS requests see
- // http://pear.php.net/bugs/bug.php?id=5363
- if ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] != 'options' )
- {
- Logger::debug( 'Checking Authentication' );
-
- if ( !is_object(Session::getDatabase()) )
- $this->setDefaultDb();
-
- $ok = false;
- if ( isset($_SERVER['PHP_AUTH_USER']) )
- {
- $user = new User();
- $user->name = $_SERVER['PHP_AUTH_USER'];
-
- $ok = $user->checkPassword( $_SERVER['PHP_AUTH_PW'] );
-
- if ( $ok )
- {
- $user->load();
- $user->setCurrent();
- $this->redirectWithSessionId();
- }
- }
-
- if ( !$ok )
- {
- // Client ist nicht angemeldet, daher wird nun die
- // Authentisierung angefordert.
- Logger::debug( 'Requesting Client to authenticate' );
- header('WWW-Authenticate: Basic realm="'.OR_TITLE.'"');
- $this->httpStatus('401 Unauthorized');
- exit;
- }
- }
- elseif ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] == 'options' )
- {
- $this->setDefaultDb();
- }
-
-
- $this->fullSkriptName = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'/';
-
- if ( $this->webdav_conf['session_in_uri'] )
- $sos = 1+strlen(session_id())+strlen($this->webdav_conf['session_in_uri_prefix']);
- else
- $sos = 0;
-
- // URL parsen.
- $uri = substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']) + $sos);
-
- Logger::debug( 'WebDAV: URI="'.$uri.'"' );
-
- $uri = $this->parseURI( $uri );
- $this->requestType = $uri['type' ];
- $this->folder = $uri['folder' ];
- $this->obj = $uri['object' ];
- $this->project = $uri['project'];
-
- $this->fullSkriptName .= implode('/',$uri['path']);
-
- if ( is_object($this->obj) && $this->obj->isFolder )
- $this->fullSkriptName .= '/';
-
- /*
- * Verzeichnisse muessen mit einem '/' enden. Falls nicht, Redirect aussfuehren.
- *
- * RFC 2518, 5.2 Collection Resources, Page 11:
- * "For example, if a client invokes a
- * method on http://foo.bar/blah (no trailing slash), the resource
- * http://foo.bar/blah/ (trailing slash) may respond as if the operation
- * were invoked on it, and should return a content-location header with
- * http://foo.bar/blah/ in it. In general clients SHOULD use the "/"
- * form of collection names."
- */
- if ( is_object($this->obj) &&
- $this->obj->isFolder &&
- $_GET['subaction'] == 'get' &&
- substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1 ) != '/' )
- {
- Logger::debug( 'WebDAV: Redirecting lame client to slashyfied URL' );
-
- header('HTTP/1.1 302 Moved Temporarily');
- header('Location: '.$_SERVER['REQUEST_URI'].'/');
- exit;
- }
-
- // Falls vorhanden, den "Destination"-Header parsen.
- if ( isset($_SERVER['HTTP_DESTINATION']) )
- {
- $destUri = parse_url( $_SERVER['HTTP_DESTINATION'] );
-
- $uri = substr($destUri['path'],strlen($_SERVER['SCRIPT_NAME'])+$sos);
-
- // URL parsen.
- $this->destination = $this->parseURI( $uri );
- }
-
- // Den Request-BODY aus der Standardeingabe lesen.
- $this->request = implode('',file('php://input'));
- }
-
-
-
- /**
- * Falls ein WebDAV-Client keine Cookies setzen kann (was HTTP/1.1 eigentlich
- * der Fall sein sollte), kann die Session-Id in die URL eingetragen
- * werden. Dies muss in der Konfiguration aktiviert werden.
- */
- function redirectWithSessionId()
- {
- if ( $this->webdav_conf['session_in_uri'] )
- {
- header('Location: '.dirname($_SERVER['REQUEST_URI']).'/'. $this->webdav_conf['session_in_uri_prefix'].session_id().'/'.basename($_SERVER['REQUEST_URI']));
- //$this->httpStatus('303 See Other');
- $this->httpStatus('302 Moved');
- }
- }
-
-
-
- /**
- * Da im WebDAV-Request keine Datenbank-Id angegeben werden kann, benutzen
- * wir hier die Standard-Datenbank.
- */
- function setDefaultDb()
- {
- global $conf;
-
- if ( !isset($conf['database']['default']) )
- {
- Logger::error('No default database in configuration');
- $this->httpStatus('500 Internal Server Error - no default-database in configuration');
- }
-
- $dbid = $conf['database']['default'];
-
- $db = new DB( $conf['database'][$dbid] );
- $db->id = $dbid;
- Session::setDatabase( $db );
- }
-
-
-
- function allowed_methods()
- {
-
- if ($this->readonly)
- return array('OPTIONS','HEAD','GET','PROPFIND'); // Readonly-Modus
- else
- // PROPPATCH unterstuetzen wir garnicht, aber lt. Spec sollten wir das.
- return array('OPTIONS','HEAD','GET','PROPFIND','DELETE','PUT','COPY','MOVE','MKCOL','PROPPATCH');
- }
-
-
-
- /**
- * HTTP-Methode OPTIONS.<br>
- * <br>
- * Es werden die verfuegbaren Methoden ermittelt und ausgegeben.
- */
- function options()
- {
- header('DAV: 1'); // Wir haben DAV-Level 1.
- header('Allow: '.implode(', ',$this->allowed_methods()) );
-
- $this->httpStatus( '200 OK' );
- }
-
-
-
- /**
- * Setzt einen HTTP-Status.<br>
- * <br>
- * Es wird ein HTTP-Status gesetzt, zus�tzlich wird der Status in den Header "X-WebDAV-Status" geschrieben.<br>
- * Ist der Status nicht 200 oder 207 (hier folgt ein BODY), wird das Skript beendet.
- */
- function httpStatus( $status = true )
- {
- if ( $status === true )
- $status = '200 OK';
-
- Logger::debug('WEBDAV: HTTP-Status: '.$status);
-
- header('HTTP/1.1 '.$status);
- header('X-WebDAV-Status: '.$status,true);
-
- // RFC 2616 (HTTP/1.1), Section 10.4.6 "405 Method Not Allowed" says:
- // "[...] The response MUST include an
- // Allow header containing a list of valid methods for the requested
- // resource."
- //
- // RFC 2616 (HTTP/1.1), Section 14.7 "Allow" says:
- // "[...] An Allow header field MUST be
- // present in a 405 (Method Not Allowed) response."
- if ( substr($status,0,3) == '405' )
- header('Allow: '.implode(', ',$this->allowed_methods()) );
- }
-
-
-
- /**
- * WebDav-HEAD-Methode.
- */
- function head()
- {
- if ( $this->obj == null )
- {
- $this->httpStatus( '404 Not Found' );
- }
- elseif ( $this->obj->isFolder )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isPage )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isLink )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isFile )
- {
- $this->httpStatus( '200 OK' );
- }
- }
-
-
-
- /**
- * WebDav-GET-Methode.
- * Die gew�nschte Datei wird geladen und im HTTP-Body mitgeliefert.
- */
- function get()
- {
- if ( $this->obj->isFolder )
- $this->getDirectory();
- elseif( $this->obj->isPage )
- {
- $this->httpStatus( '200 OK' );
-
- header('Content-Type: text/html');
-
- $page = new Page( $this->obj->objectid );
- $page->load();
- echo '<html><head><title>OpenRat WEBDAV Access</title></head>';
- echo '<body>';
- echo '<h1>'.$page->full_filename().'</h1>';
- echo '<pre>';
- echo 'No Content available';
- echo '</pre>';
- echo '</body>';
- echo '</html>';
- }
- elseif( $this->obj->isLink )
- {
- $this->httpStatus( '200 OK' );
-
- header('Content-Type: text/plain');
-
- $link = new Link( $this->obj->objectid );
- $link->load();
- echo 'url: ' .$link->url ."\n";
- echo 'target-id: '.$link->linkedObjectId."\n";
- }
- elseif( $this->obj->isFile )
- {
- $this->httpStatus( '200 OK' );
-
- $file = new File( $this->obj->objectid );
- $file->load();
-
- header('Content-Type: '.$file->mimeType() );
- header('X-File-Id: '.$file->fileid );
-
- // Angabe Content-Disposition
- // - Bild soll "inline" gezeigt werden
- // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
- header('Content-Disposition: inline; filename='.$file->filenameWithExtension() );
- header('Content-Transfer-Encoding: binary' );
- header('Content-Description: '.$file->name );
-
- $file->write(); // Bild aus Datenbank laden und in temporäre Datei schreiben
-
- // Groesse des Bildes in Bytes
- // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
- header('Content-Length: '.filesize($file->tmpfile()) );
- readfile( $file->tmpfile() );
- }
- }
-
-
-
- /**
- * Erzeugt ein Unix-�hnliche Ausgabe des Verzeichnisses als HTML.
- */
- function getDirectory()
- {
- $this->httpStatus( '200 OK' );
-
- // Verzeichnis ausgeben
- header('Content-Type: text/html');
- $nl = "\n";
- $titel = 'Index of '.htmlspecialchars($this->fullSkriptName);
- $format = "%15s %-19s %-s\n";
-
- echo '<html><head><title>'.$titel.'</title></head>';
- echo '<body>';
- echo '<h1>'.$titel.'</h1>'.$nl;
- echo '<pre>';
-
- printf($format, "Size", "Last modified", "Filename");
-
- if ( $this->requestType == 'projectlist' )
- {
- foreach( Project::getAll() as $projectName )
- {
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $z;
- $objektinhalt['size' ] = 1;
- echo '<a href="'.$this->fullSkriptName.'/'.$projectName.'"> </a>';
- }
- }
- elseif( $this->requestType == 'object' ) // Verzeichnisinhalt
- {
- $objects = $this->folder->getObjects();
-
- foreach( $objects as $object )
- {
- printf($format,
- number_format(1),
- strftime("%Y-%m-%d %H:%M:%S",$object->lastchangeDate ),
- '<a href="'.$object->filename.'">'.$object->filename.'</a>');
- echo $nl;
- }
- }
-
- echo '</pre>';
- echo '</body>';
- echo '</html>';
- }
-
-
-
- /**
- * Die Methode LOCK sollte garnicht aufgerufen werden, da wir nur
- * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
- * <br>
- * Ausgabe von HTTP-Status 412 (Precondition failed)
- */
- function lock()
- {
- $this->httpStatus('412 Precondition failed');
- $this->options();
- }
-
-
-
- /**
- * Die Methode UNLOCK sollte garnicht aufgerufen werden, da wir nur
- * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
- * <br>
- * Ausgabe von HTTP-Status 412 (Precondition failed)
- */
- function unlock()
- {
- $this->httpStatus('412 Precondition failed');
- $this->options();
- }
-
-
-
- /**
- * Die Methode POST ist bei WebDav nicht sinnvoll.<br>
- * <br>
- * Ausgabe von HTTP-Status 405 (Method Not Allowed)
- */
- function post()
- {
- // Die Methode POST ist bei Webdav nicht sinnvoll.
- $this->httpStatus('405 Method Not Allowed' );
- }
-
-
-
- /**
- * Verzeichnis anlegen.
- */
- function mkcol()
- {
-
- if ( !empty($this->request) )
- {
- $this->httpStatus('415 Unsupported Media Type' ); // Kein Body erlaubt
- }
- elseif ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
- }
- elseif ( !$this->folder->hasRight( ACL_CREATE_FOLDER ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
- }
- elseif ( $this->obj == null )
- {
- // Die URI ist noch nicht vorhanden
- $f = new Folder();
- $f->filename = basename($this->fullSkriptName);
- $f->parentid = $this->folder->objectid;
- $f->projectid = $this->project->projectid;
- $f->add();
- $this->httpStatus('201 Created');
- }
- else
- {
- // MKCOL ist nicht moeglich, wenn die URI schon existiert.
- Logger::warn('MKCOL-Request to an existing resource');
- $this->httpStatus('405 Method Not Allowed' );
- }
- }
-
-
-
- /**
- * Objekt l�schen.
- */
- function delete()
- {
- if ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
- }
- else
- {
- if ( $this->obj == null )
- {
- // Nicht existente URIs kann man auch nicht loeschen.
- $this->httpStatus('404 Not Found' );
- }
- elseif ( ! $this->obj->hasRight( ACL_DELETE ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf die Resource nicht loeschen
- }
- elseif ( $this->obj->isFolder )
- {
- $f = new Folder( $this->obj->objectid );
- $f->deleteAll();
- $this->httpStatus( true ); // OK
- Logger::debug('Deleted folder with id '.$this->obj->objectid );
- }
- elseif ( $this->obj->isFile )
- {
- $f = new File( $this->obj->objectid );
- $f->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isPage )
- {
- $p = new Page( $this->obj->objectid );
- $p->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isLink )
- {
- $l = new Link( $this->obj->objectid );
- $l->delete();
- $this->httpStatus( true ); // OK
- }
-
- }
- }
-
-
-
- /**
- * Kopieren eines Objektes.<br>
- * Momentan ist nur das Kopieren einer Datei implementiert.<br>
- * Das Kopieren von Ordnern, Verkn�pfungen und Seiten ist nicht moeglich.
- */
- function copy()
- {
- if ( $this->readonly || !$this->create )
- {
- Logger::error('WEBDAV: COPY request, but readonly or no creating');
- $this->httpStatus('405 Not Allowed' );
- }
- elseif( $this->obj == null )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- Logger::error('WEBDAV: COPY request, but Source not found');
- $this->httpStatus('405 Not Allowed' );
- }
- elseif ( $this->destination == null )
- {
- Logger::error('WEBDAV: COPY request, but no "Destination:"-Header');
- // $this->httpStatus('405 Not Allowed' );
- $this->httpStatus('412 Precondition failed');
- }
- else
- {
- // URL parsen.
- $dest = $this->destination;
- $destinationProject = $dest['project'];
- $destinationFolder = $dest['folder' ];
- $destinationObject = $dest['object' ];
-
- if ( $dest['type'] != 'object' )
- {
- Logger::debug('WEBDAV: COPY request, but "Destination:"-Header mismatch');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( $this->project->projectid != $destinationProject->projectid )
- {
- // Kopieren in anderes Projekt nicht moeglich.
- Logger::debug('WEBDAV: COPY request denied, project does not match');
- $this->httpStatus('403 Forbidden');
- }
- elseif ( $destinationObject != null )
- {
- Logger::debug('WEBDAV: COPY request denied, Destination exists. Overwriting is not supported');
- $this->httpStatus('403 Forbidden');
- }
- elseif ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
- }
- elseif ( is_object($destinationObject) && $destinationObject->isFolder)
- {
- Logger::debug('WEBDAV: COPY request denied, Folder-Copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( is_object($destinationObject) && $destinationObject->isLink)
- {
- Logger::debug('WEBDAV: COPY request denied, Link copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( is_object($destinationObject) && $destinationObject->isPage)
- {
- Logger::debug('WEBDAV: COPY request denied, Page copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- else
- {
- $f = new File();
- $f->filename = basename($_SERVER['HTTP_DESTINATION']);
- $f->name = '';
- $f->parentid = $destinationFolder->objectid;
- $f->projectid = $this->project->projectid;
- $f->add();
- $f->copyValueFromFile( $this->obj->objectid );
-
- Logger::debug('WEBDAV: COPY request accepted' );
- // Objekt wird in anderen Ordner kopiert.
- $this->httpStatus('201 Created' );
- }
- }
-
- }
-
-
-
- /**
- * Verschieben eines Objektes.<br>
- * <br>
- * Folgende Operationen sind m�glich:<br>
- * - Unbenennen eines Objektes (alle Typen)<br>
- * - Verschieben eines Objektes (alle Typen) in einen anderen Ordner.<br>
- */
- function move()
- {
- if ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden - Readonly Mode' ); // Schreibgeschuetzt
- }
- elseif ( !$this->create )
- {
- $this->httpStatus('403 Forbidden - No creation' ); // Schreibgeschuetzt
- }
- elseif( $this->obj == null )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- $this->httpStatus('404 Not Found' );
- }
- elseif( is_object($this->obj) && ! $this->obj->hasRight( ACL_WRITE ) )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
- $this->httpStatus('403 Forbidden' );
- }
- elseif ( $this->destination == null )
- {
- Logger::error('WEBDAV: MOVE request, but no "Destination:"-Header');
- // $this->httpStatus('405 Not Allowed' );
- $this->httpStatus('412 Precondition failed');
- }
- else
- {
- $dest = $this->destination;
- $destinationProject = $dest['project'];
- $destinationFolder = $dest['folder' ];
- $destinationObject = $dest['object' ];
-
- if ( $dest['type'] != 'object' )
- {
- Logger::debug('WEBDAV: MOVE request, but "Destination:"-Header mismatch');
- $this->httpStatus('405 Not Allowed');
- return;
- }
-
- if ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
- {
- Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
- $this->httpStatus('403 Forbidden' );
- }
-
- if ( $destinationObject != null )
- {
- Logger::debug('WEBDAV: MOVE request denied, destination exists');
- $this->httpStatus('412 Precondition Failed');
- return;
- }
-
- if ( $this->project->projectid != $destinationProject->projectid )
- {
- // Verschieben in anderes Projekt nicht moeglich.
- Logger::debug('WEBDAV: MOVE request denied, project does not match');
- $this->httpStatus('405 Not Allowed');
- return;
- }
-
- if ( $this->folder->objectid == $destinationFolder->objectid )
- {
- Logger::debug('WEBDAV: MOVE request accepted, object renamed');
- // Resource bleibt in gleichem Ordner.
- $this->obj->filename = basename($_SERVER['HTTP_DESTINATION']);
- $this->obj->objectSave(false);
- $this->httpStatus('201 Created' );
- return;
- }
-
- if ( $destinationFolder->isFolder )
- {
- Logger::debug('WEBDAV: MOVE request accepted, Destination: '.$destinationFolder->filename );
- // Objekt wird in anderen Ordner verschoben.
- $this->obj->setParentId( $destinationFolder->objectid );
- $this->httpStatus('201 Created' );
- return;
- }
-
- Logger::warn('WEBDAV: MOVE request failed' );
- $this->httpStatus('500 Internal Server Error' );
- }
- }
-
-
-
- /**
- * Anlegen oder �berschreiben Dateien �ber PUT.<br>
- * Dateien k�nnen neu angelegt und �berschrieben werden.<br>
- * <br>
- * Seiten k�nnen nicht �berschrieben werden. Wird versucht,
- * eine Seite mit PUT zu �berschreiben, wird der Status "405 Not Allowed" gemeldet.<br>
- */
- function put()
- {
- // TODO: 409 (Conflict) wenn �bergeordneter Ordner nicht da.
-
- if ( $this->webdav_conf['readonly'] )
- {
- $this->httpStatus('405 Not Allowed' );
- }
- elseif ( strlen($this->request) > $this->maxFileSize*1000 )
- {
- // Maximale Dateigroesse ueberschritten.
- // Der Status 207 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :)
- $this->httpStatus('507 Insufficient Storage' );
- }
- elseif ( $this->obj == null )
- {
- // Neue Datei anlegen
- if ( !$this->webdav_conf['create'] )
- {
- Logger::warn('WEBDAV: Creation of files not allowed by configuration' );
- $this->httpStatus('405 Not Allowed' );
- }
-
- if ( ! $this->folder->hasRight( ACL_CREATE_FILE ) )
- {
- $this->httpStatus('403 Forbidden');
- return;
- }
-
- $file = new File();
- $file->filename = basename($this->fullSkriptName);
- $file->extension = '';
- $file->size = strlen($this->request);
- $file->parentid = $this->folder->objectid;
- $file->projectid = $this->project->projectid;
- $file->value = $this->request;
- $file->add();
- $this->httpStatus('201 Created');
- return;
- }
- elseif ( $this->obj->isFile )
- {
- if ( ! $this->obj->hasRight( ACL_WRITE ) )
- {
- Logger::debug('PUT failed, parent folder not writable by user' );
- $this->httpStatus('403 Forbidden');
- return;
- }
-
- // Bestehende Datei ueberschreiben.
- $file = new File( $this->obj->objectid );
- $file->saveValue( $this->request );
- $file->setTimestamp();
- $this->httpStatus('204 No Content');
- Logger::debug('PUT ok, file is created' );
- return;
- }
- elseif ( $this->obj->isFolder )
- {
- Logger::error('PUT on folder is not supported, use PROPFIND. Lame client?' );
- $this->httpStatus('405 Not Allowed' );
- }
- else
- {
- // Fuer andere Objekttypen (Links, Seiten) ist kein PUT moeglich.
- Logger::warn('PUT only available for files, pages and links are ignored' );
- $this->httpStatus('405 Not Allowed' );
- }
- }
-
-
-
- /**
- * WebDav-Methode PROPFIND.
- *
- * Diese Methode wird
- * - beim Ermitteln von Verzeichnisinhalten und
- * - beim Ermitteln von Metainformationen zu einer Datei
- * verwendet.
- *
- * Das Ergebnis wird in einer XML-Zeichenkette geliefert.
- */
- function propfind()
- {
- switch( $this->requestType )
- {
- case 'projectlist': // Projektliste
-
- $inhalte = array();
-
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $z;
- $objektinhalt['size' ] = 1;
- $objektinhalt['name' ] = $this->fullSkriptName;
- $objektinhalt['displayname' ] = '';
- $objektinhalt['type'] = 'folder';
-
- $inhalte[] = $objektinhalt;
-
- foreach( Project::getAll() as $projectid=>$projectName )
- {
- $project = new Project( $projectid );
- $rootObjectId = $project->getRootObjectId();
- $folder = new Folder( $rootObjectId );
- $folder->load();
-
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $folder->lastchangeDate;
- $objektinhalt['size' ] = $project->size();
- $objektinhalt['name' ] = $this->fullSkriptName.$projectName.'/';
- $objektinhalt['displayname' ] = $projectName;
- $objektinhalt['type'] = 'folder';
- $inhalte[] = $objektinhalt;
- }
-
- $this->multiStatus( $inhalte );
- break;
-
- case 'object': // Verzeichnisinhalt
-
- if ( $this->obj == null )
- {
- // Objekt existiert nicht.
- Logger::trace( 'WEBDAV: PROPFIND of non-existent object');
- $this->httpStatus('404 Not Found');
- return;
- }
- elseif ( $this->obj->isFolder )
- {
- if ( ! $this->obj->hasRight( ACL_READ ))
- {
- Logger::debug( 'Folder '.$this->obj->objectid.': access denied');
- $this->httpStatus('403 Forbidden');
- }
-
- $inhalte = array();
-
- $objektinhalt = array();
- $objektinhalt['createdate' ] = $this->obj->createDate;
- $objektinhalt['lastchangedate'] = $this->obj->lastchangeDate;
- $objektinhalt['name' ] = $this->fullSkriptName;
- $objektinhalt['displayname' ] = basename($this->fullSkriptName);
- $objektinhalt['type' ] = 'folder';
- $objektinhalt['size' ] = 0;
- $inhalte[] = $objektinhalt;
-
- if ( $this->depth > 0 )
- {
- $objects = $this->folder->getObjects();
- foreach( $objects as $object )
- {
- if ( ! $object->hasRight( ACL_READ ))
- continue;
-
- //$object->loadRaw();
- $objektinhalt = array();
- $objektinhalt['createdate' ] = $object->createDate;
- $objektinhalt['lastchangedate'] = $object->lastchangeDate;
- $objektinhalt['displayname' ] = $object->filename;
-
- switch( $object->getType() )
- {
-
- case OR_TYPE_FOLDER:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename.'/';
- $objektinhalt['type'] = 'folder';
- $objektinhalt['size'] = 0;
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_FILE:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $file = new File($object->objectid);
- $file->load();
- $objektinhalt['size'] = $file->size;
- $objektinhalt['mime'] = 'application/x-non-readable';
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_LINK:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $objektinhalt['size'] = 0;
- $objektinhalt['mime'] = 'application/x-non-readable';
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_PAGE:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $objektinhalt['size'] = 0;
- $inhalte[] = $objektinhalt;
- break;
- default:
- }
- }
- }
- Logger::trace( 'WEBDAV: PROPFIND-2');
-
-// if ( count($inhalte)==0 )
-// $inhalte[] = array('createdate'=>0,'lastchangedate'=>0,'name'=>'empty','size'=>0,'type'=>'file');
-
- Logger::trace('Anzahl Dateien:'.count($inhalte));
- $this->multiStatus( $inhalte );
- }
- else
- {
- $object = $this->obj;
- Logger::trace( 'WEBDAV: PROPFIND of file');
- $objektinhalt = array();
- $objektinhalt = array();
- $objektinhalt['name'] = $this->fullSkriptName.'/'.$object->filename.'/';
- $objektinhalt['displayname'] = $object->filename;
- $objektinhalt['createdate' ] = $object->createDate;
- $objektinhalt['lastchangedate'] = $object->lastchangeDate;
- $file = new File( $this->obj->objectid );
- $file->load();
- $objektinhalt['size' ] = $file->size;
- $objektinhalt['type' ] = 'file';
-
-
- $this->multiStatus( array($objektinhalt) );
- }
- break;
-
- default:
- Logger::warn('Internal Error, unknown request type: '. $this->requestType);
- $this->httpStatus('500 Internal Server Error');
- }
- }
-
-
- /**
- * Webdav-Methode PROPPATCH ist nicht implementiert.
- */
- function proppatch()
- {
- // TODO: Multistatus erzeugen.
- // Evtl. ist '409 Conflict' besser?
- $this->httpStatus('405 Not Allowed');
- }
-
-
- /**
- * Erzeugt einen Multi-Status.
- * @access private
- */
- function multiStatus( $files )
- {
- $this->httpStatus('207 Multi-Status');
- header('Content-Type: text/xml; charset=utf-8');
-
- $response = '';
- $response .= '<?xml version="1.0" encoding="utf-8" ?>';
- $response .= '<d:multistatus xmlns:d="DAV:">';
-
- foreach( $files as $file )
- $response .= $this->getResponse( $file['name'],$file );
-
- $response .= '</d:multistatus>';
- Logger::trace('PROPFIND: '.$response);
-
- $response = utf8_encode($response);
-
- header('Content-Length: '.strlen($response));
- echo $response;
- }
-
-
- /**
- * Erzeugt ein "response"-Element, welches in ein "multistatus"-element verwendet werden kann.
- */
- function getResponse( $file,$options )
- {
- // TODO: Nur angeforderte Elemente erzeugen.
- $response = '';
- $response .= '<d:response>';
- $response .= '<d:href>'.$file.'</d:href>';
- $response .= '<d:propstat>';
- $response .= '<d:prop>';
- // $response .= '<d:source></d:source>';
- $response .= '<d:creationdate>'.date('r',$options['createdate']).'</d:creationdate>';
- $response .= '<d:displayname>'.$options['displayname'].'</d:displayname>';
- $response .= '<d:getcontentlength>'.$options['size'].'</d:getcontentlength>';
- $response .= '<d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">'.date('r',$options['lastchangedate']).'</d:getlastmodified>';
-
- if ( $options['type'] == 'folder')
- $response .= '<d:resourcetype><d:collection/></d:resourcetype>';
- else
- $response .= '<d:resourcetype />';
-
- $response .= '<d:categories />';
- $response .= '<d:fields></d:fields>';
-
-
-
-// $response .= '<d:getcontenttype>text/html</d:getcontenttype>';
-// $response .= '<d:getcontentlength />';
-// $response .= '<d:getcontentlanguage />';
-// $response .= '<d:executable />';
-// $response .= '<d:resourcetype>';
-// $response .= '<d:collection />';
-// $response .= '</d:resourcetype>';
-// $response .= '<d:getetag />';
-
- $response .= '</d:prop>';
- $response .= '<d:status>HTTP/1.1 200 OK</d:status>';
- $response .= '</d:propstat>';
- $response .= '</d:response>';
-
- return $response;
- }
-
-
-
- /**
- * URI parsen.
- */
- function parseURI( $uri )
- {
- // Ergebnis initialisieren (damit alle Schl�ssel vorhanden sind)
- $ergebnis = array('type' => null,
- 'project' => null,
- 'path' => array(),
- 'folder' => null,
- 'object' => null );
-
- Logger::trace( 'WEBDAV: Parsen der URI '.$uri);
- $uriParts = explode('/',$uri);
-
- $nr = 0;
- $f = null;
- $o = null;
- $ergebnis['type'] = 'projectlist';
-
- foreach( $uriParts as $uriPart )
- {
- if ( empty( $uriPart))
- continue;
-
- $ergebnis['path'][] = $uriPart;
-
- if ( $f == null )
- {
- // URI='/project/'
- // Name des Projektes in der URL, es wird das Projekt geladen.
- $ergebnis['type'] = 'object';
-
- $p = new Project();
- $p->name = $uriPart;
- Logger::trace("Projektname: ".$p->name);
- $p->loadByName();
- $ergebnis['project'] = $p;
- // Das Projekt hat weder Sprache noch Variante gesetzt.
- //Session::setProjectLanguage( new Language( $this->project->getDefaultLanguageId() ) );
- //Session::setProjectModel ( new Model ( $this->project->getDefaultModelId() ) );
-
- $oid = $p->getRootObjectId();
-
- $f = new Folder($oid);
- $ergebnis['object'] = $f;
- $ergebnis['folder'] = $f;
-
- }
- else
- {
- if ( $ergebnis['object'] == null )
- {
- $this->httpStatus('409 Conflict');
- exit;
- }
-
- $oid = $f->getObjectIdByFileName($uriPart);
-
- if ( $oid == 0 )
- {
- Logger::trace( 'WEBDAV: URL-Part does not exist: '.$uriPart);
- $ergebnis['object'] = null;
- }
- else
- {
- Logger::trace( 'Teil '.$uriPart);
- $o = new Object($oid);
- $o->load();
- $ergebnis['object'] = $o;
-
- if ( $o->isFolder )
- {
- $f = new Folder($oid);
- $ergebnis['folder'] = $f;
- }
- }
- }
- }
-
- return $ergebnis;
- }
-}
-
-
-
-/**
- * Fehler-Handler fuer WEBDAV.<br>
- * Bei einem Laufzeitfehler ist eine Ausgabe des Fehlers auf der Standardausgabe sinnlos,
- * da der WebDAV-Client dies nicht lesen oder erkennen kann.
- * Daher wird der Fehler-Handler umgebogen, so dass nur ein Logeintrag sowie ein
- * Server-Fehler erzeugt wird.
- */
-function webdavErrorHandler($errno, $errstr, $errfile, $errline)
-{
- Logger::warn('WEBDAV ERROR: '.$errno.'/'.$errstr.'/file:'.$errfile.'/line:'.$errline);
-
- // Wir teilen dem Client mit, dass auf dem Server was schief gelaufen ist.
- WebdavAction::httpStatus('500 Internal Server Error, WebDAV-Request failed with "'.$errstr.'"');
-}
-
-?>-
\ No newline at end of file
diff --git a/actionClasses/WebdavAction.ini.php b/actionClasses/WebdavAction.ini.php
@@ -1,53 +0,0 @@
-
-[default]
-goto=none
-guest=true
-
-[get]
-direct=true
-guest=true
-
-[head]
-direct=true
-guest=true
-
-[put]
-direct=true
-guest=true
-
-[mkcol]
-direct=true
-guest=true
-
-[delete]
-direct=true
-guest=true
-
-[copy]
-direct=true
-guest=true
-
-[move]
-direct=true
-guest=true
-
-[options]
-direct=true
-guest=true
-
-[propfind]
-direct=true
-guest=true
-
-[proppatch]
-direct=true
-guest=true
-
-[lock]
-direct=true
-guest=true
-
-[unlock]
-direct=true
-guest=true
-