commit 1affd5d4450e5a2da44d1cc7b21618e37f708355
parent d5f0f6bc9ffd99f7c22c040120f8e0ce6016e80f
Author: dankert <devnull@localhost>
Date: Sat, 24 Apr 2004 17:15:12 +0200
Initiale Version
Diffstat:
44 files changed, 12359 insertions(+), 0 deletions(-)
diff --git a/actionClasses/.htaccess b/actionClasses/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/actionClasses/Action.class.php b/actionClasses/Action.class.php
@@ -0,0 +1,223 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class Action
+{
+ var $db;
+ var $templateVars = Array();
+ var $actionName;
+ var $subActionName;
+
+
+ function Action()
+ {
+ global $SESS;
+// if ( $SESS['action'] != 'login')
+// $db = db_connection();
+ }
+
+
+ function getSessionVar( $varName )
+ {
+ global $SESS;
+
+ if ( !isset($SESS[ $varName ]) )
+ return '';
+ else return $SESS[ $varName ];
+ }
+
+
+ function setSessionVar( $varName,$value )
+ {
+ global $SESS;
+
+ $SESS[ $varName ] = $value;
+ }
+
+
+ function getRequestVar( $varName )
+ {
+ global $REQ;
+
+ if ( !isset($REQ[ $varName ]) )
+ return '';
+ else return $REQ[ $varName ];
+ }
+
+
+ function setTemplateVar( $varName,$value )
+ {
+ $this->templateVars[ $varName ] = $value;
+ }
+
+
+ function setTemplateVars( $varList )
+ {
+ foreach( $varList as $name=>$value )
+ {
+ $this->setTemplateVar( $name,$value );
+ }
+ }
+
+
+ function message( $title='ERROR',$add_info='' )
+ {
+ $this->setTemplateVar( 'title',lang( $title ) );
+ $this->setTemplateVar( 'text' ,lang( $title.'_DESC' ) );
+ $this->setTemplateVar( 'info' ,$add_info );
+
+ $this->forward('message');
+ }
+
+
+ /** Ausgabe des Templates
+ *
+ * Es wird das gewünschte Template auf die Standardausgabe
+ * ausgegeben.
+ *
+ * @param String Dateiname des Templates
+ */
+ function forward( $tplName )
+ {
+ global $title,
+ $cms_name,
+ $cms_version,
+ $PHP_SELF,
+ $SESS,
+ $HTTP_SERVER_VARS,
+ $cms_title,
+ $conf_php,
+ $conf_themedir;
+
+// $tpl .= $this->actionName-'_'.$this->subActionName.'.tpl.'.$conf_php;
+ $tplFileName = $tplName.'.tpl.'.$conf_php;
+
+ // Übertragen der Array-Variablen in den aktuellen Kontext
+ //
+ extract( $this->templateVars );
+
+ // Setzen einiger Standard-Variablen
+ //
+ $tpl_dir = $conf_themedir.'/templates/';
+ $image_dir = $conf_themedir.'/images/';
+
+ if ( !isset($SESS['user']) || $SESS['user']['style']=='')
+ $stylesheet = $conf_themedir.'/css/default.css';
+ else $stylesheet = $conf_themedir.'/css/'.$SESS['user']['style'].'.css';
+
+ $self = $HTTP_SERVER_VARS['PHP_SELF'];
+
+ // Einbinden des Templates
+ //
+ require( 'themes/default/templates/'.$tplFileName );
+
+ exit;
+ }
+
+
+ function callSubAction( $subActionName )
+ {
+ global $SESS;
+
+ $SESS[ $this->actionName.'action' ] = $subActionName;
+
+ $this->$subActionName();
+ }
+
+
+ /**
+ * Verschieben eines Objektes
+ * @access protected
+ */
+ function objectMove()
+ {
+ if ( $this->getRequestVar('movetoobjectid') != '' )
+ {
+ $o = new Object( $this->getSessionVar('objectid') );
+
+ if ( $o->hasRight('prop') )
+ $o->setParentId( $this->getRequestVar('movetoobjectid') );
+ }
+ }
+
+
+ /**
+ * ACL zu einem Objekt setzen
+ * @access protected
+ */
+ function objectAddACL()
+ {
+ $acl = new Acl();
+
+ $acl->objectid = $this->getSessionVar('objectid');
+
+ if ( $this->getRequestVar('type') == 'user' )
+ $acl->userid = $this->getRequestVar('userid' );
+ else $acl->groupid = $this->getRequestVar('groupid');
+
+ $acl->languageid = $this->getRequestVar('languageid');
+
+ $acl->write = ( $this->getRequestVar('write' ) != '' );
+ $acl->prop = ( $this->getRequestVar('prop' ) != '' );
+ $acl->delete = ( $this->getRequestVar('delete' ) != '' );
+ $acl->publish = ( $this->getRequestVar('publish' ) != '' );
+ $acl->create_folder = ( $this->getRequestVar('create_folder') != '' );
+ $acl->create_file = ( $this->getRequestVar('create_file' ) != '' );
+ $acl->create_link = ( $this->getRequestVar('create_link' ) != '' );
+ $acl->create_page = ( $this->getRequestVar('create_page' ) != '' );
+ $acl->grant = ( $this->getRequestVar('grant' ) != '' );
+ $acl->transmit = ( $this->getRequestVar('transmit' ) != '' );
+
+ $acl->add();
+ }
+
+
+ /**
+ * Ermitteln, ob Benutzer Administratorrechte besitzt
+ * @return Boolean
+ */
+ function userIsAdmin()
+ {
+ $user = $this->getSessionVar('user');
+ if ( $user['is_admin'] )
+ return true;
+ else return false;
+ }
+
+
+
+ /**
+ * Entfernen einer ACL
+ * @access protected
+ */
+ function objectDelACL()
+ {
+ $acl = new Acl( $this->getRequestVar('aclid') );
+ $acl->delete();
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/ElementAction.class.php b/actionClasses/ElementAction.class.php
@@ -0,0 +1,295 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class ElementAction extends Action
+{
+ var $element;
+
+
+ /**
+ * Konstruktor
+ */
+ function ElementAction()
+ {
+ $this->element = new Element( $this->getSessionVar('elementid') );
+ $this->element->load();
+
+ $this->setSessionVar('templateid',$this->element->templateid);
+ }
+
+
+ /**
+ * Ändern des Element-Typs
+ */
+ function changetype()
+ {
+ $this->element->setType( $this->getRequestVar('type') );
+ $this->element->load();
+
+ $this->callSubAction('edit');
+ }
+
+
+ /**
+ * Anzeigen des Elementes
+ */
+ function edit()
+ {
+ // Name und Beschreibung
+ $this->setTemplateVar('name',$this->element->name);
+ $this->setTemplateVar('desc',$this->element->desc);
+
+ // Die verschiedenen Element-Typen
+ $types = array();
+
+ foreach( $this->element->getAvailableTypes() as $t )
+ {
+ $types[ $t ] = lang('EL_'.$t);
+ }
+ $this->setTemplateVar('type',$types);
+
+ $this->setTemplateVar('default_type',$this->element->type);
+
+ // Abhängig vom aktuellen Element-Typ die Eigenschaften anzeigen
+
+ $properties = $this->element->getRelatedProperties();
+
+ // Eigenschaften Info-Datum
+ 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':
+
+ switch( $this->element->type )
+ {
+ case 'info':
+ $subtype = 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',
+ 'lastchange_user_username',
+ 'lastchange_user_fullname',
+ 'lastchange_user_mail',
+ 'lastchange_user_desc',
+ 'lastchange_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' );
+ break;
+
+ case 'infodate':
+ $subtype = Array('date_published',
+ 'date_saved',
+ 'date_created' );
+ break;
+
+ default:
+ $subtype = array();
+ break;
+ }
+
+ foreach( $subtype as $t )
+ {
+ $subtypes[$t] = lang('EL_'.$this->element->type.'_'.$t);
+ }
+
+ $this->setTemplateVar('subtype' ,$subtypes );
+ $this->setTemplateVar('act_subtype',$this->element->subtype);
+
+ break;
+
+
+ case 'dateformat':
+
+ $ini_date_format = parse_ini_file( CONF_LANGUAGEDIR.'/dateformat.ini.'.CONF_PHP );
+ $dateformat = array();
+
+ $this->setTemplateVar('act_dateformat','');
+
+ foreach($ini_date_format as $idx=>$d)
+ {
+ $dateformat[$idx] = date($d);
+ if ( $d == $this->element->dateformat )
+ $this->setTemplateVar('act_dateformat',$idx);
+ }
+
+ $this->setTemplateVar('dateformat' ,$dateformat );
+
+ break;
+
+
+ // Eigenschaften Text und Text-Absatz
+ case 'defaultText':
+
+ if ( $this->element->type == 'longtext')
+ $this->setTemplateVar('default_longtext',$this->element->defaultText );
+ else $this->setTemplateVar('default_text' ,$this->element->defaultText );
+ break;
+
+
+ case 'wiki':
+ $this->setTemplateVar('wiki' ,$this->element->wiki );
+ break;
+
+
+ case 'html':
+ $this->setTemplateVar('html' ,$this->element->html );
+ break;
+
+
+ // Eigenschaften PHP-Code
+ case 'code':
+ $this->setTemplateVar('code',$this->element->code);
+ break;
+
+
+ // Eigenschaften Text und Text-Absatz
+ case 'defaultText':
+ {
+ $this->setTemplateVar('default_longtext',$this->element->defaultText);
+ 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 verfügbaren Objekt-IDs
+ foreach( Folder::getAllObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ if ( $o->getType() != 'folder' )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+
+ $objects[ $id ] = lang( $o->getType() ).': ';
+ $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= ' » '.$o->name;
+ }
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects',$objects);
+
+ $this->setTemplateVar('act_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();
+ $folders[ $id ] = implode( ' » ',$f->parentObjectNames(true,true) );
+ $folders[ $id ] .= ' » ';
+ }
+ $folders[ $id ] .= $o->name;
+ }
+
+ asort( $folders ); // Sortieren
+
+ $this->setTemplateVar('folders',$folders);
+
+ $this->setTemplateVar('act_folderobjectid' ,$this->element->folderObjectId );
+
+ break;
+
+ default:
+ $this->message('ERROR','not an element property: '.$propertyName );
+ }
+ }
+
+ $this->forward('element');
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/FileAction.class.php b/actionClasses/FileAction.class.php
@@ -0,0 +1,273 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class FileAction extends Action
+{
+ var $file;
+ var $defaultSubAction = 'show';
+
+ /**
+ * Konstruktor
+ */
+ function FileAction()
+ {
+ $this->file = new File( $this->getSessionVar('objectid') );
+ $this->file->load();
+ }
+
+
+ function move()
+ {
+ $this->objectMove();
+
+ $this->callSubAction('show');
+ }
+
+
+ function addAccessACL()
+ {
+ $this->objectAddAccessACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ function delACL()
+ {
+ $this->objectDelACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ 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();
+
+ //$setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('show');
+ }
+
+
+ function savevalue()
+ {
+ $this->file->value = $this->getRequestVar('value');
+ $this->file->saveValue();
+
+ $this->callSubAction('show');
+ }
+
+
+ function save()
+ {
+ global $SESS;
+
+ // Wenn Dateiname gefüllt, dann Datenbank-Update
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ // Datei löschen
+ $this->file->delete();
+
+ unset( $SESS['objectid'] );
+ }
+ else
+ {
+ // Eigenschaften speichern
+ $this->file->filename = $this->getRequestVar('filename' );
+ $this->file->name = $this->getRequestVar('name' );
+ $this->file->extension = $this->getRequestVar('extension');
+ $this->file->desc = $this->getRequestVar('desc' );
+
+ $this->file->save();
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+ $this->callSubAction('show');
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
+ * auf die Standardausgabe geschrieben
+ */
+ function show()
+ {
+ // Angabe Content-Type
+ header('Content-Type: '.$this->file->mimeType() );
+
+ // Angabe Content-Disposition mit Dateinamen
+ header('Content-Disposition: filename='.$this->file->filenameWithExtension().';' );
+
+ echo $this->file->loadValue();
+ exit;
+ }
+
+
+ function resize()
+ {
+ $width = $this->getRequestVar('width' );
+ $height = $this->getRequestVar('height');
+
+ if ( $width != '' || $height != '' )
+
+ $this->file->imageResize( intval($width),intval($height) );
+ $this->file->save();
+ $this->file->saveValue();
+
+ $this->callSubAction('show');
+ }
+
+
+ function prop()
+ {
+ // MIME-Types aus Datei lesen
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $this->setTemplateVar('full_filename',$this->file->full_filename());
+
+ if ( substr($this->file->mimetype(),0,5) == 'text/' )
+ $var['src_url'] = Html::url(array('fileaction'=>'src'));
+
+ if ( is_numeric($this->file->lastchange_userid) )
+ {
+ $user = new User( $this->file->lastchange_userid );
+ $user->load();
+ $this->setTemplateVar('lastchange_user',array('name'=>$user->name,
+ 'url' =>Html::url(array('action'=>'user',
+ 'userid'=>$user->userid))));
+ }
+ else
+ {
+ $this->setTemplateVar('lastchange_user',array('name'=>lang('UNKNOWN')));
+ }
+
+ if ( is_numeric($this->file->create_userid) )
+ {
+ $user = new User( $this->file->create_userid );
+ $user->load();
+ $this->setTemplateVar('create_user',array('name'=>$user->name,
+ 'url' =>Html::url(array('action'=>'user',
+ 'userid'=>$user->userid))));
+ }
+ else
+ {
+ $this->setTemplateVar('create_user',array('name'=>lang('UNKNOWN')));
+ }
+
+ // Alle Ordner ermitteln
+ $this->setTemplateVar('act_folderobjectid',$this->file->parentid);
+ $list = array();
+
+ $f = new Folder( $this->file->parentid );
+
+ foreach( $f->getOtherFolders() as $oid )
+ {
+ $folder = new Folder( $oid );
+ $folder->load();
+ $list[$oid] = implode(' » ',$folder->parentObjectNames(true,true) );
+ }
+ asort( $list );
+ $this->setTemplateVar('folderobject',$list);
+
+
+
+ // 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' ] = 'main.'.$conf_php.'?action=page&objectid='.$id;
+ $list[$id]['name'] = $o->name;
+ }
+ asort( $list );
+ $this->setTemplateVar('pages',$list);
+
+ $this->forward( 'file_prop' );
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function src()
+ {
+ $this->setTemplateVar('value',$this->file->loadValue());
+
+ $this->forward('file_src');
+ }
+
+
+ /**
+ * Datei veröffentlichen
+ */
+ function pub()
+ {
+ $this->file->publish();
+
+ $var['filenames'] = Array( $this->file->full_filename() );
+ $this->forward('all_publish');
+ }
+
+
+ function rights()
+ {
+ $acl = new Acl();
+ $acl->objectid = $this->file->objectid;
+
+ $var['access_acls'] = array();
+
+ foreach( $acl->getAccessACLsFromObject() as $id )
+ {
+ $acl = new Acl( $id );
+ $acl->load();
+ $var['access_acls'][$id] = $acl->getProperties();
+ $var['access_acls'][$id]['delete_url'] = 'folder.'.$conf_php.'?folderaction=delACL&aclid='.$id;
+ }
+
+ $var['users'] = User::listAll();
+ $var['groups'] = Group::getAll();
+ $var['languages'] = Language::getAll();
+
+ $this->forward('file_rights');
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/FolderAction.class.php b/actionClasses/FolderAction.class.php
@@ -0,0 +1,359 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class FolderAction extends Action
+{
+ var $defaultSubAction = 'show';
+ var $folder;
+
+
+ function FolderAction()
+ {
+ $this->folder = new Folder( $this->getSessionVar('objectid') );
+ $this->folder->load();
+
+ if ( ! $this->folder->isFolder )
+ $this->message('','object id '.$this->folder->objectid.' is not a folder' );
+ }
+
+
+ function createnew()
+ {
+ // Neues Objekt in diesem Ordner anlegen
+ switch( $this->getRequestVar('type') )
+ {
+ case 'folder':
+
+ if ( $this->getRequestVar('foldername') != '' )
+ {
+ $f = new Folder();
+ $f->name = $this->getRequestVar('foldername');
+ $f->filename = $this->getRequestVar('foldername');
+ $f->parentid = $this->folder->objectid;
+
+ $f->add();
+ }
+
+ break;
+
+ case 'page':
+
+ if ( $this->getRequestVar('pagename') != '' )
+ {
+ $page = new Page();
+ $page->name = $this->getRequestVar('pagename' );
+ $page->filename = $this->getRequestVar('pagename' );
+ $page->templateid = $this->getRequestVar('templateid');
+ $page->parentid = $this->folder->objectid;
+
+ $page->add();
+ }
+
+ break;
+
+ case 'file':
+
+ $file = new File();
+ $upload = new Upload();
+
+ $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
+ break;
+
+ case 'link':
+
+ if ( $this->getRequestVar('linkname') != '' )
+ {
+ $link = new Link();
+ $link->name = $this->getRequestVar('linkname');
+ $link->parentid = $this->folder->objectid;
+ $link->isLinkToObject = false;
+ $link->url = '/';
+ $link->add();
+ }
+ break;
+
+ default: die();
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+ $this->callSubAction('show');
+ }
+
+
+ function save()
+ {
+ // Wenn Dateiname gefüllt, dann Datenbank-Update
+ if ( $this->getRequestVar('filename') != '' )
+ {
+ if ( $this->getRequestVar('name') != '' )
+ $this->folder->name = $this->getRequestVar('name' );
+ else $this->folder->name = $this->getRequestVar('filename');
+
+ $this->folder->filename = $this->getRequestVar('filename');
+ $this->folder->desc = $this->getRequestVar('desc');
+ $this->folder->save();
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+ $this->callSubAction('show');
+ }
+
+
+ // 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 :-)
+ }
+
+ // Ordner anzeigen
+ $this->callSubAction('show');
+
+ }
+
+
+ function move()
+ {
+ $this->objectMove();
+
+ $this->callSubAction('show');
+ }
+
+
+ function addACL()
+ {
+ $this->objectAddACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ function delACL()
+ {
+ $this->objectDelACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ function create()
+ {
+
+ if ( $this->folder->hasRight('create_page') )
+ $this->setTemplateVar('templates',Template::getAll());
+
+ $this->setTemplateVar('create_folder',$this->folder->hasRight('create_folder'));
+ $this->setTemplateVar('create_file' ,$this->folder->hasRight('create_file') );
+ $this->setTemplateVar('create_link' ,$this->folder->hasRight('create_link') );
+ $this->setTemplateVar('create_page' ,$this->folder->hasRight('create_page') );
+
+ $this->forward('folder_new');
+
+ }
+
+
+
+ function show()
+ {
+ global $conf_php;
+
+ if ( ! $this->folder->isRoot )
+ $this->setTemplateVar('up_url',"main.$conf_php?action=folder&objectid=".$this->folder->parentid);
+
+ $list = array();
+ $last_objectid = 0;
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+
+ if ( $o->hasRight('read') )
+ {
+ $o->objectLoad();
+ $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
+ $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
+ $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
+
+ $list[$id]['type'] = $o->getType();
+
+ $list[$id]['icon'] = $o->getType();
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ 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(array('action' =>'main',
+ 'callAction'=>$o->getType(),
+ 'objectid' =>$id));
+ $list[$id]['propurl' ] = Html::url(array('action'=>$o->getType(),
+ 'subaction'=>'prop',
+ 'objectid'=>$id));
+ $list[$id]['date'] = date( lang('DATE_FORMAT'),$o->lastchange_date );
+ $list[$id]['user'] = User::getUserName( $o->lastchange_userid );
+
+ if ( $last_objectid != 0 )
+ {
+ $list[$id ]['upurl' ] = Html::url(array('action'=>'folder',
+ 'subaction'=>'changesequence',
+ 'objectid1'=>$id,
+ 'objectid2'=>$last_objectid));
+ $list[$last_objectid]['downurl'] = $list[$id]['upurl'];
+ }
+
+ $last_objectid = $id;
+ }
+ }
+ $this->setTemplateVar('object',$list);
+
+ $this->forward('folder_show');
+
+ }
+
+
+ function prop()
+ {
+ $this->setTemplateVars( $this->folder->getProperties() );
+
+ // Alle Ordner ermitteln
+ $this->setTemplateVar('act_objectid',$this->folder->objectid);
+
+ $list = array();
+ $allsubfolders = $this->folder->getAllSubFolderIds();
+
+ foreach( $this->folder->getOtherFolders() as $id )
+ {
+ $f = new Folder( $id );
+ if ( ! in_array($id,$allsubfolders) )
+ $list[$id] = implode( ' » ',$f->parentObjectNames(true,true) );
+ }
+ asort( $list );
+ $this->setTemplateVar('folder',$list);
+
+ $this->forward('folder_prop');
+ }
+
+
+ function rights()
+ {
+ global $SESS;
+ global $conf_php;
+ if ($SESS['user']['is_admin'] != '1') die('nice try');
+
+ $acllist = array();
+ foreach( $this->folder->getAllInheritedAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+ $key = 'au'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
+ $acllist[$key] = $acl->getProperties();
+ }
+
+// $this->setTemplateVar('inherited_acls',$acllist );
+// $acllist = array();
+
+ foreach( $this->folder->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(array('subaction'=>'delACL','aclid'=>$aclid));
+ }
+ ksort( $acllist );
+
+ $this->setTemplateVar('acls',$acllist );
+
+ $this->setTemplateVar('users' ,User::listAll() );
+ $this->setTemplateVar('groups' ,Group::getAll() );
+
+ $languages = Language::getAll();
+ $languages[0] = lang('ALL_LANGUAGES');
+ $this->setTemplateVar('languages',$languages);
+
+ $this->forward('folder_rights');
+ }
+
+
+ function pub()
+ {
+ if ( $this->getRequestVar('go') == '1' )
+ {
+ if ( $this->getRequestVar('subdirs') == '1' )
+ $subdirs = true;
+ else $subdirs = false;
+
+ $publish = new Publish();
+
+ $this->folder->publish = &$publish;
+ $this->folder->publish( $subdirs );
+
+ $list = array();
+
+ foreach( $publish->publishedObjects as $o )
+ {
+ $list[] = $o['filename'];
+ }
+ $this->setTemplateVar('filenames',$list);
+
+ $this->forward('all_publish');
+ }
+ else
+ {
+ $this->forward('folder_pub');
+ }
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/GroupAction.class.php b/actionClasses/GroupAction.class.php
@@ -0,0 +1,166 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class GroupAction extends Action
+{
+ var $group;
+ var $defaultSubAction = 'edit';
+
+
+ function GroupAction()
+ {
+ $this->group = new Group( $this->getSessionVar('groupid') );
+ $this->group->load();
+ }
+
+
+ function save()
+ {
+ global $SESS;
+
+ if ( $this->getRequestVar('delete')!='' )
+ {
+ $this->group->delete();
+
+ unset( $SESS['groupid'] );
+ $this->setTemplateVar['tree_refresh'] = true;
+
+ $this->callSubAction('listing');
+ }
+ else
+ {
+ $this->group->name = $this->getRequestVar('name');
+ $this->group->save();
+
+ $this->callSubAction('edit');
+ }
+ }
+
+
+ function add()
+ {
+ global $REQ;
+
+ $this->group->name = $REQ['name'];
+ $this->group->add();
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('listing');
+ }
+
+
+ function adduser()
+ {
+ // Benutzer der Gruppe hinzufügen
+ $this->group->addUser( $this->getRequestVar('userid') );
+
+ $this->callSubAction('users');
+ }
+
+
+ function deluser()
+ {
+ global $REQ;
+ $this->group->delUser( $REQ['userid'] );
+
+ $this->callSubAction('users');
+ }
+
+
+ function delright()
+ {
+
+ $this->group->addRight( $REQ['aclid'] );
+
+ // Berechtigungen anzeigen
+ $SESS['groupaction'] = 'rights';
+
+ }
+
+
+ function addright()
+ {
+ $this->group->addRight( $REQ );
+
+ // Berechtigungen anzeigen
+ $SESS['groupaction'] = 'rights';
+ }
+
+
+ function listing()
+ {
+ global $conf_php;
+ // Liste aller Gruppen
+ $list = array();
+
+ foreach( Group::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url(array('action'=>'main','callAction'=>'group','callSubaction'=>'edit','groupid'=>$id));
+ $list[$id]['name'] = $name;
+ }
+
+ $this->setTemplateVar('el', $list);
+
+ $this->forward('group_list');
+ }
+
+
+ function edit()
+ {
+ $this->setTemplateVars( $this->group->getProperties() );
+
+ $this->forward('group_edit');
+ }
+
+
+ function users()
+ {
+ // Mitgliedschaften ermitteln
+ //
+ $this->setTemplateVar('memberships',$this->group->getUsers());
+
+
+ // Alle hinzufügbaren Benutzer ermitteln
+ //
+ $this->setTemplateVar('users',$this->group->getOtherUsers());
+
+ $this->forward('group_users');
+
+ }
+
+
+ function rights()
+ {
+ $this->setTemplateVar('projects',$this->group->getRights());
+
+ $this->forward('group_rights');
+
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/IndexAction.class.php b/actionClasses/IndexAction.class.php
@@ -0,0 +1,269 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class IndexAction extends Action
+{
+ var $defaultSubAction = 'show';
+
+
+ function checkLogin( $name,$pw,$db )
+ {
+ Logger::debug( "user $name wants to log in at database $db" );
+
+ global $conf;
+ global $SESS;
+
+ unset( $SESS['user'] );
+
+
+ $db = db_connection();
+
+ $ip = getenv("REMOTE_ADDR");
+
+ $user = new User();
+ $user->name = $name;
+
+ $ok = $user->checkPassword( $pw );
+
+ // Falls Login erfolgreich
+ if ( $ok )
+ {
+ // Login war erfolgreich!
+ $user->load();
+ $user->setCurrent();
+
+// // Gruppen lesen
+// $sql = new Sql('SELECT groupid FROM {t_usergroup} '.
+// 'WHERE userid={userid}');
+// $sql->setInt('userid',$SESS['user']['id']);
+// $groups = $db->getCol( $sql->query );
+//
+// $SESS['user']['projects'] = array();
+//
+//
+// // Alle ACLs zum Benutzer (und seinen Gruppen) werden gelesen und
+// // dem Benutzer in der aktuellen Session hinzugefügt.
+// foreach( Acl::getACLsFromUserId($user->userid) as $aclid )
+// {
+// $user->addACL( $aclid );
+// }
+//
+// foreach( $user->getGroupIds() as $groupid )
+// {
+// foreach( Acl::getACLsFromGroupId($groupid) as $aclid )
+// {
+// $user->addACL( $aclid );
+// }
+// }
+
+ // print_r( $SESS['user']['rights'] );
+
+ // $SESS['rights'] = array();
+
+ // $sql = new Sql('SELECT * FROM {t_acl} WHERE userid={userid}');
+ // $sql->setInt('userid',$SESS['user']['id']);
+ // $res = $db->query( $sql->query );
+ //
+ // while( $row = $res->fetchRow() )
+ // {
+ // $f = new Folder( $row['folderid'] );
+ // $f->projectid = $row['projectid'];
+ // $f->addrights( $row );
+ // unset( $f );
+ // }
+
+ // foreach( $groups as $groupid )
+ // {
+ // $sql = new Sql('SELECT * FROM {t_acl} WHERE groupid={groupid}');
+ // $sql->setInt('groupid',$groupid);
+ // $res = $db->query( $sql->query );
+ //
+ // while( $row = $res->fetchRow() )
+ // {
+ // $f = new Folder( $row['folderid'] );
+ // $f->projectid = $row['projectid'];
+ // $f->addrights( $row );
+ // unset( $f );
+ // }
+ // }
+
+ // Wenn keine Berechtigung vorhanden, dann kein Login möglich
+// if ( count($SESS['user']) == 0 && $SESS['user']['is_admin']!='1' )
+// {
+// unset($SESS['user']);
+// }
+// else
+// {
+// if ( $SESS['user']['is_admin']=='1' )
+// {
+// // Für Administratoren einfach das 1.vorhandene Projekt auswählen
+// $sql = new SQL('SELECT id FROM {t_project} ORDER BY name');
+// $SESS['projectid'] = $db->getOne( $sql->query );
+// //echo "fuck, verdammt".$SESS['projectid'];
+// }
+// else
+// {
+// // Wenn noch kein Projekt in der Session vorhanden, dann
+// // das erste Projekt starten
+// if ( !is_numeric($SESS['projectid']) )
+// {
+// $projects = array_keys( $SESS['rights'] );
+// $SESS['projectid'] = $projects[0];
+// }
+// }
+// }
+ }
+
+ if ( isset($SESS['user']) )
+ {
+ Logger::info( 'login successful' );
+ }
+ else
+ {
+ Logger::info( "login for user $name failed" );
+
+ $SESS['loginmessage'] = lang('LOGIN_FAILED');
+ }
+ }
+
+
+ function login()
+ {
+ global $SESS;
+ # Ein Benutzer versucht sich anzumelden
+ #
+ unset( $SESS['user'] );
+
+ $SESS['dbid'] = $this->getRequestVar('dbid');
+
+ $this->checkLogin( $this->getRequestVar('login_name' ),
+ $this->getRequestVar('login_password'),
+ $this->getRequestVar('dbid' ) );
+
+
+ $this->callSubAction('show');
+ }
+
+
+ function logout()
+ {
+ global $SESS;
+ unset( $SESS['user'] );
+
+ $this->callSubAction('show');
+ }
+
+
+ function show()
+ {
+ global $SESS,$conf;
+
+ if ( !isset($SESS['lang']) )
+ {
+ language_read();
+ }
+
+
+ // Authorization über HTTP
+ //
+ if ( $conf['auth']['type'] == 'http' )
+ {
+ if ( isset($PHP_AUTH_USER) )
+ {
+ login( $PHP_AUTH_USER,$PHP_AUTH_PW,$db );
+ }
+
+ # Falls Benutzer nicht angemeldet, dann Login-Maske präsentieren
+ #
+ if ( !isset($sess_user) )
+ {
+ header( 'WWW-Authenticate: Basic realm="Login"' );
+ header( 'HTTP/1.0 401 Unauthorized' );
+ echo 'Authorization Required!';
+ exit;
+ }
+ }
+
+
+ $title = $conf['global']['title'].' '.$conf['global']['version'];
+
+ if (!isset($SESS['user']))
+ {
+ $this->setTemplateVar( 'title',lang('NOT_LOGGED_IN').' - '.$title );
+ $this->setTemplateVar( 'frame_src_main',Html::url( array('action'=>'main',
+ 'callAction'=>'login',
+ 'callSubaction'=>'login' )) );
+ }
+ else
+ {
+ $this->setTemplateVar( 'title',$SESS['user']['name'].' @'.$conf['database_'.$SESS['dbid']]['comment'].' - '.$title );
+
+ if ( $this->getSessionVar('objectid') != '' )
+ {
+ $object = new Object( $this->getSessionVar('objectid') );
+ $object->load();
+ $this->setSessionVar('projectid',$object->projectid);
+
+ $this->setTemplateVar( 'frame_src_main' ,Html::url( array('action'=>'main',
+ 'callAction'=>$object->getType() )) );
+ }
+ else
+ {
+ if ( $this->getSessionVar('projectid') != '' )
+ {
+ $project = new Project( $this->getSessionVar('projectid') );
+ $objectid = $project->getRootObjectId();
+ $this->setSessionVar('objectid',$objectid);
+
+ $this->setTemplateVar( 'frame_src_main' ,Html::url( array('action'=>'main',
+ 'callAction'=>'folder' )) );
+ }
+ else
+ {
+ $this->setTemplateVar( 'frame_src_main' ,Html::url( array('action'=>'main',
+ 'callAction'=>'login',
+ 'callSubaction'=>'blank' )) );
+ }
+ }
+ }
+
+ $this->setTemplateVar( 'frame_src_title' ,Html::url( array('action'=>'title' )) );
+ $this->setTemplateVar( 'frame_src_treemenu',Html::url( array('action'=>'treemenu')) );
+ $this->setTemplateVar( 'frame_src_tree' ,Html::url( array('action'=>'tree',
+ 'subaction'=>'reload')) );
+
+ // Breite des Baums ermitteln
+ if (isset($SESS['user']))
+ $this->setTemplateVar( 'tree_width',$conf['global']['tree_width'] );
+ else $this->setTemplateVar( 'tree_width','0' );
+
+ $this->forward( 'frameset' );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/LanguageAction.class.php b/actionClasses/LanguageAction.class.php
@@ -0,0 +1,168 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Action-Klasse für die Bearbeitung einer Sprache
+ * @version $Id$
+ * @author $Author$
+ */
+class LanguageAction extends Action
+{
+ /**
+ * Zu bearbeitende Sprache, wird im Kontruktor instanziiert
+ * @type Language
+ */
+ var $language;
+
+
+ /**
+ * Konstruktor
+ */
+ function LanguageAction()
+ {
+ $this->language = new Language( $this->getSessionVar('languageid') );
+ $this->language->load();
+ }
+
+
+ /**
+ * Sprache hinzufügen
+ */
+ function add()
+ {
+
+ // Hinzufügen einer Sprache
+ $this->language->add( $this->getRequestVar('isocode') );
+ $this->setSessionVar('languageid',$this->language->languageid);
+
+ $this->callSubAction( 'edit' );
+ }
+
+
+ /**
+ * 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();
+
+ $this->callSubAction( 'listing' );
+ }
+
+
+ /**
+ * Speichern der Sprache
+ */
+ function save()
+ {
+ $this->setTemplateVar('tree_refresh',true);
+
+ if ( $this->getRequestVar('name') != '' )
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->language->delete();
+ $this->setSessionVar('languageid','');
+
+ $this->callSubAction( 'listing' );
+ }
+ else
+ {
+ $this->language->name = $this->getRequestVar('name' );
+ $this->language->isoCode = $this->getRequestVar('isocode');
+ $this->language->save();
+ }
+ }
+
+ $this->callSubAction( 'edit' );
+ }
+
+
+
+ // Auswählen einer Sprache
+ function select()
+ {
+ $this->setSessionVar('languageid',$this->language->languageid);
+
+ $this->callSubAction( 'listing' );
+ }
+
+
+
+ function listing()
+ {
+ global $conf_php;
+
+ $iso = GlobalFunctions::getIsoCodes();
+
+ $list = array();
+ $this->setTemplateVar('act_languageid',$this->language->languageid);
+
+ foreach( $this->language->getAll() as $id=>$name )
+ {
+ $l = new Language( $id );
+ $l->load();
+
+ $list[$id] = array();
+ $list[$id]['name'] = $name;
+
+ if ( $this->userIsAdmin() )
+ {
+ $list[$id]['url' ] = 'do.'.$conf_php.'?languageaction=edit&languageid='.$id;
+
+ if ( ! $l->isDefault )
+ $list[$id]['default_url'] = 'languageaction=setDefault&languageid='.$id;
+ }
+
+ if ( $this->getSessionVar('languageid') != $l->languageid )
+ $list[$id]['select_url'] = 'languageaction=select&languageid='.$id;
+ }
+
+ if ( $this->userIsAdmin() )
+ $this->setTemplateVar('isocodes',$iso);
+
+ $this->setTemplateVar('el',$list);
+
+ $this->forward('language_list');
+ }
+
+
+
+ function edit()
+ {
+ if ( count($this->language->getAll()) >= 2 )
+ $this->setTemplateVar('delete',true );
+ else $this->setTemplateVar('delete',false);
+
+ $this->setTemplateVars( $this->language->getProperties() );
+
+ $this->forward('language_edit');
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/LinkAction.class.php b/actionClasses/LinkAction.class.php
@@ -0,0 +1,212 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Action-Klasse für Verknüpfungen
+ * @version $Id$
+ * @author $Author$
+ */
+class LinkAction extends Action
+{
+ var $link;
+ var $defaultSubAction = 'prop';
+
+ /**
+ * Konstruktor
+ */
+ function LinkAction()
+ {
+ $this->link = new Link( $this->getSessionVar('objectid') );
+ $this->link->load();
+ }
+
+
+ /**
+ * Verschieben der Verknüpfung
+ */
+ function move()
+ {
+ $this->objectMove();
+ $this->link->load();
+
+ $this->callSubAction('prop');
+ }
+
+
+ function delACL()
+ {
+ $this->objectDelACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ /**
+ * Abspeichern der Eigenschaften
+ */
+ function save()
+ {
+ // Wenn Name gefüllt, dann Datenbank-Update
+ if ( $this->getRequestVar('name') != '' )
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ // Verknuepfung löschen
+ $this->link->delete();
+
+ $this->getRequestVar('tree_refresh',true);
+ $this->forward('blank');
+ }
+ else
+ {
+ // Eigenschaften speichern
+ $this->link->name = $this->getRequestVar('name');
+ $this->link->desc = $this->getRequestVar('desc');
+
+ if ( $this->getRequestVar('type') == 'link' )
+ {
+ $this->link->isLinkToObject = true;
+ $this->link->isLinkToUrl = false;
+ $this->link->linkedObjectId = $this->getRequestVar('linkobjectid');
+ }
+ else
+ {
+ $this->link->isLinkToObject = false;
+ $this->link->isLinkToUrl = true;
+ $this->link->url = $this->getRequestVar('url');
+ }
+
+ $this->link->save();
+ }
+ }
+
+ $this->getRequestVar('tree_refresh',true);
+
+ $this->callSubAction('prop');
+ }
+
+
+ function prop()
+ {
+ $this->setTemplateVars( $this->link->getProperties() );
+
+ if ( is_numeric($this->link->lastchange_userid) )
+ {
+ $user = new User( $this->link->lastchange_userid );
+ $user->load();
+ $this->setTemplateVar('lastchange_user',array('name'=>$user->name,
+ 'url' =>Html::url(array('action'=>'user',
+ 'userid'=>$user->userid))));
+ }
+ else
+ {
+ $this->setTemplateVar('lastchange_user',array('name'=>lang('UNKNOWN')));
+ }
+
+ if ( is_numeric($this->link->create_userid) )
+ {
+ $user = new User( $this->link->create_userid );
+ $user->load();
+ $this->setTemplateVar('create_user',array('name'=>$user->name,
+ 'url' =>Html::url(array('action'=>'user',
+ 'userid'=>$user->userid))));
+ }
+ else
+ {
+ $this->setTemplateVar('create_user',array('name'=>lang('UNKNOWN')));
+ }
+
+
+
+ // Typ der Verknüpfung
+ $this->setTemplateVar('type' ,$this->link->getType() );
+ $this->setTemplateVar('act_linkobjectid',$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(' » ',$folder->parentObjectNames( false,true ) );
+ $list[$oid] .= ' » '.$o->name;
+ }
+ }
+ asort( $list );
+ $this->setTemplateVar('objects',$list);
+
+
+ // Alle Ordner ermitteln
+ $this->setTemplateVar('act_objectid',$this->link->parentid);
+ $list = array();
+
+ $f = new Folder( $this->link->parentid );
+ foreach( $f->getOtherFolders() as $oid )
+ {
+ $folder = new Folder( $oid );
+ $list[$oid] = implode(' » ',$folder->parentObjectNames( true,true ) );
+ }
+ asort( $list );
+ $this->setTemplateVar('folder',$list);
+ $this->forward('link_prop');
+ }
+
+
+ function rights()
+ {
+ $acl = new Acl();
+ $acl->objectid = $this->link->objectid;
+
+ $var['access_acls'] = array();
+
+ foreach( $acl->getAccessACLsFromObject() as $id )
+ {
+ $acl = new Acl( $id );
+ $acl->load();
+ $var['access_acls'][$id] = $acl->getProperties();
+ $var['access_acls'][$id]['delete_url'] = 'folder.'.$conf_php.'?folderaction=delACL&aclid='.$id;
+ }
+
+ $var['users'] = User::listAll();
+ $var['groups'] = Group::getAll();
+ $var['languages'] = Language::getAll();
+
+ $this->forward('link_rights');
+ }
+
+}+
\ No newline at end of file
diff --git a/actionClasses/LoginAction.class.php b/actionClasses/LoginAction.class.php
@@ -0,0 +1,77 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// Revision 1.2 2003/10/02 20:56:17 dankert
+// Benutzer entfernen
+//
+// Revision 1.1 2003/09/29 18:18:21 dankert
+// erste Version
+//
+// ---------------------------------------------------------------------------
+
+
+class LoginAction extends Action
+{
+ var $defaultSubAction = 'login';
+
+ function LoginAction()
+ {
+ }
+
+
+ function blank()
+ {
+ $this->forward('blank');
+ }
+
+
+ function login()
+ {
+ global $conf;
+
+
+ $databases = explode(',',$conf['database']['databases']);
+ $dbids = array();
+
+ foreach( $databases as $db )
+ {
+ if ( !isset($conf['database_'.$db]) )
+ $this->message( '',"configuration for 'database_$db' not defined in config.ini.php");
+
+ $dbids[$db] = $conf['database_'.$db]['comment'];
+ }
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ if ( $this->getSessionVar('dbid') != '' )
+ $this->setTemplateVar('actdbid',$this->getSessionVar('dbid'));
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+
+ $this->setTemplateVar('loginmessage',$this->getSessionVar('loginmessage'));
+ $this->setSessionVar('loginmessage','');
+
+ $this->forward('login');
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/MainAction.class.php b/actionClasses/MainAction.class.php
@@ -0,0 +1,24 @@
+<?php
+
+
+class MainAction extends Action
+{
+ var $defaultSubAction = 'show';
+
+ function show()
+ {
+ if ( $this->getRequestVar('callSubaction')!='')
+ {
+ $this->setSessionVar( $this->getRequestVar('callAction').'action',$this->getRequestVar('callSubaction') );
+ }
+
+ $this->setTemplateVar('frame_src_main_menu',Html::url( array('action'=>'mainmenu' ,'subaction'=>$this->getRequestVar('callAction' ) ) ));
+ $this->setTemplateVar('frame_src_main_main',Html::url( array('action'=>$this->getRequestVar('callAction'),'subaction'=>$this->getSessionVar( $this->getRequestVar('callAction').'action' ) ) ));
+
+ $this->forward('frameset_main');
+ }
+
+}
+
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/MainmenuAction.class.php b/actionClasses/MainmenuAction.class.php
@@ -0,0 +1,409 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class MainmenuAction extends Action
+{
+ var $defaultSubAction = 'login';
+
+
+ function login()
+ {
+ $this->setTemplateVar('folder',array() );
+ $this->setTemplateVar('action','login' );
+ $this->setTemplateVar('name' ,'loginaction');
+ $this->setTemplateVar('param' ,'objectid' );
+ $this->setTemplateVar('subaction',array('login'=>lang('LOGIN')) );
+
+ $this->callSubAction('show');
+ }
+
+
+ function element()
+ {
+ $this->subActionName = 'template';
+ $this->callSubAction('template');
+ }
+
+
+ function template()
+ {
+ $this->setTemplateVar('folder',array() );
+ // Ermitteln Projectmodell
+ $model = new Model($this->getSessionVar('modelid'));
+ $model->load();
+ $this->setTemplateVar('projectmodel_name',$model->name);
+
+ $this->setTemplateVar('id','tpl'.$this->getSessionVar('templateid'));
+
+ if ( intval($this->getSessionVar('templateid')) != 0 )
+ {
+ $template = new Template( $this->getSessionVar('templateid') );
+ $template->load();
+ $this->setTemplateVar('text',$template->name );
+
+ $this->setTemplateVar('subaction',array('listing'=>lang('LISTING'),
+ 'show' =>lang('SHOW'),
+ 'el' =>lang('ELEMENTS'),
+ 'src' =>lang('SOURCECODE'),
+ 'prop' =>lang('PROP') ));
+ }
+ else
+ {
+ $this->setTemplateVar('subaction',array('listing'=>lang('LISTING')));
+
+ }
+ $this->setTemplateVar('param' ,'templateid');
+
+ $this->callSubAction('show');
+ }
+
+
+
+ function pageelement()
+ {
+ $this->subActionName = 'page';
+ $this->callSubAction('page');
+ }
+
+ function page()
+ {
+
+ $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
+
+ // Ermitteln Sprache
+ $language = new Language( $this->getSessionVar('languageid') );
+ $language->load();
+ $this->setTemplateVar('language_name',$language->name);
+
+ // Ermitteln Projectmodell
+ $model = new Model( $this->getSessionVar('modelid') );
+ $model->load();
+ $this->setTemplateVar('projectmodel_name',$model->name);
+
+ $page = new Page($this->getSessionVar('objectid'));
+ $page->load();
+
+ $folder = new Folder( $page->parentid );
+ $folder->filenames = false;
+ $folder->load();
+
+ $this->setTemplateVar('folder',$folder->parentObjectNames(true,true));
+
+ // Ermitteln Namen der Seite
+ $this->setTemplateVar('text',$page->name);
+
+ $this->setTemplateVar('id','o'.$page->objectid);
+
+ $list = array();
+ $list['show'] = lang('SHOW');
+
+ if ( $page->hasRight('write') )
+ {
+ $list['edit'] = lang('EDIT');
+ $list['el' ] = lang('ELEMENTS');
+ }
+ if ( $page->hasRight('publish') )
+ {
+ $list['pub' ] = lang('PUBLISH');
+ }
+
+ if ( $page->hasRight('prop') )
+ {
+ $list['prop'] = lang('PROP');
+ }
+
+ $user = $this->getSessionVar('user');
+ if ( $user['is_admin'] )
+ $list['src' ] = lang('SOURCECODE');
+
+ if ( $user['is_admin'] == '1' )
+ $list['rights'] = lang('RIGHTS');
+ $this->setTemplateVar('subaction',$list);
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+
+ function user()
+ {
+ $this->setTemplateVar('folder',array() );
+ $user = new User( $this->getSessionVar('userid') );
+ $user->load();
+
+ $this->setTemplateVar('text',$user->name);
+
+ if ( intval($this->getSessionVar('userid') == 0 ))
+ $this->setTemplateVar('subaction',array('listing' =>lang('LISTING')));
+ else $this->setTemplateVar('subaction',array('listing' =>lang('LISTING'),
+ 'edit' =>lang('EDIT'),
+ 'groups'=>lang('MEMBERSHIPS'),
+ 'pw' =>lang('PASSWORD') ));
+
+ $this->setTemplateVar('param','userid');
+ $this->callSubAction('show');
+ }
+
+
+
+ function group()
+ {
+ $this->setTemplateVar('folder',array() );
+
+ $group = new Group( $this->getSessionVar('groupid') );
+ $group->load();
+ $this->setTemplateVar('text',$group->name);
+
+ if ( intval($this->getSessionVar('groupid') == 0 ))
+ $this->setTemplateVar('subaction',array('listing'=>lang('LISTING') ));
+ else $this->setTemplateVar('subaction',array('listing'=>lang('LISTING'),
+ 'edit' =>lang('EDIT'),
+ 'users' =>lang('MEMBERSHIPS') ));
+
+ $this->setTemplateVar('param','groupid');
+ $this->callSubAction('show');
+ }
+
+
+ function file()
+ {
+ // Ermitteln Sprache
+ $language = new Language( $this->getSessionVar('languageid') );
+ $language->load();
+ $this->setTemplateVar('language_name',$language->name);
+
+ $file = new File( $this->getSessionVar('objectid') );
+ $file->load();
+
+ $folder = new Folder( $file->parentid );
+ $folder->filenames = false;
+ $folder->load();
+
+ $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
+
+ $this->setTemplateVar('folder',$folder->parentObjectNames(true,true));
+ $this->setTemplateVar('text' ,$file->name);
+
+ $this->setTemplateVar('id','o'.$file->objectid);
+
+ $list = array();
+ $list['show'] = lang('SHOW');
+
+ if ( substr($file->mimeType(),0,5) == 'text/' )
+ $list['src'] = lang('EDIT');
+
+ if ( $file->hasRight('prop') )
+ $list['prop'] = lang('PROP');
+
+ if ( $file->hasRight('publish') )
+ $list['pub' ] = lang('PUBLISH');
+
+ $user = $this->getSessionVar('user');
+ if ( $user['is_admin'] == '1' )
+ $list['rights'] = lang('RIGHTS');
+
+ $this->setTemplateVar('subaction',$list);
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+
+ function link()
+ {
+ // Ermitteln Sprache
+ $link = new Link( $this->getSessionVar('objectid') );
+ $link->load();
+
+ $folder = new Folder( $link->parentid );
+ $folder->filenames = false;
+ $folder->load();
+
+ $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
+
+ $language = new Language( $this->getSessionVar('languageid') );
+ $language->load();
+ $this->setTemplateVar('language_name',$language->name);
+
+ $this->setTemplateVar('folder',$folder->parentObjectNames(true,true));
+ $this->setTemplateVar('text' ,$link->name);
+
+ $this->setTemplateVar('id','o'.$link->objectid);
+
+ $list = array();
+ if ( $link->hasRight('prop') )
+ $list['prop'] = lang('PROP');
+
+ if ( $this->userIsAdmin() )
+ $list['rights'] = lang('RIGHTS');
+ $this->setTemplateVar('subaction',$list);
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+
+ function folder()
+ {
+
+ // Ermitteln Sprache
+ $language = new Language( $this->getSessionVar('languageid') );
+ $language->load();
+ $this->setTemplateVar('language_name',$language->name);
+
+ $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
+ if ( !is_numeric($this->getSessionVar('objectid')) )
+ {
+ $SESS['objectid'] = Folder::getRootObjectId();
+ }
+
+ $folder = new Folder( $this->getSessionVar('objectid') );
+ $folder->filenames = false;
+ $folder->load();
+
+ $this->setTemplateVar('folder',$folder->parentObjectNames(true,false));
+
+ $this->setTemplateVar('text',$folder->name);
+
+ $this->setTemplateVar('id','o'.$folder->objectid);
+
+ $list = array();
+ $list['show'] = lang('SHOW');
+
+ if ( $this->getSessionVar('objectid') != '' && !$folder->isRoot )
+ if ( $folder->hasRight('prop') )
+ $list['prop'] = lang('PROP');
+
+ if ( $this->getSessionVar('objectid') != '' )
+ if ( $folder->hasRight('create_folder')
+ || $folder->hasRight('create_file' )
+ || $folder->hasRight('create_link' )
+ || $folder->hasRight('create_page' ) )
+ $list['create'] = lang('NEW');
+
+ $user = $this->getSessionVar('user');
+ if ( $user['is_admin'] == '1' )
+ $list['rights'] = lang('RIGHTS');
+
+ if ( $folder->hasRight('publish') )
+ $list['pub' ] = lang('PUBLISH');
+ $this->setTemplateVar('subaction',$list);
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+ function project()
+ {
+ $this->setTemplateVar('folder',array() );
+
+ $list = array();
+ $list['listing'] = lang('LISTING');
+
+ if ( intval($this->getSessionVar('projectid')) != 0 )
+ {
+ $list['edit'] = lang('EDIT');
+ $project = new Project($this->getSessionVar('projectid'));
+ $project->load();
+ $this->setTemplateVar('text',$project->name );
+ }
+ else
+ {
+ $this->setTemplateVar('text','' );
+ }
+
+ $this->setTemplateVar('subaction',$list);
+ $this->setTemplateVar('param','projectid');
+
+ $this->callSubAction('show');
+ }
+
+
+ function language()
+ {
+ $this->setTemplateVar('id','lang');
+
+ $this->setTemplateVar('subaction',array('listing'=>lang('LISTING')));
+ $this->setTemplateVar('param','languageid');
+
+ $this->callSubAction('show');
+ }
+
+
+
+ function model()
+ {
+ $this->setTemplateVar('id','pvar');
+
+ $this->setTemplateVar('subaction',array('listing'=>lang('LISTING')));
+ $this->setTemplateVar('param','modelid');
+
+ $this->callSubAction('show');
+ }
+
+
+ function search()
+ {
+ $this->setTemplateVar('subaction',array('prop' =>lang('SEARCH_PROP' ),
+ 'content'=>lang('SEARCH_CONTENT' ) ));
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+ function transfer()
+ {
+ $this->setTemplateVar('subaction',array('import'=>lang('import')));
+ $this->setTemplateVar('param','objectid');
+
+ $this->callSubAction('show');
+ }
+
+
+ function show()
+ {
+ $this->setTemplateVar('action',$this->subActionName);
+
+ if ( $this->subActionName == 'pageelement')
+ $this->setTemplateVar('action','page');
+
+ $this->setTemplateVar('name' ,$this->subActionName);
+ $this->setTemplateVar('css_body_class','menu' );
+
+ $this->setTemplateVar('type' ,$this->subActionName);
+
+ $this->forward( 'main_menu' );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/ModelAction.class.php b/actionClasses/ModelAction.class.php
@@ -0,0 +1,145 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class ModelAction extends Action
+{
+ var $defaultSubAction = 'listing';
+ var $model;
+
+
+ function ModelAction()
+ {
+ $this->model = new Model();
+
+ if ( intval($this->getSessionVar('modelid')) != 0 )
+ {
+ $this->model->modelid = $this->getSessionVar('modelid');
+ $this->model->load();
+ }
+ }
+
+
+ function add()
+ {
+ $model = new Model();
+ $model->add( $this->getRequestVar('name') );
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('edit');
+ }
+
+
+ // Speichern eines Modells
+ function save()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->model->delete();
+
+ $this->callSubAction('listing');
+ }
+ else
+ {
+ $this->model->name = $this->getRequestVar('name');
+ $this->model->save();
+
+ $this->callSubAction('listing');
+ }
+ }
+
+ // Baum aktualisieren
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('listing');
+ }
+
+
+ function setDefault()
+ {
+ if ( !$this->userIsAdmin() ) exit();
+
+ $this->model->setDefault();
+
+ $this->callSubAction('listing');
+ }
+
+
+ function select()
+ {
+ $this->setSessionVar('projectmodelid',$this->getRequestVar('projectmodelid'));
+
+ $this->callSubAction('listing');
+ }
+
+
+ function listing()
+ {
+ global $conf_php;
+
+ $var['act_modelid'] = $this->getSessionVar('modelid');
+
+ $list = array();
+ foreach( $this->model->getAll() as $id=>$name )
+ {
+ $m = new Model( $id );
+ $m->load();
+
+ $list[$id]['name'] = $m->name;
+
+ if ( $this->userIsAdmin() )
+ $list[$id]['url' ] = 'do.'.$conf_php.'?modelaction=edit&modelid='.$id;
+
+ if ( ! $m->isDefault && $this->userIsAdmin() )
+ $list[$id]['default_url'] = 'modelaction=default&modelid='.$id;
+
+ if ( $this->getSessionVar('modelid') != $m->modelid )
+ $list[$id]['select_url' ] = 'modelaction=select&modelid='.$id;
+ }
+ $this->setTemplateVar( 'el',$list );
+ $this->setTemplateVar( 'add',$this->userIsAdmin() );
+
+ $this->forward('model_list');
+ }
+
+
+ function edit()
+ {
+ if ( count( $this->model->getAll() ) >= 2 )
+ $this->setTemplateVar('delete',true );
+ else $this->setTemplateVar('delete',false);
+
+ $this->model->load();
+
+ $this->setTemplateVars( $this->model->getProperties() );
+
+ $this->forward('model_edit');
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/PageAction.class.php b/actionClasses/PageAction.class.php
@@ -0,0 +1,295 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class PageAction extends Action
+{
+ var $page;
+ var $defaultSubAction = 'show';
+
+
+ function PageAction()
+ {
+ if ( $this->getRequestVar('objectid') != '' )
+ $this->page = new Page( $this->getRequestVar('objectid') );
+ else $this->page = new Page( $this->getSessionVar('objectid') );
+
+ $this->page->load();
+ }
+
+
+ /**
+ * Verschieben der Seite
+ */
+ function move()
+ {
+ $this->objectMove();
+ $this->link->load();
+
+ $this->callSubAction('prop');
+ }
+
+
+ function addAccessACL()
+ {
+ $this->objectAddAccessACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ function delACL()
+ {
+ $this->objectDelACL();
+
+ $this->callSubAction('rights');
+ }
+
+
+ function elsave()
+ {
+ $value = new Value();
+ $value->languageid = $this->getSessionVar('languageid');
+ $value->objectid = $this->getSessionVar('objectid');
+ $value->pageid = Page::getPageIdFromObjectId( $this->getSessionVar('objectid') );
+ $value->element = new Element( $this->getSessionVar('elementid') );
+ $value->element->load();
+ $value->load();
+
+ $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals);
+
+ $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
+
+ $value->text = $this->getRequestVar('text');
+
+ if ( $this->getRequestVar('year') != '' )
+ {
+ if ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') )
+ $value->date = strtotime($this->getRequestVar('ansidate') );
+ else $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;
+
+ $value->text = $this->getRequestVar('text');
+
+ // Inhalt speichern
+ $value->save();
+
+ $this->callSubAction( $this->getRequestVar('old_pageaction') );
+ }
+
+
+ function propsave()
+ {
+ if ($this->getRequestVar('name') != '')
+ {
+ if ( $this->getRequestVar('delete') == '1' )
+ {
+ $this->page->delete();
+ $this->forward('');
+ }
+ else
+ {
+ $this->page->name = $this->getRequestVar('name' );
+ $this->page->filename = $this->getRequestVar('filename');
+ $this->page->desc = $this->getRequestVar('desc' );
+
+ $this->page->save();
+ }
+ $this->setTemplateVar('tree_refresh',true);
+
+ }
+
+ $this->callSubAction('prop');
+ }
+
+
+ function el()
+ {
+ global $conf_php;
+
+ $this->page->public = true;
+ $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;
+
+ $u = new User( $value->lastchangeUserId );
+ $u->load();
+ $list[$id]['username' ] = $u->name;
+ $list[$id]['userfullname'] = $u->fullname;
+ $list[$id]['date' ] = date( lang('DATE_FORMAT'),$value->lastchangeTimeStamp);
+ $list[$id]['archive_url' ] = Html::url(array('action'=>'pageelement','elementid'=>$id,'subaction'=>'archive'));
+ $list[$id]['url' ] = Html::url(array('action'=>'pageelement','elementid'=>$id,'subaction'=>'edit' ));
+
+ // Maximal 50 Stellen des Inhaltes anzeigen
+ $list[$id]['value'] = Text::maxLaenge( 50,$value->value );
+ }
+ }
+
+ $this->setTemplateVar('el',$list);
+ $this->forward('page_element');
+
+ }
+
+
+ function show()
+ {
+ // Seite definieren
+ $this->page->load();
+ $this->page->generate();
+ $this->page->write();
+ require( $this->page->tmpfile() );
+
+ }
+
+
+ function edit()
+ {
+ // Editier-Icons anzeigen
+ $this->page->icons = true;
+
+ $this->page->load();
+ $this->page->generate();
+ $this->page->write();
+ require( $this->page->tmpfile() );
+
+ }
+
+
+ function src()
+ {
+ $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);
+ //$var['src'] = htmlentities($src);
+ $this->setTemplateVar('src',$src);
+
+ $this->forward('page_src');
+ }
+
+
+ function prop()
+ {
+ global $SESS;
+ $this->setTemplateVar('id',$this->page->objectid);
+
+ $this->page->public = true;
+ $this->page->load();
+ $this->setTemplateVars( $this->page->getProperties() );
+
+ $this->setTemplateVar('delete',$this->page->hasRight('delete'));
+
+ if ( $SESS['user']['is_admin'] == '1' )
+ {
+ $this->setTemplateVar('template_url',Html::url(array('action'=>'main','callAction'=>'template','templateid'=>$this->page->templateid,'tplaction'=>'show')));
+ }
+
+ $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(' » ',$f->parentObjectNames(true,true) );
+ }
+ asort( $folders );
+ $this->setTemplateVar('folder',$folders);
+
+ $this->forward('page_prop');
+ }
+
+
+ function pub()
+ {
+ $this->page->publish();
+
+ $list = array();
+ foreach( $this->page->publish->publishedObjects as $o )
+ {
+ $var['filenames'][] = $o['filename'];
+ }
+
+ $this->setTemplateVar('filenames',$list);
+
+ $this->forward('all_publish');
+ }
+
+
+ function rights()
+ {
+ global $SESS;
+ if ($SESS['user']['is_admin'] != '1') die('nice try');
+
+ $acl = new Acl();
+ $acl->objectid = $this->page->objectid;
+
+ $var['access_acls'] = array();
+
+ foreach( $acl->getAccessACLsFromObject() as $id )
+ {
+ $acl = new Acl( $id );
+ $acl->load();
+ $var['access_acls'][$id] = $acl->getProperties();
+ $var['access_acls'][$id]['delete_url'] = '?pageaction=delACL&aclid='.$id;
+ }
+
+ $var['users'] = User::listAll();
+ $var['groups'] = Group::getAll();
+
+ $this->forward('page_rights');
+
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/PageelementAction.class.php b/actionClasses/PageelementAction.class.php
@@ -0,0 +1,261 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Action-Klasse zum Bearbeiten eines Seitenelementes
+ * @author $Author$
+ * @version $Revision$
+ */
+class PageelementAction extends Action
+{
+ var $defaultSubAction = 'edit';
+
+
+ /**
+ * Enthält das Seitenobjekt
+ * @type Object
+ */
+ var $page;
+
+ /**
+ * Enthält das Elementobjekt
+ * @type Object
+ */
+ var $element;
+
+
+ /**
+ * Konstruktor
+ */
+ function PageelementAction()
+ {
+ $this->value = new Value();
+ }
+
+
+ function edit()
+ {
+ $this->value->languageid = $this->getSessionVar('languageid');
+ $this->value->objectid = $this->getSessionVar('objectid');
+ $this->value->pageid = Page::getPageIdFromObjectId( $this->getSessionVar('objectid') );
+ $this->value->element = new Element( $this->getSessionVar('elementid') );
+ $this->value->element->load();
+
+ 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);
+
+ switch( $this->value->element->type )
+ {
+
+ case 'link':
+
+ $objects = array();
+
+ foreach( Folder::getAllObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ if ( $o->getType() != 'folder' )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+
+ $objects[ $id ] = lang( $o->getType() ).': ';
+ $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= ' » '.$o->name;
+ }
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects' ,$objects);
+ $this->setTemplateVar('act_linkobjectid',$this->value->linkToObjectId);
+
+ break;
+
+ case 'list':
+
+ $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('act_linkobjectid',$this->value->linkToObjectId);
+
+ break;
+
+
+ case 'number':
+ $this->setTemplateVar('number',$this->value->number / pow(10,$this->value->element->decimals) );
+ break;
+
+ case 'longtext':
+ case 'text':
+ $this->setTemplateVar('text',$this->value->text);
+ break;
+
+ case 'date':
+
+ $date = $this->value->date;
+
+ // Wenn Datum nicht vorhanden, dann aktuelles Datum verwenden
+ if ( $date == 0 )
+ $date = time();
+
+ if ( $this->getRequestVar('year') != '' )
+ {
+ $date = mktime( $this->getRequestVar('hour'),
+ $this->getRequestVar('minute'),
+ $this->getRequestVar('second'),
+ $this->getRequestVar('month'),
+ $this->getRequestVar('day'),
+ $this->getRequestVar('year') );
+ }
+ $this->setTemplateVar('year' ,date('Y',$date) );
+ $this->setTemplateVar('month' ,date('n',$date) );
+ $this->setTemplateVar('day' ,date('j',$date) );
+ $this->setTemplateVar('hour' ,date('G',$date) );
+ $this->setTemplateVar('minute',date('i',$date) );
+ $this->setTemplateVar('second',date('s',$date) );
+
+ $this->setTemplateVar('days' ,date('t',$date) );
+
+ $this->setTemplateVar('title' ,lang('MONTH'.date('n',$date)).' '.date('Y',$date) );
+
+ // Wochentag des 1. des Monats ermitteln
+ $wday1 = date( 'w',$date );
+ $wday1 -= date('j',$date)-1;
+ while( $wday1 < 0 ) $wday1+=7;
+ $this->setTemplateVar('first_weekday',$wday1);
+
+ $this->setTemplateVar('actdate' ,date( lang('DATE_FORMAT'),$date ) );
+ $this->setTemplateVar('todayurl','?year='.date('Y').'&month='.date('m').'&day='.date('d').'&hour='.date('H').'&minute='.date('i').'&second='.date('s') );
+ $this->setTemplateVar('ansidate',date( 'Y-m-d H:i:s',$date ) );
+ $this->setTemplateVar('date' ,$date);
+
+ $all_years = array();
+ $all_months = array();
+ $all_days = array();
+ $all_hours = array();
+ $all_minutes = array();
+ for( $i=1850; $i<=2100;$i++ ) $all_years [$i] = $i;
+ for( $i=1; $i<=12; $i++ ) $all_months [$i] = lang('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);
+
+ break;
+
+ default:
+ $this->message('ERROR','unknown element type: '.$this->value->element->type );
+ }
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+
+ $this->forward('pageelement_edit_'.$this->value->element->type);
+ }
+
+
+ /**
+ * Benutzen eines alten Inhaltes
+ */
+ function usevalue()
+ {
+ $this->value->valueid = $this->getRequestVar('valueid');
+
+ // Das ausgewählte Element für die Bearbeitung verwenden
+ $this->callSubAction('edit');
+ }
+
+
+ /**
+ * Erzeugt eine Liste aller Versionsstände zu diesem Inhalt
+ */
+ function archive()
+ {
+ $this->value->page = new Page( $this->getSessionVar('objectid') );
+ $this->value->page->load();
+ $this->value->page->public = true;
+ $this->value->page->simple = true;
+
+ $this->value->simple = true;
+ $this->value->languageid = $this->getSessionVar('languageid');
+ $this->value->objectid = $this->getSessionVar('objectid' );
+ $this->value->pageid = Page::getPageIdFromObjectId( $this->getSessionVar('objectid') );
+ $this->value->element = new Element( $this->getSessionVar('elementid') );
+ $this->value->element->load();
+
+ $list = array();
+
+ foreach( $this->value->getVersionList() as $valueid )
+ {
+ $this->value->valueid = $valueid;
+ $this->value->loadWithId();
+ $this->value->generate();
+
+ if ( $this->value->lastchangeTimeStamp != 0 )
+ $date = date( lang('DATE_FORMAT'),$this->value->lastchangeTimeStamp);
+ else $date = ' ';
+
+ $list[] = array( 'value'=>Text::maxLaenge( 50,$this->value->value),
+ 'date' =>$date,
+ 'user' =>User::getUserName($this->value->lastchangeUserId),
+ 'url' =>Html::url(array('action' =>'pageelement',
+ 'subaction'=>'usevalue',
+ 'valueid' =>$valueid )) );
+ }
+
+ $this->setTemplateVar('name',$this->value->element->name);
+ $this->setTemplateVar('el',$list);
+ $this->forward('pageelement_archive');
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/ProjectAction.class.php b/actionClasses/ProjectAction.class.php
@@ -0,0 +1,107 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class ProjectAction extends Action
+{
+ var $project;
+ var $defaultSubAction = 'listing';
+
+
+ function ProjectAction()
+ {
+ $this->project = new Project( $this->getSessionVar('projectid') );
+ $this->project->load();
+ }
+
+
+ function save()
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ // Gesamtes Projekt löschen
+ $this->project->delete();
+
+ $this->setTemplateVar('tree_refresh',true);
+ }
+ else
+ {
+ $this->project->name = $this->getRequestVar('name' );
+ $this->project->target_dir = $this->getRequestVar('target_dir' );
+ $this->project->ftp_url = $this->getRequestVar('ftp_url' );
+ $this->project->ftp_passive = $this->getRequestVar('ftp_passive' );
+ $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' );
+ $this->project->content_negotiation = $this->getRequestVar('content_negotiation');
+ $this->project->cut_index = $this->getRequestVar('cut_index' );
+
+ $this->project->save(); // speichern
+ }
+
+ $this->callSubAction('listing');
+ }
+
+
+ function add()
+ {
+ // Projekt hinzufuegen
+ $this->project->name = $this->getRequestVar('name');
+ $this->project->add();
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('edit');
+ }
+
+
+ function listing()
+ {
+ global $conf_php;
+
+ // Projekte ermitteln
+ $listl = array();
+
+ foreach( $this->project->getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url(array('action'=>'main','callAction'=>'project','callSubaction'=>'edit','projectid'=>$id));
+ $list[$id]['name'] = $name;
+ }
+ $this->setTemplateVar('el',$list);
+
+ $this->forward('project_list');
+ }
+
+
+ function edit()
+ {
+ // Projekt laden
+ $this->setTemplateVars( $this->project->getProperties() );
+
+ $this->forward('project_edit');
+
+ }
+}+
\ No newline at end of file
diff --git a/actionClasses/SearchAction.class.php b/actionClasses/SearchAction.class.php
@@ -0,0 +1,188 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class SearchAction extends Action
+{
+ /**
+ * Falls keine Unteraktion ausgewählt wurde wird diese genommen
+ * @type String
+ */
+ var $defaultSubAction = 'prop';
+
+
+ /**
+ * leerer Kontruktor
+ */
+ function SearchAction()
+ {
+ }
+
+
+ /**
+ * Durchführen der Suche
+ * und Anzeige der Ergebnisse
+ */
+ function search()
+ {
+ global $conf_php;
+
+ $listObjectIds = array();
+ $listTemplateIds = array();
+
+ switch( $this->getRequestVar('searchtype') )
+ {
+ case 'prop':
+
+ switch( $this->getRequestVar('type') )
+ {
+ case 'id':
+ $o = new Object();
+ if ( $o->isObjectId($this->getRequestVar('id')) )
+ $listObjectIds[] = $this->getRequestVar('id');
+ break;
+
+ case 'filename':
+ $o = new Object();
+ $listObjectIds = $o->getObjectIdsByFilename( $this->getRequestVar('filename') );
+ break;
+
+ case 'name':
+ $o = new Object();
+ $listObjectIds = $o->getObjectIdsByName( $this->getRequestVar('name') );
+ break;
+
+ case 'desc':
+ $o = new Object();
+ $listObjectIds = $o->getObjectIdsByDescription( $this->getRequestVar('desc') );
+ break;
+
+ case 'create_user':
+ $o = new Object();
+ $listObjectIds = $o->getObjectIdsByCreateUserId( $this->getRequestVar('create_userid') );
+ break;
+
+ case 'lastchange_user':
+ $o = new Object();
+ $listObjectIds = $o->getObjectIdsByLastChangeUserId( $this->getRequestVar('lastchange_userid') );
+ break;
+
+ case 'extension':
+ $f = new File();
+ $listObjectIds = $f->getObjectIdsByExtension( $this->getRequestVar('extension') );
+ break;
+ }
+
+ break;
+
+
+ case 'content':
+
+ switch( $this->getRequestVar('type') )
+ {
+ case 'value':
+ $e = new Value();
+ $listObjectIds = $e->getObjectIdsByValue( $this->getRequestVar('text') );
+
+ $template = new Template();
+ $listTemplateIds = $template->getTemplateIdsByValue( $this->getRequestVar('text') );
+ break;
+
+ case 'lastchange_user':
+ $e = new Value();
+ $listObjectIds = $e->getObjectIdsByLastChangeUserId( $this->getRequestVar('lastchange_userid') );
+ break;
+ }
+ break;
+
+
+ default:
+ // Fallback:
+ // Dialog "Suche nach Eigenschaft" anzeigen.
+ $this->callSubAction( 'prop' );
+ exit;
+ }
+
+
+
+ $resultList = array();
+
+ foreach( $listObjectIds as $objectid )
+ {
+ $o = new Object( $objectid );
+ $o->load();
+ $resultList[$objectid] = array();
+ $resultList[$objectid]['url'] = Html::url(array('action'=>'main','callAction'=>$o->getType(),'objectid'=>$objectid));
+ $resultList[$objectid]['type'] = $o->getType();
+
+ if ( !$o->isRoot )
+ {
+ $folder = new Folder( $o->parentid );
+ $folder->load();
+ $resultList[$objectid]['name'] = implode(' » ',$folder->parentObjectNames(true,true) ).' » '.$o->name;
+ }
+ else
+ {
+ $resultList[$objectid]['name'] = '» '.$o->name;
+ }
+ $resultList[$objectid]['desc'] = $o->desc;
+ }
+
+ foreach( $listTemplateIds as $templateid )
+ {
+ $t = new Template( $templateid );
+ $t->load();
+ $resultList['t'.$templateid] = array();
+ $resultList['t'.$templateid]['url' ] = Html::url(array('action'=>'main','callAction'=>'template','templateid'=>$templateid));
+ $resultList['t'.$templateid]['type'] = 'tpl';
+ $resultList['t'.$templateid]['name'] = $t->name;
+ $resultList['t'.$templateid]['desc'] = '';
+ }
+
+ $this->setTemplateVar( 'result',$resultList );
+
+ $this->forward( 'search_result' );
+ }
+
+
+ function prop()
+ {
+ $this->setTemplateVar( 'users',User::listAll() );
+ $this->forward( 'search_prop' );
+ }
+ function content()
+ {
+ $this->setTemplateVar( 'users',User::listAll() );
+ $this->forward( 'search_content' );
+ }
+ function template()
+ {
+ $this->forward( 'search_template' );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/TemplateAction.class.php b/actionClasses/TemplateAction.class.php
@@ -0,0 +1,403 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class TemplateAction extends Action
+{
+ var $defaultSubAction = 'show';
+ var $template;
+ var $element;
+
+
+ function TemplateAction()
+ {
+ $this->template = new Template( $this->getSessionVar('templateid') );
+ $this->template->load();
+
+ if ( $this->getSessionVar('elementid') != '' )
+ {
+ $this->element = new Element( $this->getSessionVar('elementid') );
+ $this->element->load();
+ }
+ }
+
+
+ function srcsave()
+ {
+ // Speichern des Quelltextes
+ //
+ $text = $this->getRequestVar('src');
+
+ // Falls dieses Element hinzugefügt werden soll
+ if ( $this->getRequestVar('addelement') != '' )
+ {
+ $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
+ }
+
+ if ( $this->getRequestVar('addicon') != '' )
+ {
+ $text .= "\n".'{{->'.$this->getRequestVar('iconid').'}}';
+ }
+
+ foreach( $this->template->getElementNames() as $elid=>$elname )
+ {
+ $text = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}',$text );
+ $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
+ }
+
+ $this->template->src = $text;
+ $this->template->save();
+ $this->template->load();
+
+ // Wenn Element hinzugefügt wurde, dann bleibt es beim Quelltext-Modus.
+ // Sonst wird zur Anzeige umgeschaltet
+
+ if ( $this->getRequestVar('addelement') != '' ||
+ $this->getRequestVar('addicon' ) != '' )
+ {
+ $this->callSubAction('src');
+ }
+ else
+ {
+ $this->callSubAction('show');
+ }
+ }
+
+
+ // Speichern der Template-Eigenschaftens
+ //
+ function propsave()
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->template->delete();
+
+ $this->callSubAction('listing');
+ }
+ else
+ {
+ $this->template->name = $this->getRequestVar('name');
+ $this->template->save();
+
+ $this->callSubAction('show');
+ }
+ }
+
+
+ // Speichern der Dateiendung
+ //
+ function extensionsave()
+ {
+ if ( $this->getRequestVar('extension') != '' )
+ {
+ $this->template->extension = $this->getRequestVar('extension');
+ $this->template->save();
+ }
+
+ $this->callSubAction('show');
+ }
+
+
+ // Element hinzufügen
+ //
+ function addelement()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $this->template->addElement( $this->getRequestVar('name') );
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('el');
+ }
+
+
+ function add()
+ {
+ // Hinzufügen eines Templates
+ if ( $this->getRequestVar('name') != '' )
+ {
+ Template::add( $this->getRequestVar('name') );
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('listing');
+ }
+
+
+ /**
+ * Umbenennen des Elementes
+ */
+ function elementrename()
+ {
+ if ($this->getRequestVar('delete') != '')
+ {
+ $this->element->delete();
+ }
+ elseif ($this->getRequestVar('deletevalues') != '')
+ {
+ $this->element->deleteValues();
+ }
+ else
+ {
+ $this->element->name = $this->getRequestVar('name');
+ $this->element->desc = $this->getRequestVar('desc');
+
+ $this->element->save();
+ $this->element->load();
+ }
+
+ $this->setTemplateVar('tree_refresh',true);
+
+ $this->callSubAction('el');
+ }
+
+
+ /**
+ * Speichern der Element-Eigenschaften
+ */
+ function elementsave()
+ {
+ $ini_date_format = parse_ini_file( CONF_LANGUAGEDIR.'/dateformat.ini.'.CONF_PHP );
+
+ foreach( $this->element->getRelatedProperties() as $propertyName )
+ {
+ switch( $propertyName )
+ {
+ case 'dateformat':
+ $this->element->dateformat = $ini_date_format[$this->getRequestVar('dateformat')];
+ break;
+
+ case 'subtype':
+ $this->element->subtype = $this->getRequestVar('subtype');
+ break;
+
+ case 'defaultText':
+ $this->element->defaultText = $this->getRequestVar('default_text');
+ break;
+
+ case 'wiki':
+ $this->element->wiki = $this->getRequestVar('wiki') != '';
+ break;
+
+ case 'html':
+ $this->element->html = $this->getRequestVar('html') != '';
+ break;
+
+ case 'withIcon':
+ $this->element->withIcon = $this->getRequestVar('with_icon') != '';
+ break;
+
+ case 'allLanguages':
+ $this->element->allLanguages = $this->getRequestVar('all_languages') != '';
+ break;
+
+ case 'writable':
+ $this->element->writable = $this->getRequestVar('writable') != '';
+ break;
+
+ case 'decimals':
+ $this->element->decimals = $this->getRequestVar('decimals');
+ break;
+
+ case 'decPoint':
+ $this->element->decPoint = $this->getRequestVar('dec_point');
+ break;
+
+ case 'thousandSep':
+ $this->element->thousandSep = $this->getRequestVar('thousand_sep');
+ break;
+
+ case 'folderObjectId':
+ $this->element->folderObjectId = $this->getRequestVar('folderobjectid' );
+ break;
+
+ case 'defaultObjectId':
+ $this->element->defaultObjectId = $this->getRequestVar('default_objectid');
+ break;
+
+ case 'code':
+ $this->element->code = $this->getRequestVar('code' );
+ break;
+ }
+ }
+ $this->element->save();
+
+ $this->callSubAction('el');
+ }
+
+
+ function prop()
+ {
+ $this->setTemplateVar('extension',$this->template->extension);
+ $this->setTemplateVar('name' ,$this->template->name );
+
+ // von diesem Template abhängige Seiten ermitteln
+ //
+ $list = array();
+ foreach( $this->template->getDependentObjectIds() as $oid )
+ {
+ $page = new Page( $oid );
+ $page->load();
+ $list[$oid] = array();
+ $list[$oid]['name'] = $page->name;
+ $list[$oid]['url' ] = Html::url(array('action'=>'main','callAction'=>'page','objectid'=>$oid));
+ }
+ $this->setTemplateVar('pages',$list );
+
+ $this->forward('template_prop');
+ }
+
+
+ // Bearbeiten
+ //
+ function show()
+ {
+ global $conf_php;
+
+ $text = htmlentities( $this->template->src );
+ $text = str_replace("\n",'<br>',$text);
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $text = str_replace('{{'.$elid.'}}',
+ '<a href="do.'.$conf_php.'?action=element&subaction=edit'.
+ '&elementid='.$elid.
+ '" class="el_'.
+ $element->type.'" target="cms_main_main" title="'.$element->desc.'">{{'.
+ $element->name.'}}</a>',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '<a href="do.'.$conf_php.'?action=element&subaction=edit'.
+ '&elementid='.$elid.
+ '" class="el_'.
+ $element->type.'" target="cms_main_main" title="'.$element->desc.'">{{->'.
+ $element->name.'}}</a>',
+ $text );
+
+ unset( $element );
+ }
+
+ $this->setTemplateVar('text',$text);
+
+ $this->forward('template_show');
+ }
+
+
+ // 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' ] = 'do.'.$conf_php.'?action=element&subaction=edit&elementid='.$elid;
+ $list[$elid]['name'] = $element->name;
+ $list[$elid]['desc'] = $element->desc;
+ $list[$elid]['type'] = $element->type;
+
+ unset( $element );
+ }
+ $this->setTemplateVar('el',$list);
+ $this->forward('template_el');
+ }
+
+
+ // Anzeigen des Template-Quellcodes
+ //
+ function src()
+ {
+ $elements = array();
+ $icon_elements = array();
+ $text = $this->template->src;
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $elements[$elid] = $element->name;
+
+ $element = new Element( $elid );
+ $element->load();
+
+ if ( $element->type != 'info' &&
+ $element->type != 'infodate' &&
+ $element->type != 'code' )
+ $icon_elements[$elid] = lang('icon').' '.$element->name;
+
+ $text = str_replace('{{'.$elid.'}}',
+ '{{'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '{{->'.$element->name.'}}',
+ $text );
+ }
+
+ $this->setTemplateVar('elements' ,$elements );
+ $this->setTemplateVar('icon_elements',$icon_elements );
+ $this->setTemplateVar('text' ,htmlentities($text));
+
+ $this->forward('template_src');
+ }
+
+
+ // 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(array('action'=>'main','callAction'=>'template','templateid'=>$id));
+ }
+
+// $var['templatemodelid'] = htmlentities( $id );
+// $var['text'] = htmlentities( $text );
+ $this->setTemplateVar('templates',$list);
+
+ $this->forward('template_list');
+
+ }
+
+}+
\ No newline at end of file
diff --git a/actionClasses/TitleAction.class.php b/actionClasses/TitleAction.class.php
@@ -0,0 +1,74 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Actionklasse zum Anzeigen der Titelleiste
+ * @author $Author$
+ * @version $Rev: $
+ */
+class TitleAction extends Action
+{
+ /**
+ * Standard-Subaction
+ * @type String
+ */
+ var $defaultSubAction = 'show';
+
+
+ /**
+ * Fuellen der Variablen und Anzeigen der Titelleiste
+ */
+ function show()
+ {
+ global $SESS,$conf;
+
+ $this->setTemplateVar('css_body_class','title');
+
+ if ( $this->getSessionVar('dbid') != '' )
+ {
+ $this->setTemplateVar('dbid' ,$this->getSessionVar('dbid') );
+ $this->setTemplateVar('dbname',$conf['database_'.$this->getSessionVar('dbid')]['comment'] );
+ }
+
+ if ( isset($SESS['user']) )
+ {
+ $this->setTemplateVar('username' ,$SESS['user']['name'] );
+ $this->setTemplateVar('userfullname',$SESS['user']['fullname']);
+ }
+
+ // Urls zum Benutzerprofil und zum Abmelden
+ $this->setTemplateVar('profile_url',Html::url( array('action' =>'user',
+ 'subaction'=>'profile' ) ));
+ $this->setTemplateVar('logout_url' ,Html::url( array('action' =>'index',
+ 'subaction'=>'logout' ) ));
+
+ $this->forward( 'title' );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/TransferAction.class.php b/actionClasses/TransferAction.class.php
@@ -0,0 +1,230 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+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->message('ERROR',"'$folderName' is not a directory or not readable");
+ }
+ else
+ {
+ $fileLog = "starting import ...\n";
+ $fileLog = "reading directory '$folderName'\n";
+ while( $filename = readdir($dir) )
+ {
+ $full_filename = $folderName.'/'.$filename;
+
+ if ( $filename != "." &&
+ $filename != ".." &&
+ is_file($full_filename) )
+ {
+ $fileLog .= "importing file '$full_filename'\n";
+
+ $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 = addslashes( fread($f,filesize($full_filename)) );
+ fclose( $f );
+
+ $file->add();
+
+ unset( $file );
+ }
+ }
+ closedir( $dir );
+ $fileLog .= "... import finished\n";
+
+ $this->setTemplateVar( 'fileLog',$fileLog );
+ }
+ }
+
+ $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_import' );
+ }
+
+
+// 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
@@ -0,0 +1,616 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// Revision 1.1 2003/09/29 18:19:48 dankert
+// erste Version
+//
+// ---------------------------------------------------------------------------
+
+
+class TreeAction extends Action
+{
+ var $defaultSubAction = 'reload';
+
+
+ function open()
+ {
+ global $SESS;
+ array_push($SESS['tree_open'][$this->getSessionVar('projectid')],$this->getRequestVar('open'));
+
+ $this->callSubAction('show');
+ }
+
+
+ function close()
+ {
+ global $SESS;
+ $key = array_search( $this->getRequestVar('close'),$SESS['tree_open'][$this->getSessionVar('projectid')] );
+ if ( !is_null($key) && $key!==false )
+ unset( $SESS['tree_open'][$this->getSessionVar('projectid')][$key] );
+
+ $this->callSubAction('show');
+ }
+
+
+ function reload()
+ {
+ // Hinzufügen eines Ordners incl. Unterelemente zur Projektstruktur
+ function add_folder( $objectid )
+ {
+ global
+ $SESS,
+ $projectid;
+
+ $f = new Folder( $objectid );
+ $t = time();
+
+ foreach( $f->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+
+ // Wenn keine Leseberechtigung
+ if ( !$o->hasRight('read') )
+ continue;
+
+ $o->load();
+
+ if ( $o->isFolder )
+ {
+ $SESS['tree']['o'.$id] = array('text' => Text::maxLaenge( 25,$o->name ),
+ 'desc' => lang('FOLDER').' '.$id.' '.$o->desc,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'folder',
+ 'objectid' =>$id )),
+ 'icon' => 'folder',
+ 'parent' => "o$objectid",
+ 'target' => 'cms_main' );
+ add_folder( $id );
+ }
+ if ( $o->isPage )
+ {
+ $SESS['tree']['o'.$id] = array('text' => Text::maxLaenge( 25,$o->name ),
+ 'desc' => lang('PAGE').' '.$id.' '.$o->desc,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'page',
+ 'objectid' =>$id )),
+ 'icon' => 'page',
+ 'parent' => "o$objectid",
+ 'target' => 'cms_main' );
+
+ // Nur wenn die Seite beschreibbar ist, werden die
+ // Elemente im Baum angezeigt
+ if ( $o->hasRight('write') )
+ add_page_elements( $id );
+ }
+ if ( $o->isFile )
+ {
+ $file = new File( $id );
+ $file->load();
+ if ( substr($file->mimeType(),0,6) == 'image/' )
+ $icon = 'image';
+ else $icon = 'file';
+
+ $SESS['tree']['o'.$id] = array('text' => Text::maxLaenge( 25,$o->name ),
+ 'desc' => lang('FILE').' '.$id.' '.$o->desc,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'file',
+ 'objectid' =>$id )),
+ 'icon' => $icon,
+ 'parent' => "o$objectid",
+ 'target' => 'cms_main' );
+ }
+ if ( $o->isLink )
+ {
+ $SESS['tree']['o'.$id] = array('text' => Text::maxLaenge( 25,$o->name ),
+ 'desc' => lang('LINK').' '.$id.' '.$o->desc,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'link',
+ 'objectid' =>$id )),
+ 'icon' => 'link',
+ 'parent' => "o$objectid",
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+
+
+
+ function add_page_elements( $objectid )
+ {
+ global $SESS,$conf_php,$t_element;
+
+ $page = new Page( $objectid );
+ $page->load();
+
+ $template = new Template( $page->templateid );
+
+ foreach( $template->getElementIds() as $elementid )
+ {
+ $element = new Element( $elementid );
+ $element->load();
+
+ if ( $element->isWritable() )
+ {
+ $SESS['tree']['o'.$objectid.'el'.$elementid ] = array('text' => $element->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'pageelement',
+ 'callSubaction' =>'edit',
+ 'objectid' =>$objectid,
+ 'elementid' =>$elementid )),
+ 'icon' => 'el_'.$element->type,
+ 'desc' => Text::maxLaenge( 25,$element->desc ),
+ 'parent' => "o$objectid",
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+ global $SESS;
+ $projectid = $this->getSessionVar('projectid');
+
+ if ( $this->getRequestVar('projectid') != '' )
+ {
+ // Beim Laden eines neuen Projektes die bisherigen
+ // Sprach- und Projektmodelleinstellungen entfernen
+ unset( $SESS['modelid'] );
+ unset( $SESS['languageid' ] );
+ }
+
+ if (!isset($SESS['tree_open']))
+ $SESS['tree_open'] = array();
+
+ if ( !isset($SESS['tree_open'][$projectid]) )
+ $SESS['tree_open'][$projectid] = array();
+
+
+ // Erzeugen des Menue-Baums
+ //
+ language_read(); // TODO Beim 1. stable-Release entfernen!
+
+ $SESS['tree'] = array();
+
+ if ( $projectid == 0 )
+ {
+ }
+ elseif ( $projectid == -1 )
+ {
+ // Administration wurde ausgewählt!
+
+ $SESS['tree']['projects'] = array('text' => lang('PROJECTS'),
+ 'url' => Html::url(array('action'=>'main','callAction'=>'project','projectid'=>'0')),
+ 'icon' => 'project_list',
+ 'desc' => '',
+ 'target'=> 'cms_main' );
+
+ // Schleife über alle Projekte
+ foreach( Project::getAll() as $id=>$name )
+ {
+ $SESS['tree']['prj'.$id] = array('text' => $name,
+ 'parent'=> 'projects',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'project',
+ 'callSubaction'=>'edit',
+ 'projectid' =>$id )),
+ 'icon' => 'project',
+ 'desc' => '',
+ 'target'=> 'cms_main' );
+ }
+
+ $SESS['tree']['usergroups'] = array('text' => lang('USER_AND_GROUPS'),
+ 'desc' => '',
+ 'icon' => 'group' );
+
+ $SESS['tree']['user'] = array('text' => lang('USER'),
+ 'parent'=> 'usergroups',
+ 'desc' => '',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'user',
+ 'userid' =>'0',
+ 'callSubaction'=>'listing' )),
+ 'icon' => 'user',
+ 'target'=> 'cms_main' );
+
+ foreach( User::listAll() as $id=>$name )
+ {
+ $u = new User( $id );
+ $u->load();
+ $SESS['tree']['user'.$id] = array('text' => $u->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'user',
+ 'callSubaction'=>'edit',
+ 'userid' =>$id )),
+ 'icon' => 'user',
+ 'desc' => $u->fullname,
+ 'parent' => "user",
+ 'target' => 'cms_main' );
+ }
+
+ $SESS['tree']['group'] = array('text' => lang('GROUPS'),
+ 'parent'=> 'usergroups',
+ 'desc' => '',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'group',
+ 'callSubaction'=>'listing',
+ 'groupid' =>'0' )),
+ 'icon' => 'group',
+ 'target'=> 'cms_main' );
+
+ foreach( Group::getAll() as $id=>$name )
+ {
+ $g = new Group( $id );
+ $g->load();
+ $SESS['tree']['group'.$id] = array('text' => $g->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'group',
+ 'groupid' =>$id )),
+ 'icon' => 'group',
+ 'desc' => lang('GROUP').' '.$g->name,
+ 'parent' => "group",
+ 'target' => 'cms_main' );
+
+ foreach( $g->getUsers() as $id=>$name )
+ {
+ $u = new User( $id );
+ $u->load();
+ $SESS['tree']['groupuser'.$id] = array('text' => $u->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'user',
+ 'userid' =>$id )),
+ 'icon' => 'user',
+ 'desc' => $u->fullname,
+ 'parent' => 'group'.$g->groupid,
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+ else
+ {
+ // Projektstruktur
+ // --------------------------------------------------
+
+ if ( !isset($SESS['languageid']) || intval($SESS['languageid']) == 0 )
+ // Ermitteln Default-Sprache
+ $SESS['languageid'] = Language::getDefaultId();
+
+ // Ermitteln Default-Projektmodell
+ if ( !isset($SESS['modelid']) || intval($SESS['modelid']) == 0 )
+ $SESS['modelid'] = Model::getDefaultId();
+
+
+ // Den Highlander-Ordner lesen (es kann nur einen geben)
+
+
+ $f = new Folder();
+ $f->projectid = $projectid;
+ $folder = new Folder( $f->getRootObjectId() );
+ unset( $f );
+ $folder->load();
+ if ( $folder->hasRight('read') )
+ {
+ $SESS['tree']['o'.$folder->objectid ] = array('text' => $folder->name,
+ 'desc' => $folder->desc,
+ 'icon' => 'folder',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'folder',
+ 'objectid' =>$folder->objectid )),
+ 'target' => 'cms_main' );
+ add_folder( $folder->objectid );
+ }
+
+
+
+ // Templates anzeigen
+ //
+ if ( $SESS['user']['is_admin'] == '1' )
+ {
+ $SESS['tree']['tpl'] = array('text' => lang('TEMPLATES'),
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'template',
+ 'callSubaction'=>'listing',
+ 'templateid' =>'0' )),
+ 'desc' => '',
+ 'icon' => 'tpl_list',
+ 'target' => 'cms_main' );
+ foreach( Template::getAll() as $id=>$name )
+ {
+ $t = new Template( $id );
+ $t->load();
+ $SESS['tree']['tpl'.$id ] = array('text' => $t->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'template',
+ 'templateid' =>$id )),
+ 'parent' => "tpl",
+ 'icon' => 'tpl',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+ // Anzeigen der Template-Elemente
+ //
+ foreach( $t->getElementIds() as $elementid )
+ {
+ $e = new Element( $elementid );
+ $e->load();
+ $SESS['tree']['tpl'.$id.'el'.$elementid] = array('text' => $e->name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'element',
+ 'callSubaction'=>'edit',
+ 'templateid'=>$id,
+ 'elementid' =>$elementid )),
+ 'icon' => 'el_'.$e->type,
+ 'desc' => '',
+ 'parent' => 'tpl'.$id,
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+
+
+ // Sprachvarianten
+ //
+ $l = new Language();
+ $l->projectid = $projectid;
+ $languages = $l->getAll();
+
+ if ( $this->userIsAdmin() || count($languages) > 1 )
+ {
+ $SESS['tree']['lang'] = array('text' => lang('LANGUAGES'),
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'language',
+ 'callSubaction'=>'listing' )),
+ 'icon' => 'lang_list',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+
+ if ( $this->userIsAdmin() )
+ {
+ foreach( $languages as $languageid=>$name )
+ {
+ $SESS['tree']['lang'.$languageid] = array('text' => $name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'language',
+ 'callSubaction'=>'edit',
+ 'languageid' =>$languageid )),
+ 'parent' => 'lang',
+ 'icon' => 'lang',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+
+
+ // Projektvarianten
+ //
+ $m = new Model();
+ $m->projectid = $projectid;
+
+ $models = $m->getAll();
+
+ if ( $this->userIsAdmin() || count($models) > 1 )
+ {
+ $SESS['tree']['pvar'] = array('text'=> lang('MODELS'),
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'model',
+ 'callSubaction'=>'listing')),
+ 'icon' => 'model_list',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+
+ if ( $this->userIsAdmin() )
+ {
+ foreach( $models as $id=>$name )
+ {
+ $SESS['tree']['pvar'.$id] = array('text' => $name,
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'model',
+ 'callSubaction'=>'edit',
+ 'modelid' =>$id )),
+ 'parent' => "pvar",
+ 'icon' => 'model',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+ }
+ }
+ }
+
+ $SESS['tree']['other'] = array('text' => lang('OTHER'),
+ 'desc' => '',
+ 'icon' => 'other' );
+
+ if ( $SESS['user']['is_admin'] )
+ {
+ $SESS['tree']['transfer'] = array('text' => lang('FILE_TRANSFER'),
+ 'parent'=> 'other',
+ 'desc' => '',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'transfer')),
+ 'icon' => 'transfer',
+ 'target'=> 'cms_main' );
+ }
+
+ $SESS['tree']['search'] = array('text' => lang('SEARCH'),
+ 'parent'=> 'other',
+ 'url' => Html::url(array('action' =>'main',
+ 'callAction' =>'search' )),
+ 'icon' => 'search',
+ 'desc' => '',
+ 'target' => 'cms_main' );
+ }
+
+
+ // Zu jedem Baumelement werden die Kinder ermittelt
+ // Ziel: Performancesteigerung, schnellere Baumanzeige.
+
+ // Wir benötigen eine Kopie von $SESS['tree'], weil innerhalb einer foreach()-Schleife
+ // nicht das gleiche Array nochmal mit foreach() durchlaufen werden kann.
+ $SESS['tree_kopie'] = $SESS['tree'];
+
+ foreach( $SESS['tree'] as $idx=>$inh )
+ {
+ $SESS['tree'][$idx]['children'] = array();
+
+ foreach( $SESS['tree_kopie'] as $name=>$val )
+ {
+ if ( isset($val['parent']) && $val['parent'] == $idx )
+ {
+ $SESS['tree'][$idx]['children'][] = $name;
+ }
+ }
+ }
+ unset( $SESS['tree_kopie'] );
+
+ //print_r( $SESS['tree'] ); // Debug
+
+
+
+ // Ausgabe des Templates
+ //
+ $this->callSubAction('show');
+ }
+
+
+ function tree_show_element( $name,&$var )
+ {
+ global $SESS,$tree_tiefe,$tree_last,$PHP_SELF;
+
+ $open = $SESS['tree_open'][ $SESS['projectid'] ];
+ $zeile = array();
+
+ $el = $SESS['tree'][ $name ];
+
+ $children = $el['children'];
+
+ if ( !isset($tree_last) )
+ $tree_last=array();
+
+ $zeile['cols'] = array();
+
+ for ($i=1; $i<=$tree_tiefe; $i++)
+ {
+ if ($tree_last[$i-1] == 1 )
+ $zeile['cols'][] = 'blank';
+ else $zeile['cols'][] = 'line';
+ }
+
+ if ( count($children) > 0 )
+ {
+ if ( !in_array($name,$open) )
+ {
+ if ($tree_last[$i-1] == 1 )
+ $zeile['image'] = 'plus_end';
+ else $zeile['image'] = 'plus';
+ $zeile['image_url'] = Html::url(array('action'=>'tree','subaction'=>'open','open'=>$name));
+ }
+ else
+ {
+ if ($tree_last[$i-1] == 1 )
+ $zeile['image'] = 'minus_end';
+ else $zeile['image'] = 'minus';
+ $zeile['image_url'] = Html::url(array('action'=>'tree','subaction'=>'close','close'=>$name));
+ }
+ }
+ else
+ {
+ if ($tree_last[$i-1] == 1 )
+ $zeile['image'] = 'none_end';
+ else $zeile['image'] = 'none';
+ }
+
+
+ if (isset($el['icon'])) $zeile['icon'] = $el['icon'];
+
+ $zeile['text'] = $el['text'];
+ $zeile['name'] = $name;
+ $zeile['desc'] = $el['desc'];
+
+ if ( isset($el['url']) )
+ {
+ $zeile['url'] = $el['url' ];
+ //$zeile['add'] = $el['add'];
+
+ if ( isset($el['target']) )
+ $zeile['target'] = $el['target'];
+ else $zeile['target'] = 'cms_main';
+
+ }
+
+ $var['zeilen'][] = $zeile;
+
+ if ( in_array($name,$open) )
+ {
+ $nr = 0;
+ $tree_tiefe++;
+ foreach( $children as $id )
+ {
+ $nr++;
+
+ if ( $nr == count( $children ) )
+ $tree_last[$tree_tiefe]=1;
+ else $tree_last[$tree_tiefe]=0;
+
+ $this->tree_show_element( $id,&$var );
+ }
+ $tree_tiefe--;
+ }
+ }
+
+
+ /**
+ * Anzeigen des Baumes
+ */
+ function show()
+ {
+ global $tree_tiefe,$SESS,$tree_last,$var;
+
+ $tree_tiefe = 0;
+
+ // Unterpunkte ermitteln
+ $children = array();
+ foreach( $SESS['tree'] as $id=>$el )
+ {
+ if ( !isset($el['parent']) )
+ {
+ $children[] = $id;
+ }
+ }
+
+ $anz=0;
+ $var['zeilen']=array();
+
+ foreach( $children as $child )
+ {
+
+ $anz++;
+ if ( $anz == count($children) )
+ $tree_last[$tree_tiefe]=1;
+ else $tree_last[$tree_tiefe]=0;
+
+ $this->tree_show_element( $child,&$var );
+ }
+
+ $this->setTemplateVars( $var );
+ $this->forward('tree');
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/TreemenuAction.class.php b/actionClasses/TreemenuAction.class.php
@@ -0,0 +1,87 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class TreemenuAction extends Action
+{
+ var $defaultSubAction = 'show';
+
+
+ function show()
+ {
+ global $SESS;
+ $this->setTemplateVar('css_body_class','menu');
+
+ $projects = array();
+
+ if (isset($SESS['user']))
+ {
+ // Lesen der verfügbaren Projekte
+ $projekte = Project::getAll();
+
+ $projects[0] = lang('SELECT');
+
+ // Unterscheidung Administrator/Benutzer
+ if ( $SESS['user']['is_admin'] == '1' )
+ {
+ // Administrator sieht Administrationsbereich
+ $projects[-1] = lang('ADMINISTRATION');
+
+ // Administrator sieht alle Projekte
+ foreach( $projekte as $projectid=>$name )
+ {
+ $projects[$projectid] = $name;
+ }
+ }
+ else
+ {
+ // Bereitstellen der Projekte, für die der Benutzer berechtigt ist
+ foreach( $projekte as $projectid=>$projectname )
+ {
+ $project = new Project( $projectid );
+
+ $rootObject = new Object( $project->getRootObjectId() );
+ $rootObject->load();
+
+ if ( $rootObject->hasRight('read') )
+ $projects[$projectid] = $projectname;
+ }
+ }
+ $this->setTemplateVar( 'act_projectid',intval($this->getSessionVar('projectid')) );
+ }
+ $this->setTemplateVar('projects',$projects);
+
+ $this->setTemplateVar('reload_url' ,Html::url( array('action' =>'tree',
+ 'subaction'=>'reload',
+ ) ));
+
+ // Ausgabe des Templates
+ $this->forward('tree_menu');
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/actionClasses/UserAction.class.php b/actionClasses/UserAction.class.php
@@ -0,0 +1,287 @@
+<?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.1 2004-04-24 15:14:52 dankert
+// Initiale Version
+//
+// Revision 1.2 2003/10/02 20:56:17 dankert
+// Benutzer entfernen
+//
+// Revision 1.1 2003/09/29 18:18:21 dankert
+// erste Version
+//
+// ---------------------------------------------------------------------------
+
+
+class UserAction extends Action
+{
+ var $user;
+ var $defaultSubAction = 'edit';
+
+ function UserAction()
+ {
+ $this->user = new User( $this->getSessionVar('userid') );
+ $this->user->load();
+ }
+
+
+ function save()
+ {
+ global $REQ;
+
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->user->delete();
+ $this->callSubAction('listing');
+ }
+ else
+ {
+ // Benutzer speichern
+ $this->user->name = $REQ['name'];
+ $this->user->fullname = $REQ['fullname'];
+ $this->user->isAdmin = isset($REQ['is_admin']);
+ $this->user->ldap_dn = $REQ['ldap_dn'];
+ $this->user->tel = $REQ['tel'];
+ $this->user->desc = $REQ['desc'];
+ $this->user->mail = $REQ['mail'];
+ $this->user->style = $REQ['style'];
+ $this->user->save();
+ }
+
+ $this->callSubAction('edit');
+ }
+
+
+ /**
+ * Abspeichern des Profiles
+ */
+ function saveProfile()
+ {
+ global $SESS;
+ $this->user = new User( $SESS['user']['id'] );
+ $this->user->load();
+
+ $this->user->fullname = $this->getRequestVar('fullname');
+ $this->user->tel = $this->getRequestVar('tel' );
+ $this->user->desc = $this->getRequestVar('desc' );
+ $this->user->mail = $this->getRequestVar('mail' );
+ $this->user->style = $this->getRequestVar('style' );
+ $this->user->save();
+
+ $this->user->setCurrent();
+
+ $this->callSubAction('profile');
+ }
+
+
+ function add()
+ {
+
+ $this->user->add( $this->getRequestVar('name') );
+ $this->setSessionVar('userid',$this->user->userid);
+
+ $this->callSubAction('edit');
+ }
+
+
+ function addgroup()
+ {
+ $this->user->addGroup( $this->getRequestVar('groupid') );
+
+ $this->callSubAction('groups');
+ }
+
+
+ function delgroup()
+ {
+
+ $this->user->delGroup( $this->getRequestVar('groupid') );
+
+ $this->callSubAction('groups');
+ }
+
+
+ function pwchange()
+ {
+ global $SESS;
+
+ if ($this->getRequestVar('password1') != '' && $this->getRequestVar('password1') == $this->getRequestVar('password2'))
+ {
+ if ($SESS['user']['is_admin'] != '1')
+ {
+ $ok = $this->user->checkPassword( $this->getRequestVar('act_password') );
+
+ if ( $ok )
+ {
+ $this->user->setPassword( $this->getRequestVar('password1') );
+ }
+ else
+ {
+ message('ERROR_USER_PW','old password not accepted');
+ }
+ }
+ else
+ {
+ $this->user->setPassword( $this->getRequestVar('password1') );
+ }
+ }
+ else
+ {
+ message('ERROR_USER_PW','passwords not equal or blank');
+ }
+
+ $this->callSubAction('edit');
+ }
+
+ function delright()
+ {
+ if ($SESS['user']['is_admin'] != '1') die('weah');
+
+ $user->delRight( $this->getRequestVar('aclid') );
+
+ // Berechtigungen anzeigen
+ $this->callSubAction('rights');
+ }
+
+
+ function addright()
+ {
+ global $REQ;
+ if ($SESS['user']['is_admin'] != '1') die('go away hacker');
+
+ $user->addRight( $REQ );
+
+ // Berechtigungen anzeigen
+ $this->callSubAction('rights');
+ }
+
+
+ function listing()
+ {
+ global $conf_php;
+
+ $list = array();
+
+ foreach( $this->user->listAll() as $userid=>$name )
+ {
+ $list[$userid] = array();
+ $list[$userid]['url' ] = Html::url(array('action'=>'main','callAction'=>'user','callSubaction'=>'edit','userid'=>$userid));
+ $list[$userid]['name'] = $name;
+ }
+ $this->setTemplateVar('el',$list);
+
+ $this->forward('user_list');
+ }
+
+
+ function profile()
+ {
+ global $SESS;
+
+ $this->user = new User( $SESS['user']['id'] );
+ $this->user->load();
+
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $this->setTemplateVar( 'allstyles',$this->getStyles() );
+
+ $this->forward( 'user_profile' );
+ }
+
+
+ /**
+ * Eigenschaften des Benutzers anzeigen
+ */
+ function edit()
+ {
+ global $SESS;
+
+ if ( !$SESS['user']['is_admin'] ) exit();
+
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $this->setTemplateVar( 'allstyles',$this->getStyles() );
+
+ $this->forward( 'user_edit' );
+ }
+
+
+ function groups()
+ {
+
+ // Alle hinzufügbaren Gruppen ermitteln
+ $this->setTemplateVar('groups',$this->user->getOtherGroups());
+
+ // Mitgliedschaften
+ $this->setTemplateVar('memberships',$this->user->getGroups());
+
+ $this->forward('user_groups');
+ }
+
+
+ /**
+ * Ändern des Kennwortes
+ */
+ function pw()
+ {
+ $this->forward('user_pw');
+ }
+
+
+ /**
+ * Anzeigen der Benutzerrechte
+ */
+ function rights()
+ {
+ if ($SESS['user']['is_admin'] != '1')
+ die('nice try');
+
+ $var['projects'] = $user->getRights();
+
+ $var['action_url'] = 'user.'.$conf_php;
+
+ $this->forward('user_rights');
+ }
+
+
+ /**
+ * Ermitteln aller zur Verfügung stehenden Stylesheets
+ */
+ function getStyles()
+ {
+ global $conf_themedir;
+ $allstyles = array();
+ $handle=opendir( $conf_themedir.'/css' );
+
+ while ($file = readdir ($handle))
+ {
+ if ( eregi('\.css$',$file) )
+ {
+ $file = eregi_replace('\.css$','',$file);
+ $allstyles[$file] = $file;
+ }
+ }
+ closedir($handle);
+
+ return $allstyles;
+ }
+}+
\ No newline at end of file
diff --git a/db/.htaccess b/db/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/db/db.class.php b/db/db.class.php
@@ -0,0 +1,252 @@
+<?php
+//
+// +----------------------------------------------------------------------+
+// | PHP version 4.0 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2001 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available at through the world-wide-web at |
+// | http://www.php.net/license/2_02.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Bakken <ssb@fast.no> |
+// | Jan Dankert <phpdb@jandankert.de> |
+// +----------------------------------------------------------------------+
+//
+
+
+// This is the database abstraction layer. This class was inspired by the
+// great PHP-Pear-DB package. Thanks to its developers.
+
+
+// Column data indexed by numbers, ordered from 0 and up
+define('DB_FETCHMODE_ORDERED', 1);
+
+// Column data indexed by column names
+define('DB_FETCHMODE_ASSOC' , 2);
+
+// Column data as object properties
+define('DB_FETCHMODE_OBJECT' , 3);
+
+
+
+class DB
+{
+ var $isError = false;
+ var $error = '';
+ var $dbh;
+ var $fetchmode = DB_FETCHMODE_ORDERED;
+
+
+ function DB( $conf = array() )
+ {
+ $this->connect( $conf );
+ }
+
+
+ function setFetchMode( $fetchmode )
+ {
+ $this->fetchmode = $fetchmode;
+ }
+
+
+ function connect( $conf )
+ {
+ $type = $conf['type'];
+ require_once('./db/'.$type.'.class.php' );
+
+ $classname = 'db_'.$type;
+
+ $this->dbh = & new $classname;
+
+ $this->dbh->connect( $conf );
+
+ if ( $this->dbh->isError )
+ return false;
+
+ return true;
+ }
+
+
+ function isError( $value )
+ {
+ return $this->isError;
+ }
+
+
+ function nextId( $sequenceName )
+ {
+ return $this->dbh->nextId( $sequenceName );
+ }
+
+
+ function query( $query )
+ {
+
+ $result = $this->dbh->simpleQuery($query);
+
+ return new DB_result( $this->dbh,$result );
+ }
+
+
+ function affectedRows()
+ {
+ return $this->dbh->affectedRows( $query );
+ }
+
+
+ function &getOne( $query )
+ {
+ $res = $this->query($query);
+
+ $err = $res->fetchInto( &$row, DB_FETCHMODE_ORDERED );
+ $res->free();
+
+ return $row[0];
+ }
+
+
+ function &getRow( $query )
+ {
+ $res = $this->query($query);
+
+ $err = $res->fetchInto($row);
+
+ $res->free();
+
+ return $row;
+ }
+
+
+ function &getCol( $query, $col=0 )
+ {
+ $res = $this->query( $query );
+
+ if ( is_integer( $col ) )
+ $fetchmode = DB_FETCHMODE_ORDERED;
+ else $fetchmode = DB_FETCHMODE_ASSOC;
+
+ $ret = array();
+
+ while( is_array($row = $res->fetchRow($fetchmode)) )
+ {
+ $ret[] = $row[$col];
+ }
+
+ $res->free();
+
+ return $ret;
+ }
+
+
+ function &getAssoc( $query, $force_array = false )
+ {
+ $res = $this->query($query);
+
+ $cols = $res->numCols();
+
+ $results = array();
+
+ if ( $cols > 2 || $force_array )
+ {
+ while( is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED)) )
+ {
+ reset($row);
+ $results[ $row[0] ] = array_slice($row, 1);
+ }
+ }
+ else
+ {
+ while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED)))
+ {
+ $results[$row[0]] = $row[1];
+ }
+ }
+
+ $res->free();
+
+ return $results;
+ }
+
+ function &getAll($query, $fetchmode = DB_FETCHMODE_DEFAULT )
+ {
+
+ $fetchmode = (empty($fetchmode)) ? DB_FETCHMODE_DEFAULT : $fetchmode;
+
+ $res = $this->query( $query );
+
+ $results = array();
+
+ while( $row = $res->fetchRow( $fetchmode) )
+ {
+ $results[] = $row;
+ }
+
+ $res->free();
+
+ return $results;
+ }
+}
+
+
+
+
+class DB_result
+{
+ var $dbh;
+ var $result;
+
+
+ function DB_result( $dbh, $result )
+ {
+ $this->dbh = $dbh;
+ $this->result = $result;
+ }
+
+
+ function fetchRow( $fetchmode = null, $rownum = null )
+ {
+ $arr = $this->dbh->fetchRow( $this->result, $fetchmode, $rownum );
+
+ return $arr;
+ }
+
+
+ function fetchInto( &$arr, $fetchmode = null, $rownum=null )
+ {
+ $arr = $this->fetchRow( $fetchmode, $rownum );
+
+ return true;
+ }
+
+
+ function numCols()
+ {
+ return $this->dbh->numCols($this->result);
+ }
+
+
+ function numRows()
+ {
+ $rows = $this->dbh->numRows( $this->result );
+
+ if ( $this->dbh->isError )
+ echo "Fehler";
+
+ return $rows;
+ }
+
+
+ function free()
+ {
+ $err = $this->dbh->freeResult($this->result);
+ return true;
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/db/mysql.class.php b/db/mysql.class.php
@@ -0,0 +1,171 @@
+<?php
+
+//
+// +----------------------------------------------------------------------+
+// | PHP version 4.0 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2001 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available at through the world-wide-web at |
+// | http://www.php.net/license/2_02.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Bakken <ssb@fast.no> |
+// | Jan Dankert <phpdb@jandankert.de> |
+// +----------------------------------------------------------------------+
+//
+
+class DB_mysql
+{
+ var $connection;
+ var $autocommit = true;
+ var $fetchmode = DB_FETCHMODE_ORDERED; /* Default fetch mode */
+ var $isError = false;
+
+ function connect( $conf )
+ {
+ $host = $conf['host'];
+ $user = $conf['user'];
+ $pw = $conf['password'];
+ $db = $conf['database'];
+
+ if ( $conf['persistent'] )
+ $connect_function = 'mysql_pconnect';
+ else $connect_function = 'mysql_connect';
+
+ if ( $pw != '' )
+ $this->connection = $connect_function( $host,$user,$pw );
+ elseif ( $user != '' )
+ $this->connection = $connect_function( $host,$user );
+ elseif ( $host != '' )
+ $this->connection = $connect_function( $host );
+ else
+ $this->connection = $connect_function();
+
+ if ( $db != '' )
+ {
+ if ( !mysql_select_db( $db,$this->connection ) )
+ die( "cannot select database '$db'. Check rights." );
+ }
+
+ return true;
+ }
+
+
+
+// function nextId( $sequenceName )
+// {
+// $res = mysql_query("SELECT id FROM `$sequenceName`",$this->connection );
+// if ( mysql_errno($this->connection) != 0 )
+// die( mysql_error($this->connection) );
+//
+// $nextId = intval( mysql_result($res,0,0) ) + 1;
+//
+// mysql_query("UPDATE `$sequenceName` SET id=".$nextId,$this->connection );
+// if ( mysql_errno($this->connection) != 0 )
+// die( mysql_error($this->connection) );
+//
+// return $nextId;
+// }
+//
+//
+//
+ function disconnect()
+ {
+ $ret = mysql_close( $this->connection );
+ $this->connection = null;
+ return $ret;
+ }
+
+
+
+ function simpleQuery($query)
+ {
+ $result = mysql_query($query, $this->connection);
+
+ if ( ! $result )
+ {
+ die( '<pre>'.$query."\n".'<span style="color:red;">'.mysql_error().'</span></pre>' );
+ }
+
+ return $result;;
+ }
+
+
+ function affectedRows()
+ {
+ return mysql_affected_rows();
+ }
+
+
+ function fetchRow( $result, $fetchmode, $rownum )
+ {
+ if ( $rownum !== null )
+ {
+ if ( ! @mysql_data_seek($result, $rownum) )
+ {
+ return null;
+ }
+ }
+
+ if ( $fetchmode == DB_FETCHMODE_ORDERED )
+ {
+ $arr = @mysql_fetch_row( $result );
+ }
+ else
+ {
+ $arr = @mysql_fetch_array( $result,MYSQL_ASSOC );
+ }
+
+ if ( ! $arr )
+ {
+ $this->isError = true;
+ }
+
+ return $arr;
+ }
+
+
+ function freeResult($result)
+ {
+ if (is_resource($result))
+ {
+ return mysql_free_result($result);
+ }
+ return true;
+ }
+
+
+ function numCols($result)
+ {
+ $cols = mysql_num_fields( $result );
+
+ if ( ! $cols )
+ {
+ return $this->mysqlRaiseError();
+ }
+
+ return $cols;
+ }
+
+
+
+ function numRows( $result )
+ {
+ //echo "yo";
+ //print_r($result);
+ $rows = mysql_num_rows($result);
+
+ if ($rows === null )
+ {
+ $this->isError = true;
+ }
+ return $rows;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/db/postgresql.class.php b/db/postgresql.class.php
@@ -0,0 +1,138 @@
+<?php
+
+//
+// +----------------------------------------------------------------------+
+// | PHP version 4.0 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2001 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available at through the world-wide-web at |
+// | http://www.php.net/license/2_02.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Bakken <ssb@fast.no> |
+// | Jan Dankert <phpdb@jandankert.de> |
+// +----------------------------------------------------------------------+
+//
+
+class DB_postgresql
+{
+ var $connection;
+ var $autocommit = true;
+ var $fetchmode = DB_FETCHMODE_ORDERED; /* Default fetch mode */
+ var $isError = false;
+
+ function connect( $conf )
+ {
+ $host = $conf['host'];
+ $user = $conf['user'];
+ $pw = $conf['password'];
+ $db = $conf['database'];
+
+ if ( $conf['persistent'] )
+ $connect_function = 'pg_pconnect';
+ else $connect_function = 'pg_connect';
+
+ if ( $pw != '' )
+ $this->connection = $connect_function( "host=$host dbname=$db user=$user password=$pw" );
+ elseif ( $user != '' )
+ $this->connection = $connect_function( "host=$host dbname=$db user=$user" );
+ elseif ( $host != '' )
+ $this->connection = $connect_function( "host=$host dbname=$db" );
+ else
+ $this->connection = $connect_function( "dbname=$db");
+
+ return true;
+ }
+
+
+
+ function disconnect()
+ {
+ $ret = pg_close( $this->connection );
+ $this->connection = null;
+ return $ret;
+ }
+
+
+
+ function simpleQuery($query)
+ {
+ $result = @pg_exec( $this->connection,$query );
+
+ if ( ! $result )
+ {
+ die( '<pre>'.$query."\n".'<span style="color:red;">'.pg_errormessage().'</span></pre>' );
+ }
+
+ return $result;;
+ }
+
+
+ function affectedRows( $result=null )
+ {
+ return pg_affected_rows( $result );
+ }
+
+
+ function fetchRow( $result, $fetchmode, $rownum )
+ {
+ if ( $rownum !== null )
+ {
+ $arr = pg_fetch_array( $result,$rownum,PGSQL_ASSOC );
+ }
+ else
+ {
+ $arr = pg_fetch_array( $result );
+ }
+
+ if ( ! $arr )
+ {
+ $this->isError = true;
+ }
+
+ return $arr;
+ }
+
+
+ function freeResult($result)
+ {
+ if (is_resource($result))
+ {
+ return pg_freeresult($result);
+ }
+ return true;
+ }
+
+
+ function numCols($result)
+ {
+ $cols = pg_numfields( $result );
+
+ if ( ! $cols )
+ {
+ return $this->postgresRaiseError();
+ }
+
+ return $cols;
+ }
+
+
+
+ function numRows( $result )
+ {
+ $rows = pg_numrows($result);
+
+ if ($rows === null )
+ {
+ $this->isError = true;
+ }
+ return $rows;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/doc/.htaccess b/doc/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/doc/database/sql/openrat_postgresql.sql b/doc/database/sql/openrat_postgresql.sql
@@ -0,0 +1,313 @@
+-- OpenRat Content Management System
+-- SQL-Dump
+--
+-- (c) Jan Dankert
+-- Licensed under the GNU General Public Licence
+
+
+DROP TABLE or_acl;
+DROP TABLE or_value;
+DROP TABLE or_usergroup;
+DROP TABLE or_templatemodel;
+DROP TABLE or_name;
+DROP TABLE or_link;
+DROP TABLE or_folder;
+DROP TABLE or_file;
+DROP TABLE or_element;
+DROP TABLE or_projectmodel;
+DROP TABLE or_page;
+DROP TABLE or_language;
+DROP TABLE or_template;
+DROP TABLE or_object;
+DROP TABLE or_group;
+DROP TABLE or_user;
+DROP TABLE or_project;
+
+CREATE TABLE or_project (
+ id INT NOT NULL
+ , name VARCHAR(128) NOT NULL
+ , target_dir VARCHAR(255) NOT NULL
+ , ftp_url VARCHAR(255) NOT NULL
+ , ftp_passive CHAR(1) DEFAULT '0' NOT NULL
+ , cmd_after_publish VARCHAR(255) NOT NULL
+ , content_negotiation CHAR(1) DEFAULT '0' NOT NULL
+ , cut_index CHAR(1) DEFAULT '0' NOT NULL
+ , PRIMARY KEY (id)
+);
+CREATE UNIQUE INDEX projectname ON or_project (name);
+
+CREATE TABLE or_user (
+ id INT NOT NULL
+ , name VARCHAR(128) NOT NULL
+ , password VARCHAR(50) NOT NULL
+ , ldap_dn VARCHAR(255) NOT NULL
+ , fullname VARCHAR(128) NOT NULL
+ , tel VARCHAR(128) NOT NULL
+ , mail VARCHAR(255) NOT NULL
+ , descr VARCHAR(255) NOT NULL
+ , style VARCHAR(64) NOT NULL
+ , is_admin INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+);
+CREATE UNIQUE INDEX name ON or_user (name);
+
+CREATE TABLE or_group (
+ id INT NOT NULL
+ , name VARCHAR(100) NOT NULL CONSTRAINT UQ_or_group_1 UNIQUE
+ , PRIMARY KEY (id)
+);
+
+CREATE TABLE or_object (
+ id INT NOT NULL
+ , parentid INT
+ , projectid INT DEFAULT 0 NOT NULL
+ , filename VARCHAR(256) NOT NULL
+ , orderid INT DEFAULT 0 NOT NULL
+ , create_date INT DEFAULT 0 NOT NULL
+ , create_userid INT DEFAULT 0
+ , lastchange_date INT DEFAULT 0 NOT NULL
+ , lastchange_userid INT DEFAULT 0
+ , is_folder INT DEFAULT 0 NOT NULL
+ , is_file INT DEFAULT 0 NOT NULL
+ , is_page INT DEFAULT 0 NOT NULL
+ , is_link INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_object_1 FOREIGN KEY (projectid)
+ REFERENCES or_project (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_object_2 FOREIGN KEY (lastchange_userid)
+ REFERENCES or_user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_object_3 FOREIGN KEY (create_userid)
+ REFERENCES or_user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX parentid ON or_object (parentid);
+CREATE INDEX object_projectid ON or_object (projectid);
+CREATE INDEX is_folder ON or_object (is_folder);
+CREATE INDEX is_file ON or_object (is_file);
+CREATE INDEX is_page ON or_object (is_page);
+CREATE INDEX is_link ON or_object (is_link);
+CREATE INDEX orderid ON or_object (orderid);
+CREATE INDEX object_create_userid ON or_object (create_userid);
+CREATE INDEX object_lastchange_userid ON or_object (lastchange_userid);
+CREATE UNIQUE INDEX IX_or_object_11 ON or_object (parentid, filename);
+
+CREATE TABLE or_template (
+ id INT NOT NULL
+ , projectid INT
+ , name VARCHAR(50) NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_template_1 FOREIGN KEY (projectid)
+ REFERENCES or_project (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX projectid ON or_template (projectid);
+CREATE INDEX templatename ON or_template (name);
+
+CREATE TABLE or_language (
+ id INT NOT NULL
+ , projectid INT DEFAULT 0 NOT NULL
+ , isocode VARCHAR(10) NOT NULL
+ , name VARCHAR(50) NOT NULL
+ , is_default INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_language_1 FOREIGN KEY (projectid)
+ REFERENCES or_project (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE UNIQUE INDEX IX_or_language_2 ON or_language (projectid, isocode);
+
+CREATE TABLE or_page (
+ id INT NOT NULL
+ , objectid INT DEFAULT 0 NOT NULL
+ , templateid INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_page_1 FOREIGN KEY (templateid)
+ REFERENCES or_template (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+ , CONSTRAINT FK_page_2 FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+);
+CREATE UNIQUE INDEX objectid ON or_page (objectid);
+CREATE INDEX page_templateid ON or_page (templateid);
+
+CREATE TABLE or_projectmodel (
+ id INT NOT NULL
+ , projectid INT DEFAULT 0 NOT NULL
+ , name VARCHAR(50) NOT NULL
+ , extension VARCHAR(10) NOT NULL
+ , is_default INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_projectmodel_1 FOREIGN KEY (projectid)
+ REFERENCES or_project (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX projectmodel_projectid ON or_projectmodel (projectid);
+CREATE INDEX IX_or_projectmodel_3 ON or_projectmodel (projectid, extension);
+
+CREATE TABLE or_element (
+ id INT NOT NULL
+ , templateid INT DEFAULT 0 NOT NULL
+ , name VARCHAR(50) NOT NULL
+ , descr VARCHAR(255) NOT NULL
+ , type VARCHAR(20) NOT NULL
+ , subtype VARCHAR(20)
+ , with_icon CHAR(1) DEFAULT '0' NOT NULL
+ , dateformat VARCHAR(100)
+ , wiki CHAR(1) DEFAULT '0'
+ , html CHAR(1) DEFAULT '0'
+ , all_languages CHAR(1) DEFAULT '0' NOT NULL
+ , writable CHAR(1) DEFAULT '0' NOT NULL
+ , decimals CHAR(4) DEFAULT '0'
+ , dec_point VARCHAR(5)
+ , thousand_sep CHAR(1)
+ , code TEXT
+ , default_text TEXT
+ , folderobjectid INT
+ , default_objectid INT
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_or_element_1 FOREIGN KEY (default_objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_or_element_2 FOREIGN KEY (folderobjectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_or_element_3 FOREIGN KEY (templateid)
+ REFERENCES or_template (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX element_templateid ON or_element (templateid);
+CREATE UNIQUE INDEX IX_or_element_3 ON or_element (templateid, name);
+
+CREATE TABLE or_file (
+ id INT NOT NULL
+ , objectid INT DEFAULT 0 NOT NULL
+ , extension VARCHAR(10) NOT NULL
+ , size INT DEFAULT 0 NOT NULL
+ , value TEXT NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_file_1 FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+);
+CREATE UNIQUE INDEX file_objectid ON or_file (objectid);
+
+CREATE TABLE or_folder (
+ id INT NOT NULL
+ , objectid INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_folder_objectid FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE UNIQUE INDEX folder_objectid ON or_folder (objectid);
+
+CREATE TABLE or_link (
+ id INT NOT NULL
+ , objectid INT DEFAULT 0 NOT NULL
+ , link_objectid INT
+ , url VARCHAR(255)
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_link_1 FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_link_2 FOREIGN KEY (link_objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX link_objectid ON or_link (objectid);
+CREATE INDEX link_linkobjectid ON or_link (link_objectid);
+
+CREATE TABLE or_name (
+ id INT NOT NULL
+ , objectid INT DEFAULT 0 NOT NULL
+ , name VARCHAR(128) NOT NULL
+ , descr TEXT NOT NULL
+ , languageid INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_name_1 FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+ , CONSTRAINT FK_name_2 FOREIGN KEY (languageid)
+ REFERENCES or_language (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX name_objectid ON or_name (objectid);
+CREATE INDEX name_languageid ON or_name (languageid);
+
+CREATE TABLE or_templatemodel (
+ id INT NOT NULL
+ , templateid INT DEFAULT 0 NOT NULL
+ , projectmodelid INT DEFAULT 0 NOT NULL
+ , extension VARCHAR(10)
+ , text TEXT NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT UQ_or_templatemodel_1 UNIQUE (templateid, extension)
+ , CONSTRAINT FK_templatemodel_1 FOREIGN KEY (templateid)
+ REFERENCES or_template (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+ , CONSTRAINT FK_templatemodel_2 FOREIGN KEY (projectmodelid)
+ REFERENCES or_projectmodel (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+);
+CREATE INDEX templateid ON or_templatemodel (templateid);
+
+CREATE TABLE or_usergroup (
+ id INT NOT NULL
+ , userid INT DEFAULT 0 NOT NULL
+ , groupid INT DEFAULT 0 NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_usergroup_1 FOREIGN KEY (groupid)
+ REFERENCES or_group (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_usergroup_2 FOREIGN KEY (userid)
+ REFERENCES or_user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX groupid ON or_usergroup (groupid);
+CREATE INDEX userid ON or_usergroup (userid);
+
+CREATE TABLE or_value (
+ id INT NOT NULL
+ , pageid INT DEFAULT 0 NOT NULL
+ , languageid INT NOT NULL
+ , elementid INT DEFAULT 0 NOT NULL
+ , linkobjectid INT
+ , text TEXT
+ , number INT
+ , date INT
+ , active INT DEFAULT 0 NOT NULL
+ , lastchange_date INT DEFAULT 0 NOT NULL
+ , lastchange_userid INT DEFAULT 0
+ , PRIMARY KEY (id)
+ , CONSTRAINT FK_value_1 FOREIGN KEY (pageid)
+ REFERENCES or_page (id) ON DELETE RESTRICT ON UPDATE NO ACTION
+ , CONSTRAINT FK_value_2 FOREIGN KEY (elementid)
+ REFERENCES or_element (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_value_3 FOREIGN KEY (languageid)
+ REFERENCES or_language (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_value_4 FOREIGN KEY (lastchange_userid)
+ REFERENCES or_user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_value_5 FOREIGN KEY (linkobjectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+
+CREATE TABLE or_acl (
+ id INT NOT NULL
+ , userid INT
+ , groupid INT
+ , objectid INT DEFAULT 0 NOT NULL
+ , languageid INT DEFAULT 0
+ , is_write INT DEFAULT 0 NOT NULL
+ , is_prop INT DEFAULT 0 NOT NULL
+ , is_create_folder INT DEFAULT 0 NOT NULL
+ , is_create_file INT DEFAULT 0 NOT NULL
+ , is_create_link INT DEFAULT 0 NOT NULL
+ , is_create_page INT DEFAULT 0 NOT NULL
+ , is_delete INT DEFAULT 0 NOT NULL
+ , is_publish INT DEFAULT 0 NOT NULL
+ , is_grant INT DEFAULT 0 NOT NULL
+ , is_transmit INT NOT NULL
+ , PRIMARY KEY (id)
+ , CONSTRAINT fk_acl_groupid FOREIGN KEY (groupid)
+ REFERENCES or_group (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT fk_acl_userid FOREIGN KEY (userid)
+ REFERENCES or_user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT fk_acl_objectid FOREIGN KEY (objectid)
+ REFERENCES or_object (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+ , CONSTRAINT FK_or_acl_languageid FOREIGN KEY (languageid)
+ REFERENCES or_language (id) ON DELETE RESTRICT ON UPDATE RESTRICT
+);
+CREATE INDEX idx_acl_userid ON or_acl (userid);
+CREATE INDEX idx_acl_groupid ON or_acl (groupid);
+CREATE INDEX idx_acl_languageid ON or_acl (languageid);
+CREATE INDEX idx_acl_objectid ON or_acl (objectid);
+CREATE INDEX idx_acl_transmit ON or_acl (is_transmit);
+
+
+-- Insert 1 Admin-User
+
+INSERT INTO or_user
+ (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin)
+ VALUES( 1,'admin','21232f297a57a5a743894a0e4a801fc3','','Administrator','','','The Admin User','default',1 )
diff --git a/objectClasses/.htaccess b/objectClasses/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/objectClasses/Acl.class.php b/objectClasses/Acl.class.php
@@ -0,0 +1,408 @@
+<?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.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Darstellen einer Berechtigung (ACL "Access Control List")
+ * Die Berechtigung zu einem Objekt wird mit einer Liste dieser Objekte dargestellt
+ *
+ * Falls es mehrere ACLs zu einem Objekt gibt, werden die Berechtigung-Flags addiert.
+ */
+class Acl
+{
+ /**
+ * eindeutige ID dieser ACL
+ * @type Integer
+ */
+ var $aclid;
+
+ /**
+ * ID des Objektes, für das diese Berechtigung gilt
+ * @type Integer
+ */
+ var $objectid = 0;
+
+ /**
+ * ID des Benutzers
+ * ( = 0 falls die Berechtigung für eine Gruppe gilt)
+ * @type Integer
+ */
+ var $userid = 0;
+
+ /**
+ * ID der Gruppe
+ * ( = 0 falls die Berechtigung für einen Benutzer gilt)
+ * @type Integer
+ */
+ var $groupid = 0;
+
+ /**
+ * ID der Sprache
+ * @type Integer
+ */
+ var $languageid = 0;
+
+ /**
+ * Es handelt sich um eine Standard-Berechtigung
+ * (Falls false, dann Zugriffs-Berechtigung)
+ * @type Boolean
+ */
+ var $isDefault = false;
+
+ /**
+ * Name des Benutzers, für den diese Berechtigung gilt
+ * @type String
+ */
+ var $username = '';
+
+ /**
+ * Name der Gruppe, für die diese Berechtigung gilt
+ * @type String
+ */
+ var $groupname = '';
+
+ /**
+ * Inhalt lesen (ist immer wahr)
+ * @type Boolean
+ */
+ var $read = true;
+
+ /**
+ * Inhalt bearbeiten
+ * @type Boolean
+ */
+ var $write = false;
+
+ /**
+ * Eigenschaften bearbeiten
+ * @type Boolean
+ */
+ var $prop = false;
+
+ /**
+ * Objekt löschen
+ * @type Boolean
+ */
+ var $delete = false;
+
+ /**
+ * Objekt veröffentlichen
+ * @type Boolean
+ */
+ var $publish = false;
+
+ /**
+ * Unterordner anlegen
+ * @type Boolean
+ */
+ var $create_folder = false;
+
+ /**
+ * Datei anlegen (bzw. hochladen)
+ * @type Boolean
+ */
+ var $create_file = false;
+
+ /**
+ * Verknüpfung anlegen
+ * @type Boolean
+ */
+ var $create_link = false;
+
+ /**
+ * Seite anlegen
+ * @type Boolean
+ */
+ var $create_page = false;
+
+ /**
+ * Berechtigungen vergeben
+ * @type Boolean
+ */
+ var $grant = false;
+
+ /**
+ * Berechtigungen an Unterobjekte vererben
+ * @type Boolean
+ */
+ var $transmit = false;
+
+
+ /**
+ * Konstruktor
+ * @param Integer Acl-ID
+ */
+ function Acl( $aclid = 0 )
+ {
+ if ( $aclid != 0 )
+ $this->aclid = $aclid;
+ }
+
+
+ /**
+ * Laden einer ACL
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_acl}.*,{t_user}.name as username,{t_group}.name as groupname,{t_language}.name as languagename'.
+ ' FROM {t_acl} '.
+ ' LEFT JOIN {t_user} ON {t_user}.id = {t_acl}.userid '.
+ ' LEFT JOIN {t_group} ON {t_group}.id = {t_acl}.groupid '.
+ ' LEFT JOIN {t_language} ON {t_language}.id = {t_acl}.languageid '.
+ ' WHERE {t_acl}.id={aclid}' );
+
+ $sql->setInt('aclid',$this->aclid);
+
+ $row = $db->getRow( $sql->query );
+
+ $this->write = ( $row['is_write' ] == '1' );
+ $this->prop = ( $row['is_prop' ] == '1' );
+ $this->delete = ( $row['is_delete' ] == '1' );
+ $this->publish = ( $row['is_publish' ] == '1' );
+ $this->create_folder = ( $row['is_create_folder'] == '1' );
+ $this->create_file = ( $row['is_create_file' ] == '1' );
+ $this->create_page = ( $row['is_create_page' ] == '1' );
+ $this->create_link = ( $row['is_create_link' ] == '1' );
+ $this->grant = ( $row['is_grant' ] == '1' );
+ $this->transmit = ( $row['is_transmit' ] == '1' );
+
+ $this->objectid = intval($row['objectid' ]);
+ $this->languageid = intval($row['languageid']);
+ $this->userid = intval($row['userid' ]);
+ $this->groupid = intval($row['groupid' ]);
+ if ( intval($this->languageid)==0 )
+ $this->languagename = lang('ALL_LANGUAGES');
+ else $this->languagename = $row['languagename'];
+ $this->username = $row['username' ];
+ $this->groupname = $row['groupname' ];
+ }
+
+
+ function save()
+ {
+ if ( $this->delete )
+ $this->prop = true;
+
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_acl} '.
+ ' SET userid ={userid},'.
+ ' groupid ={groupid},'.
+ ' objectid ={objectid},'.
+ ' is_write ={write},'.
+ ' is_prop ={prop},'.
+ ' is_create_folder={create_folder},'.
+ ' is_create_file ={create_file},'.
+ ' is_create_link ={create_link},'.
+ ' is_create_page ={create_page},'.
+ ' is_grant ={grant},'.
+ ' is_transmit ={transmit},'.
+ ' delete ={delete},'.
+ ' publish ={publish},'.
+ ' languageid ={languageid}'.
+ ' WHERE aclid={aclid}' );
+
+ $sql->setInt('aclid' ,$this->aclid );
+ $sql->setInt('objectid',$this->objectid);
+
+ if ( intval($this->groupid) == 0 )
+ {
+ $sql->setInt ('userid',$this->userid);
+ $sql->setNull('groupid');
+ }
+ else
+ {
+ $sql->setNull('userid');
+ $sql->setInt ('groupid',$this->groupid);
+ }
+
+ $sql->setBoolean('is_default' ,$this->isDefault );
+ $sql->setBoolean('prop' ,$this->prop );
+ $sql->setBoolean('write' ,$this->write );
+ $sql->setBoolean('delete' ,$this->delete );
+ $sql->setBoolean('publish' ,$this->publish );
+ $sql->setBoolean('grant' ,$this->grant );
+ $sql->setBoolean('transmit' ,$this->transmit );
+ $sql->setBoolean('create_folder',$this->create_folder );
+ $sql->setBoolean('create_file' ,$this->create_file );
+ $sql->setBoolean('create_link' ,$this->create_link );
+ $sql->setBoolean('create_page' ,$this->create_page );
+
+ $sql->setInt('languageid',$this->languageid);
+
+ $db->query( $sql->query );
+ }
+
+
+
+ function getProperties()
+ {
+ return Array( 'write' => $this->write,
+ 'prop' => $this->prop,
+ 'create_folder'=> $this->create_folder,
+ 'create_file' => $this->create_file,
+ 'create_link' => $this->create_link,
+ 'create_page' => $this->create_page,
+ 'delete' => $this->delete,
+ 'publish' => $this->publish,
+ 'grant' => $this->grant,
+ 'transmit' => $this->transmit,
+ 'is_default' => $this->isDefault,
+ 'userid' => $this->userid,
+ 'username' => $this->username,
+ 'groupid' => $this->groupid,
+ 'groupname' => $this->groupname,
+ 'languageid' => $this->languageid,
+ 'languagename' => $this->languagename,
+ 'objectid' => $this->objectid );
+
+ }
+
+
+ function delete()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'DELETE FROM {t_acl} '.
+ ' WHERE id = {aclid}' );
+
+ $sql->setInt('aclid',$this->aclid);
+
+ $db->query( $sql->query );
+
+ $this->aclid = 0;
+ }
+
+
+ function add()
+ {
+ if ( $this->delete )
+ $this->prop = true;
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_acl}');
+ $this->aclid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql( 'INSERT INTO {t_acl} '.
+ ' (id,userid,groupid,objectid,is_write,is_prop,is_create_folder,is_create_file,is_create_link,is_create_page,is_delete,is_publish,is_grant,is_transmit,languageid)'.
+ ' VALUES( {aclid},{userid},{groupid},{objectid},{write},{prop},{create_folder},{create_file},{create_link},{create_page},{delete},{publish},{grant},{transmit},{languageid} )' );
+
+ $sql->setInt('aclid' ,$this->aclid );
+ $sql->setInt('objectid',$this->objectid);
+
+ if ( intval($this->groupid) == 0 )
+ {
+ $sql->setInt ('userid',$this->userid);
+ $sql->setNull('groupid');
+ }
+ else
+ {
+ $sql->setNull('userid');
+ $sql->setInt ('groupid',$this->groupid);
+ }
+
+ $sql->setBoolean('is_default' ,$this->isDefault );
+ $sql->setBoolean('prop' ,$this->prop );
+ $sql->setBoolean('write' ,$this->write );
+ $sql->setBoolean('delete' ,$this->delete );
+ $sql->setBoolean('publish' ,$this->publish );
+ $sql->setBoolean('grant' ,$this->grant );
+ $sql->setBoolean('transmit' ,$this->transmit );
+ $sql->setBoolean('create_folder',$this->create_folder );
+ $sql->setBoolean('create_file' ,$this->create_file );
+ $sql->setBoolean('create_link' ,$this->create_link );
+ $sql->setBoolean('create_page' ,$this->create_page );
+
+ if ( intval($this->languageid) == 0 )
+ $sql->setNull('languageid');
+ else $sql->setInt ('languageid',$this->languageid);
+
+ $db->query( $sql->query );
+ }
+
+
+// function getAccessACLsFromObject( $objectid=0 )
+// {
+// $db = db_connection();
+//
+// $sql = new Sql( 'SELECT id FROM {t_acl} '.
+// ' WHERE objectid={objectid}'.
+// ' AND is_default=0'.
+// ' ORDER BY userid,groupid ASC' );
+//
+// if ( $objectid == 0 )
+// $sql->setInt('objectid',$this->objectid);
+// else $sql->setInt('objectid',$objectid );
+//
+// return $db->getCol( $sql->query );
+// }
+//
+//
+// function getDefaultACLsFromObject( $objectid=0 )
+// {
+// $db = db_connection();
+//
+// $sql = new Sql( 'SELECT id FROM {t_acl} '.
+// ' WHERE objectid={objectid}'.
+// ' AND is_default=1'.
+// ' ORDER BY userid,groupid ASC' );
+//
+// if ( $objectid == 0 )
+// $sql->setInt('objectid',$this->objectid);
+// else $sql->setInt('objectid',$objectid );
+//
+//// echo "<pre>".$sql->query."</pre>";
+// return $db->getCol( $sql->query );
+// }
+
+
+ function getACLsFromUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE userid={userid}');
+ $sql->setInt('userid',$userid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getACLsFromGroupId( $groupid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE groupid={groupid}' );
+ $sql->setInt('groupid',$groupid);
+
+ return $db->getCol( $sql->query );
+ }
+}+
\ No newline at end of file
diff --git a/objectClasses/Element.class.php b/objectClasses/Element.class.php
@@ -0,0 +1,325 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2004/03/13 23:09:48 dankert
+// *** empty log message ***
+//
+// ---------------------------------------------------------------------------
+
+
+class Element
+{
+ /**
+ * ID dieses Elementes
+ * @type Integer
+ */
+ var $elementid;
+
+ /**
+ * Template-ID zu der dieses Elementes gehört
+ * @type Integer
+ */
+ var $templateid;
+
+ /**
+ * Sprachen-ID dieses Elementes
+ * @type Integer
+ */
+ var $languageid;
+
+ /**
+ * Typ des Elementes
+ * @type String
+ */
+ var $type;
+
+ /**
+ * Name dieses Elementes
+ * @type String
+ */
+ var $name;
+
+ /**
+ * Beschreibung zu diesem Element
+ * @type String
+ */
+ var $desc;
+
+ /**
+ * ID dieses Elementes
+ * @type String
+ */
+ var $value;
+
+ /**
+ * Objekt-ID eines Ordners, aus diesem Ordner (samt Unterordner)
+ * können zu verlinkende Objekte ausgewählt werden
+ * @type Integer
+ */
+ var $folderobjectid = 0;
+
+ /**
+ * Schalter ob dieses Element von Redakteuren bearbeiten werden kann
+ * @type Boolean
+ */
+ var $writable;
+
+ /**
+ * Schalter ob dieses Element in allen Sprachen den gleichen Inhalt hat
+ * @type Boolean
+ */
+ var $allLanguages;
+
+ function Element( $elementid=0 )
+ {
+ global $SESS;
+
+ if ( intval($elementid)!=0 )
+ $this->elementid = $elementid;
+ }
+
+
+ function add()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_element}');
+ $this->elementid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql( 'INSERT INTO {t_element}'.
+ ' (id,templateid,name,descr,type,writable) '.
+ " VALUES ( {elementid},{templateid},{name},'',{type},{writable} ) " );
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'type' ,$this->type );
+ $sql->setInt ( 'templateid',$this->templateid );
+ $sql->setBoolean( 'writable' ,$this->writable );
+
+ $db->query( $sql->query );
+ }
+
+
+
+// function path_to_page( $pageid )
+// {
+// return $this->page->path_to_object( $pageid );
+// }
+// function path_to_object( $pageid )
+// {
+// return $this->path_to_page( $pageid );
+// }
+
+
+
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_element}'.
+ ' WHERE id={elementid}' );
+ $sql->setInt( 'elementid',$this->elementid );
+ $prop = $db->getRow( $sql->query );
+
+ $this->templateid = $prop['templateid'];
+ $this->name = $prop['name'];
+ $this->desc = $prop['descr'];
+ $this->type = $prop['type'];
+ $this->subtype = $prop['subtype'];
+
+ $this->dateformat = $prop['dateformat'];
+ $this->wiki = ( $prop['wiki' ] == '1' );
+ $this->withIcon = ( $prop['with_icon' ] == '1' );
+ $this->html = ( $prop['html' ] == '1' );
+ $this->allLanguages = ( $prop['all_languages'] == '1' );
+ $this->writable = ( $prop['writable' ] == '1' );
+
+ if ( !$this->writable)
+ $this->withIcon = false;
+
+ $this->decimals = $prop['decimals'];
+ $this->decPoint = $prop['dec_point'];
+ $this->thousandSep = $prop['thousand_sep'];
+ $this->code = $prop['code'];
+ $this->defaultText = $prop['default_text'];
+ $this->folderObjectId = intval($prop['folderobjectid' ]);
+ $this->defaultObjectId = intval($prop['default_objectid']);
+ }
+
+
+
+ // Element speichern
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_element}'.
+ ' SET templateid = {templateid},'.
+ ' name = {name},'.
+ ' descr = {desc},'.
+ ' type = {type},'.
+ ' subtype = {subtype},'.
+ ' with_icon = {withIcon},'.
+ ' dateformat = {dateformat},'.
+ ' wiki = {wiki},'.
+ ' html = {html},'.
+ ' all_languages = {allLanguages},'.
+ ' writable = {writable},'.
+ ' decimals = {decimals},'.
+ ' dec_point = {decPoint},'.
+ ' thousand_sep = {thousandSep},'.
+ ' code = {code},'.
+ ' default_text = {defaultText},'.
+ ' folderobjectid = {folderObjectId},'.
+ ' default_objectid= {defaultObjectId}'.
+ ' WHERE id={elementid}' );
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'desc' ,$this->desc );
+ $sql->setString ( 'type' ,$this->type );
+ $sql->setString ( 'subtype' ,$this->subtype );
+ $sql->setBoolean( 'withIcon' ,$this->withIcon );
+ $sql->setString ( 'dateformat' ,$this->dateformat );
+ $sql->setBoolean( 'wiki' ,$this->wiki );
+ $sql->setBoolean( 'html' ,$this->html );
+ $sql->setBoolean( 'writable' ,$this->writable );
+ $sql->setBoolean( 'allLanguages' ,$this->allLanguages );
+ $sql->setInt ( 'decimals' ,$this->decimals );
+ $sql->setString ( 'decPoint' ,$this->decPoint );
+ $sql->setString ( 'thousandSep' ,$this->thousandSep );
+ $sql->setString ( 'code' ,$this->code );
+ $sql->setString ( 'defaultText' ,$this->defaultText );
+
+ if ( intval($this->folderObjectId)==0 )
+ $sql->setNull( 'folderObjectId' );
+ else $sql->setInt ( 'folderObjectId' ,$this->folderObjectId );
+
+ if ( intval($this->defaultObjectId)==0 )
+ $sql->setNull( 'defaultObjectId' );
+ else $sql->setInt ( 'defaultObjectId' ,$this->defaultObjectId );
+
+ $db->query( $sql->query );
+ }
+
+
+
+ // Element speichern
+ function setType( $type )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_element}'.
+ ' SET type = {type}'.
+ ' WHERE id={elementid}' );
+
+ $sql->setInt ( 'elementid',$this->elementid );
+ $sql->setString ( 'type' ,$type );
+
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Löschen des Elementes und aller Inhalte
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Inhalte löschen
+ $this->deleteValues();
+
+ // Element löschen
+ $sql = new Sql('DELETE FROM {t_element} '.
+ ' WHERE id={elementid}' );
+ $sql->setInt( 'elementid',$this->elementid );
+
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Löschen aller Seiteninhalte mit diesem Element
+ */
+ function deleteValues()
+ {
+ $db = db_connection();
+
+ // Alle Inhalte mit diesem Element löschen
+ $sql = new Sql('DELETE FROM {t_value} '.
+ ' WHERE elementid={elementid}' );
+ $sql->setInt( 'elementid',$this->elementid );
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Abhängig vom Element-Typ werden die zur Darstellung notwendigen Eigenschaften ermittelt
+ * @return Array()
+ */
+ function getRelatedProperties()
+ {
+ $typeprop = Array('text' =>Array('withIcon','allLanguages','writable','html','wiki','defaultText'),
+ 'longtext'=>Array('withIcon','allLanguages','writable','html','wiki','defaultText'),
+ 'number' =>Array('withIcon','allLanguages','writable','decPoint','decimals','thousandSep','defaultText'),
+ 'link' =>Array('withIcon','allLanguages','writable','folderObjectId','defaultObjectId'),
+ 'date' =>Array('withIcon','allLanguages','writable','dateformat'),
+ 'list' =>Array('withIcon','allLanguages','writable','folderObjectId'),
+ 'code' =>Array('code'),
+ 'info' =>Array('subtype'),
+ 'infodate'=>Array('subtype','dateformat') );
+
+ return $typeprop[ $this->type ];
+ }
+
+
+ /**
+ * Ermitteln aller benutzbaren Elementtypen
+ * @return Array
+ */
+ function getAvailableTypes()
+ {
+ return array('text',
+ 'longtext',
+ 'number',
+ 'link',
+ 'date',
+ 'list',
+ 'code',
+ 'info',
+ 'infodate');
+ }
+
+
+ function isWritable()
+ {
+ if ( in_array($this->type,Array('info','infodate','code')) )
+ return false;
+
+ return $this->writable;
+ }
+}+
\ No newline at end of file
diff --git a/objectClasses/File.class.php b/objectClasses/File.class.php
@@ -0,0 +1,443 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2003/10/27 23:21:55 dankert
+// Methode(n) hinzugefügt: savevalue(), save()
+//
+// ---------------------------------------------------------------------------
+
+
+class File extends Object
+{
+ var $fileid;
+
+ var $size = 0;
+ var $value = '';
+ var $extension = '';
+ var $log_filenames = array();
+ var $publish = null;
+
+ /**
+ * Um Probleme mit BLOB-Feldern und Datenbank-Besonderheiten zu vermeiden,
+ * kann der Binärinhalt BASE64-kodiert gespeichert werden.
+ * @type Boolean
+ */
+ var $storeValueAsBase64 = false;
+
+ function File( $objectid='' )
+ {
+ global $conf,$SESS;
+
+ if ( isset($conf['database_'.$SESS['dbid']]['base64']) &&
+ $conf['database_'.$SESS['dbid']]['base64'] == true )
+ $this->storeValueAsBase64 = true;
+ else $this->storeValueAsBase64 = false;
+
+ $this->Object( $objectid );
+ $this->isFile = true;
+ }
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function full_filename()
+ {
+ $filename = parent::full_filename();
+
+ if ( $this->extension != '' )
+ {
+ $filename .= '.'.$this->extension;
+ }
+
+ return $filename;
+ }
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei (ohne Pfadangabe)
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function filenameWithExtension()
+ {
+ if ( $this->extension != '' )
+ return $this->filename.'.'.$this->extension;
+ else return $this->filename;
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ Array('full_filename'=>$this->full_filename(),
+ 'extension' =>$this->extension,
+ 'size' =>$this->size,
+ 'mimetype' =>$this->mimetype() ) );
+ }
+
+
+ function getFileObjectIdsByExtension( $extension )
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sqlquery = 'SELECT * FROM {t_object} ';
+
+ if ( $extension != '' )
+ {
+ $sqlquery .= " WHERE extension='";
+
+ $ext = explode(',',$extension);
+ $sqlquery .= implode( "' OR extension='",$ext );
+ $sqlquery .= "' AND is_file=1 AND projectid={projectid}";
+ }
+ else
+ {
+ $sqlquery .= " WHERE is_file=1 AND projectid={projectid}";
+ }
+
+ $sql = new Sql( $sqlquery );
+ $sql->setInt( 'projectid',$SESS['projectid'] );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte zu einer Dateierweiterung ermittelt
+ * @param String Dateierweiterung ohne führenden Punkt (z.B. 'jpeg')
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByExtension( $extension )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_file}.objectid FROM {t_file} '.
+ ' LEFT JOIN {t_object} '.
+ ' ON {t_object}.id={t_file}.objectid'.
+ ' WHERE {t_file}.extension={extension}'.
+ ' AND {t_object}.projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setString( 'extension',$extension );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function mimeType()
+ {
+ global $conf_languagedir,$conf_php;
+ $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
+
+ if ( isset($mime_types[ strtolower($this->extension) ]) )
+ $mime = $mime_types[ strtolower($this->extension) ];
+ else $mime = 'application/octet-stream';
+
+ return( $mime );
+ }
+
+
+ function imageResize( $newWidth,$newHeight )
+ {
+ global $conf;
+
+ // Schalter, ob GD in Version 2 verfuegbar ist
+ $gd2 = $conf['gd']['version2'];
+
+ $this->write(); // Datei schreiben
+
+ // Bildinformationen ermitteln
+ $size = getimagesize( $this->tmpfile() );
+
+ // Breite und Hoehe des aktuellen Bildes
+ $oldWidth = $size[0];
+ $oldHeight = $size[1];
+ $aspectRatio = $oldHeight / $oldWidth; // Seitenverhaeltnis
+
+ // Wenn nur Breite oder Hoehe angegeben ist, dann
+ // das Seitenverhaeltnis beibehalten
+ if ( $newWidth == 0 )
+ $newWidth = $newHeight / $aspectRatio;
+
+ if ( $newHeight == 0 )
+ $newHeight = $newWidth * $aspectRatio;
+
+ switch( $size[2] )
+ {
+ case '1': // GIF
+
+ $oldImage = ImageCreateFromGIF( $this->tmpfile );
+ $newImage = ImageCreate($newWidth,$newHeight);
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ ImageGIF($newImage, $this->tmpfile() );
+ $this->extension = 'gif';
+
+ break;
+
+ case '2': // JPEG
+
+ $oldImage = ImageCreateFromJPEG($this->tmpfile);
+
+ if ( $gd2 )
+ {
+ // Verwende TrueColor
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterstützt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ ImageJPEG($newImage, $this->tmpfile );
+ $this->extension = 'jpeg';
+
+ break;
+
+ case '3': // PNG
+
+ $oldImage = imagecreatefrompng($this->tmpfile);
+ if ( $gd2 )
+ {
+ // Verwende TrueColor
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterstützt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ imagepng( $newImage,$this->tmpfile() );
+ $this->extension = 'png';
+
+ break;
+
+ default:
+ die('unsupported type for resizing');
+ }
+
+ $f = fopen( $this->tmpfile(), "r" );
+ $this->value = fread( $f,filesize($this->tmpfile()) );
+ fclose( $f );
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,extension,size'.
+ ' FROM {t_file}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $db->getRow( $sql->query );
+
+ $this->fileid = $row['id' ];
+ $this->extension = $row['extension'];
+ $this->size = $row['size' ];
+
+ $this->objectLoad();
+ }
+
+
+
+ function delete()
+ {
+ $db = db_connection();
+
+ // Datei löschen
+ $sql = new Sql( 'DELETE FROM {t_file} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+
+
+ /**
+ * Stellt fest, ob es sich bei dieser Datei um ein Bild handelt
+ */
+ function isImage()
+ {
+ return eregi('jpe?g|png|gif',$this->extension);
+ }
+
+
+ function extension()
+ {
+ if ($this->extension != '')
+ return $this->extension;
+
+ $this->load();
+ return $this->extension;
+ }
+
+
+ // Einen Dateinamen in Dateiname und Extension aufteilen
+ function parse_filename($filename)
+ {
+ $filename = basename($filename);
+
+ $p = strrpos($filename, '.');
+ if ($p !== false)
+ {
+ $this->extension = substr($filename, $p +1);
+ $this->filename = substr($filename, 0, $p);
+ }
+ else
+ {
+ $this->extension = '';
+ $this->filename = $filename;
+ }
+ }
+
+
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_file} SET '.
+ ' size = {size},'.
+ ' extension = {extension}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setString('size' ,$this->size );
+ $sql->setString('extension',$this->extension );
+ $sql->setString('objectid' ,$this->objectid );
+ $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function loadValue()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT size,value'.
+ ' FROM {t_file}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $db->getRow( $sql->query );
+
+ $this->value = $row['value'];
+ $this->size = $row['size' ];
+
+ if ( $this->storeValueAsBase64 )
+ $this->value = base64_decode( $this->value );
+
+ return( $this->value );
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function saveValue( $value = '' )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_file}'.
+ ' SET value={value}, '.
+ ' size={size} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setString( 'objectid' ,$this->objectid );
+ $sql->setInt ( 'size' ,strlen($this->value) );
+
+ if ( $this->storeValueAsBase64 )
+ $sql->setString( 'value' ,base64_encode($this->value) );
+ else $sql->setString( 'value' ,$this->value );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Lesen der Datei aus der Datenbank und schreiben in temporaere Datei
+ function write()
+ {
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->loadValue() );
+ fclose( $f );
+ }
+
+
+ function add()
+ {
+ $db = db_connection();
+
+ $this->objectAdd();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_file}');
+ $this->fileid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_file}'.
+ ' (id,objectid,extension,size,value)'.
+ " VALUES( {fileid},{objectid},{extension},0,'' )" );
+ $sql->setInt ('fileid' ,$this->fileid );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('extension',$this->extension );
+
+ $db->query( $sql->query );
+
+ $this->saveValue();
+ }
+
+
+ function publish()
+ {
+ if ( ! is_object($this->publish) )
+ $this->publish = new Publish();
+
+ $this->write();
+ $this->publish->copy( $this->tmpfile(),$this->full_filename() );
+
+// $this->log_filenames = $this->publish->log_filenames;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Folder.class.php b/objectClasses/Folder.class.php
@@ -0,0 +1,646 @@
+<?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.
+#
+
+
+class Folder extends Object
+{
+ var $folderid;
+ var $projectid;
+ var $parentfolders = array();
+ var $subfolders = array();
+ var $filenames = true;
+ var $name = '';
+ var $filename = '';
+ var $desc = '';
+ var $publish = null;
+
+
+ function Folder( $objectid='' )
+ {
+ $this->Object( $objectid );
+ $this->isFolder = true;
+ }
+
+
+ function add()
+ {
+ $this->objectAdd();
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_folder}');
+ $this->folderid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_folder}'.
+ ' (id,objectid)'.
+ ' VALUES( {folderid},{objectid} )' );
+ $sql->setInt ('folderid' ,$this->folderid );
+ $sql->setInt ('objectid' ,$this->objectid );
+
+ $db->query( $sql->query );
+ }
+
+
+
+ function getRootFolderId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new SQL('SELECT id FROM {t_folder}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden
+ if ( isset($this) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ // Datenbankabfrage ausführen
+ return $db->getOne( $sql->query );
+ }
+
+
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT * FROM {t_folder} WHERE objectid={objectid}');
+ $sql->setInt('objectid',$this->objectid);
+
+ $row = $db->getRow( $sql->query );
+
+ $this->objectLoad();
+
+ $this->folderid = $row['id' ];
+ }
+
+
+
+ function save()
+ {
+ $db = db_connection();
+
+// $sql = new Sql('UPDATE {t_folder}'.
+// 'SET xx ={xx}'.
+// ' WHERE objectid={objectid}' );
+// $sql->setInt('parentid' ,$this->parentId);
+// $sql->setInt('objectid' ,$this->objectid);
+// $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+
+ function setOrderId( $orderid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_folder} '.
+ ' SET orderid={orderid}'.
+ ' WHERE id={folderid}');
+ $sql->setInt('folderid',$this->folderid);
+ $sql->setInt('orderid' ,$orderid );
+
+ $db->query( $sql->query );
+ }
+
+
+
+// function getSubFolders()
+// {
+// global $SESS;
+// $db = db_connection();
+//
+// $sql = new Sql('SELECT id FROM {t_folder}'.
+// ' WHERE parentid={folderid}'.
+// ' AND projectid={projectid}'.
+// ' ORDER BY orderid ASC' );
+// $sql->setInt('folderid' ,$SESS['folderid' ]);
+// $sql->setInt('projectid',$SESS['projectid']);
+//
+// return( $db->getCol( $sql->query ));
+// }
+
+
+ function getObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function publish( $subdirs = false )
+ {
+ if ( ! is_object($this->publish) )
+ $this->publish = new Publish();
+
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $o = new Object( $oid );
+ $o->load();
+
+ if ( $o->isPage )
+ {
+ $p = new Page( $oid );
+ $p->load();
+ $p->publish = &$this->publish;
+ $p->publish();
+ }
+
+ if ( $o->isFile )
+ {
+ $f = new File( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish();
+ }
+
+ if ( $o->isFolder && $subdirs )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish( true );
+ }
+ }
+ }
+
+
+ function getObjectIdByFileName( $filename )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' AND filename={filename}' );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('filename' ,$filename );
+
+ return( intval($db->getOne( $sql->query )) );
+ }
+
+
+ function getAllObjectIds()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('projectid',$SESS['projectid']);
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getRootObjectId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return( $db->getOne( $sql->query ) );
+ }
+
+
+ function getOtherFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE is_folder=1'.
+ ' and id != {objectid} '.
+ ' AND projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getAllFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE is_folder=1'.
+ ' AND projectid={projectid}' );
+
+ if ( !isset($this->projectid) )
+ $sql->setInt( 'projectid',$SESS['projectid'] );
+ else $sql->setInt( 'projectid',$this->projectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getPages()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_page=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getFiles()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_file=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getLinks()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_link=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ // Rechte für diesen Ordner hinzufügen
+ function addrights( $rights,$inherit = true )
+ {
+ global $SESS;
+
+ $SESS['rights'][$rights['projectid']][$this->folderid]['show'] = true;
+
+ if ($rights['read'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['read'] = 1;
+ if ($rights['write'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['write'] = 1;
+ if ($rights['create'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['create'] = 1;
+ if ($rights['delete'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['delete'] = 1;
+ if ($rights['publish'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['publish'] = 1;
+
+ // Rechte auf Unterordner vererben
+ // sowie für übergeordnete Ordner die Anzeige erzwingen
+ if ( $inherit )
+ {
+ // Übergeordnete Ordner ermitteln
+ $parentfolder = $this->parentObjectIds();
+
+ // Übergeordnete Ordner immer anzeigen (Schalter 'show'=true)
+ foreach( $parentfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+ }
+
+ $f = new Folder( 'null' );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+
+
+ // Unterordner ermitteln
+ //echo "Kurz vor subfolderberechnung, folderid ist ".$this->folderid.'<br>';
+ $subfolder = $this->subfolder();
+
+ // Rechte weitergeben
+ foreach( $subfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( $rights,false );
+ unset($f);
+ }
+ }
+ }
+
+
+ // Ermitteln aller übergeordneten Ordner
+ //
+ function parentfolder_bak( $with_root = false, $with_self = false )
+ {
+ $db = db_connection();
+ $this->parentfolders = array();
+
+ // Übergeordneten Ordner lesen
+ $sql = new Sql('SELECT parentid FROM {t_folder} WHERE id={folderid}');
+
+ $sql->setInt('folderid',$this->folderid);
+ $parentid = $db->getOne( $sql->query );
+
+ // Ordner ist bereits höchster Ordner
+ if ( !is_numeric($parentid))
+ {
+ // Falls Anzeige höchster oder aktueller Ordner
+ if ( $with_root && $with_self )
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $this->folderid ] = $this->filename;
+ else $this->parentfolders[ $this->folderid ] = $this->name;
+ }
+
+ return $this->parentfolders;
+ }
+
+ // Aktuellen Ordner hinzufügen
+ if ( $with_self )
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $this->folderid ] = $this->filename;
+ else $this->parentfolders[ $this->folderid ] = $this->name;
+ }
+
+ // Schleife über alle übergeordneten Ordner
+ while( is_numeric($parentid) )
+ {
+ $sql = new Sql('SELECT * FROM {t_folder} WHERE id={folderid}');
+ $sql->setInt('folderid',$parentid);
+
+ $row_folder = $db->getRow( $sql->query );
+
+ if (is_numeric($row_folder['parentid']) || $with_root)
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $parentid ] = $row_folder['filename'];
+ else $this->parentfolders[ $parentid ] = $row_folder['name'];
+ }
+
+ $parentid = $row_folder['parentid'];
+ }
+
+
+ // Reihenfolge umdrehen
+ $this->parentfolders = array_reverse($this->parentfolders,true);
+
+ return $this->parentfolders;
+ }
+
+
+ // Ermitteln aller übergeordneten Ordner
+ //
+ function parentObjectIds( $with_root = false, $with_self = false )
+ {
+ $db = db_connection();
+ $this->parentfolders = array();
+
+ // Übergeordneten Ordner lesen
+ $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
+
+ $sql->setInt('objectid',$this->objectid);
+ $parentid = $db->getOne( $sql->query );
+
+ // Ordner ist bereits höchster Ordner
+ if ( !is_numeric($parentid))
+ {
+ // Falls Anzeige höchster oder aktueller Ordner
+ if ( $with_root && $with_self )
+ {
+ $this->parentfolders[] = $this->objectid;
+ }
+
+ return $this->parentfolders;
+ }
+
+ // Aktuellen Ordner hinzufügen
+ if ( $with_self )
+ {
+ $this->parentfolders[] = $this->objectid;
+ }
+
+ // Schleife über alle übergeordneten Ordner
+ while( is_numeric($parentid) )
+ {
+ $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
+ $sql->setInt('objectid',$parentid);
+
+ $row_folder = $db->getRow( $sql->query );
+
+ if (is_numeric($row_folder['parentid']) || $with_root)
+ {
+ $this->parentfolders[] = $parentid;
+ }
+
+ $parentid = $row_folder['parentid'];
+ }
+
+
+ // Reihenfolge umdrehen
+ $this->parentfolders = array_reverse($this->parentfolders,true);
+
+ return $this->parentfolders;
+ }
+
+
+ function parentObjectFileNames( $with_root = false, $with_self = false )
+ {
+ $erg = array();
+
+ foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $erg[$oid] = $f->filename;
+ }
+
+ return $erg;
+ }
+
+ function parentObjectNames( $with_root = false, $with_self = false )
+ {
+ $erg = array();
+
+ foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $erg[$oid] = $f->name;
+ }
+ return $erg;
+ }
+
+
+ // Ermitteln aller Unterordner
+ //
+ function subfolder()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_folder=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $this->subfolders = $db->getCol( $sql->query );
+
+ return $this->subfolders;
+ }
+
+
+ // Ermitteln aller Unterordner (rekursives Absteigen)
+ //
+ function getAllSubFolderIds()
+ {
+ global $SESS;
+
+ $ids = array();
+
+ foreach( $this->getSubFolderIds() as $id )
+ {
+// echo "durchlaufe $id";
+ $ids[] = $id;
+
+ $f = new Folder( $id );
+ $f->projectid = $this->projectid;
+
+ foreach( $f->getAllSubFolderIds() as $xid )
+ {
+ $ids[] = $xid;
+ }
+ }
+
+// print_r( $ids );
+ return $ids;
+ }
+
+
+ /**
+ * Loeschen dieses Ordners.
+ * Der Ordner wird nur geloescht, wenn er keine Unterelemente mehr enthält.
+ * Zum Loeschen inklusive Unterelemente dient die Methode deleteAll()
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Nur loeschen, wenn es keine Unterelemente gibt
+ if ( count( $this->getObjectIds() ) == 0 )
+ {
+ $sql = new Sql( 'UPDATE {t_element} '.
+ ' SET folderobjectid=NULL '.
+ ' WHERE folderobjectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $sql = new Sql( 'DELETE FROM {t_folder} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+ }
+
+
+ /**
+ * Rekursives loeschen aller Inhalte
+ *
+ * Loeschen aller Inhalte dieses Ordners
+ * inclusive aller Unterelemente
+ */
+ function deleteAll()
+ {
+ $db = db_connection();
+
+ // Löschen aller Unterordner
+ foreach( $this->subfolder() as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ {
+ $folder->deleteAll();
+ }
+ }
+
+ // Löschen aller Seiten,Verknuepfungen und Dateien in
+ // diesem Ordner
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $object = new Object( $oid );
+ {
+ $object->load();
+
+ if ( $object->isPage )
+ {
+ $page = new Page( $oid );
+ $page->load();
+ $page->delete();
+ }
+
+ if ( $object->isLink )
+ {
+ $link = new Link( $oid );
+ $link->load();
+ $link->delete();
+ }
+
+ if ( $object->isFile )
+ {
+ $file = new File( $oid );
+ $file->load();
+ $file->delete();
+ }
+ }
+ }
+
+ // Zum Abschluss den aktuellen Ordner loeschen
+ $this->delete();
+ }
+
+
+ function getSubFolderIds()
+ {
+ return $this->subfolder();
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Group.class.php b/objectClasses/Group.class.php
@@ -0,0 +1,305 @@
+<?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.
+#
+
+
+class Group
+{
+ var $groupid = 0;
+ var $error = '';
+
+ var $name = '';
+ var $fullname = '';
+ var $ldap_dn;
+ var $tel;
+ var $mail;
+ var $desc;
+ var $style;
+ var $isAdmin;
+
+
+ // Konstruktor
+ function Group( $groupid='' )
+ {
+ if ( is_numeric($groupid) )
+ $this->groupid = $groupid;
+ }
+
+
+ // Lesen aller Gruppen aus der Datenbank
+ function getAll()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,name FROM {t_group}' );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Lesen Benutzer aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_group}'.
+ ' WHERE id={groupid}' );
+ $sql->setInt( 'groupid',$this->groupid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name' ];
+ }
+
+
+ // Speichern Benutzer in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = new Sql( 'UPDATE {t_group} '.
+ 'SET name = {name} '.
+ 'WHERE id={groupid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setInt ('groupid',$this->groupid );
+
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Rueckgabe aller Eigenschaften
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'groupid'=>$this->groupid );
+ }
+
+
+ // Gruppe hinzufuegen
+ function add( $name = '' )
+ {
+ $db = db_connection();
+
+ if ( $name != '' )
+ $this->name = $name;
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_group}');
+ $this->groupid = intval($db->getOne($sql->query))+1;
+
+ // Gruppe hinzufügen
+ $sql = new Sql( 'INSERT INTO {t_group} '.
+ '(id,name) VALUES( {groupid},{name} )');
+ $sql->setInt ('groupid',$this->groupid );
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ // Gruppe entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Berechtigungen zu dieser Gruppe löschen
+ foreach( Acl::getACLsFromGroupId($this->groupid) as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->delete();
+ }
+
+ // Alle Gruppenzugehörigkeiten zu dieser Gruppe löschen
+ $sql = new Sql( 'DELETE FROM {t_usergroup} '.
+ 'WHERE groupid={groupid}' );
+ $sql->setInt ('groupid',$this->groupid );
+ $res = $db->query($sql->query);
+
+ // Gruppe löschen
+ $sql = new Sql( 'DELETE FROM {t_group} '.
+ 'WHERE id={groupid}' );
+ $sql->setInt ('groupid',$this->groupid );
+ $res = $db->query($sql->query);
+ }
+
+
+ // Benutzer ermitteln, die Mitglied dieser Gruppe sind
+ function getUsers()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_user}.id,{t_user}.name FROM {t_user} '.
+ 'LEFT JOIN {t_usergroup} ON {t_usergroup}.userid={t_user}.id '.
+ 'WHERE {t_usergroup}.groupid={groupid}' );
+ $sql->setInt('groupid',$this->groupid );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Benutzer ermitteln, die *nicht* Mitglied dieser Gruppe sind
+ function getOtherUsers()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_user}.id,{t_user}.name FROM {t_user}'.
+ ' LEFT JOIN {t_usergroup} ON {t_usergroup}.userid={t_user}.id AND {t_usergroup}.groupid={groupid}'.
+ ' WHERE {t_usergroup}.groupid IS NULL' );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Benutzer einer Gruppe hinzufuegen
+ function addUser( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_usergroup}');
+ $usergroupid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql( 'INSERT INTO {t_usergroup} '.
+ ' (id,userid,groupid) '.
+ ' VALUES( {usergroupid},{userid},{groupid} )' );
+ $sql->setInt('usergroupid',$usergroupid );
+ $sql->setInt('userid' ,$userid );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ $db->query( $sql->query );
+
+ }
+
+
+ // Benutzer aus Gruppe entfernen
+ function delUser( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'DELETE FROM {t_usergroup} '.
+ ' WHERE userid={userid} AND groupid={groupid}' );
+ $sql->setInt ('userid' ,$userid );
+ $sql->setInt ('groupid' ,$this->groupid );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Alle Berechtigungen ermitteln
+ function getRights()
+ {
+ global $SESS,$conf_php;
+ $db = db_connection();
+ $var = array();
+
+ // Alle Projekte lesen
+ $sql = new Sql( 'SELECT id,name FROM {t_project}' );
+ $projects = $db->getAssoc( $sql->query );
+
+ foreach( $projects as $projectid=>$projectname )
+ {
+ $var[$projectid] = array();
+ $var[$projectid]['name'] = $projectname;
+ $var[$projectid]['folders'] = array();
+ $var[$projectid]['rights'] = array();
+
+ $sql = new Sql( 'SELECT {t_acl}.* FROM {t_acl}'.
+ ' LEFT JOIN {t_folder} ON {t_acl}.folderid = {t_folder}.id'.
+ ' WHERE {t_folder}.projectid={projectid}'.
+ ' AND {t_acl}.groupid={groupid}' );
+ $sql->setInt('projectid',$projectid );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ $acls = $db->getAll( $sql->query );
+
+ foreach( $acls as $acl )
+ {
+ $aclid = $acl['id'];
+ $folder = new Folder( $acl['folderid'] );
+ $folder->load();
+ $var[$projectid]['rights'][$aclid] = $acl;
+ $var[$projectid]['rights'][$aclid]['foldername'] = implode(' » ',$folder->parentfolder( false,true ));
+ $var[$projectid]['rights'][$aclid]['delete_url'] = 'user.'.$conf_php.'?useraction=delright&aclid='.$aclid;
+ }
+
+ $sql = new Sql( 'SELECT id FROM {t_folder}'.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$projectid);
+ $folders = $db->getCol( $sql->query );
+
+ $var[$projectid]['folders'] = array();
+
+ foreach( $folders as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ $folder->load();
+ $var[$projectid]['folders'][$folderid] = implode(' » ',$folder->parentfolder( false,true ));
+ }
+
+ asort( $var[$projectid]['folders'] );
+ }
+
+ return $var;
+ }
+
+
+ // Berechtigung der Gruppe hinzufuegen
+ function addRight( $data )
+ {
+ global $REQ,$SESS;
+ $db = db_connection();
+
+ $sql = new SQL('INSERT INTO {t_acl} '.
+ '(userid,groupid,folderid,`read`,`write`,`create`,`delete`,publish) '.
+ 'VALUES({userid},{groupid},{folderid},{read},{write},{create},{delete},{publish})');
+
+ $sql->setNull('userid');
+ $sql->setInt ('groupid',$this->groupid);
+ $sql->setInt ('projectid',$SESS['projectid']);
+ $sql->setInt ('folderid',$data['folderid']);
+
+ $sql->setInt ('read' ,$data['read' ]);
+ $sql->setInt ('write' ,$data['write' ]);
+ $sql->setInt ('create' ,$data['create' ]);
+ $sql->setInt ('delete' ,$data['delete' ]);
+ $sql->setInt ('publish',$data['publish']);
+
+ // Datenbankabfrage ausführen
+ $db->query( $sql->query );
+ }
+
+
+ // Berechtigung entfernen
+ function delRight( $aclid )
+ {
+ $sql = new SQL('DELETE FROM {t_acl} WHERE id={aclid}');
+ $sql->setInt( 'aclid',$aclid );
+
+ // Datenbankabfrage ausführen
+ $db->query( $sql->query );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Language.class.php b/objectClasses/Language.class.php
@@ -0,0 +1,227 @@
+<?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.
+#
+
+
+class Language
+{
+ var $languageid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isoCode = '';
+ var $isDefault = false;
+
+
+ // Konstruktor
+ function Language( $languageid='' )
+ {
+ global $SESS;
+
+ if ( is_numeric($languageid) )
+ $this->languageid = $languageid;
+
+ $this->projectid = $SESS['projectid'];
+ }
+
+
+ // Lesen aller Sprachen aus der Datenbank
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( "SELECT id,name FROM {t_language} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Lesen aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_language}'.
+ ' WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name'];
+ $this->isoCode = $row['isocode'];
+ if ( $row['is_default'] == '1' )
+ $this->isDefault = true;
+ else $this->isDefault = false;
+ }
+
+
+ // Speichern der Sprache in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = new Sql( 'UPDATE {t_language} '.
+ 'SET name = {name}, '.
+ ' isocode = {isocode} '.
+ 'WHERE id={languageid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setString( 'isocode' ,$this->isoCode );
+
+ $sql->setInt( 'languageid',$this->languageid );
+
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften dieser Sprache
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'isocode'=>$this->isoCode );
+ }
+
+
+ /**
+ * Neue Sprache hinzufügen
+ */
+ function add( $isocode='' )
+ {
+ global $SESS;
+ global $iso;
+ $db = db_connection();
+
+ if ( $isocode != '' )
+ {
+ // Kleiner Trick, damit "no" (Norwegen) in der .ini-Datei stehen kann
+ $isocode = str_replace('_','',$isocode);
+
+ $this->isocode = $isocode;
+ $codes = GlobalFunctions::getIsoCodes();
+ $this->name = $codes[ $isocode ];
+ }
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_language}');
+ $this->languageid = intval($db->getOne($sql->query))+1;
+
+ // Sprache hinzufügen
+ $sql = new Sql( 'INSERT INTO {t_language} '.
+ '(id,projectid,name,isocode,is_default) VALUES( {languageid},{projectid},{name},{isocode},0 )');
+ $sql->setInt ('languageid',$this->languageid );
+ $sql->setInt ('projectid' ,$this->projectid );
+ $sql->setString('name' ,$this->name );
+ $sql->setString('isocode' ,$this->isoCode );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = new Sql( 'UPDATE {t_language} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$SESS['projectid'] );
+ $db->query( $sql->query );
+
+ // Jetzt die gewünschte Sprachvariante auf Standard setzen
+ $sql = new Sql( 'UPDATE {t_language} '.
+ ' SET is_default = 1 '.
+ ' WHERE id={languageid}' );
+ $sql->setInt('languageid',$this->languageid );
+ $db->query( $sql->query );
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_language} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getOne( $sql->query );
+ }
+
+
+ // Sprache entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Sprache löschen
+// $sql = new Sql( 'SELECT COUNT(*) FROM {t_language} WHERE projectid={projectid}' );
+// $sql->setInt( 'projectid',$this->projectid );
+// $count = $db->getOne( $sql->query );
+//
+// // Nur löschen, wenn es mindestens 2 Sprachen gibt
+// if ( $count >= 2 )
+// {
+ // Inhalte mit dieser Sprache löschen
+ $sql = new Sql( 'DELETE FROM {t_value} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Inhalte mit dieser Sprache löschen
+ $sql = new Sql( 'DELETE FROM {t_name} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Sprache löschen
+ $sql = new Sql( 'DELETE FROM {t_language} WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Andere Sprache auf "Default" setzen
+ $sql = new Sql( 'SELECT id FROM {t_language} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_languageid = $db->getOne( $sql->query );
+
+ $sql = new Sql( 'UPDATE {t_language} SET is_default=1 WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$new_default_languageid );
+ $db->query( $sql->query );
+// }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Link.class.php b/objectClasses/Link.class.php
@@ -0,0 +1,171 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2003/10/27 23:21:55 dankert
+// Methode(n) hinzugefügt: savevalue(), save()
+//
+// ---------------------------------------------------------------------------
+
+
+class Link extends Object
+{
+ var $linkid;
+ var $linkedObjectId = 0;
+ var $url = '';
+ var $isLinkToUrl = false;
+ var $isLinkToObject = false;
+
+ function Link( $objectid='' )
+ {
+ $this->Object( $objectid );
+ $this->isLink = true;
+ $this->isLinkToObject = false;
+ }
+
+
+ // Lesen der Verknüpfung aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT *'.
+ ' FROM {t_link}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $db->getRow( $sql->query );
+
+ $this->url = $row['url'];
+ $this->linkedObjectId = $row['link_objectid'];
+
+ if ( is_numeric( $this->linkedObjectId ) )
+ {
+ $this->isLinkToUrl = false;
+ $this->isLinkToObject = true;
+ }
+ else
+ {
+ $this->isLinkToUrl = true;
+ $this->isLinkToObject = false;
+ }
+
+ $this->objectLoad();
+ }
+
+
+
+ function delete()
+ {
+ $db = db_connection();
+
+ // Verknüpfung löschen
+ $sql = new Sql( 'DELETE FROM {t_link} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+
+
+
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_link} SET '.
+ ' url = {url},'.
+ ' link_objectid = {linkobjectid}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt ('objectid' ,$this->objectid );
+
+ if ( $this->isLinkToObject )
+ {
+ $sql->setInt ('linkobjectid',$this->linkedObjectId );
+ $sql->setNull('url' );
+ }
+ else
+ {
+ $sql->setNull ('linkobjectid');
+ $sql->setString('url',$this->url );
+ }
+
+ $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ Array( 'objectid' =>$this->objectid,
+ 'linkobjectid' =>$this->linkedObjectId,
+ 'url' =>$this->url,
+ 'isLinkToUrl' =>$this->isLinkToUrl,
+ 'isLinkToObject' =>$this->isLinkToObject) );
+ }
+
+
+ function getType()
+ {
+ if ( $this->isLinkToObject )
+ return 'link';
+ else return 'url';
+ }
+
+
+ function add()
+ {
+ $this->objectAdd();
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_link}');
+ $this->linkid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_link}'.
+ ' (id,objectid,url,link_objectid)'.
+ ' VALUES( {linkid},{objectid},{url},{linkobjectid} )' );
+ $sql->setInt ('linkid' ,$this->linkid );
+ $sql->setInt ('objectid' ,$this->objectid );
+
+ if ( $this->isLinkToObject )
+ {
+ $sql->setInt ('linkobjectid',$this->linkedObjectId );
+ $sql->setNull('url' );
+ }
+ else
+ {
+ $sql->setNull ('linkobjectid');
+ $sql->setString('url',$this->url );
+ }
+
+ $db->query( $sql->query );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Model.class.php b/objectClasses/Model.class.php
@@ -0,0 +1,197 @@
+<?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.
+#
+
+
+class Model
+{
+ var $modelid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isDefault = false;
+
+
+ // Konstruktor
+ function Model( $modelid='' )
+ {
+ global $SESS;
+
+ if ( is_numeric($modelid) )
+ $this->modelid = $modelid;
+
+ $this->projectid = $SESS['projectid'];
+ }
+
+
+ // Lesen aller Projektmodelle aus der Datenbank
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( "SELECT id,name FROM {t_model} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( isset($this) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Lesen aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_model}'.
+ ' WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$this->modelid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name'];
+
+ if ( $row['is_default'] == '1' )
+ $this->isDefault = true;
+ else $this->isDefault = false;
+ }
+
+
+ // Speichern der Sprache in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET name = {name} '.
+ ' WHERE id={modelid}' );
+ $sql->setString( 'name' ,$this->name );
+
+ $sql->setInt( 'modelid',$this->modelid );
+
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ function getProperties()
+ {
+ return Array( 'name'=>$this->name );
+ }
+
+
+ // Modell hinzufuegen
+ function add( $name = '' )
+ {
+ if ( $name != '' )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_model}');
+ $this->modelid = intval($db->getOne($sql->query))+1;
+
+ // Modell hinzufügen
+ $sql = new Sql( 'INSERT INTO {t_model} '.
+ "(id,projectid,name,extension,selflink,is_default) VALUES( {modelid},{projectid},{name},'',0,0 )");
+
+ $sql->setInt ('modelid' ,$this->modelid );
+ $sql->setInt ('projectid',$this->projectid );
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_model} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getOne( $sql->query );
+ }
+
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$this->projectid );
+ $db->query( $sql->query );
+
+ // Jetzt die gewünschte Sprachvariante auf Standard setzen
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET is_default = 1 '.
+ ' WHERE id={modelid}' );
+ $sql->setInt('modelid',$this->modelid );
+ $db->query( $sql->query );
+ }
+
+
+ // Modell entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+// $sql = new Sql( 'SELECT COUNT(*) FROM {t_model} WHERE projectid={projectid}' );
+// $sql->setInt( 'projectid',$this->projectid );
+// $count = $db->getOne( $sql->query );
+//
+// // Nur löschen, wenn es mindestens 2 Modelle gibt
+// if ( $count >= 2 )
+// {
+ // Modell löschen
+ $sql = new Sql( 'DELETE FROM {t_model} WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$this->modelid );
+ $db->query( $sql->query );
+
+ // Anderes Modell auf "Default" setzen
+ $sql = new Sql( 'SELECT id FROM {t_model} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_modelid = $db->getOne( $sql->query );
+
+ $sql = new Sql( 'UPDATE {t_model} SET is_default=1 WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$new_default_modelid );
+ $db->query( $sql->query );
+// }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Object.class.php b/objectClasses/Object.class.php
@@ -0,0 +1,915 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.2 2004/03/20 14:15:07 dankert
+// Kommentare
+//
+// Revision 1.1 2004/03/20 01:47:33 dankert
+// *** empty log message ***
+//
+// ---------------------------------------------------------------------------
+
+/**
+ * Darstellung eines Objektes im Projektbaum.
+ * Dieses Objekt stellt eines der 4 Unterobjekte Ordner,Datei,Link oder Seite dar.
+ *
+ * @version $Revision$
+ * @author $Author$
+ */
+class Object
+{
+ /** eindeutige ID dieses Objektes
+ * @see #$objectid
+ * @type Integer
+ */
+ var $id;
+
+ /** eindeutige ID dieses Objektes
+ * @type Integer
+ */
+ var $objectid;
+
+ /** Objekt-ID des Ordners, in dem sich dieses Objekt befindet
+ * Kann "null" oder "0" sein, wenn es sich um den Wurzelordner des Projektes handelt
+ * @see #$isRoot
+ * @type Integer
+ */
+ var $parentid;
+
+ /** Physikalischer Dateiname des Objektes (bei Links nicht gefüllt)
+ * <em>enthält nicht die Dateinamen-Erweiterung</em>
+ * @type String
+ */
+ var $filename = '';
+
+ /** Logischer (sprachabhaengiger) Name des Objektes
+ * (wird in Tabelle <code>name</code> abgelegt)
+ * @type String
+ */
+ var $name = '';
+
+ /** Logische (sprachabhaengige) Beschreibung des Objektes
+ * (wird in Tabelle <code>name</code> abgelegt)
+ * @type String
+ */
+ var $desc = '';
+
+ /** Zeitpunkt der Erstellung. Die Variable beinhaltet den Unix-Timestamp.
+ * @type Integer
+ */
+ var $create_date;
+
+ /** Benutzer-ID welche dieses Objekt erstellt hat.
+ * @type Integer
+ */
+ var $create_userid;
+
+ /** Zeitpunkt der letzten Aenderung. Die Variable beinhaltet den Unix-Timestamp.
+ * @type Integer
+ */
+ var $lastchange_date;
+
+ /** Benutzer-ID welche dieses Objekt zuletzt geaendert hat.
+ * @type Integer
+ */
+ var $lastchange_userid;
+
+ /**
+ * Kennzeichen, ob Objekt ein Ordner ist
+ * @type Boolean
+ */
+ var $isFolder = false;
+
+ /**
+ * Kennzeichen, ob Objekt eine binaere Datei ist
+ * @type Boolean
+ */
+ var $isFile = false;
+
+ /**
+ * Kennzeichen, ob Objekt eine Seite ist
+ * @type Boolean
+ */
+ var $isPage = false;
+
+ /**
+ * Kennzeichen, ob Objekt eine Verknuepfung (Link) ist
+ * @type Boolean
+ */
+ var $isLink = false;
+
+ /** Kennzeichen ob Objekt den Wurzelordner des Projektes darstellt (parentid ist dann NULL)
+ * @type Boolean
+ */
+ var $isRoot = false;
+
+ /** Sprach-ID
+ * @see Language
+ * @type Integer
+ */
+ var $languageid;
+
+ /**
+ * Projektmodell-ID
+ * @see Projectmodel
+ * @type Integer
+ */
+ var $modelid;
+
+ /**
+ * Projekt-ID
+ * @see Project
+ * @type Integer
+ */
+ var $projectid;
+
+ /**
+ * Dateiname der temporaeren Datei
+ * @type String
+ */
+ var $tmpfile;
+
+
+ /** <strong>Konstruktor</strong>
+ * Füllen des neuen Objektes mit Init-Werten
+ * Es werden die Standardwerte aus der Session benutzt, um
+ * Sprach-ID, Projektmodell-Id und Projekt-ID zu setzen
+ *
+ * @param Integer Objekt-ID (optional)
+ */
+ function Object($objectid = '')
+ {
+ global $SESS;
+
+ if (is_numeric($objectid))
+ {
+ $this->objectid = $objectid;
+ $this->id = $objectid;
+ }
+
+ if ( isset($SESS['languageid']) )
+ $this->languageid = $SESS['languageid'];
+ else $this->languageid = 0;
+
+ if ( isset($SESS['modelid']) )
+ $this->modelid = $SESS['modelid'];
+ else $this->modelid = 0;
+
+ if ( isset($SESS['projectid']) )
+ $this->projectid = $SESS['projectid'];
+ }
+
+
+ /**
+ * Lesen aller Objekte aus dem aktuellen Projekt
+ * @return Array Alle Objekt-IDs des aktuellen Projektes
+ */
+ function getAllObjectIds()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ if ( !isset($this->projectid) )
+ $projectid = $SESS['projectid'];
+ else $projectid = $this->projectid;
+
+ $sql = new Sql('SELECT id from {t_object} '.
+ ' WHERE projectid={projectid}');
+ $sql->setInt('projectid', $projectid);
+
+ return $db->getCol($sql->query);
+ }
+
+
+ // Kompletten Dateinamen des Objektes erzeugen
+ function full_filename()
+ {
+ $path = $this->path();
+
+ if ($path != '')
+ $path.= '/';
+
+ $path.= $this->filename();
+
+// if ($this->extension() != '')
+// $path.= '.'.$this->extension();
+
+ return $path;
+ }
+
+ /**
+ * Prüfen einer Berechtigung zu diesem Objekt
+ */
+ function checkRight( $type )
+ {
+ return true;
+ }
+
+
+ /**
+ * Prüfen einer Berechtigung zu diesem Objekt
+ */
+ function hasRight( $type )
+ {
+ global $SESS;
+
+ // Administratoren dürfen alles
+ if ($SESS['user']['is_admin'] == '1')
+ return true;
+
+ $user = new user( $SESS['user']['id'] );
+ $groups = $user->getGroupIds();
+
+ foreach( array_merge($this->getAclIds(),$this->getInheritedAclIds()) as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+
+ if ( $user->userid == $acl->userid ||
+ in_array( $acl->groupid,$groups ) )
+ {
+ if ( $acl->$type )
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Typ des Objektes ermitteln
+ *
+ * @return String der Typ des Objektes entweder 'folder','file','page' oder 'link'
+ */
+ function getType()
+ {
+ if ($this->isFolder)
+ return 'folder';
+ if ($this->isFile)
+ return 'file';
+ if ($this->isPage)
+ return 'page';
+ if ($this->isLink)
+ return 'link';
+
+ return 'unknown';
+ }
+
+
+ function getProperties()
+ {
+ return Array( 'id' =>$this->objectid,
+ 'objectid' =>$this->objectid,
+ 'parentid' =>$this->parentid,
+ 'filename' =>$this->filename,
+ 'name' =>$this->name,
+ 'desc' =>$this->desc,
+ 'description' =>$this->desc,
+ 'create_date' =>$this->create_date,
+ 'create_userid' =>$this->create_userid,
+ 'lastchange_date' =>$this->lastchange_date,
+ 'lastchange_userid'=>$this->lastchange_userid,
+ 'isFolder' =>$this->isFolder,
+ 'isFile' =>$this->isFile,
+ 'isLink' =>$this->isLink,
+ 'isPage' =>$this->isPage,
+ 'isRoot' =>$this->isRoot,
+ 'languageid' =>$this->languageid,
+ 'modelid' =>$this->modelid,
+ 'projectid' =>$this->projectid );
+ }
+
+
+ /**
+ * Ermitteln des physikalischen Dateipfades, in dem sich das Objekt befindet
+ * @return String Pfadangabe, z.B. 'pfad/zu/objekt'
+ */
+ function path()
+ {
+ $folder = new Folder($this->parentid);
+
+ return implode('/', $folder->parentObjectFileNames(false, true));
+ }
+
+
+ /**
+ * Ermitteln des Dateinamens und Rueckgabe desselben
+ * @return String Dateiname
+ */
+ function filename()
+ {
+ if ($this->filename != '')
+ return $this->filename;
+
+ $this->load();
+
+ return $this->filename;
+ }
+
+ /**
+ * Lesen der Eigenschaften aus der Datenbank
+ * Es werden
+ * - die sprachunabhängigen Daten wie Dateiname, Typ sowie Erstellungs- und Änderungsdatum geladen
+ * - die sprachabhängigen Daten wie Name und Beschreibung geladen
+ */
+ function objectLoad()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT {t_object}.*,{t_name}.name,{t_name}.descr'.' FROM {t_object}'.' LEFT JOIN {t_name} ON {t_object}.id={t_name}.objectid AND {t_name}.languageid={languageid} '.' WHERE {t_object}.id={objectid}');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $this->languageid);
+ $row = $db->getRow($sql->query);
+
+ if (count($row) == 0)
+ die('fatal: objectid not found: '.$this->objectid);
+
+ $this->parentid = $row['parentid'];
+
+ if ( intval($this->parentid) == 0 )
+ $this->isRoot = true;
+ else $this->isroot = false;
+
+ $this->filename = trim(strtolower($row['filename']));
+
+ // Dateiname muss gueltig sein,
+ // ungueltige Zeichen werden entfernt
+ $gueltig = 'abcdefghijklmnopqrstuvwxyz0123456789-_.';
+ $tmp = strtr($this->filename, $gueltig, str_repeat('#', strlen($gueltig)));
+ $this->filename = strtr($this->filename, $tmp, str_repeat('_', strlen($tmp)));
+
+ // Falls leer, id<objectnr> als Dateinamen verwenden
+ if ($this->filename == '')
+ $this->filename = $this->objectid;
+
+ $this->create_date = $row['create_date'];
+ $this->create_userid = $row['create_userid'];
+ $this->lastchange_date = $row['lastchange_date'];
+ $this->lastchange_userid = $row['lastchange_userid'];
+
+ $this->isFolder = false;
+ $this->isFile = false;
+ $this->isPage = false;
+ $this->isLink = false;
+
+ $this->projectid = $row['projectid'];
+
+ if ($row['is_folder'] == '1')
+ $this->isFolder = true;
+
+ if ($row['is_file'] == '1')
+ $this->isFile = true;
+
+ if ($row['is_page'] == '1')
+ $this->isPage = true;
+
+ if ($row['is_link'] == '1')
+ $this->isLink = true;
+
+ if ( $this->isRoot )
+ {
+ $project = new Project( $this->projectid );
+ $project->load();
+ $this->name = $project->name;
+ $this->desc = '';
+ }
+ else
+ {
+ $this->name = $row['name' ];
+ $this->desc = $row['descr'];
+ }
+
+
+ // Falls leer, id<objectnr> als Dateinamen verwenden
+ if ($this->name == '')
+ $this->name = $this->filename;
+ }
+
+
+ /**
+ * Laden des Objektes
+ * @deprecated bitte objectLoad() benutzen
+ */
+ function load()
+ {
+ $this->objectLoad();
+ }
+
+ /**
+ * Lesen von logischem Namen und Beschreibung
+ * Diese Eigenschaften sind sprachabhaengig und stehen deswegen in einer
+ * separaten Tabelle
+ * @access private
+ */
+ function objectLoadName()
+ {
+ die();
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT *'.' FROM {t_name}'.' WHERE objectid={objectid}'.' AND languageid={languageid}');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $this->languageid);
+ $res = $db->query($sql->query);
+
+ if ($res->numRows() == 0)
+ {
+ // Wenn Name in dieser Sprache nicht vorhanden, dann irgendeinen Namen lesen
+ $sql->setQuery('SELECT *'.' FROM {t_name}'.' WHERE objectid={objectid}'.' AND name != {blank}');
+ $sql->setString('blank', '');
+ $res = $db->query($sql->query);
+ }
+ $row = $res->fetchRow();
+
+ $this->name = $row['name'];
+ $this->desc = $row['description'];
+
+ // Falls leer, id<objectnr> als Dateinamen verwenden
+ if ($this->name == '')
+ $this->name = $this->filename;
+ }
+
+ /**
+ * Eigenschaften des Objektes in Datenbank speichern
+ */
+ function objectSave()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_object} SET '.
+ ' parentid={parentid},'.
+ ' lastchange_date = {time} ,'.
+ ' lastchange_userid = {userid},'.
+ ' filename = {filename}'.
+ ' WHERE id={objectid}');
+
+ if ( $this->isRoot )
+ $sql->setNull('parentid');
+ else $sql->setInt ('parentid',$this->parentid );
+
+ $sql->setInt ('objectid', $this->objectid);
+ $sql->setString('filename', $this->filename);
+ $sql->setInt ('time' , time());
+ $sql->setInt ('userid' , $SESS['user']['id']);
+
+ $db->query($sql->query);
+
+ // Nur wenn nicht Wurzelordner
+ if ( !$this->isroot )
+ {
+ if ( $this->name == '' )
+ $this->name = $this->filename;
+
+ $this->objectSaveName();
+ }
+ }
+
+ /**
+ * Logischen Namen und Beschreibung des Objektes in Datenbank speichern
+ * (wird von objectSave() automatisch aufgerufen)
+ *
+ * @access private
+ */
+ function ObjectSaveName()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT COUNT(*) FROM {t_name} '.' WHERE objectid ={objectid}'.' AND languageid={languageid}');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $SESS['languageid']);
+ $count = $db->getOne($sql->query);
+
+ if ($count > 0)
+ {
+ $sql->setQuery('UPDATE {t_name} SET '.
+ ' name = {name},'.
+ ' descr = {desc} '.
+ ' WHERE objectid ={objectid}'.
+ ' AND languageid={languageid}');
+ $sql->setString('name', $this->name);
+ $sql->setString('desc', $this->desc);
+ $db->query($sql->query);
+ }
+ else
+ {
+ $sql = new Sql('SELECT MAX(id) FROM {t_name}');
+ $nameid = intval($db->getOne($sql->query))+1;
+
+ $sql->setQuery('INSERT INTO {t_name}'.' (id,objectid,languageid,name,descr)'.' VALUES( {nameid},{objectid},{languageid},{name},{desc} )');
+ $sql->setInt ('objectid' , $this->objectid );
+ $sql->setInt ('languageid', $this->languageid );
+ $sql->setInt ('nameid', $nameid );
+ $sql->setString('name' , $this->name);
+ $sql->setString('desc' , $this->desc);
+ $db->query($sql->query);
+ }
+ }
+
+ /**
+ * Objekt loeschen. Es muss sichergestellt sein, dass auch das Unterobjekt geloeschet wird.
+ * Diese Methode wird daher normalerweise nur vom Unterobjekt augerufen
+ * @access protected
+ */
+ function objectDelete()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_element} '.
+ ' SET default_objectid=NULL '.
+ ' WHERE default_objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $sql = new Sql( 'UPDATE {t_value} '.
+ ' SET linkobjectid=NULL '.
+ ' WHERE linkobjectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+
+ // Objekt-Namen löschen
+ $sql = new Sql('DELETE FROM {t_name} WHERE objectid={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $db->query($sql->query);
+
+ // Objekt löschen
+ $sql = new Sql('DELETE FROM {t_object} WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $db->query($sql->query);
+
+ $this->deleteAllACLs();
+ }
+
+
+ /**
+ * Objekt hinzufuegen
+ */
+ function objectAdd()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Neue Objekt-Id bestimmen
+ $sql = new Sql('SELECT MAX(id) FROM {t_object}');
+ $this->objectid = intval($db->getOne($sql->query))+1;
+
+ if ( $this->filename == '' )
+ $this->filename = $this->objectid;
+
+ $sql = new Sql('SELECT COUNT(*) FROM {t_object}'.' WHERE parentid={parentid} AND filename={filename}');
+ $sql->setString('filename', $this->filename);
+
+ if ( $this->isRoot )
+ $sql->setNull('parentid');
+ else $sql->setInt ('parentid',$this->parentid );
+
+ // Falls Objekt mit diesem Dateinamen bereits existiert, dann Dateinamen aendern
+ if ($db->getOne($sql->query) > 0)
+ {
+ $this->filename .= md5(microtime());
+ }
+
+ $sql = new Sql('INSERT INTO {t_object}'.
+ ' (id,parentid,projectid,filename,orderid,create_date,create_userid,lastchange_date,lastchange_userid,is_folder,is_file,is_page,is_link)'.
+ ' VALUES( {objectid},{parentid},{projectid},{filename},{orderid},{time},{userid},{time},{userid},{is_folder},{is_file},{is_page},{is_link} )');
+
+ if ( $this->isRoot )
+ $sql->setNull('parentid');
+ else $sql->setInt ('parentid',$this->parentid );
+
+ $sql->setInt ('objectid' , $this->objectid );
+ $sql->setString('filename' , $this->filename );
+ $sql->setString('projectid', $this->projectid);
+ $sql->setInt ('orderid' , 99999 );
+ $sql->setInt ('time' , time() );
+ $sql->setInt ('userid' , $SESS['user']['id']);
+
+ $sql->setBoolean('is_folder',$this->isFolder);
+ $sql->setBoolean('is_file', $this->isFile);
+ $sql->setBoolean('is_page', $this->isPage);
+ $sql->setBoolean('is_link', $this->isLink);
+
+ $db->query($sql->query);
+
+ $this->objectSaveName();
+ }
+
+
+ function getAclIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE objectid={objectid}'.
+ ' AND ( languageid IS NULL OR '.
+ ' languageid = {languageid} )'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('languageid',$this->languageid);
+ $sql->setInt('objectid' ,$this->objectid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getAllAclIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE objectid={objectid}'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$this->objectid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getInheritedAclIds()
+ {
+ $acls = array();
+
+ if ( $this->getType() == 'unknown' )
+ $this->load();
+
+ // Root-Ordner erhaelt keine Vererbungen
+ if ( $this->isRoot )
+ return $acls;
+
+ $db = db_connection();
+ $folder = new Folder( $this->parentid );
+
+ foreach( $folder->parentObjectIds(true,true) as $oid )
+ {
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE objectid={objectid}'.
+ ' AND is_transmit = 1'.
+ ' AND ( languageid IS NULL OR '.
+ ' languageid = {languageid} )'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$oid);
+ $sql->setInt('languageid',$this->languageid);
+ $acls = array_merge( $acls,$db->getCol( $sql->query ) );
+ }
+
+ return $acls;
+ }
+
+
+ function getAllInheritedAclIds()
+ {
+ $acls = array();
+
+ if ( $this->getType() == 'unknown' )
+ $this->load();
+
+ // Root-Ordner erhaelt keine Vererbungen
+ if ( $this->isRoot )
+ return $acls;
+
+ $db = db_connection();
+ $folder = new Folder( $this->parentid );
+
+ foreach( $folder->parentObjectIds(true,true) as $oid )
+ {
+ $sql = new Sql( 'SELECT id FROM {t_acl} '.
+ ' WHERE objectid={objectid}'.
+ ' AND is_transmit = 1'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$oid);
+ $acls = array_merge( $acls,$db->getCol( $sql->query ) );
+ }
+
+ return $acls;
+ }
+
+
+ /**
+ * Entfernen aller ACLs zu diesem Objekt
+ * @access private
+ */
+ function deleteAllACLs()
+ {
+ foreach( $this->getAllAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->delete();
+ }
+ }
+
+
+ /**
+ * Dateinamen der temporaeren Datei bestimmen
+ */
+ function tmpfile()
+ {
+ global $conf_tmpdir;
+
+ $this->tmpfile = $conf_tmpdir.'/tmp_file'.$this->objectid.'.tmp';
+ //$this->tmpfile = $conf_tmpdir.'/'.md5('f'.$this->fileid).'.tmp';
+
+ return $this->tmpfile;
+ }
+
+
+ /**
+ * Reihenfolge-Sequenznr. dieses Objektes neu speichern
+ * die Nr. wird sofort in der Datenbank gespeichert.
+ *
+ * @param Integer neue Sequenz-Nr.
+ */
+ function setOrderId( $orderid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_object} '.' SET orderid={orderid}'.' WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->setInt('orderid', $orderid);
+
+ $db->query($sql->query);
+ }
+
+
+ /**
+ * Übergeordnete Objekt-ID dieses Objektes neu speichern
+ * die Nr. wird sofort in der Datenbank gespeichert.
+ *
+ * @param Integer Übergeordnete Objekt-ID
+ */
+ function setParentId( $parentid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_object} '.' SET parentid={parentid}'.' WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->setInt('parentid', $parentid);
+
+ $db->query($sql->query);
+ }
+
+
+ function getDependentObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_page}.objectid FROM {t_value}'.
+ ' LEFT JOIN {t_page} '.
+ ' ON {t_value}.pageid = {t_page}.id '.
+ ' WHERE linkobjectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einem bestimmten Namen ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByFileName( $text )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_object} '.
+ ' WHERE filename LIKE {filename}'.
+ ' AND projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setString( 'filename','%'.$text.'%' );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einem Namen ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByName( $text )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_object}.id FROM {t_object} '.
+ ' LEFT JOIN {t_name} '.
+ ' ON {t_object}.id={t_name}.objectid'.
+ ' WHERE {t_name}.name LIKE {name}'.
+ ' AND {t_name}.languageid={languageid}'.
+ ' AND {t_object}.projectid={projectid}' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'name' ,'%'.$text.'%' );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einer Beschreibung ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByDescription( $text )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_object}.id FROM {t_object} '.
+ ' LEFT JOIN {t_name} '.
+ ' ON {t_object}.id={t_name}.objectid'.
+ ' WHERE {t_name}.descr LIKE {desc}'.
+ ' AND {t_name}.languageid={languageid}'.
+ ' AND {t_object}.projectid={projectid}' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'desc' ,'%'.$text.'%' );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der Erstellung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByCreateUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_object} '.
+ ' WHERE create_userid={userid}'.
+ ' AND projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der letzten Änderung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByLastChangeUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_object} '.
+ ' WHERE lastchange_userid={userid}'.
+ ' AND projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Gibt true zurück, wenn die angegebene Objekt-ID existiert
+ * @param Integer Objekt-ID
+ * @return Boolean
+ */
+ function isObjectId( $id )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_object} '.
+ ' WHERE id={objectid}'.
+ ' AND projectid={projectid}' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'objectid' ,$id );
+
+ return ($db->getOne($sql->query) == intval($id) );
+ }
+
+
+
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Page.class.php b/objectClasses/Page.class.php
@@ -0,0 +1,600 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2004/03/20 14:15:00 dankert
+// Kommentare
+//
+// ---------------------------------------------------------------------------
+
+
+class Page extends Object
+{
+ var $pageid;
+ var $templateid;
+
+ var $simple = false;
+ var $public = false;
+
+ var $el = array();
+
+ var $icons = false;
+ var $src = '';
+ var $tmpfile;
+ var $edit = false;
+
+ var $content_negotiation = false;
+ var $cut_index = false;
+ var $default_language = false;
+ var $link = false;
+
+ var $log_filenames = array();
+ var $projectmodelid = 0;
+
+ var $publish = null;
+
+
+ function Page( $objectid='' )
+ {
+ $this->Object( $objectid );
+ $this->isPage = true;
+ }
+
+
+ function tmpfile()
+ {
+ $this->tmpfile = parent::tmpfile();
+ $this->tmpfile .= '.php';
+ return $this->tmpfile;
+ }
+
+
+ /**
+ * Ermitteln der Objekt-ID (Tabelle object) anhand der Seiten-ID (Tablle page)
+ *
+ * @deprecated pageid sollte nicht mehr benutzt werden
+ * @return Integer objectid
+ */
+ function getObjectIdFromPageId( $pageid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT objectid FROM {t_page} '.
+ ' WHERE id={pageid}' );
+ $sql->setInt('pageid',$pageid);
+
+ return $db->getOne( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln der Seiten-ID anhand der Objekt-ID
+ *
+ * @deprecated pageid sollte nicht mehr benutzt werden
+ * @return Integer pageid
+ */
+ function getPageIdFromObjectId( $objectid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_page} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$objectid);
+
+ return $db->getOne( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ Array('full_filename'=>$this->full_filename(),
+ 'pageid' =>$this->pageid,
+ 'templateid' =>$this->templateid ) );
+ }
+
+
+ /**
+ * Ermitteln der Ordner, in dem sich die Seite befindet
+ * @return Array
+ */
+ function parentfolder()
+ {
+ $folder = new Folder();
+ $folder->folderid = $this->folderid;
+
+ return $folder->parentfolder( false,false );
+ }
+
+
+/*
+ function path_to_file( $fileid )
+ {
+ global $conf_php;
+
+ if ( $this->public )
+ {
+ $inhalt = $this->up_path();
+
+ $file = new File();
+ $file->fileid = $fileid;
+ $file->load();
+
+ $inhalt .= $file->full_filename();
+ }
+ else
+ {
+ $inhalt = "file.$conf_php?fileaction=show&fileid=".$fileid;
+ $inhalt = sid($inhalt);
+ }
+
+ return $inhalt;
+ }
+*/
+
+ /**
+ * Ermittelt den Pfad zu einem beliebigen Objekt
+ *
+ * @param Integer Objekt-ID des Zielobjektes
+ * @return String Relative Link-angabe, Beispiel: '../../pfad/datei.jpeg'
+ */
+ function path_to_object( $objectid )
+ {
+ global $conf_php,
+ $SESS;
+ $inhalt = '';
+ $object = new Object( $objectid );
+ $object->objectLoad();
+
+
+ if ( $this->public )
+ {
+ switch( $object->getType() )
+ {
+ case 'file':
+
+ $inhalt = $this->up_path();
+
+ $f = new File( $objectid );
+ $f->load();
+ $inhalt .= $f->full_filename();
+ break;
+
+ case 'page':
+
+ $inhalt = $this->up_path();
+
+ $p = new Page( $objectid );
+ $p->languageid = $this->languageid;
+ $p->load();
+ $inhalt .= $p->full_filename();
+ break;
+
+ case 'link':
+ $link = new Link( $objectid );
+ $link->load();
+
+ if ( $link->isLinkToObject )
+ {
+ $linkedObject = new Object( $link->linkedObjectId );
+ $linkedObject->load();
+
+ switch( $linkedObject->getType() )
+ {
+ case 'file':
+ $f = new File( $linkedObjectId );
+ $f->load();
+ $inhalt = $this->up_path();
+ $inhalt .= $f->full_filename();
+ break;
+
+ case 'page':
+ $p = new Page( $linkedObjectId );
+ $p->languageid = $this->languageid;
+ $p->load();
+ $inhalt = $this->up_path();
+ $inhalt .= $p->full_filename();
+ break;
+ }
+ }
+ else
+ {
+ $inhalt = $link->url;
+ }
+ break;
+ }
+ }
+ else
+ {
+ // Interne Verlinkungen in der Seitenvorschau
+ switch( $object->getType() )
+ {
+ case 'file':
+ $inhalt = "do.$conf_php?action=file&subaction=show&objectid=".$objectid;
+ break;
+
+ case 'page':
+ $inhalt = "do.$conf_php?action=page&objectid=".$objectid;
+ break;
+
+ case 'link':
+ $link = new Link( $objectid );
+ $link->load();
+
+ if ( $link->isLinkToObject )
+ {
+ $linkedObject = new Object( $link->linkedObjectId );
+ $linkedObject->load();
+
+ switch( $linkedObject->getType() )
+ {
+ case 'file':
+ $inhalt = "do.$conf_php?action=file&subaction=show&objectid=".$link->linkedObjectId;
+ break;
+
+ case 'page':
+ $inhalt = "do.$conf_php?action=page&objectid=".$link->linkedObjectId;
+ break;
+ }
+ }
+ else
+ {
+ $inhalt = $link->url;
+ }
+ break;
+ }
+ }
+
+ return $inhalt;
+ }
+
+
+
+ /**
+ * Erzeugt Präfix für eine relative Pfadangabe
+ * Beispiel: Seite liegt in Ordner /pfad/pfad => '../../'
+ *
+ * @return String Pfadangabe
+ * @access private
+ */
+ function up_path()
+ {
+ $folder = new Folder( $this->parentid );
+ $folder->load();
+ $folder->parentObjectIds(false,true);
+ $f = count( $folder->parentfolders );
+
+ //echo $this->parentid;
+ //print_r( $folder->parentfolders );
+
+ if ( $f == 0 )
+ {
+ return './';
+ }
+ else
+ {
+ return str_repeat( '../',$f );
+ }
+ }
+
+
+ /**
+ * getter-Methode für den Dateinamen
+ *
+ * @return String Dateiname
+ */
+ function filename()
+ {
+ return $this->filename;
+ }
+
+
+ /**
+ * Eine Seite hinzufuegen
+ */
+ function add()
+ {
+ $db = db_connection();
+
+ $this->objectAdd(); // Hinzufügen von Objekt (dabei wird Objekt-ID ermittelt)
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_page}');
+ $this->pageid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_page}'.
+ ' (id,objectid,templateid)'.
+ ' VALUES( {pageid},{objectid},{templateid} )' );
+ $sql->setInt ('pageid' ,$this->pageid );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setInt ('templateid',$this->templateid );
+
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Seite laden
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_page} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $row = $db->getRow( $sql->query );
+
+ $this->pageid = $row['id' ];
+ $this->templateid = $row['templateid'];
+
+ $this->objectLoad();
+ }
+
+
+ function delete()
+ {
+ global $db;
+
+ $sql = new Sql( 'DELETE FROM {t_value} '.
+ ' WHERE pageid={pageid}' );
+ $sql->setInt('pageid',$this->pageid);
+ $db->query( $sql->query );
+
+ $sql = new Sql( 'DELETE FROM {t_page} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+
+
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_page}'.
+ ' SET templateid ={templateid}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('templateid' ,$this->templateid);
+ $sql->setInt('objectid' ,$this->objectid );
+ $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Seite
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/seite.en.html'
+ */
+ function full_filename()
+ {
+ $filename = parent::full_filename();
+
+ if ( !$this->default_language )
+ {
+ $l = new Language( $this->languageid );
+ $l->load();
+ $filename .= '.'.$l->isoCode;
+ }
+
+ $t = new Template( $this->templateid );
+ $t->projectmodelid = $this->modelid;
+ $t->load();
+ $filename .= '.'.$t->extension;
+
+ if ( $this->default_language )
+ {
+ $filename .= '.'.$t->extension;
+ }
+
+
+ return $filename;
+ }
+
+
+ function language_filename()
+ {
+ global $SESS;
+
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT COUNT(*) FROM {t_language}'.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$SESS['projectid']);
+
+ if ( $db->getOne( $sql->query ) == 1 )
+ {
+ // Wenn es nur eine Sprache gibt, keine Sprachangabe im Dateinamen
+ return '';
+ }
+ else
+ {
+ $sql = new Sql( 'SELECT isocode FROM {t_language}'.
+ ' WHERE id={languageid}' );
+ $sql->setInt('languageid',$this->languageid);
+ $isocode = $db->getOne( $sql->query );
+
+ return strtolower( $isocode );
+ }
+ }
+
+
+ /**
+ * Erzeugen der Inhalte zu allen Elementen dieser Seite
+ * wird von generate() aufgerufen
+ *
+ * @access private
+ */
+ function generate_elements()
+ {
+ $this->values = array();
+
+ $t = new Template( $this->templateid );
+
+ foreach( $t->getElementIds() as $elementid )
+ {
+ // neues Elementobjekt erzeugen
+ $val = new Value();
+ $val->element = new Element( $elementid );
+ $val->element->load();
+
+ $val->objectid = $this->objectid;
+ $val->pageid = Page::getPageIdFromObjectId( $this->objectid );
+ $val->languageid = $this->languageid;
+ $val->simple = $this->simple;
+ $val->modelid = $this->modelid;
+ $val->page = &$this;
+ $val->generate();
+ $this->values[$elementid] = $val;
+ }
+ }
+
+
+ /**
+ * Erzeugen des Inhaltes der gesamten Seite
+ * @return String Inhalt
+ */
+ function generate()
+ {
+
+ global $conf,
+ $conf_php,
+ $db,
+ $conf_tmpdir,
+ $sess_vars,
+ $SESS;
+
+ $this->generate_elements();
+
+ $template = new Template( $this->templateid );
+ $template->load();
+
+ $this->ext = $template->extension;
+
+ $src = $template->src;
+
+ // Ersetzen der Platzhalter durch die Element-Inhalte
+ //
+
+ foreach( $this->values as $id=>$value )
+ {
+ $inh = $value->value;
+ $src = str_replace( '{{'.$id.'}}',$inh,$src );
+
+ if ( $this->icons )
+ $src = str_replace( '{{->'.$id.'}}','<a href="do.'.$conf_php.'?action=pagelement&elementid='.$id.'&pageelementaction=edit" title="'.$value->element->desc.'" target="cms_main_main"><img src="'.$conf['directories']['themedir'].'/images/icon_el_'.$value->element->type.'.png" border="0"></a>',$src );
+ else $src = str_replace( '{{->'.$id.'}}','',$src );
+ }
+
+ $this->value = &$src;
+
+ return $this->value;
+ }
+
+
+ /**
+ * Schreiben des Seiteninhaltes in die temporaere Datei
+ */
+ function write()
+ {
+ // Schreiben der Cache-Datei
+ //
+
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->value );
+ fclose( $f );
+ }
+
+
+ /**
+ * Generieren dieser Seite in Dateisystem und/oder auf FTP-Server
+ */
+ function publish()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ if ( ! is_object($this->publish) )
+ $this->publish = new Publish();
+
+ $this->content_negotiation = $this->publish->content_negotiation;
+ $this->cut_index = $this->publish->cut_index;
+ $this->public = true;
+
+ // Schleife über alle Sprachvarianten
+ foreach( Language::getAll() as $languageid=>$x )
+ {
+ $this->languageid = $languageid;
+
+ // Schleife über alle Projektvarianten
+ foreach( Model::getAll() as $projectmodelid )
+ {
+ $this->projectmodelid = $projectmodelid;
+
+ $this->load();
+ $this->generate();
+ $this->write();
+
+ //echo $this->tmpfile().' > '.$this->full_filename().'<br>';
+ $this->publish->copy( $this->tmpfile(),$this->full_filename() );
+ }
+ }
+
+ // Bei Verwendung der Content-Negotiation wird eine Default-Variante
+ // ohne Sprachversion, aber mit doppelter Extension
+ // z.B. index.html.html erzeugt
+ if ( $this->publish->content_negotiation && count(Language::getAll())>1 )
+ {
+ $this->languageid = Language::getDefaultId();
+ $this->default_language = true;
+
+ // Schleife über alle Projektvarianten
+ foreach( Model::getAll() as $projectmodelid )
+ {
+ $this->projectmodelid = $projectmodelid;
+
+ $this->load();
+ $this->generate();
+ $this->write();
+
+ //echo $this->tmpfile().' > '.$this->full_filename().'<br>';
+ $publish->copy( $this->tmpfile(),$this->full_filename() );
+ }
+ }
+
+// $this->log_filenames = $this->publish->log_filenames;
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Project.class.php b/objectClasses/Project.class.php
@@ -0,0 +1,254 @@
+<?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.
+#
+
+
+class Project
+{
+ // Eigenschaften
+ var $projectid;
+ var $name;
+ var $target_dir;
+ var $ftp_url;
+ var $ftp_passive;
+ var $cmd_after_publish;
+ var $content_negotiation;
+ var $cut_index;
+
+ // Konstruktor
+ function Project( $projectid )
+ {
+ global $SESS;
+
+ if ( is_numeric($projectid) )
+ $this->projectid = $projectid;
+ else $this->projectid = $SESS['projectid'];
+ }
+
+
+ // Liefert alle verfügbaren Projekte
+ function getAll()
+ {
+ $db = db_connection();
+ $sql = new Sql( 'SELECT id,name FROM {t_project} '.
+ ' ORDER BY name' );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ function getLanguageIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_language}'.
+ ' WHERE projectid={projectid} ' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getModelIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_projectmodel}'.
+ ' WHERE projectid= {projectid} ' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getTemplateIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_template}'.
+ ' WHERE projectid= {projectid} ' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln des Root-Ordners zu diesem Projekt
+ */
+ function getRootObjectId()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ $sql->setInt('projectid',$this->projectid);
+
+ return( $db->getOne( $sql->query ) );
+ }
+
+
+
+ // Laden
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_project} '.
+ ' WHERE id={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name'];
+ $this->target_dir = $row['target_dir'];
+ $this->ftp_url = $row['ftp_url'];
+ $this->ftp_passive = $row['ftp_passive'];
+ $this->cmd_after_publish = $row['cmd_after_publish'];
+ $this->content_negotiation = $row['content_negotiation'];
+ $this->cut_index = $row['cut_index'];
+ }
+
+
+ // Speichern
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_project}'.
+ ' SET name = {name},'.
+ ' target_dir = {target_dir},'.
+ ' ftp_url = {ftp_url}, '.
+ ' ftp_passive = {ftp_passive}, '.
+ ' cut_index = {cut_index}, '.
+ ' content_negotiation = {content_negotiation}, '.
+ ' cmd_after_publish = {cmd_after_publish} '.
+ 'WHERE id= {projectid} ' );
+
+ $sql->setString('name' ,$this->name );
+ $sql->setString('target_dir' ,$this->target_dir );
+ $sql->setString('ftp_url' ,$this->ftp_url );
+ $sql->setInt ('ftp_passive' ,$this->ftp_passive );
+ $sql->setString('cmd_after_publish' ,$this->cmd_after_publish );
+ $sql->setInt ('content_negotiation',$this->content_negotiation );
+ $sql->setInt ('cut_index' ,$this->cut_index );
+ $sql->setInt ('projectid' ,$this->projectid );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Speichern
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'target_dir' =>$this->target_dir,
+ 'ftp_url' =>$this->ftp_url,
+ 'ftp_passive' =>$this->ftp_passive,
+ 'cmd_after_publish' =>$this->cmd_after_publish,
+ 'content_negotiation'=>$this->content_negotiation,
+ 'cut_index' =>$this->cut_index,
+ 'projectid' =>$this->projectid );
+ }
+
+
+ // Projekt hinzufuegen
+ function add()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_project}');
+ $this->projectid = intval($db->getOne($sql->query))+1;
+
+
+ // Projekt hinzufügen
+ $sql = new Sql( 'INSERT INTO {t_project} (id,name,target_dir,ftp_url,ftp_passive,cmd_after_publish,content_negotiation,cut_index) '.
+ " VALUES( {projectid},{name},'','',0,'',0,0 ) " );
+ $sql->setString('name' ,$this->name );
+ $sql->setInt ('projectid',$this->projectid );
+
+ $db->query( $sql->query );
+
+ // Sprache anlegen
+ $language = new Language();
+ $language->projectid = $this->projectid;
+ $language->isoCode = 'en';
+ $language->name = 'english';
+ $language->add();
+
+ // Haupt-Ordner anlegen
+ $folder = new Folder();
+ $folder->isRoot = true;
+ $folder->projectid = $this->projectid;
+ $folder->languageid = $language->languageid;
+ $folder->filename = $this->name;
+ $folder->name = $this->name;
+ $folder->isRoot = true;
+ $folder->add();
+
+ // Modell anlegen
+ $model = new Model();
+ $model->projectid = $this->projectid;
+ $model->name = 'html';
+ $model->add();
+ }
+
+
+ // Projekt aus Datenbank entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Root-Ordner rekursiv samt Inhalten loeschen
+ $folder = new Folder( $this->getRootObjectId() );
+ $folder->deleteAll();
+
+
+ foreach( $this->getLanguageIds() as $languageid )
+ {
+ $language = new Language( $languageid );
+ $language->delete();
+ }
+
+
+ foreach( $this->getTemplateIds() as $templateid )
+ {
+ $template = new Template( $templateid );
+ $template->delete();
+ }
+
+
+ foreach( $this->getModelIds() as $modelid )
+ {
+ $model = new Model( $modelid );
+ $model->delete();
+ }
+
+
+ // Projekt löschen
+ $sql = new Sql( 'DELETE FROM {t_project}'.
+ ' WHERE id= {projectid} ' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $db->query( $sql->query );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Template.class.php b/objectClasses/Template.class.php
@@ -0,0 +1,313 @@
+<?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.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Logische Darstellung eines Templates
+ *
+ * @author: $Author$
+ * @version: $Revision$
+ */
+class Template
+{
+ /**
+ * ID dieses Templates
+ * @type Integer
+ */
+ var $templateid = 0;
+
+ /**
+ * Projekt-ID des aktuell ausgewählten Projektes
+ * @type Integer
+ */
+ var $projectid;
+
+ /**
+ * Logischer Name
+ * @type String
+ */
+ var $name;
+
+ /**
+ * ID der Projektvariante
+ * @type Integer
+ */
+ var $modelid;
+
+ /**
+ * Dateierweiterung dieses Templates (abhängig von der Projektvariante)
+ * @type String
+ */
+ var $extension;
+
+ /**
+ * Inhalt des Templates (abhängig von der Projektvariante)
+ * @type String
+ */
+ var $src;
+
+ // Konstruktor
+ function Template( $templateid='' )
+ {
+ global $SESS;
+ $this->modelid = $SESS['modelid'];
+ $this->projectid = $SESS['projectid'];
+
+ if ( is_numeric($templateid) )
+ $this->templateid = $templateid;
+ }
+
+
+ /**
+ * Ermitteln aller Templates in dem aktuellen Projekt
+ * @return Array
+ */
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,name FROM {t_template}'.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY name ASC ' );
+ if ( isset($this->projectid) )
+ $sql->setInt( 'projectid',$this->projectid );
+ else $sql->setInt( 'projectid',$SESS['projectid'] );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ /**
+ * Laden des Templates aus der Datenbank und füllen der Objekteigenschaften
+ */
+ function load()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_template}'.
+ ' WHERE id={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name' ];
+ $this->projectid = $row['projectid'];
+
+ $sql = new Sql( 'SELECT * FROM {t_templatemodel}'.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $sql->setInt( 'modelid' ,$this->modelid );
+ $row = $db->getRow( $sql->query );
+
+ $this->extension = $row['extension'];
+ $this->src = $row['text'];
+
+ }
+
+
+ /**
+ * Abspeichern des Templates in der Datenbank
+ */
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_template}'.
+ ' SET name={name}'.
+ ' WHERE id={templateid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setInt ( 'templateid',$this->templateid );
+ $row = $db->getRow( $sql->query );
+
+ $sql = new Sql( 'SELECT COUNT(*) FROM {t_templatemodel}'.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setInt ( 'modelid' ,$this->modelid );
+
+ if ( intval($db->getOne($sql->query)) > 0 )
+ {
+ $sql = new Sql( 'UPDATE {t_templatemodel}'.
+ ' SET extension={extension},'.
+ ' text={src} '.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ }
+ else
+ {
+ $sql = new Sql('SELECT MAX(id) FROM {t_templatemodel}');
+ $nextid = intval($db->getOne($sql->query))+1;
+ $sql = new Sql( 'INSERT INTO {t_templatemodel}'.
+ ' (id,templateid,projectmodelid,extension,text) '.
+ ' VALUES ({id},{templateid},{modelid},{extension},{src}) ');
+ $sql->setInt ( 'id',$nextid );
+ }
+
+ $sql->setString( 'extension' ,$this->extension );
+ $sql->setString( 'src' ,$this->src );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setInt ( 'modelid' ,$this->modelid );
+
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Es werden Templates mit einem Inhalt gesucht
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Template-IDs
+ */
+ function getTemplateIdsByValue( $text )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT templateid FROM {t_templatemodel}'.
+ ' WHERE text LIKE {text} '.
+ ' AND projectmodelid={modelid}' );
+
+ $sql->setInt ( 'modelid',$this->modelid );
+ $sql->setString( 'text' ,'%'.$text.'%' );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste nur mit den Element-IDs ermittelt und zurückgegeben
+ * @return Array
+ */
+ function getElementIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_element}'.
+ ' WHERE templateid={templateid}'.
+ ' ORDER BY name ASC' );
+ $sql->setInt( 'templateid',$this->templateid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste mit den Element-Namen zurückgegeben
+ * @return Array
+ */
+ function getElementNames()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,name FROM {t_element}'.
+ ' WHERE templateid={templateid}'.
+ ' ORDER BY name ASC' );
+ $sql->setInt( 'templateid',$this->templateid );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ /**
+ * Hinzufügen eines Elementes
+ * @param String Name des Elementes
+ */
+ function addElement( $name )
+ {
+ $element = new Element();
+ $element->name = $name;
+ $element->type = 'text';
+ $element->templateid = $this->templateid;
+ $element->wiki = true;
+ $element->writable = true;
+ $element->add();
+ }
+
+
+ /**
+ * Hinzufügen eines Templates
+ * @param String Name des Templates
+ */
+ function add( $name )
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_template}');
+ $this->templateid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql( 'INSERT INTO {t_template}'.
+ ' (id,name,projectid)'.
+ ' VALUES({templateid},{name},{projectid})' );
+ $sql->setInt ('templateid',$this->templateid );
+ $sql->setString('name' ,$name );
+ $sql->setInt ('projectid' ,$SESS['projectid']);
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln alles Objekte (=Seiten), welche auf diesem Template basieren
+ * @return Array Liste von Objekt-IDs
+ */
+ function getDependentObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT objectid FROM {t_page}'.
+ ' WHERE templateid={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Loeschen des Templates
+ *
+ * Entfernen alle Templateinhalte und des Templates selber
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'DELETE FROM {t_templatemodel}'.
+ ' WHERE templateid={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $db->query( $sql->query );
+
+ $sql = new Sql( 'DELETE FROM {t_template}'.
+ ' WHERE id={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $db->query( $sql->query );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/User.class.php b/objectClasses/User.class.php
@@ -0,0 +1,568 @@
+<?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.
+#
+
+
+class User
+{
+ var $userid = 0;
+ var $error = '';
+
+ var $name = '';
+ var $fullname = '';
+ var $ldap_dn;
+ var $tel;
+ var $mail;
+ var $desc;
+ var $style;
+ var $isAdmin;
+
+
+ // Konstruktor
+ function User( $userid='' )
+ {
+ if ( is_numeric($userid) )
+ $this->userid = $userid;
+ }
+
+
+ // Lesen Benutzer aus der Datenbank
+ function listAll()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,name '.
+ ' FROM {t_user}'.
+ ' ORDER BY name' );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ /**
+ * Benutzer als aktiven Benutzer in die Session schreiben
+ */
+ function setCurrent()
+ {
+ global $SESS;
+
+ $SESS['user'] = $this->getProperties();
+ }
+
+
+ // Lesen Benutzer aus der Datenbank
+ function load()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_user}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$this->userid );
+ $row = $db->getRow( $sql->query );
+
+ if ( count($row) > 1 )
+ {
+ $this->name = $row['name' ];
+ $this->style = $row['style' ];
+ $this->isAdmin = $row['is_admin'];
+ $this->ldap_dn = $row['ldap_dn' ];
+ $this->fullname = $row['fullname'];
+ $this->tel = $row['tel' ];
+ $this->mail = $row['mail' ];
+ $this->desc = $row['descr' ];
+
+ if ( $this->fullname == '' )
+ $this->fullname = $this->name;
+
+ if ( $this->style == '' )
+ $this->style = 'default';
+ }
+ else
+ {
+ $this->name = lang('UNKNOWN');
+ $this->style = 'default';
+ $this->isAdmin = false;
+ $this->ldap_dn = '';
+ $this->fullname = lang('UNKNOWN');
+ $this->tel = '';
+ $this->mail = '';
+ $this->desc = '';
+ }
+
+ /* vorerst unbenutzt:
+ if ( $row['use_ldap'] == '1' )
+ {
+ // Daten aus LDAP-Verzeichnisdienst lesen
+
+ // Verbindung zum LDAP-Server herstellen
+ $ldap_conn = @ldap_connect( $conf['ldap']['host'],$conf['ldap']['port'] );
+
+ if ( !$ldap_conn )
+ {
+ logger( 'INFO','cannot connect to LDAP server '.$conf['ldap']['host'].' '.$conf['ldap']['port'] );
+ $this->error = 'cannot connect to LDAP server';
+ return false;
+ }
+
+ // Anonymes LDAP-Login versuchen
+ $ldap_bind = @ldap_bind( $ldap_conn );
+
+ if ( $ldap_bind )
+ {
+ // Login erfolgreich
+ $sr = ldap_read( $ldap_conn,$row['ldap_dn'],'(objectclass=*)' );
+
+ $daten = ldap_get_entries( $ldap_conn,$sr );
+
+ $this->fullname = $daten[0]['givenName'][0].' '.$daten[0]['sn'][0];
+ $this->tel = $daten[0]['telephoneNumber'][0];
+ $this->mail = $daten[0]['mail'][0];
+ $this->desc = $daten[0]['description'][0];
+ }
+
+ }
+ */
+ }
+
+
+
+ // Lesen Benutzername
+ function getUserName( $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT name FROM {t_user}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$userid );
+
+ $name = $db->getOne( $sql->query );
+
+ if ( $name == '' )
+ return lang('UNKNOWN');
+ else return $name;
+ }
+
+
+ // Speichern Benutzer in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_user}'.
+ ' SET name={name},'.
+ ' fullname={fullname},'.
+ ' ldap_dn ={ldap_dn} ,'.
+ ' tel ={tel} ,'.
+ ' descr ={desc} ,'.
+ ' mail ={mail} ,'.
+ ' style ={style} ,'.
+ ' is_admin={isAdmin} '.
+ ' WHERE id={userid}' );
+ $sql->setInt ( 'userid' ,$this->userid );
+ $sql->setString ( 'fullname',$this->fullname);
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'ldap_dn' ,$this->ldap_dn );
+ $sql->setString ( 'tel' ,$this->tel );
+ $sql->setString ( 'desc' ,$this->desc );
+ $sql->setString ( 'mail' ,$this->mail );
+ $sql->setString ( 'style' ,$this->style );
+ $sql->setBoolean( 'isAdmin' ,$this->isAdmin );
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ // Benutzer hinzufuegen
+ function add( $name = '' )
+ {
+ if ( $name != '' )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_user}');
+ $this->userid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_user}'.
+ ' (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin)'.
+ " VALUES( {userid},{name},'','','','','','','default',0 )" );
+ $sql->setInt ('userid',$this->userid);
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ // Benutzer entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Alle Archivdaten in Dateien mit diesem Benutzer entfernen
+ $sql = new Sql( 'UPDATE {t_object} '.
+ 'SET create_userid=null '.
+ 'WHERE create_userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $db->query( $sql->query );
+
+ // Alle Berechtigungen dieses Benutzers löschen
+ $sql = new Sql( 'DELETE FROM {t_acl} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $db->query( $sql->query );
+
+ // Alle Gruppenzugehörigkeiten dieses Benutzers löschen
+ $sql = new Sql( 'DELETE FROM {t_usergroup} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $db->query( $sql->query );
+
+ // Benutzer löschen
+ $sql = new Sql( 'DELETE FROM {t_user} '.
+ 'WHERE id={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $db->query( $sql->query );
+ }
+
+
+ /** Ermitteln der Eigenschaften zu diesem Benutzer
+ *
+ * @return Array Liste der Eigenschaften als assoziatives Array
+ */
+ function getProperties()
+ {
+ return Array( 'userid' => $this->userid,
+ 'id' => $this->userid,
+ 'fullname'=> $this->fullname,
+ 'name' => $this->name,
+ 'ldap_dn' => $this->ldap_dn,
+ 'tel' => $this->tel,
+ 'desc' => $this->desc,
+ 'mail' => $this->mail,
+ 'style' => $this->style,
+ 'is_admin'=> $this->isAdmin,
+ 'isAdmin' => $this->isAdmin );
+ }
+
+
+ // Ueberpruefen des Kennwortes
+ // entweder ueber Datenbank oder ueber LDAP-Verzeichnisdienst
+ function checkPassword( $password )
+ {
+ global $conf;
+ $this->error = '';
+
+ $db = db_connection();
+
+ // Lesen des Benutzers aus der DB-Tabelle
+ $sql = new Sql( 'SELECT * FROM {t_user} WHERE name={name}' );
+ $sql->setString('name',$this->name);
+
+ $res_user = $db->query( $sql->query );
+
+ if ( $res_user->numRows() == 1 )
+ {
+ $row_user = $res_user->fetchRow();
+ $this->userid = $row_user['id'];
+
+ // Falls LDAP-dn vorhanden wird Benutzer per LDAP authentifiziert
+ if ( $row_user['ldap_dn'] != '' )
+ {
+ Logger::debug( 'checking login via ldap' );
+ $ldapHost = $conf['ldap']['host'];
+ $ldapPort = $conf['ldap']['port'];
+
+ // Verbindung zum LDAP-Server herstellen
+ $ldap_conn = @ldap_connect( $ldapHost,$ldapPort );
+
+ if ( !$ldap_conn )
+ {
+ Logger::error( "connect to ldap server '$ldapHost:$ldapPort' failed" );
+ $this->error = 'cannot connect to LDAP server';
+ return false;
+ }
+
+ // LDAP-Login versuchen
+ if ( @ldap_bind( $ldap_conn,$row_user['ldap_dn'],$password) )
+ {
+ // Login erfolgreich
+ $SESS['user'] = $row_user;
+ return true;
+ }
+ }
+ else
+ {
+ Logger::debug( 'checking md5-password '.md5($password).' against database' );
+
+ // Prüfen ob Kennwort mit Datenbank übereinstimmt
+ if ( $row_user['password'] == md5( $password ) )
+ {
+ // Login erfolgreich
+ return true;
+ }
+ }
+ }
+
+ // Benutzername nicht in Datenbank oder Kennwort falsch
+ return false;
+ }
+
+
+ // Neues Kennwort fuer diesen Benutzer setzen
+ function setPassword( $password )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_user} SET password={password}'.
+ 'WHERE id={userid}' );
+ $sql->setString('password',md5($password) );
+ $sql->setInt ('userid' ,$this->userid );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Gruppen ermitteln, in denen der Benutzer Mitglied ist
+ function getGroups()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_group}.id,{t_group}.name FROM {t_group} '.
+ 'LEFT JOIN {t_usergroup} ON {t_usergroup}.groupid={t_group}.id '.
+ 'WHERE {t_usergroup}.userid={userid}' );
+ $sql->setInt('userid',$this->userid );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Gruppen ermitteln, in denen der Benutzer Mitglied ist
+ function getGroupIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT groupid FROM {t_usergroup} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt('userid',$this->userid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ // Gruppen ermitteln, in denen der Benutzer *nicht* Mitglied ist
+ function getOtherGroups()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_group}.id,{t_group}.name FROM {t_group}'.
+ ' LEFT JOIN {t_usergroup} ON {t_usergroup}.groupid={t_group}.id AND {t_usergroup}.userid={userid}'.
+ ' WHERE {t_usergroup}.userid IS NULL' );
+ $sql->setInt('userid' ,$this->userid );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Benutzer einer Gruppe hinzufuegen
+ function addGroup( $groupid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_usergroup}');
+ $usergroupid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql( 'INSERT INTO {t_usergroup} '.
+ ' (id,userid,groupid) '.
+ ' VALUES( {usergroupid},{userid},{groupid} )' );
+ $sql->setInt('usergroupid',$usergroupid );
+ $sql->setInt('userid' ,$this->userid );
+ $sql->setInt('groupid' ,$groupid );
+
+ $db->query( $sql->query );
+
+ }
+
+
+ // Benutzer aus Gruppe entfernen
+ function delGroup( $groupid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'DELETE FROM {t_usergroup} '.
+ ' WHERE userid={userid} AND groupid={groupid}' );
+ $sql->setInt ('userid' ,$this->userid );
+ $sql->setInt ('groupid' ,$groupid );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Alle Berechtigungen ermitteln
+ function getRights()
+ {
+ global $SESS,$conf_php;
+ $db = db_connection();
+ $var = array();
+
+ // Alle Projekte lesen
+ $sql = new Sql( 'SELECT id,name FROM {t_project}' );
+ $projects = $db->getAssoc( $sql->query );
+
+ foreach( $projects as $projectid=>$projectname )
+ {
+ $var[$projectid] = array();
+ $var[$projectid]['name'] = $projectname;
+ $var[$projectid]['folders'] = array();
+ $var[$projectid]['rights'] = array();
+
+ $sql = new Sql( 'SELECT {t_acl}.* FROM {t_acl}'.
+ ' LEFT JOIN {t_folder} ON {t_acl}.folderid = {t_folder}.id'.
+ ' WHERE {t_folder}.projectid={projectid}'.
+ ' AND {t_acl}.userid={userid}' );
+ $sql->setInt('projectid',$projectid );
+ $sql->setInt('userid' ,$this->userid );
+
+ $acls = $db->getAll( $sql->query );
+
+ foreach( $acls as $acl )
+ {
+ $aclid = $acl['id'];
+ $folder = new Folder( $acl['folderid'] );
+ $folder->load();
+ $var[$projectid]['rights'][$aclid] = $acl;
+ $var[$projectid]['rights'][$aclid]['foldername'] = implode(' » ',$folder->parentfolder( false,true ));
+ $var[$projectid]['rights'][$aclid]['delete_url'] = 'user.'.$conf_php.'?useraction=delright&aclid='.$aclid;
+ }
+
+ $sql = new Sql( 'SELECT id FROM {t_folder}'.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$projectid);
+ $folders = $db->getCol( $sql->query );
+
+ $var[$projectid]['folders'] = array();
+
+ foreach( $folders as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ $folder->load();
+ $var[$projectid]['folders'][$folderid] = implode(' » ',$folder->parentfolder( false,true ));
+ }
+
+ asort( $var[$projectid]['folders'] );
+ }
+
+ return $var;
+ }
+
+
+ // Berechtigung dem Benutzer hinzufuegen
+ function addRight( $data )
+ {
+ global $REQ,$SESS;
+ $db = db_connection();
+
+ $sql = new SQL('INSERT INTO {t_acl} '.
+ '(userid,groupid,folderid,`read`,`write`,`create`,`delete`,publish) '.
+ 'VALUES({userid},{groupid},{folderid},{read},{write},{create},{delete},{publish})');
+
+ $sql->setInt ('userid',$this->userid);
+ $sql->setNull('groupid');
+ $sql->setInt ('projectid',$SESS['projectid']);
+ $sql->setInt ('folderid',$data['folderid']);
+
+ $sql->setInt ('read' ,$data['read' ]);
+ $sql->setInt ('write' ,$data['write' ]);
+ $sql->setInt ('create' ,$data['create' ]);
+ $sql->setInt ('delete' ,$data['delete' ]);
+ $sql->setInt ('publish',$data['publish']);
+
+ // Datenbankabfrage ausführen
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Benutzer erhält eine Berechtigung
+ *
+ * @param Integer ID der hinzuzufügenden ACL
+ * @access public
+ */
+ function addACL( $aclid )
+ {
+ global $SESS;
+
+ $acl = new Acl( $aclid );
+ $acl->load();
+
+ // Falls Berechtigung für dieses Objekt nicht vorhanden, dann anlegen
+ if ( !isset($SESS['rights'][$acl->objectid]) )
+ $SESS['rights'][$acl->objectid] = Array( 'read' =>true,
+ 'prop' =>false,
+ 'write' =>false,
+ 'delete' =>false,
+ 'publish' =>false,
+ 'create_folder'=>false,
+ 'create_file' =>false,
+ 'create_link' =>false,
+ 'create_page' =>false );
+
+ // Hinzufügen der Flags
+ if ( $acl->prop )
+ $SESS['rights'][$acl->objectid]['prop' ] = true;
+
+ if ( $acl->write )
+ $SESS['rights'][$acl->objectid]['write' ] = true;
+
+ if ( $acl->delete )
+ $SESS['rights'][$acl->objectid]['delete' ] = true;
+
+ if ( $acl->publish )
+ $SESS['rights'][$acl->objectid]['publish'] = true;
+
+ if ( $acl->create_folder )
+ $SESS['rights'][$acl->objectid]['create_folder' ] = true;
+
+ if ( $acl->create_file )
+ $SESS['rights'][$acl->objectid]['create_file' ] = true;
+
+ if ( $acl->create_link )
+ $SESS['rights'][$acl->objectid]['create_link' ] = true;
+
+ if ( $acl->create_page )
+ $SESS['rights'][$acl->objectid]['create_page' ] = true;
+ }
+
+
+ // Berechtigung entfernen
+ function delRight( $aclid )
+ {
+ $db = db_connection();
+
+ $sql = new SQL('DELETE FROM {t_acl} WHERE id={aclid}');
+ $sql->setInt( 'aclid',$aclid );
+
+ // Datenbankabfrage ausführen
+ $db->query( $sql->query );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/objectClasses/Value.class.php b/objectClasses/Value.class.php
@@ -0,0 +1,894 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2004/03/13 23:09:48 dankert
+// *** empty log message ***
+//
+// ---------------------------------------------------------------------------
+
+
+class Value
+{
+ /**
+ * ID dieser Inhaltes
+ * @type Integer
+ */
+ var $valueid=0;
+
+ /**
+ * Seiten-Objekt der übergeordneten Seite
+ * @type Object
+ */
+ var $page;
+
+ /**
+ * Objekt-ID, auf die verlinkt wird
+ * @type Integer
+ */
+ var $linkToObjectId;
+
+ /**
+ * Text-Inhalt
+ * @type String
+ */
+ var $text;
+
+ /**
+ * Zahl. Auch Fließkommazahlen werden als Ganzzahl gespeichert
+ * @type Integer
+ */
+ var $number;
+
+
+ /**
+ * Datum als Unix-Timestamp
+ * @type Integer
+ */
+ var $date;
+
+ /**
+ * Element-Objekt
+ * @type Object
+ */
+ var $element;
+
+ /**
+ * Der eigentliche Inhalt des Elementes
+ * @type String
+ */
+ var $value;
+
+ /**
+ * TimeStamp der letzten Änderung
+ * @type Integer
+ */
+ var $lastchangeTimeStamp;
+
+ /**
+ * Benutzer-ID der letzten Änderung
+ * @type Integer
+ */
+ var $lastchangeUserId;
+
+ /**
+ * Konstruktor
+ */
+ function Value()
+ {
+ global $SESS;
+
+ $this->lastchangeUserId = 0;
+ $this->lastchangeTimeStamp = 0;
+
+ $this->languageid = $SESS['languageid'];
+ }
+
+
+ /**
+ * Umwandeln von Wiki-Textauszeichnungen in HTML-Auszeichnungen
+ *
+ * @param text zu bearbeitender Text
+ * @param html Boolean, ob HTML-Tags erlaubt sind
+ *
+ * @return String Ausgabe
+ */
+ function decode_wiki( $text,$html=false )
+ {
+ global $conf_languagedir,
+ $conf_php;
+
+ $neu = array();
+
+ $pre = false;
+ $br = false;
+ $ul = false;
+ $ol = false;
+ $table = false;
+ $p = false;
+
+ $text = str_replace( "\n===",'H1H1H1',$text );
+ $text = str_replace( "\n---",'H2H2H2',$text );
+ $text = str_replace( "\n...",'H3H3H3',$text );
+
+ // Zeichenkette in die einzelnen Zeilen zerlegen
+ $zeilen = explode("\n",$text);
+
+ foreach( $zeilen as $zeile )
+ {
+ # Leerzeichen und sonstige Sonderzeichen am Zeilenende entfernen
+ $zeile = chop( $zeile );
+
+ // Präformatierter Text Anfang
+ if ( $zeile == '=' && !$pre )
+ {
+ $zeile = '<pre>';
+ $pre = true;
+ }
+
+ // Präformatierter Text Ende
+ if ( $zeile == '=' && $pre )
+ {
+ $zeile = '</pre>';
+ $pre = false;
+ }
+
+
+ // Bei präformatierem Text keine weiteren Formatierungen durchführen
+ if ( !$pre )
+ {
+ // Überschrift 1. Ordnung
+ if ( substr($zeile,0,3) == '!!!' )
+ {
+ $zeile = '<h1>'.substr($zeile,3).'</h1>';
+ }
+
+ if ( ereg( 'H1H1H1.*$',$zeile ) )
+ {
+ $zeile = eregi_replace( 'H1H1H1.*$','',$zeile );
+ $zeile = chop( $zeile );
+ $zeile = '<h1>'.$zeile.'</h1>';
+ }
+
+
+ // Überschrift 2. Ordnung
+ if ( substr($zeile,0,2) == '!!' )
+ {
+ $zeile = '<h2>'.substr($zeile,2).'</h2>';
+ }
+
+ if ( ereg( 'H2H2H2.*$',$zeile ) )
+ {
+ $zeile = eregi_replace( 'H2H2H2.*$','',$zeile );
+ $zeile = chop( $zeile );
+ $zeile = '<h2>'.$zeile.'</h2>';
+ }
+
+
+ // Überschrift 3. Ordnung
+ if ( substr($zeile,0,1) == '!' )
+ {
+ $zeile = '<h3>'.substr($zeile,1).'</h3>';
+ }
+
+ if ( ereg( 'H3H3H3.*$',$zeile ) )
+ {
+ $zeile = eregi_replace( 'H3H3H3.*$','',$zeile );
+ $zeile = chop( $zeile );
+ $zeile = '<h3>'.$zeile.'</h3>';
+ }
+
+
+ // Tabellen
+ $beg = substr($zeile,0,1);
+
+ if ( $beg == '|' )
+ {
+ if ( !$table )
+ {
+ $neu[] = '<table>';
+ $table = true;
+ }
+
+ $zeile = ereg_replace( '^\|','<tr><td>',$zeile );
+ $zeile = ereg_replace( '\|$','</td></tr>',$zeile );
+ $zeile = str_replace( '|','</td><td>',$zeile );
+
+ $zeile = eregi_replace( '<td>!([^<]+)</td>','<th>\\1</th>',$zeile );
+
+ $zeile = eregi_replace( '<td>\(([a-zA-Z0-9]+)\)([^<]+)</td>','<td class="\\1">\\2</td>',$zeile );
+ $zeile = eregi_replace( '<th>\(([a-zA-Z0-9]+)\)([^<]+)</th>','<th class="\\1">\\2</th>',$zeile );
+ }
+ else
+ {
+ if( $table )
+ {
+ $table = false;
+ $neu[] = '</table>';
+ }
+ }
+
+ $beg = substr($zeile,0,2);
+
+ // numerierte Aufzaehlungen
+ if ( $beg == '# ' )
+ {
+ if ( !$ol )
+ {
+ $neu[] = '<ol>';
+ $ol = true;
+ }
+ $zeile = '<li>'.substr($zeile,2).'</li>';
+ }
+ else
+ {
+ if ( $ol )
+ {
+ $ol = false;
+ $neu[] = '</ol>';
+ }
+ }
+
+
+ // einfache Aufzaehlungen
+ if ( $beg == '- ' || $beg == '* ' || $beg == 'o ' )
+ {
+ if ( !$ul )
+ {
+ $neu[] = '<ul>';
+ $ul = true;
+ }
+ $zeile = '<li>'.substr($zeile,2).'</li>';
+ }
+ else
+ {
+ if ( $ul )
+ {
+ $ul = false;
+ $neu[] = '</ul>';
+ }
+ }
+ }
+
+
+ // Absätze einrichten
+ if (!$pre && !$ol && !$ul && !$table && substr($zeile,0,1)!='<' )
+ {
+ if ( $zeile != '' && $p )
+ {
+ $neu[] = '<br/>';
+ }
+
+ if ( $zeile == '' && $p )
+ {
+ $neu[] = '</p>';
+ $p = false;
+ }
+
+ if ( $zeile != '' && !$p )
+ {
+ $neu[] = '<p>';
+ $p = true;
+ }
+ }
+
+
+ // Textauszeichnungen fett,kursiv,fest
+ if ( !$pre ) // nicht bei präformatiertem Text
+ {
+ // *Fett*
+ $zeile = ereg_replace( '\*([^*]+[^\\])\*' , '<strong>\\1</strong>' , $zeile );
+
+ // kursiv
+ $zeile = ereg_replace( '_([^_]+[^\\])_' , ' <em>\\1</em> ' , $zeile );
+ //$zeile = ereg_replace( '\/([^\/:]+)\/', ' <em>\\1</em> ' , $zeile );
+
+ // feste Breite
+ $zeile = ereg_replace( '=([^=]+[^\\])=' , ' <tt>\\1</tt> ' , $zeile );
+
+ $zeile = str_replace( '\*','*',$zeile );
+ $zeile = str_replace( '\_','_',$zeile );
+ $zeile = str_replace( '\=','=',$zeile );
+
+ // Links
+ if ( $this->element->html )
+ $pf = '>';
+ else $pf = '>';
+
+ // Text->... umsetzen nach "Text"->... (Anfuehrungszeichen ergaenzen)
+ $zeile = ereg_replace( '([A-Za-z0-9._?äöüÄÖÜß-]+)-'.$pf, '"\\1"-'.$pf, $zeile );
+
+ // ...->Link umsetzen nach ...->"Link" (Anfuehrungszeichen ergaenzen)
+ $zeile = ereg_replace( '-'.$pf.'([A-Za-z0-9.:_\/\,\?\=\&-]+)', '-'.$pf.'"\\1"',$zeile );
+
+ # Links ...->"nnn" ersetzen mit ...->"object:nnn"
+ $zeile = ereg_replace( '-'.$pf.'\"([0-9]+)\"', '-'.$pf.'"object:\\1"', $zeile );
+
+ // Links ->... url-kodieren
+// preg_match_all( '|-'.$pf.'\"([^\"]+)\"|',$zeile,$urls,PREG_SET_ORDER );
+// foreach( $urls as $url )
+// {
+// echo $url[1];
+// $urlneu = urlencode( $url[1] );
+// echo "wird zu $urlneu<br>";
+// $zeile = str_replace( $url[0],'-'.$pf.'"'.$urlneu.'"',$zeile );
+// }
+
+ # Links "mit->..."
+ $zeile = ereg_replace( '\"([^\"]+)\"-'.$pf.'\"([^\"]+)\"', '<a href="\\2">\\1</a>', $zeile );
+
+ // alleinstehende externe Links
+ $zeile = ereg_replace( '([^"])((https?|ftps?|news|gopher):\/\/([A-Za-z0-9._\/\,-]*))', '\\1<a href="\\2">\\4</a>', $zeile );
+ $zeile = ereg_replace( '^((https?|ftps?|news|gopher):\/\/([A-Za-z0-9._\/\,-]*))', '<a href="\\1">\\3</a>', $zeile );
+
+ // Einbinden von Bildern
+ $zeile = ereg_replace( '(ima?ge?):\/?\/?(([0-9]+))(\{.*\})?', '<img src="object:\\2" />', $zeile );
+
+ # mailto:...-Links
+ $zeile = ereg_replace( '([A-Za-z0-9._-]+@[A-Za-z0-9._-]+)', '<a href="mailto:\\1">\\1</a>', $zeile );
+
+ // Links object:nnn ersetzen
+ preg_match_all( '|object:([0-9]+)|',$zeile,$objects,PREG_SET_ORDER );
+ foreach( $objects as $object )
+ {
+ $var = $this->page->path_to_object( $object[1] );
+ $zeile = str_replace( $object[0],$var,$zeile );
+ }
+ }
+ $neu[] = $zeile;
+ }
+
+ if ( $ol ) $neu[] = '</ol>';
+ if ( $ul ) $neu[] = '</ul>';
+ if ( $table ) $neu[] = '</table>';
+ if ( $pre ) $neu[] = '</pre>';
+ if ( $p ) $neu[] = '</p>';
+
+
+ $text = implode("\n",$neu);
+
+ $ini_chars = parse_ini_file( $conf_languagedir.'/specialchars.ini.'.$conf_php );
+ foreach( $ini_chars as $key=>$val)
+ {
+ $text = str_replace( $key,$val,$text );
+ }
+ return $text;
+ }
+
+
+ function path_to_page( $pageid )
+ {
+ return $this->page->path_to_object( $pageid );
+ }
+ function path_to_object( $pageid )
+ {
+ return $this->path_to_page( $pageid );
+ }
+
+
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_value}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}'.
+ ' AND active=1' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+ $row = $db->getRow( $sql->query );
+
+ $this->text = $row['text'];
+ $this->valueid = intval($row['id'] );
+ $this->linkToObjectId = intval($row['linkobjectid']);
+ $this->number = intval($row['number' ]);
+ $this->date = intval($row['date' ]);
+
+ $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
+ $this->lastchangeUserId = intval($row['lastchange_userid']);
+ }
+
+
+ function loadWithId()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_value}'.
+ ' WHERE id={valueid}' );
+ $sql->setInt( 'valueid',$this->valueid);
+ $row = $db->getRow( $sql->query );
+
+ $this->text = $row['text'];
+ $this->valueid = intval($row['id'] );
+ $this->linkToObjectId = intval($row['linkobjectid']);
+ $this->number = intval($row['number' ]);
+ $this->date = intval($row['date' ]);
+
+ $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
+ $this->lastchangeUserId = intval($row['lastchange_userid']);
+ }
+
+
+ /**
+ * Alle Versionen des aktuellen Inhaltes werden ermittelt
+ * @return Array
+ */
+ function getVersionList()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_value}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}'.
+ ' ORDER BY lastchange_date' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Inhalt speichern
+ */
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+// $sql = new Sql( 'UPDATE {t_value}'.
+// ' SET '.
+// ' linkobjectid = {linkobjectid},'.
+// ' text = {defaultText},'.
+// ' number = {folderObjectId},'.
+// ' date = {defaultObjectId},'.
+// ' active = 1'.
+// ' WHERE elementid ={elementid}'.
+// ' AND pageid ={pageid}'.
+// ' AND languageid={languageid}' );
+ $sql = new Sql( 'UPDATE {t_value}'.
+ ' SET active=0'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $db->query( $sql->query );
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_value}');
+ $this->valueid = intval($db->getOne($sql->query))+1;
+
+ $sql->setQuery( 'INSERT INTO {t_value}'.
+ ' (id,linkobjectid,text,number,date,elementid,pageid,languageid,active,lastchange_date,lastchange_userid)'.
+ ' VALUES ({valueid},{linkobjectid},{text},{number},{date},{elementid},{pageid},{languageid},1,{lastchange_date},{lastchange_userid})' );
+
+ $sql->setInt( 'valueid' ,$this->valueid );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid );
+
+ if ( intval($this->linkToObjectId)==0)
+ $sql->setNull ( 'linkobjectid' );
+ else $sql->setInt ( 'linkobjectid',$this->linkToObjectId );
+
+ if ( $this->text == '' )
+ $sql->setNull ( 'text' );
+ else $sql->setString( 'text',$this->text );
+
+ if ( intval($this->number)==0)
+ $sql->setNull ( 'number' );
+ else $sql->setInt ( 'number',$this->number );
+
+ if ( intval($this->date)==0)
+ $sql->setNull ( 'date' );
+ else $sql->setInt ( 'date',$this->date );
+
+ $sql->setInt ( 'lastchange_date' ,time() );
+ $sql->setInt ( 'lastchange_userid',$SESS['user']['userid'] );
+
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Diesen Inhalt löschen
+ */
+ function delete()
+ {
+ $db = db_connection();
+ $sql = new Sql( 'DELETE * FROM {t_value}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+ $row = $db->getRow( $sql->query );
+ }
+
+
+ /**
+ * Inhalt ermitteln
+ */
+ function generate()
+ {
+ if ( intval($this->valueid)==0 )
+ $this->load();
+ global $db,
+ $conf,
+ $conf_php,
+ $conf_tmpdir,
+ $SESS;
+
+ $inhalt = '';
+
+ switch( $this->element->type )
+ {
+ case 'list':
+
+ $objectid = $this->linkToObjectId;
+
+ if ( intval($objectid) == 0 )
+ $objectid = $this->element->defaultObjectId;
+
+ if ( $this->simple )
+ {
+ $f = new Folder( $objectid );
+ $f->load();
+ $inhalt = $f->name;
+ unset( $f );
+ }
+ else
+ {
+ if ( $objectid != $this->page->objectid ) // Rekursion vermeiden
+ {
+ $f = new Folder( $objectid );
+ foreach( $f->getObjectIds() as $oid )
+ {
+ if ( $oid != $this->page->objectid ) // Rekursion vermeiden
+ {
+ $o = new Object( $oid );
+ $o->load();
+ switch( $o->getType() )
+ {
+ case 'page':
+ $p = new Page( $oid );
+ $p->public = $this->page->public;
+ $p->projectmodelid = $this->page->projectmodelid;
+ $p->languageid = $this->languageid;
+ $p->load();
+ $p->generate();
+ $inhalt .= $p->value;
+ unset( $p );
+ break;
+ case 'link':
+ $l = new Link( $oid );
+ $l->load();
+ if ( $l->isLinkToObject )
+ {
+ $op = new Object( $l->linkedObjectId );
+ $op->load();
+ if ( $op->isPage )
+ {
+ $p = new Page( $l->linkedObjectId );
+ $p->public = $this->page->public;
+ $p->projectmodelid = $this->page->projectmodelid;
+ $p->languageid = $this->languageid;
+ $p->load();
+ $p->generate();
+ $inhalt .= $p->value;
+ unset( $p );
+ }
+ }
+ break;
+ }
+ }
+ else die('FATAL: recursion detected');
+ }
+ }
+ else die('FATAL: recursion detected');
+ }
+
+ if ( $this->simple )
+ {
+ $inhalt = strip_tags( $inhalt );
+ $inhalt = str_replace( "\n",'',$inhalt );
+ $inhalt = str_replace( "\r",'',$inhalt );
+ }
+
+ break;
+
+
+ case 'link':
+
+ $objectid = $this->linkToObjectId;
+
+ if ( intval($objectid) == 0 )
+ $objectid = $this->element->defaultObjectId;
+
+ if ( $this->simple )
+ {
+ $p = new Page( $objectid );
+ $p->load();
+ $inhalt = $p->name;
+ }
+ else
+ {
+ $inhalt = $this->page->path_to_object( $objectid );
+ }
+
+ break;
+
+
+ case 'longtext':
+ case 'text':
+
+ $inhalt = $this->text;
+
+ if ( $inhalt == '' )
+ $inhalt = $this->element->defaultText;
+
+ // Wenn HTML nicht erlaubt ist, dann die HTML-Tags ersetzen
+ if ( !$this->element->html )
+ {
+ $inhalt = str_replace('<','<',$inhalt);
+ $inhalt = str_replace('>','>',$inhalt);
+ }
+
+ // Schnellformatierung ('Wiki') durchführen
+ if ( $this->element->wiki )
+ {
+ $inhalt = $this->decode_wiki( $inhalt );
+ }
+
+ if ( $this->simple )
+ {
+ $inhalt = strip_tags( $inhalt );
+ $inhalt = str_replace( "\n",'',$inhalt );
+ $inhalt = str_replace( "\r",'',$inhalt );
+ }
+
+ break;
+
+
+ // Zahl
+ //
+ // wird im entsprechenden Format angezeigt.
+ case 'number':
+
+ $number = $this->number / pow(10,$this->element->decimals);
+ $inhalt = number_format( $number,$this->element->decimals,$this->element->decPoint,$this->element->thousandSep );
+
+ break;
+
+
+ // Datum
+ case 'date':
+
+ $date = $this->date;
+ if ( intval($date) == 0 )
+ $date = time();
+
+ $inhalt = date( $this->element->dateformat,$date );
+
+ break;
+
+
+ // Programmcode (PHP)
+ case 'code':
+
+ $this->page->load();
+
+ Api::delOutput('');
+ $code = "<?php\n".$this->element->code."\n?>";
+ $tmp = $conf_tmpdir.'/'.md5($this->element->elementid).'.tmp';
+ $f = fopen( $tmp,'w' );
+ fwrite( $f,$code );
+ fclose( $f );
+
+ require( $tmp );
+
+ $inhalt = Api::getOutput();
+
+ break;
+
+
+ // Info-Feld als Datum
+ case 'infodate':
+
+ switch( $this->element->subtype )
+ {
+ case 'date_published':
+ $inhalt = date( $this->element->dateformat );
+ break;
+
+ case 'date_saved':
+ $inhalt = date( $this->element->dateformat );
+ break;
+
+ case 'date_created':
+ $inhalt = date( $this->element->dateformat );
+ break;
+
+ default:
+ $inhalt = date( $this->element->dateformat );
+ }
+
+ break;
+
+
+ // Info-Feld
+ case 'info':
+
+ switch( $this->element->subtype )
+ {
+ case 'db_id':
+ $inhalt = $SESS['dbid'];
+ break;
+ case 'db_name':
+ $inhalt = '';
+ break;
+ case 'project_id':
+ $inhalt = '';
+ break;
+ case 'project_name':
+ $inhalt = '';
+ break;
+ case 'language_id':
+ $inhalt = '';
+ break;
+ case 'language_iso':
+ $inhalt = '';
+ break;
+ case 'language_name':
+ $inhalt = '';
+ break;
+ case 'page_id':
+ $inhalt = '';
+ break;
+ case 'page_name':
+ $inhalt = '';
+ break;
+ case 'page_desc':
+ $inhalt = '';
+ break;
+ case 'page_fullfilename':
+ $inhalt = '';
+ break;
+ case 'page_filename':
+ $inhalt = '';
+ break;
+ case 'page_extension':
+ $inhalt = '';
+ break;
+ case 'lastchange_user_username':
+ $inhalt = '';
+ break;
+ case 'lastchange_user_fullname':
+ $inhalt = '';
+ break;
+ case 'lastchange_user_mail':
+ $inhalt = '';
+ break;
+ case 'lastchange_user_desc':
+ $inhalt = '';
+ break;
+ case 'lastchange_user_tel':
+ $inhalt = '';
+ break;
+ case 'create_user_username':
+ $inhalt = '';
+ break;
+ case 'create_user_fullname':
+ $inhalt = '';
+ break;
+ case 'create_user_mail':
+ $inhalt = '';
+ break;
+ case 'create_user_desc':
+ $inhalt = '';
+ break;
+ case 'create_user_tel':
+ $inhalt = '';
+ break;
+ case 'act_user_username':
+ $inhalt = '';
+ break;
+ case 'act_user_fullname':
+ $inhalt = '';
+ break;
+ case 'act_user_mail':
+ $inhalt = '';
+ break;
+ case 'act_user_desc':
+ $inhalt = '';
+ break;
+ case 'act_user_tel':
+ $inhalt = '';
+ break;
+ default:
+ $inhalt = '';
+ }
+ break;
+ }
+
+ if ( $this->page->icons && $this->element->withIcon )
+ $inhalt = '<a href="do.'.$conf_php.'?action=pageelement&elementid='.$this->element->elementid.'&pageelementaction=edit'.'" title="'.$this->element->desc.'" target="cms_main_main"><img src="'.$conf['directories']['themedir'].'/images/icon_el_'.$this->element->type.'.png" border="0" align="left"></a>'.$inhalt;
+
+ $this->value = $inhalt;
+ }
+
+
+ /**
+ * Es werden Objekte mit einem Inhalt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByValue( $text )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_object}.id FROM {t_value} '.
+ ' LEFT JOIN {t_page} '.
+ ' ON {t_page}.id={t_value}.pageid '.
+ ' LEFT JOIN {t_object} '.
+ ' ON {t_object}.id={t_page}.objectid '.
+ ' WHERE {t_value}.text LIKE {text}'.
+ ' AND {t_value}.languageid={languageid}' );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'text' ,'%'.$text.'%' );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der letzten Änderung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByLastChangeUserId( $userid )
+ {
+
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_object}.id FROM {t_value} '.
+ ' LEFT JOIN {t_page} '.
+ ' ON {t_page}.id={t_value}.pageid '.
+ ' LEFT JOIN {t_object} '.
+ ' ON {t_object}.id={t_page}.objectid '.
+ ' WHERE {t_value}.lastchange_userid={userid}'.
+ ' AND {t_value}.languageid={languageid}' );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $db->getCol( $sql->query );
+ }
+}+
\ No newline at end of file