commit 2682e9a6f8ff801c3bfd67f411537af953c7732a
parent bfe27219f14dbb6bad6cbe3ab257e4ad6f8e760d
Author: dankert <devnull@localhost>
Date: Sun, 2 May 2004 21:28:26 +0200
geloescht
Diffstat:
5 files changed, 0 insertions(+), 2761 deletions(-)
diff --git a/functions/element.inc.php b/functions/element.inc.php
@@ -1,741 +0,0 @@
-<?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-03-13 23:09:48 dankert
-// *** empty log message ***
-//
-// ---------------------------------------------------------------------------
-
-
-class Element
-{
- var $elementid;
- var $templateid;
- var $pageid;
- var $languageid;
- var $type;
- var $name;
- var $value;
- var $page;
- var $folderid;
-
- function Element( $elementid )
- {
- $this->elementid = $elementid;
- }
-
-
- 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===",'===',$text );
- $text = str_replace( "\n---",'---',$text );
- $text = str_replace( "\n...",'...',$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;
- }
-
-
- if ( !$pre ) // nicht bei präformatiertem Text
- {
- // Überschrift 1. Ordnung
- if ( substr($zeile,0,3) == '!!!' )
- {
- $zeile = '<h1>'.substr($zeile,3).'</h1>';
- }
-
- if ( ereg( '\=\=\=$',$zeile ) )
- {
- $zeile = eregi_replace( '\=+$','',$zeile );
- $zeile = chop( $zeile );
- $zeile = '<h1>'.$zeile.'</h1>';
- }
-
-
- // Überschrift 2. Ordnung
- if ( substr($zeile,0,2) == '!!' )
- {
- $zeile = '<h2>'.substr($zeile,2).'</h2>';
- }
-
- if ( ereg( '\-\-\-$',$zeile ) )
- {
- $zeile = eregi_replace( '\-+$','',$zeile );
- $zeile = chop( $zeile );
- $zeile = '<h2>'.$zeile.'</h2>';
- }
-
-
- // Überschrift 3. Ordnung
- if ( substr($zeile,0,1) == '!' )
- {
- $zeile = '<h3>'.substr($zeile,1).'</h3>';
- }
-
- if ( ereg( '\.\.\.$',$zeile ) )
- {
- $zeile = eregi_replace( '\.+$','',$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 );
-
- // Links
-
- # abc->http://...-Links
-
-
- if ( $this->html )
- $pf = '>';
- else $pf = '>';
-
- # Links "mit->..."
- $zeile = ereg_replace( '\"([^\"]+)\"-'.$pf.'((https?|ftps?|page|file):\/\/([A-Za-z0-9._\/\,\?\=\&-]*))' , '<a href="\\2">\\1</a>', $zeile );
- $zeile = ereg_replace( '([A-Za-z0-9._?äöüÄÖÜß-]+)-'.$pf.'((https?|ftps?|page|file):\/\/([A-Za-z0-9._\/\,\?\=\&-]*))', '<a href="\\2">\\1</a>', $zeile );
-
- # alleinstehende HTTP oder FTP-Links
- $zeile = ereg_replace( '([^"])((https?|ftps?|page|file):\/\/([A-Za-z0-9._\/\,-]*))', '\\1<a href="\\2">\\4</a>', $zeile );
- $zeile = ereg_replace( '^((https?|ftps?|page|file):\/\/([A-Za-z0-9._\/\,-]*))', '<a href="\\1">\\3</a>', $zeile );
- $zeile = ereg_replace( '((ima?ge?):\/\/([0-9]+))(\{.*\})?', '<img src="\\1" />', $zeile );
- //$zeile = ereg_replace( '((https?|ftps?|page|file):\/\/([A-Za-z0-9._\/-]*))', '<a href="\\1">\\3</a>', $zeile );
-
- # mailto:...-Links
- $zeile = ereg_replace( '([A-Za-z0-9._-]+@[A-Za-z0-9._-]+)', '<a href="mailto:\\1">\\1</a>', $zeile );
-
- // Links image://... ersetzen
- preg_match_all( '|ima?ge?:\/\/([0-9]+)(\{.*\})?| ',$zeile,$images,PREG_SET_ORDER );
- //print_r($images);
- foreach( $images as $image )
- {
- //echo "id".$image[1].'<br>';
- $var = $this->page->path_to_file( $image[1] );
- //echo "ergibt".$var.'<br>';
- $zeile = str_replace( $image[0],$var,$zeile );
- }
-
- // Links page://... ersetzen
- preg_match_all( '|page:\/\/([0-9]+)(\{.*\})?|',$zeile,$pages,PREG_SET_ORDER );
- foreach( $pages as $page )
- {
- $var = $this->page->path_to_object( $page[1] );
- $zeile = str_replace( $page[0],$var,$zeile );
- }
-
- // Links file://... ersetzen
- preg_match_all( '|file:\/\/([0-9]+)(\{.*\})?|',$zeile,$files,PREG_SET_ORDER );
- foreach( $files as $file )
- {
- $var = $this->page->path_to_file( $file[1] );
- $zeile = str_replace( $file[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 add( $name )
- {
- }
-
-
-
- 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['desc'];
- $this->type = $prop['type'];
- $this->subtype = $prop['subtype'];
-
- if ( $prop['with_icon'] == '1' )
- $this->with_icon = true;
- else $this->with_icon = false;
-
- $this->folderid = $prop['folderid'];
- $this->extension = $prop['extension'];
- $this->dateformat = $prop['dateformat'];
- $this->width = $prop['width'];
- $this->height = $prop['height'];
-
- if ( $prop['wiki'] == '1' )
- $this->wiki = true;
- else $this->wiki = false;
-
- if ( $prop['html'] == '1' )
- $this->html = true;
- else $this->html = false;
-
- $this->decimals = $prop['decimals'];
- $this->dec_point = $prop['dec_point'];
- $this->thousand_sep = $prop['thousand_sep'];
- $this->code = $prop['code'];
- $this->default_text = $prop['default_text'];
- $this->default_objectid = intval($prop['default_objectid']);
- }
-
-
-
- // Element speichern
- function save()
- {
- $db = db_connection();
-
- $sql = new Sql( 'UPDATE {t_element}'.
- ' SET templateid = {templateid},'.
- ' name = {name},'.
- ' `desc` = {desc},'.
- ' type = {type},'.
- ' subtype = {subtype},'.
- ' with_icon = {with_icon},'.
- ' folderid = {folderid},'.
- ' extension = {extension},'.
- ' dateformat = {dateformat},'.
- ' width = {width},'.
- ' height = {height},'.
- ' wiki = {wiki},'.
- ' html = {html},'.
- ' decimals = {decimals},'.
- ' dec_point = {dec_point},'.
- ' thousand_sep = {thousand_sep},'.
- ' code = {code},'.
- ' default_text = {default_text},'.
- ' default_objectid= {default_objectid}'.
- ' 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( 'with_icon' ,$this->with_icon );
- $sql->setInt ( 'folderid' ,$this->folderid );
- $sql->setString ( 'extension' ,$this->extension );
- $sql->setString ( 'dateformat' ,$this->dateformat );
- $sql->setInt ( 'width' ,$this->width );
- $sql->setInt ( 'height' ,$this->height );
- $sql->setBoolean( 'wiki' ,$this->wiki );
- $sql->setBoolean( 'html' ,$this->html );
- $sql->setInt ( 'decimals' ,$this->decimals );
- $sql->setString ( 'dec_point' ,$this->dec_point );
- $sql->setString ( 'thousand_sep' ,$this->thousand_sep );
- $sql->setString ( 'code' ,$this->code );
- $sql->setString ( 'default_text' ,$this->default_text );
- $sql->setInt ( 'default_objectid',$this->default_objectid );
-
-// echo $sql->query;
-
- $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 );
- }
-
-
- function delete()
- {
- // 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 );
-
- // Element löschen
- $sql = new Sql('DELETE FROM {t_element} '.
- ' WHERE id={elementid}' );
- $sql->setInt( 'elementid',$this->elementid );
-
- $db->query( $sql->query );
- }
-
-
- function generate()
- {
- $this->load();
- global $db,
- $conf,
- $conf_php,
- $conf_tmpdir,
- $SESS;
-
- // Inhalt aus Datenbank lesen
- $sql = new Sql('SELECT * FROM {t_value} '.
- ' WHERE elementid={elementid}'.
- ' AND pageid={pageid}'.
- ' AND languageid={languageid}' );
-
- $sql->setInt('elementid' ,$this->elementid );
- $sql->setInt('pageid' ,$this->pageid );
- $sql->setInt('languageid',$this->languageid );
-
- $val = $db->getRow( $sql->query );
-
- $this->lastchange_date = $val['lastchange_date' ];
- $this->lastchange_userid = $val['lastchange_userid'];
- $inhalt = '';
-
- switch( $this->type )
- {
- case 'include':
-
- // Ermitteln des Inhalte
- // (hier kann es mehrere Ergebnisse geben)
- $res_incl = $db->query( $sql->query );
-
- while( $row_incl = $res_incl->fetchRow() )
- {
- // Rekursion vermeiden
- if ( $row_incl['linkpageid'] != $this->pageid )
- {
- $p = new Page( Page::getObjectIdFromPageId($row_incl['linkpageid']) );
- $p->public = $this->page->public;
- $p->projectmodelid = $this->page->projectmodelid;
- $p->languageid = $this->languageid;
- $p->load();
- $p->generate();
- $inhalt .= $p->value;
- unset( $p );
- }
- }
-
- if ( $this->simple )
- {
- $inhalt = strip_tags( $inhalt );
- $inhalt = str_replace( "\n",'',$inhalt );
- $inhalt = str_replace( "\r",'',$inhalt );
- }
-
- break;
-
-
-
- case 'resize':
-
- $fileid = $val['fileid'];
-
- if ( $fileid == '' )
- $fileid = $this->default_fileid;
-
- if ( $this->public )
- {
- $inhalt = $this->up_path();
-
- $file = new File();
- $file->fileid = $fileid;
-
- $inhalt .= $file->full_filename();
- }
- else
- {
- $inhalt = "file.$conf_php?fileaction=showresize&fileid=".$fileid."&width=".$el['width']."&height=".$el['height'];
- $inhalt = sid($inhalt);
- }
-
- break;
-
-
- case 'file':
- case 'link':
-
- $objectid = $val['linkobjectid'];
-
- if ( !is_numeric($objectid) || $objectid==0 )
- $objectid = $this->default_objectid;
-
- if ( $this->simple )
- {
- $p = new Page( $objectid );
- $p->load();
- $inhalt = $p->name;
- }
- else
- {
-// echo "p2o $objectid";
- $inhalt = $this->page->path_to_object( $objectid );
-// echo "Inhalt: $inhalt <br>";
- }
-
- break;
-
-
- case 'longtext':
-
- $inhalt = $val['text'];
-
- if ( $inhalt == '' )
- $inhalt = $this->default_text;
-
- // Wenn HTML nicht erlaubt ist, dann die HTML-Tags ersetzen
- if ( !$this->html )
- {
- $inhalt = str_replace('<','<',$inhalt);
- $inhalt = str_replace('>','>',$inhalt);
- }
-
- // Schnellformatierung ('Wiki') durchführen
- if ( $this->wiki )
- {
- $inhalt = $this->decode_wiki( $inhalt );
- }
-
- if ( $this->simple )
- {
- $inhalt = strip_tags( $inhalt );
- $inhalt = str_replace( "\n",'',$inhalt );
- $inhalt = str_replace( "\r",'',$inhalt );
- }
-
- break;
-
-
- case 'text':
-
- $inhalt = $val['text'];
-
- if ( $inhalt == '' )
- $inhalt = $this->default_text;
-
- // Wenn HTML nicht erlaubt ist, dann die HTML-Tags ersetzen
- if ( $this->html )
- {
- $inhalt = str_replace('<','<',$inhalt);
- $inhalt = str_replace('>','>',$inhalt);
- }
-
- // Schnellformatierung ('Wiki') durchführen
- if ( $this->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 = $val['number'] / pow(10,$this->decimals);
- $inhalt = number_format( $number,$this->decimals,$this->dec_point,$this->thousand_sep );
-
- break;
-
-
- // Datum
- case 'date':
-
- if ( !is_numeric($val['date']) )
- $val['date'] = time();
-
- $inhalt = date( $this->dateformat,$val['date'] );
-
- break;
-
-
- // Programmcode (PHP)
- case 'code':
-
- $this->page->load();
-
- Api::delOutput('');
- $code = "<?php\n".$this->code."\n?>";
- $tmp = $conf_tmpdir.'/'.md5($this->pageid.'_'.$this->projectmodelid.'_'.$this->elementid).'.tmp';
- $f = fopen( $tmp,'w' );
- fwrite( $f,$code );
- fclose( $f );
-
- //error_reporting( E_NOTICE );
- require( $tmp );
- //error_reporting( E_PARSE );
-
- $inhalt = Api::getOutput();
-
- break;
-
-
- // Info-Feld als Datum
- case 'infodate':
-
- $inhalt = date( $this->dateformat );
-
- break;
-
-
- // Info-Feld
- case 'info':
-
- //echo "aha:".$el['subtype'].'<br>';
- if ( $this->subtype == 'id_db' )
- $inhalt = $SESS['dbid'];
-
- if ( $this->subtype == 'id_project' )
- $inhalt = $SESS['projectid'];
-
- if ( $this->subtype == 'id_projectmodel' )
- $inhalt = $this->projectmodelid;
-
- if ( $this->subtype == 'id_language' )
- $inhalt = $this->languageid;
-
- if ( $this->subtype == 'id_page' )
- $inhalt = $SESS['pageid'];
-
- if ( $this->subtype == 'id_user' )
- $inhalt = $SESS['user']['id'];
-
- if ( $this->subtype == 'id_pageuser' )
- $inhalt = '0';
-
- if ( $this->subtype == 'name_db' )
- $inhalt = $conf['database_'.$SESS['dbid']]['name'];
-
- if ( $this->subtype == 'name_project' )
- {
- $sql = "SELECT name FROM $t_project WHERE id=".$SESS['projectid'];
- $inhalt = $db->getOne($sql);
- }
-
- if ( $this->subtype == 'name_page' )
- {
- $inhalt = $this->page->name;
- }
-
- if ( $this->subtype == 'name_user' )
- $inhalt = $SESS['user']['name'];
-
- if ( $this->subtype == 'fullname_user' )
- $inhalt = $SESS['user']['fullname'];
-
- if ( $this->subtype == 'mail_user' )
- $inhalt = $SESS['user']['mail'];
-
- if ( $this->subtype == 'name_pageuser' )
- {
- $sql = "SELECT name FROM $t_user WHERE id=1";
- $inhalt = $db->getOne($sql);
- }
-
- break;
- }
-
- if ( $this->icons && $this->with_icon )
- $inhalt = '<a href="'.sid('pageelement.'.$conf_php.'?elementid='.$this->id.'&pageelementaction=edit').'" title="'.$this->desc.'" target="cms_main_main"><img src="'.$conf['directories']['themedir'].'/images/icon_el_'.$this->type.'.gif" border="0" align="left"></a>'.$inhalt;
-
- $this->value = $inhalt;
- }
-}-
\ No newline at end of file
diff --git a/functions/file.inc.php b/functions/file.inc.php
@@ -1,362 +0,0 @@
-<?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 2003-10-27 23:21:55 dankert
-// Methode(n) hinzugefügt: savevalue(), save()
-//
-// ---------------------------------------------------------------------------
-
-
-class File
-{
- var $fileid;
-
- var $folderid;
- var $filename = '';
- var $name = '';
- var $desc;
- var $size;
- var $create_date;
- var $create_userid;
- var $lastchange_date;
- var $lastchange_userid;
- var $extension;
- var $tmpfile;
- var $value;
- var $log_filenames = array();
-
- function File( $fileid='' )
- {
- if ( is_numeric($fileid) )
- $this->fileid = $fileid;
- }
-
-
- function parse_filename( $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 full_filename()
- {
- $path = $this->path();
- if ( $path != '' )
- $path .= '/';
-
- $path .= $this->filename();
-
- if ( $this->extension() != '' )
- $path .= '.'.$this->extension();
-
- return $path;
- }
-
-
- function resize( $width,$height )
- {
- global $conf;
-
- // Bildinformationen ermitteln
- $size = getimagesize( $this->tmpfile );
- $breite = $size[0];
- $hoehe = $size[1];
-
- $neueBreite=$width;
- $neueHoehe=intval($hoehe*$neueBreite/$breite);
-
- if ( $size[2]==1 )
- {
- // GIF
- $altesBild=ImageCreateFromGIF( $this->tmpfile );
- $neuesBild=ImageCreate($neueBreite,$neueHoehe);
- ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,
- $neueHoehe,$breite,$hoehe);
- ImageGIF($neuesBild, $this->tmpfile );
- }
-
- if ( $size[2]==2 )
- {
- // JPG
- $altesBild=ImageCreateFromJPEG( $this->tmpfile );
-
- if ( $conf['gd']['version'] >= 2 )
- {
- // Verwende TrueColor
- $neuesBild = imageCreateTrueColor( $neueBreite,$neueHoehe );
-
- ImageCopyResampled($neuesBild,$altesBild,0,0,0,0,$neueBreite,
- $neueHoehe,$breite,$hoehe);
- }
- else
- {
- // GD Version 1.x unterstützt kein TrueColor
- $neuesBild = ImageCreate($neueBreite,$neueHoehe);
-
- ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,
- $neueHoehe,$breite,$hoehe);
- }
-
- ImageJPEG($neuesBild, $this->tmpfile );
- }
-
- if ( $size[2]==3 )
- {
- // PNG
- $altesBild = ImageCreateFromPNG( $this->tmpfile );
-
- // Versuche TrueColor, sofern möglich.
- $neuesBild = @imageCreateTrueColor( $neueBreite,$neueHoehe );
- if ( ! $dst_img )
- {
- $neuesBild = ImageCreate($neueBreite,$neueHoehe);
- }
-
- ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
- ImagePNG( $neuesBild,$this->tmpfile );
- }
- }
-
-
- function path()
- {
- $folder = new Folder( $this->folderid );
- $folder->load();
- $folder->parentfolder( false,true );
-
- return implode( '/',$folder->parentfolders );
- }
-
-
- function filename()
- {
- if ( $this->filename!='' )
- return $this->filename;
-
- global $db;
- extract( table_names() );
-
- $sql = "SELECT filename FROM $t_file WHERE id=".$this->fileid;
- $this->filename = $db->getOne( $sql );
-
- return $this->filename;
- }
-
-
- function extension()
- {
- if ( $this->extension!='' )
- return $this->extension;
-
- global $db;
- extract( table_names() );
-
- $sql = "SELECT extension FROM $t_file WHERE id=".$this->fileid;
- $this->extension = $db->getOne( $sql );
-
- return $this->extension;
- }
-
-
- // Lesen der Datei aus der Datenbank
- function load()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT folderid,filename,name,extension,`desc`,size,create_date,create_userid,lastchange_date,lastchange_userid'.
- ' FROM {t_file}'.
- ' WHERE id={fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
- $row = $db->getRow( $sql->query );
-
- $this->folderid = $row['folderid'];
-
- $this->filename = eregi_replace('[^a-z0-9\.\_\-]','',$row['filename']); // RFC 1630
- if ( $this->filename == '' )
- $this->filename = 'f'.$this->fileid;
- $this->name = $row['name'];
- $this->extension = $row['extension'];
- $this->size = $row['size'];
- $this->desc = $row['desc'];
- $this->create_date = $row['create_date' ];
- $this->create_userid = $row['create_userid' ];
- $this->lastchange_date = $row['lastchange_date' ];
- $this->lastchange_userid = $row['lastchange_userid'];
- }
-
-
-
- function delete()
- {
- $db = db_connection();
-
- // Alle Inhalte mit dieser Datei löschen
- $sql = new Sql( 'DELETE FROM {t_value} '.
- ' WHERE fileid={fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
- $db->query( $sql->query );
-
- // Alle Elemente dieser Datei als Default-Inhalt auf NULL setzen
- $sql = new Sql( 'UPDATE {t_element} '.
- ' SET default_fileid = NULL'.
- ' WHERE default_fileid = {fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
- $db->query( $sql->query );
-
- // Datei löschen
- $sql = new Sql( 'DELETE FROM {t_file} '.
- ' WHERE id={fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
- $db->query( $sql->query );
- }
-
-
-
- function save()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('UPDATE {t_file} SET '.
- ' folderid={folderid},'.
- ' lastchange_date = {time} ,'.
- ' lastchange_userid = {userid},'.
- ' filename = {filename} ,'.
- ' name = {name} ,'.
- ' extension = {extension},'.
- ' `desc` = {desc} '.
- ' WHERE id={fileid}' );
- $sql->setInt ('fileid' ,$this->fileid );
- $sql->setInt ('folderid' ,$this->folderid );
- $sql->setString('filename' ,$this->filename );
- $sql->setString('name' ,$this->name );
- $sql->setString('desc' ,$this->desc );
- $sql->setString('extension',$this->extension);
- $sql->setInt ('time' ,time() );
- $sql->setInt ('userid' ,$SESS['user']['id'] );
- $sql->setString('value' ,$this->value );
-
- $db->query( $sql->query );
- }
-
-
- // Lesen der Datei aus der Datenbank
- function loadvalue()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT value'.
- ' FROM {t_file}'.
- ' WHERE id={fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
- $this->value = &$db->getOne( $sql->query );
-
- return( $this->value );
- }
-
-
- // Lesen der Datei aus der Datenbank
- function savevalue()
- {
- $db = db_connection();
-
- $sql = new Sql( 'UPDATE {t_file}'.
- ' SET value={value} '.
- ' WHERE id={fileid}' );
- $sql->setInt ( 'fileid',$this->fileid );
- $sql->setString( 'value' ,$this->value );
-
- $db->query( $sql->query );
- }
-
-
- // Lesen der Datei aus der Datenbank
- function write()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT value'.
- ' FROM {t_file}'.
- ' WHERE id={fileid}' );
- $sql->setInt( 'fileid',$this->fileid );
-
- $f = fopen( $this->tmpfile(),'w' );
- fwrite( $f,$db->getOne( $sql->query ) );
- fclose( $f );
- }
-
-
- function add()
- {
- $db = db_connection();
-
- $sql = new Sql('INSERT INTO {t_file}'.
- ' (folderid,name,filename,extension,size,`desc`,create_date,create_userid,lastchange_date,lastchange_userid,value)'.
- ' VALUES( {folderid},{name},{filename},{extension},{filesize},{desc},{time},{userid},{time},{userid},{value} )' );
- $sql->setInt ('folderid' ,$this->folderid );
- $sql->setString('filename' ,$this->filename );
- $sql->setString('name' ,$this->name );
- $sql->setString('extension',$this->extension);
- $sql->setInt ('filesize' ,strlen($this->value) );
- $sql->setString('desc' ,$this->desc );
- $sql->setInt ('time' ,$this->create_date );
- $sql->setInt ('userid' ,$this->create_userid );
- $sql->setString('value' ,addslashes($this->value) );
-
- $db->query( $sql->query );
- }
-
-
- function tmpfile()
- {
- global $conf_tmpdir;
-
- $this->tmpfile = $conf_tmpdir.'/tmp_file'.$this->fileid.'.tmp';
- //$this->tmpfile = $conf_tmpdir.'/'.md5('f'.$this->fileid).'.tmp';
-
- return $this->tmpfile;
- }
-
-
- function publish()
- {
- $publish = new Publish();
-
- $this->write();
-
- $publish->copy( $this->tmpfile(),$this->full_filename() );
-
- $this->log_filenames = $publish->log_filenames;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/functions/object.class.php b/functions/object.class.php
@@ -1,560 +0,0 @@
-<?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.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;
- }
-
- $this->languageid = $SESS['languageid'];
- $this->modelid = $SESS['projectmodelid'];
- $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();
-
- $sql = new Sql('SELECT id from {t_object} '.
- ' WHERE projectid={projectid}');
- $sql->setInt('projectid', $this->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;
- }
-
- function checkRight($type)
- {
- return true;
- global $SESS;
-
- if ($SESS['user']['is_admin'] == '1')
- return true;
-
- if ($SESS['rights'][$this->projectid][$this->objectid][$type] == '1')
- 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';
- }
-
-
- /**
- * 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}.description'.' 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['description'];
- }
-
-
- // 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 )
- $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} ,'.' description = {desc} '.' WHERE objectid ={objectid}'.' AND languageid={languageid}');
- $sql->setString('name', $this->name);
- $sql->setString('desc', $this->desc);
- $db->query($sql->query);
- }
- else
- {
- $sql->setQuery('INSERT INTO {t_name}'.' (objectid,languageid,name,description)'.' VALUES( {objectid},{languageid},{name},{desc} )');
- $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();
-
- // 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);
-
- }
-
-
- /**
- * Objekt hinzufuegen
- */
- function objectAdd()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('SELECT COUNT(*) FROM {t_object}'.' WHERE parentid={parentid} AND filename={filename}');
- $sql->setString('filename', $this->filename);
- $sql->setInt('parentid', $this->parentid);
-
- // Falls Objekt mit diesem Dateinamen bereits existiert, dann Dateinamen aendern
- if ($db->getOne($sql->query) > 0)
- {
- $this->filename .= time();
- }
-
- $sql = new Sql('INSERT INTO {t_object}'.
- ' (parentid,projectid,filename,orderid,create_date,create_userid,lastchange_date,lastchange_userid,is_folder,is_file,is_page,is_link)'.
- ' VALUES( {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->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);
-
- // Hinzugefügte Objekt-ID bestimmen
- if ( $this->isRoot )
- $sql->setQuery('SELECT id FROM {t_object}'.' WHERE parentid IS NULL AND filename={filename}');
- else $sql->setQuery('SELECT id FROM {t_object}'.' WHERE parentid={parentid} AND filename={filename}');
-
- $this->objectid = $db->getOne($sql->query);
-
- $this->objectSaveName();
- }
-
-
- /**
- * Dateinamen der temporaeren Datei bestimmen
- */
- function tmpfile()
- {
- global $conf_tmpdir;
-
- $this->tmpfile = $conf_tmpdir.'/tmp_file'.$this->fileid.'.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);
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/functions/page.inc.php b/functions/page.inc.php
@@ -1,622 +0,0 @@
-<?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-03-20 14:15:00 dankert
-// Kommentare
-//
-// ---------------------------------------------------------------------------
-
-
-// Ermitteln der Ordner, in dem sich die Seite befindet
-//
-
-/*
-function p1age_get_folder( $pageid,$filenames=true )
-{
- global $conf,
- $SESS,
- $db;
-
- if (!isset($db))
- $db = new DB( $conf['database_'.$SESS['dbid']] );
-
- $t_page = $conf_db_prefix.'page';
- $sql = "SELECT folderid FROM $t_page WHERE id=".$SESS['pageid'];
- //echo "sql:$sql";
- $folderid = $db->getOne($sql);
-
- return folder_path( $folderid,$filenames );
-}
-
-
-// Ermitteln aller übergeordneten Ordner
-//
-function foldser_path( $folderid,$filenames=true )
-{
- global $conf,
- $SESS,
- $db;
-
- if (!isset($db))
- $db = new DB( $conf['database_'.$SESS['dbid']] );
-
- $folder = array();
-
- if ( $folderid == '' )
- return $folder;
-
- do
- {
- $t_folder = $conf_db_prefix.'folder';
- $sql = "SELECT * FROM $t_folder WHERE id=".$folderid;
- $res_folder = $db->query( $sql );
- $row_folder = $res_folder->fetchRow(DB_FETCHMODE_ASSOC);
- if ( $filenames )
- $folder[ $folderid ] = $row_folder['filename'];
- else $folder[ $folderid ] = $row_folder['name'];
- $folderid = $row_folder['parentid'];
- $res_folder->free();
- }
- while( $row_folder['parentid'] != null );
-
- // Array in umgekehrter Reihenfolge zurückgeben
- return array_reverse($folder,true);
-}
-*/
-
-
-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 $name;
- var $ext;
- var $edit = false;
-
- var $content_negotiation = false;
- var $cut_index = false;
- var $default_language = false;
- var $link = false;
-
- var $log_filenames = array();
-
-
- function Page( $objectid='' )
- {
- $this->Object( $objectid );
- $this->isPage = true;
- }
-
-
- /**
- * 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 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;
-
- $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 = "file.$conf_php?fileaction=show&objectid=".$objectid;
- break;
-
- case 'page':
- $inhalt = "page.$conf_php?pageaction=".$SESS['pageaction'].
- '&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 = "file.$conf_php?fileaction=show&objectid=".$link->linkedObjectId;
- break;
-
- case 'page':
- $inhalt = "page.$conf_php?pageaction=".$SESS['pageaction'].
- '&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->parentfolder(false,true);
- $f = count( $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('INSERT INTO {t_page}'.
- ' (objectid,templateid)'.
- ' VALUES( {objectid},{templateid} )' );
- $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 );
- echo $sql->query.'<br>';
-
- $sql = new Sql( 'DELETE FROM {t_page} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $db->query( $sql->query );
-
- echo $sql->query.'<br>';
-
- $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->projectmodelid;
- $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()
- {
- $t = new Template( $this->templateid );
-
- foreach( $t->getElementIds() as $elementid )
- {
- // neues Elementobjekt erzeugen
- $el = new Element( $elementid );
- $el->objectid = $this->objectid;
- $el->pageid = Page::getPageIdFromObjectId( $this->objectid );
- $el->languageid = $this->languageid;
- $el->simple = $this->simple;
- $el->page = &$this;
- $el->generate();
- $this->el[$elementid] = $el;
- }
- }
-
-
- /**
- * 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->el as $id=>$el )
- {
- $inh = $el->value;
- $src = str_replace( '{{'.$id.'}}',$inh,$src );
-
- if ( $this->icons )
- $src = str_replace( '{{->'.$id.'}}','<a href="'.sid('pageelement.'.$conf_php.'?elementid='.$id.'&pageelementaction=edit').'" title="'.$el['desc'].'" target="cms_main_main"><img src="'.$conf['directories']['themedir'].'/images/icon_el_'.$el['type'].'.gif" 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();
-
- $publish = new Publish();
-
- $this->content_negotiation = $publish->content_negotiation;
- $this->cut_index = $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>';
- $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 ( $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 = $publish->log_filenames;
- }
-}
-
-
-?>-
\ No newline at end of file
diff --git a/functions/user.inc.php b/functions/user.inc.php
@@ -1,471 +0,0 @@
-<?php
-#
-# DaCMS Content Management System
-# Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-
-
-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}' );
-
- return $db->getAssoc( $sql->query );
- }
-
-
- function setCurrent()
- {
- global $SESS;
-
- $SESS['user'] = array();
- $SESS['user']['id'] = $this->userid;
- $SESS['user']['name'] = $this->name;
- $SESS['user']['fullname'] = $this->fullname;
- $SESS['user']['mail'] = $this->mail;
- $SESS['user']['is_admin'] = $this->isAdmin;
- $SESS['user']['style'] = $this->style;
- }
-
-
- // 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['desc' ];
-
- 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} ,'.
- ' `desc` ={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( 'url' ,$this->url );
- $sql->setString( 'style' ,$this->style );
- $sql->setString( '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('INSERT INTO {t_user}'.
- ' (name)'.
- ' VALUES( {name} )' );
- $sql->setString('name',$this->name);
-
- // Datenbankbefehl ausfuehren
- $db->query( $sql->query );
- }
-
-
- // Benutzer entfernen
- function delete()
- {
- // 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 );
- }
-
-
- // 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'] != '' )
- {
- // 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;
- }
-
- // LDAP-Login versuchen
- if ( @ldap_bind( $ldap_conn,$row_user['ldap_dn'],$password) )
- {
- // Login erfolgreich
- $SESS['user'] = $row_user;
- return true;
- }
- }
- else
- {
-// echo "aha";
-// echo $row_user['password'].':'.$password':'.md5( $password );
- // 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 *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( 'INSERT INTO {t_usergroup} '.
- ' (userid,groupid) '.
- ' VALUES( {userid},{groupid} )' );
- $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 );
- }
-
-
- // 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