openrat-cms

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

commit d86ff8c9734055e284e1c1b168816bf902d0fc4b
parent 506f5495f7bca3663ca09b54503544d3432a3d7c
Author: Jan Dankert <devnull@localhost>
Date:   Fri,  8 Dec 2017 22:29:13 +0100

Neuer Objekttyp 'url' mit Modelklasse, Actionklasse und anderen Änderungen. Darüber hinaus benötigt die Methode query() aus dem Statement keinen Parameter mehr.

Diffstat:
action/LinkAction.class.php | 21+++++----------------
action/UrlAction.class.php | 212+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
db/DbUpdate.class.php | 4++--
db/update/DBVersion000001.class.php | 2+-
init.php | 3++-
model/Acl.class.php | 4++--
model/Element.class.php | 10+++++-----
model/File.class.php | 8++++----
model/Folder.class.php | 15+++++++++++----
model/Group.class.php | 16++++++++--------
model/Language.class.php | 16++++++++--------
model/Link.class.php | 107++++++++++++++++++++++---------------------------------------------------------
model/Model.class.php | 14+++++++-------
model/Object.class.php | 43+++++++++++++++++++++++++++++--------------
model/Page.class.php | 14+++++++-------
model/Project.class.php | 6+++---
model/Template.class.php | 10+++++-----
model/Url.class.php | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
model/User.class.php | 24++++++++++++------------
model/Value.class.php | 14+++++++-------
model/include.inc.php | 31++++++++++++++++---------------
modules/database/Database.class.php | 2+-
modules/database/Statement.class.php | 14++++++--------
23 files changed, 496 insertions(+), 208 deletions(-)

diff --git a/action/LinkAction.class.php b/action/LinkAction.class.php @@ -39,8 +39,7 @@ class LinkAction extends ObjectAction { public $security = SECURITY_USER; - var $link; - var $defaultSubAction = 'prop'; + private $link; /** * Konstruktor @@ -97,19 +96,10 @@ class LinkAction extends ObjectAction { if( $this->getRequestVar('type') != '' ) { - if ( $this->getRequestVar('type') == 'link' ) - { - $this->link->isLinkToObject = true; - $this->link->isLinkToUrl = false; - $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); - } - else - { - $this->link->isLinkToObject = false; - $this->link->isLinkToUrl = true; - $this->link->url = $this->getRequestVar('url'); - } - + $this->link->isLinkToObject = true; + $this->link->isLinkToUrl = false; + $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); + $this->link->save(); $this->link->setTimestamp(); Session::setObject( $this->link ); @@ -132,7 +122,6 @@ class LinkAction extends ObjectAction $this->setTemplateVar('type' ,$this->link->getType() ); $this->setTemplateVar('targetobjectid' ,$this->link->linkedObjectId); $this->setTemplateVar('targetobjectname',$this->link->name ); - $this->setTemplateVar('url' ,$this->link->url ); } diff --git a/action/UrlAction.class.php b/action/UrlAction.class.php @@ -0,0 +1,211 @@ +<?php + +namespace cms\action; + +use cms\model\Folder; +use cms\model\Link; + + + + + +use Session; + +// OpenRat Content Management System +// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * Action-Klasse f?r Verkn?pfungen + * @version $Id$ + * @author $Author$ + * @package openrat.actions + */ +class UrlAction extends ObjectAction +{ + public $security = SECURITY_USER; + + var $link; + var $defaultSubAction = 'prop'; + + /** + * Konstruktor + */ + function __construct() + { + $this->link = new Link( $this->getRequestId() ); + $this->link->load(); + } + + + + function remove() + { + $this->setTemplateVars( $this->link->getProperties() ); + } + + + + function delete() + { + if ( $this->hasRequestVar("delete") ) + { + $this->link->delete(); + $this->addNotice('link',$this->link->name,'DELETED'); + } + } + + + + /** + * Abspeichern der Eigenschaften + */ + function propPost() + { + // Wenn Name gefuellt, dann Datenbank-Update + if ( $this->getRequestVar('name') != '' ) + { + // Eigenschaften speichern + $this->link->name = $this->getRequestVar('name' ,'full'); + $this->link->desc = $this->getRequestVar('description','full'); + + $this->link->save(); + $this->link->setTimestamp(); + Session::setObject( $this->link ); + } + } + + + /** + * Abspeichern der Eigenschaften + */ + function editPost() + { + if( $this->getRequestVar('type') != '' ) + { + if ( $this->getRequestVar('type') == 'link' ) + { + $this->link->isLinkToObject = true; + $this->link->isLinkToUrl = false; + $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); + } + else + { + $this->link->isLinkToObject = false; + $this->link->isLinkToUrl = true; + $this->link->url = $this->getRequestVar('url'); + } + + $this->link->save(); + $this->link->setTimestamp(); + Session::setObject( $this->link ); + + $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK); + } + else + { + $this->addNotice('link',$this->link->name,'NOT_SAVED',OR_NOTICE_WARN); + } + } + + + + public function editView() + { + $this->setTemplateVars( $this->link->getProperties() ); + + // Typ der Verknuepfung + $this->setTemplateVar('type' ,$this->link->getType() ); + $this->setTemplateVar('targetobjectid' ,$this->link->linkedObjectId); + $this->setTemplateVar('targetobjectname',$this->link->name ); + $this->setTemplateVar('url' ,$this->link->url ); + } + + + + function propView() + { + $this->setTemplateVars( $this->link->getProperties() ); + $this->setTemplateVar('act_linkobjectid',$this->link->linkedObjectId); + } + + + + function infoView() + { + $this->setTemplateVars( $this->link->getProperties() ); + } + + + /** + * Liefert die Struktur zu diesem Ordner: + * - Mit den übergeordneten Ordnern und + * - den in diesem Ordner enthaltenen Objekten + * + * Beispiel: + * <pre> + * - A + * - B + * - C (dieser Ordner) + * - Unterordner + * - Seite + * - Seite + * - Datei + * </pre> + */ + public function structureView() + { + + $structure = array(); + $tmp = &$structure; + $nr = 0; + + $folder = new Folder( $this->link->parentid ); + $parents = $folder->parentObjectNames(false,true); + + foreach( $parents as $id=>$name) + { + unset($children); + unset($o); + $children = array(); + $o = array('id'=>$id,'name'=>$name,'type'=>'folder','level'=>++$nr,'children'=>&$children); + + $tmp[$id] = &$o;; + + unset($tmp); + + $tmp = &$children; + } + + + + unset($children); + unset($id); + unset($name); + + $elementChildren = array(); + + $tmp[ $this->link->objectid ] = array('id'=>$this->link->objectid,'name'=>$this->link->name,'type'=>'link','self'=>true,'children'=>&$elementChildren); + + // + //$elementChildren[$id] = array('id'=>$this->page->objectid.'_'.$id,'name'=>$name,'type'=>'pageelement','children'=>array() ); + + //Html::debug($structure); + + $this->setTemplateVar('outline',$structure); + } +}+ \ No newline at end of file diff --git a/db/DbUpdate.class.php b/db/DbUpdate.class.php @@ -37,7 +37,7 @@ class DbUpdate $sql->setInt('version', $installVersion); $sql->setInt('status' , OR_DB_STATUS_UPDATE_PROGRESS); $sql->setInt('time' , time() ); - $sql->query( $sql ); + $sql->query(); $db->commit(); } @@ -58,7 +58,7 @@ class DbUpdate $sql->setInt('status' , OR_DB_STATUS_UPDATE_SUCCESS); $sql->setInt('version', $installVersion); $sql->setInt('time' , time() ); - $sql->query( $sql ); + $sql->query(); $db->commit(); } } diff --git a/db/update/DBVersion000001.class.php b/db/update/DBVersion000001.class.php @@ -342,7 +342,7 @@ class DBVersion000001 extends DbVersion if ( $countUsers == 0 ) { $sql = $db->sql("INSERT INTO {{user}} (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin) VALUES(1,'admin','admin','','Administrator','','','Account for administration tasks.','default',1)",$db->id); - $sql->query( $sql ); + $sql->query(); $db->commit(); } } diff --git a/init.php b/init.php @@ -27,10 +27,11 @@ define('MAX_FOLDER_DEPTH',5 ); define('OR_VERSION' ,'1.1-snapshot' ); define('OR_TITLE' ,'OpenRat CMS'); +define('OR_TYPE_FOLDER','folder'); define('OR_TYPE_PAGE' ,'page' ); define('OR_TYPE_FILE' ,'file' ); define('OR_TYPE_LINK' ,'link' ); -define('OR_TYPE_FOLDER','folder'); +define('OR_TYPE_URL' ,'url' ); define('OR_ACTIONCLASSES_DIR' ,'./action/' ); diff --git a/model/Acl.class.php b/model/Acl.class.php @@ -385,7 +385,7 @@ class Acl $sql->setInt('aclid' ,$this->aclid ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $this->aclid = 0; } @@ -505,6 +505,6 @@ SQL else $sql->setInt ('languageid',$this->languageid); - $sql->query( $sql ); + $sql->query(); } } \ No newline at end of file diff --git a/model/Element.class.php b/model/Element.class.php @@ -155,7 +155,7 @@ class Element $sql->setBoolean( 'writable' ,$this->writable ); $sql->setString ( 'description',$this->desc ); - $sql->query( $sql ); + $sql->query(); } @@ -277,7 +277,7 @@ SQL $sql->setNull( 'defaultObjectId' ); else $sql->setInt ( 'defaultObjectId' ,$this->defaultObjectId ); - $sql->query( $sql ); + $sql->query(); } @@ -300,7 +300,7 @@ SQL $sql->setInt ( 'elementid',$this->elementid ); $sql->setString ( 'type' ,$this->type ); - $sql->query( $sql ); + $sql->query(); } @@ -334,7 +334,7 @@ SQL ' WHERE id={elementid}' ); $sql->setInt( 'elementid',$this->elementid ); - $sql->query( $sql ); + $sql->query(); } @@ -350,7 +350,7 @@ SQL $sql = $db->sql('DELETE FROM {{value}} '. ' WHERE elementid={elementid}' ); $sql->setInt( 'elementid',$this->elementid ); - $sql->query( $sql ); + $sql->query(); } diff --git a/model/File.class.php b/model/File.class.php @@ -454,7 +454,7 @@ class File extends Object $sql = $db->sql( 'DELETE FROM {{file}} '. ' WHERE objectid={objectid}' ); $sql->setInt( 'objectid',$this->objectid ); - $sql->query( $sql ); + $sql->query(); $this->objectDelete(); } @@ -526,7 +526,7 @@ EOF $sql->setString('size' ,$this->size ); $sql->setString('extension',$this->extension ); $sql->setString('objectid' ,$this->objectid ); - $sql->query( $sql ); + $sql->query(); $this->objectSave(); } @@ -602,7 +602,7 @@ EOF else $sql->setString( 'value',$this->value ); - $sql->query( $sql ); + $sql->query(); } @@ -635,7 +635,7 @@ EOF $sql->setInt ('objectid' ,$this->objectid ); $sql->setString('extension',$this->extension ); - $sql->query( $sql ); + $sql->query(); $this->saveValue(); } diff --git a/model/Folder.class.php b/model/Folder.class.php @@ -60,7 +60,7 @@ class Folder extends Object $sql->setInt ('folderid' ,$this->folderid ); $sql->setInt ('objectid' ,$this->objectid ); - $sql->query( $sql ); + $sql->query(); } @@ -141,7 +141,7 @@ class Folder extends Object $sql->setInt('folderid',$this->folderid); $sql->setInt('orderid' ,$orderid ); - $sql->query( $sql ); + $sql->query(); } @@ -779,12 +779,12 @@ SQL ' SET folderobjectid=NULL '. ' WHERE folderobjectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'DELETE FROM {{folder}} '. ' WHERE objectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $this->objectDelete(); } @@ -832,6 +832,13 @@ SQL $link->delete(); } + if ( $object->isUrl ) + { + $url = new Url( $oid ); + $url->load(); + $url->delete(); + } + if ( $object->isFile ) { $file = new File( $oid ); diff --git a/model/Group.class.php b/model/Group.class.php @@ -118,7 +118,7 @@ class Group $sql->setInt ('groupid',$this->groupid ); // Datenbankabfrage ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -151,7 +151,7 @@ class Group $sql->setString('name' ,$this->name ); // Datenbankbefehl ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -164,20 +164,20 @@ class Group $sql = $db->sql( 'DELETE FROM {{acl}} '. 'WHERE groupid={groupid}' ); $sql->setInt ('groupid',$this->groupid ); - $sql->query( $sql ); + $sql->query(); // Alle Gruppenzugehoerigkeiten zu dieser Gruppe loeschen $sql = $db->sql( 'DELETE FROM {{usergroup}} '. 'WHERE groupid={groupid}' ); $sql->setInt ('groupid',$this->groupid ); - $sql->query($sql); + $sql->query(); // Gruppe loeschen $sql = $db->sql( 'DELETE FROM {{group}} '. 'WHERE id={groupid}' ); $sql->setInt ('groupid',$this->groupid ); - $sql->query($sql); + $sql->query(); } @@ -224,7 +224,7 @@ class Group $sql->setInt('userid' ,$userid ); $sql->setInt('groupid' ,$this->groupid ); - $sql->query( $sql ); + $sql->query(); } @@ -239,7 +239,7 @@ class Group $sql->setInt ('userid' ,$userid ); $sql->setInt ('groupid' ,$this->groupid ); - $sql->query( $sql ); + $sql->query(); } @@ -323,7 +323,7 @@ class Group $sql->setInt ('publish',$data['publish']); // Datenbankabfrage ausf?hren - $sql->query( $sql ); + $sql->query(); } diff --git a/model/Language.class.php b/model/Language.class.php @@ -151,7 +151,7 @@ SQL $sql->setInt( 'languageid',$this->languageid ); // Datenbankabfrage ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -197,7 +197,7 @@ SQL $sql->setString('isocode' ,$this->isoCode ); // Datenbankbefehl ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -212,14 +212,14 @@ SQL ' SET is_default = 0 '. ' WHERE projectid={projectid}' ); $sql->setInt('projectid',$this->projectid ); - $sql->query( $sql ); + $sql->query(); // Jetzt die gew?nschte Sprachvariante auf Standard setzen $sql = $db->sql( 'UPDATE {{language}} '. ' SET is_default = 1 '. ' WHERE id={languageid}' ); $sql->setInt('languageid',$this->languageid ); - $sql->query( $sql ); + $sql->query(); } @@ -260,17 +260,17 @@ SQL // Inhalte mit dieser Sprache l?schen $sql = $db->sql( 'DELETE FROM {{value}} WHERE languageid={languageid}' ); $sql->setInt( 'languageid',$this->languageid ); - $sql->query( $sql ); + $sql->query(); // Inhalte mit dieser Sprache l?schen $sql = $db->sql( 'DELETE FROM {{name}} WHERE languageid={languageid}' ); $sql->setInt( 'languageid',$this->languageid ); - $sql->query( $sql ); + $sql->query(); // Sprache l?schen $sql = $db->sql( 'DELETE FROM {{language}} WHERE id={languageid}' ); $sql->setInt( 'languageid',$this->languageid ); - $sql->query( $sql ); + $sql->query(); // Andere Sprache auf "Default" setzen $sql = $db->sql( 'SELECT id FROM {{language}} WHERE projectid={projectid}' ); @@ -279,7 +279,7 @@ SQL $sql = $db->sql( 'UPDATE {{language}} SET is_default=1 WHERE id={languageid}' ); $sql->setInt( 'languageid',$new_default_languageid ); - $sql->query( $sql ); + $sql->query(); // } } } diff --git a/model/Link.class.php b/model/Link.class.php @@ -1,22 +1,5 @@ <?php namespace cms\model; -// OpenRat Content Management System -// Copyright (C) 2002-2012 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. - /** @@ -32,19 +15,20 @@ class Link extends Object var $linkid; var $linkedObjectId = 0; var $url = ''; - var $isLinkToUrl = false; - var $isLinkToObject = false; function __construct( $objectid='' ) { parent::__construct( $objectid ); $this->isLink = true; - $this->isLinkToObject = false; } - - // Lesen der Verkn�pfung aus der Datenbank - function load() + + + /** + * Lesen der Verknuepfung aus der Datenbank + * @throws \ObjectNotFoundException + */ + function load() { $db = db_connection(); @@ -56,27 +40,17 @@ class Link extends Object if ( count($row ) != 0 ) { - $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() + /** + * + */ + function delete() { $db = db_connection(); @@ -84,37 +58,28 @@ class Link extends Object $sql = $db->sql( 'DELETE FROM {{link}} '. ' WHERE objectid={objectid}' ); $sql->setInt( 'objectid',$this->objectid ); - - $sql->query( $sql ); + + $sql->query(); $this->objectDelete(); } - - function save() + /** + * + */ + function save() { global $SESS; $db = db_connection(); $sql = $db->sql('UPDATE {{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 ); - } - - $sql->query( $sql ); + $sql->setInt ('linkobjectid',$this->linkedObjectId ); + + $sql->query(); $this->objectSave(); } @@ -123,19 +88,15 @@ class Link extends Object function getProperties() { return array_merge( parent::getProperties(), - Array( 'objectid' =>$this->objectid, - 'linkobjectid' =>$this->linkedObjectId, - 'url' =>$this->url, - 'isLinkToUrl' =>$this->isLinkToUrl, - 'isLinkToObject' =>$this->isLinkToObject) ); + array( 'objectid' =>$this->objectid, + 'linkobjectid' =>$this->linkedObjectId + )); } function getType() { - if ( $this->isLinkToObject ) - return 'link'; - else return 'url'; + return 'link'; } @@ -149,23 +110,13 @@ class Link extends Object $this->linkid = intval($sql->getOne())+1; $sql = $db->sql('INSERT INTO {{link}}'. - ' (id,objectid,url,link_objectid)'. - ' VALUES( {linkid},{objectid},{url},{linkobjectid} )' ); + ' (id,objectid,link_objectid)'. + ' VALUES( {linkid},{objectid},{linkobjectid} )' ); $sql->setInt ('linkid' ,$this->linkid ); $sql->setInt ('objectid' ,$this->objectid ); + $sql->setInt ('linkobjectid',$this->linkedObjectId ); - if ( $this->isLinkToObject ) - { - $sql->setInt ('linkobjectid',$this->linkedObjectId ); - $sql->setNull('url' ); - } - else - { - $sql->setNull ('linkobjectid'); - $sql->setString('url',$this->url ); - } - - $sql->query( $sql ); + $sql->query(); } } diff --git a/model/Model.class.php b/model/Model.class.php @@ -150,7 +150,7 @@ SQL $sql->setInt( 'modelid',$this->modelid ); // Datenbankabfrage ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -192,7 +192,7 @@ SQL $sql->setString('name' ,$this->name ); // Datenbankbefehl ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -228,14 +228,14 @@ SQL ' SET is_default = 0 '. ' WHERE projectid={projectid}' ); $sql->setInt('projectid',$this->projectid ); - $sql->query( $sql ); + $sql->query(); // Jetzt die gew?nschte Sprachvariante auf Standard setzen $sql = $db->sql( 'UPDATE {{projectmodel}} '. ' SET is_default = 1 '. ' WHERE id={modelid}' ); $sql->setInt('modelid',$this->modelid ); - $sql->query( $sql ); + $sql->query(); } @@ -255,7 +255,7 @@ SQL SQL ); $sql->setInt( 'modelid',$this->modelid ); - $sql->query( $sql ); + $sql->query(); // Dieses Modell löschen $sql = $db->sql( <<<SQL @@ -264,7 +264,7 @@ SQL SQL ); $sql->setInt( 'modelid',$this->modelid ); - $sql->query( $sql ); + $sql->query(); // Anderes Modell auf "Default" setzen (sofern vorhanden) if ( $this->isDefault ) @@ -275,7 +275,7 @@ SQL $sql = $db->sql( 'UPDATE {{projectmodel}} SET is_default=1 WHERE id={modelid}' ); $sql->setInt( 'modelid',$new_default_modelid ); - $sql->query( $sql ); + $sql->query(); } } } diff --git a/model/Object.class.php b/model/Object.class.php @@ -5,6 +5,7 @@ namespace { define('OR_TYPEID_FILE',2); define('OR_TYPEID_PAGE',3); define('OR_TYPEID_LINK',4); + define('OR_TYPEID_URL',5); } @@ -103,6 +104,12 @@ namespace cms\model { var $isLink = false; /** + * Kennzeichen, ob Objekt eine Verknuepfung (Url) ist + * @type Boolean + */ + var $isUrl = false; + + /** * Kennzeichnet den Typ dieses Objektes. * Muss den Inhalt OR_FILE, OR_FOLDER, OR_PAGE oder OR_LINK haben. * Vorbelegung mit <code>null</code>. @@ -308,6 +315,8 @@ SQL return OR_TYPE_PAGE; if ($this->isLink) return OR_TYPE_LINK; + if ($this->isUrl) + return OR_TYPE_URL; return 'unknown'; } @@ -329,6 +338,7 @@ SQL 'isFolder' =>$this->isFolder, 'isFile' =>$this->isFile, 'isLink' =>$this->isLink, + 'isUrl' =>$this->isUrl, 'isPage' =>$this->isPage, 'isRoot' =>$this->isRoot, 'languageid' =>$this->languageid, @@ -540,6 +550,7 @@ SQL $this->isFile = ( $row['typeid'] == OR_TYPEID_FILE ); $this->isPage = ( $row['typeid'] == OR_TYPEID_PAGE ); $this->isLink = ( $row['typeid'] == OR_TYPEID_LINK ); + $this->isUrl = ( $row['typeid'] == OR_TYPEID_URL ); } @@ -589,6 +600,7 @@ SQL $this->isFile = ( $row['typeid'] == OR_TYPEID_FILE ); $this->isPage = ( $row['typeid'] == OR_TYPEID_PAGE ); $this->isLink = ( $row['typeid'] == OR_TYPEID_LINK ); + $this->isUrl = ( $row['typeid'] == OR_TYPEID_URL ); if ( $this->isRoot ) { @@ -633,7 +645,7 @@ SQL $sql = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND languageid={languageid}'); $sql->setInt('objectid' , $this->objectid ); $sql->setInt('languageid', $this->languageid); - $res = $sql->query($sql); + $res = $sql->query(); if ($res->numRows() == 0) { @@ -690,7 +702,7 @@ SQL $sql->setInt ('objectid', $this->objectid); - $sql->query($sql); + $sql->query(); // Nur wenn nicht Wurzelordner if ( !$this->isRoot && $withName ) @@ -724,7 +736,7 @@ SQL $sql->setInt ('objectid',$this->objectid ); $sql->setInt ('time' ,$this->lastchangeDate ); - $sql->query( $sql ); + $sql->query(); } @@ -740,7 +752,7 @@ SQL $sql->setInt ('objectid',$this->objectid ); $sql->setInt ('time' ,$this->createDate ); - $sql->query( $sql ); + $sql->query(); } @@ -777,7 +789,7 @@ SQL $sql->setString('desc', $this->desc); $sql->setInt( 'objectid' , $this->objectid ); $sql->setInt( 'languageid', $this->languageid ); - $sql->query($sql); + $sql->query(); } else { @@ -790,7 +802,7 @@ SQL $sql->setInt ('nameid', $nameid ); $sql->setString('name' , $this->name); $sql->setString('desc' , $this->desc); - $sql->query($sql); + $sql->query(); } } @@ -807,25 +819,25 @@ SQL ' SET default_objectid=NULL '. ' WHERE default_objectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'UPDATE {{value}} '. ' SET linkobjectid=NULL '. ' WHERE linkobjectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'UPDATE {{link}} '. ' SET link_objectid=NULL '. ' WHERE link_objectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); // Objekt-Namen l?schen $sql = $db->sql('DELETE FROM {{name}} WHERE objectid={objectid}'); $sql->setInt('objectid', $this->objectid); - $sql->query($sql); + $sql->query(); // ACLs loeschen $this->deleteAllACLs(); @@ -833,7 +845,7 @@ SQL // Objekt l?schen $sql = $db->sql('DELETE FROM {{object}} WHERE id={objectid}'); $sql->setInt('objectid', $this->objectid); - $sql->query($sql); + $sql->query(); } @@ -871,7 +883,7 @@ SQL $sql->setInt( 'typeid',$this->getTypeid()); - $sql->query($sql); + $sql->query(); if ( !empty($this->name) ) $this->objectSaveName(); @@ -1072,6 +1084,8 @@ SQL return( array('read','write','delete','prop','release','publish','grant') ); if ( $this->isLink ) return( array('read','write','delete','prop','grant') ); + if ( $this->isUrl ) + return( array('read','write','delete','prop','grant') ); } @@ -1165,7 +1179,7 @@ SQL $sql->setInt('objectid', $this->objectid); $sql->setInt('orderid', $orderid); - $sql->query($sql); + $sql->query(); } @@ -1183,7 +1197,7 @@ SQL $sql->setInt('objectid', $this->objectid); $sql->setInt('parentid', $parentid); - $sql->query($sql); + $sql->query(); } @@ -1350,6 +1364,7 @@ SQL if ($this->isFile) return OR_TYPEID_FILE; if ($this->isPage) return OR_TYPEID_PAGE; if ($this->isLink) return OR_TYPEID_LINK; + if ($this->isUrl) return OR_TYPEID_URL; } diff --git a/model/Page.class.php b/model/Page.class.php @@ -359,7 +359,7 @@ class Page extends Object $sql->setInt ('objectid' ,$this->objectid ); $sql->setInt ('templateid',$this->templateid ); - $sql->query( $sql ); + $sql->query(); } @@ -389,12 +389,12 @@ class Page extends Object $sql = $db->sql( 'DELETE FROM {{value}} '. ' WHERE pageid={pageid}' ); $sql->setInt('pageid',$this->pageid); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'DELETE FROM {{page}} '. ' WHERE objectid={objectid}' ); $sql->setInt('objectid',$this->objectid); - $sql->query( $sql ); + $sql->query(); $this->objectDelete(); } @@ -444,7 +444,7 @@ class Page extends Object ' WHERE objectid={objectid}' ); $sql->setInt('templateid' ,$this->templateid); $sql->setInt('objectid' ,$this->objectid ); - $sql->query( $sql ); + $sql->query(); $this->objectSave(); } @@ -465,7 +465,7 @@ class Page extends Object ' WHERE objectid={objectid}' ); $sql->setInt('templateid' ,$this->templateid); $sql->setInt('objectid' ,$this->objectid ); - $sql->query( $sql ); + $sql->query(); // Inhalte umschluesseln, d.h. die Element-Ids aendern @@ -482,7 +482,7 @@ class Page extends Object $sql->setInt('pageid' ,$this->pageid); $sql->setInt('elementid',$oldElementId ); - $sql->query( $sql ); + $sql->query(); } else { @@ -496,7 +496,7 @@ class Page extends Object $sql->setInt('pageid' ,$this->pageid); $sql->setInt('oldelementid',$oldElementId ); $sql->setInt('newelementid',$newElementId ); - $sql->query( $sql ); + $sql->query(); } } } diff --git a/model/Project.class.php b/model/Project.class.php @@ -249,7 +249,7 @@ SQL $sql->setInt ('cut_index' ,$this->cut_index ); $sql->setInt ('projectid' ,$this->projectid ); - $sql->query( $sql ); + $sql->query(); try { @@ -294,7 +294,7 @@ SQL $sql->setInt ('projectid',$this->projectid ); $sql->setString('name' ,$this->name ); - $sql->query( $sql ); + $sql->query(); // Modell anlegen $model = new Model(); @@ -377,7 +377,7 @@ SQL $sql = $db->sql( 'DELETE FROM {{project}}'. ' WHERE id= {projectid} ' ); $sql->setInt( 'projectid',$this->projectid ); - $sql->query( $sql ); + $sql->query(); } function getDefaultLanguageId() diff --git a/model/Template.class.php b/model/Template.class.php @@ -158,7 +158,7 @@ class Template ' WHERE id={templateid}' ); $sql->setString( 'name' ,$this->name ); $sql->setInt ( 'templateid',$this->templateid ); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'SELECT COUNT(*) FROM {{templatemodel}}'. ' WHERE templateid={templateid}'. @@ -192,7 +192,7 @@ class Template $sql->setInt ( 'templateid' ,$this->templateid ); $sql->setInt ( 'modelid' ,$this->modelid ); - $sql->query( $sql ); + $sql->query(); } @@ -360,7 +360,7 @@ SQL $sql->setInt ('projectid' ,$this->projectid ); - $sql->query( $sql ); + $sql->query(); } @@ -399,12 +399,12 @@ SQL $sql = $db->sql( 'DELETE FROM {{templatemodel}}'. ' WHERE templateid={templateid}' ); $sql->setInt( 'templateid',$this->templateid ); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'DELETE FROM {{template}}'. ' WHERE id={templateid}' ); $sql->setInt( 'templateid',$this->templateid ); - $sql->query( $sql ); + $sql->query(); } diff --git a/model/Url.class.php b/model/Url.class.php @@ -0,0 +1,113 @@ +<?php +namespace cms\model; + +/** + * Darstellen einer URL. An URL points to an string-based URL. + * + * @author Jan Dankert + * @package openrat.objects + */ +class Url extends Object +{ + public $urlid; + public $url = ''; + + function __construct( $objectid='' ) + { + parent::__construct( $objectid ); + $this->isUrl = true; + } + + + // Lesen der Verkn�pfung aus der Datenbank + function load() + { + $db = db_connection(); + + $sql = $db->sql( 'SELECT *'. + ' FROM {{url}}'. + ' WHERE objectid={objectid}' ); + $sql->setInt( 'objectid',$this->objectid ); + $row = $sql->getRow(); + + if ( count($row ) != 0 ) + { + $this->url = $row['url']; + } + + $this->objectLoad(); + } + + + /** + * Löschen. + */ + function delete() + { + $db = db_connection(); + + $sql = $db->sql( 'DELETE FROM {{url}} '. + ' WHERE objectid={objectid}' ); + $sql->setInt( 'objectid',$this->objectid ); + + $sql->query(); + + $this->objectDelete(); + } + + + + public function save() + { + global $SESS; + $db = db_connection(); + + $sql = $db->sql('UPDATE {{url}} SET '. + ' url = {url}'. + ' WHERE objectid={objectid}' ); + $sql->setInt ('objectid' ,$this->objectid ); + $sql->setString('url',$this->url ); + + $sql->query(); + + $this->objectSave(); + } + + + function getProperties() + { + return array_merge( parent::getProperties(), + Array( 'objectid' =>$this->objectid, + 'url' =>$this->url + ) ); + } + + + function getType() + { + return 'url'; + } + + + function add() + { + $this->objectAdd(); + + $db = db_connection(); + + $sql = $db->sql('SELECT MAX(id) FROM {{url}}'); + $this->urlid = intval($sql->getOne())+1; + + $sql = $db->sql('INSERT INTO {{url}}'. + ' (id,objectid,url)'. + ' VALUES( {urlid},{objectid},{url} )' ); + $sql->setInt ('urlid' ,$this->urlid ); + $sql->setInt ('objectid' ,$this->objectid ); + + $sql->setString('url',$this->url ); + + $sql->query(); + } +} + +?>+ \ No newline at end of file diff --git a/model/User.class.php b/model/User.class.php @@ -126,7 +126,7 @@ SQL $sql->setInt( 'userid',$this->userid ); // Datenbankabfrage ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -418,7 +418,7 @@ SQL $sql->setInt ( 'userid' ,$this->userid ); // Datenbankabfrage ausfuehren - $sql->query( $sql ); + $sql->query(); } @@ -444,7 +444,7 @@ SQL $sql->setString('name' ,$this->name ); // Datenbankbefehl ausfuehren - $sql->query( $sql ); + $sql->query(); $this->addNewUserGroups(); // Neue Gruppen hinzufuegen. @@ -500,39 +500,39 @@ SQL 'SET create_userid=null '. 'WHERE create_userid={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); // "Letzte �nderung von" f�r diesen Benutzer entfernen $sql = $db->sql( 'UPDATE {{object}} '. 'SET lastchange_userid=null '. 'WHERE lastchange_userid={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); // Alle Archivdaten in Dateien mit diesem Benutzer entfernen $sql = $db->sql( 'UPDATE {{value}} '. 'SET lastchange_userid=null '. 'WHERE lastchange_userid={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); // Alle Berechtigungen dieses Benutzers l?schen $sql = $db->sql( 'DELETE FROM {{acl}} '. 'WHERE userid={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); // Alle Gruppenzugehoerigkeiten dieses Benutzers l?schen $sql = $db->sql( 'DELETE FROM {{usergroup}} '. 'WHERE userid={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); // Benutzer loeschen $sql = $db->sql( 'DELETE FROM {{user}} '. 'WHERE id={userid}' ); $sql->setInt ('userid',$this->userid ); - $sql->query( $sql ); + $sql->query(); } @@ -583,7 +583,7 @@ SQL $sql->setString('password',Password::hash($this->pepperPassword($password),$algo) ); $sql->setInt ('userid' ,$this->userid ); - $sql->query( $sql ); + $sql->query(); } @@ -660,7 +660,7 @@ SQL $sql->setInt('userid' ,$this->userid ); $sql->setInt('groupid' ,$groupid ); - $sql->query( $sql ); + $sql->query(); } @@ -680,7 +680,7 @@ SQL $sql->setInt ('userid' ,$this->userid ); $sql->setInt ('groupid' ,$groupid ); - $sql->query( $sql ); + $sql->query(); } diff --git a/model/Value.class.php b/model/Value.class.php @@ -338,7 +338,7 @@ SQL $sql->setInt( 'pageid' ,$this->pageid ); $sql->setInt( 'languageid',$this->languageid); - $sql->query( $sql ); + $sql->query(); $sql = $db->sql( 'UPDATE {{value}}'. ' SET publish=1'. @@ -350,7 +350,7 @@ SQL $sql->setInt( 'pageid' ,$this->pageid ); $sql->setInt( 'languageid',$this->languageid); - $sql->query( $sql ); + $sql->query(); } /** @@ -370,7 +370,7 @@ SQL $sql->setInt( 'pageid' ,$this->pageid ); $sql->setInt( 'languageid',$this->languageid); - $sql->query( $sql ); + $sql->query(); if ( $this->publish ) { @@ -385,7 +385,7 @@ SQL $sql->setInt( 'pageid' ,$this->pageid ); $sql->setInt( 'languageid',$this->languageid); - $sql->query( $sql ); + $sql->query(); } // Naechste ID aus Datenbank besorgen @@ -424,7 +424,7 @@ SQL $user = \Session::getUser(); $sql->setInt ( 'lastchange_userid',$user->userid ); - $sql->query( $sql ); + $sql->query(); // Nur ausfuehren, wenn in Konfiguration aktiviert. $limit = config('content','revision-limit'); @@ -476,7 +476,7 @@ SQL $sql->setInt( 'languageid',$this->languageid ); $sql->setInt( 'min_date' ,$limit['max-age']*24*60*60); $sql->setInt( 'min_id' ,$values[count($values)-$limit['min-revisions']]); - $sql->query($sql); + $sql->query(); } if ( count($values) > $limit['max-revisions'] ) @@ -497,7 +497,7 @@ SQL $sql->setInt( 'languageid',$this->languageid ); $sql->setInt( 'min_date' ,$limit['min-age']*24*60*60); $sql->setInt( 'min_id' ,$values[count($values)-$limit['max-revisions']]); - $sql->query($sql); + $sql->query(); } } diff --git a/model/include.inc.php b/model/include.inc.php @@ -2,20 +2,21 @@ namespace cms\model; // Diese Objekte stehen zeitweise in der Sitzung, daher muessen dieser immer geparst werden. -require_once( OR_OBJECTCLASSES_DIR."ModelBase.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Value.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Acl.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Template.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Object.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Folder.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Link.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."File.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."User.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Group.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Project.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Page.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Language.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Model.class.".PHP_EXT ); -require_once( OR_OBJECTCLASSES_DIR."Element.class.".PHP_EXT ); +require_once( __DIR__."ModelBase.class.".PHP_EXT ); +require_once( __DIR__."Value.class.".PHP_EXT ); +require_once( __DIR__."Acl.class.".PHP_EXT ); +require_once( __DIR__."Template.class.".PHP_EXT ); +require_once( __DIR__."Object.class.".PHP_EXT ); +require_once( __DIR__."Folder.class.".PHP_EXT ); +require_once( __DIR__."Link.class.".PHP_EXT ); +require_once( __DIR__."Url.class.".PHP_EXT ); +require_once( __DIR__."File.class.".PHP_EXT ); +require_once( __DIR__."User.class.".PHP_EXT ); +require_once( __DIR__."Group.class.".PHP_EXT ); +require_once( __DIR__."Project.class.".PHP_EXT ); +require_once( __DIR__."Page.class.".PHP_EXT ); +require_once( __DIR__."Language.class.".PHP_EXT ); +require_once( __DIR__."Model.class.".PHP_EXT ); +require_once( __DIR__."Element.class.".PHP_EXT ); ?> \ No newline at end of file diff --git a/modules/database/Database.class.php b/modules/database/Database.class.php @@ -199,7 +199,7 @@ class Database } /** - * @param $sql + * @param $sql string das SQL * @return Statement */ public function sql($sql ) diff --git a/modules/database/Statement.class.php b/modules/database/Statement.class.php @@ -74,16 +74,14 @@ class Statement // Statement an die Datenbank schicken $this->client->prepare( $this->sql->query,$this->sql->param ); } - - /** - * Ausfuehren einer Datenbankanfrage. - * - * @param SQL-Objekt - * @return Object (Result) - */ - public function query( ) + /** + * Ausfuehren einer Datenbankanfrage. + * + * @return Object (Result) + */ + public function query() { return $this->execute(); }