commit 59b8fb960231c76db39f4c07c7369651877e5590
parent 8461a4f4a1d9bf0650f8c23590465c0e330f8773
Author: Jan Dankert <devnull@localhost>
Date: Sat, 16 Dec 2017 23:33:32 +0100
Das CMS in eigene Module aufteilen. Das Modul cms-ui ist noch leer. Teile aus cms-core müssen nach cms-ui wandern, das ist aber aufwändiger und kommt später.
Diffstat:
185 files changed, 31195 insertions(+), 31195 deletions(-)
diff --git a/action/.htaccess b/action/.htaccess
@@ -1,2 +0,0 @@
-order deny,allow
-deny from all-
\ No newline at end of file
diff --git a/action/Action.class.php b/action/Action.class.php
@@ -1,781 +0,0 @@
-<?php
-
-namespace {
-
- class ObjectNotFoundException extends Exception
- {
- }
-
-
- define('OR_NOTICE_OK', 'ok');
- define('OR_NOTICE_WARN', 'warning');
- define('OR_NOTICE_ERROR', 'error');
-
- define('OR_FILTER_ALPHA', 'abc');
- define('OR_FILTER_ALPHANUM', 'abc123');
- define('OR_FILTER_FILENAME', 'file');
- define('OR_FILTER_MAIL', 'mail');
- define('OR_FILTER_TEXT', 'text');
- define('OR_FILTER_FULL', 'full');
- define('OR_FILTER_NUMBER', '123');
- define('OR_FILTER_RAW', 'raw');
- define('OR_FILTER_ALL', 'all');
-
-
-}
-
-
-namespace cms\action {
-
- use cms\model\User;
- use \DomainException;
- use \Html;
- use \Session;
-use \Logger;
-use \Http;
- use \template_engine\TemplateEngine;
- use \Text;
- use \XML;
-use \JSON;
-use \Exception;
-use \LogicException;
-
-// 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.
-
-
-
-
-
- /**
- * Eltern-Klasse fuer alle Actions.
- *
- * Diese Klasse stellt grundlegende action-uebergreifende Methoden
- * bereit.
- * Dient als Ueberklasse fuer alle abgeleiteten Action-Klassen in
- * diesem Package bzw. Verzeichnis.
- *
- * @author Jan Dankert
- * @package openrat.actions
- * @abstract
- */
- class Action
- {
- public $db;
- public $actionName;
- public $subActionName;
- public $actionClassName;
- public $writable;
-
- public $publishing;
- public $refresh;
-
- protected $templateVars = Array();
-
- /**
- * Aktuell angemeldeter Benutzer.<br>
- * Wird in der Funktion "init()" gesetzt.
- *
- * @var Object Benutzer
- */
- var $currentUser;
-
-
- protected function setStyle($style)
- {
- $this->setControlVar("new_style", $style);
- }
-
-
- function nextView($viewName)
- {
- $this->setControlVar("next_view", $viewName);
- }
-
-
- /**
- * Wird durch das Controller-Skript (do.php) nach der Kontruierung des Objektes aufgerufen.
- * So koennen Unterklassen ihren eigenen Kontruktor besitzen, ohne den Superkontruktor
- * (=diese Funktion) aufrufen zu m�ssen.
- */
- public function init()
- {
- global $conf;
- $this->writable = !$conf['security']['readonly'];
- $this->publishing = !$conf['security']['nopublish'];
- $this->currentUser = Session::getUser();
-
- $this->templateVars['errors'] = array();
- $this->templateVars['notices'] = array();
- $this->templateVars['control'] = array();
- $this->templateVars['output'] = array();
-
- header('Content-Language: ' . $conf['language']['language_code']);
-
- $this->refresh = false;
- }
-
-
- /**
- * Liest eine Session-Variable
- *
- * @param String $varName Schl�ssel
- * @return mixed
- */
- protected function getSessionVar($varName)
- {
- global $SESS;
-
- if (!isset($SESS[$varName]))
- return '';
- else return $SESS[$varName];
- }
-
-
- /**
- * Setzt eine Session-Variable
- *
- * @param string $varName Schluessel
- * @param mixed $value Inhalt
- * @return mixed
- */
- protected function setSessionVar($varName, $value)
- {
- global $SESS;
-
- $SESS[$varName] = $value;
- }
-
-
- /**
- * Ermittelt den Inhalt der gew�nschten Request-Variablen.
- * Falls nicht vorhanden, wird "" zur�ckgegeben.
- *
- * @param String $varName Schl�ssel
- * @return String Inhalt
- */
- protected function getRequestVar($varName, $transcode = OR_FILTER_FULL)
- {
- global $REQ;
-
- if (!isset($REQ[$varName]))
- return '';
-
-
- switch ($transcode) {
- case OR_FILTER_ALPHA:
- $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
- break;
-
- case OR_FILTER_ALPHANUM:
- $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,_-!?%&/()';
- break;
-
- case OR_FILTER_FILENAME:
- // RFC 1738, Section 2.2:
- // Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
- // reserved characters used for their reserved purposes may be used
- // unencoded within a URL.
- $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$-_.+!*(),' . "'";
- break;
-
- case OR_FILTER_MAIL:
- $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-@';
- break;
-
- case OR_FILTER_TEXT:
- case OR_FILTER_FULL:
- case OR_FILTER_ALL:
- // Ausfiltern von Control-Chars ( ASCII < 32 außer CR,LF) und HTML (<,>)
- $white = '';
- $white .= chr(10) . chr(13); // Line-Feed, Carriage-Return
- for ($i = 32; $i <= 59; $i++) $white .= chr($i); // Zahlen
- // 60: '<'
- $white .= chr(61);
- // 62: '>'
- for ($i = 63; $i <= 126; $i++) $white .= chr($i); // abc
- for ($i = 128; $i <= 255; $i++) $white .= chr($i); // Sonderzeichen incl. UTF-8, UTF-16 (beginnen mit Bit 1)
- break;
-
- case OR_FILTER_NUMBER:
- $white = '1234567890.';
- break;
-
- case OR_FILTER_RAW:
- return $REQ[$varName];
-
- default:
- Http::serverError('Unknown request filter', 'not found: ' . $transcode);
- return '?';
- }
-
- $value = $REQ[$varName];
- $newValue = Text::clean($value, $white);
-
- if (strlen($newValue) != strlen($value))
- $this->addNotice('', '', 'UNEXPECTED_CHARS', OR_NOTICE_WARN);
-
- return $newValue;
- }
-
-
- /**
- * Ermittelt, ob der aktuelle Request eine Variable mit dem
- * angegebenen Namen enth�lt.
- *
- * @param String $varName Schl�ssel
- * @return boolean true, falls vorhanden.
- */
- protected function hasRequestVar($varName)
- {
- global $REQ;
-
- return (isset($REQ[$varName]) && (!empty($REQ[$varName]) || $REQ[$varName] == '0'));
- }
-
-
- /**
- * Ermittelt die aktuelle Id aus dem Request.<br>
- * Um welche ID es sich handelt, ist abh�ngig von der Action.
- *
- * @return Integer
- */
- protected function getRequestId()
- {
- if ($this->hasRequestVar('idvar'))
- return intval($this->getRequestVar($this->getRequestVar('idvar')));
- else
- return intval($this->getRequestVar(REQ_PARAM_ID));
- }
-
-
- /**
- * Setzt eine Variable f�r die Oberfl�che.
- *
- * @param String $varName Schl�ssel
- * @param Mixed $value
- */
- protected function setTemplateVar($varName, $value)
- {
- $this->templateVars['output'][$varName] = $value;
- }
-
-
- /**
- * Setzt eine Variable f�r die Oberfl�che.
- *
- * @param String $varName Schl�ssel
- * @param Mixed $value
- */
- protected function setControlVar($varName, $value)
- {
- $this->templateVars['control'][$varName] = $value;
- }
-
-
- /**
- * Setzt eine Liste von Variablen f�r die Oberfl�che.
- *
- * @param array $varList Assoziatives Array
- */
- protected function setTemplateVars($varList)
- {
- foreach ($varList as $name => $value) {
- $this->setTemplateVar($name, $value);
- }
- }
-
-
- /**
- * F�gt einen Validierungsfehler hinzu.
- *
- * @param String $name Name des validierten Eingabefeldes
- * @param String Textschl�ssel der Fehlermeldung (optional)
- */
- protected function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array())
- {
- if (!empty($message))
- $this->addNotice('', '', $message, OR_NOTICE_ERROR, $vars, $log);
-
- $this->templateVars['errors'][] = $name;
- }
-
-
- public function handleResult($result)
- {
- // TODO -
- }
-
- /**
- * F�gt ein Meldung hinzu.
- *
- * @param String $type Typ des Objektes, zu dem diese Meldung geh�rt.
- * @param String $name Name des Objektes, zu dem diese Meldung geh�rt.
- * @param String $text Textschl�ssel der Fehlermeldung (optional)
- * @param String $status Einer der Werte OR_NOTICE_(OK|WARN|ERROR)
- * @param array $vars Variablen f�r den Textschl�ssel
- * @param array $log Weitere Hinweistexte f�r diese Meldung.
- */
- protected function addNotice($type, $name, $text, $status = OR_NOTICE_OK, $vars = array(), $log = array())
- {
- if ($status === true)
- $status = OR_NOTICE_OK;
- elseif ($status === false)
- $status = OR_NOTICE_ERROR;
-
- $this->templateVars['notice_status'] = $status;
- $this->templateVars['status'] = $status;
- $this->templateVars['success'] = ($status == OR_NOTICE_ERROR ? 'false' : 'true');
-
- if ($status == OR_NOTICE_OK && isset($_COOKIE['or_ignore_ok_notices']))
- return;
-
- if (!is_array($log))
- $log = array($log);
-
- if (!is_array($vars))
- $vars = array($vars);
-
- $this->templateVars['notices'][] = array('type' => $type,
- 'name' => $name,
- 'key' => 'NOTICE_' . $text,
- 'vars' => $vars,
- 'text' => lang('NOTICE_' . $text, $vars),
- 'log' => $log,
- 'status' => $status);
- }
-
-
- /**
- * Ausgabe des Templates.<br>
- * <br>
- * Erst hier soll die Ausgabe auf die Standardausgabe, also die
- * Ausgabe f�r den Browser, starten.<br>
- * <br>
- */
- public function forward()
- {
- Session::close();
- global $conf;
-
- $db = db_connection();
-
- if (is_object($db))
- $db->commit();
-
- // Ablaufzeit für den Inhalt auf aktuelle Zeit setzen.
- header('Expires: ' . substr(date('r', time() - date('Z')), 0, -5) . 'GMT', false);
-
- if ($conf['security']['content-security-policy'])
- header('X-Content-Security-Policy: ' . 'allow \'self\'; img-src: *; script-src \'self\'; options inline-script');
-
-
- $httpAccept = getenv('HTTP_ACCEPT');
- $types = explode(',', $httpAccept);
-
- if (version_compare(PHP_VERSION, '4.3.0', '>='))
- Logger::trace('Output' . "\n" . print_r($this->templateVars, true));
-
- // Weitere Variablen anreichern.
- $this->templateVars['session'] = array('name' => session_name(), 'id' => session_id(), 'token' => token());
- $this->templateVars['version'] = OR_VERSION;
- $this->templateVars['api'] = '2';
-
- if (sizeof($types) == 1 && in_array('application/php-array', $types) || $this->getRequestVar('output') == 'php-array') {
- if (version_compare(PHP_VERSION, '4.3.0', '<'))
- Http::serverError('application/php-array is only available with PHP >= 4.3');
-
- header('Content-Type: application/php-array; charset=UTF-8');
- echo print_r($this->templateVars, true);
- exit;
- }
-
- if (sizeof($types) == 1 && in_array('application/php-serialized', $types) || $this->getRequestVar('output') == 'php') {
- header('Content-Type: application/php-serialized; charset=UTF-8');
- echo serialize($this->templateVars);
- exit;
- }
-
- if (sizeof($types) == 1 && in_array('application/json', $types) || $this->getRequestVar('output') == 'json') {
- $json = new JSON();
- header('Content-Type: application/json; charset=UTF-8');
- if (function_exists('json_encode'))
- // Native Methode ist schneller..
- echo json_encode($this->templateVars, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PARTIAL_OUTPUT_ON_ERROR);
- else
- // Fallback, falls json_encode() nicht existiert...
- echo $json->encode($this->templateVars);
- exit;
- }
-
- if (sizeof($types) == 1 && in_array('application/xml', $types) || $this->getRequestVar('output') == 'xml') {
- require_once(OR_SERVICECLASSES_DIR . "XML.class." . PHP_EXT);
- $xml = new XML();
- $xml->root = 'server'; // Name des XML-root-Elementes
- header('Content-Type: application/xml; charset=UTF-8');
- echo $xml->encode($this->templateVars);
- exit;
- }
-
- header('Content-Type: text/html; charset=UTF-8');
- $this->setMenu();
-
- $tplName = $this->actionName . '/' . $this->subActionName;
-
-
-// if (isset($this->actionConfig[$this->subActionName]['target']))
-// $targetSubActionName = $this->actionConfig[$this->subActionName]['target'];
-// else
- $targetSubActionName = $this->subActionName;
-
-
- global $REQ;
- global $PHP_SELF;
- global $HTTP_SERVER_VARS;
- global $image_dir;
- global $view;
-
- // Übertragen der Ausgabe-Variablen in den aktuellen Kontext
- //
- extract($this->templateVars['output']);
-
- // Setzen einiger Standard-Variablen
- //
- $tpl_dir = OR_THEMES_DIR . $conf['interface']['theme'] . '/pages/html/';
- $image_dir = OR_THEMES_EXT_DIR . $conf['interface']['theme'] . '/images/';
-
- $user = Session::getUser();
-
- $self = $HTTP_SERVER_VARS['PHP_SELF'];
-
- if (!empty($conf['interface']['override_title']))
- $cms_title = $conf['interface']['override_title'];
- else
- $cms_title = OR_TITLE . ' ' . OR_VERSION;
-
- $subActionName = $this->subActionName;
- $actionName = $this->actionName;
- $requestId = $this->getRequestId();
-
- $iFile = 'themes/default/templates/' . $tplName . '.tpl.out.' . PHP_EXT;
-
- if (DEVELOPMENT) {
- $srcXmlFilename = 'themes/default/templates/' . $tplName . '.tpl.src.xml';
-
- // Das Template kompilieren.
- // Aus dem XML wird eine PHP-Datei erzeugt.
- try {
- $te = new TemplateEngine();
- $te->compile($srcXmlFilename, $iFile);
- unset($te);
- } catch (Exception $e) {
- throw new DomainException("Compilation failed for Template '$tplName'.", 0, $e);
- }
- header("X-CMS-Template-File: " . $iFile);
- }
-
-
- if (is_file($iFile))
- // Einbinden des Templates
- require_once($iFile);
- else
- throw new LogicException("File '$iFile' not found.");
- }
-
-
- /**
- * Ruft eine weitere Subaction auf.
- *
- * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben.
- */
- protected function callSubAction($subActionName)
- {
- return;
-
- /*
- *
- if ( in_array($this->actionName,array('page','file','link','folder')) )
- Session::setSubaction( $subActionName );
-
- $this->subActionName = $subActionName;
-
- Logger::trace("next subaction is '$subActionName'");
-
- $this->$subActionName();
- */
- }
-
-
- /**
- * Ruft eine weitere Subaction auf.
- *
- * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben.
- */
- protected function nextSubAction($subActionName)
- {
- $this->subActionName = $subActionName;
-
- Logger::trace("next subaction is '$subActionName'");
-
- $methodName = $subActionName . ($_SERVER['REQUEST_METHOD'] == 'POST' ? 'Post' : 'View');
- $this->$methodName();
- }
-
-
- /**
- * Ermitteln, ob Benutzer Administratorrechte besitzt
- * @return Boolean TRUE, falls der Benutzer ein Administrator ist.
- */
- protected function userIsAdmin()
- {
- $user = Session::getUser();
- return is_object($user) && $user->isAdmin;
- }
-
-
- /**
- * Ermitteln, ob Benutzer Administratorrechte besitzt
- * @return Boolean TRUE, falls der Benutzer ein Administrator ist.
- */
- public function userIsLoggedIn()
- {
- $user = Session::getUser();
- return is_object($user) && $user->isAdmin;
- }
-
-
- /**
- * Ermitteln des Benutzerobjektes aus der Session
- * @return User
- */
- protected function getUserFromSession()
- {
- return Session::getUser();
- }
-
-
- /**
- * Benutzen eines sog. "Conditional GET".
- *
- * Diese Funktion setzt einen "Last-Modified"-HTTP-Header.
- * Ist der Inhalt der Seite nicht neuer, so wird der Inhalt
- * der Seite nicht ausgegeben, sondern nur HTTP-Status 304
- * ("304 not modified") gesetzt.
- * Der Rest der Seite muss dann nicht mehr erzeugt werden,
- * wodurch die Performance stark erhoeht werden kann.
- *
- * Credits: Danke an Charles Miller
- * @see http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers
- *
- * Gefunden auf:
- * @see http://simon.incutio.com/archive/2003/04/23/conditionalGet
- *
- * @param Timestamp Letztes Aenderungsdatum des Objektes
- */
- protected function lastModified($time, $expirationDuration = 0)
- {
- $user = Session::getUser();
-
- // Conditional-Get eingeschaltet?
- if (!config('cache', 'conditional_get'))
- return;
-
- $expires = substr(date('r', time() + $expirationDuration - date('Z')), 0, -5) . 'GMT';
- $lastModified = substr(date('r', $time - date('Z')), 0, -5) . 'GMT';
- $etag = '"' . base_convert($time, 10, 36) . '"';
-
- // Header senden
- header('Expires: ' . $expires);
- header('Last-Modified: ' . $lastModified);
- header('ETag: ' . $etag);
-
- // Die vom Interpreter sonst automatisch gesetzten
- // Header uebersteuern
- header('Cache-Control: must-revalidate');
- header('Pragma:');
-
- // See if the client has provided the required headers
- $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
- $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
-
- // Bug in Apache 2.2, mod_deflat adds '-gzip' to E-Tag
- if (substr($if_none_match, -6) == '-gzip"')
- $if_none_match = substr($if_none_match, 0, -6) . '"';
-
- // At least one of the headers is there - check them
- if ($if_none_match && $if_none_match != $etag)
- return; // etag is there but doesn't match
-
- if ($if_modified_since && $if_modified_since != $lastModified)
- return; // if-modified-since is there but doesn't match
-
- if (!$if_modified_since && !$if_none_match)
- return;
-
- // Der entfernte Browser bzw. Proxy holt die Seite nun aus seinem Cache
- header('HTTP/1.0 304 Not Modified');
- exit; // Sofortiges Skript-Ende
- }
-
-
- /**
- * @param $max int max Anzahl der Sekunden, die die Seite im Browsercache bleiben darf
- */
- protected function maxAge($max = 3600)
- {
- // Die Header "Last-Modified" und "ETag" wurden bereits in der
- // Methode "lastModified()" gesetzt.
-
- header('Expires: ' . substr(date('r', time() - date('Z') + $max), 0, -5) . 'GMT');
- header('Pragma: '); // 'Pragma' ist Bullshit und
- // wird von den meisten Browsern ignoriert.
- header('Cache-Control: public, max-age=' . $max . ", s-maxage=" . $max);
- }
-
-
- protected function setMenu()
- {
- return;
-
- $windowMenu = array();
- $name = $this->actionConfig[$this->subActionName]['menu'];
- $menuList = explode(',', $this->actionConfig['menu']['menu']);
- //$menuList = explode(',',$this->actionConfig['menu'][$name]);
-
- if (isset($this->actionConfig[$this->subActionName]['menuaction']))
- $actionName = $this->actionConfig[$this->subActionName]['menuaction'];
- else
- $actionName = $this->subActionName;
-
- foreach ($menuList as $menuName) {
- if (isset($this->actionConfig[$menuName]['alias']))
- $menuText = 'menu_' . $this->actionName . '_' . $this->actionConfig[$menuName]['alias'];
- else
- $menuText = 'menu_' . $this->actionName . '_' . $menuName;
-
-
- $menuKey = 'accesskey_window_' . $menuName;
-
- $menuEntry = array('subaction' => $menuName,
- 'text' => $menuText,
- 'title' => $menuText . '_DESC',
- 'key' => $menuKey);
-
- if ($this->checkMenu($menuName))
- $menuEntry['url'] = Html::url($actionName, $menuName, $this->getRequestId());
-
- $windowMenu[] = $menuEntry;
- }
- $this->setTemplateVar('windowMenu', $windowMenu);
- }
-
-
- /**
- * Ermittelt, ob der Men�punkt aktiv ist.
- * Ob ein Men�punkt als aktiv angezeigt werden soll, steht meist erst zur Laufzeit fest.
- * <br>
- * Diese Methode kann von den Unterklassen �berschrieben werden.
- * Falls diese Methode nicht �berschrieben wird, sind alle Men�punkte aktiv.
- *
- * @param String $name Logischer Name des Men�punktes
- * @return boolean TRUE, wenn Men�punkt aktiv ist.
- */
- protected function checkMenu($name)
- {
- // Standard: Alle Men�punkt sind aktiv.
- return true;
- }
-
-
- /**
- * Erzeugt einen Redirect auf einen bestimmte URL.
- */
- protected function redirect($url)
- {
- $this->setControlVar('redirect', $url);
- }
-
-
- /**
- * Sorgt dafür, dass alle anderen Views aktualisiert werden.
- *
- * Diese Methode sollte dann aufgerufen werden, wenn Objekte geändert werden
- * und dies Einfluss auf andere Views hat.
- */
- protected function refresh()
- {
- $this->refresh = true;
- $this->setControlVar('refresh', true);
- }
-
-
- /**
- * Setzt eine neue Perspektive für die Sitzung.
- *
- * @param String Name der Perspektive
- */
- protected function setPerspective($name)
- {
- Session::set('perspective', $name);
- $this->refresh();
- }
- }
-
-
-// TODO - nicht benutzt
- interface ActionResult
- {
- public function getErrorField();
-
- public function isSuccess();
- }
-
- class ActionResultSuccess implements ActionResult
- {
- public function isSuccess()
- {
- return true;
- }
-
- public function getErrorField()
- {
- return null;
- }
- }
-
- class ActionResultError implements ActionResult
- {
- private $fieldName;
-
- public function __construct($name)
- {
- $this->fieldName = $name;
- }
-
- public function isSuccess()
- {
- return false;
- }
-
- public function getErrorField()
- {
- return $this->fieldName;
- }
- }
-
-
-}-
\ No newline at end of file
diff --git a/action/ConfigurationAction.class.php b/action/ConfigurationAction.class.php
@@ -1,116 +0,0 @@
-<?php
-
-namespace cms\action;
-
-// 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; version 2.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-use Session;
-/**
- * Action-Klasse fuer die Bearbeitung eines Template-Elementes.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class ConfigurationAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- }
-
-
- public function editView()
- {
- $this->nextSubAction('show');
- }
-
-
- /**
- * Anzeigen des Elementes
- */
- function showView()
- {
- require_once('./util/config-default.php');
- $conf_default = $conf;
-
- $conf_cms = Session::getConfig();
- $conf_cms['system']['server'] = array( 'time' => date('r'),
- 'os' => php_uname('s'),
- 'host' => php_uname('n'),
- 'release'=> php_uname('r'),
- 'machine'=> php_uname('m'),
- 'owner' => get_current_user(),
- 'pid' => getmypid() );
-
-
- $conf_cms['system']['interpreter'] = array( 'version' => phpversion(),
- 'SAPI' => php_sapi_name(),
- 'session-name' => session_name(),
- 'magic_quotes_gpc' => get_magic_quotes_gpc(),
- 'magic_quotes_runtime'=> get_magic_quotes_runtime() );
-
- unset($conf_cms['language']);
-
- foreach( array('upload_max_filesize',
- 'file_uploads',
- 'memory_limit',
- 'max_execution_time',
- 'post_max_size',
- 'display_errors',
- 'register_globals'
- ) as $iniName )
- $conf_cms['system']['environment'][ $iniName ] = ini_get( $iniName );
-
- $extensions = get_loaded_extensions();
- asort( $extensions );
-
- foreach( $extensions as $id=>$extensionName )
- $conf_cms['system']['interpreter'][ 'extension' ][$extensionName] = 'loaded';
-
- $flatDefaultConfig = flattenArray('',$conf_default);
- $flatCMSConfig = flattenArray('',Session::getConfig());
- $flatConfig = flattenArray('',$conf_cms);
-
- $config = array();
- foreach( $flatConfig as $key=>$val )
- {
- $config[] = array( 'key'=>$key,'value'=>$val,'class'=>(empty($flatCMSConfig[$key])?'readonly':(isset($flatDefaultConfig[$key]) && $flatDefaultConfig[$key]==$flatConfig[$key]?'default':'changed')));
- }
- $this->setTemplateVar('config',$config );
- }
-}
-
-
-function flattenArray( $prefix,$arr )
-{
- $new = array();
- foreach( $arr as $key=>$val)
- {
- if ( is_array($val) )
- $new += flattenArray($prefix.$key.'.',$val);
- else
- $new[$prefix.$key] = $key=='password'?'*******************':$val;
- }
- return $new;
-}
-
-
-?>-
\ No newline at end of file
diff --git a/action/ElementAction.class.php b/action/ElementAction.class.php
@@ -1,667 +0,0 @@
-<?php
-
-namespace cms\action;
-
-
-use cms\model\Element;
-use cms\model\Template;
-use cms\model\Folder;
-use cms\model\Object;
-use Text;
-
-
-// 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; version 2.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-/**
- * Action-Klasse fuer die Bearbeitung eines Template-Elementes.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class ElementAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $element;
-
- private $template;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- if ( $this->getRequestId() == 0 )
- die('no element-id available');
-
- $this->element = new Element( $this->getRequestId() );
- $this->element->load();
-
- $this->setTemplateVar( 'elementid' ,$this->element->elementid );
- }
-
-
-
- /**
- * Umbenennen des Elementes
- */
- function editPost()
- {
- $this->element->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM);
- $this->element->desc = $this->getRequestVar('description','all' );
-
- $this->element->save();
- $this->element->load();
-
- $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
- /**
- * Umbenennen des Elementes
- */
- function deleteView()
- {
- $this->setTemplateVar( 'name' ,$this->element->name );
- }
-
-
- /**
- * Entfernen des Elementes
- */
- function deletePost()
- {
- if ( !$this->hasRequestVar('confirm') )
- {
- $this->addValidationError('confirm');
- return;
- }
-
- $type = $this->getRequestVar('type','abc');
-
- if ( $type == 'value' )
- {
- $this->element->deleteValues();
- $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
- }
- elseif ( $type == 'all' )
- {
- $this->element->delete();
- $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
- }
- }
-
-
-
- /**
- * Aendern des Element-Typs
- */
- function typePost()
- {
- if ( !$this->userIsAdmin() && $this->getRequestVar('type') == 'code' )
- {
- // Code-Elemente fuer Nicht-Administratoren nicht benutzbar
- $this->addNotice('element',$this->template->name,'CANCELED',OR_NOTICE_ERROR);
- }
- else
- {
- // Neuen Typ setzen und speichern
- $this->element->setType( $this->getRequestVar('type') );
- $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK);
- }
- }
-
-
- /**
- * Anzeigen des Elementes
- */
- function editView()
- {
-
- // Name und Beschreibung
- $this->setTemplateVar('name' ,$this->element->name);
-
- $this->setTemplateVar('description',$this->element->desc);
- }
-
-
-
- function typeView
- ()
- {
- // Die verschiedenen Element-Typen
- $types = array();
-
- foreach( $this->element->getAvailableTypes() as $t )
- $types[ $t ] = 'EL_'.$t;
-
- // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
- if ( !$this->userIsAdmin() )
- unset( $types['code'] );
-
- // Liste aller Elementtypen
- $this->setTemplateVar('types',$types);
-
- // Aktueller Typ
- $this->setTemplateVar('type',$this->element->type);
- }
-
-
-
- /**
- * Auswahlmaske f�r weitere Einstellungen zum Template-Element.
- *
- */
- function infoView()
- {
- $this->setTemplateVar('id' ,$this->element->elementid );
- $this->setTemplateVar('name',$this->element->name );
- }
-
- /**
- * Auswahlmaske f�r weitere Einstellungen zum Template-Element.
- *
- */
- function propView()
- {
- global $conf;
- $this->setTemplateVar('type',$this->element->type );
-
- // Abhaengig vom aktuellen Element-Typ die Eigenschaften anzeigen
- $properties = $this->element->getRelatedProperties();
-
- foreach( $this->element->getRelatedProperties() as $propertyName )
- {
- switch( $propertyName )
- {
- case 'withIcon':
- $this->setTemplateVar('with_icon' ,$this->element->withIcon );
- break;
-
- case 'allLanguages':
- $this->setTemplateVar('all_languages',$this->element->allLanguages);
- break;
-
- case 'writable':
- $this->setTemplateVar('writable' ,$this->element->writable );
- break;
-
- case 'subtype':
-
- $convertToLang = false;
- switch( $this->element->type )
- {
- case 'info':
- $subtypes = Array('db_id',
- 'db_name',
- 'project_id',
- 'project_name',
- 'language_id',
- 'language_iso',
- 'language_name',
- 'page_id',
- 'page_name',
- 'page_desc',
- 'page_fullfilename',
- 'page_filename',
- 'page_extension',
- 'edit_url',
- 'edit_fullurl',
- 'lastch_user_username',
- 'lastch_user_fullname',
- 'lastch_user_mail',
- 'lastch_user_desc',
- 'lastch_user_tel',
- 'create_user_username',
- 'create_user_fullname',
- 'create_user_mail',
- 'create_user_desc',
- 'create_user_tel',
- 'act_user_username',
- 'act_user_fullname',
- 'act_user_mail',
- 'act_user_desc',
- 'act_user_tel' );
- $convertToLang = true;
- break;
-
- case 'infodate':
- case 'linkdate':
- $subtypes = Array('date_published',
- 'date_saved',
- 'date_created' );
- $convertToLang = true;
- break;
-
- case 'link':
- $subtypes = Array(
- 'file',
- 'image',
- 'image_data_uri',
- 'page',
- 'folder',
- 'link' );
- $convertToLang = true;
- break;
-
- case 'linkinfo':
- $subtypes = Array('width',
- 'height',
- 'id',
- 'name',
- 'description',
- 'mime-type',
- 'lastch_user_username',
- 'lastch_user_fullname',
- 'lastch_user_mail',
- 'lastch_user_desc',
- 'lastch_user_tel',
- 'create_user_username',
- 'create_user_fullname',
- 'create_user_mail',
- 'create_user_desc',
- 'create_user_tel',
- 'filename',
- 'full_filename' );
- $convertToLang = true;
- break;
-
- case 'insert':
- $subtypes = Array('inline',
- 'ssi' );
- $convertToLang = true;
- break;
-
- case 'dynamic':
-
- $files = Array();
- $handle = opendir ('./macro');
- while ( $file = readdir($handle) )
- {
- $file = substr($file,0,strlen($file)-10);
- if ( $file != '' )
- $files[$file] = $file;
- }
- closedir($handle);
-
- $subtypes = $files;
- break;
-
- default:
- $subtypes = array();
- break;
- }
-
- if ( $convertToLang )
- {
- foreach( $subtypes as $t=>$v )
- {
- unset($subtypes[$t]);
- $subtypes[$v] = lang('EL_'.$this->element->type.'_'.$v);
- }
- }
-
- // Variable $subtype muss existieren, um Anzeige des Feldes zu erzwingen.
- if (!isset($this->element->subtype))
- $this->element->subtype='';
-
- $this->setTemplateVar('subtypes',$subtypes );
- $this->setTemplateVar('subtype' ,$this->element->subtype);
-
- break;
-
-
- case 'dateformat':
-
- $ini_date_format = $conf['date']['format'];
- $dateformat = array();
-
- $this->setTemplateVar('dateformat','');
-
- foreach($ini_date_format as $idx=>$d)
- {
- if ( strpos($d,'%')!==FALSE )
- $dateformat[$idx] = strftime($d);
- else
- $dateformat[$idx] = date($d);
- if ( $d == $this->element->dateformat )
- $this->setTemplateVar('dateformat',$idx);
- }
-
- $this->setTemplateVar('dateformats',$dateformat);
-
- break;
-
-
- // Eigenschaften Text und Text-Absatz
- case 'defaultText':
-
- switch( $this->element->type )
- {
- case 'longtext':
- $this->setTemplateVar('default_longtext',$this->element->defaultText );
- break;
-
- case 'select':
- case 'text':
- $this->setTemplateVar('default_text' ,$this->element->defaultText );
- break;
- }
- break;
-
-
- case 'htmlwiki':
- if ( !$this->element->wiki && !$this->element->html )
- $format = 'none';
- elseif ( $this->element->wiki && !$this->element->html )
- $format = 'wiki';
- elseif ( !$this->element->wiki && $this->element->html )
- $format = 'html';
- elseif ( $this->element->wiki && $this->element->html )
- $format = 'wiki,html';
-
- $this->setTemplateVar('format', $format );
-
- $formatlist = array();
- $formatlist['none' ] = 'raw'; // Nur Text, ohne Auszeichnungen
- // Für einfache Textelemente gibt es keinen HTML-Editor
- if ( $this->element->type == 'longtext' )
- $formatlist['html' ] = 'html'; // Text mit HTML-Editor
- $formatlist['wiki' ] = 'wiki'; // Text mit Markup, HTML nicht erlaubt
- $formatlist['wiki,html'] = 'wikihtml'; // Text mit Markup, HTML erlaubt
-
- foreach( $formatlist as $t=>$v )
- $formatlist[$t] = array('lang'=>'EL_PROP_'.$v);
-
- $this->setTemplateVar('formatlist', $formatlist );
- break;
-
- case 'linktype':
- $this->setTemplateVar('linktype', $this->element->wiki );
- $this->setTemplateVar('linktypelist', array('page','file','link') );
- break;
-
- case 'prefix':
- $t = new Template( $this->element->templateid );
-
- $elements = array();
- foreach( $t->getElements() as $element )
- {
- if ( $element->type == 'link' )
- $elements[$element->name] = $element->name;
- }
- unset($t);
-
- $this->setTemplateVar('linkelements',$elements );
-
- list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
- $this->setTemplateVar('linkelement',$linkElementName );
-
- break;
-
- case 'name':
-
- $names = array();
-
- foreach( Template::getAll() as $tid=>$name )
- {
- $t = new Template( $tid );
- $t->load();
-
- foreach( $t->getElements() as $element )
- {
- if ( !in_array($element->type,array('copy','linkinfo','link')) )
- $names[$element->name] = $t->name.' - '.$element->name.' ('.lang('EL_'.$element->type).')';
- }
- unset($t);
- }
-
-
- $this->setTemplateVar('names',$names );
-
- list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
- $this->setTemplateVar('name',$targetElementName );
- break;
-
- // Eigenschaften PHP-Code
- case 'code':
-
- switch( $this->element->type )
- {
-
- case 'select':
- $this->setTemplateVar('select_items',$this->element->code );
- break;
-
- case 'dynamic':
-
- $className = $this->element->subtype;
- $fileName = OR_DYNAMICCLASSES_DIR.'/'.$className.'.class.'.PHP_EXT;
-
- if ( is_file( $fileName ) )
- {
- require( $fileName );
-
- if ( class_exists($className) )
- {
- $dynEl = new $className;
-
- $desc = array();
-
- $description = $dynEl->description;
- $paramList = array();
-
- $old = $this->element->getDynamicParameters();
- $parameters = '';
-
- foreach( get_object_vars($dynEl) as $paramName=>$paramDesc )
- {
- if ( isset( $dynEl->$paramName ) )
- {
- if ( is_object($dynEl->$paramName))
- continue;
- if ( is_array($dynEl->$paramName))
- continue;
- if ( in_array($paramName,array('output')))
- continue;
- $paramList[$paramName] = $dynEl->$paramName;
-
- $parameters .= $paramName.':';
- if ( !empty($old[$paramName]) )
- $parameters .= $old[$paramName];
- else
- $parameters .= $dynEl->$paramName;
- $parameters .= "\n";
- }
- }
-
- $this->setTemplateVar('dynamic_class_description',$dynEl->description );
- $this->setTemplateVar('dynamic_class_parameters' ,$paramList );
- $this->setTemplateVar('parameters' ,$parameters );
- }
- }
-
- break;
-
- case 'code':
- if ( $conf['security']['disable_dynamic_code'] )
- $this->addNotice('element',$this->element->name,'CODE_DISABLED',OR_NOTICE_WARN);
-
- $this->setTemplateVar('code',$this->element->code);
- break;
- }
- break;
-
-
- case 'decimals':
- $this->setTemplateVar('decimals' ,$this->element->decimals );
- break;
-
- case 'decPoint':
- $this->setTemplateVar('dec_point' ,$this->element->decPoint );
- break;
-
- case 'thousandSep':
- $this->setTemplateVar('thousand_sep' ,$this->element->thousandSep );
- break;
-
-
- // Eigenschaften Link
- case 'defaultObjectId':
-
- $objects = array();
-
- // Ermitteln aller verfuegbaren Objekt-IDs
- foreach( Folder::getAllObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- switch( $this->element->type )
- {
- case 'list':
- if ( !$o->isFolder )
- continue 2;
- break;
-
- case 'link':
- if ( !$o->isPage && !$o->isFile && !$o->isLink )
- continue 2;
- break;
- //Change tobias
- case 'insert':
- if ( !$o->isFolder && !$o->isPage && !$o->isFile && !$o->isLink )
- continue 2;
- break;
- //Change tobias end
- default:
- continue 2;
- }
-
- $objects[ $id ] = lang( $o->getType() ).': ';
-
- if ( !$o->isRoot )
- {
- $f = new Folder( $o->parentid );
- $f->load();
- $names = $f->parentObjectNames(false,true);
- foreach( $names as $fid=>$name )
- $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
- $objects[ $id ] .= implode( FILE_SEP,$names );
- }
-
- $objects[ $id ] .= FILE_SEP.$o->name;
- }
-
- asort( $objects ); // Sortieren
-
- $this->setTemplateVar('objects',$objects);
-
- $this->setTemplateVar('default_objectid',$this->element->defaultObjectId);
-
- break;
-
-
- case 'folderObjectId':
-
- $folders = array();
-
- // Ermitteln aller verf?gbaren Objekt-IDs
- foreach( Folder::getAllFolders() as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- $folders[ $id ] = '';
- if ( !$o->isRoot )
- {
- $f = new Folder( $o->parentid );
- $f->load();
- $names = $f->parentObjectNames(true,true);
- foreach( $names as $fid=>$name )
- $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
- $folders[ $id ] = implode( ' » ',$names );
- $folders[ $id ] .= ' » ';
- }
- $folders[ $id ] .= $o->name;
- }
-
- asort( $folders ); // Sortieren
-
- $this->setTemplateVar('folders',$folders);
-
- $this->setTemplateVar('folderobjectid' ,$this->element->folderObjectId );
-
- break;
-
- default:
- throw new \LogicException('not an element property: '.$propertyName );
- }
- }
- }
-
-
-
- /**
- * Speichern der Element-Eigenschaften
- */
- function propPost()
- {
- global $conf;
- $ini_date_format = $conf['date']['format'];
-
- if ( $this->hasRequestVar('dateformat'))
- $this->element->dateformat = $ini_date_format[$this->getRequestVar('dateformat')];
- $this->element->subtype = $this->getRequestVar('subtype');
-
- if ( $this->hasRequestVar('default_longtext'))
- $this->element->defaultText = $this->getRequestVar('default_longtext',OR_FILTER_RAW);
- else
- $this->element->defaultText = $this->getRequestVar('default_text',OR_FILTER_ALPHANUM);
- $this->element->wiki = in_array('wiki',explode(',',$this->getRequestVar('format')));
- $this->element->html = in_array('html',explode(',',$this->getRequestVar('format')));
- $this->element->withIcon = $this->getRequestVar('with_icon') != '';
- $this->element->allLanguages = $this->getRequestVar('all_languages') != '';
- $this->element->writable = $this->getRequestVar('writable') != '';
- $this->element->decimals = $this->getRequestVar('decimals');
- $this->element->decPoint = $this->getRequestVar('dec_point');
- $this->element->thousandSep = $this->getRequestVar('thousand_sep');
- $this->element->folderObjectId = $this->getRequestVar('folderobjectid' );
- $this->element->defaultObjectId = $this->getRequestVar('default_objectid');
- if ( $this->hasRequestVar('select_items'))
- $this->element->code = $this->getRequestVar('select_items');
- else
- $this->element->code = $this->getRequestVar('code' ,'raw');
-
- if ( $this->hasRequestVar('name') )
- $this->element->name = $this->getRequestVar('name');
-
- if ( $this->hasRequestVar('linkelement') )
- $this->element->setPrefix( $this->getRequestVar('linkelement') );
-
- if ( $this->hasRequestVar('parameters'))
- $this->element->code = $this->getRequestVar('parameters',OR_FILTER_RAW);
-
-// Html::debug($this->element);
- $this->element->save();
- $this->addNotice('element',$this->element->name,'SAVED');
-
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/action/FileAction.class.php b/action/FileAction.class.php
@@ -1,815 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\File;
-
-use Http;
-use \Html;
-
-// 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 zum Bearbeiten einer Datei
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class FileAction extends ObjectAction
-{
- public $security = SECURITY_USER;
-
- var $file;
- var $defaultSubAction = 'show';
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->file = new File( $this->getRequestId() );
- $this->file->load();
- }
-
-
- /**
- * Ersetzt den Inhalt mit einer anderen Datei
- */
- public function editPost()
- {
- $upload = new Upload();
-
- $this->file->filename = $upload->filename;
- $this->file->extension = $upload->extension;
- $this->file->size = $upload->size;
- $this->file->save();
-
- $this->file->value = $upload->value;
- $this->file->saveValue();
- $this->file->setTimestamp();
-
- //$setTemplateVar('tree_refresh',true);
- $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok');
- }
-
-
- public function valuePost()
- {
- $this->file->value = $this->getRequestVar('value',OR_FILTER_RAW);
- $this->file->saveValue();
-
- $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok');
- $this->file->setTimestamp();
- }
-
-
- /**
- * Abspeichern der Eigenschaften zu dieser Datei.
- *
- */
- function propPost()
- {
- // Eigenschaften speichern
- $this->file->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME);
- $this->file->name = $this->getRequestVar('name' ,OR_FILTER_FULL );
- $this->file->extension = $this->getRequestVar('extension' ,OR_FILTER_FILENAME);
- $this->file->desc = $this->getRequestVar('description',OR_FILTER_FULL );
-
- $this->file->save();
- $this->file->setTimestamp();
- $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok');
- }
-
-
-
- /**
- * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
- * auf die Standardausgabe geschrieben
- */
- function previewView()
- {
- $url = Html::url('file','show',$this->file->objectid,array('target'=>'none') );
- $this->setTemplateVar('preview_url',$url );
-
- $this->setTemplateVar('image',$this->file->isImage() );
-
- }
-
-
- /**
- * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
- * auf die Standardausgabe geschrieben
- */
- function showView()
- {
- $this->lastModified( $this->file->lastchangeDate );
-
- if ( $this->file->extension == 'gz' )
- {
- global $conf;
- $mime_types = $conf['mime-types'];
-
- $pos = strrpos($this->file->filename,'.');
- if ( $pos === false )
- $ext = '';
- else
- $ext = substr($this->file->filename,$pos+1);
-
- $ext = strtolower($ext);
-
- if ( !empty($mime_types[$ext]) )
- $mime_type = $mime_types[$ext];
- else
- // Wenn kein Mime-Type gefunden, dann Standartwert setzen
- $mime_type = OR_FILE_DEFAULT_MIMETYPE;
-
- header('Content-Type: '.$mime_type );
- header('Content-Encoding: gzip' );
- }
- else
- {
- // Angabe Content-Type
- header('Content-Type: '.$this->file->mimeType() );
- }
-
- header('X-File-Id: ' .$this->file->fileid );
- header('X-Id: ' .$this->file->id );
-
- // Angabe Content-Disposition
- // - Bild soll "inline" gezeigt werden
- // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
- header('Content-Disposition: inline; filename='.$this->file->filenameWithExtension() );
- header('Content-Transfer-Encoding: binary' );
- header('Content-Description: '.$this->file->name );
-
- $this->file->write(); // Bild aus Datenbank laden
-
- // Groesse des Bildes in Bytes
- // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
- header('Content-Length: '.filesize($this->file->tmpfile()) );
-
- if ( in_array( getenv('HTTP_ACCEPT'),array('application/php-array','application/php-serialized','application/json','application/xml')))
- {
- $this->setTemplateVar('encoding', 'base64');
- $this->setTemplateVar('value' , base64_encode($this->file->tmpfile()) );
- }
- // Unterscheidung, ob PHP-Code in der Datei ausgefuehrt werden soll.
- elseif ( ( config('publish','enable_php_in_file_content')=='auto' && $this->file->getRealExtension()=='php') ||
- config('publish','enable_php_in_file_content')===true )
- // PHP-Code ausfuehren
- require( $this->file->tmpfile() );
- else
- // PHP-Code nicht ausfuehren, Datei direkt auf die Standardausgabe schreiben
- readfile( $this->file->tmpfile() );
- exit;
- }
-
-
- function imageFormat()
- {
- if ( ! function_exists( 'imagetypes' ) )
- return 0;
-
- $ext = strtolower($this->file->getRealExtension());
- $types = imagetypes();
- $formats = array( 'gif' =>IMG_GIF,
- 'jpg' =>IMG_JPG,
- 'jpeg'=>IMG_JPG,
- 'png' =>IMG_PNG );
-
- if ( !isset($formats[$ext]) )
- return 0;
-
- if ( $types & $formats[$ext] )
- return $formats[$ext];
-
- return 0;
- }
-
-
-
- function imageExt()
- {
- switch( $this->imageFormat() )
- {
- case IMG_GIF:
- return 'GIF';
- case IMG_JPG:
- return 'JPEG';
- case IMG_PNG:
- return 'PNG';
- }
- }
-
-
-
- function imageFormats()
- {
- if ( ! function_exists( 'imagetypes' ) )
- return array();
-
- $types = imagetypes();
- $formats = array( IMG_GIF => 'gif',
- IMG_JPG => 'jpeg',
- IMG_PNG => 'png' );
- $formats2 = $formats;
-
- foreach( $formats as $b=>$f )
- if ( !($types & $b) )
- unset( $formats2[$b] );
-
- return $formats2;
- }
-
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function sizeView()
- {
- $this->setTemplateVars( $this->file->getProperties() );
-
- $format = $this->imageFormat();
-
- if ( $format == 0 )
- {
- $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN);
- }
-
- $formats = $this->imageFormats();
-
- if ( empty($formats) )
- $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN);
-
- $sizes = array();
- foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s )
- $sizes[strval($s/100)] = $s.'%';
-
- $jpeglist = array();
- for ($i=10; $i<=95; $i+=5)
- $jpeglist[$i]=$i.'%';
-
- $this->setTemplateVar('factors' ,$sizes );
- $this->setTemplateVar('jpeglist' ,$jpeglist );
- $this->setTemplateVar('formats' ,$formats );
- $this->setTemplateVar('format' ,$format );
- $this->setTemplateVar('factor' ,1 );
-
- $this->file->getImageSize();
- $this->setTemplateVar('width' ,$this->file->width );
- $this->setTemplateVar('height',$this->file->height );
- $this->setTemplateVar('type' ,'input' );
- }
-
-
-
-
- /**
- * Bildgroesse eines Bildes aendern
- */
- public function sizePost()
- {
- $width = intval($this->getRequestVar('width' ));
- $height = intval($this->getRequestVar('height' ));
- $jpegcompression = $this->getRequestVar('jpeg_compression') ;
- $format = $this->getRequestVar('format' ) ;
- $factor = $this->getRequestVar('factor' ) ;
-
- if ( $this->getRequestVar('type') == 'input' &&
- ! $this->hasRequestVar('width' ) &&
- ! $this->hasRequestVar('height') )
- {
- $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' );
- $this->addValidationError('height','');
- $this->callSubAction('size');
- return;
- }
-
- if ( $this->hasRequestVar('copy') )
- {
- // Datei neu anlegen.
- $imageFile = new File($this->file->objectid);
- $imageFile->load();
- $imageFile->name = lang('copy_of').' '.$imageFile->name;
- $imageFile->desription = lang('copy_of').' '.$imageFile->description;
- $imageFile->filename = $imageFile->filename.'_resized_'.time();
- $imageFile->add();
- $imageFile->copyValueFromFile( $this->file->objectid );
- }
- else
- {
- $imageFile = $this->file;
- }
-
- if ( $this->getRequestVar('type') == 'factor')
- {
- $width = 0;
- $height = 0;
- }
- else
- {
- $factor = 1;
- }
-
- $imageFile->write();
-
- $imageFile->imageResize( intval($width),intval($height),$factor,$this->imageFormat(),$format,$jpegcompression );
- $imageFile->setTimestamp();
- $imageFile->save(); // Um z.B. Groesse abzuspeichern
- $imageFile->saveValue();
-
- $this->addNotice($imageFile->getType(),$imageFile->name,'IMAGE_RESIZED','ok');
- }
-
-
- function propView()
- {
-
- global $conf;
-
- if ( $this->file->filename == $this->file->objectid )
- $this->file->filename = '';
-
- // Eigenschaften der Datei uebertragen
- $this->setTemplateVars( $this->file->getProperties() );
-
- $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' );
- $this->setTemplateVar('full_filename',$this->file->full_filename());
-
- if ( is_file($this->file->tmpfile()))
- {
- $this->setTemplateVar('cache_filename' ,$this->file->tmpfile());
- $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile()));
- }
-
- // Alle Seiten mit dieser Datei ermitteln
- $pages = $this->file->getDependentObjectIds();
-
- $list = array();
- foreach( $pages as $id )
- {
- $o = new Object( $id );
- $o->load();
- $list[$id] = array();
- $list[$id]['url' ] = Html::url('main','page',$id);
- $list[$id]['name'] = $o->name;
- }
- asort( $list );
- $this->setTemplateVar('pages',$list);
- $this->setTemplateVar('edit_filename',$conf['filename']['edit']);
- }
-
-
- public function infoView()
- {
-
- global $conf;
-
- if ( $this->file->filename == $this->file->objectid )
- $this->file->filename = '';
-
- // Eigenschaften der Datei uebertragen
- $this->setTemplateVars( $this->file->getProperties() );
-
- $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' );
- $this->setTemplateVar('full_filename',$this->file->full_filename());
-
- if ( is_file($this->file->tmpfile()))
- {
- $this->setTemplateVar('cache_filename' ,$this->file->tmpfile());
- $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile()));
- }
-
- // Alle Seiten mit dieser Datei ermitteln
- $pages = $this->file->getDependentObjectIds();
-
- $list = array();
- foreach( $pages as $id )
- {
- $o = new Object( $id );
- $o->load();
- $list[$id] = array();
- $list[$id]['url' ] = Html::url('main','page',$id);
- $list[$id]['name'] = $o->name;
- }
- asort( $list );
- $this->setTemplateVar('pages',$list);
- $this->setTemplateVar('edit_filename',$conf['filename']['edit']);
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function editView()
- {
- global $conf;
- // MIME-Types aus Datei lesen
- $this->setTemplateVars( $this->file->getProperties() );
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function upload()
- {
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function valueView()
- {
- global $conf;
- // MIME-Types aus Datei lesen
- $this->setTemplateVars( $this->file->getProperties() );
- $this->setTemplateVar('value',$this->file->loadValue());
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function extractView()
- {
- $this->setTemplateVars( $this->file->getProperties() );
-
- $imageFormat = $this->imageFormat();
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function uncompressView()
- {
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function uncompressPost()
- {
- switch( $this->file->extension )
- {
- case 'gz':
- if ( $this->getRequestVar('replace') )
- {
- if ( strcmp(substr($this->file->loadValue(),0,2),"\x1f\x8b"))
- {
- Http::serverError("Not GZIP format (See RFC 1952)");
- }
- $method = ord(substr($this->file->loadValue(),2,1));
- if ( $method != 8 )
- {
- Http::serverError("Unknown GZIP method: $method");
- }
- $this->file->value = gzinflate( substr($this->file->loadValue(),10));
- $this->file->parse_filename( $this->file->filename );
- $this->file->save();
- $this->file->saveValue();
- }
- else
- {
- $newFile = new File();
- $newFile->name = $this->file->name;
- $newFile->parentid = $this->file->parentid;
- $newFile->value = gzinflate( substr($this->file->loadValue(),10));
- $newFile->parse_filename( $this->file->filename );
- $newFile->add();
- }
-
- break;
-
- case 'bz2':
- if ( $this->getRequestVar('replace') )
- {
- $this->file->value = bzdecompress($this->file->loadValue());
- $this->file->parse_filename( $this->file->filename );
- $this->file->save();
- $this->file->saveValue();
- }
- else
- {
- $newFile = new File();
- $newFile->name = $this->file->name;
- $newFile->parentid = $this->file->parentid;
- $newFile->value = bzdecompress( $this->file->loadValue() );
- $newFile->parse_filename( $this->file->filename );
- $newFile->add();
- }
-
- break;
-
- default:
- die( 'cannot uncompress file with extension: '.$this->file->extension );
- }
-
- $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK);
- $this->callSubAction('edit');
- }
-
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function extractPost()
- {
- switch( $this->file->extension )
- {
- case 'tar':
- $folder = new Folder();
- $folder->parentid = $this->file->parentid;
- $folder->name = $this->file->name;
- $folder->filename = $this->file->filename;
- $folder->add();
-
- $tar = new ArchiveTar();
- $tar->openTAR( $this->file->loadValue() );
-
- foreach( $tar->files as $file )
- {
- $newFile = new File();
- $newFile->name = $file['name'];
- $newFile->parentid = $folder->objectid;
- $newFile->value = $file['file'];
- $newFile->parse_filename( $file['name'] );
- $newFile->lastchangeDate = $file['time'];
- $newFile->add();
-
- $this->addNotice('file',$newFile->name,'ADDED');
- }
-
- unset($tar);
-
- break;
-
- case 'zip':
-
- $folder = new Folder();
- $folder->parentid = $this->file->parentid;
- $folder->name = $this->file->name;
- $folder->filename = $this->file->filename;
- $folder->description = $this->file->fullFilename;
- $folder->add();
-
- $zip = new ArchiveUnzip();
- $zip->open( $this->file->loadValue() );
-
- $lista = $zip->getList();
-
- if(sizeof($lista)) foreach($lista as $fileName=>$trash){
-
-
- $newFile = new File();
- $newFile->name = basename($fileName);
- $newFile->description = 'Extracted: '.$this->file->fullFilename.' -> '.$fileName;
- $newFile->parentid = $folder->objectid;
- $newFile->parse_filename( basename($fileName) );
-
- $newFile->value = $zip->unzip($fileName);
- $newFile->add();
-
- $this->addNotice('file',$newFile->name,'ADDED');
- unset($newFile);
- }
-
- $zip->close();
- unset($zip);
-
- break;
-
- default:
- die( 'cannot extract file with extension: '.$this->file->extension );
- }
- $this->callSubAction('edit');
- }
-
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function compressView()
- {
- $formats = array();
- foreach( $this->getCompressionTypes() as $t )
- $formats[$t] = lang('compression_'.$t);
-
- $this->setTemplateVar('formats' ,$formats );
- }
-
-
-
- /**
- * Anzeigen des Inhaltes
- */
- function compressPost()
- {
- $format = $this->getRequestVar('format',OR_FILTER_ALPHANUM);
-
- switch( $format )
- {
- case 'gz':
- if ( $this->getRequestVar('replace',OR_FILTER_NUMBER)=='1' )
- {
- $this->file->value = gzencode( $this->file->loadValue(),1 );
- $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP );
- $this->file->save();
- $this->file->saveValue();
-
- }
- else
- {
- $newFile = new File();
- $newFile->name = $this->file->name;
- $newFile->parentid = $this->file->parentid;
- $newFile->value = gzencode( $this->file->loadValue(),1 );
- $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP );
- $newFile->add();
- }
-
- break;
-
- case 'bzip2':
- if ( $this->getRequestVar('replace')=='1' )
- {
- $this->file->value = bzcompress( $this->file->loadValue() );
- $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' );
- $this->file->save();
- $this->file->saveValue();
-
- }
- else
- {
- $newFile = new File();
- $newFile->name = $this->file->name;
- $newFile->parentid = $this->file->parentid;
- $newFile->value = bzcompress( $this->file->loadValue() );
- $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' );
- $newFile->add();
- }
-
- break;
- default:
- die( 'unknown compress type: '.$format );
- }
-
- $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK);
- $this->callSubAction('edit');
- }
-
-
- /**
- * Datei veroeffentlichen
- */
- function pubView()
- {
- }
-
-
- /**
- * Datei veroeffentlichen
- */
- function pubPost()
- {
- $this->file->publish();
- $this->file->publish->close();
-
- $this->addNotice('file',$this->file->fullFilename,'PUBLISHED'.($this->file->publish->ok?'':'_ERROR'),$this->file->publish->ok,array(),$this->file->publish->log);
- }
-
-
-
- function getCompressionTypes()
- {
- $compressionTypes = array();
- if ( function_exists('gzencode' ) ) $compressionTypes[] = 'gz';
- //if ( function_exists('gzencode' ) ) $compressionTypes[] = 'zip';
- if ( function_exists('bzipcompress') ) $compressionTypes[] = 'bz2';
- return $compressionTypes;
- }
-
- function getArchiveTypes()
- {
- $archiveTypes = array();
- $archiveTypes[] = 'tar';
- $archiveTypes[] = 'zip';
- return $archiveTypes;
- }
-
-
-
- function checkMenu( $name )
- {
- $archiveTypes = $this->getArchiveTypes();
- $compressionTypes = $this->getCompressionTypes();
-
- switch( $name )
- {
- case 'uncompress':
- return !readonly() && in_array($this->file->extension,$compressionTypes);
-
- case 'compress':
- return !readonly() && !in_array($this->file->extension,$compressionTypes);
-
- case 'extract':
- return !readonly() && in_array($this->file->extension,$archiveTypes);
-
- case 'size':
- return !readonly() && $this->file->isImage();
-
- case 'editvalue':
- return !readonly() && substr($this->file->mimeType(),0,5)=='text/';
-
- case 'aclform':
- return !readonly();
-
- default:
- return true;
- }
- }
-
-
-
- /**
- * 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->file->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->file->objectid ] = array('id'=>$this->file->objectid,'name'=>$this->file->name,'type'=>'file','self'=>true,'children'=>&$elementChildren);
-
-
- //Html::debug($structure);
-
- $this->setTemplateVar('outline',$structure);
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/action/FilebrowserAction.class.php b/action/FilebrowserAction.class.php
@@ -1,261 +0,0 @@
-<?php
-
-namespace cms\action;
-
-
-use Http;
-use Session;
-use \Html;
-
-// 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 zum Bearbeiten einer Datei
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class FilebrowserAction extends ObjectAction
-{
- public $security = SECURITY_USER;
-
- var $command;
- var $resourceType;
-
- /**
- * Ordner
- *
- * @var String
- */
- var $currentFolder;
-
- /**
- * Aktueller Ordner
- *
- * @var Object
- */
- var $folder;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- if ( $this->getRequestId() != 0 )
- {
- $fid = $this->getRequestId();
- }
- else
- {
- $project = Session::getProject();
- $fid = $project->getRootObjectId();
- }
-
- $this->folder = new Folder( $fid );
- $this->folder->load();
-
-
- }
-
-
-
- /**
- *
- */
- function show()
- {
- Http::notAuthorized('no subaction found');
- }
-
-
- /**
- * Datei-Upload.
- *
- */
- public function directuploadPost()
- {
- $upload = new Upload( $this->getRequestVar('name','abc') );
-
- if ( !$upload->isValid() )
- {
- echo 'Upload failed, reason: '.$upload->error;
- }
- else
- {
- $file = new File();
- $file->parentid = $this->folder->objectid;
- $file->name = $upload->filename;
- $file->filename = $upload->filename;
- $file->extension = $upload->extension;
- $file->value = $upload->value;
- $file->add();
-
- $newId = $file->objectid;
- $newUrl = str_replace('&','&',Html::url('file','show',$newId,array('oid'=>'__OID__'.$newId.'__')));
-
- echo '<script type="text/javascript">' ;
- echo 'window.parent.CKEDITOR.tools.callFunction('.$this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER).",'".$newUrl."','');</script>";
- echo '</script>' ;
- echo 'OK' ;
- }
-
- }
-
-
- public function browseView()
- {
- global $conf_php;
- $funcNum = $this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER);
-
- if ( ! $this->folder->isRoot )
- $this->setTemplateVar('up_url',Html::url('filebrowser','browse',$this->folder->parentid,array('CKEditorFuncNum'=>$funcNum)));
-
- $user = Session::getUser();
- $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
- $this->setTemplateVar('style',$user->style );
-
- $list = array();
-
- // Schleife ueber alle Objekte in diesem Ordner
- foreach( $this->folder->getObjects() as $o )
- {
- $id = $o->objectid;
-
- if ( $o->hasRight(ACL_READ) )
- {
- $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
- $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
- $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
- if ( $list[$id]['desc'] == '' )
- $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
-
- $list[$id]['type'] = $o->getType();
-
- $list[$id]['icon' ] = $o->getType();
- $list[$id]['class'] = $o->getType();
- if ( $o->isFolder )
- $list[$id]['url' ] = Html::url('filebrowser','browse',$id,array('CKEditorFuncNum'=>$funcNum) );
- else
- $list[$id]['url' ] = "javascript:window.top.opener.CKEDITOR.tools.callFunction($funcNum,'".Html::url('file','show',$id,array('oid'=>'__OID__'.$id.'__'))."','');window.top.close();window.top.opener.focus();";
-
-
-
- if ( $o->getType() == 'file' )
- {
- $file = new File( $id );
- $file->load();
- $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
-
- if ( $file->isImage() )
- {
- $list[$id]['icon' ] = 'image';
- $list[$id]['class'] = 'image';
- //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
- }
-// if ( substr($file->mimeType(),0,5) == 'text/' )
-// $list[$id]['icon'] = 'text';
- }
-
- $list[$id]['date'] = $o->lastchangeDate;
- $list[$id]['user'] = $o->lastchangeUser;
- }
- }
-
- $this->setTemplateVar('object' ,$list );
- $this->setTemplateVar('CKEditorFuncNum',$funcNum );
- $this->setTemplateVar('token',token() );
- $this->setTemplateVar('id',$this->folder->objectid );
- }
-
-
- public function addfolderPost()
- {
-
- $filename = $this->getRequestVar('name');
-
- if ( empty($filename) )
- {
- $this->addNotice('folder',$this->name,'ADDED',OR_NOTICE_ERROR);
- }
- elseif( !$this->folder->hasRight(ACL_CREATE_FOLDER) )
- {
- $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR);
- }
- elseif( $this->folder->hasFilename( $filename ) )
- {
- $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR);
-
- }
- else
- {
- $newFolder = new Folder();
- $newFolder->parentid = $this->folder->objectid;
- $newFolder->filename = $filename;
- $newFolder->name = $filename;
- $newFolder->add();
-
- $this->addNotice('folder',$this->folder->name,'ADDED',OR_NOTICE_OK);
- }
- }
-
-
-
- public function uploadPost()
- {
- if ( $this->hasRequestVar('name') )
- $name = $this->getRequestVar('name','abc');
- else
- $name = 'file';
-
- $upload = new Upload($name);
-
- if ( !$upload->isValid() )
- {
- Html::debug($upload);
- $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
- return;
- }
- // Pr�fen der maximal erlaubten Dateigr��e.
- elseif ( $upload->size < 0 )
- {
- // Maximale Dateigr��e ist �berschritten
- $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
- return;
- }
- elseif( $upload->size > 0 )
- {
- $file = new File();
- $file->desc = '';
- $file->filename = $upload->filename;
- $file->name = $upload->filename;
- $file->extension = $upload->extension;
- $file->size = $upload->size;
- $file->parentid = $this->folder->objectid;
-
- $file->value = $upload->value;
-
- $file->add(); // Datei hinzufuegen
- $this->folder->setTimestamp();
- $this->addNotice('file',$file->name,'ADDED','ok');
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/action/FolderAction.class.php b/action/FolderAction.class.php
@@ -1,1566 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use ArchiveTar;
-use cms\model\Template;
-use cms\model\Page;
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\File;
-use cms\model\Link;
-
-use cms\model\Url;
-use Http;
-use Publish;
-use Session;
-use \Html;
-use Text;
-use Upload;
-
-// 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 zum Bearbeiten eines Ordners
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class FolderAction extends ObjectAction
-{
- public $security = SECURITY_USER;
-
- private $folder;
-
- public function __construct()
- {
- $this->folder = new Folder( $this->getRequestId() );
- $this->folder->load();
- }
-
-
-
- /**
- * Neues Objekt anlegen.<br>
- * Dies kann ein(e) Verzeichnis, Seite, Verkn�pfung oder Datei sein.<br>
- */
- public function createPost()
- {
- global $conf;
- $type = $this->getRequestVar('type' );
-
- switch( $type )
- {
- case 'folder':
- $name = $this->getRequestVar('folder_name');
-
- if ( !empty($name) )
- {
- $f = new Folder();
- $f->name = $name;
- $f->parentid = $this->folder->objectid;
- $f->add();
- $this->folder->setTimestamp();
- $this->addNotice('folder',$f->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('folder_name');
- $this->callSubAction('create');
- }
- break;
-
- case 'file':
- $upload = new Upload();
-
- if ( !$upload->isValid() )
- {
- $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
- $this->callSubAction('createfile');
- return;
- }
- // Pr�fen der maximal erlaubten Dateigr��e.
- elseif ( $upload->size > $this->maxFileSize() )
- {
- // Maximale Dateigr��e ist �berschritten
- $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
- $this->callSubAction('createfile');
- return;
- }
- elseif( $upload->size > 0 )
- {
- $file = new File();
- $file->desc = '';
- $file->filename = $upload->filename;
- $file->name = $upload->filename;
- $file->extension = $upload->extension;
- $file->size = $upload->size;
- $file->parentid = $this->folder->objectid;
-
- $file->value = $upload->value;
-
- $file->add(); // Datei hinzufuegen
- $this->folder->setTimestamp();
- $this->addNotice('file',$file->name,'ADDED','ok');
- }
-
- break;
-
- case 'page':
-
- $name = $this->getRequestVar('page_name');
- if ( !empty($name) )
- {
- $page = new Page();
- $page->name = $name;
- $page->templateid = $this->getRequestVar('page_templateid');
- $page->parentid = $this->folder->objectid;
- $page->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('page',$page->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('page_name');
- $this->callSubAction('create');
- }
- break;
-
- case 'link':
-
- $name = $this->getRequestVar('link_name');
- if ( !empty($name) )
- {
- $link = new Link();
- $link->name = $name;
- $link->parentid = $this->folder->objectid;
-
- $link->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('link',$link->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('link_name');
- $this->callSubAction('create');
- }
-
- break;
-
- case 'url':
-
- $urlValue = $this->getRequestVar('url');
- if ( !empty($urlValue) )
- {
- $url = new Url();
- $url->name = $urlValue;
- $url->parentid = $this->folder->objectid;
-
- $url->url = $urlValue;
-
- $url->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('url',$url->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('url');
- $this->callSubAction('create');
- }
-
- break;
-
- default:
- $this->addValidationError('type');
- $this->callSubAction('create');
-
- }
-
- }
-
-
-
- public function createfolderPost()
- {
- $type = $this->getRequestVar('type' );
- $name = $this->getRequestVar('name' );
- $filename = $this->getRequestVar('filename' );
- $description = $this->getRequestVar('description');
-
- if ( !empty($name) )
- {
- $f = new Folder();
- $f->name = $name;
- $f->filename = $name;
- $f->desc = $description;
- $f->parentid = $this->folder->objectid;
-
- $f->add();
- $this->addNotice('folder',$f->name,'ADDED','ok');
- $this->setTemplateVar('objectid',$f->objectid);
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('createfolder');
- }
-
- $this->folder->setTimestamp();
- }
-
-
-
- public function createfilePost()
- {
- $type = $this->getRequestVar('type' );
- $name = $this->getRequestVar('name' );
- $filename = $this->getRequestVar('filename' );
- $description = $this->getRequestVar('description');
-
- $file = new File();
-
- // Die neue Datei wird über eine URL geladen und dann im CMS gespeichert.
- if ( $this->hasRequestVar('url') )
- {
- $url = $this->getRequestVar('url');
- $http = new Http();
- $http->setUrl( $url );
-
- $ok = $http->request();
-
- if ( !$ok )
- {
- $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error);
- $this->callSubAction('createfile');
- return;
- }
-
- $file->desc = $description;
- $file->filename = basename($url);
- $file->name = !empty($name)?$name:basename($url);
- $file->size = strlen($http->body);
- $file->value = $http->body;
- $file->parentid = $this->folder->objectid;
- }
- else
- {
- $upload = new Upload();
-
- if ( $upload->isValid() )
- {
- $file->desc = $description;
- $file->filename = $upload->filename;
- $file->name = !empty($name)?$name:$upload->filename;
- $file->extension = $upload->extension;
- $file->size = $upload->size;
- $file->parentid = $this->folder->objectid;
-
- $file->value = $upload->value;
- }
- else
- {
- if ( $this->hasRequestVar('name') )
- {
- $file->name = $this->getRequestVar('name');
- $file->desc = $this->getRequestVar('description');
- $file->filename = $this->getRequestVar('filename', OR_FILTER_FILENAME);
- $file->parentid = $this->folder->objectid;
- }
- else
- {
- $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
- $this->callSubAction('createfile');
- return;
- }
-
- }
- }
-
- $file->add(); // Datei hinzufuegen
- $this->addNotice('file',$file->name,'ADDED','ok');
- $this->setTemplateVar('objectid',$file->objectid);
-
- $this->folder->setTimestamp();
- }
-
-
-
- public function createlinkPost()
- {
- $name = $this->getRequestVar('name' );
- $filename = $this->getRequestVar('filename' );
- $description = $this->getRequestVar('description');
-
- if ( !empty($name) )
- {
- $link = new Link();
- $link->filename = $filename;
- $link->name = $name;
- $link->desc = $description;
- $link->parentid = $this->folder->objectid;
-
- $link->linkedObjectId = $this->getRequestVar('targetobjectid');
-
- $link->add();
-
- $this->addNotice('link',$link->name,'ADDED','ok');
- $this->setTemplateVar('objectid',$link->objectid);
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('createlink');
- return;
- }
-
- $this->folder->setTimestamp();
- }
-
- public function createurlPost()
- {
- $name = $this->getRequestVar('name' );
- $description = $this->getRequestVar('description');
- $filename = $this->getRequestVar('filename' );
-
- if ( !empty($name) )
- {
- $url = new Url();
- $url->filename = $filename;
- $url->name = $name;
- $url->desc = $description;
- $url->parentid = $this->folder->objectid;
-
- $url->url = $this->getRequestVar('url');
-
- $url->add();
-
- $this->addNotice('url',$url->name,'ADDED','ok');
- $this->setTemplateVar('objectid',$url->objectid);
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('createurl');
- return;
- }
-
- $this->folder->setTimestamp();
- }
-
-
-
- public function createpagePost()
- {
- $type = $this->getRequestVar('type' );
- $name = $this->getRequestVar('name' );
- $filename = $this->getRequestVar('filename' );
- $description = $this->getRequestVar('description');
-
- if ( $this->getRequestVar('name') != '' )
- {
- $page = new Page();
- $page->name = $name;
- $page->desc = $description;
- $page->filename = $filename;
- $page->templateid = $this->getRequestVar('templateid');
- $page->parentid = $this->folder->objectid;
-
- $page->add();
-
- $this->addNotice('page',$page->name,'ADDED','ok');
- $this->setTemplateVar('objectid',$page->objectid);
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('createpage');
- return;
- }
-
- $this->folder->setTimestamp();
- }
-
-
-
- /**
- * Abspeichern der Ordner-Eigenschaften. Ist der Schalter "delete" gesetzt, wird
- * der Ordner stattdessen gel?scht.
- */
- public function propPost()
- {
- // Ordnereigenschaften speichern
- if ( $this->getRequestVar('name') != '' )
- $this->folder->name = $this->getRequestVar('name' ,'full');
- elseif ($this->getRequestVar('filename') != '' )
- $this->folder->name = $this->getRequestVar('filename',OR_FILTER_ALPHANUM);
- else
- {
- $this->addValidationError('name');
- $this->addValidationError('filename');
- //$this->callSubAction('prop');
- return;
- }
-
- $this->folder->filename = $this->getRequestVar('filename' ,OR_FILTER_ALPHANUM);
- $this->folder->desc = $this->getRequestVar('description','full' );
- $this->folder->save();
- $this->addNotice($this->folder->getType(),$this->folder->name,'PROP_SAVED','ok');
- }
-
-
- /**
- * Reihenfolge von Objekten aendern.
- */
- public function orderPost()
- {
- $ids = $this->folder->getObjectIds();
- $seq = 0;
-
- $order = explode(',',$this->getRequestVar('order') );
-
- foreach( $order as $objectid )
- {
- if ( ! in_array($objectid,$ids) )
- {
- Http::serverError('Object-Id '.$objectid.' is not in this folder any more');
- }
- $seq++; // Sequenz um 1 erhoehen
-
- $o = new Object( $objectid );
- $o->setOrderId( $seq );
-
- unset( $o ); // Selfmade Garbage Collection :-)
- }
-
- $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
- $this->folder->setTimestamp();
- }
-
-
- // Reihenfolge von Objekten aendern
- public function changesequencePost()
- {
- $ids = $this->folder->getObjectIds();
- $seq = 0;
- foreach( $ids as $id )
- {
- $seq++; // Sequenz um 1 erhoehen
-
- // Die beiden Ordner vertauschen
- if ( $id == $this->getRequestVar('objectid1') )
- $id = $this->getRequestVar('objectid2');
- elseif ( $id == $this->getRequestVar('objectid2') )
- $id = $this->getRequestVar('objectid1');
-
- $o = new Object( $id );
- $o->setOrderId( $seq );
-
- unset( $o ); // Selfmade Garbage Collection :-)
- }
-
- $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
- $this->folder->setTimestamp();
-
- // Ordner anzeigen
- $this->callSubAction('order');
-
- }
-
-
- private function OLD__________editPost()
- {
- $type = $this->getRequestVar('type'); // Typ der Aktion, z.B "copy" oder "move"
-
- switch( $type )
- {
- case 'move':
- case 'copy':
- case 'link':
- // Liste von m�glichen Zielordnern anzeigen
-
- $otherfolder = array();
- foreach( $this->folder->getAllFolders() as $id )
- {
- $f = new Folder( $id );
-
- // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
- // von Verkn�pfungen vorhanden sein.
- //
- // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
- // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
- if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) ||
- ( ( $type=='move' || $type == 'copy' ) &&
- ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) )
- // Zielordner hinzuf�gen
- $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
- }
-
- // Zielordner-Liste alphabetisch sortieren
- asort( $otherfolder );
-
- $this->setTemplateVar('folder',$otherfolder);
-
- break;
-
- case 'archive':
- $this->setTemplateVar('ask_filename','');
- break;
-
- case 'delete':
- $this->setTemplateVar('ask_commit','');
- break;
-
- default:
- $this->addValidationError('type');
- return;
-
- } // switch
-
- $ids = $this->folder->getObjectIds();
- $objectList = array();
-
- foreach( $ids as $id )
- {
- // Nur, wenn Objekt ausgewaehlt wurde
- if ( !$this->hasRequestVar('obj'.$id) )
- continue;
-
- $o = new Object( $id );
- $o->load();
-
- // F�r die gew�nschte Aktion m�ssen pro Objekt die entsprechenden Rechte
- // vorhanden sein.
- if ( $type == 'copy' && $o->hasRight( ACL_READ ) ||
- $type == 'move' && $o->hasRight( ACL_DELETE ) ||
- $type == 'link' && $o->hasRight( ACL_READ ) ||
- $type == 'archive' && $o->hasRight( ACL_READ ) ||
- $type == 'delete' && $o->hasRight( ACL_DELETE ) )
- $objectList[ $id ] = $o->getProperties();
- }
-
- $this->setTemplateVar('type' ,$type );
- $this->setTemplateVar('objectlist',$objectList );
-
- // Komma-separierte Liste von ausgew�hlten Objekt-Ids erzeugen
- $this->setTemplateVar('ids',join(array_keys($objectList),',') );
- }
-
-
-
- /**
- * Verschieben/Kopieren/Loeschen/Verknuepfen von mehreren Dateien in diesem Ordner
- */
- public function editPost()
- {
- $type = $this->getRequestVar('type');
- $ids = explode(',',$this->getRequestVar('ids'));
- $targetObjectId = $this->getRequestVar('targetobjectid');
-
- // Prüfen, ob Schreibrechte im Zielordner bestehen.
- switch( $type )
- {
- case 'move':
- case 'copy':
- case 'link':
- $f = new Folder( $targetObjectId );
-
- // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
- // von Verkn�pfungen vorhanden sein.
- //
- // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
- // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
- if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) ||
- ( ( $type=='move' || $type == 'copy' ) &&
- ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) )
- {
- // OK
- }
- else
- {
- $this->addValidationError('targetobjectid','no_rights');
- return;
- }
-
- break;
- default:
- }
-
-
- $ids = $this->folder->getObjectIds();
- $objectList = array();
-
- foreach( $ids as $id )
- {
- // Nur, wenn Objekt ausgewaehlt wurde
- if ( !$this->hasRequestVar('obj'.$id) )
- continue;
-
- $o = new Object( $id );
- $o->load();
-
- // Fuer die gewuenschte Aktion muessen pro Objekt die entsprechenden Rechte
- // vorhanden sein.
- if ( $type == 'copy' && $o->hasRight( ACL_READ ) ||
- $type == 'move' && $o->hasRight( ACL_WRITE ) ||
- $type == 'link' && $o->hasRight( ACL_READ ) ||
- $type == 'archive' && $o->hasRight( ACL_READ ) ||
- $type == 'delete' && $o->hasRight( ACL_DELETE ) )
- $objectList[ $id ] = $o->getProperties();
- else
- $this->addNotice($o->getType(),$o->name,'no_rights',OR_NOTICE_WARN);
- }
-
- $ids = array_keys($objectList);
-
- if ( $type == 'archive' )
- {
- require_once('serviceClasses/ArchiveTar.class.php');
- $tar = new ArchiveTar();
- $tar->files = array();
-
- foreach( $ids as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- if ( $o->isFile )
- {
- $file = new File($id);
- $file->load();
-
- // Datei dem Archiv hinzufügen.
- $info = array();
- $info['name'] = $file->filenameWithExtension();
- $info['file'] = $file->loadValue();
- $info['mode'] = 0600;
- $info['size'] = $file->size;
- $info['time'] = $file->lastchangeDate;
- $info['user_id' ] = 1000;
- $info['group_id'] = 1000;
- $info['user_name' ] = 'nobody';
- $info['group_name'] = 'nobody';
-
- $tar->numFiles++;
- $tar->files[]= $info;
- }
- else
- {
- // Was anderes als Dateien ignorieren.
- $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN);
- }
-
- }
-
- // TAR speichern.
- $tarFile = new File();
- $tarFile->name = lang('GLOBAL_ARCHIVE').' '.$this->getRequestVar('filename');
- $tarFile->filename = $this->getRequestVar('filename');
- $tarFile->extension = 'tar';
- $tarFile->parentid = $this->folder->objectid;
-
- $tar->__generateTAR();
- $tarFile->value = $tar->tar_file;
- $tarFile->add();
- }
- else
- {
- foreach( $ids as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- switch( $type )
- {
- case 'move':
- if ( $o->isFolder )
- {
- $f = new Folder( $id );
- $allsubfolders = $f->getAllSubFolderIds();
-
- // Plausibilisierungsprüfung:
- //
- // Wenn
- // - Das Zielverzeichnis sich nicht in einem Unterverzeichnis des zu verschiebenen Ordners liegt
- // und
- // - Das Zielverzeichnis nicht der zu verschiebene Ordner ist
- // dann verschieben
- if ( !in_array($targetObjectId,$allsubfolders) && $id != $targetObjectId )
- {
- $this->addNotice($o->getType(),$o->name,'MOVED','ok');
- $o->setParentId( $targetObjectId );
- }
- else
- {
- $this->addNotice($o->getType(),$o->name,'ERROR','error');
- }
- }
- else
- {
- $o->setParentId( $targetObjectId );
- $this->addNotice($o->getType(),$o->name,'MOVED','ok');
- }
- break;
-
- case 'copy':
- switch( $o->getType() )
- {
- case 'folder':
- // Ordner zur Zeit nicht kopieren
- // Funktion waere zu verwirrend
- $this->addNotice($o->getType(),$o->name,'CANNOT_COPY_FOLDER','error');
- break;
-
- case 'file':
- $f = new File( $id );
- $f->load();
- $f->filename = '';
- $f->name = lang('COPY_OF').' '.$f->name;
- $f->parentid = $targetObjectId;
- $f->add();
- $f->copyValueFromFile( $id );
-
- $this->addNotice($o->getType(),$o->name,'COPIED','ok');
- break;
-
- case 'page':
- $p = new Page( $id );
- $p->load();
- $p->filename = '';
- $p->name = lang('COPY_OF').' '.$p->name;
- $p->parentid = $targetObjectId;
- $p->add();
- $p->copyValuesFromPage( $id );
- $this->addNotice($o->getType(),$o->name,'COPIED','ok');
- break;
-
- case 'link':
- $l = new Link( $id );
- $l->load();
- $l->filename = '';
- $l->name = lang('COPY_OF').' '.$l->name;
- $l->parentid = $targetObjectId;
- $l->add();
- $this->addNotice($o->getType(),$o->name,'COPIED','ok');
- break;
-
- default:
- die('fatal: what type to delete?');
- }
- $notices[] = lang('COPIED');
- break;
-
- case 'link':
-
- if ( $o->isFile ||
- $o->isPage ) // Nur Seiten oder Dateien sind verknuepfbar
- {
- $link = new Link();
- $link->parentid = $targetObjectId;
-
- $link->linkedObjectId = $id;
- $link->isLinkToObject = true;
- $link->name = lang('LINK_TO').' '.$o->name;
- $link->add();
- $this->addNotice($o->getType(),$o->name,'LINKED','ok');
- }
- else
- {
- $this->addNotice($o->getType(),$o->name,'ERROR','error');
- }
- break;
-
- case 'delete':
-
- if ( $this->hasRequestVar('confirm') )
- {
- switch( $o->getType() )
- {
- case 'folder':
- $f = new Folder( $id );
- $f->deleteAll();
- break;
-
- case 'file':
- $f = new File( $id );
- $f->delete();
- break;
-
- case 'page':
- $p = new Page( $id );
- $p->load();
- $p->delete();
- break;
-
- case 'link':
- $l = new Link( $id );
- $l->delete();
- break;
-
- case 'url':
- $u = new Url( $id );
- $u->delete();
- break;
-
- default:
- throw new \LogicException("Error while deleting: Unknown type: {$o->getType()}");
- }
- $this->addNotice($o->getType(),$o->name,'DELETED',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN);
- }
-
- break;
-
- default:
- $this->addNotice($o->getType(),$o->name,'ERROR','error');
- }
-
- }
- }
-
- $this->folder->setTimestamp();
- }
-
-
- /**
- * Reihenfolge von Objekten aendern.
- */
- public function reorderPost()
- {
- $type = $this->getRequestVar('type');
-
- switch( $type )
- {
- case 'type':
- $ids = $this->folder->getObjectIdsByType();
- break;
-
- case 'name':
- $ids = $this->folder->getChildObjectIdsByName();
- break;
-
- case 'lastchange':
- $ids = $this->folder->getObjectIdsByLastChange();
- break;
-
- case 'flip':
- $ids = $this->folder->getObjectIds();
- $ids = array_reverse( $ids ); // Reihenfolge drehen
-
- break;
-
- default:
- Http::sendStatus(400,'Bad request','Unknown reordertype: '.$type );
- }
-
- // Und jetzt die neu ermittelte Reihenfolge speichern
- $seq = 0;
- foreach( $ids as $id )
- {
- $seq++; // Sequenz um 1 erhoehen
-
- $o = new Object( $id );
- $o->setOrderId( $seq );
-
- unset( $o );
- }
- $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
-
- $this->folder->setTimestamp();
- }
-
-
- public function settopPost()
- {
- $o = new Object( $this->getRequestVar('objectid1') );
- $o->setOrderId( 1 );
-
- $ids = $this->folder->getObjectIds();
- $seq = 1;
-
- foreach( $ids as $id )
- {
- if ( $id != $this->getRequestVar('objectid1') )
- {
- $seq++; // Sequenz um 1 erhoehen
-
- $o = new Object( $id );
- $o->setOrderId( $seq );
-
- unset( $o ); // Selfmade Garbage Collection :-)
- }
- }
-
- $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
- $this->folder->setTimestamp();
-
- // Ordner anzeigen
- $this->callSubAction('order');
- }
-
-
- public function setbottomPost()
- {
- $ids = $this->folder->getObjectIds();
- $seq = 0;
-
- foreach( $ids as $id )
- {
- if ( $id != $this->getRequestVar('objectid1') )
- {
- $seq++; // Sequenz um 1 erhoehen
-
- $o = new Object( $id );
- $o->setOrderId( $seq );
-
- unset( $o ); // Selfmade Garbage Collection :-)
- }
- }
-
- $seq++; // Sequenz um 1 erhoehen
- $o = new Object( $this->getRequestVar('objectid1') );
- $o->setOrderId( $seq );
-
- $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
- $this->folder->setTimestamp();
-
- // Ordner anzeigen
- $this->callSubAction('order');
-
- }
-
-
- /**
- * Alias für Methode 'create'.
- */
- public function newView()
- {
- $this->nextSubAction('create');
- }
-
-
- /**
- * Alias für Methode 'create'.
- */
- public function newPost()
- {
- $this->nextSubAction('create');
- }
-
-
- public function createView()
- {
- // Maximale Dateigroesse.
- $maxSizeBytes = $this->maxFileSize();
- $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
- $this->setTemplateVar('maxlength',$maxSizeBytes );
-
- $all_templates = Template::getAll();
- $this->setTemplateVar('templates' ,$all_templates );
-
- if ( count($all_templates) == 0 )
- $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
-
- $this->setTemplateVar('objectid' ,$this->folder->objectid );
- }
-
-
-
- public function createfolderView()
- {
- $this->setTemplateVar('objectid' ,$this->folder->objectid );
- }
-
-
-
- /**
- * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br>
- * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br>
- *
- * @return Integer maximale Dateigroesse in Bytes
- */
- private function maxFileSize()
- {
- global $conf;
-
- // When querying memory size values:
- // Many ini memory size values, such as upload_max_filesize,
- // are stored in the php.ini file in shorthand notation.
- // ini_get() will return the exact string stored in the php.ini file
- // and NOT its integer equivalent.
- $sizes = array(10*1024*1024*1024); // Init with 10GB enough? :)
-
- foreach( array('upload_max_filesize','post_max_size','memory_limit') as $var )
- {
- $v = $this->stringToBytes(ini_get($var));
-
- if ($v > 0 )
- $sizes[] = $v;
- }
-
- $confMaxSize = intval($conf['content']['file']['max_file_size'])*1024;
- if ( $confMaxSize > 0 )
- $sizes[] = $confMaxSize;
-
- return min($sizes);
- }
-
-
- /**
- * Hochladen einer Datei.
- *
- */
- public function createfileView()
- {
- // Maximale Dateigroesse.
- $maxSizeBytes = $this->maxFileSize();
- $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
- $this->setTemplateVar('maxlength',$maxSizeBytes );
-
- $this->setTemplateVar('objectid',$this->folder->objectid );
- }
-
-
- /**
- * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie
- * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br>
- * <br>
- * Quelle: http://de.php.net/manual/de/function.ini-get.php
- *
- * @param String Abgek�rzter Bytewert
- * @return Integer Byteanzahl
- */
- private function stringToBytes($val)
- {
- $val = trim($val);
- $last = strtolower($val{strlen($val)-1});
- // Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden!
- switch($last)
- {
- // The 'G' modifier is available since PHP 5.1.0
- case 'g':
- $val *= 1024;
- case 'm':
- $val *= 1024;
- case 'k':
- $val *= 1024;
- }
-
- return intval($val);
- }
-
-
-
- public function createlinkView()
- {
- $this->setTemplateVar('objectid' ,$this->folder->objectid );
- }
-
-
- public function createurlView()
- {
- }
-
-
- public function createpageView()
- {
- $all_templates = Template::getAll();
- $this->setTemplateVar('templates' ,$all_templates );
- $this->setTemplateVar('objectid' ,$this->folder->objectid );
-
- if ( count($all_templates) == 0 )
- $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
- }
-
-
- /**
- * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
- * auf die Standardausgabe geschrieben
- */
- private function previewViewUnused()
- {
- $this->setTemplateVar('preview_url',Html::url('folder','show',$this->folder->objectid,array('target'=>'none') ) );
- }
-
-
-
- /**
- * Anzeige aller Objekte in diesem Ordner.
- */
- public function previewView()
- {
- global $conf_php;
-
- if ( ! $this->folder->isRoot )
- $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid));
-
- $list = array();
-
- // Schleife ueber alle Objekte in diesem Ordner
- foreach( $this->folder->getObjects() as $o )
- {
- /* @var $o Object */
-
- $id = $o->objectid;
-
- if ( $o->hasRight(ACL_READ) )
- {
- $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
- $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
- $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
- if ( $list[$id]['desc'] == '' )
- $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
-
- $list[$id]['type'] = $o->getType();
- $list[$id]['id' ] = $id;
-
- $list[$id]['icon' ] = $o->getType();
- $list[$id]['class'] = $o->getType();
- $list[$id]['url' ] = Html::url($o->getType(),'',$id);
-
- if ( $o->getType() == 'file' )
- {
- $file = new File( $id );
- $file->load();
- $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
-
- if ( $file->isImage() )
- {
- $list[$id]['icon' ] = 'image';
- $list[$id]['class'] = 'image';
- //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
- }
-// if ( substr($file->mimeType(),0,5) == 'text/' )
-// $list[$id]['icon'] = 'text';
- }
-
- $list[$id]['date'] = $o->lastchangeDate;
- $list[$id]['user'] = $o->lastchangeUser;
- }
- }
-
- $this->setTemplateVar('object' ,$list );
- }
-
-
- /**
- * Anzeige aller Objekte in diesem Ordner.
- */
- public function contentView()
- {
- global $conf_php;
-
- if ( ! $this->folder->isRoot )
- $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid));
-
- $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
-
- $list = array();
-
- // Schleife ueber alle Objekte in diesem Ordner
- foreach( $this->folder->getObjects() as $o )
- {
- /* @var $o Object */
- $id = $o->objectid;
-
- if ( $o->hasRight(ACL_READ) )
- {
- $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
- $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
- $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
- if ( $list[$id]['desc'] == '' )
- $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
-
- $list[$id]['type'] = $o->getType();
- $list[$id]['id' ] = $id;
-
- $list[$id]['icon' ] = $o->getType();
- $list[$id]['class'] = $o->getType();
- $list[$id]['url' ] = Html::url($o->getType(),'',$id);
-
- if ( $o->getType() == 'file' )
- {
- $file = new File( $id );
- $file->load();
- $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
-
- if ( $file->isImage() )
- {
- $list[$id]['icon' ] = 'image';
- $list[$id]['class'] = 'image';
- //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
- }
-// if ( substr($file->mimeType(),0,5) == 'text/' )
-// $list[$id]['icon'] = 'text';
- }
-
- $list[$id]['date'] = $o->lastchangeDate;
- $list[$id]['user'] = $o->lastchangeUser;
- }
- }
-
- $this->setTemplateVar('object' ,$list );
- }
-
-
- public function editView()
- {
- global $conf_php;
-
- $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
-
- $list = array();
-
- // Schleife ueber alle Objekte in diesem Ordner
- foreach( $this->folder->getObjects() as $o )
- {
- /* @var $o Object */
- $id = $o->objectid;
-
- if ( $o->hasRight(ACL_READ) )
- {
- $list[$id]['objectid'] = $id;
- $list[$id]['id' ] = 'obj'.$id;
- $list[$id]['name' ] = $o->name;
- $list[$id]['filename'] = $o->filename;
- $list[$id]['desc' ] = $o->desc;
- if ( $list[$id]['desc'] == '' )
- $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
-
- $list[$id]['type'] = $o->getType();
-
- $list[$id]['icon'] = $o->getType();
-
- if ( $o->getType() == 'file' )
- {
- $file = new File( $id );
- $file->load();
- $list[$id]['size'] = $file->size;
- $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
-
- if ( substr($file->mimeType(),0,6) == 'image/' )
- $list[$id]['icon'] = 'image';
-// if ( substr($file->mimeType(),0,5) == 'text/' )
-// $list[$id]['icon'] = 'text';
- }
-
- $list[$id]['url' ] = Html::url($o->getType(),'',$id);
- $list[$id]['date'] = date( lang('DATE_FORMAT'),$o->lastchangeDate );
- $list[$id]['user'] = $o->lastchangeUser;
-
- if ( $this->hasRequestVar("markall") || $this->hasRequestVar('obj'.$id) )
- $this->setTemplateVar('obj'.$id,'1');
- }
- }
-
- if ( $this->folder->hasRight(ACL_WRITE) )
- {
- // Alle anderen Ordner ermitteln
- $otherfolder = array();
- foreach( $this->folder->getAllFolders() as $id )
- {
- $f = new Folder( $id );
- if ( $f->hasRight( ACL_WRITE ) )
- $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
- }
- asort( $otherfolder );
-
- $this->setTemplateVar('folder',$otherfolder);
-
- // URLs zum Umsortieren der Eintraege
- $this->setTemplateVar('order_url' ,Html::url('folder','order',$this->folder->id) );
- }
-
- $actionList = array();
- $actionList[] = 'copy';
- $actionList[] = 'link';
- $actionList[] = 'archive';
-
- if ( $this->folder->hasRight(ACL_WRITE) )
- {
- $actionList[] = 'move';
- $actionList[] = 'delete';
- }
-
- $this->setTemplateVar('actionlist',$actionList );
- $this->setTemplateVar('defaulttype',$this->getRequestVar('type','alpha'));
-
- $this->setTemplateVar('object' ,$list );
- $this->setTemplateVar('act_objectid',$this->folder->id);
-
- $rootFolder = new Folder( Folder::getRootFolderId() );
- $rootFolder->load();
-
- $this->setTemplateVar('properties' ,$this->folder->getProperties() );
- $this->setTemplateVar('rootfolderid' ,$rootFolder->id );
- $this->setTemplateVar('rootfoldername',$rootFolder->name);
- }
-
-
-
-
- public function rootView()
- {
- $rootFolder = new Folder( Folder::getRootFolderId() );
- $rootFolder->load();
-
- $this->setTemplateVar('rootfolderid' ,$rootFolder->id );
- $this->setTemplateVar('rootfoldername',$rootFolder->name);
- }
-
-
-
- /**
- * Reihenfolge bearbeiten.
- */
- public function orderView()
- {
- global $conf_php;
-
- $list = array();
- $last_objectid = 0;
-
- // Schleife ueber alle Objekte in diesem Ordner
- foreach( $this->folder->getObjects() as $o )
- {
- /* @var $o Object */
- $id = $o->objectid;
-
- if ( $o->hasRight(ACL_READ) )
- {
- $list[$id]['id' ] = $id;
- $list[$id]['name'] = Text::maxLength( $o->name ,30);
- $list[$id]['filename'] = Text::maxLength( $o->filename ,20);
- $list[$id]['desc'] = Text::maxLength( $o->desc ,30);
- if ( $list[$id]['desc'] == '' )
- $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
-
- $list[$id]['type'] = $o->getType();
-
- $list[$id]['icon'] = $o->getType();
-
- if ( $o->getType() == 'file' )
- {
- $file = new File( $id );
- $file->load();
- $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
-
- if ( $file->isImage() )
- $list[$id]['icon'] = 'image';
- }
-
- $list[$id]['url' ] = Html::url($o->getType(),'',$id);
- $list[$id]['date'] = $o->lastchangeDate;
- $list[$id]['user'] = $o->lastchangeUser;
-
- if ( $last_objectid != 0 && $o->hasRight(ACL_WRITE) )
- {
- $list[$id ]['upurl' ] = Html::url('folder','changesequence',0,array(
- 'objectid1'=>$id,
- 'objectid2'=>$last_objectid));
- $list[$last_objectid]['downurl' ] = $list[$id]['upurl'];
- $list[$last_objectid]['bottomurl'] = Html::url('folder','setbottom',0,array(
- 'objectid1'=>$last_objectid));
- $list[$id ]['topurl' ] = Html::url('folder','settop',0,array(
- 'objectid1'=>$id));
- }
-
- $last_objectid = $id;
- }
- }
-
- $this->setTemplateVar('flip_url' ,Html::url('folder','reorder',0,array('type'=>'flip' )) );
- $this->setTemplateVar('orderbyname_url' ,Html::url('folder','reorder',0,array('type'=>'name' )) );
- $this->setTemplateVar('orderbytype_url' ,Html::url('folder','reorder',0,array('type'=>'type' )) );
- $this->setTemplateVar('orderbylastchange_url',Html::url('folder','reorder',0,array('type'=>'lastchange')) );
- $this->setTemplateVar('object' ,$list );
- $this->setTemplateVar('act_objectid',$this->folder->id);
- $this->setTemplateVar('token',token() );
- }
-
-
-
- /**
- * Eigenschaften anzeigen.
- */
- public function propView()
- {
- $this->setTemplateVars( $this->folder->getProperties() );
- }
-
- /**
- * Infos anzeigen.
- */
- public function infoView()
- {
- $this->setTemplateVars( $this->folder->getProperties() );
- $this->setTemplateVar( 'full_filename',$this->folder->full_filename() );
- }
-
-
-
- /**
- * 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;
-
- $parents = $this->folder->parentObjectNames(false,true);
-
- foreach( $parents as $id=>$name)
- {
- //Html::debug($name,"Name");
-
- unset($children);
- unset($o);
- $children = array();
- $o = array('id'=>$id,'name'=>$name,'type'=>'folder','level'=>++$nr,'children'=>&$children);
-
- if ( $id == $this->folder->objectid)
- $o['self'] = true;
-
- $tmp[$id] = &$o;;
-
- unset($tmp);
-
- $tmp = &$children;
- }
-
-
- $contents = $this->folder->getObjects();
-
- unset($children);
- unset($o);
-
- $children = array();
- foreach( $contents as $o )
- {
- /* @var $o Object */
- $children[$o->objectid] = array('id'=>$o->objectid,'name'=>$o->name,'type'=>$o->getType());
- }
- $tmp+= $children;
-
- //Html::debug($structure);
-
- $this->setTemplateVar('outline',$structure);
- }
-
-
- public function pubView()
- {
- // Schalter nur anzeigen, wenn sinnvoll
- $this->setTemplateVar('files' ,count($this->folder->getFiles()) > 0 );
- $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 );
- $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 );
-
- //$this->setTemplateVar('clean' ,$this->folder->isRoot );
- // Gefaehrliche Option, da dies bestehende Dateien, die evtl. nicht zum CMS gehören, überschreibt.
- // Daher deaktiviert.
- $this->setTemplateVar('clean' ,false );
- }
-
-
- public function pubPost()
- {
- if ( !$this->folder->hasRight( ACL_PUBLISH ) )
- die('no rights for publish');
-
- $subdirs = ( $this->hasRequestVar('subdirs') );
- $pages = ( $this->hasRequestVar('pages' ) );
- $files = ( $this->hasRequestVar('files' ) );
-
- Session::close();
- $publish = new Publish();
-
- $this->folder->publish = &$publish;
- $this->folder->publish( $pages,$files,$subdirs );
- $this->folder->publish->close();
-
- $list = array();
- foreach( $publish->publishedObjects as $o )
- $list[] = $o['full_filename'];
-
- if ( !$publish->ok )
- $this->addNotice('folder',$this->folder->name,'PUBLISHED_ERROR',OR_NOTICE_ERROR,array(),$publish->log);
- else
- $this->addNotice('folder',$this->folder->name,'PUBLISHED',OR_NOTICE_OK,array(),$list);
-
- // Wenn gewuenscht, das Zielverzeichnis aufraeumen
- if ( $this->hasRequestVar('clean') )
- $publish->clean();
- }
-
-
-
- public function checkMenu( $name )
- {
- switch( $name)
- {
- case 'createfolder':
- return !readonly() && $this->folder->hasRight(ACL_CREATE_FOLDER);
-
- case 'createfile':
- return !readonly() && $this->folder->hasRight(ACL_CREATE_FILE);
-
- case 'createlink':
- return !readonly() && $this->folder->hasRight(ACL_CREATE_LINK);
-
- case 'createpage':
- return !readonly() && $this->folder->hasRight(ACL_CREATE_PAGE);
-
- case 'remove':
- return !readonly() && count($this->folder->getObjectIds()) == 0;
-
- case 'select':
- case 'order':
- case 'aclform':
- return !readonly();
-
- default:
- return true;
- }
- }
-}-
\ No newline at end of file
diff --git a/action/GroupAction.class.php b/action/GroupAction.class.php
@@ -1,321 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Acl;
-use cms\model\User;
-use cms\model\Project;
-use cms\model\Group;
-use cms\model\Object;
-use cms\model\Language;
-
-use \Html;
-// 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 zum Bearbeiten einer Benutzergruppe.
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class GroupAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- private $group;
-
-
- function __construct()
- {
- $this->group = new Group( $this->getRequestId() );
- $this->group->load();
- $this->setTemplateVar( 'groupid',$this->group->groupid );
- }
-
-
-
- function removePost()
- {
- if ( $this->hasRequestVar('confirm') )
- {
- $this->group->delete();
-
- $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN);
- }
- }
-
-
-
- function removeView()
- {
- $this->setTemplateVars( $this->group->getProperties() );
- }
-
-
-
- function editPost()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- $this->group->name = $this->getRequestVar('name');
-
- $this->group->save();
-
- $this->addNotice('group',$this->group->name,'SAVED','ok');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('edit');
- }
- }
-
-
- function adduser()
- {
- $this->setTemplateVar('users',$this->group->getOtherUsers());
- }
-
-
- /**
- * Benutzer zur Gruppe hinzuf�gen.<br>
- * Es kann eine Liste oder eine einzelne Person zur Gruppe hinzugef�gt werden.
- */
- function addusertogroup()
- {
- $userid = $this->getRequestVar('userid');
-
- if ( is_array($userid))
- {
- // Im Request steht eine Liste von User-Ids.
- foreach( $userid as $uid )
- {
- $this->group->addUser( $uid );
- }
- $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OR_NOTICE_OK,array('count'=>count($userid)));
- }
- elseif( intval($userid) > 0 )
- {
- // Nur 1 Benutzer hinzuf�gen.
- $this->group->addUser( intval($userid) );
- $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OK_NOTICE_OK,array('count'=>'1'));
- }
- else
- {
- // Es wurde kein Benutzer ausgew�hlt.
- $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN);
- }
- }
-
-
-
- /**
- * Einen Benutzer aus der Gruppe entfernen.
- */
- function deluser()
- {
- $this->group->delUser( intval($this->getRequestVar('userid')) );
-
- $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK);
- }
-
-
-
- /**
- * Liste aller Gruppen.
- */
- function listingView()
- {
- $list = array();
-
- foreach( Group::getAll() as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['url' ] = Html::url('main','group',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit'));
- $list[$id]['name'] = $name;
- }
-
- $this->setTemplateVar('el', $list);
- }
-
-
- function editView()
- {
- $this->setTemplateVars( $this->group->getProperties() );
- }
-
-
-
-
-
-
- /**
- * Liste aller Benutzer in dieser Gruppe.
- *
- */
- function membershipsView()
- {
- // Mitgliedschaften ermitteln
- //
- $userliste = array();
-
- $allUsers = User::listAll();
-
- $actualGroupUsers = $this->group->getUsers();
-
- foreach( $allUsers as $id=>$name )
- {
- $hasUser = array_key_exists($id,$actualGroupUsers);
- $varName = 'user'.$id;
- $userliste[$id] = array('name' => $name,
- 'id' => $id,
- 'var' => $varName,
- 'member' => $hasUser
- );
- $this->setTemplateVar($varName,$hasUser);
- }
- $this->setTemplateVar('memberships',$userliste);
-
- global $conf;
- if ($conf['security']['authorize']['type']=='ldap')
- $this->addNotice('group',$this->group->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
- }
-
-
- function membershipsPost()
- {
- $allUsers = User::listAll();
- $groupUsers = $this->group->getUsers();
-
- foreach( $allUsers as $id=>$name )
- {
- $hasUser = array_key_exists($id,$groupUsers);
-
- if ( !$hasUser && $this->hasRequestVar('user'.$id) )
- {
- $this->group->addUser($id);
- $this->addNotice('user',$name,'ADDED');
- }
-
- if ( $hasUser && !$this->hasRequestVar('user'.$id) )
- {
- $this->group->delUser($id);
- $this->addNotice('user',$name,'DELETED');
- }
- }
- }
-
-
-
-
-
- /**
- * Anzeigen der Benutzerrechte
- */
- function rightsView()
- {
- $rights = $this->group->getAllAcls();
-
- $projects = array();
-
- foreach( $rights as $acl )
- {
- if ( !isset($projects[$acl->projectid]))
- {
- $projects[$acl->projectid] = array();
- $p = new Project($acl->projectid);
- $p->load();
- $projects[$acl->projectid]['projectname'] = $p->name;
- $projects[$acl->projectid]['rights' ] = array();
- }
-
- $right = array();
-
- if ( $acl->languageid > 0 )
- {
- $language = new Language($acl->languageid);
- $language->load();
- $right['languagename'] = $language->name;
- }
- else
- {
- $right['languagename'] = lang('ALL_LANGUAGES');
- }
-
-
- $o = new Object($acl->objectid);
- $o->objectLoad();
- $right['objectname'] = $o->name;
- $right['objectid' ] = $o->objectid;
- $right['objecttype'] = $o->getType();
-
- if ( $acl->groupid > 0 )
- {
- $group = new Group($acl->groupid);
- $group->load();
- $right['groupname'] = $group->name;
- }
- else
- {
- // Berechtigung f�r "alle".
- }
-
- $right['bits'] = $acl->getProperties();
-
- $projects[$acl->projectid]['rights'][] = $right;
- }
-
- $this->setTemplateVar('projects' ,$projects );
-
- $this->setTemplateVar('show',Acl::getAvailableRights() );
- }
-
-
-
- /**
- * Men�.
- *
- * @param String $menu Men�eintrag.
- * @return boolean TRUE, wenn Men�eintrag aktiv ist.
- */
- function checkMenu( $menu )
- {
- switch( $menu )
- {
- case 'remove':
- case 'add':
- return !readonly();
-
- case 'users':
- return true;
- case 'adduser':
- // Benutzer k�nnen nur hinzugef�gt werden, wenn noch nicht alle
- // in der Gruppe sind.
- return !readonly() && count($this->group->getOtherUsers()) > 0;
- default:
- return true;
- }
- }
-}-
\ No newline at end of file
diff --git a/action/GrouplistAction.class.php b/action/GrouplistAction.class.php
@@ -1,91 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Group;
-// 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 zum Bearbeiten einer Benutzergruppe.
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class GrouplistAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- function __construct()
- {
- }
-
-
- /**
- * Liste aller Gruppen.
- */
- function showView()
- {
- $list = array();
-
- foreach( Group::getAll() as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['id' ] = $id;
- $list[$id]['name'] = $name;
- }
-
- $this->setTemplateVar('el', $list);
- }
-
-
- function editView()
- {
- $this->nextSubAction('show');
- }
-
-
-
- function addView()
- {
- }
-
-
- function addPost()
- {
- if ( $this->getRequestVar('name') != '')
- {
- $this->group = new Group();
- $this->group->name = $this->getRequestVar('name');
- $this->group->add();
- $this->addNotice('group',$this->group->name,'ADDED','ok');
- $this->callSubAction('listing');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- }
- }
-
-
-
-
-}-
\ No newline at end of file
diff --git a/action/IndexAction.class.php b/action/IndexAction.class.php
@@ -1,393 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use \Auth;
-use cms\model\User;
-use Exception;
-use JSqueeze;
-use Less_Parser;
-use Logger;
-use ObjectNotFoundException;
-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; version 2.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-/**
- * Action-Klasse fuer die Anzeige der Hauptseite.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class IndexAction extends Action
-{
- public $security = SECURITY_GUEST;
-
-
- private $perspective;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->perspective = Session::get('perspective');
-
- if ( !empty($this->perspective))
- $this->lastModified( config('config','last_modification_time') );
- }
-
-
- public function showView()
- {
- global $conf;
-
- // Schauen, ob eine Perspektive existiert.
- if ( empty($this->perspective) )
- {
- // Da keine Perspektive existiert, handelt es sich wohl um den
- // ersten Aufruf in dieser Sitzung.
-
- // Versuchen, einen Benutzernamen zu ermitteln, der im Eingabeformular vorausgewählt wird.
- $modules = explode(',',$conf['security']['modules']['autologin']);
-
- $username = '';
- foreach( $modules as $module)
- {
- Logger::debug('Auto-Login module: '.$module);
- $moduleClass = $module.'Auth';
- $auth = new $moduleClass;
- $username = $auth->username();
-
- if ( !empty($username) )
- {
- Logger::debug('Auto-Login for User '.$username);
- break; // Benutzername gefunden.
- }
- }
-
- if ( !empty( $username ) )
- {
- try
- {
- $user = User::loadWithName( $username );
- Session::setUser($user);
- Logger::info('auto-login for user '.$username);
- $this->setPerspective('start');
- }
- catch( ObjectNotFoundException $e )
- {
- Logger::warn('Username for autologin does not exist: '.$username);
- $this->setPerspective('login');
- }
- }
- else
- {
- // Kein Auto-Login moeglich, die Anmeldemaske anzeigen.
- $this->setPerspective('login');
- }
- }
-
- // Theme für den angemeldeten Benuter ermitteln, dieser wird für
- // den Link auf die CSS-Datei benoetigt.
- $user = Session::getUser();
- if ( is_object($user) )
- $style = $user->style;
- else
- $style = config('interface','style','default');
-
- $jsFiles = $this->getJSFiles();
- $cssFiles = $this->getCSSFiles();
- $themeCss = $this->getThemeCSS();
-
- // HTML-Datei direkt einbinden.
- require('themes/default/layout/index.php');
- exit;
- }
-
-
- private function getCSSFiles()
- {
- $productionCSSFile = OR_THEMES_DIR . 'default/production/combined.min.css';
-
- if (PRODUCTION)
- {
- return array(
- $productionCSSFile
- );
- }
-
- $outFiles = array();
-
- $css = array();
- $css[] = OR_THEMES_EXT_DIR . 'default/css/openrat-ui';
- $css[] = OR_THEMES_EXT_DIR . 'default/css/openrat-workbench';
-
- // Komponentenbasiertes CSS
- $elements = parse_ini_file(OR_THEMES_DIR . config('interface', 'theme') . '/include/elements.ini.' . PHP_EXT);
-
- foreach (array_keys($elements) as $c)
- {
- $componentCssFile = OR_MODULES_DIR . 'template-engine/components/html/' . $c . '/' . $c;
- if (is_file($componentCssFile . '.less'))
- $css[] = $componentCssFile;
- }
-
- $modified = false;
- foreach ($css as $cssF)
- {
- $lessFile = $cssF . '.less';
- $cssFile = $cssF . '.css';
- $cssMinFile = $cssF . '.min.css';
-
- if (! is_file($lessFile))
- {
- Logger::warn("Stylesheet not found: $lessFile");
- continue;
- }
- elseif (! is_file($cssFile) || ! is_writable($cssFile))
- {
- Logger::warn("Stylesheet output file not found or not writable: $cssFile");
- continue;
- }
- elseif (! is_file($cssMinFile) || ! is_writable($cssMinFile))
- {
- Logger::warn("Stylesheet output file not found or not writable: $cssMinFile");
- continue;
- }
- else
- {
- if (filemtime($lessFile) > filemtime($cssMinFile))
- {
- // LESS-Source wurde geändert, CSS-Version muss aktualisiert werden.
- $modified = true;
-
- // Den absoluten Pfad zur LESS-Datei ermitteln. Dieser wird vom LESS-Parser für den korrekten Link
- // auf die LESS-Datei in der Sourcemap benötigt.
- $pfx = substr(realpath($lessFile),0,0-strlen(basename($lessFile)));
-
- $parser = new Less_Parser(array(
- 'sourceMap' => true,
- 'indentation' => ' ',
- 'outputSourceFiles' => false,
- 'sourceMapBasepath' => $pfx
- ));
-
-
- $parser->parseFile( ltrim($lessFile,'./') );
- $source = $parser->getCss();
-
- file_put_contents($cssFile, $source);
-
- $parser = new Less_Parser(array(
- 'compress' => true,
- 'sourceMap' => false,
- 'indentation' => ''
- ));
- $parser->parseFile($lessFile);
- $source = $parser->getCss();
-
-
- file_put_contents($cssMinFile, $source);
- }
-
- $outFiles[] = $cssFile;
- }
- }
-
- if ($modified)
- {
- if ( !is_writable($productionCSSFile))
- {
- Logger::warn('not writable: '.$productionCSSFile);
- }
- else
- {
- file_put_contents($productionCSSFile,'');
- foreach ($css as $cssF)
- {
- $cssMinFile = $cssF . '.min.css';
- if ( is_file($cssMinFile))
- file_put_contents($productionCSSFile,file_get_contents($cssMinFile),FILE_APPEND);
- }
- }
- }
-
- return $outFiles;
- }
-
-
-
- private function getThemeCSS()
- {
- // Je Theme die Theme-CSS-Datei ausgeben.
- $lessFile = OR_THEMES_EXT_DIR . 'default/css/openrat-theme.less';
- $css = '';
-
-
- foreach (array_keys(config('style')) as $styleId)
- {
- try
- {
- $parser = new Less_Parser(array(
- 'sourceMap' => DEVELOPMENT,
- 'indentation' => ' ',
- 'outputSourceFiles' => false
- ));
- $parser->parseFile($lessFile,basename($lessFile));
-
- $styleConfig = config('style-default') + config('style', $styleId);
- $lessVars = array(
- 'cms-theme-id' => strtolower($styleId),
- 'cms-image-path' => 'themes/default/images/'
- );
-
- foreach ($styleConfig as $styleSetting => $value)
- $lessVars['cms-' . strtolower(strtr($styleSetting, '_', '-'))] = $value;
- $parser->modifyVars($lessVars);
- $css .= $parser->getCss();
- }
- catch (Exception $e)
- {
- $css .= "\n\n/* WARNING!\n LESS Parser failed on file '$lessFile'. Reason: " . $e->__toString() . " */\n\n";
- }
- }
-
- if (PRODUCTION)
- {
- return $css; // Should we minify here? Bandwidth vs. cpu-load.
- }
- else
- {
- return $css;
- }
- }
-
-
-
- private function getJSFiles()
- {
- $productionJSFile = OR_THEMES_DIR . 'default/production/combined.min.js';
-
- if (PRODUCTION)
- {
- return array(
- $productionJSFile
- );
- }
- else
- {
- $js = array();
- $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-1.12.4';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-ui/js/jquery-ui-1.8.16.custom';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery.scrollTo';
- // $js[] = OR_THEMES_EXT_DIR default/js/jquery.mjs.nestedSortable.js"></script>
-
- // Jquery-Plugins
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orHint';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orSearch';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orLinkify';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orTree';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orLoadView';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orAutoheight';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-svg';
- $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-qrcode';
- // OpenRat internal JS
- $js[] = OR_THEMES_EXT_DIR . 'default/js/openrat';
- $js[] = OR_THEMES_EXT_DIR . '../editor/markitup/markitup/jquery.markitup';
- $js[] = OR_THEMES_EXT_DIR . '../editor/editor/ckeditor';
- $js[] = OR_THEMES_EXT_DIR . '../editor/ace/src-min-noconflict/ace';
- $js[] = OR_THEMES_EXT_DIR . '../editor/editor/adapters/jquery';
-
- // Komponentenbasiertes Javascript
- $elements = parse_ini_file(OR_THEMES_DIR . config('interface', 'theme') . '/include/elements.ini.' . PHP_EXT);
-
- foreach (array_keys($elements) as $c)
- {
- $componentJsFile = OR_MODULES_DIR . '/template-engine/components/html/' . $c . '/' . $c;
- if (is_file($componentJsFile . '.js'))
- $js[] = $componentJsFile;
- }
-
- $outDevJsFiles = array();
- $outProJsFiles = array();
- $lastModTime = 0;
-
- foreach ($js as $jsFile)
- {
- $jsFileMin = $jsFile . '.min.js';
- $jsFileNormal = $jsFile . '.js';
-
- if (!is_file($jsFileNormal) && !is_file($jsFileMin))
- {
- Logger::warn("No Javascript file found for $jsFile");
- continue;
- }
- elseif (is_file($jsFileNormal) && !is_file($jsFileMin))
- {
- Logger::warn("No Min-Javascript file found for $jsFile");
- continue;
- }
- elseif (!is_file($jsFileNormal) && is_file($jsFileMin))
- {
- // Nur eine Min-Version existiert. Das ist ok.
- $outDevJsFiles[] = $jsFileMin;
- $outProJsFiles[] = $jsFileMin;
- $modTime = filemtime($jsFileMin);
- }
- else
- {
- if ( filemtime($jsFileNormal) > filemtime($jsFileMin) )
- {
- if ( is_writable( $jsFileMin))
- $jz = new JSqueeze();
- file_put_contents( $jsFileMin, $jz->squeeze(file_get_contents($jsFileNormal)));
- $modTime = time();
- }
- else
- {
- $modTime = filemtime($jsFileMin);
- }
- $outDevJsFiles[] = $jsFileNormal;
- $outProJsFiles[] = $jsFileMin;
- }
- $lastModTime = max($lastModTime, $modTime);
- }
-
- if ($lastModTime > filemtime($productionJSFile))
- {
- if (! is_writable($productionJSFile))
- {
- Logger::warn("Not writable: " . $productionJSFile);
- }
- else
- {
- file_put_contents($productionJSFile, '');
- foreach ($outProJsFiles as $srcFile)
- file_put_contents($productionJSFile, file_get_contents($srcFile), FILE_APPEND);
- }
- }
- }
-
- return $outDevJsFiles;
- }
-
-
-
-}
-?>-
\ No newline at end of file
diff --git a/action/LanguageAction.class.php b/action/LanguageAction.class.php
@@ -1,275 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Language;
-use Session;
-use \Html;
-// 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 die Bearbeitung einer Sprache
- * @version $Id$
- * @author $Author$
- * @package openrat.actions
- */
-class LanguageAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $defaultSubAction = 'listing';
-
- /**
- * Zu bearbeitende Sprache, wird im Kontruktor instanziiert
- * @type Language
- */
- var $language;
- var $project;
-
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->language = new Language( $this->getRequestId() );
- $this->language->load();
-
- $this->project = Session::getProject();
- }
-
-
- /**
- * Setzen der Sprache als Standardsprache.
- * Diese Sprache wird benutzt beim Ausw?hlen des Projektes sowie
- * als Default-Sprache bei mehrsprachigen Webseiten ("content-negotiation")
- */
- function setdefaultPost()
- {
- $this->language->setDefault();
- }
-
-
-
- /**
- * Anzeigen der L�schbest�tigungs-Maske.
- */
- function removeView()
- {
- $this->setTemplateVar('name' ,$this->language->name );
- }
-
-
- /**
- * L�schen der Sprache.
- */
- function removePost()
- {
- if ( $this->getRequestVar('confirm') == '1' )
- $this->language->delete();
- }
-
-
- function propView()
- {
- $this->nextSubAction('advanced');
- }
-
- /**
- * Speichern der Sprache
- */
- function advancedPost()
- {
- global $conf;
-
- if ( $this->hasRequestVar('name') )
- {
- $this->language->name = $this->getRequestVar('name' );
- $this->language->isoCode = $this->getRequestVar('isocode');
- }
- else
- {
- $countryList = $conf['countries'];
- $iso = $this->getRequestVar('isocode');
- $this->language->name = $countryList[$iso];
- $this->language->isoCode = strtolower( $iso );
- }
-
- $this->language->save();
- }
-
-
-
- /**
- * Speichern der Sprache
- */
- function editPost()
- {
- global $conf;
-
- if ( $this->hasRequestVar('name') )
- {
- $this->language->name = $this->getRequestVar('name' );
- $this->language->isoCode = $this->getRequestVar('isocode');
- }
- else
- {
- $countryList = $conf['countries'];
- $iso = $this->getRequestVar('isocode');
- $this->language->name = $countryList[$iso];
- $this->language->isoCode = strtolower( $iso );
- }
-
- $this->language->save();
- }
-
-
-
- function listingView()
- {
- global $conf;
- $countryList = $conf['countries'];
-
- $list = array();
-
- $actLanguage = Session::getProjectLanguage();
- $this->setTemplateVar('act_languageid',$actLanguage->languageid);
-
- foreach( $this->project->getLanguageIds() as $id )
- {
- $l = new Language( $id );
- $l->load();
-
- unset( $countryList[strtoupper($l->isoCode)] );
-
- $list[$id] = array();
- $list[$id]['name' ] = $l->name;
- $list[$id]['isocode'] = $l->isoCode;
-
- if ( $this->userIsAdmin() )
- {
- $list[$id]['url' ] = Html::url('language','edit',$id,
- array() );
-
- if ( ! $l->isDefault )
- $list[$id]['default_url'] = Html::url( 'language','setdefault',$id );
- }
-
- if ( $actLanguage->languageid != $l->languageid )
- $list[$id]['select_url'] = Html::url( 'index','language',$id );
- }
-
-// if ( $this->userIsAdmin() )
-// {
-// asort($countryList);
-// $this->setTemplateVar('isocodes',$countryList);
-// }
-
- $this->setTemplateVar('el',$list);
- }
-
-
-
- function editView()
- {
- global $conf;
- $countryList = $conf['countries'];
-
- foreach( $this->project->getLanguageIds() as $id )
- {
- if ( $id == $this->language->languageid )
- continue;
-
- $l = new Language( $id );
- $l->load();
-
- unset( $countryList[$l->isoCode] );
- }
-
- asort( $countryList );
- $this->setTemplateVar('isocodes' ,$countryList );
- $this->setTemplateVar('isocode' ,strtoupper($this->language->isoCode) );
- }
-
-
-
- function advancedView()
- {
- $this->setTemplateVar('isocode',$this->language->isoCode);
- $this->setTemplateVar('name' ,$this->language->name );
- }
-
-
-
-
-
- function checkmenu( $menu )
- {
- switch( $menu )
- {
- case 'remove':
- $actLanguage = Session::getProjectLanguage();
- return
- !readonly() &&
- $this->userIsAdmin() &&
- isset($this->language) &&
- count( $this->language->getAll() ) >= 2 &&
- $actLanguage->languageid != $this->language->languageid;
-
- case 'add':
- return
- !readonly() && $this->userIsAdmin();
-
- default:
- return true;
- }
- }
-
-
- /**
- * 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();
- $languagelistChildren = array();
-
- $structure[0] = array('id'=>'0','name'=>lang('LANGUAGES'),'type'=>'languagelist','level'=>1,'children'=>&$languagelistChildren);
-
- $languagelistChildren[ $this->language->languageid ] = array('id'=>$this->language->languageid,'name'=>$this->language->name,'type'=>'language','self'=>true);
-
-
- //Html::debug($structure);
-
- $this->setTemplateVar('outline',$structure);
- }
-}-
\ No newline at end of file
diff --git a/action/LanguagelistAction.class.php b/action/LanguagelistAction.class.php
@@ -1,148 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Language;
-
-
-
-use Session;
-use \Html;
-
-// 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 die Bearbeitung einer Sprache
- * @version $Id$
- * @author $Author$
- * @package openrat.actions
- */
-class LanguagelistAction extends Action
-{
- public $security = SECURITY_USER;
-
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->project = Session::getProject();
- }
-
-
-
- function showView()
- {
- global $conf;
- $countryList = $conf['countries'];
-
- $list = array();
-
- $actLanguage = Session::getProjectLanguage();
- $this->setTemplateVar('act_languageid',$actLanguage->languageid);
-
- foreach( $this->project->getLanguageIds() as $id )
- {
- $l = new Language( $id );
- $l->load();
-
- unset( $countryList[strtoupper($l->isoCode)] );
-
- $list[$id] = array();
- $list[$id]['name' ] = $l->name;
- $list[$id]['isocode'] = $l->isoCode;
-
- if ( $this->userIsAdmin() )
- {
- $list[$id]['id' ] = $id;
-
- if ( ! $l->isDefault )
- $list[$id]['default_url'] = Html::url( 'language','setdefault',$id );
- }
-
- if ( $actLanguage->languageid != $l->languageid )
- $list[$id]['select_url'] = Html::url( 'index','language',$id );
- }
-
-// if ( $this->userIsAdmin() )
-// {
-// asort($countryList);
-// $this->setTemplateVar('isocodes',$countryList);
-// }
-
- $this->setTemplateVar('el',$list);
- }
-
-
-
- function editView()
- {
- $this->nextSubAction('show');
- }
-
-
-
-
- /**
- * Sprache hinzufuegen
- */
- function addView()
- {
- global $conf;
- $countryList = $conf['countries'];
-
- $language = Session::getProjectLanguage();
-
- foreach( $this->project->getLanguageIds() as $id )
- {
-
- if ( $id == $language->languageid )
- continue;
-
- $l = new Language( $id );
- $l->load();
-
- unset( $countryList[$l->isoCode] );
- }
-
- asort( $countryList );
- $this->setTemplateVar('isocodes' ,$countryList );
- $this->setTemplateVar('isocode' ,'' );
- }
-
-
- function addPost()
- {
- global $conf;
- $countryList = $conf['countries'];
-
- // Hinzufuegen einer Sprache
- $iso = $this->getRequestVar('isocode');
- $language = new Language();
- $language->projectid = $this->project->projectid;
- $language->isoCode = $iso;
- $language->name = $countryList[$iso];
- $language->add();
-
- $this->addNotice('language',$language->name,'ADDED','ok');
- }
-
-
-}-
\ No newline at end of file
diff --git a/action/LinkAction.class.php b/action/LinkAction.class.php
@@ -1,191 +0,0 @@
-<?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 LinkAction extends ObjectAction
-{
- public $security = SECURITY_USER;
-
- private $link;
-
- /**
- * 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()
- {
- $this->link->linkedObjectId = $this->getRequestVar('targetobjectid');
-
- $this->link->save();
- $this->link->setTimestamp();
- Session::setObject( $this->link );
-
- $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
- 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 );
- }
-
-
-
- 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/action/LoginAction.class.php b/action/LoginAction.class.php
@@ -1,2187 +0,0 @@
-<?php
-
-namespace cms\action;
-
-
-use cms\model\User;
-use cms\model\Project;
-use cms\model\Group;
-use cms\model\Value;
-use cms\model\Element;
-use cms\model\Page;
-use cms\model\Object;
-use cms\model\Language;
-use cms\model\Model;
-
-
-use \database\Database;
-use \DB;
-use \DbUpdate;
-use \Exception;
-use \Http;
-use \InternalAuth;
-use \Logger;
-use \ObjectNotFoundException;
-use \OpenRatException;
-use \security\Password;
-use \Session;
-use \Html;
-use \Mail;
-use \Text;
-
-
-// OpenRat Content Management System
-// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; version 2.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
-define('PROJECTID_ADMIN',-1);
-
-/**
- * Action-Klasse fuer die Start-Action
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class LoginAction extends Action
-{
- public $security = SECURITY_GUEST;
-
-
- /**
- * Eine Datenbankverbindugn wird aufgebaut und initalisiert.
- *
- * @param $dbid Datenbank-Id
- * @throws OpenRatException
- */
- private function setDb( $dbid )
- {
- global $conf;
-
- if ( !isset($conf['database'][$dbid] ))
- Http::serverError( 'unknown DB-Id: '.$dbid );
-
- $db = db_connection();
- if ( is_object($db) )
- $db->rollback();
-
- try
- {
- $db = new Database( $conf['database'][$dbid] );
- $db->id = $dbid;
- $db->start(); // Transaktion starten.
- Session::setDatabase( $db );
- }catch(\Exception $e)
- {
- throw new OpenRatException('DATABASE_ERROR_CONNECTION',$e->getMessage() );
- }
- }
-
-
- /**
- * Prueft, ob der Parameter 'dbid' übergeben wurde.
- * @throws OpenRatException
- */
- function checkForDb()
- {
- global $conf;
- $dbid = $this->getRequestVar('dbid');
-
- if ( $dbid != '' )
- $this->setDb( $dbid );
- }
-
-
- /**
- * @throws OpenRatException
- */
- function setDefaultDb()
- {
- if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) )
- {
- $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID);
- }
- else
- {
- global $conf;
-
- if ( !isset($conf['database']['default']) )
- Http::serverError('default-database not set');
-
- $dbid = $conf['database']['default'];
- }
-
- $this->setDb( $dbid );
- }
-
-
- /**
- * Führt ein Login durch.
- * @param $name string Benutzername
- * @param $pw string Password
- * @param $pw1 string new Password
- * @param $pw2 string new Password repeated
- * @return bool
- * @throws ObjectNotFoundException
- */
- private function checkLogin($name, $pw, $pw1, $pw2 )
- {
- Logger::debug( "Login user: '$name'.'" );
-
- global $conf;
- global $SESS;
-
- unset( $SESS['user'] );
-
-
- $db = db_connection();
-
- if ( !is_object($db) )
- {
- $this->addNotice('database','','DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('no connection'));
- //$this->callSubAction('showlogin');
- return false;
- }
-
- if ( !$db->available )
- {
- $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error));
- //$this->callSubAction('showlogin');
- return false;
- }
-
- $ip = getenv("REMOTE_ADDR");
-
- $user = new User();
- $user->name = $name;
-
- $ok = $user->checkPassword( $pw );
-
- $mustChangePassword = $user->mustChangePassword;
-
- if ( $mustChangePassword )
- {
- // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
- // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
- if ( empty($pw1) )
- {
- }
- elseif ( $pw1 != $pw2 )
- {
- $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
- $this->addValidationError('password2','');
- }
- elseif ( strlen($pw2) < $conf['security']['password']['min_length'] )
- {
- $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
- $this->addValidationError('password2','');
- }
- else
- {
- // Kennw?rter identisch und lang genug.
- $user->setPassword( $pw1,true );
-
- // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen.
- $ok = true;
- $mustChangePassword = false;
-
- $pw = $pw1;
- }
- }
-
- // Falls Login erfolgreich
- if ( $ok )
- {
- // Login war erfolgreich!
- $user->load();
- $user->setCurrent();
-
- if ($user->passwordAlgo != Password::bestAlgoAvailable() )
- // Re-Hash the password with a better hash algo.
- $user->setPassword($pw);
-
-
- Logger::info( "login successful for {$user->name} from IP $ip" );
-
- return true;
- }
- else
- {
- Logger::info( "login failed for user {$user->name} from IP $ip" );
-
- return false;
- }
- }
-
-
- /**
- * Anzeigen der Loginmaske.
- *
- * Es wird nur die Loginmaske angezeigt.
- * @throws OpenRatException
- */
- function loginView()
- {
- // Hier nie "304 not modified" setzen, da sonst keine
- // Login-Fehlermeldung erscheinen kann.
- global $conf;
-
- $sso = $conf['security']['sso'];
- $ssl = $conf['security']['ssl'];
-
- $ssl_trust = false;
- $ssl_user_var = '';
- extract( $ssl, EXTR_PREFIX_ALL, 'ssl' );
-
- if ( $sso['enable'] )
- {
- $authid = $this->getRequestVar( $sso['auth_param_name']);
-
- if ( empty( $authid) )
- Http::notAuthorized( 'no authorization data (no auth-id)');
-
- if ( $sso['auth_param_serialized'] )
- $authid = unserialize( $authid );
-
- $purl = parse_url($sso['url']);
- // Verbindung zu URL herstellen.
- $errno=0; $errstr='';
- $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30);
- if ( !$fp )
- {
- echo "Connection failed: $errstr ($errno)";
- }
- else
- {
- $http_get = $purl['path'];
- if ( !empty($purl['query']) )
- $http_get .= '?'.$purl['query'];
-
- $header = array();
-
- $header[] = "GET $http_get HTTP/1.0";
- $header[] ="Host: ".$purl['host'];
- $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)";
- $header[] = "Connection: Close";
-
- if ( $sso['cookie'] )
- {
- $cookie = 'Cookie: ';
- if ( is_array($authid))
- foreach( $authid as $cookiename=>$cookievalue)
- $cookie .= $cookiename.'='.$cookievalue."; ";
- else
- $cookie .= $sso['cookie_name'].'='.$authid;
-
- $header[] = $cookie;
- }
-
-// Html::debug($header);
- fputs ($fp, implode("\r\n",$header)."\r\n\r\n");
-
- $inhalt=array();
- while (!feof($fp)) {
- $inhalt[] = fgets($fp,128);
- }
- fclose($fp);
-
- $html = implode('',$inhalt);
-// Html::debug($html);
- if ( !preg_match($sso['expect_regexp'],$html) )
- Http::notAuthorized('auth failed');
- $treffer=0;
- if ( !preg_match($sso['username_regexp'],$html,$treffer) )
- Http::notAuthorized('auth failed');
- if ( !isset($treffer[1]) )
- Http::notAuthorized('authorization failed');
-
- $username = $treffer[1];
-
-// Html::debug( $treffer );
- $this->setDefaultDb();
-
- $user = User::loadWithName( $username );
-
- if ( ! $user->isValid( ))
- Http::notAuthorized('authorization failed: user not found: '.$username);
-
- $user->setCurrent();
-
- $this->callSubAction('show');
- }
- }
-
- elseif ( $ssl_trust )
- {
- if ( empty($ssl_user_var) )
- Http::serverError( 'please set environment variable name in ssl-configuration.' );
-
- $username = getenv( $ssl_user_var );
-
- if ( empty($username) )
- Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' );
-
- $this->setDefaultDb();
-
- $user = User::loadWithName( $username );
-
- if ( !$user->isValid() )
- Http::serverError( 'unknown username: '.$username );
-
- $user->setCurrent();
-
- $this->callSubAction('show');
- }
-
- foreach( $conf['database'] as $dbid => $dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbid] = array('key' => $dbid,
- 'value' => empty($dbconf['name'])?$dbid:Text::maxLength($dbconf['name']),
- 'title' => @$dbconf['description'] );
- }
-
-
- if ( empty($dbids) )
- $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
-
- if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) )
- $this->setTemplateVar('login_name',$_COOKIE['or_username']);
-
- if ( !isset($this->templateVars['login_name']) )
- $this->setTemplateVar('login_name',@$conf['security']['default']['username']);
-
- if ( @$this->templateVars['login_name']== @$conf['security']['default']['username'])
- $this->setTemplateVar('login_password',@$conf['security']['default']['password']);
-
- $this->setTemplateVar( 'dbids',$dbids );
-
- $db = Session::getDatabase();
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- elseif( isset($this->templateVars['actid']) )
- ;
- elseif ( isset($_COOKIE['or_dbid']) && isset($dbids[$_COOKIE['or_dbid']]) )
- // DB-Id aus dem Cookie lesen.
- $this->setTemplateVar('actdbid',$_COOKIE['or_dbid'] );
- else
- $this->setTemplateVar('actdbid',$conf['login']['default-database']);
-
-
- // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen.
- $ssl_user_var = $conf['security']['ssl']['client_cert_dn_env'];
- if ( !empty($ssl_user_var) )
- {
- $username = getenv( $ssl_user_var );
-
- if ( empty($username) )
- {
- // Nothing to do.
- // if user has no valid client cert he could not access this form.
- }
- else {
-
- // Benutzername ist in Eingabemaske unver�nderlich
- $this->setTemplateVar('force_username',$username);
- }
-
- }
-
- $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
-
- $this->setTemplateVar('register' ,$conf['login' ]['register' ]);
- $this->setTemplateVar('send_password',$conf['login' ]['send_password']);
-
- // Versuchen, einen Benutzernamen zu ermitteln, der im Eingabeformular vorausgewählt wird.
- $modules = explode(',',$conf['security']['modules']['preselect']);
-
- $username = '';
- foreach( $modules as $module)
- {
- Logger::debug('Preselecting module: '.$module);
- $moduleClass = $module.'Auth';
- /** @var \Auth $auth */
- $auth = new $moduleClass;
- $username = $auth->username();
-
- if ( !empty($username) )
- {
- Logger::debug('Preselecting User '.$username);
- break; // Benutzername gefunden.
- }
- }
-
- $this->setTemplateVar('login_name',$username);
- }
-
-
-
- /**
- * Anzeigen der Loginmaske.
- *
- * Es wird nur die Loginmaske angezeigt.
- * Hier nie "304 not modified" setzen, da sonst keine
- * Login-Fehlermeldung erscheinen kann
- */
- function openidView()
- {
- global $conf;
-
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbname] = array('key' =>$dbname,
- 'value'=>Text::maxLength($dbconf['description']),
- 'title'=>$dbconf['description'].(isset($dbconf['host'])?' ('.$dbconf['host'].')':'') );
- }
-
- $openid_provider = array();
- foreach( explode(',',$conf['security']['openid']['provider']['name']) as $provider )
- $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name');
- $this->setTemplateVar('openid_providers',$openid_provider);
- $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity'));
- //$this->setTemplateVar('openid_provider','identity');
-
-
- if ( empty($dbids) )
- $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
-
- if ( !isset($_COOKIE['or_username']) )
- $this->setTemplateVar('login_name',$_COOKIE['or_username']);
- else
- $this->setTemplateVar('login_name',$conf['security']['default']['username']);
-
- $this->setTemplateVar( 'dbids',$dbids );
-
- $db = Session::getDatabase();
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- else
- $this->setTemplateVar('actdbid',$conf['database']['default']);
-
- $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
-
- }
-
-
-
- /**
- * Erzeugt ein Projekt-Auswahlmenue.
- */
- function projectmenu()
- {
- $user = Session::getUser();
-
- if ( $user->mustChangePassword )
- {
- $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
- $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu ?ndern.
- }
-
-
- // Diese Seite gilt pro Sitzung.
- $this->lastModified( $user->loginDate );
-
- // Projekte ermitteln
- $projects = $user->projects;
-
- $list = array();
-
- foreach( $projects as $id=>$name )
- {
- $p = array();
- $p['url' ] = Html::url('index','project',$id);
- $p['name'] = $name;
- $p['id' ] = $id;
-
- $tmpProject = new Project( $id );
- $p['defaultmodelid' ] = $tmpProject->getDefaultModelId();
- $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId();
- $p['models' ] = $tmpProject->getModels();
- $p['languages' ] = $tmpProject->getLanguages();
-
- $list[] = $p;
- }
-
- $this->setTemplateVar('projects',$list);
-
- if ( empty($list) )
- {
- // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben.
- if ( $this->userIsAdmin() )
- // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen
- $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
- else
- // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf?gung steht
- $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
- }
-
- $this->metaValues();
- }
-
-
-
- /**
- * Erzeugt eine Anwendungsliste.
- */
- function applications()
- {
- global $conf;
-
- // Diese Seite gilt pro Sitzung.
- $user = Session::getUser();
- $userGroups = $user->getGroups();
- $this->lastModified( $user->loginDate );
-
- // Applikationen ermitteln
- $list = array();
- foreach( $conf['applications'] as $id=>$app )
- {
- if ( !is_array($app) )
- continue;
-
- if ( isset($app['group']) )
- if ( !in_array($app['group'],$userGroups) )
- continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden.
-
- $p = array();
- $p['url'] = $app['url'];
- $p['description'] = @$app['description'];
- if ( isset($app['param']) )
- {
- $p['url'] .= strpos($p['url'],'?')!==false?'&':'?';
- $p['url'] .= $app['param'].'='.session_id();
- }
- $p['name'] = $app['name'];
-
- $list[] = $p;
- }
-
-
- $this->metaValues();
- $this->setTemplateVar('applications',$list);
- }
-
-
-
- /**
- * Ermittelt Meta-Angaben f?r den HTML-Kopf.<br>
- * Falls der Browser die Meta-Angaben entsprechend auswertet, k?nnen ?ber feste Browser-Men?s
- die Projekt direkt ausgew?hlt werden.
- */
- function metaValues()
- {
- global $conf;
- $metaList = array();
-
- $user = Session::getUser();
- if ( is_object($user) )
- {
- // Projekte ermitteln
- $projects = $user->projects;
- foreach( $projects as $id=>$name )
- {
- $metaList[] = array('name' => 'chapter',
- 'url' => Html::url('index','project',$id),
- 'title'=> $name );
- }
-
- if ( $this->userIsAdmin() )
- {
- $metaList[] = array('name' => 'appendix',
- 'url' => Html::url('index','projectmenu',0 ),
- 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) );
-
- $metaList[] = array('name' => 'chapter',
- 'url' => Html::url('index','administration',0),
- 'title'=> lang('administration') );
- }
-
- // Applikationen ermitteln
- foreach( $conf['applications'] as $id=>$app )
- {
- if ( !is_array($app) )
- continue;
- $appUrl = $app['url'];
- if ( isset($app['param']) )
- {
- $appUrl .= strpos($appUrl,'?')!==false?'&':'?';
- $appUrl .= $app['param'].'='.session_id();
- }
-
- $metaList[] = array('name' => 'bookmark',
- 'url' => $appUrl ,
- 'title'=> $app['name'] );
- }
- }
-
- $project = Session::getProject();
- if ( is_object($project) && $project->projectid > 0 )
- {
- $languages =$project->getLanguages();
-
- foreach( $project->getModels() as $modelid=>$modelname )
- {
- foreach( $languages as $languageid=>$languagename )
- {
-
- $metaList[] = array('name' => 'subsection',
- 'url' => Html::url('index',
- 'project',
- $project->projectid,
- array('languageid'=>$languageid,
- 'modelid' =>$modelid) ),
- 'title'=> $modelname.' - '.$languagename
- );
- }
- }
- }
-
- $metaList[] = array('name' => 'author',
- 'url' => $conf['login']['logo']['url'],
- 'title'=> $conf['login']['logo']['url'] );
-
- $metaList[] = array('name' => 'top',
- 'url' => Html::url('index','logout',0 ),
- 'title'=> 'Start' );
-
- $metaList[] = array('name' => 'contents',
- 'url' => Html::url('index','projectmenu',0 ),
- 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) );
-
-
- $this->setTemplateVar('metaList',$metaList);
- }
-
-
-
- /**
- * Open-Id Login, ?berpr?fen der Anmeldung.<br>
- * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
- * Kapitel "4.4. check_authentication"<br>
- * <br>
- * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur?ck.<br>
- * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
- * <br>
- * Es muss noch beim OpenId-Provider die Best?tigung eingeholt werden, danach ist der
- * Benutzer angemeldet.<br>
- */
- public function openidloginView()
- {
- global $conf;
- $openId = Session::get('openid');
-
- if ( !$openId->checkAuthentication() )
- {
- Http::notAuthorized('OpenId-Login failed' );
- die();
- $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- //Html::debug($openId);
-
- // Anmeldung wurde mit "is_valid:true" best?tigt.
- // Der Benutzer ist jetzt eingeloggt.
- $username = $openId->getUserFromIdentiy();
-
- Logger::debug("OpenId-Login successful for $username");
-
- if ( empty($username) )
- {
- // Es konnte kein Benutzername ermittelt werden.
- Http::notAuthorized('no username supplied by openid provider' );
- die();
- $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- $user = User::loadWithName( $username );
-
- if ( $user->userid <=0)
- {
- // Benutzer ist (noch) nicht vorhanden.
- if ( $conf['security']['openid']['add']) // Anlegen?
- {
- $user->name = $username;
- $user->add();
-
- $user->mail = @$openId->info['email'];
- $user->fullname = @$openId->info['fullname'];
- $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht)
- }
- else
- {
- Logger::debug("OpenId-Login failed for $username");
- // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht).
- Http::notAuthorized('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
- die();
-
- $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
- $this->addValidationError('openid_url','');
- return;
- }
- }
- else
- {
- // Benutzer ist bereits vorhanden.
- if ( @$conf['security']['openid']['update_user'])
- {
- $user->fullname = @$openId->info['fullname'];
- $user->mail = @$openId->info['email'];
- $user->save();
- }
- }
-
- Logger::info("User login successful: ".$username);
- $user->setCurrent(); // Benutzer ist jetzt in der Sitzung.
-
- $this->setStyle( $user->style );
- $this->setPerspective('start');
-
- $server = Http::getServer();
- Logger::debug("Redirecting to $server");
- header('Location: '.slashify($server) );
- exit();
- }
-
-
- /**
- * Login.
- */
- function openidPost()
- {
- global $conf;
-
- $this->checkForDb();
- Session::setUser('');
-
- if ( $conf['login']['nologin'] )
- Http::notAuthorized('login disabled');
-
- $openid_user = $this->getRequestVar('openid_url' );
- $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
- $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
- $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
- $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
-
- // Cookie setzen
- setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) );
-
- // Login mit Open-Id.
- if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) )
- {
- $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user);
-
- if ( ! $openId->login() )
- {
- $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- Session::set('openid',$openId);
- $this->redirect( $openId->getRedirectUrl() );
- return;
- }
- }
-
-
- /**
- * Synchronisiert die bisherigen Gruppen des Benutzers mit den Gruppen, die sich aus der Authentifzierung ergeben haben.
- *
- * @param $user User Benutzerobjekt
- * @param $groups array $groups Einfaches Array von Gruppennamen.
- */
- private function checkGroups($user, $groups)
- {
- if ( $groups == null )
- return;
-
- $oldGroups = $user->getGroups();
-
- foreach( $oldGroups as $id=>$name)
- {
- if ( !in_array($name,$groups) )
- $user->delGroup($id);
- }
-
- foreach( $groups as $name)
- {
- if ( ! in_array($name,$oldGroups))
- {
- try
- {
- $group = Group::loadWithName( $name );
- $user->addGroup($group->groupid);
- }
- catch (ObjectNotFoundException $e)
- {
- // Gruppe fehlt. Anlegen?
- if ( config('ldap','authorize','auto_add' ) )
- {
- // Die Gruppe in der OpenRat-Datenbank hinzufuegen.
- $g = new Group();
- $g->name = $group;
- $g->add(); // Gruppe hinzufuegen
- $user->addGroup($g->groupid); // Und Gruppe dem Benutzer hinzufuegen.
- }
-
- }
- }
- }
- }
-
-
- /**
- * Login.
- * Zuerst wird die Datenbankverbindung aufgebaut und falls notwendig, aktualisiert.
- */
- function loginPost()
- {
- global $conf;
-
- if ( $this->hasRequestVar('dbid'))
- {
- $dbid = $this->getRequestVar('dbid');
-
- if ( !is_array($conf['database'][$dbid]) )
- $this->addValidationError('dbid');
-
- try {
-
-
- $db = new Database($conf['database'][$dbid], true);
- $db->id = $dbid;
- }
- catch( Exception $e) {
- throw new OpenRatException('DATABASE_ERROR_CONNECTION',$e->getMessage());
- }
-
- // Datenbank aktualisieren, sofern notwendig.
- require_once( OR_DBCLASSES_DIR.'DbUpdate.class.'.PHP_EXT );
- $updater = new DbUpdate();
- $updater->update( $db );
-
- unset($db);
- }
-
- $this->checkForDb();
-
- Session::setUser(''); // Altes Login entfernen.
-
- if ( $conf['login']['nologin'] )
- Http::notAuthorized('login disabled');
-
- $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
- $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
- $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
- $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
- $token = $this->getRequestVar('user_token' ,OR_FILTER_ALPHANUM);
-
- // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
- // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
- if ( empty($newPassword1) )
- {
- // Kein neues Kennwort,
- // nichts zu tun...
- }
- else
- {
- $auth = new InternalAuth();
-
- if ( $auth->login($loginName, $loginPassword,$token) || $auth->mustChangePassword )
- {
- if ( $newPassword1 != $newPassword2 )
- {
- $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
- $this->addValidationError('password2','');
- return;
- }
- elseif ( strlen($newPassword1) < $conf['security']['password']['min_length'] )
- {
- $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
- $this->addValidationError('password2','');
- return;
- }
- else
- {
- // Kennwoerter identisch und lang genug.
- $user = User::loadWithName($loginName);
- $user->setPassword( $newPassword1,true );
-
- // Das neue gesetzte Kennwort für die weitere Authentifizierung benutzen.
- $loginPassword = $newPassword1;
- }
- }
- else
- {
- // Anmeldung gescheitert.
- $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
- $this->addValidationError('login_name' ,'');
- $this->addValidationError('login_password','');
- return;
- }
- }
-
- // Cookie setzen
- $cookieLifetime = 60*60*24*30*12*2; // 2 Jahre.
- setcookie('or_username',$loginName ,time()+$cookieLifetime );
- setcookie('or_dbid' ,$this->getRequestVar('dbid'),time()+$cookieLifetime );
-
- // Authentifzierungs-Module.
- $modules = explode(',',$conf['security']['modules']['authenticate']);
-
- $loginOk = false;
- $mustChangePassword = false;
- $tokenFailed = false;
- $groups = null;
- $lastModule = null;
-
- // Jedes Authentifizierungsmodul durchlaufen, bis ein Login erfolgreich ist.
- foreach( $modules as $module)
- {
- $moduleClass = $module.'Auth';
- $auth = new $moduleClass;
- Logger::info('Trying to login with module '.$moduleClass);
- $loginStatus = $auth->login( $loginName,$loginPassword, $token );
- $loginOk = $loginStatus === true || $loginStatus === OR_AUTH_STATUS_SUCCESS;
-
- if ( $loginStatus === OR_AUTH_STATUS_PW_EXPIRED )
- $mustChangePassword = true;
- if ( $loginStatus === OR_AUTH_STATUS_TOKEN_NEEDED )
- $tokenFailed = true;
-
- if ( $loginOk )
- {
- Logger::info('Login successful for '.$loginName);
- $lastModule = $module;
-
- if ( isset($auth->groups ) )
- $groups = $auth->groups;
-
- break; // Login erfolgreich, erstes Modul gewinnt.
- }
- }
-
- /*
- $loginOk = $this->checkLogin( $loginName,
- $loginPassword,
- $newPassword1,
- $newPassword2 );
- */
-
-
- if ( $loginOk )
- {
-
- try
- {
- // Benutzer über den Benutzernamen laden.
- $user = User::loadWithName($loginName);
- $user->loginModuleName = $lastModule;
-// Session::setUser($user);
- $user->setCurrent();
-
- if ($user->passwordAlgo != Password::bestAlgoAvailable() )
- // Re-Hash the password with a better hash algo.
- $user->setPassword($loginPassword);
-
- }
- catch( ObjectNotFoundException $ex )
- {
- // Benutzer wurde zwar authentifiziert, ist aber in der
- // internen Datenbank nicht vorhanden
- if ( $conf['security']['newuser']['autoadd'] )
- {
- // Neue Benutzer in die interne Datenbank uebernehmen.
- $user = new User();
- $user->name = $loginName;
- $user->fullname = $loginName;
- $user->add();
- $user->save();
- }
- else
- {
- // Benutzer soll nicht angelegt werden.
- // Daher ist die Anmeldung hier gescheitert.
- $loginOk = false;
- }
- }
- }
-
- Password::delay();
-
- $ip = getenv("REMOTE_ADDR");
-
- if ( !$loginOk )
- {
- // Anmeldung nicht erfolgreich
-
- Logger::debug("Login failed for user '$loginName' from IP $ip");
-
- if ( $tokenFailed )
- {
- // Token falsch.
- $this->addNotice('user',$loginName,'LOGIN_FAILED_TOKEN_FAILED','error' );
- $this->addValidationError('user_token','');
- }
- elseif ( $mustChangePassword )
- {
- // Anmeldung gescheitert, Benutzer muss Kennwort ?ndern.
- $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' );
- $this->addValidationError('password1','');
- $this->addValidationError('password2','');
- }
- else
- {
- // Anmeldung gescheitert.
- $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
- $this->addValidationError('login_name' ,'');
- $this->addValidationError('login_password','');
- }
-
-
- //$this->callSubAction('login');
- return;
- }
- else
- {
-
- Logger::debug("Login successful for user '$loginName' from IP $ip");
-
- $this->checkGroups( $user, $groups );
-
- if ( $this->hasRequestVar('remember') )
- {
- // Cookie setzen
- setcookie('or_username',$user->name ,time()+(60*60*24*30*12*2) );
- setcookie('or_token' ,$user->loginToken(),time()+(60*60*24*30*12*2) );
- }
-
- // Anmeldung erfolgreich.
- if ( config('security','renew_session_login') )
- $this->recreateSession();
-
- $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname));
-
- $this->setStyle( $user->style );
-
- $this->evaluateRequestVars();
-
- $object = Session::getObject();
- // Falls noch kein Objekt ausgewaehlt, dann das zuletzt ge?nderte benutzen.
- if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] )
- {
- $objectid = Value::getLastChangedObjectByUserId($user->userid);
- if ( Object::available($objectid))
- {
- $object = new Object($objectid);
- $object->load();
- Session::setObject($object);
-
- $project = new Project( $object->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
- }
-
- $this->setStyle( $user->style ); // Benutzer-Style setzen
-
- $langFile = OR_LANGUAGE_DIR.'lang-'.$user->language.'.'.PHP_EXT;
-
- // Pruefen, ob Sprache vorhanden ist.
- if ( !file_exists( $langFile ) )
- {
- // Nur Warnung ins Log schreiben, keinen Fehler werfen
- // Es ist möglich, dass Sprachen entfernt werden.
- Logger::warn("Languagefile $langFile does not exist.");
- }
- else
- {
- require( $langFile );
- global $conf;
- $conf['language'] = $lang;
- $conf['language']['language_code'] = $user->language;
- Session::setConfig( $conf );
- }
-
-
-
- // Entscheiden, welche Perspektive als erstes angezeigt werden soll.
-
- $allProjects = Project::getAllProjects();
-
- if ( $conf['login']['start']['start_single_project'] &&
- count($allProjects) == 1 )
- {
- // Das einzige Projekt sofort starten.
- $projectIds = array_keys($allProjects);
-
- $project = new Project($projectIds[0]);
- $project->load();
- $language = new Language( $project->getDefaultLanguageId() );
- $language->load();
- $model = new Model( $project->getDefaultModelId() );
- $model->load();
-
- Session::setProject( $project );
- Session::setProjectLanguage( $language );
- Session::setProjectModel( $model );
-
-
- $this->setPerspective('normal');
- }
- elseif ( $conf['login']['start']['start_lastchanged_object'] )
- {
- $user = Session::getUser();
- $objectid = Value::getLastChangedObjectByUserId($user->userid);
- if ( Object::available($objectid))
- {
- // Das Projekt des zuletzt geänderten Objekts ermitteln
- // und dieses Projekt starten.
- $o = new Object( $objectid );
- $o->load();
-
- $project = new Project($o->projectid);
- $project->load();
- $language = new Language( $project->getDefaultLanguageId() );
- $language->load();
- $model = new Model( $project->getDefaultModelId() );
- $model->load();
-
- Session::setProject( $project );
- Session::setProjectLanguage( $language );
- Session::setProjectModel( $model );
-
- $this->setPerspective('normal');
- }
- else
- {
- // Benutzer hat noch nie eine Änderung durchgefuehrt.
- // Erstmal die Startseite anzeigen.
- $this->setPerspective('start');
- }
- }
-
- else
- {
- // Erstmal die Startseite anzeigen.
- $this->setPerspective('start');
- }
- }
-
- }
-
-
- /**
- * Benutzer meldet sich ab.
- */
- function logoutPost()
- {
- global $conf;
-
- $user = Session::getUser();
- if ( is_object($user) )
- $this->setTemplateVar('login_username',$user->name);
-
- // Ausgew?hlte Objekte merken, um nach dem n?. Login wieder sofort auszuw?hlen.
- $o = Session::getObject();
- if ( is_object($o) )
- $this->setTemplateVar('objectid',$o->objectid);
- $p = Session::getProject();
- if ( is_object($p) )
- $this->setTemplateVar('projectid',$p->projectid);
- $l = Session::getProjectLanguage();
- if ( is_object($l) )
- $this->setTemplateVar('languageid',$l->languageid);
- $m = Session::getProjectModel();
- if ( is_object($m) )
- $this->setTemplateVar('modelid',$m->modelid);
- $db = db_connection();
- if ( is_object($db) )
- $this->setTemplateVar('dbid',$db->id);
-
- /*
- // Alle Variablen aus der Sitzung entfernen.
- session_unset();
-
- // Damit wird die Session gel�scht, nicht nur die Session-Daten!
- if ( ini_get("session.use_cookies") )
- {
- $params = session_get_cookie_params();
- setcookie( session_name(),'', time() - 3600,
- $params["path"],$params["domain"],$params["secure"],$params["httponly"] );
- }
-
- // Loeschen der Session.
- session_destroy();
- */
- if ( config('security','renew_session_logout') )
- $this->recreateSession();
-
- session_unset();
-
- if ( @$conf['theme']['compiler']['compile_at_logout'] )
- {
- foreach( $conf['action'] as $actionName => $actionConfig )
- {
- foreach( $actionConfig as $subActionName=>$subaction )
- {
- if ( is_array($subaction) &&
- !isset($subaction['goto' ]) &&
- !isset($subaction['direct']) &&
- !isset($subaction['action']) &&
- !isset($subaction['async' ]) &&
- !isset($subaction['alias' ]) &&
- $subActionName != 'menu' )
- {
- $engine = new template_engine\TemplateEngine();
- $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName);
- }
- }
- }
- }
-
- // Login-Token löschen:
- // Wenn der Benutzer sich abmelden will, dann soll auch die automatische
- // Anmeldung deaktiviert werden.
- setcookie('or_token' ,'',0 );
-
- // Umleiten auf eine definierte URL.s
- $redirect_url = @$conf['security']['logout']['redirect_url'];
-
- if ( !empty($redirect_url) )
- {
- $this->redirect($redirect_url);
- }
-
- Session::set('perspective','login');
-
- // Style zurücksetzen.
- // Der Style des Benutzers koennte auch stehen bleiben. Aber dann gäbe es Rückschlüsse darauf, wer zuletzt angemeldet war (Sicherheit!).
- $this->setStyle( config('interface','style','default') );
- $this->refresh();
- }
-
-
-
- /**
- * Benutzer meldet sich ab.
- */
- function logoutView()
- {
- }
-
-
- /**
- * Ausw?hlen der Administration.
- */
- function administration()
- {
- Session::setProject( new Project(-1) );
- }
-
-
-
- /**
- * Ausgeben von maschinenlesbaren Benutzerinformationen.
- *
- * Diese Funktion dient dem Single-Signon f?r fremde Anwendungen, welche
- * die Benutzerinformationen des angemeldeten Benutzers aus dieser
- * Anwendung auslesen k?nnen.
- */
- function userinfo()
- {
- $user = Session::getUser();
- $info = array('username' => $user->name,
- 'fullname' => $user->fullname,
- 'mail' => $user->mail,
- 'telephone' => $user->tel,
- 'style' => $user->style,
- 'admin' => $user->isAdmin?'true':'false',
- 'ldap' => $user->ldap_dn,
- 'groups' => implode(',',$user->getGroups()),
- 'description'=> $user->desc
- );
-
- // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die
- // Informationen per XML aus.
- if ( $this->hasRequestVar('xml') )
- {
- header('Content-Type: text/xml');
- echo '<userinfo>';
- foreach( $info as $n=>$i )
- echo '<'.$n.'>'.$i.'</'.$n.'>'."\n";
- echo '</userinfo>';
-
- }
-
- // Sonst normale Textausgabe im INI-Datei-Format.
- else
- {
- header('Content-Type: text/plain');
- foreach( $info as $n=>$i )
- echo $n.'="'.$i."\"\n";
- }
-
- exit; // Fertig.
- }
-
-
- function project()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
-
- Session::setUser( $user );
- }
-
-
- function object()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) );
-
- Session::setUser( $user );
- }
-
-
- function language()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) );
- }
-
-
- function model()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) );
-
- $user = Session::getUser();
- }
-
-
- /**
- * Auswerten der Request-Variablen.
- *
- * @param Array $add
- */
- function evaluateRequestVars( $add = array() )
- {
- global $REQ;
- $vars = $REQ + $add;
-
- $db = db_connection();
- if ( !is_object($db) )
- {
- if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
- $this->setDb($vars[REQ_PARAM_DATABASE_ID]);
- else
- Http::serverError('no database available.');
- }
- else
- {
- // Pr�ft, ob die �bergebene Datenbank-Id mit der
- // aktuellen �bereinstimmt.
- // Falls nicht, muss ein Re-Login erfolgen.
- if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
- if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] )
- {
- $this->callSubAction('show');
- return;
- }
- }
-
-
- if ( isset($vars[REQ_PARAM_OBJECT_ID]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) )
- {
- $object = new Object( $vars[REQ_PARAM_OBJECT_ID] );
- $object->objectLoadRaw();
- Session::setObject( $object );
-
- $project = new Project( $object->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
- elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) )
- {
- $language = new Language( $vars[REQ_PARAM_LANGUAGE_ID] );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $project = new Project( $language->projectid );
- $project->load();
- Session::setProject( $project );
-
- $model = Session::getProjectModel();
- if ( !is_object($model) )
- {
- $model = new Model( $project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
-
- $object = Session::getObject();
- if ( is_object($object) && $object->projectid == $project->projectid )
- {
- $object->objectLoadRaw();
- Session::setObject( $object );
- }
- else
- {
- Session::setObject( '' );
- }
- }
- elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) )
- {
- $model = new Model( $vars[REQ_PARAM_MODEL_ID] );
- $model->load();
- Session::setProjectModel( $model );
-
- $project = new Project( $model->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = Session::getProjectLanguage();
- if ( !is_object($language) || $language->projectid != $project->projectid )
- {
- $language = new Language( $project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
- }
-
- $object = Session::getObject();
- $object->objectLoadRaw();
- if ( is_object($object) && $object->projectid == $project->projectid )
- {
- $object->objectLoadRaw();
- Session::setObject( $object );
- }
- else
- {
- Session::setObject( '' );
- }
- }
- elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) )
- {
- $project = new Project( $vars[REQ_PARAM_PROJECT_ID] );
- $project->load();
-
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
-
- $object = Session::getObject();
- if ( is_object($object) && $object->projectid == $project->projectid )
- {
- $object->objectLoadRaw();
- Session::setObject( $object );
- }
- else
- {
- Session::setObject( '' );
- }
- }
- }
-
-
- function showtree()
- {
- Session::set('showtree',true );
- }
-
-
- function hidetree()
- {
- Session::set('showtree',false );
- }
-
-
- function switchuser()
- {
- $user = Session::getUser();
-
- if ( ! $user->isAdmin )
- Http::notAuthorized("");
-
- $this->recreateSession();
-
- $newUser = new User( $this->getRequestId() );
- $newUser->load();
-
- $newUser->setCurrent();
- }
-
-
- function show()
- {
- global $conf;
- global $PHP_AUTH_USER;
- global $PHP_AUTH_PW;
-
- $user = Session::getUser();
- // Gast-Login
- if ( ! is_object($user) )
- {
- if ( $conf['security']['guest']['enable'] )
- {
- $this->setDefaultDb();
- $username = $conf['security']['guest']['user'];
- $user = User::loadWithName($username);
- if ( $user->userid > 0 )
- $user->setCurrent();
- else
- {
- Logger::warn('Guest login failed, user not found: '.$username);
- $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) );
- $user = null;
- }
- }
- }
-
- if ( ! is_object($user) )
- {
- switch( $conf['security']['login']['type'] )
- {
-
- // Authorization ueber HTTP
- //
- case 'http':
- $ok = false;
-
- if ( isset($_SERVER['PHP_AUTH_USER']) )
- {
- $this->setDefaultDb();
- $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] );
- }
-
- if ( ! $ok )
- {
- header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' );
- header( 'HTTP/1.0 401 Unauthorized' );
- echo 'Authorization Required!';
- exit;
- }
- break;
-
- case 'form':
- // Benutzer ist nicht angemeldet
- $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske
- return;
- break;
-
- default:
- Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' );
- }
- }
-
- if ( $user->mustChangePassword )
- {
- $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
- $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu ?ndern.
- }
-
- // Seite ?ndert sich nur 1x pro Session
- $this->lastModified( $user->loginDate );
-
- $projectid = intval( $this->getRequestVar('projectid' ) );
- $languageid = intval( $this->getRequestVar('languageid') );
- $modelid = intval( $this->getRequestVar('modelid' ) );
- $objectid = intval( $this->getRequestVar('objectid' ) );
- $elementid = intval( $this->getRequestVar('elementid' ) );
-
- if ( $projectid != 0 )
- {
- $project = new Project( $projectid );
- $project->load();
- Session::setProject($project);
- }
- elseif ( $languageid != 0 )
- {
- $language = new Language( $languageid );
- $language->load();
- Session::setProjectLanguage($language);
- }
- elseif ( $modelid != 0 )
- {
- $model = new Model( $modelid );
- $model->load();
- Session::setProjectModel($model);
- }
- elseif ( $objectid != 0 )
- {
- $object = new Object( $objectid );
- $object->objectLoad();
- Session::setObject($object);
- }
- if ( $elementid != 0 )
- {
- $element = new Element( $elementid );
- Session::setElement($element);
- }
-
- $project = Session::getProject();
- $object = Session::getObject();
- $elementid = 0;
-
- if ( is_object($project) )
- {
- if ( $project->projectid == PROJECTID_ADMIN )
- {
- $project->name = lang('ADMINISTRATION');
- Session::setProject( $project );
-
- Session::setProjectLanguage( '' );
- Session::setProjectModel ( '' );
- Session::setObject ( '' );
- }
-
- $this->setTemplateVar( 'title',$project->name );
-
- if ( is_object($object) )
- {
- $type = $object->getType();
-
- if ( $type == 'page' )
- {
- $page = new Page($object->objectid);
- $page->load();
- $elementList = $page->getWritableElements();
- if ( count($elementList) == 1 )
- $elementid = current(array_keys($elementList));
- }
-
- if ( $elementid > 0 )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) );
- else
- $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) );
- }
- else
- {
- $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
- }
- }
- elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN )
- {
- if ( $this->hasRequestVar('projectid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) );
- elseif ( $this->hasRequestVar('groupid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) );
- elseif ( $this->hasRequestVar('userid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) );
- else
- $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
- }
- else
- {
- $this->callSubAction( 'projectmenu' );
- }
-
-
- $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) );
-
- $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) );
- $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) );
- $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) );
- $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) );
- $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) );
- $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) );
-
- $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] );
-
- $this->metaValues();
- }
-
-
-
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'applications':
- // Men?punkt "Anwendungen" wird nur angezeigt, wenn weitere Anwendungen
- // konfiguriert sind.
- return count(@$conf['applications']) > 0;
-
- case 'register': // Registrierung
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- return @$conf['login']['register'] && @$conf['security']['auth']['type'] == 'database';
-
- case 'password': // Kennwort vergessen
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- // Deaktiviert, falls LDAP-Lookup aktiviert ist.
- return @$conf['login']['send_password'] && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
-
- case 'administration':
- // "Administration" nat?rlich nur f?r Administratoren.
- return $this->userIsAdmin();
-
- case 'login':
- return !@$conf['login']['nologin'];
-
- case 'logout':
- return true;
-
- case 'projectmenu':
- return true;
-
- default:
- return false;
- }
- }
-
-
- /**
- * Maske anzeigen, um Benutzer zu registrieren.
- */
- public function registerView()
- {
-
- }
-
-
- /**
- * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen.
- * Maske anzeigen, damit Benuter Registriercode anzeigen kann.
- */
- public function registercodeView()
- {
- global $conf;
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbname] = $dbconf['description'];
- }
-
- $this->setTemplateVar( 'dbids',$dbids );
-
- $db = Session::getDatabase();
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- else
- $this->setTemplateVar('actdbid',$conf['database']['default']);
-
-
-
- }
-
-
-
- public function registerPost()
- {
- global $conf;
-
- Session::set('registerMail',$this->getRequestVar('mail') );
-
- srand ((double)microtime()*1000003);
- $registerCode = rand();
-
- Session::set('registerCode',$registerCode );
-
- $email_address = $this->getRequestVar('mail',OR_FILTER_MAIL);
-
- if ( ! Mail::checkAddress($email_address) )
- {
- $this->addValidationError('mail');
- return;
- }
-
- // E-Mail and die eingegebene Adresse verschicken
- $mail = new Mail($email_address,
- 'register_commit_code','register_commit_code');
- $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable
-
- if ( $mail->send() )
- {
- $this->addNotice('','','mail_sent',OR_NOTICE_OK);
- $this->nextView('registeruserdata');
- }
- else
- {
- $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error);
- return;
- }
-
- $this->nextView('registercode');
- }
-
-
- /**
- * Benutzerregistierung.
- * Benutzer hat Best?tigungscode erhalten und eingegeben.
- */
- function registercodePost()
- {
- global $conf;
- $this->checkForDb();
-
- $origRegisterCode = Session::get('registerCode');
- $inputRegisterCode = $this->getRequestVar('code');
-
- if ( $origRegisterCode != $inputRegisterCode )
- {
- // Best?tigungscode stimmt nicht.
- $this->addValidationError('code','code_not_match');
- return;
- }
-
- // Best?tigungscode stimmt ?berein.
- // Neuen Benutzer anlegen.
-
- if ( !$this->hasRequestVar('username') )
- {
- $this->addValidationError('username');
- return;
- }
-
- $user = User::loadWithName( $this->getRequestVar('username') );
- if ( $user->isValid() )
- {
- $this->addValidationError('username','USER_ALREADY_IN_DATABASE');
- return;
- }
-
- if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] )
- {
- $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length']));
- return;
- }
-
- $newUser = new User();
- $newUser->name = $this->getRequestVar('username');
- $newUser->add();
-
- $newUser->mail = Session::get('registerMail');
- $newUser->save();
-
- $newUser->setPassword( $this->getRequestVar('password'),true );
-
- $this->addNotice('user',$newUser->name,'user_added','ok');
-
- $this->nextView('login');
- }
-
-
-
- /**
- * Vergessenes Kennwort zusenden lassen.
- */
- function passwordView()
- {
- // TODO: Attribut "Password" abfragen
- foreach( config('database') as $dbname=>$dbconf )
- {
- $dbconf = $dbconf + config('database-default','defaults');
- if ( $dbconf['enabled'] )
- $dbids[$dbname] = $dbconf['description'];
- }
-
- $this->setTemplateVar( 'dbids',$dbids );
-
-
- $db = Session::getDatabase();
-
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- else
- $this->setTemplateVar('actdbid',config('database-default','default-id'));
- }
-
-
- /*
- function changepassword()
- {
- }
- */
-
-
- /*
- function setnewpassword()
- {
- $oldPw = $this->getRequestVar('password_old' );
- $newPw1 = $this->getRequestVar('password_new_1');
- $newPw2 = $this->getRequestVar('password_new_2');
-
- if ( $newPw1 == $newPw2 )
- {
- // Aktuellen Benutzer aus der Sitzung ermitteln
- $user = $this->getUserFromSession();
-
- // Altes Kennwort pr?fen.
- $ok = $user->checkPassword( $oldPw );
-
- if ( $ok ) // Altes Kennwort ist ok.
- {
- $user->setPassword( $newPw1 ); // Setze neues Kennwort
- $user->mustChangePassword = false;
- Session::setUser($user);
- $this->addNotice('user',$user->name,'password_set','ok');
- }
- else
- {
- // Altes Kennwort falsch.
- $this->addNotice('user',$user->name,'password_error','error');
- }
- }
- else
- {
- // Beide neuen Kennw?rter stimmen nicht ?berein
- $this->addNotice('user',$user->name,'passwords_not_match','error');
- }
- }
- */
-
-
- /**
- * Einen Kennwort-Anforderungscode an den Benutzer senden.
- */
- function passwordPost()
- {
- if ( !$this->hasRequestVar('username') )
- {
- $this->addValidationError('username');
- return;
- }
-
- $this->checkForDb();
-
- $user = User::loadWithName( $this->getRequestVar("username") );
- // Html::debug($user);
- Password::delay();
- if ( $user->isValid() )
- {
- srand ((double)microtime()*1000003);
- $code = rand();
- $this->setSessionVar("password_commit_code",$code);
-
- $eMail = new Mail( $user->mail,'password_commit_code' );
- $eMail->setVar('name',$user->getName());
- $eMail->setVar('code',$code);
- if ( $eMail->send() )
- $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK);
- else
- $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error);
-
- }
- else
- {
- //$this->addNotice('','user','username_not_found');
- // Trotzdem vort?uschen, eine E-Mail zu senden, damit die G?ltigkeit
- // eines Benutzernamens nicht von au?en gepr?ft werden kann.
- //
- $this->addNotice('user',$this->getRequestVar("username"),'mail_sent');
-
- }
-
- $this->setSessionVar("password_commit_name",$user->name);
- $this->nextView('passwordcode');
- }
-
-
-
- /**
- * Anzeige Formular zum Eingeben des Kennwort-Codes.
- *
- */
- function passwordcodeView()
- {
-
- }
-
-
- /**
- * Neues Kennwort erzeugen und dem Benutzer zusenden.
- */
- function passwordcodePost()
- {
- $username = $this->getSessionVar("password_commit_name");
-
- if ( $this->getRequestVar("code")=='' ||
- $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") )
- {
- $this->addValidationError('code','PASSWORDCODE_NOT_MATCH');
- return;
- }
-
- $user = User::loadWithName( $username );
-
- if ( !$user->isValid() )
- {
- // Benutzer konnte nicht geladen werden.
- $this->addNotice('user',$username,'error',OR_NOTICE_ERROR);
- return;
- }
-
- $newPw = User::createPassword(); // Neues Kennwort erzeugen.
-
- $eMail = new Mail( $user->mail,'password_new' );
- $eMail->setVar('name' ,$user->getName());
- $eMail->setVar('password',$newPw );
-
- if ( $eMail->send() )
- {
- $user->setPassword( $newPw, false ); // Kennwort muss beim n?. Login ge?ndert werden.
- $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK);
- }
- else
- {
- // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den
- // Code per E-Mail erhalten hat.
- $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error);
- }
- }
-
-
- /**
- * Erzeugt eine neue Sitzung.
- */
- function recreateSession()
- {
-
- // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht.
- if ( version_compare(phpversion(),"4.3.2","<") )
- {
- $randlen = 32;
- $randval = "0123456789abcdefghijklmnopqrstuvwxyz";
- $newid = "";
- for ($i = 1; $i <= $randlen; $i++)
- {
- $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1);
- }
- session_id( $newid );
- }
- elseif( version_compare(phpversion(),"4.3.2","==") )
- {
- session_regenerate_id();
-
- // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt.
- if ( ini_get("session.use_cookies") )
- setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" );
- }
- elseif ( version_compare(phpversion(),"5.1.0",">") )
- {
- session_regenerate_id(true);
- }
- else
- {
- // 5.1.0 > PHP >= 4.3.3
- }
- }
-
-
- function licenseView()
- {
- $software = array();
-
- $software[] = array('name' =>'OpenRat Content Management System',
- 'url' =>'http://www.openrat.de/',
- 'license'=>'GPL v2');
- $software[] = array('name' =>'jQuery Core Javascript Framework',
- 'url' =>'http://jquery.com/',
- 'license'=>'MPL, GPL v2');
- $software[] = array('name' =>'jQuery UI Javascript Framework',
- 'url' =>'http://jqueryui.com/',
- 'license'=>'MPL, GPL v2');
- $software[] = array('name' =>'GeSHi - Generic Syntax Highlighter',
- 'url' =>'http://qbnz.com/highlighter/',
- 'license'=>'GPL v2');
- $software[] = array('name' =>'CKEditor',
- 'url' =>'http://ckeditor.com/',
- 'license'=>'GPL v2');
- $software[] = array('name' =>'960 Grid System CSS',
- 'url' =>'http://960.gs/',
- 'license'=>'GPL v3, MIT');
- $software[] = array('name' =>'TAR file format',
- 'url' =>'http://www.phpclasses.org/package/529',
- 'license'=>'LGPL');
- $software[] = array('name' =>'JSON file format',
- 'url' =>'http://pear.php.net/pepr/pepr-proposal-show.php?id=198',
- 'license'=>'BSD');
-
- $this->setTemplateVar('software',$software);
- }
-
-
- function pingView()
- {
- echo "1";
- }
-}
-
-
-?>-
\ No newline at end of file
diff --git a/action/ModelAction.class.php b/action/ModelAction.class.php
@@ -1,209 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Model;
-
-
-
-use Session;
-use \Html;
-
-// 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 zum Bearbeiten eines Projetmodells
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class ModelAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $defaultSubAction = 'listing';
- var $model;
-
-
- function __construct()
- {
- $this->model = new Model( $this->getRequestId() );
- $this->model->load();
-
- $this->project = Session::getProject();
- }
-
-
-
-
- /**
- * Entfernen der Variante.<br>
- * Es wird ein Best�tigungsdialog angezeigt.
- */
- function removeView()
- {
- $this->model->load();
-
- $this->setTemplateVar( 'name',$this->model->name );
- }
-
-
- /**
- * Löschen des Models.
- */
- function removePost()
- {
- if ( $this->hasRequestVar('confirm') )
- {
- $this->model->delete();
- $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice('model',$this->model->name,'NOTHING_DONE',OR_NOTICE_WARN);
- }
- }
-
-
-
- // Speichern eines Modells
- function editPost()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- $this->model->name = $this->getRequestVar('name');
- $this->model->save();
- $this->addNotice('model',$this->model->name,'SAVED','ok');
- }
- else
- {
- $this->addNotice('model',$this->model->name,'NOT_SAVED','error');
- }
-
- // Baum aktualisieren
-// $this->setTemplateVar('tree_refresh',true);
- }
-
-
- function setdefaultPost()
- {
- if ( !$this->userIsAdmin() ) exit();
-
- $this->model->setDefault();
-
- $this->callSubAction('listing');
- }
-
-
- function listingView()
- {
- global $conf_php;
- $actModel = Session::getProjectModel();
-
-// $var['act_modelid'] = $this->getSessionVar('modelid');
-
- $list = array();
- foreach( $this->project->getModelIds() as $id )
- {
- $m = new Model( $id );
- $m->load();
-
- $list[$id]['name'] = $m->name;
-
- if ( $this->userIsAdmin() )
- $list[$id]['url' ] = Html::url('model','edit',$id,
- array() );
-
- if ( ! $m->isDefault && $this->userIsAdmin() )
- $list[$id]['default_url'] = Html::url('model','setdefault',$id);
-
- if ( $actModel->modelid != $m->modelid )
- $list[$id]['select_url' ] = Html::url('index','model',$id);
- }
- $this->setTemplateVar( 'el',$list );
- $this->setTemplateVar( 'add',$this->userIsAdmin() );
- }
-
-
- /**
- * Bearbeiten der Variante.
- * Ermitteln aller Eigenschaften der Variante.
- */
- function editView()
- {
- $this->model->load();
-
- $this->setTemplateVars( $this->model->getProperties() );
- }
-
-
- function checkmenu( $menu )
- {
- switch( $menu )
- {
- case 'remove':
- $actModel = Session::getProjectModel();
- return
- !readonly() &&
- $this->userIsAdmin() &&
- is_object($this->model) &&
- count( $this->model->getAll() ) >= 2 &&
- $actModel->modelid != $this->model->modelid;
-
- case 'add':
- return
- !readonly() && $this->userIsAdmin();
-
- default:
- return true;
- }
- }
-
-
- /**
- * 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();
- $modellistChildren = array();
-
- $structure[0] = array('id'=>'0','name'=>lang('MODELS'),'type'=>'modellist','level'=>1,'children'=>&$modellistChildren);
-
- $modellistChildren[ $this->model->modelid ] = array('id'=>$this->model->modelid,'name'=>$this->model->name,'type'=>'model','self'=>true);
-
-
- //Html::debug($structure);
-
- $this->setTemplateVar('outline',$structure);
- }
-}-
\ No newline at end of file
diff --git a/action/ModellistAction.class.php b/action/ModellistAction.class.php
@@ -1,118 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Model;
-use Html;
-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 zum Bearbeiten eines Projetmodells
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class ModellistAction extends Action
-{
- /**
- * @var Model
- */
- public $model;
-
- public $security = SECURITY_USER;
-
- private $project;
-
- function __construct()
- {
- if ( $this->getRequestId() != 0 )
- {
- $this->model = new Model( $this->getRequestId() );
- $this->model->load();
- }
-
- $this->project = Session::getProject();
- }
-
-
- function showView()
- {
- global $conf_php;
- $actModel = Session::getProjectModel();
-
-// $var['act_modelid'] = $this->getSessionVar('modelid');
-
- $list = array();
- foreach( $this->project->getModelIds() as $id )
- {
- $m = new Model( $id );
- $m->load();
-
- $list[$id]['name'] = $m->name;
-
- if ( $this->userIsAdmin() )
- $list[$id]['id' ] = $id;
-
- if ( ! $m->isDefault && $this->userIsAdmin() )
- $list[$id]['default_url'] = Html::url('model','setdefault',$id);
-
- if ( $actModel->modelid != $m->modelid )
- $list[$id]['select_url' ] = Html::url('index','model',$id);
- }
- $this->setTemplateVar( 'el',$list );
- $this->setTemplateVar( 'add',$this->userIsAdmin() );
- }
-
-
- /**
- * Bearbeiten der Variante.
- * Ermitteln aller Eigenschaften der Variante.
- */
- function editView()
- {
- $this->nextSubAction('show');
- }
-
-
-
-
- function addView()
- {
- }
-
-
- function addPost()
- {
- $model = new Model();
- $model->projectid = $this->project->projectid;
- $model->name = $this->getRequestVar('name');
- $model->add();
-
- // Wenn kein Namen eingegeben, dann einen setzen.
- if ( empty($model->name) )
- {
- // Name ist "Variante <id>"
- $model->name = lang('MODEL').' '.$model->modelid;
- $model->save();
- }
- }
-
-}-
\ No newline at end of file
diff --git a/action/ObjectAction.class.php b/action/ObjectAction.class.php
@@ -1,480 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Acl;
-use cms\model\User;
-use cms\model\Group;
-use cms\model\Page;
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\Language;
-use cms\model\File;
-use cms\model\Link;
-
-// 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 zum Bearbeiten eines Ordners
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class ObjectAction extends Action
-{
- public $security = SECURITY_USER;
-
- private $objectid;
-
- public function copyView()
- {
- $this->actionName = 'object';
- global $conf_php;
-
- $sourceObject = new Object( $this->getRequestId());
- $sourceObject->load();
-
- $targetFolder = new Object( $this->getRequestVar('targetFolderId',OR_FILTER_NUMBER));
- $targetFolder->load();
-
- $this->setTemplateVar('source' ,$sourceObject->getProperties() );
- $this->setTemplateVar('sourceId',$sourceObject->objectid );
- $this->setTemplateVar('target' ,$targetFolder->getProperties() );
- $this->setTemplateVar('targetId',$targetFolder->objectid );
- $this->setTemplateVar('types' ,array('move'=>'move','moveandlink'=>'moveandlink','copy'=>'copy','link'=>'link') );
-
- if ( ! $targetFolder->hasRight(ACL_WRITE) )
- {
- $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
- }
- }
-
-
- /**
- * Ein Fileobjekt wird in einen neuen Ordner kopiert oder verschoben.
- */
- public function copyPost()
- {
- $type = $this->getRequestVar('type');
- $targetObjectId = $this->getRequestVar('targetid',OR_FILTER_NUMBER);
- $sourceObjectId = $this->getRequestVar('sourceid',OR_FILTER_NUMBER);
-
- $sourceObject = new Object( $sourceObjectId );
- $sourceObject->load();
-
- $targetFolder = new Object( $targetObjectId );
- $targetFolder->load();
-
- // Prüfen, ob Schreibrechte im Zielordner bestehen.
- if ( ! $targetFolder->hasRight(ACL_WRITE) )
- {
- $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
- return;
- }
-
- switch( $type )
- {
- case 'move':
-
- if ( $sourceObject->isFolder )
- {
- $f = new Folder( $sourceObjectId );
- $allsubfolders = $f->getAllSubFolderIds();
-
- // Plausibilisierungsprüfung:
- //
- // Wenn
- // - Das Zielverzeichnis sich nicht in einem Unterverzeichnis des zu verschiebenen Ordners liegt
- // und
- // - Das Zielverzeichnis nicht der zu verschiebene Ordner ist
- // dann verschieben
- if ( in_array($targetObjectId,$allsubfolders) || $sourceObjectId == $targetObjectId )
- {
- $this->addNotice('folder',$sourceObject->name,'ERROR',OR_NOTICE_ERROR);
- return;
- }
- }
-
- // TODO:
- // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
- // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
- $sourceObject->setParentId( $targetObjectId );
- $this->addNotice($sourceObject->type, $sourceObject->name, 'moved');
- break;
-
- case 'moveandlink':
-
- $oldParentId = $sourceObject->parentid;
-
- $sourceObject->setParentId( $targetObjectId );
- $this->addNotice($sourceObject->type, $sourceObject->name, 'moved');
-
- $link = new Link();
- $link->parentid = $oldParentId;
- $link->name = lang('LINK_TO').' '.$sourceObject->name;
- $link->filename = $sourceObject->filename;
- $link->linkedObjectId = $sourceObjectId;
- $link->add();
- $this->addNotice('link', $link->name, 'added');
-
- break;
-
- case 'copy':
-
- switch( $sourceObject->getType() )
- {
- case 'folder':
- // Ordner zur Zeit nicht kopieren
- // Funktion waere zu verwirrend
- $this->addNotice($sourceObject->getType(),$sourceObject->name,'CANNOT_COPY_FOLDER','error');
- break;
-
- case 'file':
- $f = new File( $sourceObjectId );
- $f->load();
- $f->filename = '';
- $f->name = lang('COPY_OF').' '.$f->name;
- $f->parentid = $targetObjectId;
- $f->add();
- $f->copyValueFromFile( $sourceObjectId );
-
- $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
- break;
-
- case 'page':
- $p = new Page( $sourceObjectId );
- $p->load();
- $p->filename = '';
- $p->name = lang('COPY_OF').' '.$p->name;
- $p->parentid = $targetObjectId;
- $p->add();
- $p->copyValuesFromPage( $sourceObjectId );
- $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
- break;
-
- case 'link':
- $l = new Link( $sourceObjectId );
- $l->load();
- $l->filename = '';
- $l->name = lang('COPY_OF').' '.$l->name;
- $l->parentid = $targetObjectId;
- $l->add();
- $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
- break;
-
- default:
- Http::serverError('fatal: unknown type while deleting');
- }
- break;
-
- case 'link':
-
- // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
- // von Verkn�pfungen vorhanden sein.
- if ( ! $targetFolder->hasRight(ACL_CREATE_LINK) )
- {
- $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
- return;
- }
-
- $link = new Link();
- $link->parentid = $targetObjectId;
- $link->name = lang('LINK_TO').' '.$sourceObject->name;
- $link->filename = $sourceObject->filename;
- $link->linkedObjectId = $sourceObjectId;
- $link->isLinkToObject = true;
- $link->add();
- $this->addNotice('link', $link->name, 'added');
- // OK
- break;
-
- default:
- Http::serverError('Unknown type for copying');
- break;
- }
-
- $targetFolder->setTimestamp();
-
- }
-
- /**
- * ACL zu einem Objekt setzen
- *
- * @access public
- */
- function aclformPost()
- {
- $acl = new Acl();
-
- $acl->objectid = $this->getRequestId();
-
- // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
- // diesem Objekt die ACLs zu aendern.
- $o = new Object( $acl->objectid );
-
- if ( !$o->hasRight( ACL_GRANT ) )
- die('uh?'); // Scheiss Hacker.
-
- // Handelt es sich um eine Benutzer- oder Gruppen ACL?
- switch( $this->getRequestVar('type') )
- {
- case 'user':
- $acl->userid = $this->getRequestVar('userid' );
-
- if ( $acl->userid <= 0 )
- {
- $this->addValidationError('type' );
- $this->addValidationError('userid','');
- $this->callSubAction('aclform');
- return;
- }
- break;
- case 'group':
- $acl->groupid = $this->getRequestVar('groupid');
- if ( $acl->groupid <= 0 )
- {
- $this->addValidationError('type' );
- $this->addValidationError('groupid','');
- $this->callSubAction('aclform');
- return;
- }
- break;
- case 'all':
- break;
- default:
- $this->addValidationError('type');
- $this->callSubAction('aclform');
- return;
- }
-
- $acl->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID);
-
- $acl->write = ( $this->hasRequestVar('write' ) );
- $acl->prop = ( $this->hasRequestVar('prop' ) );
- $acl->delete = ( $this->hasRequestVar('delete' ) );
- $acl->release = ( $this->hasRequestVar('release' ) );
- $acl->publish = ( $this->hasRequestVar('publish' ) );
- $acl->create_folder = ( $this->hasRequestVar('create_folder') );
- $acl->create_file = ( $this->hasRequestVar('create_file' ) );
- $acl->create_link = ( $this->hasRequestVar('create_link' ) );
- $acl->create_page = ( $this->hasRequestVar('create_page' ) );
- $acl->grant = ( $this->hasRequestVar('grant' ) );
- $acl->transmit = ( $this->hasRequestVar('transmit' ) );
-
- $acl->add();
-
- // Falls die Berechtigung vererbbar ist, dann diese sofort an
- // Unterobjekte vererben.
- if ( $acl->transmit )
- {
- $folder = new Folder( $acl->objectid );
- $oids = $folder->getObjectIds();
- foreach( $folder->getAllSubfolderIds() as $sfid )
- {
- $subfolder = new Folder( $sfid );
- $oids = array_merge($oids,$subfolder->getObjectIds());
- }
-
- foreach( $oids as $oid )
- {
- $acl->objectid = $oid;
- $acl->add();
- }
- }
-
-
-
-
- $this->addNotice('','','ADDED',OR_NOTICE_OK);
-
- $o->setTimestamp();
- }
-
-
-
- /**
- * Alle Rechte anzeigen
- */
- function rightsView()
- {
- $this->actionName = 'object';
- $o = new Object( $this->getRequestId() );
- $o->objectLoadRaw();
- $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
- $this->setTemplateVar( 'type',$o->getType() );
-
- $acllist = array();
-
- /*
- foreach( $o->getAllInheritedAclIds() as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->load();
- $key = 'au'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
- $acllist[$key] = $acl->getProperties();
- }
- */
-
- foreach( $o->getAllAclIds() as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->load();
- $key = 'bu'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
- $acllist[$key] = $acl->getProperties();
- $acllist[$key]['aclid'] = $aclid;
- }
- ksort( $acllist );
-
- $this->setTemplateVar('acls',$acllist );
-
- $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
- }
-
-
-
- /**
- * Alle Rechte anzeigen
- */
- function inheritView()
- {
- $this->actionName = 'object';
-
- $o = new Object( $this->getRequestId() );
- $o->objectLoadRaw();
- $this->setTemplateVar( 'type',$o->getType() );
-
- $acllist = array();
- $this->setTemplateVar('acls',$acllist );
- }
-
-
-
- /**
- *
- * @return unknown_type
- */
- function inheritPost()
- {
- Session::close();
-
- $folder = new Folder( $this->getRequestId() );
- $folder->load();
-
- if ( ! $this->hasRequestVar('inherit') )
- {
- $this->addNotice('folder',$folder->name,'NOTHING_DONE',OR_NOTICE_WARN);
- return;
- }
-
-
- $aclids = $folder->getAllAclIds();
-
- $newAclList = array();
- foreach( $aclids as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->load();
- if ( $acl->transmit )
- $newAclList[] = $acl;
- }
- Logger::debug('inheriting '.count($newAclList).' acls');
-
- $oids = $folder->getObjectIds();
-
- foreach( $folder->getAllSubfolderIds() as $sfid )
- {
- $subfolder = new Folder( $sfid );
-
- $oids = array_merge($oids,$subfolder->getObjectIds());
- }
-
- foreach( $oids as $oid )
- {
- $object = new Object( $oid );
-
- // Die alten ACLs des Objektes löschen.
- foreach( $object->getAllAclIds() as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->objectid = $oid;
- $acl->delete();
- Logger::debug('removing acl '.$aclid.' for object '.$oid);
- }
-
- // Vererbbare ACLs des aktuellen Ordners anwenden.
- foreach( $newAclList as $newAcl )
- {
- $newAcl->objectid = $oid;
- $newAcl->add();
- Logger::debug('adding new acl '.$newAcl->aclid.' for object '.$oid);
- }
- }
-
- $this->addNotice('folder',$folder->name,'SAVED',OR_NOTICE_OK);
- }
-
-
- /**
- * Formular anzeigen, um Rechte hinzufuegen
- */
- function aclformView()
- {
- $this->actionName = 'object';
-
- $o = new Object( $this->getRequestId() );
- $o->objectLoadRaw();
-
- $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
- $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
-
- $this->setTemplateVar('users' ,User::listAll() );
- $this->setTemplateVar('groups' ,Group::getAll() );
-
- $languages = array(0=>lang('ALL_LANGUAGES'));
- $languages += Language::getAll();
- $this->setTemplateVar('languages',$languages );
- $this->setTemplateVar('objectid' ,$o->objectid );
- $this->setTemplateVar('action' ,$this->actionName);
- }
-
-
-
- /**
- * Entfernen einer ACL
- *
- * @access protected
- */
- function delaclPost()
- {
- $acl = new Acl($this->getRequestVar('aclid'));
- $acl->objectid = $this->getRequestId();
-
- // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
- // diesem Objekt die ACLs zu aendern.
- $o = new Object( $this->getRequestId() );
-
- if ( !$o->hasRight( ACL_GRANT ) )
- Http::notAuthorized('no grant rights'); // Da wollte uns wohl einer vereimern.
-
- $acl->delete(); // Weg mit der ACL
-
- $this->addNotice('','','DELETED',OR_NOTICE_OK);
- }
-}-
\ No newline at end of file
diff --git a/action/PageAction.class.php b/action/PageAction.class.php
@@ -1,880 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Project;
-use cms\model\Value;
-use cms\model\Element;
-use cms\model\Template;
-use cms\model\Page;
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\Language;
-use cms\model\Model;
-use \Html;
-use Http;
-use Logger;
-use Session;
-
-
-/**
- * Action-Klasse zum Bearbeiten einer Seite
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class PageAction extends ObjectAction
-{
- public $security = SECURITY_USER;
-
- var $page;
- var $defaultSubAction = 'show';
-
-
- function __construct()
- {
- $this->page = new Page( $this->getRequestId() );
- $this->page->load();
-
- // Hier kann leider nicht das Datum der letzten Änderung verwendet werden,
- // da sich die Seite auch danach ändern kann, z.B. durch Includes anderer
- // Seiten oder Änderung einer Vorlage oder Änderung des Dateinamens einer
- // verlinkten Datei.
- //$this->lastModified( time() );
- }
-
-
- /**
- * Alle Daten aus dem Formular speichern
- */
- function formPost()
- {
- $this->page->public = true;
- $this->page->simple = true;
-
- foreach( $this->page->getElements() as $elementid=>$name )
- {
- if ( $this->hasRequestVar('saveid'.$elementid) )
- {
- $value = new Value();
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $value->objectid );
- $value->element = new Element( $elementid );
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- // Eingegebenen Inhalt aus dem Request lesen
- $inhalt = $this->getRequestVar( 'id'.$elementid );
-
- // Den Inhalt speichern.
- switch( $value->element->type )
- {
- case 'number':
- $value->number = $inhalt * pow(10,$value->element->decimals);
- break;
-
- case 'date':
- $value->date = strtotime( $inhalt );
- break;
-
- case 'text':
- case 'longtext':
- case 'select':
- $value->text = $inhalt;
- break;
-
- case 'link':
- case 'list':
- case 'insert':
- $value->linkToObjectId = intval($inhalt);
- break;
- }
-
- $value->page = &$this->page;
-
- // Ermitteln, ob Inhalt sofort freigegeben werden kann und soll
- if ( $this->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') )
- $value->publish = true;
- else
- $value->publish = false;
-
-// Html::debug($inhalt,'Eingabe');
-// Html::debug($value,'Inhalt');
-
- // Inhalt speichern.
- // Inhalt in allen Sprachen gleich?
- if ( $value->element->allLanguages )
- {
- // Inhalt fuer jede Sprache einzeln speichern.
- $p = new Project();
- foreach( $p->getLanguageIds() as $languageid )
- {
- $value->languageid = $languageid;
- $value->save();
- }
- }
- else
- {
- // sonst nur 1x speichern (fuer die aktuelle Sprache)
- $value->languageid = $this->getSessionVar(REQ_PARAM_LANGUAGE_ID);
- $value->save();
- }
- }
- }
- $this->page->setTimestamp(); // "Letzte Aenderung" setzen
-
- if ( $this->hasRequestVar('publish') )
- $this->callSubAction( 'pubnow' );
- else
- $this->callSubAction( 'el' );
- }
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- function editPost()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals);
- $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
- $value->text = $this->getRequestVar('text');
-
- // Vorschau anzeigen
- if ( $value->element->type=='longtext' && ($this->hasRequestVar('preview')||$this->hasRequestVar('addmarkup')) )
- {
- if ( $this->hasRequestVar('preview') )
- {
- $value->page = $this->page;
- $value->simple = false;
- $value->page->languageid = $value->languageid;
- $value->page->load();
- $value->generate();
- $this->setTemplateVar('preview_text',$value->value );
- }
-
- if ( $this->hasRequestVar('addmarkup') )
- {
- $addText = $this->getRequestVar('addtext');
-
- if ( !empty($addText) ) // Nur, wenn ein Text eingegeben wurde
- {
- $addText = $this->getRequestVar('addtext');
-
- if ( $this->hasRequestVar('strong') )
- $value->text .= '*'.$addText.'*';
-
- if ( $this->hasRequestVar('emphatic') )
- $value->text .= '_'.$addText.'_';
-
- if ( $this->hasRequestVar('link') )
- $value->text .= '"'.$addText.'"->"'.$this->getRequestVar('objectid').'"';
- }
-
- if ( $this->hasRequestVar('table') )
- $value->text .= "|$addText | |\n|$addText | |\n|$addText | |\n";
-
- if ( $this->hasRequestVar('list') )
- $value->text .= "\n- ".$addText."\n".'- '.$addText."\n".'- '.$addText."\n";
-
- if ( $this->hasRequestVar('numlist') )
- $value->text .= "\n# ".$addText."\n".'# '.$addText."\n".'# '.$addText."\n";
-
- if ( $this->hasRequestVar('image') )
- $value->text .= '{'.$this->getRequestVar('objectid').'}';
- }
-
- // Ermitteln aller verlinkbaren Objekte (fuer Editor)
- $objects = array();
-
- foreach( Folder::getAllObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- if ( $o->getType() != 'folder' )
- {
- $f = new Folder( $o->parentid );
- $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': ';
- $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
- $objects[ $id ] .= FILE_SEP.$o->name;
- }
- }
- asort($objects);
- $this->setTemplateVar( 'objects' ,$objects );
-
- $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) );
- $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) );
- $this->setTemplateVar( 'html' ,$value->element->html );
- $this->setTemplateVar( 'wiki' ,$value->element->wiki );
- $this->setTemplateVar( 'text' ,$value->text );
- $this->setTemplateVar( 'name' ,$value->element->name );
- $this->setTemplateVar( 'desc' ,$value->element->desc );
- $this->setTemplateVar( 'objectid',$this->page->objectid );
- return;
- }
-
- if ( $this->hasRequestVar('year') ) // Wird ein Datum gespeichert?
- {
- // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden
- if ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') )
- $value->date = strtotime($this->getRequestVar('ansidate') );
- else
- // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen
- $value->date = mktime( $this->getRequestVar('hour' ),
- $this->getRequestVar('minute'),
- $this->getRequestVar('second'),
- $this->getRequestVar('month' ),
- $this->getRequestVar('day' ),
- $this->getRequestVar('year' ) );
- }
- else $value->date = 0; // Datum nicht gesetzt.
-
- $value->text = $this->getRequestVar('text');
-
- $value->page = new Page( $value->objectid );
- $value->page->load();
-
- // Inhalt sofort freigegeben, wenn
- // - Recht vorhanden
- // - Freigabe gewuenscht
- if ( $value->page->hasRight( ACL_RELEASE ) && $this->getRequestVar('release')!='' )
- $value->publish = true;
- else
- $value->publish = false;
-
- // Inhalt speichern
-
- // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt
- // fuer jede Sprache einzeln gespeichert.
- if ( $value->element->allLanguages )
- {
- $project = Session::getProject();
- foreach( $project->getLanguageIds() as $languageid )
- {
- $value->languageid = $languageid;
- $value->save();
- }
- }
- else
- {
- // sonst nur 1x speichern (fuer die aktuelle Sprache)
- $value->save();
- }
-
- $this->page->setTimestamp(); // "Letzte Aenderung" setzen
-
- // Falls ausgewaehlt die Seite sofort veroeffentlichen
- if ( $this->hasRequestVar('publish') )
- $this->callSubAction( 'pubnow' ); // Weiter zum veroeffentlichen
- else
- $this->callSubAction( 'el' ); // Element-Liste anzeigen
- }
-
-
-
- /**
- * Eigenschaften der Seite speichern
- */
- function propPost()
- {
- if ( $this->getRequestVar('name')!='' )
- {
- $this->page->name = $this->getRequestVar('name' ,OR_FILTER_FULL );
- $this->page->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME);
- $this->page->desc = $this->getRequestVar('description',OR_FILTER_FULL );
-
- $this->page->save();
- $this->addNotice($this->page->getType(),$this->page->name,'PROP_SAVED','ok');
-
- if ( $this->hasRequestVar('creationTimestamp') && $this->currentUser->isAdmin )
- $this->page->createDate = $this->getRequestVar('creationTimestamp',OR_FILTER_NUMBER);
- $this->page->setCreationTimestamp();
- }
- else
- {
- $this->addValidationError('name');
- }
- }
-
-
-
- /**
- * Die Eigenschaften der Seite anzeigen
- */
- function propView()
- {
- $this->setTemplateVar('id',$this->page->objectid);
-
- $this->page->public = true;
- $this->page->load();
- $this->page->full_filename();
-
- if ( $this->page->filename == $this->page->objectid )
- $this->page->filename = '';
-
- $this->setTemplateVars( $this->page->getProperties() );
-
- if ( $this->userIsAdmin() )
- {
- $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
- }
-
- $template = new Template( $this->page->templateid );
- $template->load();
- $this->setTemplateVar('template_name',$template->name);
-
- // Alle Ordner ermitteln
-// $this->setTemplateVar('act_folderobjectid',$this->page->parentid);
-//
-// $folders = array();
-// $folder = new Folder( $this->page->parentid );
-
-// foreach( $folder->getOtherFolders() as $oid )
-// {
-// $f = new Folder( $oid );
-// $folders[$oid] = implode( FILE_SEP,$f->parentObjectNames(true,true) );
-// }
-// asort( $folders );
-// $this->setTemplateVar('folder',$folders);
-
- $templates = Array();
- foreach( Template::getAll() as $id=>$name )
- {
- if ( $id != $this->page->templateid )
- $templates[$id]=$name;
- }
- $this->setTemplateVar('templates',$templates);
- }
-
-
-
- /**
- * Die Eigenschaften der Seite anzeigen
- */
- function infoView()
- {
- $this->setTemplateVar('id',$this->page->objectid);
-
- $this->page->public = true;
- $this->page->load();
- $this->page->full_filename();
-
- if ( $this->page->filename == $this->page->objectid )
- $this->page->filename = '';
-
- $this->setTemplateVars( $this->page->getProperties() );
-
- if ( $this->userIsAdmin() )
- {
- $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
- }
-
- $template = new Template( $this->page->templateid );
- $template->load();
- $this->setTemplateVar('template_name',$template->name);
-
-
- }
-
-
-
-
- /**
- * Austauschen der Vorlage vorbereiten
- *
- * Es wird ein Formualr erzeugt, in dem der Benutzer auswaehlen kann, welche Elemente
- * in welches Element uebernommen werden sollen
- */
- public function changetemplateselectelementsView()
- {
- $newTemplateId = $this->getRequestVar( 'newtemplateid' );
-
- if ( $newTemplateId != 0 )
- {
- $this->setTemplateVar('newtemplateid',$newTemplateId );
-
- $oldElements = array();
- $oldTemplate = new Template( $this->page->templateid );
- $newTemplate = new Template( $newTemplateId );
-
- foreach( $oldTemplate->getElementIds() as $elementid )
- {
- $e = new Element( $elementid );
- $e->load();
-
- if ( !$e->isWritable() )
- continue;
-
- $oldElement = array();
- $oldElement['name'] = $e->name.' - '.lang('EL_'.$e->type );
- $oldElement['id' ] = $e->elementid;
-
- $newElements = Array();
- $newElements[0] = lang('ELEMENT_DELETE_VALUES');
-
- foreach( $newTemplate->getElementIds() as $newelementid )
- {
- $ne = new Element( $newelementid );
- $ne->load();
-
- // Nur neue Elemente anbieten, deren Typ identisch ist
- if ( $ne->type == $e->type )
- $newElements[$newelementid] = lang('ELEMENT').': '.$ne->name.' - '.lang('EL_'.$e->type );
- }
- $oldElement['newElementsName'] = 'from'.$e->elementid;
- $oldElement['newElementsList'] = $newElements;
- $oldElements[$elementid] = $oldElement;
- }
- $this->setTemplateVar('elements',$oldElements );
- }
- else
- {
- $this->callSubAction('prop');
- }
- }
-
-
-
- /**
- * Die Vorlage der Seite austauschen
- *
- * Die Vorlage wird ausgetauscht, die Inhalte werden gemaess der Benutzereingaben kopiert
- */
- public function changetemplateselectelementsPost()
- {
- $newTemplateId = $this->getRequestVar('newtemplateid');
- $replaceElementMap = Array();
-
- $oldTemplate = new Template( $this->page->templateid );
- foreach( $oldTemplate->getElementIds() as $elementid )
- $replaceElementMap[$elementid] = $this->getRequestVar('from'.$elementid);
-
- if ( $newTemplateId != 0 )
- {
- $this->page->replaceTemplate( $newTemplateId,$replaceElementMap );
- $this->addNotice('page',$this->page->name,'SAVED',OR_NOTICE_OK);
- }
- else
- $this->addNotice('page',$this->page->name,'NOT_SAVED',OR_NOTICE_WARN);
- }
-
-
-
-
- /**
- * Alle Elemente der Seite anzeigen
- */
- function editView()
- {
- $this->page->public = true;
- $this->page->simple = true;
- $this->page->generate_elements();
-
- $list = array();
-
- // Schleife ueber alle Inhalte der Seite
- foreach( $this->page->values as $id=>$value )
- {
- // Element wird nur angezeigt, wenn es editierbar ist
- if ( $value->element->isWritable() )
- {
- $list[$id] = array();
- $list[$id]['name'] = $value->element->name;
- $list[$id]['pageelementid' ] = $this->page->objectid.'_'.$id;
- $list[$id]['desc'] = $value->element->desc;
- $list[$id]['type'] = $value->element->type;
-
- $list[$id]['archive_count'] = intval($value->getCountVersions());
- if ( $list[$id]['archive_count'] > 0 )
- $list[$id]['archive_url'] = Html::url( 'pageelement','archive',$this->page->id,array('elementid'=>$id) );
-
- // Inhalt anzeigen
- $list[$id]['value'] = $value->value;
- }
- }
-
- $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array('withIcons'=>'1') ) );
- $this->setTemplateVar('properties',$this->page->getProperties() );
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Alle editierbaren Felder in einem Formular bereitstellen
- */
- function formView()
- {
- global $conf_php;
-
- $this->page->public = false;
- $this->page->simple = true;
- $this->page->generate_elements();
-
- $list = array();
-
- foreach( $this->page->values as $id=>$value )
- {
- if ( $value->element->isWritable() )
- {
- $list[$id] = array();
- $list[$id]['name'] = $value->element->name;
- $list[$id]['desc'] = $value->element->desc;
- $list[$id]['type'] = $value->element->type;
- $list[$id]['id' ] = 'id'.$value->element->elementid;
- $list[$id]['saveid'] = 'saveid'.$value->element->elementid;
-
- switch( $value->element->type )
- {
- case 'text':
- case 'longtext':
- $list[$id]['value'] = $value->text;
- break;
-
- case 'date':
- $list[$id]['value'] = date( 'Y-m-d H:i:s',$value->date );
- break;
-
- case 'number':
- $list[$id]['value'] = $value->number / pow(10,$value->element->decimals);
- break;
-
- case 'select':
- $list[$id]['list' ] = $value->element->getSelectItems();
- $list[$id]['value'] = $value->text;
- break;
-
- case 'link':
- $objects = array();
-
- foreach( Folder::getAllObjectIds() as $oid )
- {
- $o = new Object( $oid );
- $o->load();
-
- if ( $o->getType() != 'folder' )
- {
- $f = new Folder( $o->parentid );
- $f->load();
-
- $objects[ $oid ] = lang( $o->getType() ).': ';
- $objects[ $oid ] .= implode( ' » ',$f->parentObjectNames(false,true) );
- $objects[ $oid ] .= ' » '.$o->name;
- }
- }
-
- asort( $objects ); // Sortieren
-
- $list[$id]['list' ] = $objects;
- $list[$id]['value'] = $value->linkToObjectId;
- break;
-
- case 'list':
- $objects = array();
- foreach( Folder::getAllFolders() as $oid )
- {
- $f = new Folder( $oid );
- $f->load();
-
- $objects[ $oid ] = lang( $f->getType() ).': ';
- $objects[ $oid ] .= implode( ' » ',$f->parentObjectNames(false,true) );
- }
-
- asort( $objects ); // Sortieren
-
- $this->setTemplateVar('list' ,$objects);
- $this->setTemplateVar('value',$this->value->linkToObjectId);
-
- break;
- }
- }
- }
-
- $this->setTemplateVar( 'release',$this->page->hasRight(ACL_RELEASE) );
- $this->setTemplateVar( 'publish',$this->page->hasRight(ACL_PUBLISH) );
-
- $this->setWindowMenu( 'elements' );
- $this->setTemplateVar('el',$list);
- }
-
-
-
- /**
- * Seite anzeigen
- */
- function previewView()
- {
- $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid ) );
- }
-
- /**
- * Seite anzeigen
- */
- function showView()
- {
- // Seite definieren
- if ( $this->hasRequestVar('withIcons') )
- $this->page->icons = true;
-
- $this->page->load();
- $this->page->generate();
- $this->page->write();
-
- header('Content-Type: '.$this->page->mimeType().'; charset=UTF-8' );
-
- // HTTP-Header mit Sprachinformation setzen.
- $language = Session::getProjectLanguage();
- header('Content-Language: '.$language->isoCode);
-
- Logger::debug("preview page: ".$this->page->tmpfile() );
-
- // Wenn
- if ( ( config('publish','enable_php_in_page_content')=='auto' && $this->page->template->extension == 'php') ||
- config('publish','enable_php_in_page_content')===true )
- require( $this->page->tmpfile() );
- else
- readfile( $this->page->tmpfile() );
-
- exit();
- }
-
-
-
- /**
- * Den Quellcode der Seite anzeigen
- *
- * Alle HTML-Sonderzeichen werden maskiert
- */
- function src()
- {
- $language = Session::getProjectLanguage();
- $model = Session::getProjectModel();
-
- $this->page->languageid = $language->languageid;
- $this->page->modelid = $model->modelid;
-
- $this->page->withLanguage = config('publish','filename_language') == 'always' || count(Language::count()) > 1;
- $this->page->withModel = config('publish','filename_type' ) == 'always' || count(Model::count() ) > 1;
-
- $this->page->public = true;
- $this->page->load();
-
- $src = $this->page->generate();
-
- // HTML Highlighting
-
- //$src = preg_replace( '|<(.+)( .+)?'.'>|Us' , '<strong><$1</strong>$2<strong>></strong>', $src);
- //$src = preg_replace( '|([a-zA-Z]+)="(.+)"|Us' , '<em>$1</em>=<var>"$2"</var>' , $src);
- $src = htmlentities($src);
-
- $this->setTemplateVar('src',$src);
- }
-
-
-
-
- /**
- * Die Eigenschaften der Seite anzeigen
- */
- function changetemplateView()
- {
- $this->page->public = true;
- $this->page->load();
-
- $this->setTemplateVars( $this->page->getProperties() );
-
- if ( $this->userIsAdmin() )
- {
- $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
- }
-
- $template = new Template( $this->page->templateid );
- $template->load();
- $this->setTemplateVar('template_name',$template->name);
-
- $templates = Array();
- foreach( Template::getAll() as $id=>$name )
- {
- if ( $id != $this->page->templateid )
- $templates[$id]=$name;
- }
- $this->setTemplateVar('templates',$templates);
- }
-
-
-
-
-
- /**
- * Seite veroeffentlichen
- *
- * Es wird ein Formular angzeigt, mit dem die Seite veroeffentlicht
- * werden kann
- */
- function pubView()
- {
- }
-
-
-
- /**
- * Seite veroeffentlichen
- *
- * Die Seite wird generiert.
- */
- function pubPost()
- {
- if ( !$this->page->hasRight( ACL_PUBLISH ) )
- Http::notAuthorized( 'no right for publish' );
-
- Session::close();
-
- $this->page->public = true;
- $this->page->publish();
- $this->page->publish->close();
-
-// foreach( $this->page->publish->publishedObjects as $o )
-// {
-// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
-// }
-
- $this->addNotice( 'page',
- $this->page->fullFilename,
- 'PUBLISHED'.($this->page->publish->ok?'':'_ERROR'),
- $this->page->publish->ok,
- array(),
- $this->page->publish->log );
- }
-
-
- function setWindowMenu( $type ) {
- switch( $type)
- {
- case 'elements':
- $menu = array( array('subaction'=>'el' ,'text'=>'all'),
- array('subaction'=>'form','text'=>'change' ) );
- $this->setTemplateVar('windowMenu',$menu);
- break;
- case 'acl':
- $menu = array( array('subaction'=>'rights' ,'text'=>'show'),
- array('subaction'=>'aclform','text'=>'add' ) );
- $this->setTemplateVar('windowMenu',$menu);
- break;
-
- }
- }
-
-
- /**
- * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
- *
- * @see actionClasses/Action#checkMenu($name)
- */
- function checkMenu( $menu ) {
-
- switch( $menu)
- {
- case 'changetemplate':
- // Template nur austauschbar, wenn es mind. 2 gibt.
- return (!readonly() && count(Template::getAll()) > 1);
-
- case 'aclform':
- return !readonly();
-
- case 'form':
- return !readonly();
-
- default:
- return true;
-
- }
- }
-
-
- /**
- * 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->page->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->page->objectid ] = array('id'=>$this->page->objectid,'name'=>$this->page->name,'type'=>'page','self'=>true,'children'=>&$elementChildren);
-
- $template = new Template( $this->page->templateid );
- $elements = $template->getElementNames();
-
- foreach( $elements as $id=>$name )
- {
- $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/action/PageelementAction.class.php b/action/PageelementAction.class.php
@@ -1,1540 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\User;
-use cms\model\Value;
-use cms\model\Element;
-use cms\model\Template;
-use cms\model\Page;
-use cms\model\Folder;
-use cms\model\Object;
-use Html;
-use Http;
-use Session;
-use Transformer;
-use \Text;
-
-// 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 zum Bearbeiten eines Seitenelementes
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class PageelementAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $defaultSubAction = 'edit';
-
-
- /**
- * Enthaelt das Seitenobjekt
- * @type Object
- */
- var $page;
-
- /**
- * Enthaelt das Elementobjekt
- * @type Object
- */
- var $element;
-
-
- /**
- * Enth�lt den Inhalt
- *
- * @var Object
- */
- var $value;
-
-
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->value = new Value();
-
- $id = $this->getRequestVar('id');
- $ids = explode('_',$id);
- if ( count($ids) > 1 )
- {
- list( $pageid, $elementid ) = $ids;
- }
- else
- {
- $pageid = $this->getRequestId();
- $elementid = $this->getRequestVar('elementid');
- }
-
- if ( $pageid != 0 )
- {
- $this->page = new Page( $pageid );
- $this->page->load();
- }
-
- if ( $elementid != 0 )
- {
- $this->elementid = $elementid;
- $this->element = new Element( $elementid );
- }
- }
-
-
-
- /**
- * Anzeigen des Element-Inhaltes.
- */
- public function propView()
- {
- Http::noContent();
-
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->page = $this->page;
- $this->value->simple = false;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
- $this->value->load();
-
- $this->setTemplateVar('name' ,$this->value->element->name );
- $this->setTemplateVar('description' ,$this->value->element->desc );
- $this->setTemplateVar('elementid' ,$this->value->element->elementid);
- $this->setTemplateVar('element_type',$this->value->element->type );
-
- $user = new User( $this->value->lastchangeUserId );
- $user->load();
- $this->setTemplateVar('lastchange_user',$user);
- $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp);
-
- $t = new Template( $this->page->templateid );
- $t->load();
- $this->setTemplateVar('template_name',$t->name );
- $this->setTemplateVar('template_url' ,Html::url('template','prop',$t->templateid) );
-
- $this->setTemplateVar('element_name' ,$this->value->element->name );
- $this->setTemplateVar('element_url' ,Html::url('element','name',$this->value->element->elementid) );
-
- }
-
-
-
- /**
- * Anzeigen des Element-Inhaltes.
- */
- public function infoView()
- {
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->page = $this->page;
- $this->value->simple = false;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
- $this->value->load();
-
- $this->setTemplateVar('name' ,$this->value->element->name );
- $this->setTemplateVar('description' ,$this->value->element->desc );
- $this->setTemplateVar('elementid' ,$this->value->element->elementid);
- $this->setTemplateVar('element_type',$this->value->element->type );
-
- $user = new User( $this->value->lastchangeUserId );
- $user->load();
- $this->setTemplateVar('lastchange_user',$user->getProperties());
- $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp);
-
- $t = new Template( $this->page->templateid );
- $t->load();
- $this->setTemplateVar('template_name',$t->name );
- $this->setTemplateVar('template_id' ,$t->templateid );
-
- $this->setTemplateVar('element_name' ,$this->value->element->name );
- $this->setTemplateVar('element_id' ,$this->value->element->elementid );
-
- }
-
-
-
- /**
- * Anzeigen des Element-Inhaltes.
- */
- public function structureView()
- {
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->page = $this->page;
- $this->value->simple = false;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
- $this->value->load();
-
- if ( $this->value->element->type == 'longtext' && $this->value->element->wiki )
- {
- $this->setTemplateVar('text',$this->value->text);
- }
-
- }
-
-
-
- /**
- * Normaler Editiermodus.
- *
- * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
- */
- public function editView()
- {
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
-
- if ( intval($this->value->valueid)!=0 )
- $this->value->loadWithId();
- else
- $this->value->load();
-
- $this->setTemplateVar('name' ,$this->value->element->name );
- $this->setTemplateVar('desc' ,$this->value->element->desc );
- $this->setTemplateVar('elementid',$this->value->element->elementid);
- $this->setTemplateVar('type' ,$this->value->element->type );
- $this->setTemplateVar('value_time',time() );
-
-
- $this->value->page = new Page( $this->page->objectid );
- $this->value->page->languageid = $this->value->languageid;
- $this->value->page->load();
-
- $this->setTemplateVar( 'objectid',$this->value->page->objectid );
-
- if ( $this->value->page->hasRight(ACL_RELEASE) )
- $this->setTemplateVar( 'release',true );
- if ( $this->value->page->hasRight(ACL_PUBLISH) )
- $this->setTemplateVar( 'publish',false );
-
- $funktionName = 'edit'.$this->value->element->type;
-
- if ( ! method_exists($this,$funktionName) )
- Http::serverError('Method does not exist: PageElementAction#'.$funktionName );
-
- $this->$funktionName(); // Aufruf der Funktion "edit<Elementtyp>()".
- }
-
-
-
- /**
- * Vorschau.
- */
- public function previewView()
- {
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
- $this->value->public = true;
- $this->value->simple = true;
-
- if ( intval($this->value->valueid)!=0 )
- $this->value->loadWithId();
- else
- $this->value->load();
-
-
- $this->value->page = new Page( $this->page->objectid );
- $this->value->page->languageid = $this->value->languageid;
- $this->value->page->load();
-
- $this->value->generate();
- $this->setTemplateVar('preview' ,$this->value->value );
- }
-
-
-
- /**
- * Datum bearbeiten.
- *
- */
- private function editdate()
- {
- global $conf;
- $date = $this->value->date;
-
- // Wenn Datum nicht vorhanden...
- if ( $date == 0 )
- // ... dann aktuelles Datum (gerundet auf 1 Minute) verwenden
- $date = intval(time()/60)*60;
-
- $this->setTemplateVar('ansidate',date( 'Y-m-d H:i:s',$date ) );
- $this->setTemplateVar('date' ,$date);
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
-
-
- // Wenn Datum nicht vorhanden, dann aktuelles Datum verwenden
- if ( $this->hasRequestVar('year') )
- {
- $date = mktime( $this->getRequestVar('hour'),
- $this->getRequestVar('minute'),
- $this->getRequestVar('second'),
- $this->getRequestVar('month'),
- $this->getRequestVar('day'),
- $this->getRequestVar('year') );
- }
- $year = intval(date('Y',$date));
- $month = intval(date('n',$date));
- $day = intval(date('j',$date));
- $hour = intval(date('G',$date));
- $minute = intval(date('i',$date));
- $second = intval(date('s',$date));
- $this->setTemplateVar('year' ,$year );
- $this->setTemplateVar('month' ,$month );
- $this->setTemplateVar('day' ,$day );
- $this->setTemplateVar('hour' ,$hour );
- $this->setTemplateVar('minute',$minute );
- $this->setTemplateVar('second',$second );
-
- $this->setTemplateVar('monthname',lang('DATE_MONTH'.date('n',$date)) );
- $this->setTemplateVar('yearname' ,date('Y',$date) );
-
-
- // Zwischenberechnungen
- $heuteTag = intval(date('j'));
- $monatLetzterTag = intval(date('t',$date));
- $monatErsterDatum = $date-(($day-1)*86400);
- $wocheNr = date( 'W',$monatErsterDatum );
- $wochentagErster = date( 'w',$monatErsterDatum );
-
-
- $weekdayOffset = intval($conf['editor']['calendar']['weekday_offset']);
-
- // Alle Wochentage
- $weekdays = array();
- for ( $i=0; $i<=6; $i++ )
- {
- $wday = ($i+$weekdayOffset)%7;
- $weekdays[$wday] = lang('DATE_WEEKDAY'.$wday);
- }
-
- $this->setTemplateVar('weekdays',$weekdays);
-
-
- $monat = array();
- $d = 0;
- $begin = false;
- do
- {
- $woche = array(); // Neue Woche
-
- for ( $i=0; $i<=6; $i++ ) // Alle Wochentage der Woche
- {
- $wday = ($i+$weekdayOffset)%7;
- $tag = array(); // Neuer Tag
-
- if (!$begin && $wday == $wochentagErster)
- $begin = true;
-
- if ( $begin && $d < $monatLetzterTag )
- {
- $d++;
- $tag['nr'] = $d;
- $tag['today'] = ($year==date('Y') && $month==date('n') && $d==$heuteTag);
- if ($d != $day)
- $tag['url'] = Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>$year ,
- 'month' =>$month ,
- 'day' =>$d ,
- 'hour' =>$hour ,
- 'minute'=>$minute,
- 'second'=>$second ) );
- else
- $tag['url'] = '';
- }
- else
- {
- $tag['nr' ]='';
- $tag['today' ]=false;
- $tag['url' ]='';
- }
- $woche[] = $tag;
-
- }
- $monat[$wocheNr] = $woche;
- $wocheNr++;
- }
- while( $d < $monatLetzterTag-1 );
- // Html::debug($monat);
- $this->setTemplateVar('weeklist',$monat);
-
- $this->setTemplateVar('actdate' ,date( lang('DATE_FORMAT'),$date ) );
- $this->setTemplateVar('todayurl',Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>date('Y'),
- 'month' =>date('n'),
- 'day' =>date('j'),
- 'hour' =>date('G'),
- 'minute'=>date('i'),
- 'second'=>date('s') ) ) );
- $this->setTemplateVar('lastyearurl',Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>$year-1,
- 'month' =>$month ,
- 'day' =>$day ,
- 'hour' =>$hour ,
- 'minute'=>$minute,
- 'second'=>$second ) ) );
- $this->setTemplateVar('nextyearurl',Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>$year+1 ,
- 'month' =>$month ,
- 'day' =>$day ,
- 'hour' =>$hour ,
- 'minute'=>$minute,
- 'second'=>$second ) ) );
- $this->setTemplateVar('lastmonthurl',Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>$year ,
- 'month' =>$month-1,
- 'day' =>$day ,
- 'hour' =>$hour ,
- 'minute'=>$minute,
- 'second'=>$second ) ) );
- $this->setTemplateVar('nextmonthurl',Html::url( 'pageelement','edit','',
- array('elementid'=>$this->element->elementid,'mode'=>'edit',
- 'year' =>$year ,
- 'month' =>$month+1,
- 'day' =>$day ,
- 'hour' =>$hour ,
- 'minute'=>$minute,
- 'second'=>$second ) ) );
-
- // $this->setTemplateVar('date' ,$date);
-
-
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
-
-
- $all_years = array();
- $all_months = array();
- $all_days = array();
- $all_hours = array();
- $all_minutes = array();
- for( $i=$year-100; $i<=$year+100;$i++ ) $all_years [$i] = $i;
- for( $i=1; $i<=12; $i++ ) $all_months [$i] = lang('DATE_MONTH'.$i);
- for( $i=1; $i<=31; $i++ ) $all_days [$i] = str_pad($i,2,'0',STR_PAD_LEFT);
- for( $i=0; $i<=23; $i++ ) $all_hours [$i] = str_pad($i,2,'0',STR_PAD_LEFT);
- for( $i=0; $i<=59; $i++ ) $all_minutes[$i] = str_pad($i,2,'0',STR_PAD_LEFT);
-
- $this->setTemplateVar('all_years' ,$all_years );
- $this->setTemplateVar('all_months' ,$all_months );
- $this->setTemplateVar('all_days' ,$all_days );
- $this->setTemplateVar('all_hours' ,$all_hours );
- $this->setTemplateVar('all_minutes',$all_minutes);
- $this->setTemplateVar('all_seconds',$all_minutes);
- }
-
-
-
- /**
- * Verkn�pfung bearbeiten.
- *
- */
- private function editlink()
- {
- $this->setTemplateVar('rootfolderid',Folder::getRootFolderId() );
-
- // Ermitteln, welche Objekttypen verlinkt werden d�rfen.
- $type = $this->value->element->subtype;
-
- if ( substr($type,0,5) == 'image' )
- $type = 'file';
-
- if ( !in_array($type,array('file','page','link','folder')) )
- $types = array('file','page','link'); // Fallback: Der Link kann auf Seiten,Dateien und Verknüpfungen zeigen
- else
- $types = array($type); // gewünschten Typ verwenden
-
- $objects = array();
-
- foreach( Folder::getAllObjectIds($types) as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- // if ( in_array( $o->getType(),$types ))
- // {
- $f = new Folder( $o->parentid );
- // $f->load();
-
- $objects[ $id ] = lang( $o->getType() ).': ';
- $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
- $objects[ $id ] .= FILE_SEP.$o->name;
- // }
- }
-
- asort( $objects ); // Sortieren
-
- $this->setTemplateVar('objects' ,$objects);
- $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
-
- $this->setTemplateVar('types',implode(',',$types));
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else
- $this->setTemplateVar('old_pageaction','show' );
- }
-
-
-
- function linkView()
- {
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = $this->page->pageid;
- $this->value->element = &$this->element;
- $this->value->element->load();
- $this->value->publish = false;
- $this->value->load();
-
- $this->setTemplateVar('name' ,$this->value->element->name );
- $this->setTemplateVar('desc' ,$this->value->element->desc );
-
- $this->setTemplateVar('rootfolderid' ,Folder::getRootFolderId() );
-
- // Ermitteln, welche Objekttypen verlinkt werden d�rfen.
- if ( empty($this->value->element->subtype) )
- $types = array('page','file','link'); // Fallback: Alle erlauben :)
- else
- $types = explode(',',$this->value->element->subtype );
-
- $objects = array();
-
- $objects[ 0 ] = lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt"
-
-
- $t = new Template( $this->page->templateid );
-
- foreach( $t->getDependentObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- // if ( in_array( $o->getType(),$types ))
- // {
- $f = new Folder( $o->parentid );
- // $f->load();
-
- $objects[ $id ] = lang( $o->getType() ).': ';
- $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
- $objects[ $id ] .= FILE_SEP.$o->name;
- // }
- }
-
- asort( $objects ); // Sortieren
-
- $this->setTemplateVar('objects' ,$objects);
- $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
-
- $this->value->page = new Page( $this->page->objectid );
- $this->value->page->languageid = $this->value->languageid;
- $this->value->page->load();
-
- $this->setTemplateVar( 'release',$this->value->page->hasRight(ACL_RELEASE) );
- $this->setTemplateVar( 'publish',$this->value->page->hasRight(ACL_PUBLISH) );
-
- $this->setTemplateVar( 'objectid',$this->value->page->objectid );
- }
-
-
-
- /**
- * Auswahlbox.
- *
- */
- private function editselect()
- {
- $this->setTemplateVar( 'items',$this->value->element->getSelectItems() );
- $this->setTemplateVar( 'text' ,$this->value->text );
-
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
- }
-
-
-
- /**
- * Einf�gen-Element.
- *
- */
- private function editlist()
- {
- $this->editinsert();
- }
-
-
-
- /**
- * Einf�gen-Element.
- *
- */
- private function editinsert()
- {
- // Auswahl ueber alle Elementtypen
- $objects = array();
- //Änderung der möglichen Types
- $types = array('file','page','link');
- $objects[ 0 ] = lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt"
- //Auch Dateien dazu
- foreach( Folder::getAllObjectIds($types) as $id )
- {
- $f = new Folder( $id );
- $f->load();
-
- $objects[ $id ] = lang( $f->getType() ).': ';
- $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
- }
-
- foreach( Folder::getAllFolders() as $id )
- {
- $f = new Folder( $id );
- $f->load();
-
- $objects[ $id ] = lang( $f->getType() ).': ';
- $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
- }
-
- asort( $objects ); // Sortieren
-
- $this->setTemplateVar('objects' ,$objects);
- $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
-
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
- }
-
-
-
- /**
- * Zahl bearbeiten.
- *
- */
- private function editnumber()
- {
- $this->setTemplateVar('number',$this->value->number / pow(10,$this->value->element->decimals) );
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
- }
-
-
- /**
- * Ein Element der Seite bearbeiten
- *
- * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
- */
- private function editlongtext()
- {
- if ($this->value->element->wiki)
- $this->setTemplateVar( 'editor','wiki' );
- elseif ($this->value->element->html)
- $this->setTemplateVar( 'editor','html' );
- else
- $this->setTemplateVar( 'editor','text' );
-
- if ( !isset($this->templateVars['text']))
- // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits
- // einen Text eingegeben hat (Vorschaufunktion).
- $this->setTemplateVar( 'text',$this->linkifyOIDs( $this->value->text ) );
-
- /*
- *
- if (! $this->isEditMode() )
- {
- $this->value->generate(); // Inhalt erzeugen.
- $this->setTemplateVar('text',$this->linkifyOIDs( $this->value->value ));
- }
- */
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
-
-
-
- if ( $this->element->wiki )
- {
- $project = Session::getProject();
- $languages = $project->getLanguages();
-
- if ( count($languages) > 1 )
- {
- $languages[$this->value->languageid] = $languages[$this->value->languageid].' *';
- $this->setTemplateVar('languages',$languages);
- }
-
- if ( $this->hasRequestVar('otherlanguageid') )
- {
- $lid = $this->getRequestVar('otherlanguageid');
- $otherValue = new Value();
- $otherValue->languageid = $lid;
- $otherValue->pageid = $this->value->pageid;
- $otherValue->element = $this->value->element;
- $otherValue->elementid = $this->value->elementid;
- $otherValue->publish = $this->value->publish;
- $otherValue->load();
- $this->setTemplateVar('languagetext' ,wordwrap($otherValue->text,100) );
- $this->setTemplateVar('languagename' ,$languages[$lid] );
- $this->setTemplateVar('otherlanguageid',$lid );
- }
-
- if ( !isset($this->templateVars['text']))
- // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits
- // einen Text eingegeben hat (Vorschaufunktion).
- $this->setTemplateVar( 'text',$this->value->text );
- }
-
- }
-
-
-
- /**
- * Ein Element der Seite bearbeiten
- *
- * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
- */
- private function edittext()
- {
- $this->setTemplateVar( 'text',$this->value->text );
-
- if ( $this->getSessionVar('pageaction') != '' )
- $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
- else $this->setTemplateVar('old_pageaction','show' );
- }
-
-
-
- /**
- * Wiederherstellung eines alten Inhaltes.
- */
- public function usePost()
- {
- $this->value->valueid = $this->getRequestVar('valueid');
- $this->value->loadWithId();
- $this->value->element = new Element( $this->value->elementid );
-
- if ( $this->value->pageid != $this->page->pageid )
- Http::serverError( 'Cannot find value','page-id does not match' );
-
- // Pruefen, ob Berechtigung zum Freigeben besteht
- //$this->value->release = $this->page->hasRight(ACL_RELEASE);
- $this->value->release = false;
-
- // Inhalt wieder herstellen, in dem er neu gespeichert wird.
- $this->value->save();
-
- $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_USE_FROM_ARCHIVE',OR_NOTICE_OK);
- }
-
-
-
- /**
- * Freigeben eines Inhaltes
- */
- public function releasePost()
- {
- $this->value->valueid = intval($this->getRequestVar('valueid'));
- $this->value->loadWithId();
-
- if ( $this->value->pageid != $this->page->pageid )
- die( 'cannot release, bad page' );
-
- // Pruefen, ob Berechtigung zum Freigeben besteht
- if ( !$this->page->hasRight(ACL_RELEASE) )
- Http::notAuthorized( 'Cannot release','no right' );
-
- // Inhalt freigeben
- $this->value->release();
-
- $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_RELEASED',OR_NOTICE_OK);
- }
-
-
- /**
- * Erzeugt eine Liste aller Versionsst?nde zu diesem Inhalt
- */
- public function historyView()
- {
- $this->page->public = true;
- $this->page->simple = true;
- $this->page->load();
- $this->value->page = &$this->page;
-
- $this->value->simple = true;
- $language = Session::getProjectLanguage();
- $this->value->languageid = $language->languageid;
- $this->value->objectid = $this->page->objectid;
- $this->value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
- $this->value->element = &$this->element;
- $this->value->element->load();
-
- $list = array();
- // $version_list = array();
- $lfd_nr = 0;
-
- foreach( $this->value->getVersionList() as $value )
- {
- $lfd_nr++;
- $value->element = &$this->element;
- $value->page = &$this->page;
- $value->simple = true;
- $value->generate();
-
-
- // $date = date( lang('DATE_FORMAT'),$value->lastchangeTimeStamp);
-
- // if ( in_array( $this->element->type,array('text','longtext') ) )
- // $version_list[ $value->valueid ] = '('.$lfd_nr.') '.$date;
-
- $zeile = array( 'value' => Text::maxLaenge( 50,$value->value),
- 'objectid' => $this->page->objectid,
- 'date' => $value->lastchangeTimeStamp,
- 'lfd_nr' => $lfd_nr,
- 'id' => $value->valueid,
- 'valueid' => $value->valueid,
- 'user' => $value->lastchangeUserName );
-
- // Nicht aktive Inhalte k�nnen direkt bearbeitet werden und sind
- // nach dem Speichern dann wieder aktiv (nat�rlich als n�chster/neuer Inhalt)
- if ( ! $value->active )
- $zeile['useUrl'] = Html::url('pageelement','usevalue',$this->page->objectid,array('valueid' =>$value->valueid,'mode'=>'edit'));
-
- // Freigeben des Inhaltes.
- // Nur das aktive Inhaltselement kann freigegeben werden. Nat�rlich auch nur,
- // wenn es nicht schon freigegeben ist.
- if ( ! $value->publish && $value->active )
- $zeile['releaseUrl'] = Html::url('pageelement','release',$this->page->objectid,array('valueid' =>$value->valueid ));
-
- $zeile['public'] = $value->publish;
- $zeile['active'] = $value->active;
-
- $list[$lfd_nr] = $zeile;
-
- }
-
- if ( in_array( $this->value->element->type, array('longtext') ) && $lfd_nr >= 2 )
- {
- $this->setTemplateVar('compareid',$list[$lfd_nr-1]['id']);
- $this->setTemplateVar('withid' ,$list[$lfd_nr ]['id']);
- }
-
- $this->setTemplateVar('name' ,$this->element->name);
- $this->setTemplateVar('el' ,$list );
- }
-
-
- /**
- * Vergleicht 2 Versionen eines Inhaltes
- */
- function diffView()
- {
- $value1id = $this->getRequestVar('compareid');
- $value2id = $this->getRequestVar('withid' );
-
- // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen
- if ( $value1id == $value2id )
- {
- $this->addValidationError('compareid' );
- $this->addValidationError('withid' ,'');
- $this->callSubAction('archive');
- return;
- }
-
- // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen
- if ( $value1id > $value2id )
- list($value1id,$value2id) = array( $value2id,$value1id );
-
-
- $value1 = new Value( $value1id );
- $value2 = new Value( $value2id );
- $value1->valueid = $value1id;
- $value2->valueid = $value2id;
-
- $value1->loadWithId();
- $value2->loadWithId();
-
- $this->setTemplateVar('date_left' ,$value1->lastchangeTimeStamp);
- $this->setTemplateVar('date_right',$value2->lastchangeTimeStamp);
-
- $text1 = explode("\n",$value1->text);
- $text2 = explode("\n",$value2->text);
-
- // Unterschiede feststellen.
- $res_diff = Text::diff($text1,$text2);
-
- list( $text1,$text2 ) = $res_diff;
-
- $diff = array();
- $i = 0;
- while( isset($text1[$i]) || isset($text2[$i]) )
- {
- $line = array();
-
- if ( isset($text1[$i]['text']) )
- $line['left'] = $text1[$i];
-
- if ( isset($text2[$i]['text']) )
- $line['right'] = $text2[$i];
-
- $i++;
- $diff[] = $line;
- }
- $this->setTemplateVar('diff',$diff );
- }
-
-
-
- /**
- * Ein Element der Seite speichern.
- */
- public function editPost()
- {
- $this->element->load();
- $type = $this->element->type;
-
- if ( empty($type))
- die('Error: No element type available.');
-
- $funktionName = 'save'.$type;
-
- $this->$funktionName(); // Aufruf Methode "save<ElementTyp>()"
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savetext()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- if ( $this->hasRequestVar('linkobjectid') )
- $value->linkToObjectId = $this->getRequestVar('linkobjectid');
- else
- $value->text = $this->getRequestVar('text','raw');
-
- $this->afterSave($value);
- }
-
-
-
- /**
- * Nach dem Speichern weitere Dinge ausfuehren.<br>
- * - Inhalt freigeben<br>
- * - Seite veroeffentlichen<br>
- * - Inhalt fuer andere Sprachen speichern<br>
- * - Hinweis ueber erfolgtes Speichern ausgeben<br>
- * <br>
- * Nicht zu verwechseln mit <i>Aftershave</i> :)
- */
- private function afterSave( $value )
- {
- $value->page = new Page( $value->objectid );
- $value->page->load();
-
-
- // Inhalt sofort freigegeben, wenn
- // - Recht vorhanden
- // - Freigabe gewuenscht
- if ( $value->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') )
- $value->publish = true;
- else
- $value->publish = false;
-
- // Up-To-Date-Check
- $lastChangeTime = $value->getLastChangeTime();
- if ( $lastChangeTime > $this->getRequestVar('value_time') )
- {
- $this->addNotice('pageelement',$value->element->name,'CONCURRENT_VALUE_CHANGE',OR_NOTICE_WARN,array('last_change_time'=>date(lang('DATE_FORMAT'),$lastChangeTime)));
- }
-
- // Inhalt speichern
-
- // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt
- // fuer jede Sprache einzeln gespeichert.
- if ( $value->element->allLanguages )
- {
- $project = Session::getProject();
- foreach( $project->getLanguageIds() as $languageid )
- {
- $value->languageid = $languageid;
- $value->save();
- }
- }
- else
- {
- // sonst nur 1x speichern (fuer die aktuelle Sprache)
- $value->save();
- }
-
- $this->addNotice('pageelement',$value->element->name,'SAVED',OR_NOTICE_OK);
- $this->page->setTimestamp(); // "Letzte Aenderung" setzen
-
- // Falls ausgewaehlt die Seite sofort veroeffentlichen
- if ( $value->page->hasRight( ACL_PUBLISH ) && $this->hasRequestVar('publish') )
- {
- $this->page->publish();
- $this->addNotice('pageelement',$value->element->name,'PUBLISHED',OR_NOTICE_OK);
- }
- }
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savelongtext()
- {
- global $conf;
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
-
- if ( $this->hasRequestVar('linkobjectid') )
- $value->linkToObjectId = $this->getRequestVar('linkobjectid');
- else
- $value->text = $this->compactOIDs( $this->getRequestVar('text','raw') );
-
- // Vorschau anzeigen
- if ( $this->hasRequestVar('preview' ) ||
- $this->hasRequestVar('addmarkup') )
- {
- $inputText = $this->getRequestVar('text','raw');
-
- if ( $this->hasRequestVar('preview') )
- {
- $value->page = $this->page;
- $value->simple = false;
- $value->page->languageid = $value->languageid;
- $value->page->load();
- $value->generate();
- $this->setTemplateVar('preview',$value->value );
- }
-
- if ( $this->hasRequestVar('addmarkup') )
- {
- $conf_tags = $conf['editor']['text-markup'];
-
- if ( $this->hasRequestVar('addtext') ) // Nur, wenn ein Text eingegeben wurde
- {
- $addText = $this->getRequestVar('addtext','raw');
-
- if ( $this->hasRequestVar('strong') )
- $inputText .= $conf_tags['strong-begin'].$addText.$conf_tags['strong-end'];
-
- if ( $this->hasRequestVar('emphatic') )
- $inputText .= $conf_tags['emphatic-begin'].$addText.$conf_tags['emphatic-end'];
-
- if ( $this->hasRequestVar('link') )
- $inputText .= '"'.$addText.'"'.$conf_tags['linkto'].'"'.$this->parseOID($this->getRequestVar('objectid')).'"';
- }
-
- if ( $this->hasRequestVar('table') )
- $inputText .= "\n".
- $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n".
- $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n".
- $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n";
-
- if ( $this->hasRequestVar('list') )
- $inputText .= "\n".
- $conf_tags['list-unnumbered'].' '.$addText."\n".
- $conf_tags['list-unnumbered'].' '.$addText."\n".
- $conf_tags['list-unnumbered'].' '.$addText."\n";
-
- if ( $this->hasRequestVar('numlist') )
- $inputText .= "\n".
- $conf_tags['list-numbered'].' '.$addText."\n".
- $conf_tags['list-numbered'].' '.$addText."\n".
- $conf_tags['list-numbered'].' '.$addText."\n";
-
- if ( $this->hasRequestVar('image') )
- $inputText .= $conf_tags['image-begin'].$this->parseOID($this->getRequestVar('objectid')).$conf_tags['image-end'];
- }
-
- // Ermitteln aller verlinkbaren Objekte (fuer Editor)
- /*
- $objects = array();
-
- foreach( Folder::getAllObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->load();
-
- if ( $o->getType() != 'folder' )
- {
- $f = new Folder( $o->parentid );
- $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': ';
- $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
- $objects[ $id ] .= FILE_SEP.$o->name;
- }
- }
- asort($objects);
- $this->setTemplateVar( 'objects' ,$objects );
- */
-
- $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) );
- $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) );
- $this->setTemplateVar( 'html' ,$value->element->html );
- $this->setTemplateVar( 'wiki' ,$value->element->wiki );
- $this->setTemplateVar( 'text' ,$inputText );
- $this->setTemplateVar( 'name' ,$value->element->name );
- $this->setTemplateVar( 'desc' ,$value->element->desc );
- $this->setTemplateVar( 'objectid',$this->page->objectid );
-
- $this->setTemplateVar( 'mode' ,'edit' );
- }
- else
- {
- $this->afterSave($value);
- }
-
- }
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savedate()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- if ( $this->hasRequestVar('linkobjectid') )
- $value->linkToObjectId = $this->getRequestVar('linkobjectid');
- elseif ( $this->hasRequestVar('date') )
- // Wenn ein Timestamp übergeben wurde, dann dieses verwenden
- $value->date = $this->getRequestVar('date');
- elseif ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') )
- // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden
- $value->date = strtotime($this->getRequestVar('ansidate') );
- else
- // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen
- $value->date = mktime( $this->getRequestVar('hour' ),
- $this->getRequestVar('minute'),
- $this->getRequestVar('second'),
- $this->getRequestVar('month' ),
- $this->getRequestVar('day' ),
- $this->getRequestVar('year' ) );
-
- $this->afterSave($value);
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function saveselect()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- $value->text = $this->getRequestVar('text');
-
- $this->afterSave($value);
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savelink()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- if ( $this->hasRequestVar('linkurl') )
- $value->linkToObjectId = $this->parseOID($this->getRequestVar('linkurl'));
- else
- $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
-
- $this->afterSave($value);
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savelist()
- {
- $this->saveinsert();
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function saveinsert()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
-
- $this->afterSave($value);
- }
-
-
-
- /**
- * Element speichern
- *
- * Der Inhalt eines Elementes wird abgespeichert
- */
- private function savenumber()
- {
- $value = new Value();
- $language = Session::getProjectLanguage();
- $value->languageid = $language->languageid;
- $value->objectid = $this->page->objectid;
- $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
-
- if ( $this->hasRequestVar('elementid') )
- $value->element = new Element( $this->getRequestVar('elementid') );
- else
- $value->element = Session::getElement();
-
- $value->element->load();
- $value->publish = false;
- $value->load();
-
- if ( $this->hasRequestVar('linkobjectid') )
- $value->linkToObjectId = $this->getRequestVar('linkobjectid');
- else
- $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals);
-
- $this->afterSave($value);
- }
-
-
- function exportlongtext()
- {
- $types = array();
-
- foreach( array('odf','plaintext') as $type )
- {
- $types[$type] = lang('FILETYPE_'.$type);
- }
-
- $this->setTemplateVar('types',$types);
- }
-
-
- function importlongtext()
- {
- $types = array();
-
- foreach( array('odf','plaintext') as $type )
- {
- $types[$type] = lang('FILETYPE_'.$type);
- }
- $this->setTemplateVar('types',$types);
- }
-
-
- function doexportlongtext()
- {
- $type = $this->getRequestVar('type');
- switch($type)
- {
- case 'odf':
-
- // Angabe Content-Type
- // header('Content-Type: '.$this->file->mimeType());
- // header('X-File-Id: '.$this->file->fileid);
-
- // header('Content-Disposition: inline; filename='.$this->id.'.odt');
- header('Content-Transfer-Encoding: binary');
- // header('Content-Description: '.$this->file->name);
-
- echo $this->createOdfDocument();
-
- exit;
-
- default:
- }
-
- exit;
- }
-
-
- /**
- * ODF erzeugen.<br>
- * vorerst ZURUECKGESTELLT!
- *
- * @return unknown
- */
- private function createOdfDocument()
- {
- // TODO: ODF ist nicht ganz ohne.
- $transformer = new Transformer();
- $transformer->text = $this->value->text;
- $transformer->type = 'odf';
- $transformer->transform();
- return $transformer->text;
- }
-
-
-
- /**
- * Men�eintr�ge aktivieren/deaktivieren.
- *
- * @param String $name
- * @return boolean
- */
- function checkMenu( $name )
- {
- $type = $this->element->type;
-
- switch( $name )
- {
- case 'edit':
- case 'prop':
- return true;
-
- case 'archive':
- // Archiv ist nur verf�gbar, wenn es mind. 1 Version des Inhaltes gibt.
-
- if ( $this->subActionName!='diff' && is_object($this->value) )
- return $this->value->getCountVersions() > 0;
- else
- return true;
-
- case 'link':
- // Verkn�pfung zu anderen Seiten ist nur m�glich f�r
- // Datum, Text, Textabsatz, Ganzzahl.
- return in_array($type,array('date','text','longtext','number'));
-
- default:
- return false;
- }
- }
-
-
- function linkifyOIDs( $text )
- {
- foreach( Text::parseOID($text) as $oid=>$t )
- {
- $url = $this->page->path_to_object($oid);
- $text = str_replace($t,'"'.$url.'"',$text);
- }
-
- return $text;
- }
-
-
- function compactOIDs( $text )
- {
- foreach( Text::parseOID($text) as $oid=>$t )
- {
- $text = str_replace($t,'"?__OID__'.$oid.'__"',$text);
- }
-
- return $text;
- }
-
-
- function parseOID( $text )
- {
- $treffer = array();
- preg_match_all('/(.*)__OID__([0-9]+)__(.*)/', $text, $treffer,PREG_SET_ORDER);
-
- $oid = $treffer[0][2];
-
- if ( !empty($oid) )
- return $oid;
- else
- return intval($text);
- }
-
- /**
- * Seite veroeffentlichen
- *
- * Es wird ein Formular angzeigt, mit dem die Seite veroeffentlicht
- * werden kann
- */
- public function pubView()
- {
- }
-
-
-
- /**
- * Seite veroeffentlichen
- *
- * Die Seite wird generiert.
- */
- function pubPost()
- {
- if ( !$this->page->hasRight( ACL_PUBLISH ) )
- Http::notAuthorized( 'no right for publish' );
-
- $this->page->public = true;
- $this->page->publish();
- $this->page->publish->close();
-
-// foreach( $this->page->publish->publishedObjects as $o )
-// {
-// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
-// }
-
- $this->addNotice( 'page',
- $this->page->fullFilename,
- 'PUBLISHED'.($this->page->publish->ok?'':'_ERROR'),
- $this->page->publish->ok,
- array(),
- $this->page->publish->log );
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/action/ProfileAction.class.php b/action/ProfileAction.class.php
@@ -1,313 +0,0 @@
-<?php
-
-namespace cms\action;
-
-
-// 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.
-use LogicException;
-use Mail;
-use security\Base2n;
-use \Session;
-
-
-/**
- * Action-Klasse zum Bearbeiten des Benutzerprofiles
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class ProfileAction extends Action
-{
- public $security = SECURITY_USER;
-
- private $user;
- var $defaultSubAction = 'edit';
-
- /**
- * Konstruktor.
- * Setzen der Benutzer-Objektes.
- */
- function __construct()
- {
- $this->user = Session::getUser();
- }
-
-
- /**
- * Abspeichern des Profiles
- */
- function editPost()
- {
- $this->user->fullname = $this->getRequestVar('fullname');
- $this->user->tel = $this->getRequestVar('tel' );
- $this->user->desc = $this->getRequestVar('desc' );
- $this->user->style = $this->getRequestVar('style' );
- $this->user->language = $this->getRequestVar('language');
- $this->user->timezone = $this->getRequestVar('timezone');
- $this->user->hotp = $this->hasRequestVar('hotp' );
- $this->user->totp = $this->hasRequestVar('totp' );
-
-
- $this->setStyle( $this->user->style ); // Style sofort anwenden
- Session::setUser( $this->user );
-
- if ( !empty($this->user->fullname) )
- {
- $this->user->save();
- $this->setStyle($this->user->style);
- $this->addNotice('user',$this->user->name,'SAVED','ok');
- }
- else
- {
- $this->addValidationError('fullname');
- }
-
-
- // Ausgewählte Sprache sofort verwenden.
- $l = $this->getRequestVar('language');
-
- $this->setLanguage($l);
- }
-
-
-
- /**
- * Anzeigen einer Maske zum Ändern des Kennwortes.
- */
- function pwView()
- {
- // Kennwortänderung funktioniert natürlich nur in der internen Datenbank.
- //
- // Hier wird festgestellt, ob der Benutzer sich über die interne Datenbank angemeldet hat.
- // Nur dann kann man auch sein Kennwort ändern.
- $user = $this->getUserFromSession();
- $pwchangePossible = in_array( strtolower($user->loginModuleName), array('cookieauth','internal'));
- $this->setTemplateVar('pwchange_enabled', $pwchangePossible);
- }
-
-
-
- /**
- * Anzeige einer Maske zum Ändern der E-Mail-Adresse
- */
- function mailView()
- {
- }
-
-
-
- /*
- * Es wird eine E-Mail mit einem Freischaltcode an die eingegebene Adresse geschickt.
- */
- function mailPost()
- {
- srand ((double)microtime()*1000003);
- $code = rand(); // Zufalls-Freischaltcode erzeugen
- $newMail = $this->getRequestVar('mail');
-
- if ( empty($newMail) )
- {
- // Keine E-Mail-Adresse eingegeben.
- $this->addValidationError('mail');
- return;
- }
- else
- {
- // Der Freischaltcode wird in der Sitzung gespeichert.
- Session::set('mailChangeCode',$code );
- Session::set('mailChangeMail',$newMail);
-
- // E-Mail an die neue Adresse senden.
- $mail = new Mail( $newMail,'mail_change_code' );
- $mail->setVar('code',$code );
- $mail->setVar('name',$this->user->getName());
-
- if ( $mail->send() )
- {
- $this->addNotice('user',$this->user->name,'mail_sent',OR_NOTICE_OK); // Meldung
- $this->nextView('confirmmail');
- }
- else
- {
- $this->addNotice('user',$this->user->name,'mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); // Meldung
- return;
- }
- }
- }
-
-
-
- /**
- * Anzeige einer Maske, in die der Freischaltcode für das
- * Ändern der E-Mail-Adresse eingetragen werden muss.
- */
- function confirmmailView()
- {
- }
-
-
-
- /**
- * Abspeichern der neuen E-Mail-Adresse
- */
- function confirmmailPost()
- {
- $sessionCode = Session::get('mailChangeCode');
- $newMail = Session::get('mailChangeMail');
- $inputRegisterCode = $this->getRequestVar('code');
-
- if ( $sessionCode == $inputRegisterCode )
- {
- // Best�tigungscode stimmt �berein.
- // E-Mail-Adresse �ndern.
- $this->user->mail = $newMail;
- $this->user->save();
-
- $this->addNotice('user',$this->user->name,'SAVED',OR_NOTICE_OK);
- }
- else
- {
- // Best�tigungscode stimmt nicht.
- $this->addValidationError('code','code_not_match');
- }
-
- }
-
-
-
- public function pwPost()
- {
- if ( ! $this->user->checkPassword( $this->getRequestVar('act_password') ) )
- {
- $this->addValidationError('act_password');
- }
- elseif ( $this->getRequestVar('password1') == '' )
- {
- $this->addValidationError('password1');
- }
- elseif ( $this->getRequestVar('password1') != $this->getRequestVar('password2') )
- {
- $this->addValidationError('password2','PASSWORDS_DO_NOT_MATCH');
- }
- elseif ( strlen($this->getRequestVar('password1'))<intval(config('security','password','min_length')) )
- {
- $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>config('security','password','min_length')));
- }
- else
- {
- $this->user->setPassword( $this->getRequestVar('password1') );
- $this->addNotice('user',$this->user->name,'SAVED','ok');
- }
- }
-
-
-
- /**
- * Anzeige aller Benutzer-Eigenschaften.
- */
- function editView()
- {
- $issuer = urlencode(config('application','operator'));
- $account = $this->user->name.'@'.$_SERVER['SERVER_NAME'];
-
- $base32 = new Base2n(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', FALSE, TRUE, TRUE);
- $secret = $base32->encode(hex2bin($this->user->otpSecret));
- $counter = $this->user->hotpCount;
-
- $this->setTemplateVars( $this->user->getProperties() );
-
- $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
-
- $this->setTemplateVar('timezone_list',timezone_identifiers_list() );
-
- $languages = explode(',',config('i18n','available'));
- foreach($languages as $id=>$name)
- {
- unset($languages[$id]);
- $languages[$name] = $name;
- }
- $this->setTemplateVar('language_list',$languages);
-
- $this->setTemplateVars(
- $this->user->getProperties() +
- array('totpSecretUrl' => "otpauth://totp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}",
- 'hotpSecretUrl' => "otpauth://hotp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}&counter={$counter}"
- )
- );
-
-
- }
-
-
-
- /**
- * Anzeige aller Gruppen des angemeldeten Benutzers.
- *
- */
- function membershipsView()
- {
- $this->setTemplateVar( 'groups',$this->user->getGroups() );
- }
-
-
-
- /**
- * @param String $name Menüpunkt
- * @return boolean true, falls Menüpunkt zugelassen
- */
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'pwchange':
- // Die Funktion "Kennwort setzen" ist nur aktiv, wenn als Authentifizierungs-Backend
- // auch die interne Benutzerdatenbank eingesetzt wird.
- return @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
-
- default:
- return true;
- }
- }
-
- /**
- * Setzt eine Sprache für den Benutzer.
- *
- * @param $l string Sprache
- */
- public function setLanguage($l)
- {
- global $conf;
- $langFile = OR_LANGUAGE_DIR . 'lang-' . $l . '.' . PHP_EXT;
-
- // Pruefen, ob Sprache vorhanden ist.
- if (!file_exists($langFile))
- throw new LogicException("Languagefile $langFile does not exist.");
-
- $lang = array();
- require($langFile); // Setzt $lang
- global $conf;
- $conf['language'] = $lang;
- $conf['language']['language_code'] = $l;
- Session::setConfig($conf);
- }
-
-}-
\ No newline at end of file
diff --git a/action/ProjectAction.class.php b/action/ProjectAction.class.php
@@ -1,351 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Project;
-use cms\model\Folder;
-
-// 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 zum Bearbeiten eines Projektes
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class ProjectAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- var $project;
- var $defaultSubAction = 'listing';
-
-
- function __construct()
- {
- $this->project = new Project( $this->getRequestId() );
- $this->project->load();
- }
-
-
- function editPost()
- {
- if ( $this->getRequestVar('name') != '')
- {
- $this->project->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM);
- $this->project->target_dir = $this->getRequestVar('target_dir' ,OR_FILTER_RAW );
- $this->project->ftp_url = $this->getRequestVar('ftp_url' ,OR_FILTER_RAW );
- $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,OR_FILTER_RAW );
- $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,OR_FILTER_RAW );
- $this->project->content_negotiation = $this->getRequestVar('content_negotiation',OR_FILTER_NUMBER );
- $this->project->cut_index = $this->getRequestVar('cut_index' ,OR_FILTER_NUMBER );
-
- $this->addNotice('project',$this->project->name,'SAVED','ok');
- $this->project->save(); // speichern
-
- $root = new Folder( $this->project->getRootObjectId() );
- $root->setTimestamp();
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('edit');
- }
- }
-
-
-
- /**
- * Liste aller Projekte anzeigen.
- *
- */
- function listingView()
- {
- global $conf_php;
-
- // Projekte ermitteln
- $list = array();
-
- foreach(Project::getAllProjects() as $id=> $name )
- {
- $list[$id] = array();
- $list[$id]['url' ] = Html::url('project','edit',$id);
- $list[$id]['use_url' ] = Html::url('tree' ,'load',0 ,array('projectid'=>$id,'target'=>'tree'));
- $list[$id]['name' ] = $name;
- }
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Auswaehlen und starten eines Projektes.
- */
- function select()
- {
- $user = Session::getUser();
- $projects = $user->projects;
-
- // Administrator sieht Administrationsbereich
- if ( $user->isAdmin )
- $projects = array_merge( array("-1"=>lang('ADMINISTRATION')),$projects );
-
- // Projekte ermitteln
- $list = array();
-
- foreach( $projects as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['url' ] = Html::url('index','project',$id);
- $list[$id]['name'] = $name;
- }
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Anzeige der Eigenschaften des Projektes.
- */
- function editView()
- {
- $extraProperties = array('rootobjectid'=>$this->project->getRootObjectId());
-
- $this->setTemplateVars( $this->project->getProperties() + $extraProperties );
-
- }
-
-
- function removeView()
- {
- $this->setTemplateVar( 'name',$this->project->name );
- }
-
-
- function removePost()
- {
- if ( !$this->hasRequestVar('delete') )
- {
- $this->addValidationError('delete');
- return;
- }
-
- // Gesamtes Projekt loeschen
- $this->project->delete();
-
- $this->setTemplateVar('tree_refresh',true);
- $this->addNotice('project',$this->project->name,'DELETED');
- }
-
-
-
- /**
- * Anzeige View fuer Wartung.
- */
- function maintenanceView()
- {
- }
-
-
-
- /**
- * Wartung durchfuehren.
- */
- function maintenancePost()
- {
- switch( $this->getRequestVar('type') )
- {
- case 'check_files':
- // Konsistenzprüfungen
- $this->project->checkLostFiles();
- $status = empty($this->project->log) ? OR_NOTICE_OK : OR_NOTICE_ERROR;
-
- $this->addNotice('project',$this->project->name,'DONE',$status,array(),$this->project->log);
- break;
-
- case 'check_limit':
- // Alte Versionen löschen.
- $this->project->checkLimit();
- $this->addNotice('project',$this->project->name,'DONE');
- break;
-
- default:
- $this->addValidationError('type');
- return;
- }
- }
-
-
-
- /**
- * Synchronisation mit dem Dateisystem.
- */
- public function syncPost()
- {
-
- }
-
-
- /**
- * Synchronisation mit dem Dateisystem.
- */
- public function syncView()
- {
- global $conf;
- $syncConf = $conf['sync'];
-
- if ( ! $syncConf['enabled'] )
- return;
-
- $syncDir = slashify($syncConf['directory']).$this->project->name;
-
-
- }
-
-
- /**
- * Import aus dem Dateisystem.
- */
- public function importView()
- {
-
- }
-
-
- /**
- * Import aus dem Dateisystem.
- */
- public function importPost()
- {
-
- }
-
-
- /**
- * Export in Dateisystem.
- */
- public function exportView()
- {
-
- }
-
-
- /**
- * Export in Dateisystem.
- */
- public function exportPost()
- {
-
- }
-
-
- /**
- * Projekt exportieren.
- */
- public function copyView()
- {
-
- }
-
-
- /**
- * Projekt exportieren.
- */
- public function copyPost()
- {
- $db = db_connection();
- $this->setTemplateVar( 'dbid',$db->id );
-
- global $conf;
- $dbids = array();
-
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'])
- $dbids[$dbname] = $dbconf['description'];
- }
- $this->setTemplateVar( 'dbids',$dbids );
-
-
- if ( $this->hasRequestVar('ok') )
- {
- $this->project->export( $this->getRequestVar('dbid') );
-
- $this->addNotice('project',$this->project->name,'DONE');
- $this->setTemplateVar('done',true);
- }
- }
-
-
-
- /**
- * Ausgabe PHPINFO.
- *
- */
- function phpinfo()
- {
- global $conf;
- if ( !@$conf['security']['show_system_info'] )
- Http::sendStatus(403,'Forbidden','Display of system information is disabled by configuration');
-
- phpinfo();
- }
-
-
-
-
- function infoView()
- {
- $this->setTemplateVar( 'info', $this->project->info() );
- }
-
-
-
-
- /**
- * @param String $name Menüpunkt
- * @return boolean true, falls Menüpunkt zugelassen
- */
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'remove':
- return !readonly();
- case 'maintenance':
- return !readonly();
-
- default:
- return true;
- }
- }
-
-
- /**
- * Ermittelt die letzten Änderungen, die im aktuellen Projekt gemacht worden sind.
- */
- public function historyView()
- {
- $result = $this->project->getLastChanges();
-
- $this->setTemplateVar('timeline', $result);
- }
-
-
-}-
\ No newline at end of file
diff --git a/action/ProjectlistAction.class.php b/action/ProjectlistAction.class.php
@@ -1,125 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Project;
-
-// 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 zum Bearbeiten eines Projektes
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class ProjectlistAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- function __construct()
- {
- }
-
-
- public function editView()
- {
- $this->nextSubAction('show');
- }
-
- /**
- * Liste aller Projekte anzeigen.
- *
- */
- public function showView()
- {
- global $conf_php;
-
- // Projekte ermitteln
- $list = array();
-
- foreach(Project::getAllProjects() as $id=> $name )
- {
- $list[$id] = array();
- $list[$id]['id' ] = $id;
- $list[$id]['name' ] = $name;
- }
- $this->setTemplateVar('projects',$list);
- }
-
-
-
- function addView()
- {
- $this->setTemplateVar( 'projects',Project::getAllProjects() );
- }
-
-
- /**
- * Projekt hinzufuegen.
- *
- */
- function addPost()
- {
- if ( !$this->hasRequestVar('type') )
- {
- $this->addValidationError('type');
- $this->callSubAction('add');
- return;
- }
- else
- {
- switch( $this->getRequestVar('type') )
- {
- case 'empty':
- if ( !$this->hasRequestVar('name') )
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- return;
- }
- $this->project = new Project();
- $this->project->name = $this->getRequestVar('name');
- $this->project->add();
- $this->addNotice('project',$this->project->name,'ADDED');
- break;
- case 'copy':
- $db = db_connection();
- $project = new Project($this->getRequestVar('projectid'));
- $project->load();
- $project->export($db->id);
- $this->addNotice('project',$project->name,'DONE');
- break;
- default:
- Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') );
- }
-
- }
- }
-
-
- /**
- * Ermittelt die letzten Änderungen, die in allen Projekten gemacht worden sind.
- */
- function historyView()
- {
- $result = Project::getAllLastChanges();
- $this->setTemplateVar('timeline', $result);
- }
-
-}-
\ No newline at end of file
diff --git a/action/SearchAction.class.php b/action/SearchAction.class.php
@@ -1,238 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\User;
-use cms\model\Value;
-use cms\model\Template;
-use cms\model\Object;
-use cms\model\File;
-
-
-
-use Session;
-use \Html;
-
-
-
-// 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.
-
-
-define('SEARCH_FLAG_ID' , 1);
-define('SEARCH_FLAG_NAME' , 2);
-define('SEARCH_FLAG_FILENAME' , 4);
-define('SEARCH_FLAG_DESCRIPTION', 8);
-define('SEARCH_FLAG_VALUE' ,16);
-
-
-/**
- * Action-Klasse fuer die Suchfunktion.
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class SearchAction extends Action
-{
- public $security = SECURITY_USER;
-
-
- /**
- * leerer Kontruktor
- */
- function __construct()
- {
- }
-
-
-
- public function editView()
- {
- $user = Session::getUser();
- $this->setTemplateVar( 'users' ,User::listAll() );
- $this->setTemplateVar( 'act_userid',$user->userid );
- }
-
- /**
- * Durchf?hren der Suche
- * und Anzeige der Ergebnisse
- */
- public function resultView()
- {
- $suchText = $this->getRequestVar('text');
- $searchFlags = 0;
-
- if ( $this->hasRequestVar('id' ) ) $searchFlags |= SEARCH_FLAG_ID;
- if ( $this->hasRequestVar('filename' ) ) $searchFlags |= SEARCH_FLAG_FILENAME;
- if ( $this->hasRequestVar('name' ) ) $searchFlags |= SEARCH_FLAG_NAME;
- if ( $this->hasRequestVar('description') ) $searchFlags |= SEARCH_FLAG_DESCRIPTION;
- if ( $this->hasRequestVar('content' ) ) $searchFlags |= SEARCH_FLAG_VALUE;
-
- $this->performSearch($suchText, $searchFlags);
-
- /*
- case 'lastchange_user':
- $e = new Value();
-
- $language = Session::getProjectLanguage();
- $e->languageid = $language->languageid;
-
- $listObjectIds = $e->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') );
- break;
- }*/
- }
-
-
-
- /**
- * Durchf?hren der Suche
- * und Anzeige der Ergebnisse
- */
- public function quicksearchView()
- {
- global $conf;
-
- $text = $this->getRequestVar('search');
-
- $flag = $conf['search']['quicksearch']['flag'];
- $searchFlags = 0;
- if ( $flag['id' ] ) $searchFlags |= SEARCH_FLAG_ID;
- if ( $flag['name' ] ) $searchFlags |= SEARCH_FLAG_NAME;
- if ( $flag['filename' ] ) $searchFlags |= SEARCH_FLAG_FILENAME;
- if ( $flag['description'] ) $searchFlags |= SEARCH_FLAG_DESCRIPTION;
- if ( $flag['content' ] ) $searchFlags |= SEARCH_FLAG_VALUE;
-
- $this->performSearch($text, $searchFlags);
- }
-
-
-
- /**
- * Durchf?hren der Suche
- * und Anzeige der Ergebnisse
- */
- private function performSearch( $text, $flag)
- {
- global $conf;
-
- $listObjectIds = array();
- $listTemplateIds = array();
-
- $project = Session::getProject();
- if ( is_object($project) && $project->projectid == -1 )
- {
- $resultList = array();
-
- $user = User::loadWithName($text);
- if ( is_object($user) )
- {
- $userResult = array( 'url' => Html::url('template','',$templateid),
- 'type' => 'user',
- 'name' => $user->name,
- 'desc' => lang('NO_DESCRIPTION_AVAILABLE'),
- 'lastchange_date' => 0 );
- }
- $resultList[] = $userResult;
-
- $this->setTemplateVar( 'result',$resultList );
- }
- else
- {
- if ( $flag & SEARCH_FLAG_ID && Object::available( intval($text) ) )
- $listObjectIds[] = intval( $text );
-
- if ( $flag & SEARCH_FLAG_NAME )
- {
- $o = new Object();
- $listObjectIds += $o->getObjectIdsByName( $text );
- }
-
- if ( $flag & SEARCH_FLAG_DESCRIPTION )
- {
- $o = new Object();
- $listObjectIds += $o->getObjectIdsByDescription( $text );
- }
-
- if ( $flag & SEARCH_FLAG_FILENAME )
- {
- $o = new Object();
- $listObjectIds += $o->getObjectIdsByFilename( $text );
-
- $f = new File();
- $listObjectIds += $f->getObjectIdsByExtension( $text );
- }
-
- // Inhalte durchsuchen
- if ( $flag & SEARCH_FLAG_VALUE )
- {
- $e = new Value();
- $listObjectIds += $e->getObjectIdsByValue( $text );
-
- $template = new Template();
- $listTemplateIds += $template->getTemplateIdsByValue( $text );
- }
-
- $this->explainResult( $listObjectIds, $listTemplateIds );
- }
-
- }
-
-
- /**
- *
- */
- private function explainResult( $listObjectIds, $listTemplateIds )
- {
- $resultList = array();
-
- foreach( $listObjectIds as $objectid )
- {
- $o = new Object( $objectid );
- $o->load();
- $resultList[$objectid] = array();
- $resultList[$objectid]['id' ] = $objectid;
- $resultList[$objectid]['url' ] = Html::url($o->getType(),'',$objectid);
- $resultList[$objectid]['type'] = $o->getType();
- $resultList[$objectid]['name'] = $o->name;
- $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate;
-
- if ( $o->desc != '' )
- $resultList[$objectid]['desc'] = $o->desc;
- else
- $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- }
-
- foreach( $listTemplateIds as $templateid )
- {
- $t = new Template( $templateid );
- $t->load();
- $resultList['t'.$templateid] = array();
- $resultList['t'.$templateid]['id' ] = $templateid;
- $resultList['t'.$templateid]['url' ] = Html::url('template','',$templateid);
- $resultList['t'.$templateid]['type'] = 'template';
- $resultList['t'.$templateid]['name'] = $t->name;
- $resultList['t'.$templateid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- $resultList['t'.$templateid]['lastchange_date'] = 0;
- }
-
- $this->setTemplateVar( 'result',$resultList );
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/action/StartAction.class.php b/action/StartAction.class.php
@@ -1,1704 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\User;
-use cms\model\Project;
-use cms\model\Value;
-use cms\model\Element;
-use cms\model\Page;
-use cms\model\Object;
-use cms\model\Language;
-use cms\model\Model;
-
-
-use database\Database;
-use Http;
-use Logger;
-use \security\Password;
-use Session;
-use \Html;
-use \Mail;
-
-// OpenRat Content Management System
-// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; version 2.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
-if ( !defined('PROJECTID_ADMIN') )
- define('PROJECTID_ADMIN',-1);
-
-/**
- * Action-Klasse fuer die Start-Action
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class StartAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $mustChangePassword = false;
-
- function setDb( $dbid )
- {
- global $conf;
-
- if ( !isset($conf['database'][$dbid] ))
- Http::serverError( 'unknown DB-Id: '.$dbid );
-
- $db = db_connection();
- if ( is_object($db) )
- {
- $db->rollback();
- }
-
- $db = new Database( $conf['database'][$dbid] );
- $db->id = $dbid;
- $db->start();
- Session::setDatabase( $db );
- }
-
-
-
- function checkForDb()
- {
- global $conf;
- $dbid = $this->getRequestVar('dbid');
-
- if ( $dbid != '' )
- $this->setDb( $dbid );
- }
-
-
-
- function setDefaultDb()
- {
- if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) )
- {
- $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID);
- }
- else
- {
- global $conf;
-
- if ( !isset($conf['database']['default']) )
- Http::serverError('default-database not set');
-
- $dbid = $conf['database']['default'];
- }
-
- $this->setDb( $dbid );
- }
-
-
-
- function checkLogin( $name,$pw,$pw1,$pw2 )
- {
- Logger::debug( "login user $name" );
-
- global $conf;
- global $SESS;
-
- unset( $SESS['user'] );
-
-
- $db = db_connection();
-
- if ( !$db->available )
- {
- $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error));
- $this->callSubAction('showlogin');
- return false;
- }
-
- $ip = getenv("REMOTE_ADDR");
-
- $user = new User();
- $user->name = $name;
-
- $ok = $user->checkPassword( $pw );
-
- $this->mustChangePassword = $user->mustChangePassword;
-
- if ( $this->mustChangePassword )
- {
- // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
- // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
- if ( empty($pw1) )
- {
- }
- elseif ( $pw1 != $pw2 )
- {
- $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
- $this->addValidationError('password2','');
- }
- elseif ( strlen($pw2) < $conf['security']['password']['min_length'] )
- {
- $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
- $this->addValidationError('password2','');
- }
- else
- {
- // Kennw�rter identisch und lang genug.
- $user->setPassword( $pw1,true );
-
- // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen.
- $ok = true;
- $this->mustChangePassword = false;
- $user->mustChangePassword = false;
- }
- }
-
- // Falls Login erfolgreich
- if ( $ok )
- {
- // Login war erfolgreich!
- $user->load();
- $user->setCurrent();
- Logger::info( 'login successful' );
-
- return true;
- }
- else
- {
- Logger::info( "login for user $name failed" );
-
- return false;
- }
- }
-
-
-
- /**
- * Anzeigen der Loginmaske.
- *
- * Es wird nur die Loginmaske angezeigt.
- * Hier nie "304 not modified" setzen, da sonst keine
- * Login-Fehlermeldung erscheinen kann
- */
- function loginView()
- {
- global $conf;
- $sso = $conf['security']['sso'];
- $ssl = $conf['security']['ssl'];
-
- $ssl_trust = false;
- $ssl_user_var = '';
- extract( $ssl, EXTR_PREFIX_ALL, 'ssl' );
-
- if ( $sso['enable'] )
- {
- $authid = $this->getRequestVar( $sso['auth_param_name']);
-
- if ( empty( $authid) )
- Http::notAuthorized( 'no authorization data (no auth-id)');
-
- if ( $sso['auth_param_serialized'] )
- $authid = unserialize( $authid );
-
- $purl = parse_url($sso['url']);
- // Verbindung zu URL herstellen.
- $errno=0; $errstr='';
- $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30);
- if ( !$fp )
- {
- echo "Connection failed: $errstr ($errno)";
- }
- else
- {
- $http_get = $purl['path'];
- if ( !empty($purl['query']) )
- $http_get .= '?'.$purl['query'];
-
- $header = array();
-
- $header[] = "GET $http_get HTTP/1.0";
- $header[] ="Host: ".$purl['host'];
- $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)";
- $header[] = "Connection: Close";
-
- if ( $sso['cookie'] )
- {
- $cookie = 'Cookie: ';
- if ( is_array($authid))
- foreach( $authid as $cookiename=>$cookievalue)
- $cookie .= $cookiename.'='.$cookievalue."; ";
- else
- $cookie .= $sso['cookie_name'].'='.$authid;
-
- $header[] = $cookie;
- }
-
-// Html::debug($header);
- fputs ($fp, implode("\r\n",$header)."\r\n\r\n");
-
- $inhalt=array();
- while (!feof($fp)) {
- $inhalt[] = fgets($fp,128);
- }
- fclose($fp);
-
- $html = implode('',$inhalt);
-// Html::debug($html);
- if ( !preg_match($sso['expect_regexp'],$html) )
- Http::notAuthorized('auth failed');
- $treffer=0;
- if ( !preg_match($sso['username_regexp'],$html,$treffer) )
- Http::notAuthorized('auth failed');
- if ( !isset($treffer[1]) )
- Http::notAuthorized('authorization failed');
-
- $username = $treffer[1];
-
-// Html::debug( $treffer );
- $this->setDefaultDb();
-
- $user = User::loadWithName( $username );
-
- if ( ! $user->isValid( ))
- Http::notAuthorized('authorization failed: user not found: '.$username);
-
- $user->setCurrent();
-
- $this->callSubAction('show');
- }
- }
-
- elseif ( $ssl_trust )
- {
- if ( empty($ssl_user_var) )
- Http::serverError( 'please set environment variable name in ssl-configuration.' );
-
- $username = getenv( $ssl_user_var );
-
- if ( empty($username) )
- Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' );
-
- $this->setDefaultDb();
-
- $user = User::loadWithName( $username );
-
- if ( !$user->isValid() )
- Http::serverError( 'unknown username: '.$username );
-
- $user->setCurrent();
-
- $this->callSubAction('show');
- }
-
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbname] = array('key' =>$dbname,
- 'value'=>Text::maxLength($dbconf['description']),
- 'title'=>$dbconf['description'].' ('.$dbconf['host'].')' );
- }
-
- $openid_provider = array();
- foreach( explode(',',$conf['security']['openid']['provider']) as $provider )
- $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name');
- $this->setTemplateVar('openid_providers',$openid_provider);
- $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity'));
- //$this->setTemplateVar('openid_provider','identity');
-
-
- if ( empty($dbids) )
- $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
-
- if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) )
- $this->setTemplateVar('login_name',$_COOKIE['or_username']);
-
- if ( !isset($this->templateVars['login_name']) )
- $this->setTemplateVar('login_name',@$conf['security']['default']['username']);
-
- if ( $this->templateVars['login_name']== @$conf['security']['default']['username'])
- $this->setTemplateVar('login_password',@$conf['security']['default']['password']);
-
- $this->setTemplateVar( 'dbids',$dbids );
-
- $db = Session::getDatabase();
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- elseif( isset($this->templateVars['actid']) )
- ;
- else
- $this->setTemplateVar('actdbid',$conf['database']['default']);
-
-
- // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen.
- $ssl_user_var = $conf['security']['ssl']['user_var'];
- if ( !empty($ssl_user_var) )
- {
- $username = getenv( $ssl_user_var );
-
- if ( empty($username) )
- {
- echo lang('ERROR_LOGIN_BROKEN_SSL_CERT');
- Logger::warn( 'no username in SSL client certificate (var='.$ssl_user_var.').' );
- exit;
- }
-
- // Benutzername ist in Eingabemaske unveränderlich
- $this->setTemplateVar('force_username',$username);
- }
-
- $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
- $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
-
- $this->setTemplateVar('register' ,$conf['login' ]['register' ]);
- $this->setTemplateVar('send_password',$conf['login' ]['send_password']);
- }
-
-
-
- /**
- * Setzt die neue Projekt-Id und lädt die Workbench neu.
- *
- */
- public function projectmenuPost()
- {
-
- $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
- $this->setPerspective('normal');
- }
-
-
- /**
- * Erzeugt ein Projekt-Auswahlmenue.
- */
- public function projectmenuView()
- {
- $user = Session::getUser();
-
- if ( $user->mustChangePassword )
- {
- $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
- $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern.
- }
-
-
- // Diese Seite gilt pro Sitzung.
- //$this->lastModified( $user->loginDate );
-
- // Projekte ermitteln
- $projects = $user->getReadableProjects();
-
- $list = array();
-
- foreach( $projects as $id=>$name )
- {
- $p = array();
- $p['url' ] = Html::url('start','project',$id);
- $p['name'] = $name;
- $p['id' ] = $id;
-
- $tmpProject = new Project( $id );
- $p['defaultmodelid' ] = $tmpProject->getDefaultModelId();
- $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId();
- $p['models' ] = $tmpProject->getModels();
- $p['languages' ] = $tmpProject->getLanguages();
-
- $list[] = $p;
- }
-
- $this->setTemplateVar('projects',$list);
-
- if ( empty($list) )
- {
- // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben.
- if ( $this->userIsAdmin() )
- // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen
- $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
- else
- // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf�gung steht
- $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
- }
-
- //$this->metaValues();
- }
-
-
-
- /**
- * Erzeugt eine Anwendungsliste.
- */
- public function applicationsView()
- {
- global $conf;
-
- // Diese Seite gilt pro Sitzung.
- $user = Session::getUser();
- $userGroups = $user->getGroups();
- $this->lastModified( $user->loginDate );
-
- // Applikationen ermitteln
- $list = array();
- foreach( $conf['applications'] as $id=>$app )
- {
- if ( !is_array($app) )
- continue;
-
- if ( isset($app['group']) )
- if ( !in_array($app['group'],$userGroups) )
- continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden.
-
- $p = array();
- $p['url'] = $app['url'];
- $p['description'] = @$app['description'];
- if ( isset($app['param']) )
- {
- $p['url'] .= strpos($p['url'],'?')!==false?'&':'?';
- $p['url'] .= $app['param'].'='.session_id();
- }
- $p['name'] = $app['name'];
-
- $list[] = $p;
- }
-
-
- $this->metaValues();
- $this->setTemplateVar('applications',$list);
- }
-
-
-
- /**
- * Ermittelt Meta-Angaben f�r den HTML-Kopf.<br>
- * Falls der Browser die Meta-Angaben entsprechend auswertet, k�nnen �ber feste Browser-Men�s die Projekt direkt ausgew�hlt werden.
- * @Unused
- */
- private function metaValues()
- {
- global $conf;
- $metaList = array();
-
- $user = Session::getUser();
- if ( is_object($user) )
- {
- // Projekte ermitteln
- $projects = $user->projects;
- foreach( $projects as $id=>$name )
- {
- $metaList[] = array('name' => 'chapter',
- 'url' => Html::url('index','project',$id),
- 'title'=> $name );
- }
-
- if ( $this->userIsAdmin() )
- {
- $metaList[] = array('name' => 'appendix',
- 'url' => Html::url('index','projectmenu',0 ),
- 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) );
-
- $metaList[] = array('name' => 'chapter',
- 'url' => Html::url('index','administration',0),
- 'title'=> lang('administration') );
- }
-
- // Applikationen ermitteln
- foreach( $conf['applications'] as $id=>$app )
- {
- if ( !is_array($app) )
- continue;
- $appUrl = $app['url'];
- if ( isset($app['param']) )
- {
- $appUrl .= strpos($appUrl,'?')!==false?'&':'?';
- $appUrl .= $app['param'].'='.session_id();
- }
-
- $metaList[] = array('name' => 'bookmark',
- 'url' => $appUrl ,
- 'title'=> $app['name'] );
- }
- }
-
- $project = Session::getProject();
- if ( is_object($project) && $project->projectid > 0 )
- {
- $languages =$project->getLanguages();
-
- foreach( $project->getModels() as $modelid=>$modelname )
- {
- foreach( $languages as $languageid=>$languagename )
- {
-
- $metaList[] = array('name' => 'subsection',
- 'url' => Html::url('index',
- 'project',
- $project->projectid,
- array('languageid'=>$languageid,
- 'modelid' =>$modelid) ),
- 'title'=> $modelname.' - '.$languagename
- );
- }
- }
- }
-
- $metaList[] = array('name' => 'author',
- 'url' => $conf['login']['logo']['url'],
- 'title'=> $conf['login']['logo']['url'] );
-
- $metaList[] = array('name' => 'top',
- 'url' => Html::url('index','logout',0 ),
- 'title'=> 'Start' );
-
- $metaList[] = array('name' => 'contents',
- 'url' => Html::url('index','projectmenu',0 ),
- 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) );
-
-
- $this->setTemplateVar('metaList',$metaList);
- }
-
-
-
- /**
- * Open-Id Login, �berpr�fen der Anmeldung.<br>
- * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
- * Kapitel "4.4. check_authentication"<br>
- * <br>
- * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br>
- * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
- * <br>
- * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der
- * Benutzer angemeldet.<br>
- */
- function openid()
- {
- global $conf;
- $openId = Session::get('openid');
-
- if ( !$openId->checkAuthentication() )
- {
- $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- //Html::debug($openId);
-
- // Anmeldung wurde mit "is_valid:true" best�tigt.
- // Der Benutzer ist jetzt eingeloggt.
- $username = $openId->getUserFromIdentiy();
-
- if ( empty($username) )
- {
- // Es konnte kein Benutzername ermittelt werden.
- $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- $user = User::loadWithName( $username );
-
- if ( $user->userid <=0)
- {
- // Benutzer ist (noch) nicht vorhanden.
- if ( $conf['security']['openid']['add']) // Anlegen?
- {
- $user->name = $username;
- $user->add();
-
- $user->mail = $openId->info['email'];
- $user->fullname = $openId->info['fullname'];
- $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht)
- }
- else
- {
- // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht).
- $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
- }
- else
- {
- // Benutzer ist bereits vorhanden.
- if ( @$conf['security']['openid']['update_user'])
- {
- $user->fullname = $openId->info['fullname'];
- $user->mail = $openId->info['email'];
- $user->save();
- }
- }
-
- $user->setCurrent(); // Benutzer ist jetzt in der Sitzung.
- }
-
-
- /**
- * Login.
- */
- function loginPost()
- {
- global $conf;
-
- $this->checkForDb();
- Session::setUser('');
-
- if ( $conf['login']['nologin'] )
- Http::notAuthorized('login disabled');
-
- $openid_user = $this->getRequestVar('openid_url' );
- $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
- $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
- $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
- $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
-
- // Cookie setzen
- setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) );
-
- // Login mit Open-Id.
- if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) )
- {
- $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user);
-
- if ( ! $openId->login() )
- {
- $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) );
- $this->addValidationError('openid_url','');
- $this->callSubAction('showlogin');
- return;
- }
-
- Session::set('openid',$openId);
- $openId->redirect();
- die('Unreachable Code');
- }
-
-
- // Ermitteln, ob der Baum angezeigt werden soll
- // Ist die Breite zu klein, dann wird der Baum nicht angezeigt
- Session::set('showtree',intval($this->getRequestVar('screenwidth')) > $conf['interface']['min_width'] );
-
- $loginOk = $this->checkLogin( $loginName,
- $loginPassword,
- $newPassword1,
- $newPassword2 );
-
- usleep(hexdec(Password::randomHexString(1))); // delay: 0-255 ms
-
- if ( !$loginOk )
- {
-
- if ( $this->mustChangePassword )
- {
- // Anmeldung gescheitert, Benutzer muss Kennwort �ndern.
- $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' );
- $this->addValidationError('password1','');
- $this->addValidationError('password2','');
- }
- else
- {
- // Anmeldung gescheitert.
- $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
- $this->addValidationError('login_name' ,'');
- $this->addValidationError('login_password','');
- }
-
- Logger::debug("Login failed for user '$loginName'");
-
- $this->callSubAction('login');
- return;
- }
- else
- {
- Logger::debug("Login successful for user '$loginName'");
-
- // Anmeldung erfolgreich.
- if ( config('security','renew_session_login') )
- $this->recreateSession();
-
- $user = Session::getUser();
- $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname));
-
- $this->evaluateRequestVars();
-
- $object = Session::getObject();
- // Falls noch kein Objekt ausgew�hlt, dann das zuletzt ge�nderte benutzen.
- if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] )
- {
- $objectid = Value::getLastChangedObjectByUserId($user->userid);
- if ( Object::available($objectid))
- {
- $object = new Object($objectid);
- $object->load();
- Session::setObject($object);
- }
-
- $project = new Project( $object->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
- }
-
- $this->refresh(); // Benutzer ist angemeldet: Andere Views könnte das interessieren.
- }
-
-
- /**
- * Benutzer meldet sich ab.
- */
- function logoutPost()
- {
- global $conf;
-
- $user = Session::getUser();
- if ( is_object($user) )
- $this->setTemplateVar('login_username',$user->name);
-
- // Ausgew�hlte Objekte merken, um nach dem n�. Login wieder sofort auszuw�hlen.
- $o = Session::getObject();
- if ( is_object($o) )
- $this->setTemplateVar('objectid',$o->objectid);
- $p = Session::getProject();
- if ( is_object($p) )
- $this->setTemplateVar('projectid',$p->projectid);
- $l = Session::getProjectLanguage();
- if ( is_object($l) )
- $this->setTemplateVar('languageid',$l->languageid);
- $m = Session::getProjectModel();
- if ( is_object($m) )
- $this->setTemplateVar('modelid',$m->modelid);
- $db = db_connection();
- if ( is_object($db) )
- $this->setTemplateVar('dbid',$db->id);
-
- /*
- // Alle Variablen aus der Sitzung entfernen.
- session_unset();
-
- // Damit wird die Session gelöscht, nicht nur die Session-Daten!
- if ( ini_get("session.use_cookies") )
- {
- $params = session_get_cookie_params();
- setcookie( session_name(),'', time() - 3600,
- $params["path"],$params["domain"],$params["secure"],$params["httponly"] );
- }
-
- // Loeschen der Session.
- session_destroy();
- */
- if ( config('security','renew_session_logout') )
- $this->recreateSession();
-
- session_unset();
-
- if ( @$conf['theme']['compiler']['compile_at_logout'] )
- {
- foreach( $conf['action'] as $actionName => $actionConfig )
- {
- foreach( $actionConfig as $subActionName=>$subaction )
- {
- if ( is_array($subaction) &&
- !isset($subaction['goto' ]) &&
- !isset($subaction['direct']) &&
- !isset($subaction['action']) &&
- !isset($subaction['alias' ]) &&
- $subActionName != 'menu' )
- {
- $engine = new template_engine\TemplateEngine();
- $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName);
- }
- }
- }
- }
-
- // Umleiten auf eine definierte URL.s
- $redirect_url = @$conf['security']['logout']['redirect_url'];
-
- if ( !empty($redirect_url) )
- {
- header('Location: '.$redirect_url);
- exit;
- }
- }
-
-
-
- /**
- * Benutzer meldet sich ab.
- */
- function logoutView()
- {
- }
-
-
- /**
- * Ausw�hlen der Administration.
- */
- function administrationPost()
- {
- Session::setProject( new Project(-1) );
- Session::set('perspective','administration');
- $this->refresh();
- }
-
-
-
- /**
- * Auswaehlen des Benutzer-Profiles.
- */
- function profilePost()
- {
- Session::set('perspective','profile');
- $this->refresh();
- }
-
-
-
- /**
- * Auswaehlen der Startseite.
- */
- function startPost()
- {
- Session::set('perspective','start');
- $this->refresh();
- }
-
-
-
- /**
- * Ausgeben von maschinenlesbaren Benutzerinformationen.
- *
- * Diese Funktion dient dem Single-Signon f�r fremde Anwendungen, welche
- * die Benutzerinformationen des angemeldeten Benutzers aus dieser
- * Anwendung auslesen k�nnen.
- */
- function userinfo()
- {
- $user = Session::getUser();
- $info = array('username' => $user->name,
- 'fullname' => $user->fullname,
- 'mail' => $user->mail,
- 'telephone' => $user->tel,
- 'style' => $user->style,
- 'admin' => $user->isAdmin?'true':'false',
- 'ldap' => $user->ldap_dn,
- 'groups' => implode(',',$user->getGroups()),
- 'description'=> $user->desc
- );
-
- // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die
- // Informationen per XML aus.
- if ( $this->hasRequestVar('xml') )
- {
- header('Content-Type: text/xml');
- echo '<userinfo>';
- foreach( $info as $n=>$i )
- echo '<'.$n.'>'.$i.'</'.$n.'>'."\n";
- echo '</userinfo>';
-
- }
-
- // Sonst normale Textausgabe im INI-Datei-Format.
- else
- {
- header('Content-Type: text/plain');
- foreach( $info as $n=>$i )
- echo $n.'="'.$i."\"\n";
- }
-
- exit; // Fertig.
- }
-
-
- function project()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
-
- Session::setUser( $user );
- }
-
-
- function object()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) );
-
- Session::setUser( $user );
- }
-
-
- function languagePost()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- Http::serverError('No user in session');
- return;
- }
-
- $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) );
- }
-
-
- function modelPost()
- {
- $user = Session::getUser();
- if ( ! is_object($user) )
- {
- $this->callSubAction('show');
- return;
- }
-
- $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) );
- }
-
-
- /**
- * Auswerten der Request-Variablen.
- *
- * @param Array $add
- */
- private function evaluateRequestVars( $add = array() )
- {
- global $REQ;
- $vars = $REQ + $add;
-
- $db = db_connection();
- if ( !is_object($db) )
- {
- if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
- $this->setDb($vars[REQ_PARAM_DATABASE_ID]);
- else
- Http::serverError('no database available.');
- }
- else
- {
- // Prüft, ob die übergebene Datenbank-Id mit der
- // aktuellen übereinstimmt.
- // Falls nicht, muss ein Re-Login erfolgen.
- if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
- if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] )
- {
- $this->callSubAction('show');
- return;
- }
- }
-
-
- if ( isset($vars[REQ_PARAM_OBJECT_ID]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) )
- {
- $object = new Object( $vars[REQ_PARAM_OBJECT_ID] );
- $object->objectLoadRaw();
- // Session::setObject( $object ); // Unnötig
-
- $project = new Project( $object->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
- elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) )
- {
- $language = new Language( $vars[REQ_PARAM_LANGUAGE_ID] );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $project = new Project( $language->projectid );
- $project->load();
- Session::setProject( $project );
-
- $model = Session::getProjectModel();
- if ( !is_object($model) )
- {
- $model = new Model( $project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
-
- }
- elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) )
- {
- $model = new Model( $vars[REQ_PARAM_MODEL_ID] );
- $model->load();
- Session::setProjectModel( $model );
-
- $project = new Project( $model->projectid );
- $project->load();
- Session::setProject( $project );
-
- $language = Session::getProjectLanguage();
- if ( !is_object($language) || $language->projectid != $project->projectid )
- {
- $language = new Language( $project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
- }
- }
- elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) )
- {
- $project = new Project( $vars[REQ_PARAM_PROJECT_ID] );
- $project->load();
-
- Session::setProject( $project );
-
- $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
- $model->load();
- Session::setProjectModel( $model );
- }
- }
-
-
- function showtree()
- {
- Session::set('showtree',true );
- }
-
-
- function hidetree()
- {
- Session::set('showtree',false );
- }
-
-
- function switchuser()
- {
- $user = Session::getUser();
-
- if ( ! $user->isAdmin )
- Http::notAuthorized("");
-
- $this->recreateSession();
-
- $newUser = new User( $this->getRequestId() );
- $newUser->load();
-
- $newUser->setCurrent();
- }
-
-
- function show()
- {
- global $conf;
- global $PHP_AUTH_USER;
- global $PHP_AUTH_PW;
-
- $user = Session::getUser();
- // Gast-Login
- if ( ! is_object($user) )
- {
- if ( $conf['security']['guest']['enable'] )
- {
- $this->setDefaultDb();
- $username = $conf['security']['guest']['user'];
- $user = User::loadWithName($username);
- if ( $user->userid > 0 )
- $user->setCurrent();
- else
- {
- Logger::warn('Guest login failed, user not found: '.$username);
- $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) );
- $user = null;
- }
- }
- }
-
- if ( ! is_object($user) )
- {
- switch( $conf['security']['login']['type'] )
- {
-
- // Authorization ueber HTTP
- //
- case 'http':
- $ok = false;
-
- if ( isset($_SERVER['PHP_AUTH_USER']) )
- {
- $this->setDefaultDb();
- $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] );
- }
-
- if ( ! $ok )
- {
- header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' );
- header( 'HTTP/1.0 401 Unauthorized' );
- echo 'Authorization Required!';
- exit;
- }
- break;
-
- case 'form':
- // Benutzer ist nicht angemeldet
- $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske
- return;
- break;
-
- default:
- Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' );
- }
- }
-
- if ( $user->mustChangePassword )
- {
- $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
- $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern.
- }
-
- // Seite �ndert sich nur 1x pro Session
- $this->lastModified( $user->loginDate );
-
- $projectid = intval( $this->getRequestVar('projectid' ) );
- $languageid = intval( $this->getRequestVar('languageid') );
- $modelid = intval( $this->getRequestVar('modelid' ) );
- $objectid = intval( $this->getRequestVar('objectid' ) );
- $elementid = intval( $this->getRequestVar('elementid' ) );
-
- if ( $projectid != 0 )
- {
- $project = new Project( $projectid );
- $project->load();
- Session::setProject($project);
- }
- elseif ( $languageid != 0 )
- {
- $language = new Language( $languageid );
- $language->load();
- Session::setProjectLanguage($language);
- }
- elseif ( $modelid != 0 )
- {
- $model = new Model( $modelid );
- $model->load();
- Session::setProjectModel($model);
- }
- elseif ( $objectid != 0 )
- {
- $object = new Object( $objectid );
- $object->objectLoad();
- Session::setObject($object);
- }
- if ( $elementid != 0 )
- {
- $element = new Element( $elementid );
- Session::setElement($element);
- }
-
- $project = Session::getProject();
- $object = Session::getObject();
- $elementid = 0;
-
- if ( is_object($project) )
- {
- if ( $project->projectid == PROJECTID_ADMIN )
- {
- $project->name = lang('ADMINISTRATION');
- Session::setProject( $project );
-
- Session::setProjectLanguage( '' );
- Session::setProjectModel ( '' );
- Session::setObject ( '' );
- }
-
- $this->setTemplateVar( 'title',$project->name );
-
- if ( is_object($object) )
- {
- $type = $object->getType();
-
- if ( $type == 'page' )
- {
- $page = new Page($object->objectid);
- $page->load();
- $elementList = $page->getWritableElements();
- if ( count($elementList) == 1 )
- $elementid = current(array_keys($elementList));
- }
-
- if ( $elementid > 0 )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) );
- else
- $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) );
- }
- else
- {
- $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
- }
- }
- elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN )
- {
- if ( $this->hasRequestVar('projectid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) );
- elseif ( $this->hasRequestVar('groupid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) );
- elseif ( $this->hasRequestVar('userid') )
- $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) );
- else
- $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
- }
- else
- {
- $this->callSubAction( 'projectmenu' );
- }
-
-
- $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) );
-
- $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) );
- $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) );
- $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) );
- $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) );
- $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) );
- $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) );
-
- $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] );
-
- $this->metaValues();
- }
-
-
-
- function checkMenu( $name )
- {
- global $conf;
-
- switch( $name )
- {
- case 'applications':
- // Men�punkt "Anwendungen" wird nur angezeigt, wenn weitere Anwendungen
- // konfiguriert sind.
- return count(@$conf['applications']) > 0;
-
- case 'register': // Registrierung
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- return @$conf['login']['register'] && @$conf['security']['auth']['type'] == 'database';
-
- case 'password': // Kennwort vergessen
- // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
- // Deaktiviert, falls LDAP-Lookup aktiviert ist.
- return @$conf['login']['send_password'] && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
-
- case 'administration':
- // "Administration" nat�rlich nur f�r Administratoren.
- return $this->userIsAdmin();
-
- case 'login':
- return !@$conf['login']['nologin'];
-
- case 'logout':
- return true;
-
- case 'projectmenu':
- return true;
-
- default:
- return false;
- }
- }
-
-
- /**
- * Maske anzeigen, um Benutzer zu registrieren.
- */
- function register()
- {
-
- }
-
-
- /**
- * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen.
- * Maske anzeigen, damit Benuter Registriercode anzeigen kann.
- */
- public function registercode()
- {
- $email_address = $this->getRequestVar('mail','mail');
-
- if ( ! Mail::checkAddress($email_address) )
- {
- $this->addValidationError('mail');
- $this->setTemplateVar('mail',$email_address);
- $this->callSubAction('register');
- return;
- }
-
-
- srand ((double)microtime()*1000003);
- $registerCode = rand();
-
- Session::set('registerCode',$registerCode );
-
- // E-Mail and die eingegebene Adresse verschicken
- $mail = new Mail($email_address,
- 'register_commit_code','register_commit_code');
- $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable
-
- if ( $mail->send() )
- {
- $this->addNotice('','','mail_sent',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error);
- $this->callSubAction('register');
- return;
- }
- }
-
-
-
- public function registeruserdata()
- {
- global $conf;
-
- Session::set('registerMail',$this->getRequestVar('mail') );
- // TODO: Attribut "Password" abfragen
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbname] = $dbconf['description'];
- }
-
- $this->setTemplateVar( 'dbids',$dbids );
-
- $db = Session::getDatabase();
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- else
- $this->setTemplateVar('actdbid',$conf['database']['default']);
- }
-
-
- /**
- * Benutzerregistierung.
- * Benutzer hat Best�tigungscode erhalten und eingegeben.
- */
- public function registercommit()
- {
- global $conf;
- $this->checkForDb();
-
- $origRegisterCode = Session::get('registerCode');
- $inputRegisterCode = $this->getRequestVar('code');
-
- if ( $origRegisterCode != $inputRegisterCode )
- {
- // Best�tigungscode stimmt nicht.
- $this->addValidationError('code','code_not_match');
- $this->callSubAction('registeruserdata');
- return;
- }
-
- // Best�tigungscode stimmt �berein.
- // Neuen Benutzer anlegen.
-
- if ( !$this->hasRequestVar('username') )
- {
- $this->addValidationError('username');
- $this->callSubAction('registeruserdata');
- return;
- }
-
- $user = User::loadWithName( $this->getRequestVar('username') );
- if ( $user->isValid() )
- {
- $this->addValidationError('username','USER_ALREADY_IN_DATABASE');
- $this->callSubAction('registeruserdata');
- return;
- }
-
- if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] )
- {
- $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length']));
- $this->callSubAction('registeruserdata');
- return;
- }
-
- $newUser = new User();
- $newUser->name = $this->getRequestVar('username');
- $newUser->add();
-
- $newUser->mail = Session::get('registerMail');
- $newUser->save();
-
- $newUser->setPassword( $this->getRequestVar('password'),true );
-
- $this->addNotice('user',$newUser->name,'user_added','ok');
- }
-
-
-
- /**
- * Vergessenes Kennwort zusenden lassen.
- */
- public function password()
- {
- global $conf;
-
- // TODO: Attribut "Password" abfragen
- foreach( $conf['database'] as $dbname=>$dbconf )
- {
- if ( is_array($dbconf) && $dbconf['enabled'] )
- $dbids[$dbname] = $dbconf['description'];
- }
-
- $this->setTemplateVar( 'dbids',$dbids );
-
-
- $db = Session::getDatabase();
-
- if ( is_object($db) )
- $this->setTemplateVar('actdbid',$db->id);
- else
- $this->setTemplateVar('actdbid',$conf['database']['default']);
-
- }
-
-
- /*
- function changepassword()
- {
- }
- */
-
-
- /*
- function setnewpassword()
- {
- $oldPw = $this->getRequestVar('password_old' );
- $newPw1 = $this->getRequestVar('password_new_1');
- $newPw2 = $this->getRequestVar('password_new_2');
-
- if ( $newPw1 == $newPw2 )
- {
- // Aktuellen Benutzer aus der Sitzung ermitteln
- $user = $this->getUserFromSession();
-
- // Altes Kennwort pr�fen.
- $ok = $user->checkPassword( $oldPw );
-
- if ( $ok ) // Altes Kennwort ist ok.
- {
- $user->setPassword( $newPw1 ); // Setze neues Kennwort
- $user->mustChangePassword = false;
- Session::setUser($user);
- $this->addNotice('user',$user->name,'password_set','ok');
- }
- else
- {
- // Altes Kennwort falsch.
- $this->addNotice('user',$user->name,'password_error','error');
- }
- }
- else
- {
- // Beide neuen Kennw�rter stimmen nicht �berein
- $this->addNotice('user',$user->name,'passwords_not_match','error');
- }
- }
- */
-
-
- /**
- * Einen Kennwort-Anforderungscode an den Benutzer senden.
- */
- public function passwordcode()
- {
- if ( !$this->hasRequestVar('username') )
- {
- $this->addValidationError('username');
- $this->callSubAction('password');
- return;
- }
-
- $this->checkForDb();
-
- $user = User::loadWithName( $this->getRequestVar("username") );
-
- Password::delay();
-
- // Html::debug($user);
- if ( $user->isValid() )
- {
- srand ((double)microtime()*1000003);
- $code = rand();
- $this->setSessionVar("password_commit_code",$code);
-
- $eMail = new Mail( $user->mail,'password_commit_code' );
- $eMail->setVar('name',$user->getName());
- $eMail->setVar('code',$code);
- if ( $eMail->send() )
- $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK);
- else
- $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error);
-
- }
- else
- {
- //$this->addNotice('','user','username_not_found');
- // Trotzdem vort�uschen, eine E-Mail zu senden, damit die G�ltigkeit
- // eines Benutzernamens nicht von au�en gepr�ft werden kann.
- //
- $this->addNotice('user',$this->getRequestVar("username"),'mail_sent');
- }
-
- $this->setSessionVar("password_commit_name",$user->name);
- }
-
-
-
- /**
- * Anzeige Formular zum Eingeben des Kennwort-Codes.
- *
- */
- public function passwordinputcode()
- {
-
- }
-
-
- /**
- * Neues Kennwort erzeugen und dem Benutzer zusenden.
- */
- public function passwordcommit()
- {
- $username = $this->getSessionVar("password_commit_name");
-
- if ( $this->getRequestVar("code")=='' ||
- $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") )
- {
- $this->addValidationError('code','PASSWORDCODE_NOT_MATCH');
- $this->callSubAction('passwordinputcode');
- return;
- }
-
- $user = User::loadWithName( $username );
-
- if ( !$user->isValid() )
- {
- // Benutzer konnte nicht geladen werden.
- $this->addNotice('user',$username,'error',OR_NOTICE_ERROR);
- return;
- }
-
- $newPw = User::createPassword(); // Neues Kennwort erzeugen.
-
- $eMail = new Mail( $user->mail,'password_new' );
- $eMail->setVar('name' ,$user->getName());
- $eMail->setVar('password',$newPw );
-
- if ( $eMail->send() )
- {
- $user->setPassword( $newPw, false ); // Kennwort muss beim n�. Login ge�ndert werden.
- $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK);
- }
- else
- {
- // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den
- // Code per E-Mail erhalten hat.
- $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error);
- }
- }
-
-
- /**
- * Erzeugt eine neue Sitzung.
- */
- private function recreateSession()
- {
-
- // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht.
- if ( version_compare(phpversion(),"4.3.2","<") )
- {
- $randlen = 32;
- $randval = "0123456789abcdefghijklmnopqrstuvwxyz";
- $newid = "";
- for ($i = 1; $i <= $randlen; $i++)
- {
- $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1);
- }
- session_id( $newid );
- }
- elseif( version_compare(phpversion(),"4.3.2","==") )
- {
- session_regenerate_id();
-
- // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt.
- if ( ini_get("session.use_cookies") )
- setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" );
- }
- elseif ( version_compare(phpversion(),"5.1.0",">") )
- {
- session_regenerate_id(true);
- }
- else
- {
- // 5.1.0 > PHP >= 4.3.3
- }
- }
-
-
-
-
-
-
- /**
- * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer im aktuellen Projekt gemacht worden sind.
- */
- public function userprojecttimelineView()
- {
- $project = Session::getProject();
- $result = $project->getMyLastChanges();
-
- $this->setTemplateVar('timeline', $result);
- }
-
-
-}
-
-
-?>-
\ No newline at end of file
diff --git a/action/TemplateAction.class.php b/action/TemplateAction.class.php
@@ -1,571 +0,0 @@
-<?php
-
-namespace cms\action;
-
-namespace cms\action;
-use cms\model\Element;
-use cms\model\Template;
-use cms\model\Page;
-
-
-
-use Session;
-use \Html;
-use \Text;
-
-// OpenRat Content Management System
-// Copyright (C) 2002-2009 Jan Dankert
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-/**
- * Action-Klasse zum Bearbeiten einer Seitenvorlage.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-
-class TemplateAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $defaultSubAction = 'show';
- var $template;
- var $element;
-
-
- function __construct()
- {
- $this->template = new Template( $this->getRequestId() );
- $this->template->load();
- $this->setTemplateVar( 'templateid',$this->template->templateid );
-
- if ( intval($this->getRequestVar('elementid')) != 0 )
- {
- $this->element = new Element( $this->getRequestVar('elementid') );
- $this->element->load();
- $this->setTemplateVar( 'elementid',$this->element->elementid );
- }
- }
-
-
- function srcPost()
- {
- // Speichern des Quelltextes
- //
- $text = $this->getRequestVar('src','raw');
-
- foreach( $this->template->getElementNames() as $elid=>$elname )
- {
- $text = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}',$text );
- $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFEMPTY:' .$elid.':BEGIN}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFEMPTY:' .$elid.':END}}' ,$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFNOTEMPTY:'.$elid.':BEGIN}}',$text );
- $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFNOTEMPTY:'.$elid.':END}}' ,$text );
- }
-
- $this->template->src = $text;
- $this->template->save();
- $this->template->load();
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
-
- function srcelementPost()
- {
- $text = $this->template->src;
-
- switch( $this->getRequestVar('type') )
- {
- case 'addelement':
- $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
- break;
-
- case 'addicon':
- $text .= "\n".'{{->'.$this->getRequestVar('writable_elementid').'}}';
- break;
-
- case 'addifempty':
- $text .= "\n".'{{IFEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
- break;
-
- case 'addifnotempty':
- $text .= "\n".'{{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
- break;
-
- default:
- $this->addValidationError('type');
- $this->callSubAction('srcelement');
- return;
- }
-
- $this->template->src = $text;
-
- $this->template->save();
- $this->template->load();
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
- // Speichern der Template-Eigenschaftens
- //
- function propPost()
- {
-
- if ($this->getRequestVar('name') == "")
- {
- $this->addValidationError('name');
- $this->callSubAction('name');
- return;
- }
- else
- {
- $this->template->name = $this->getRequestVar('name');
- $this->template->save();
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
- }
-
-
- // Speichern der Template-Eigenschaftens
- //
- function removePost()
- {
- if ( $this->getRequestVar('delete') != '' )
- {
- $this->template->delete();
- $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK);
- }
- else
- {
- $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN);
- }
- }
-
-
- /**
- * Entfernen der Vorlage
- */
- function removeView()
- {
- $this->setTemplateVar('name',$this->template->name);
- }
-
-
- /**
- * Anzeigen aller Seiten der Vorlage.
- */
- function infoView()
- {
- $pages = array();
- $pageids = $this->template->getDependentObjectIds();
-
- foreach( $pageids as $pageid )
- {
- $page = new Page($pageid);
- $page->load();
-
- $pages[$pageid] = $page->name;
- }
-
- $this->setTemplateVar('pages',$pages);
- $this->setTemplateVar('id' ,$this->template->templateid);
- }
-
-
- // Speichern der Dateiendung
- //
- function extensionPost()
- {
- if ( $this->getRequestVar('type') == "list" )
- $this->template->extension = $this->getRequestVar('extension');
- else
- $this->template->extension = $this->getRequestVar('extensiontext');
-
- $this->template->save();
- $this->addNotice('template',$this->template->name,'SAVED','ok');
- }
-
-
- function addelView()
- {
- // Die verschiedenen Element-Typen
- $types = array();
-
- foreach( Element::getAvailableTypes() as $t )
- {
- $types[ $t ] = 'EL_'.$t;
- }
-
- // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
- if ( !$this->userIsAdmin() )
- unset( $types['code'] );
-
- $this->setTemplateVar('types',$types);
- }
-
-
-
- /*
- * Neues Element hinzufuegen.
- */
- function addelPost()
- {
-
- $name = $this->getRequestVar('name',OR_FILTER_ALPHANUM);
- if ( empty($name) )
- {
- $this->addValidationError('name');
- $this->callSubAction('addel');
- return;
- }
-
- $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('type') );
- $this->setTemplateVar('tree_refresh',true);
-
- if ( $this->hasRequestVar('addtotemplate') )
- {
- $elnames = $this->template->getElementNames();
- $elid = array_search($name,$elnames);
- $this->template->src .= "\n".'{{'.$elid.'}}';
- $this->template->save();
- }
-
- $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
- /**
- * Eigenschaften einer Vorlage anzeigen
- */
- function propView()
- {
- $this->setTemplateVar('name' ,$this->template->name );
- $this->setTemplateVar('extension',$this->template->extension );
- $this->setTemplateVar('mime_type',$this->template->mimeType() );
- }
-
-
-
- /**
- * Eigenschaften einer Vorlage anzeigen
- */
- function extensionView()
- {
-
- global $conf;
- $mime_types = array();
- foreach( $conf['mime-types'] as $ext=>$type )
- $mime_types[$ext] = $ext.' - '.$type;
-
- $this->setTemplateVar('mime_types',$mime_types);
-
- $this->setTemplateVar('extension' ,$this->template->extension);
- $this->setTemplateVar('extensiontext',$this->template->extension);
-
- if ( isset($mime_types[$this->template->extension]) )
- $this->setTemplateVar('type','list');
- else
- $this->setTemplateVar('type','text');
- }
-
-
-
- /**
- * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
- * auf die Standardausgabe geschrieben
- */
- function previewView()
- {
- $this->setTemplateVar('preview_url',Html::url('template','show',$this->template->templateid,array('target'=>'none') ) );
- }
-
-
-
-
- /**
- * Voransicht einer Vorlage
- */
- function showView()
- {
- header('Content-Type: '.$this->template->mimeType().'; charset='.$this->getCharset() );
- $text = $this->template->src;
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = Html::url( 'element','edit',$this->template->templateid,array('elementid'=>$elid));
-
- $text = str_replace('{{'.$elid.'}}',$element->name,
- $text );
- $text = str_replace('{{->'.$elid.'}}','',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}','',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}','',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}','',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}','',
- $text );
-
- unset( $element );
- }
-
- echo $text;
-
- exit();
- }
-
-
- /**
- * Bearbeiten einer Vorlage
- */
- function editView()
- {
- // Elemente laden
- $list = array();
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $list[$elid] = array();
- $list[$elid]['id' ] = $elid;
- $list[$elid]['name' ] = $element->name;
- $list[$elid]['description'] = $element->desc;
- $list[$elid]['type' ] = $element->type;
-
- unset( $element );
- }
- $this->setTemplateVar('elements',$list);
-
-
- $text = Text::encodeHtml( $this->template->src );
- $text = str_replace("\n",'<br/>',$text);
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = 'javascript:openNewAction(\''.$element->name.'\',\'element\',\''.$elid.'\');';
-
- $text = str_replace('{{'.$elid.'}}',
- '<a href="'.$url.'" class="element el_'.
- $element->getTypeClass().'" title="'.$element->desc.'">{{'.
- $element->name.'}}</a>',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '<a href="'.$url.'" class="element el_'.
- $element->getTypeClass().'" title="'.$element->desc.'">{{->'.
- $element->name.'}}</a>',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- unset( $element );
- }
-
- $this->setTemplateVar('text',$text);
- }
-
-
- function srcelementView()
- {
- $elements = array();
- $writable_elements = array();
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $elements[$elid] = $element->name;
-
- if ( $element->isWritable() )
- $writable_elements[$elid] = $element->name;
- }
-
- $this->setTemplateVar('elements' ,$elements );
- $this->setTemplateVar('writable_elements',$writable_elements);
- }
-
-
-
- /**
- * Anzeigen des Template-Quellcodes
- */
- function srcView()
- {
- $text = $this->template->src;
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $text = str_replace('{{'.$elid.'}}',
- '{{'.$element->name.'}}',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '{{->'.$element->name.'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- }
-
- $this->setTemplateVar( 'src',$text );
-
- }
-
-
- // Anzeigen aller Templates
- //
- function listingView()
- {
- global $conf_php;
-
- $list = array();
-
- foreach( Template::getAll() as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['name'] = $name;
- $list[$id]['url' ] = Html::url('template','el',$id,array());
- }
-
-// $var['templatemodelid'] = htmlentities( $id );
-// $var['text'] = htmlentities( $text );
- $this->setTemplateVar('templates',$list);
- }
-
-
- /**
- * Anzeigen der Maske zum Veröffentlichen.
- */
- public function pubView()
- {
-
- }
-
-
-
- /**
- * Veröffentlichen.
- */
- public function pubPost()
- {
- $objectIds = $this->template->getDependentObjectIds();
-
- Session::close();
-
- foreach( $objectIds as $objectid )
- {
- $page = new Page( $objectid );
-
- if ( !$page->hasRight( ACL_PUBLISH ) )
- continue;
-
- $page->public = true;
- $page->publish();
- $page->publish->close();
-
- // foreach( $this->page->publish->publishedObjects as $o )
- // {
- // $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
- // }
-
- $this->addNotice( 'page',
- $page->fullFilename,
- 'PUBLISHED'.($page->publish->ok?'':'_ERROR'),
- $page->publish->ok,
- array(),
- $page->publish->log );
- }
- }
-
-
-
- /**
- * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
- *
- * @see actionClasses/Action#checkMenu($name)
- */
- function checkMenu( $menu ) {
-
- switch( $menu)
- {
- case 'srcelement':
- // Platzhalter nur hinzufuegbar, wenn es welche gibt.
- return is_object($this->template) &&
- (count($this->template->getElementIds()) > 0);
-
- case 'remove':
- // Entfernen von Templates nur dann erlaubt, wenn keine Seiten auf diesem Template basieren.
- return is_object($this->template) &&
- (count($this->template->getDependentObjectIds()) == 0);
-
- case 'pages':
- // Anzeige von Seiten nur dann sinnvoll, wenn es auch Seiten gibt.
- return is_object($this->template) &&
- (count($this->template->getDependentObjectIds()) > 0);
-
- case 'add':
- case 'addel':
- return !readonly();
-
- default:
- return true;
-
- }
- }
-
-}-
\ No newline at end of file
diff --git a/action/TemplatelistAction.class.php b/action/TemplatelistAction.class.php
@@ -1,233 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Element;
-use cms\model\Template;
-use Session;
-
-// OpenRat Content Management System
-// Copyright (C) 2002-2009 Jan Dankert
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-/**
- * Action-Klasse zum Bearbeiten einer Seitenvorlage.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-
-class TemplatelistAction extends Action
-{
- public $security = SECURITY_USER;
-
- function __construct()
- {
- }
-
-
-
- /**
- * Bearbeiten einer Vorlage
- */
- function editView()
- {
- $this->nextSubAction('show');
- }
-
-
-
- // Anzeigen aller Templates
- //
- function showView()
- {
- global $conf_php;
-
- $list = array();
-
- foreach( Template::getAll() as $id=>$name )
- {
- $list[$id] = array();
- $list[$id]['name'] = $name;
- $list[$id]['id' ] = $id;
- }
-
-// $var['templatemodelid'] = htmlentities( $id );
-// $var['text'] = htmlentities( $text );
- $this->setTemplateVar('templates',$list);
- }
-
-
-
- /**
- * Vorlage hinzuf�gen.
- */
- function addView()
- {
- $this->setTemplateVar( 'templates',Template::getAll() );
-
- $examples = array();
- $dir = opendir( 'examples/templates');
- while( $file = readdir($dir) )
- {
- if ( substr($file,0,1) != '.')
- {
- $examples[$file] = $file;
- }
- }
-
- $this->setTemplateVar( 'examples',$examples );
- $this->setTemplateVar( 'templateid','' );
- $this->setTemplateVar( 'example','' );
- }
-
-
-
- function addPost()
- {
- // Hinzufuegen eines Templates
- if ( $this->getRequestVar('name') == '' )
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- return;
- }
-
- // Hinzufuegen eines Templates
- switch( $this->getRequestVar('type') )
- {
- case 'empty':
-
- // Neues Template anlegen.
- $template = new Template();
- $template->add( $this->getRequestVar('name') );
- $this->addNotice('template',$template->name,'ADDED','ok');
- break;
-
- case 'copy':
-
- $copy_templateid = intval($this->getRequestVar('templateid') );
-
- if ( $copy_templateid == 0 )
- {
- $this->addValidationError('templateid');
- return;
- }
-
- // Neues Template anlegen.
- $template = new Template();
- $template->add( $this->getRequestVar('name') );
- $this->addNotice('template',$template->name,'ADDED','ok');
-
- // Template kopieren.
- $copy_template = new Template( $copy_templateid );
- $copy_template->load();
- $elementMapping = array();
- foreach( $copy_template->getElements() as $element )
- {
- /* @type $element Element */
- $element->load();
- $oldelementId = $element->elementid;
- $element->templateid = $template->templateid;
- $element->add();
- $element->save();
-
- $elementMapping[$oldelementId] = $element->elementid;
- }
-
- $project = Session::getProject();
- foreach( $project->getModelIds() as $modelid )
- {
- // Template laden
- $copy_template->modelid = $modelid;
- $copy_template->load();
-
- $template->modelid = $modelid;
- $src = $copy_template->src;
-
- // Elemente im Quelltext an die geänderten Element-Idn anpassen.
- foreach( $elementMapping as $oldId=>$newId)
- $src = str_replace('{{'.$oldId.'}}','{{'.$newId.'}}',$src);
-
- $template->src = $src;
- $template->extension = $copy_template->extension;
- $template->save();
- }
-
- $this->addNotice('template',$copy_template->name,'COPIED','ok');
-
- break;
-
- case 'example':
-
- // Neues Template anlegen.
- $template = new Template();
-
- $model = Session::getProjectModel();
- $template->modelid = $model->modelid;
-
- $template->add( $this->getRequestVar('name') );
-
- $example = parse_ini_file('examples/templates/'.$this->getRequestVar('example'),true);
-
- foreach( $example as $exampleKey=>$exampleElement )
- {
- if ( !is_array($exampleElement) )
- {
- $template->$exampleKey = $exampleElement;
- }
- else
- {
- $element = new Element();
- $element->templateid = $template->templateid;
- $element->name = $exampleKey;
- $element->writable = true;
- $element->add();
-
- foreach( $exampleElement as $ePropName=>$ePropValue)
- $element->$ePropName = $ePropValue;
-
- $element->defaultText = str_replace(';',"\n",$element->defaultText);
- $element->save();
-// Html::debug($element,"Element");
- }
- }
-// Html::debug($template,"Template");
- $template->name = $this->getRequestVar('name');
- $template->src = str_replace(';',"\n",$template->src);
-
- foreach( $template->getElementNames() as $elid=>$elname )
- {
- $template->src = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}' ,$template->src );
- $template->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$template->src );
- }
-
- $template->save();
- $this->addNotice('template',$template->name,'ADDED','ok');
-
- break;
- default:
- $this->addValidationError('type');
- $this->callSubAction('add');
- return;
- }
-
-
- $this->setTemplateVar('tree_refresh',true);
- }
-
-
-}-
\ No newline at end of file
diff --git a/action/TitleAction.class.php b/action/TitleAction.class.php
@@ -1,134 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Project;
-use cms\model\Object;
-use cms\model\Language;
-use cms\model\Model;
-
-use Session;
-use \Html;
-// OpenRat Content Management System
-// Copyright (C) 2002-2009 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
-/**
- * Actionklasse zum Anzeigen der Titelleiste.
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-class TitleAction extends Action
-{
- public $security = SECURITY_GUEST;
-
- /**
- * Fuellen der Variablen und Anzeigen der Titelleiste
- */
- public function showView()
- {
- $this->setTemplateVar('buildinfo',OR_TITLE.' '.OR_VERSION.' - build '.config('build','build') );
-
- $user = Session::getUser();
- if ( !is_object($user) )
- return; // Kein Benutzer angemeldet.
-
-
- $db = Session::getDatabase();
- $this->setTemplateVar('dbname',$db->conf['name'].(readonly()?' ('.lang('readonly').')':''));
- $this->setTemplateVar('dbid' ,$db->id);
-
- $databases = array();
-
- $this->setTemplateVar('username' ,$user->name );
- $this->setTemplateVar('userfullname',$user->fullname);
-
- $project = Session::getProject();
- if ( is_object($project) )
- {
- $this->setTemplateVar('projectname',$project->name);
- $this->setTemplateVar('projects' ,Project::getAllProjects() );
- }
-
-
-
- $language = Session::getProjectLanguage();
- if ( is_object($language) )
- {
- $this->setTemplateVar('languagename',$language->name);
- $this->setTemplateVar('languages',Language::getAll() );
- }
-
- $model = Session::getProjectModel();
- if ( is_object($model) )
- {
- $this->setTemplateVar('modelname',$model->name);
- $this->setTemplateVar('models' ,Model::getAll() );
- }
-
- // Urls zum Benutzerprofil und zum Abmelden
- //$this->setTemplateVar('profile_url',Html::url( 'profile' ));
- //$this->setTemplateVar('logout_url' ,Html::url( 'index','logout' ));
- $this->setTemplateVar('isAdmin',$this->userIsAdmin() );
- $this->setTemplateVar('isLoggedIn',$this->userIsLoggedIn() );
-
- if ( config('interface','session','auto_extend') )
- {
- $this->setTemplateVar('ping_url' ,Html::url('title','ping') );
- $this->setTemplateVar('ping_timeout',ini_get('session.gc_maxlifetime')-60 );
- }
- }
-
-
- public function pingView()
- {
- $this->setTemplateVar('ping',true );
- $this->setTemplateVar('time',date('r') );
- }
-
-
- public function historyView()
- {
- $resultList = array();
-
- $history = Session::get('history');
-
- if ( is_array($history) )
- {
- foreach( array_reverse($history) as $objectid )
- {
- $o = new Object( $objectid );
- $o->load();
- $resultList[$objectid] = array();
- $resultList[$objectid]['url'] = Html::url($o->getType(),'',$objectid);
- $resultList[$objectid]['type'] = $o->getType();
- $resultList[$objectid]['name'] = $o->name;
- $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate;
-
- if ( $o->desc != '' )
- $resultList[$objectid]['desc'] = $o->desc;
- else
- $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
- }
- }
-
- $this->setTemplateVar( 'history',$resultList );
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/action/TreeAction.class.php b/action/TreeAction.class.php
@@ -1,377 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use AdministrationTree;
-use cms\model\Language;
-use cms\model\Model;
-
-use Exception;
-use JSqueeze;
-use Less_Parser;
-use Logger;
-use ObjectNotFoundException;
-use ProjectTree;
-use Session;
-use \Html;
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-/**
- * Action-Klasse zum Laden/Anzeigen des Navigations-Baumes
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-
-class TreeAction extends Action
-{
- public $security = SECURITY_USER;
-
- var $tree;
-
-
- /**
- * ?ffnen aller Baumelemente
- */
- function openall()
- {
- $this->tree = Session::getTree();
- $this->tree->all();
- Session::setTree( $this->tree );
- }
-
-
-// function refresh()
-// {
-// $this->tree = Session::getTree();
-// $this->tree->refresh();
-// Session::setTree( $this->tree );
-// }
-
-
- /**
- * ?ffnen eines Baumelementes
- */
- function open()
- {
- $this->tree = Session::getTree();
- $this->tree->open( $this->getRequestId() );
- Session::setTree( $this->tree );
- }
-
-
- /**
- * Schlie?en eines Baumelementes
- */
- function close()
- {
- $this->tree = Session::getTree();
- $this->tree->close( $this->getRequestId() );
- Session::setTree( $this->tree );
- }
-
-
- /**
- * Neues Laden des Baumes
- */
- private function load()
- {
- global $SESS;
-
- $project = Session::getProject();
- $projectid = $project->projectid;
-
- Logger::debug( "Initializing Tree for Project ".$projectid);
-
- if ( $projectid == -1 )
- {
- $this->tree = new AdministrationTree();
- }
- else
- {
- $this->tree = new ProjectTree();
- $this->tree->projectId = $projectid;
- }
-
- Session::setTree( $this->tree );
- }
-
-
- /**
- * Liefert ein Array mit allen Zeilen des Baumes.
- *
- * Ruft sich intern rekursiv auf.
- *
- * @param $elId
- * @param $tiefe
- * @param $isLast
- * @return unknown_type
- */
- function outputElement( $elId,$tiefe,$isLast )
- {
- $treeElement = $this->tree->elements[$elId];
-
- $zeilen = array();
- $zeile = array();
-
- global $class;
- $zeile['class'] = $class;
- if ( $this->getRequestId() == $elId )
- $zeile['class'] = 'opened';
- if ( $this->getRequestId() == $elId )
- $class ='active';
-
- if ( !isset($tree_last) )
- $tree_last=array();
-
- $zeile['cols'] = array();
-
- for ( $i=1; $i<=$tiefe-1; $i++ )
- {
- if ( $isLast[$i] )
- $zeile['cols'][] = 'blank';
- else
- $zeile['cols'][] = 'line';
- }
-
- if ( $tiefe == 0 )
- {
- }
- elseif ( $treeElement->type != "" )
- {
- if ( count($treeElement->subElementIds) == 0 )
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'plus_end';
- else $zeile['image'] = 'plus';
-
- $zeile['image_url' ] = Html::url('tree','open',$elId);
- $zeile['image_url_desc'] = lang('TREE_OPEN_ELEMENT');
- }
- else
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'minus_end';
- else $zeile['image'] = 'minus';
-
- $zeile['image_url' ] = Html::url('tree','close',$elId);
- $zeile['image_url_desc'] = lang('TREE_CLOSE_ELEMENT');
- }
- }
- else
- {
- if ( $isLast[$tiefe] )
- $zeile['image'] = 'none_end';
- else $zeile['image'] = 'none';
- }
-
-
-
- $zeile['icon'] = $treeElement->icon;
- $zeile['text'] = $treeElement->text;
- $zeile['desc'] = $treeElement->description;
- $zeile['name'] = $elId;
-
- // Url setzen
- if ( $treeElement->url != "" )
- $zeile['url'] = $treeElement->url;
-
- // HTML-Target setzen
- if ( $treeElement->target != "" )
- $zeile['target'] = $treeElement->target;
- else
- $zeile['target'] = 'cms_main';
-
- $zeile['colspan'] = 20 - count( $zeile['cols'] ) - intval(isset($zeile['image']));
-
- $zeilen[] = $zeile;
- // Rekursiv alle Unter-Elemente lesen
- $nr = 0;
- foreach( $this->tree->elements[$elId]->subElementIds as $subElementId )
- {
- $nr++;
- if ( $nr == count($this->tree->elements[$elId]->subElementIds) )
- $isLast[$tiefe+1] = true;
- else $isLast[$tiefe+1] = false;
-
- // Rekursiver Aufruf
- $zeilen = array_merge( $zeilen,$this->outputElement( $subElementId,$tiefe+1,$isLast ) );
- }
-
- if ( $this->getRequestId() == $elId )
- $class ='';
-
- return $zeilen;
- }
-
-
- /**
- * Anzeigen des Baumes
- */
- public function treeView()
- {
- return;
- $this->load();
-
- $project = Session::getProject();
- if ( is_object($project) )
- {
- $this->setTemplateVar('projectname',$project->name);
- }
-
- $this->tree = Session::getTree();
-
- //if ( $this->getRequestVar('target')!='tree' )
- $this->tree->refresh();
-
- $var = array();
- $var['zeilen'] = $this->outputElement( 0,0,array() );
- $var['zeilen'] = array();
-
- $this->setTemplateVars( $var );
- }
-
-
- /**
- * Anzeigen des Baumes fuer asynchrone Anfragen.
- */
- function loadAll()
- {
- $this->tree = Session::getTree();
-
- $this->setTemplateVar( 'lines',$this->outputElement( 0,0,array() ) );
- $this->setTemplateVar( 'tree',$this->tree->elements );
- }
-
- /**
- * Anzeigen des Baumes fuer asynchrone Anfragen.
- */
- public function loadEntryView()
- {
- exit;
- $this->tree = Session::getTree();
-
- $this->setTemplateVar( 'lines',$this->outputElement( 0,0,array() ) );
- $this->setTemplateVar( 'tree',$this->tree->elements );
- }
-
-
-
- /**
- * Anzeigen des Baumes fuer asynchrone Anfragen.
- */
- public function loadBranchView()
- {
- $project = Session::getProject();
- $projectid = $project->projectid;
-
- Logger::debug( "Initializing Tree for Project ".$projectid);
-
- if ( $projectid == -1 )
- {
- $tree = new AdministrationTree();
- }
- else
- {
- $tree = new ProjectTree();
- $tree->projectId = $projectid;
- }
-
-
- $type = $this->getRequestVar('type');
-
- $tree->tempElements = array();
-
- if ( intval($this->getRequestVar('id')) != 0 )
- $tree->$type( $this->getRequestId() );
- else
- $tree->$type();
-
- $branch = array();
- foreach( $tree->tempElements as $element )
- {
- $branch[] = get_object_vars($element);
- }
-
- $this->setTemplateVar( 'branch',$branch );
- }
-
-
- /**
- * Inhalt des Projektes anzeigen.
- */
- private function content()
- {
- if ( $this->hasRequestVar('projectid') )
- $this->load();
-
- // Nichts - denn der Baum lädt sich über AJAX selbst.
- }
-
-
- /**
- * Projekt-Einstellungen anzeigen.
- */
- public function settingsView()
- {
- $this->setTemplateVar( 'languages' ,Language::getAll() );
- $this->setTemplateVar( 'languageid',Session::getProjectLanguage()->languageid );
- $this->setTemplateVar( 'models' ,Model::getAll() );
- $this->setTemplateVar( 'modelid' ,Session::getProjectModel()->modelid );
- }
-
- public function settingsPost()
- {
- $language = new Language( $this->getRequestVar(REQ_PARAM_LANGUAGE_ID,OR_FILTER_NUMBER) );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $model = new Model( $this->getRequestVar(REQ_PARAM_MODEL_ID,OR_FILTER_NUMBER) );
- $model->load();
- Session::setProjectModel( $model );
-
- $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK);
- $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK);
- $this->refresh();
- }
-
-
- public function languagePost()
- {
- $language = new Language( $this->getRequestId() );
- $language->load();
- Session::setProjectLanguage( $language );
-
- $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK);
- $this->refresh();
- }
-
-
- public function modelPost()
- {
- $model = new Model( $this->getRequestId() );
- $model->load();
- Session::setProjectModel( $model );
-
- $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK);
- $this->refresh();
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/action/UrlAction.class.php b/action/UrlAction.class.php
@@ -1,189 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Folder;
-use cms\model\Url;
-
-
-
-
-
-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 $url;
- var $defaultSubAction = 'prop';
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->url = new Url( $this->getRequestId() );
- $this->url->load();
- }
-
-
-
- function remove()
- {
- $this->setTemplateVars( $this->url->getProperties() );
- }
-
-
-
- function delete()
- {
- if ( $this->hasRequestVar("delete") )
- {
- $this->url->delete();
- $this->addNotice('url',$this->url->name,'DELETED');
- }
- }
-
-
-
- /**
- * Abspeichern der Eigenschaften
- */
- function propPost()
- {
- // Wenn Name gefuellt, dann Datenbank-Update
- if ( $this->getRequestVar('name') != '' )
- {
- // Eigenschaften speichern
- $this->url->name = $this->getRequestVar('name' ,'full');
- $this->url->desc = $this->getRequestVar('description','full');
-
- $this->url->save();
- $this->url->setTimestamp();
- Session::setObject( $this->url );
- }
- }
-
-
- /**
- * Abspeichern der Eigenschaften
- */
- function editPost()
- {
- $this->url->url = $this->getRequestVar('url');
- $this->url->save();
- $this->url->setTimestamp();
- Session::setObject( $this->url );
-
- $this->addNotice('url',$this->url->name,'SAVED',OR_NOTICE_OK);
- }
-
-
-
- public function editView()
- {
- $this->setTemplateVars( $this->url->getProperties() );
-
- // Typ der Verknuepfung
- $this->setTemplateVar('type' ,$this->url->getType() );
- $this->setTemplateVar('url' ,$this->url->url );
- }
-
-
-
- function propView()
- {
- $this->setTemplateVars( $this->url->getProperties() );
- }
-
-
-
- function infoView()
- {
- $this->setTemplateVars( $this->url->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->url->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->url->objectid ] = array('id'=>$this->url->objectid,'name'=>$this->url->name,'type'=>'url','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/action/UserAction.class.php b/action/UserAction.class.php
@@ -1,506 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Acl;
-use cms\model\User;
-use cms\model\Project;
-use cms\model\Group;
-use cms\model\Object;
-use cms\model\Language;
-
-
-use Http;
-use security\Base2n;
-use \security\Password;
-use \Session;
-use \Html;
-use \Mail;
-
-// 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 zum Bearbeiten eines Benutzers
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class UserAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- var $user;
- var $defaultSubAction = 'edit';
-
-
- /**
- * UserAction constructor.
- * @throws \ObjectNotFoundException
- */
- function __construct()
- {
- $this->user = new User( $this->getRequestId() );
- $this->user->load();
- $this->setTemplateVar('userid',$this->user->userid);
- }
-
-
- function editPost()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- // Benutzer speichern
- $this->user->name = $this->getRequestVar('name' );
- $this->user->fullname = $this->getRequestVar('fullname');
- $this->user->isAdmin = $this->hasRequestVar('is_admin');
- $this->user->ldap_dn = $this->getRequestVar('ldap_dn' );
- $this->user->tel = $this->getRequestVar('tel' );
- $this->user->desc = $this->getRequestVar('desc' );
- $this->user->language = $this->getRequestVar('language');
- $this->user->timezone = $this->getRequestVar('timezone');
- $this->user->hotp = $this->hasRequestVar('hotp' );
- $this->user->totp = $this->hasRequestVar('totp' );
-
- global $conf;
- if ( @$conf['security']['user']['show_admin_mail'] )
- $this->user->mail = $this->getRequestVar('mail' );
-
- $this->user->style = $this->getRequestVar('style' );
-
- $this->user->save();
- $this->addNotice('user',$this->user->name,'SAVED','ok');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('edit');
- }
- }
-
-
-
- function removeView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
- }
-
-
-
- function removePost()
- {
- if ( $this->hasRequestVar('confirm') )
- {
- $this->user->delete();
- $this->addNotice('user',$this->user->name,'DELETED','ok');
- }
- else
- {
- $this->addValidationError('confirm');
- return;
- }
- }
-
-
- function addgrouptouser()
- {
- $this->user->addGroup( $this->getRequestVar('groupid') );
-
- $this->addNotice('user',$this->user->name,'ADDED','ok');
- }
-
-
- function addgroup()
- {
- // Alle hinzufuegbaren Gruppen ermitteln
- $this->setTemplateVar('groups',$this->user->getOtherGroups());
- }
-
-
- function delgroup()
- {
- $this->user->delGroup( $this->getRequestVar('groupid') );
-
- $this->addNotice('user',$this->user->name,'DELETED','ok');
- }
-
-
- /**
- * Das Kennwort wird an den Benutzer geschickt
- *
- * @access private
- */
- function mailPw( $pw )
- {
- $to = $this->user->fullname.' <'.$this->user->mail.'>';
- $mail = new Mail($to,'USER_MAIL');
-
- $mail->setVar('username',$this->user->name );
- $mail->setVar('password',$pw );
- $mail->setVar('name' ,$this->user->getName() );
-
- $mail->send();
- }
-
-
- /**
- * Aendern des Kennwortes
- */
- public function pwPost()
- {
- global $conf;
-
- $pw1 = $this->getRequestVar('password1');
- $pw2 = $this->getRequestVar('password2');
-
- $type = $this->getRequestVar('type');
-
- switch( $type )
- {
- case 'input':
- if ( strlen($pw1)<intval($conf['security']['password']['min_length']) )
- {
- $this->addValidationError('password1');
- return;
- }
- elseif ( $pw1 != $pw2 )
- {
- $this->addValidationError('password2');
- return;
- }
- else
- {
- $newPassword = $pw1;
- }
- break;
- case 'proposal';
- $newPassword = $this->getRequestVar('password_proposal');
- break;
- case 'random';
- $newPassword = $this->user->createPassword();
- break;
- default:
- Http::serverError('Type unknown: '.$type);
- }
-
- // Kennwoerter identisch und lang genug
- $this->user->setPassword($newPassword,!$this->hasRequestVar('timeout') ); // Kennwort setzen
-
- // E-Mail mit dem neuen Kennwort an Benutzer senden
- if ( $this->hasRequestVar('email') && !empty($this->user->mail) && $conf['mail']['enabled'] )
- {
- $this->mailPw( $newPassword );
- $this->addNotice('user',$this->user->name,'MAIL_SENT','ok');
- }
-
- $this->addNotice('user',$this->user->name,'SAVED','ok');
-
- }
-
-
-
- function listingView()
- {
- $list = array();
-
- foreach( User::getAllUsers() as $user )
- {
- /* @var $user User */
- $list[$user->userid] = $user->getProperties();
- $list[$user->userid]['url' ] = Html::url('main','user',$user->userid,
- array(REQ_PARAM_TARGETSUBACTION=>'edit') );
- }
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Eigenschaften des Benutzers ermitteln.
- */
- function editView()
- {
- global $conf;
-
- $issuer = urlencode(config('application','operator'));
- $account = $this->user->name.'@'.$_SERVER['SERVER_NAME'];
-
- $base32 = new Base2n(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', FALSE, TRUE, TRUE);
- $secret = $base32->encode(@hex2bin($this->user->otpSecret));
-
- $counter = $this->user->hotpCount;
-
- $this->setTemplateVars(
- $this->user->getProperties() +
- array('totpSecretUrl' => "otpauth://totp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}",
- 'hotpSecretUrl' => "otpauth://hotp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}&counter={$counter}"
- )
- + array('totpToken'=>Password::getTOTPCode($this->user->otpSecret))
- );
-
- $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
-
- $this->setTemplateVar('timezone_list',timezone_identifiers_list() );
-
- $languages = explode(',',$conf['i18n']['available']);
- foreach($languages as $id=>$name)
- {
- unset($languages[$id]);
- $languages[$name] = $name;
- }
- $this->setTemplateVar('language_list',$languages);
-
- }
-
-
-
-
- /**
- * Eigenschaften des Benutzers anzeigen
- */
- function infoView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
-
- $gravatarConfig = config('interface','gravatar');
-
- $this->setTemplateVar( 'image', 'about:blank' );
- if ( is_array($gravatarConfig) )
- {
- extract($gravatarConfig);
-
- if ( isset($enable) && $enable && !empty($this->user->mail) )
- {
- $url = 'http://www.gravatar.com/avatar/'.md5($this->user->mail).'?';
- if ( isset($size))
- $url .= '&s='.$size;
- if ( isset($default))
- $url .= '&d='.$default;
- if ( isset($rating))
- $url .= '&r='.$rating;
-
- $this->setTemplateVar( 'image', $url );
- }
- }
- }
-
-
- function membershipsView()
- {
- $gruppenListe = array();
-
- $allGroups = Group::getAll();
- $userGroups = $this->user->getGroups();
-
- foreach( $allGroups as $id=>$name )
- {
-
- $hasGroup = array_key_exists($id,$userGroups);
- $varName = 'group'.$id;
- $gruppenListe[$id] = array('name' =>$name,
- 'id' =>$id,
- 'var' =>$varName,
- 'member' =>$hasGroup
- );
- $this->setTemplateVar($varName,$hasGroup);
- }
- $this->setTemplateVar('memberships',$gruppenListe);
-
- global $conf;
- if ($conf['security']['authorize']['type']=='ldap')
- $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
- }
-
-
- function membershipsPost()
- {
- $allGroups = Group::getAll();
- $userGroups = $this->user->getGroups();
- $aenderung = false;
-
- foreach( $allGroups as $id=>$name )
- {
- $hasGroup = array_key_exists($id,$userGroups);
-
- if ( !$hasGroup && $this->hasRequestVar('group'.$id) )
- {
- $this->user->addGroup($id);
- $this->addNotice('group',$name,'ADDED');
- $aenderung = true;
- }
-
- if ( $hasGroup && !$this->hasRequestVar('group'.$id) )
- {
- $this->user->delGroup($id);
- $this->addNotice('group',$name,'DELETED');
- $aenderung = true;
- }
- }
-
- if ( ! $aenderung )
- $this->addNotice('group',$name,'NOTHING_DONE');
- }
-
-
- /**
- * Aendern des Kennwortes
- */
- function pwView()
- {
- $this->setTemplateVars( $this->user->getProperties() );
-
- $this->setTemplateVar('password_proposal', $this->user->createPassword() );
- }
-
-
- /**
- * Anzeigen der Benutzerrechte
- * @throws \ObjectNotFoundException
- */
- function rightsView()
- {
- $rights = $this->user->getAllAcls();
-
- $projects = array();
-
- foreach( $rights as $acl )
- {
- /* @var $acl Acl */
- if ( !isset($projects[$acl->projectid]))
- {
- $projects[$acl->projectid] = array();
- $p = new Project($acl->projectid);
- $p->load();
- $projects[$acl->projectid]['projectname'] = $p->name;
- $projects[$acl->projectid]['rights' ] = array();
- }
-
- $right = array();
-
- if ( $acl->languageid > 0 )
- {
- $language = new Language($acl->languageid);
- $language->load();
- $right['languagename'] = $language->name;
- }
- else
- {
- $right['languagename'] = lang('ALL_LANGUAGES');
- }
-
-
- $o = new Object($acl->objectid);
- $o->objectLoad();
- $right['objectname'] = $o->name;
- $right['objectid' ] = $o->objectid;
- $right['objecttype'] = $o->getType();
-
- if ( $acl->userid > 0 )
- {
- $user = new User($acl->userid);
- $user->load();
- $right['username'] = $user->name;
- }
- elseif ( $acl->groupid > 0 )
- {
- $group = new Group($acl->groupid);
- $group->load();
- $right['groupname'] = $group->name;
- }
- else
- {
- ;
- // Berechtigung fuer "alle".
- }
-
-// $show = array();
-// foreach( $acl->getProperties() as $p=>$set)
-// $show[$p] = $set;
-//
-// $right['show'] = $show;
- $right['bits'] = $acl->getProperties();
-
- $projects[$acl->projectid]['rights'][] = $right;
- }
-
- $this->setTemplateVar('projects' ,$projects );
-
- $this->setTemplateVar('show',Acl::getAvailableRights() );
-
- if ( $this->user->isAdmin )
- $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',OR_NOTICE_WARN);
- }
-
-
- /**
- * @param String $name Men�punkt
- * @return boolean
- */
- function checkMenu( $menu )
- {
- global $conf;
-
- switch( $menu )
- {
- case 'add':
- case 'remove':
- return !readonly();
-
- case 'addgroup':
- return !readonly() && count($this->user->getOtherGroups()) > 0;
-
- case 'groups':
- return !readonly() && count(Group::getAll()) > 0;
-
- case 'pw':
- return !readonly()
- && @$conf['security']['auth']['type'] == 'database'
- && !@$conf['security']['auth']['userdn'];
- }
-
- return true;
- }
-
-
- /**
- * Wechselt zu einem ausgewählten User.
- * @throws \ObjectNotFoundException
- */
- public function switchPost()
- {
- // User laden...
- $user = new User( $this->getRequestId() );
- $user->load();
-
- // Und in der Sitzung speichern.
- Session::setUser( $user );
-
- $this->refresh();
- }
-
-
- /**
- * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer in allen Projekten gemacht worden sind.
- */
- public function historyView()
- {
- $result = $this->user->getLastChanges();
- $this->setTemplateVar('timeline', $result);
- }
-
-
-}-
\ No newline at end of file
diff --git a/action/UserlistAction.class.php b/action/UserlistAction.class.php
@@ -1,87 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\User;
-
-// 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 zum Bearbeiten eines Benutzers
- * @author $Author$
- * @version $Revision$
- * @package openrat.actions
- */
-class UserlistAction extends Action
-{
- public $security = SECURITY_ADMIN;
-
- function __construct()
- {
- }
-
-
- function showView()
- {
- $list = array();
-
- foreach( User::getAllUsers() as $user )
- {
- $list[$user->userid] = $user->getProperties();
- $list[$user->userid]['id' ] = $user->userid;
- }
- $this->setTemplateVar('el',$list);
- }
-
-
- /**
- * Eigenschaften des Benutzers anzeigen
- */
- function editView()
- {
- $this->nextSubAction('show');
- }
-
-
-
- function addView()
- {
- }
-
-
-
- function addPost()
- {
- if ( $this->getRequestVar('name') != '' )
- {
- $this->user = new User();
- $this->user->add( $this->getRequestVar('name') );
- $this->addNotice('user',$this->user->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('name');
- $this->callSubAction('add');
- }
- }
-
-
-
-
-}-
\ No newline at end of file
diff --git a/action/WebdavAction.class.php b/action/WebdavAction.class.php
@@ -1,1217 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\User;
-use cms\model\Project;
-use cms\model\Page;
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\File;
-use cms\model\Link;
-
-
-/**
- * Action-Klasse fuer WebDAV.<br>
- *
- * Das virtuelle Ordnersystem dieses CMS kann �ber das WebDAV-Protokoll
- * dargestellt werden.
- *
- * Diese Klasse nimmt die Anfragen von WebDAV-Clients entgegen, zerlegt die
- * Anfrage und erzeugt eine Antwort, die im HTTP-Body zur�ck �bertragen
- * wird.
- * <br>
- * WebDAV ist spezifiziert in der RFC 2518.<br>
- * Siehe <code>http://www.ietf.org/rfc/rfc2518.txt</code><br>
- *
- * Implementiert wird DAV-Level 1 (d.h. ohne LOCK).
- *
- * Der Zugang über WebDAV beinhaltet einige Nachteile:
- * - Login ist nur mit Name/Kennwort möglich (kein OpenId)
- * - Nur die Standard-Datenbank kann verwendet werden
- * - Der Client muss Cookies unterstützen
- *
- * @author Jan Dankert
- * @package openrat.actions
- */
-
-class WebdavAction extends Action
-{
- public $security = SECURITY_USER;
-
- // Zahlreiche Instanzvariablen, die im Konstruktor
- // beim Zerlegen der Anfrag gef�llt werden.
- var $defaultSubAction = 'show';
- var $database;
- var $depth;
- var $project;
- var $folder;
- var $obj;
- var $filename;
- var $pathnames = array();
- var $uri;
- var $headers;
- var $requestType;
- var $request;
- var $destination = null;
- var $fullSkriptName;
- var $create;
- var $readonly;
- var $maxFileSize;
- var $webdav_conf;
- var $overwrite = false;
-
-
- /**
- * Im Kontruktor wird der Request analysiert und ggf. eine Authentifzierung
- * durchgefuehrt.
- */
- function __construct()
- {
- if (!defined('E_STRICT'))
- define('E_STRICT', 2048);
-
- // Nicht notwendig, da wir den Error-Handler umbiegen:
- error_reporting(0); // PHP-Fehlermeldungen zerstoeren XML-Dokument, daher ausschalten.
-
- // PHP-Fehler ins Log schreiben, damit die Ausgabe nicht zerstoert wird.
- if (version_compare(PHP_VERSION, '5.0.0', '>'))
- set_error_handler('webdavErrorHandler',E_ERROR | E_WARNING);
- else
- set_error_handler('webdavErrorHandler');
-
-
- //Changed tobias
- //global $conf;
- $prefs = new Preferences();
- $conf = $prefs->load();
- //End changed Tobias
- $this->webdav_conf = $conf['webdav'];
-
- if ( $this->webdav_conf['compliant_to_redmond'] )
- header('MS-Author-Via: DAV' ); // Extrawurst fuer MS-Clients.
-
- if ( $this->webdav_conf['expose_openrat'] )
- header('X-Dav-powered-by: OpenRat CMS'); // Bandbreite verschwenden :)
-
- Logger::trace( 'WEBDAV: URI='.$_SERVER['REQUEST_URI']);
-
- if ( !$conf['webdav']['enable'])
- {
- Logger::warn( 'WEBDAV is disabled by configuration' );
- $this->httpStatus('403 Forbidden');
- exit;
- }
-
- $this->create = $this->webdav_conf['create'];
- $this->readonly = $this->webdav_conf['readonly'];
- $this->maxFileSize = $this->webdav_conf['max_file_size'];
-
- Logger::debug( 'WEBDAV method is '.$_GET['subaction'] );
-
- $this->headers = getallheaders();
- /* DAV compliant servers MUST support the "0", "1" and
- * "infinity" behaviors. By default, the PROPFIND method without a Depth
- * header MUST act as if a "Depth: infinity" header was included. */
- if ( !isset($this->headers['Depth']) )
- $this->depth = 1;
- elseif ( strtolower($this->headers['Depth'])=='infinity')
- $this->depth = 1;
- else
- $this->depth = intval($this->headers['Depth']);
-
- if ( isset($this->headers['Destination']) )
- $this->destination = $this->headers['Destination'];
-
- if ( isset($this->headers['Overwrite']) )
- $this->overwrite = $this->headers['Overwrite'] == 'T';
-
- // Pr�fen, ob Benutzer angemeldet ist.
- $user = $this->getUserFromSession();
-
- // Authentisierung erzwingen (au�er bei Methode OPTIONS).
- // For the motivation for not checking OPTIONS requests see
- // http://pear.php.net/bugs/bug.php?id=5363
- if ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] != 'options' )
- {
- Logger::debug( 'Checking Authentication' );
-
- if ( !is_object(Session::getDatabase()) )
- $this->setDefaultDb();
-
- $ok = false;
- if ( isset($_SERVER['PHP_AUTH_USER']) )
- {
- $user = new User();
- $user->name = $_SERVER['PHP_AUTH_USER'];
-
- $ok = $user->checkPassword( $_SERVER['PHP_AUTH_PW'] );
-
- if ( $ok )
- {
- $user->load();
- $user->setCurrent();
- $this->redirectWithSessionId();
- }
- }
-
- if ( !$ok )
- {
- // Client ist nicht angemeldet, daher wird nun die
- // Authentisierung angefordert.
- Logger::debug( 'Requesting Client to authenticate' );
- header('WWW-Authenticate: Basic realm="'.OR_TITLE.'"');
- $this->httpStatus('401 Unauthorized');
- exit;
- }
- }
- elseif ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] == 'options' )
- {
- $this->setDefaultDb();
- }
-
-
- $this->fullSkriptName = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'/';
-
- if ( $this->webdav_conf['session_in_uri'] )
- $sos = 1+strlen(session_id())+strlen($this->webdav_conf['session_in_uri_prefix']);
- else
- $sos = 0;
-
- // URL parsen.
- $uri = substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']) + $sos);
-
- Logger::debug( 'WebDAV: URI="'.$uri.'"' );
-
- $uri = $this->parseURI( $uri );
- $this->requestType = $uri['type' ];
- $this->folder = $uri['folder' ];
- $this->obj = $uri['object' ];
- $this->project = $uri['project'];
-
- $this->fullSkriptName .= implode('/',$uri['path']);
-
- if ( is_object($this->obj) && $this->obj->isFolder )
- $this->fullSkriptName .= '/';
-
- /*
- * Verzeichnisse muessen mit einem '/' enden. Falls nicht, Redirect aussfuehren.
- *
- * RFC 2518, 5.2 Collection Resources, Page 11:
- * "For example, if a client invokes a
- * method on http://foo.bar/blah (no trailing slash), the resource
- * http://foo.bar/blah/ (trailing slash) may respond as if the operation
- * were invoked on it, and should return a content-location header with
- * http://foo.bar/blah/ in it. In general clients SHOULD use the "/"
- * form of collection names."
- */
- if ( is_object($this->obj) &&
- $this->obj->isFolder &&
- $_GET['subaction'] == 'get' &&
- substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1 ) != '/' )
- {
- Logger::debug( 'WebDAV: Redirecting lame client to slashyfied URL' );
-
- header('HTTP/1.1 302 Moved Temporarily');
- header('Location: '.$_SERVER['REQUEST_URI'].'/');
- exit;
- }
-
- // Falls vorhanden, den "Destination"-Header parsen.
- if ( isset($_SERVER['HTTP_DESTINATION']) )
- {
- $destUri = parse_url( $_SERVER['HTTP_DESTINATION'] );
-
- $uri = substr($destUri['path'],strlen($_SERVER['SCRIPT_NAME'])+$sos);
-
- // URL parsen.
- $this->destination = $this->parseURI( $uri );
- }
-
- // Den Request-BODY aus der Standardeingabe lesen.
- $this->request = implode('',file('php://input'));
- }
-
-
-
- /**
- * Falls ein WebDAV-Client keine Cookies setzen kann (was HTTP/1.1 eigentlich
- * der Fall sein sollte), kann die Session-Id in die URL eingetragen
- * werden. Dies muss in der Konfiguration aktiviert werden.
- */
- function redirectWithSessionId()
- {
- if ( $this->webdav_conf['session_in_uri'] )
- {
- header('Location: '.dirname($_SERVER['REQUEST_URI']).'/'. $this->webdav_conf['session_in_uri_prefix'].session_id().'/'.basename($_SERVER['REQUEST_URI']));
- //$this->httpStatus('303 See Other');
- $this->httpStatus('302 Moved');
- }
- }
-
-
-
- /**
- * Da im WebDAV-Request keine Datenbank-Id angegeben werden kann, benutzen
- * wir hier die Standard-Datenbank.
- */
- function setDefaultDb()
- {
- global $conf;
-
- if ( !isset($conf['database']['default']) )
- {
- Logger::error('No default database in configuration');
- $this->httpStatus('500 Internal Server Error - no default-database in configuration');
- }
-
- $dbid = $conf['database']['default'];
-
- $db = new DB( $conf['database'][$dbid] );
- $db->id = $dbid;
- Session::setDatabase( $db );
- }
-
-
-
- function allowed_methods()
- {
-
- if ($this->readonly)
- return array('OPTIONS','HEAD','GET','PROPFIND'); // Readonly-Modus
- else
- // PROPPATCH unterstuetzen wir garnicht, aber lt. Spec sollten wir das.
- return array('OPTIONS','HEAD','GET','PROPFIND','DELETE','PUT','COPY','MOVE','MKCOL','PROPPATCH');
- }
-
-
-
- /**
- * HTTP-Methode OPTIONS.<br>
- * <br>
- * Es werden die verfuegbaren Methoden ermittelt und ausgegeben.
- */
- function options()
- {
- header('DAV: 1'); // Wir haben DAV-Level 1.
- header('Allow: '.implode(', ',$this->allowed_methods()) );
-
- $this->httpStatus( '200 OK' );
- }
-
-
-
- /**
- * Setzt einen HTTP-Status.<br>
- * <br>
- * Es wird ein HTTP-Status gesetzt, zus�tzlich wird der Status in den Header "X-WebDAV-Status" geschrieben.<br>
- * Ist der Status nicht 200 oder 207 (hier folgt ein BODY), wird das Skript beendet.
- */
- function httpStatus( $status = true )
- {
- if ( $status === true )
- $status = '200 OK';
-
- Logger::debug('WEBDAV: HTTP-Status: '.$status);
-
- header('HTTP/1.1 '.$status);
- header('X-WebDAV-Status: '.$status,true);
-
- // RFC 2616 (HTTP/1.1), Section 10.4.6 "405 Method Not Allowed" says:
- // "[...] The response MUST include an
- // Allow header containing a list of valid methods for the requested
- // resource."
- //
- // RFC 2616 (HTTP/1.1), Section 14.7 "Allow" says:
- // "[...] An Allow header field MUST be
- // present in a 405 (Method Not Allowed) response."
- if ( substr($status,0,3) == '405' )
- header('Allow: '.implode(', ',$this->allowed_methods()) );
- }
-
-
-
- /**
- * WebDav-HEAD-Methode.
- */
- function head()
- {
- if ( $this->obj == null )
- {
- $this->httpStatus( '404 Not Found' );
- }
- elseif ( $this->obj->isFolder )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isPage )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isLink )
- {
- $this->httpStatus( '200 OK' );
- }
- elseif( $this->obj->isFile )
- {
- $this->httpStatus( '200 OK' );
- }
- }
-
-
-
- /**
- * WebDav-GET-Methode.
- * Die gew�nschte Datei wird geladen und im HTTP-Body mitgeliefert.
- */
- function get()
- {
- if ( $this->obj->isFolder )
- $this->getDirectory();
- elseif( $this->obj->isPage )
- {
- $this->httpStatus( '200 OK' );
-
- header('Content-Type: text/html');
-
- $page = new Page( $this->obj->objectid );
- $page->load();
- echo '<html><head><title>OpenRat WEBDAV Access</title></head>';
- echo '<body>';
- echo '<h1>'.$page->full_filename().'</h1>';
- echo '<pre>';
- echo 'No Content available';
- echo '</pre>';
- echo '</body>';
- echo '</html>';
- }
- elseif( $this->obj->isLink )
- {
- $this->httpStatus( '200 OK' );
-
- header('Content-Type: text/plain');
-
- $link = new Link( $this->obj->objectid );
- $link->load();
- echo 'url: ' .$link->url ."\n";
- echo 'target-id: '.$link->linkedObjectId."\n";
- }
- elseif( $this->obj->isFile )
- {
- $this->httpStatus( '200 OK' );
-
- $file = new File( $this->obj->objectid );
- $file->load();
-
- header('Content-Type: '.$file->mimeType() );
- header('X-File-Id: '.$file->fileid );
-
- // Angabe Content-Disposition
- // - Bild soll "inline" gezeigt werden
- // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
- header('Content-Disposition: inline; filename='.$file->filenameWithExtension() );
- header('Content-Transfer-Encoding: binary' );
- header('Content-Description: '.$file->name );
-
- $file->write(); // Bild aus Datenbank laden und in tempor�re Datei schreiben
-
- // Groesse des Bildes in Bytes
- // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
- header('Content-Length: '.filesize($file->tmpfile()) );
- readfile( $file->tmpfile() );
- }
- }
-
-
-
- /**
- * Erzeugt ein Unix-�hnliche Ausgabe des Verzeichnisses als HTML.
- */
- function getDirectory()
- {
- $this->httpStatus( '200 OK' );
-
- // Verzeichnis ausgeben
- header('Content-Type: text/html');
- $nl = "\n";
- $titel = 'Index of '.htmlspecialchars($this->fullSkriptName);
- $format = "%15s %-19s %-s\n";
-
- echo '<html><head><title>'.$titel.'</title></head>';
- echo '<body>';
- echo '<h1>'.$titel.'</h1>'.$nl;
- echo '<pre>';
-
- printf($format, "Size", "Last modified", "Filename");
-
- if ( $this->requestType == 'projectlist' )
- {
- foreach(Project::getAllProjects() as $projectName )
- {
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $z;
- $objektinhalt['size' ] = 1;
- echo '<a href="'.$this->fullSkriptName.'/'.$projectName.'"> </a>';
- }
- }
- elseif( $this->requestType == 'object' ) // Verzeichnisinhalt
- {
- $objects = $this->folder->getObjects();
-
- foreach( $objects as $object )
- {
- printf($format,
- number_format(1),
- strftime("%Y-%m-%d %H:%M:%S",$object->lastchangeDate ),
- '<a href="'.$object->filename.'">'.$object->filename.'</a>');
- echo $nl;
- }
- }
-
- echo '</pre>';
- echo '</body>';
- echo '</html>';
- }
-
-
-
- /**
- * Die Methode LOCK sollte garnicht aufgerufen werden, da wir nur
- * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
- * <br>
- * Ausgabe von HTTP-Status 412 (Precondition failed)
- */
- function lock()
- {
- $this->httpStatus('412 Precondition failed');
- $this->options();
- }
-
-
-
- /**
- * Die Methode UNLOCK sollte garnicht aufgerufen werden, da wir nur
- * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
- * <br>
- * Ausgabe von HTTP-Status 412 (Precondition failed)
- */
- function unlock()
- {
- $this->httpStatus('412 Precondition failed');
- $this->options();
- }
-
-
-
- /**
- * Die Methode POST ist bei WebDav nicht sinnvoll.<br>
- * <br>
- * Ausgabe von HTTP-Status 405 (Method Not Allowed)
- */
- function post()
- {
- // Die Methode POST ist bei Webdav nicht sinnvoll.
- $this->httpStatus('405 Method Not Allowed' );
- }
-
-
-
- /**
- * Verzeichnis anlegen.
- */
- function mkcol()
- {
-
- if ( !empty($this->request) )
- {
- $this->httpStatus('415 Unsupported Media Type' ); // Kein Body erlaubt
- }
- elseif ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
- }
- elseif ( !$this->folder->hasRight( ACL_CREATE_FOLDER ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
- }
- elseif ( $this->obj == null )
- {
- // Die URI ist noch nicht vorhanden
- $f = new Folder();
- $f->filename = basename($this->fullSkriptName);
- $f->parentid = $this->folder->objectid;
- $f->projectid = $this->project->projectid;
- $f->add();
- $this->httpStatus('201 Created');
- }
- else
- {
- // MKCOL ist nicht moeglich, wenn die URI schon existiert.
- Logger::warn('MKCOL-Request to an existing resource');
- $this->httpStatus('405 Method Not Allowed' );
- }
- }
-
-
-
- /**
- * Objekt l�schen.
- */
- function delete()
- {
- if ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
- }
- else
- {
- if ( $this->obj == null )
- {
- // Nicht existente URIs kann man auch nicht loeschen.
- $this->httpStatus('404 Not Found' );
- }
- elseif ( ! $this->obj->hasRight( ACL_DELETE ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf die Resource nicht loeschen
- }
- elseif ( $this->obj->isFolder )
- {
- $f = new Folder( $this->obj->objectid );
- $f->deleteAll();
- $this->httpStatus( true ); // OK
- Logger::debug('Deleted folder with id '.$this->obj->objectid );
- }
- elseif ( $this->obj->isFile )
- {
- $f = new File( $this->obj->objectid );
- $f->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isPage )
- {
- $p = new Page( $this->obj->objectid );
- $p->delete();
- $this->httpStatus( true ); // OK
- }
- elseif ( $this->obj->isLink )
- {
- $l = new Link( $this->obj->objectid );
- $l->delete();
- $this->httpStatus( true ); // OK
- }
-
- }
- }
-
-
-
- /**
- * Kopieren eines Objektes.<br>
- * Momentan ist nur das Kopieren einer Datei implementiert.<br>
- * Das Kopieren von Ordnern, Verkn�pfungen und Seiten ist nicht moeglich.
- */
- function copy()
- {
- if ( $this->readonly || !$this->create )
- {
- Logger::error('WEBDAV: COPY request, but readonly or no creating');
- $this->httpStatus('405 Not Allowed' );
- }
- elseif( $this->obj == null )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- Logger::error('WEBDAV: COPY request, but Source not found');
- $this->httpStatus('405 Not Allowed' );
- }
- elseif ( $this->destination == null )
- {
- Logger::error('WEBDAV: COPY request, but no "Destination:"-Header');
- // $this->httpStatus('405 Not Allowed' );
- $this->httpStatus('412 Precondition failed');
- }
- else
- {
- // URL parsen.
- $dest = $this->destination;
- $destinationProject = $dest['project'];
- $destinationFolder = $dest['folder' ];
- $destinationObject = $dest['object' ];
-
- if ( $dest['type'] != 'object' )
- {
- Logger::debug('WEBDAV: COPY request, but "Destination:"-Header mismatch');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( $this->project->projectid != $destinationProject->projectid )
- {
- // Kopieren in anderes Projekt nicht moeglich.
- Logger::debug('WEBDAV: COPY request denied, project does not match');
- $this->httpStatus('403 Forbidden');
- }
- elseif ( $destinationObject != null )
- {
- Logger::debug('WEBDAV: COPY request denied, Destination exists. Overwriting is not supported');
- $this->httpStatus('403 Forbidden');
- }
- elseif ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
- {
- $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
- }
- elseif ( is_object($destinationObject) && $destinationObject->isFolder)
- {
- Logger::debug('WEBDAV: COPY request denied, Folder-Copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( is_object($destinationObject) && $destinationObject->isLink)
- {
- Logger::debug('WEBDAV: COPY request denied, Link copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- elseif ( is_object($destinationObject) && $destinationObject->isPage)
- {
- Logger::debug('WEBDAV: COPY request denied, Page copy not implemented');
- $this->httpStatus('405 Not Allowed');
- }
- else
- {
- $f = new File();
- $f->filename = basename($_SERVER['HTTP_DESTINATION']);
- $f->name = '';
- $f->parentid = $destinationFolder->objectid;
- $f->projectid = $this->project->projectid;
- $f->add();
- $f->copyValueFromFile( $this->obj->objectid );
-
- Logger::debug('WEBDAV: COPY request accepted' );
- // Objekt wird in anderen Ordner kopiert.
- $this->httpStatus('201 Created' );
- }
- }
-
- }
-
-
-
- /**
- * Verschieben eines Objektes.<br>
- * <br>
- * Folgende Operationen sind m�glich:<br>
- * - Unbenennen eines Objektes (alle Typen)<br>
- * - Verschieben eines Objektes (alle Typen) in einen anderen Ordner.<br>
- */
- function move()
- {
- if ( $this->readonly )
- {
- $this->httpStatus('403 Forbidden - Readonly Mode' ); // Schreibgeschuetzt
- }
- elseif ( !$this->create )
- {
- $this->httpStatus('403 Forbidden - No creation' ); // Schreibgeschuetzt
- }
- elseif( $this->obj == null )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- $this->httpStatus('404 Not Found' );
- }
- elseif( is_object($this->obj) && ! $this->obj->hasRight( ACL_WRITE ) )
- {
- // Was nicht da ist, laesst sich auch nicht verschieben.
- Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
- $this->httpStatus('403 Forbidden' );
- }
- elseif ( $this->destination == null )
- {
- Logger::error('WEBDAV: MOVE request, but no "Destination:"-Header');
- // $this->httpStatus('405 Not Allowed' );
- $this->httpStatus('412 Precondition failed');
- }
- else
- {
- $dest = $this->destination;
- $destinationProject = $dest['project'];
- $destinationFolder = $dest['folder' ];
- $destinationObject = $dest['object' ];
-
- if ( $dest['type'] != 'object' )
- {
- Logger::debug('WEBDAV: MOVE request, but "Destination:"-Header mismatch');
- $this->httpStatus('405 Not Allowed');
- return;
- }
-
- if ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
- {
- Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
- $this->httpStatus('403 Forbidden' );
- }
-
- if ( $destinationObject != null )
- {
- Logger::debug('WEBDAV: MOVE request denied, destination exists');
- $this->httpStatus('412 Precondition Failed');
- return;
- }
-
- if ( $this->project->projectid != $destinationProject->projectid )
- {
- // Verschieben in anderes Projekt nicht moeglich.
- Logger::debug('WEBDAV: MOVE request denied, project does not match');
- $this->httpStatus('405 Not Allowed');
- return;
- }
-
- if ( $this->folder->objectid == $destinationFolder->objectid )
- {
- Logger::debug('WEBDAV: MOVE request accepted, object renamed');
- // Resource bleibt in gleichem Ordner.
- $this->obj->filename = basename($_SERVER['HTTP_DESTINATION']);
- $this->obj->objectSave(false);
- $this->httpStatus('201 Created' );
- return;
- }
-
- if ( $destinationFolder->isFolder )
- {
- Logger::debug('WEBDAV: MOVE request accepted, Destination: '.$destinationFolder->filename );
- // Objekt wird in anderen Ordner verschoben.
- $this->obj->setParentId( $destinationFolder->objectid );
- $this->httpStatus('201 Created' );
- return;
- }
-
- Logger::warn('WEBDAV: MOVE request failed' );
- $this->httpStatus('500 Internal Server Error' );
- }
- }
-
-
-
- /**
- * Anlegen oder �berschreiben Dateien �ber PUT.<br>
- * Dateien k�nnen neu angelegt und �berschrieben werden.<br>
- * <br>
- * Seiten k�nnen nicht �berschrieben werden. Wird versucht,
- * eine Seite mit PUT zu �berschreiben, wird der Status "405 Not Allowed" gemeldet.<br>
- */
- function put()
- {
- // TODO: 409 (Conflict) wenn �bergeordneter Ordner nicht da.
-
- if ( $this->webdav_conf['readonly'] )
- {
- $this->httpStatus('405 Not Allowed' );
- }
- elseif ( strlen($this->request) > $this->maxFileSize*1000 )
- {
- // Maximale Dateigroesse ueberschritten.
- // Der Status 207 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :)
- $this->httpStatus('507 Insufficient Storage' );
- }
- elseif ( $this->obj == null )
- {
- // Neue Datei anlegen
- if ( !$this->webdav_conf['create'] )
- {
- Logger::warn('WEBDAV: Creation of files not allowed by configuration' );
- $this->httpStatus('405 Not Allowed' );
- }
-
- if ( ! $this->folder->hasRight( ACL_CREATE_FILE ) )
- {
- $this->httpStatus('403 Forbidden');
- return;
- }
-
- $file = new File();
- $file->filename = basename($this->fullSkriptName);
- $file->extension = '';
- $file->size = strlen($this->request);
- $file->parentid = $this->folder->objectid;
- $file->projectid = $this->project->projectid;
- $file->value = $this->request;
- $file->add();
- $this->httpStatus('201 Created');
- return;
- }
- elseif ( $this->obj->isFile )
- {
- if ( ! $this->obj->hasRight( ACL_WRITE ) )
- {
- Logger::debug('PUT failed, parent folder not writable by user' );
- $this->httpStatus('403 Forbidden');
- return;
- }
-
- // Bestehende Datei ueberschreiben.
- $file = new File( $this->obj->objectid );
- $file->saveValue( $this->request );
- $file->setTimestamp();
- $this->httpStatus('204 No Content');
- Logger::debug('PUT ok, file is created' );
- return;
- }
- elseif ( $this->obj->isFolder )
- {
- Logger::error('PUT on folder is not supported, use PROPFIND. Lame client?' );
- $this->httpStatus('405 Not Allowed' );
- }
- else
- {
- // Fuer andere Objekttypen (Links, Seiten) ist kein PUT moeglich.
- Logger::warn('PUT only available for files, pages and links are ignored' );
- $this->httpStatus('405 Not Allowed' );
- }
- }
-
-
-
- /**
- * WebDav-Methode PROPFIND.
- *
- * Diese Methode wird
- * - beim Ermitteln von Verzeichnisinhalten und
- * - beim Ermitteln von Metainformationen zu einer Datei
- * verwendet.
- *
- * Das Ergebnis wird in einer XML-Zeichenkette geliefert.
- */
- function propfind()
- {
- switch( $this->requestType )
- {
- case 'projectlist': // Projektliste
-
- $inhalte = array();
-
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $z;
- $objektinhalt['size' ] = 1;
- $objektinhalt['name' ] = $this->fullSkriptName;
- $objektinhalt['displayname' ] = '';
- $objektinhalt['type'] = 'folder';
-
- $inhalte[] = $objektinhalt;
-
- foreach(Project::getAllProjects() as $projectid=> $projectName )
- {
- $project = new Project( $projectid );
- $rootObjectId = $project->getRootObjectId();
- $folder = new Folder( $rootObjectId );
- $folder->load();
-
- $objektinhalt = array();
- $z = 30*365.25*24*60*60;
- $objektinhalt['createdate' ] = $z;
- $objektinhalt['lastchangedate'] = $folder->lastchangeDate;
- $objektinhalt['size' ] = $project->size();
- $objektinhalt['name' ] = $this->fullSkriptName.$projectName.'/';
- $objektinhalt['displayname' ] = $projectName;
- $objektinhalt['type'] = 'folder';
- $inhalte[] = $objektinhalt;
- }
-
- $this->multiStatus( $inhalte );
- break;
-
- case 'object': // Verzeichnisinhalt
-
- if ( $this->obj == null )
- {
- // Objekt existiert nicht.
- Logger::trace( 'WEBDAV: PROPFIND of non-existent object');
- $this->httpStatus('404 Not Found');
- return;
- }
- elseif ( $this->obj->isFolder )
- {
- if ( ! $this->obj->hasRight( ACL_READ ))
- {
- Logger::debug( 'Folder '.$this->obj->objectid.': access denied');
- $this->httpStatus('403 Forbidden');
- }
-
- $inhalte = array();
-
- $objektinhalt = array();
- $objektinhalt['createdate' ] = $this->obj->createDate;
- $objektinhalt['lastchangedate'] = $this->obj->lastchangeDate;
- $objektinhalt['name' ] = $this->fullSkriptName;
- $objektinhalt['displayname' ] = basename($this->fullSkriptName);
- $objektinhalt['type' ] = 'folder';
- $objektinhalt['size' ] = 0;
- $inhalte[] = $objektinhalt;
-
- if ( $this->depth > 0 )
- {
- $objects = $this->folder->getObjects();
- foreach( $objects as $object )
- {
- if ( ! $object->hasRight( ACL_READ ))
- continue;
-
- //$object->loadRaw();
- $objektinhalt = array();
- $objektinhalt['createdate' ] = $object->createDate;
- $objektinhalt['lastchangedate'] = $object->lastchangeDate;
- $objektinhalt['displayname' ] = $object->filename;
-
- switch( $object->getType() )
- {
-
- case OR_TYPE_FOLDER:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename.'/';
- $objektinhalt['type'] = 'folder';
- $objektinhalt['size'] = 0;
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_FILE:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $file = new File($object->objectid);
- $file->load();
- $objektinhalt['size'] = $file->size;
- $objektinhalt['mime'] = 'application/x-non-readable';
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_LINK:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $objektinhalt['size'] = 0;
- $objektinhalt['mime'] = 'application/x-non-readable';
- $inhalte[] = $objektinhalt;
- break;
- case OR_TYPE_PAGE:
- $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
- $objektinhalt['type'] = 'file';
- $objektinhalt['size'] = 0;
- $inhalte[] = $objektinhalt;
- break;
- default:
- }
- }
- }
- Logger::trace( 'WEBDAV: PROPFIND-2');
-
-// if ( count($inhalte)==0 )
-// $inhalte[] = array('createdate'=>0,'lastchangedate'=>0,'name'=>'empty','size'=>0,'type'=>'file');
-
- Logger::trace('Anzahl Dateien:'.count($inhalte));
- $this->multiStatus( $inhalte );
- }
- else
- {
- $object = $this->obj;
- Logger::trace( 'WEBDAV: PROPFIND of file');
- $objektinhalt = array();
- $objektinhalt = array();
- $objektinhalt['name'] = $this->fullSkriptName.'/'.$object->filename.'/';
- $objektinhalt['displayname'] = $object->filename;
- $objektinhalt['createdate' ] = $object->createDate;
- $objektinhalt['lastchangedate'] = $object->lastchangeDate;
- $file = new File( $this->obj->objectid );
- $file->load();
- $objektinhalt['size' ] = $file->size;
- $objektinhalt['type' ] = 'file';
-
-
- $this->multiStatus( array($objektinhalt) );
- }
- break;
-
- default:
- Logger::warn('Internal Error, unknown request type: '. $this->requestType);
- $this->httpStatus('500 Internal Server Error');
- }
- }
-
-
- /**
- * Webdav-Methode PROPPATCH ist nicht implementiert.
- */
- function proppatch()
- {
- // TODO: Multistatus erzeugen.
- // Evtl. ist '409 Conflict' besser?
- $this->httpStatus('405 Not Allowed');
- }
-
-
- /**
- * Erzeugt einen Multi-Status.
- * @access private
- */
- function multiStatus( $files )
- {
- $this->httpStatus('207 Multi-Status');
- header('Content-Type: text/xml; charset=utf-8');
-
- $response = '';
- $response .= '<?xml version="1.0" encoding="utf-8" ?>';
- $response .= '<d:multistatus xmlns:d="DAV:">';
-
- foreach( $files as $file )
- $response .= $this->getResponse( $file['name'],$file );
-
- $response .= '</d:multistatus>';
- Logger::trace('PROPFIND: '.$response);
-
- $response = utf8_encode($response);
-
- header('Content-Length: '.strlen($response));
- echo $response;
- }
-
-
- /**
- * Erzeugt ein "response"-Element, welches in ein "multistatus"-element verwendet werden kann.
- */
- function getResponse( $file,$options )
- {
- // TODO: Nur angeforderte Elemente erzeugen.
- $response = '';
- $response .= '<d:response>';
- $response .= '<d:href>'.$file.'</d:href>';
- $response .= '<d:propstat>';
- $response .= '<d:prop>';
- // $response .= '<d:source></d:source>';
- $response .= '<d:creationdate>'.date('r',$options['createdate']).'</d:creationdate>';
- $response .= '<d:displayname>'.$options['displayname'].'</d:displayname>';
- $response .= '<d:getcontentlength>'.$options['size'].'</d:getcontentlength>';
- $response .= '<d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">'.date('r',$options['lastchangedate']).'</d:getlastmodified>';
-
- if ( $options['type'] == 'folder')
- $response .= '<d:resourcetype><d:collection/></d:resourcetype>';
- else
- $response .= '<d:resourcetype />';
-
- $response .= '<d:categories />';
- $response .= '<d:fields></d:fields>';
-
-
-
-// $response .= '<d:getcontenttype>text/html</d:getcontenttype>';
-// $response .= '<d:getcontentlength />';
-// $response .= '<d:getcontentlanguage />';
-// $response .= '<d:executable />';
-// $response .= '<d:resourcetype>';
-// $response .= '<d:collection />';
-// $response .= '</d:resourcetype>';
-// $response .= '<d:getetag />';
-
- $response .= '</d:prop>';
- $response .= '<d:status>HTTP/1.1 200 OK</d:status>';
- $response .= '</d:propstat>';
- $response .= '</d:response>';
-
- return $response;
- }
-
-
-
- /**
- * URI parsen.
- */
- function parseURI( $uri )
- {
- // Ergebnis initialisieren (damit alle Schl�ssel vorhanden sind)
- $ergebnis = array('type' => null,
- 'project' => null,
- 'path' => array(),
- 'folder' => null,
- 'object' => null );
-
- Logger::trace( 'WEBDAV: Parsen der URI '.$uri);
- $uriParts = explode('/',$uri);
-
- $nr = 0;
- $f = null;
- $o = null;
- $ergebnis['type'] = 'projectlist';
-
- foreach( $uriParts as $uriPart )
- {
- if ( empty( $uriPart))
- continue;
-
- $ergebnis['path'][] = $uriPart;
-
- if ( $f == null )
- {
- // URI='/project/'
- // Name des Projektes in der URL, es wird das Projekt geladen.
- $ergebnis['type'] = 'object';
-
- $p = new Project();
- $p->name = $uriPart;
- Logger::trace("Projektname: ".$p->name);
- $p->loadByName();
- $ergebnis['project'] = $p;
- // Das Projekt hat weder Sprache noch Variante gesetzt.
- //Session::setProjectLanguage( new Language( $this->project->getDefaultLanguageId() ) );
- //Session::setProjectModel ( new Model ( $this->project->getDefaultModelId() ) );
-
- $oid = $p->getRootObjectId();
-
- $f = new Folder($oid);
- $ergebnis['object'] = $f;
- $ergebnis['folder'] = $f;
-
- }
- else
- {
- if ( $ergebnis['object'] == null )
- {
- $this->httpStatus('409 Conflict');
- exit;
- }
-
- $oid = $f->getObjectIdByFileName($uriPart);
-
- if ( $oid == 0 )
- {
- Logger::trace( 'WEBDAV: URL-Part does not exist: '.$uriPart);
- $ergebnis['object'] = null;
- }
- else
- {
- Logger::trace( 'Teil '.$uriPart);
- $o = new Object($oid);
- $o->load();
- $ergebnis['object'] = $o;
-
- if ( $o->isFolder )
- {
- $f = new Folder($oid);
- $ergebnis['folder'] = $f;
- }
- }
- }
- }
-
- return $ergebnis;
- }
-}
-
-
-
-/**
- * Fehler-Handler fuer WEBDAV.<br>
- * Bei einem Laufzeitfehler ist eine Ausgabe des Fehlers auf der Standardausgabe sinnlos,
- * da der WebDAV-Client dies nicht lesen oder erkennen kann.
- * Daher wird der Fehler-Handler umgebogen, so dass nur ein Logeintrag sowie ein
- * Server-Fehler erzeugt wird.
- */
-function webdavErrorHandler($errno, $errstr, $errfile, $errline)
-{
- Logger::warn('WEBDAV ERROR: '.$errno.'/'.$errstr.'/file:'.$errfile.'/line:'.$errline);
-
- // Wir teilen dem Client mit, dass auf dem Server was schief gelaufen ist.
- WebdavAction::httpStatus('500 Internal Server Error, WebDAV-Request failed with "'.$errstr.'"');
-}
-
-?>-
\ No newline at end of file
diff --git a/action/WorkbenchAction.class.php b/action/WorkbenchAction.class.php
@@ -1,82 +0,0 @@
-<?php
-
-namespace cms\action;
-
-use cms\model\Value;
-use cms\model\Folder;
-use cms\model\Object;
-
-use Logger;
-use Session;
-
-/**
- * Action-Klasse zum Anzeigen der Workbench
- * @author Jan Dankert
- * @package openrat.actions
- */
-class WorkbenchAction extends Action
-{
- public $security = SECURITY_GUEST;
-
- private $perspective;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- global $conf;
- $this->perspective = Session::get('perspective');
-
-
-
- }
-
-
- /**
- * Ersetzt den Inhalt mit einer anderen Datei
- */
- public function showView()
- {
- global $conf;
- global $preselectedobjects;
-
-
- $preselectedobjects = array();;
- // Zuletzt geändertes Objekt laden.
- if ( $this->perspective == 'normal' )
- {
- $project = Session::getProject();
- $rootFolder = new Folder( $project->getRootObjectId() );
- $rootFolder->load();
- $preselectedobjects[] = $rootFolder;
-
- if ( $conf['login']['start']['start_lastchanged_object'] )
- {
- $user = Session::getUser();
-
- $objectid = Value::getLastChangedObjectInProjectByUserId($project->projectid, $user->userid);
- if ( Object::available($objectid))
- {
- $object = new Object($objectid);
- $object->load();
-
- Logger::debug('preselecting object '.$objectid);
- $preselectedobjects[] = $object;
- }
- }
- }
-
- global $viewconfig;
-
- Logger::debug('Workbench is using perspektive: '.$this->perspective);
- $viewconfig = parse_ini_file('themes/default/layout/perspective/'.$this->perspective.'.ini.php',true);
-
- require_once('themes/default/layout/perspective/window.php');
- require_once('themes/default/layout/perspective/'.$this->perspective.'.php');
- // Ausgabe fertig.
- exit;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/Auth.class.php b/auth/Auth.class.php
@@ -1,28 +0,0 @@
-<?php
-
-
-DEFINE('OR_AUTH_STATUS_SUCCESS',1);
-DEFINE('OR_AUTH_STATUS_FAILED',2);
-DEFINE('OR_AUTH_STATUS_PW_EXPIRED',3);
-DEFINE('OR_AUTH_STATUS_TOKEN_NEEDED',4);
-
-interface Auth
-{
- /**
- * Prüft den eingegebenen Benutzernamen und das Kennwort
- * auf Richtigkeit.
- *
- * @param Benutzername
- * @param Kennwort
- */
- function login( $username, $password, $token );
-
-
- /**
- * Ermittelt den Benutzernamen.
- * Der Benutzername wird verwendet, um die Loginmaske vorauszufüllen.
- */
- function username();
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/CookieAuth.class.php b/auth/CookieAuth.class.php
@@ -1,31 +0,0 @@
-<?php
-
-/**
- * Authentifizierung als Gast-User.
- *
- * Falls konfiguriert, wird der Gast-Benutzer voreingestellt.
- *
- * @author dankert
- */
-class CookieAuth implements Auth
-{
- public function username()
- {
- if ( isset($_COOKIE['or_username']) )
- return $_COOKIE['or_username'];
- else
- return null;
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return false;
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/DatabaseAuth.class.php b/auth/DatabaseAuth.class.php
@@ -1,46 +0,0 @@
-<?php
-
-use database\Database;
-
-/**
- * Authentifzierung über eine externe Datenbank.
- * @author dankert
- *
- */
-class DatabaseAuth implements Auth
-{
-
- /**
- * Login.
- */
- public function login( $user, $password, $token )
- {
- global $conf;
-
- $authDbConf = $conf['security']['authdb'];
-
- if ( ! $authDbConf['enable'] )
- return false;
-
- $authdb = new Database( $authDbConf );
-
- $sql = $authdb->sql( $conf['security']['authdb']['sql'] );
- $algo = $authdb->sql( $conf['security']['authdb']['hash_algo'] );
- $sql->setString('username',$user );
- $sql->setString('password',hash($algo,$password));
- $row = $sql->getRow();
- $ok = !empty($row);
-
- // noch nicht implementiert: $authdb->close();
-
- return $ok?OR_AUTH_STATUS_SUCCESS:OR_AUTH_STATUS_FAILED;
- }
-
- public function username()
- {
- return null;
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/GuestAuth.class.php b/auth/GuestAuth.class.php
@@ -1,33 +0,0 @@
-<?php
-
-/**
- * Authentifizierung als Gast-User.
- *
- * Falls konfiguriert, wird der Gast-Benutzer voreingestellt.
- *
- * @author dankert
- */
-class GuestAuth implements Auth
-{
- public function username()
- {
- global $conf;
- $guestConf = $conf['security']['guest'];
-
- if ( $guestConf['enable'] )
- return $guestConf['user'];
- else
- return null;
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return false;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/HttpAuth.class.php b/auth/HttpAuth.class.php
@@ -1,42 +0,0 @@
-<?php
-
-/**
- * HTTP-Authentifzierung.
- *
- * Das vom Benutzer eingegebene Kennwort wird gegen eine HTTP-Adresse
- * geprüft, bei der HTTP-Auth aktiviert ist.
- *
- * @author Jan Dankert
- */
-class HttpAuth implements Auth
-{
-
- /**
- * Dieses Loginmodul kann keinen Namen feststellen.
- */
- public function username()
- {
- return null;
- }
-
-
- /**
- * Ueberpruefen des Kennwortes.
- *
- * Das Kennwort wird gegen einen HTTP-Server geprüft.
- */
- public function login( $user, $password, $token )
- {
- global $conf;
-
- $http = new Http( $conf['security']['http']['url'] );
- $http->method = 'HEAD';
- $http->setBasicAuthentication( $this->name, $password );
-
- $ok = $http->request();
-
- return $ok;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/IdentAuth.class.php b/auth/IdentAuth.class.php
@@ -1,57 +0,0 @@
-<?php
-
-/**
- * Authentifizierung via Ident-Server.
- *
- * Der Benutzername wird über einen Ident-Server, der auf dem
- * Client installiert sein muss, ermittelt.
- *
- * @author dankert
- */
-class IdentAuth implements Auth
-{
- public function username()
- {
- $ip = Http::getClientIP();
- $port = Http::getClientPort();
- $identPort = 113;
- if ( !$socket = @fsockopen($ip,$identPort,$errno, $errstr,10 ))
- {
- return null;
- }
-
- $line = $port.','.$_SERVER['SERVER_PORT']."\r\n";
- @fwrite($socket, $line);
- $line = @fgets($socket, 1000); // 1000 octets according to RFC 1413
- fclose($socket);
-
- $array = explode(':', $line, 4);
- if (count($array) >= 4 && ! strcasecmp(trim($array[1]), 'USERID'))
- {
- $username = trim($array[3]);
- Logger::debug('Ident: User-Id: '.$username );
- return $username;
- }
- elseif (count($array) >= 3 && ! strcasecmp(trim($array[1]), 'ERROR'))
- {
- Logger::debug('Ident: Error: '.trim($array[2]) );
- return null;
- }
- else
- {
- Logger::warn('Ident: Invalid ident server response: '.$line);
- return null;
- }
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return OR_AUTH_STATUS_FAILED;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/InternalAuth.class.php b/auth/InternalAuth.class.php
@@ -1,97 +0,0 @@
-<?php
-
-use cms\model\User;
-use security\Password;
-
-/**
- * Authentifizierungsmodul für die interne Benutzerdatenbank.
- *
- * @author Jan Dankert
- *
- */
-class InternalAuth implements Auth
-{
- var $mustChangePassword = false;
-
- /**
- * Ueberpruefen des Kennwortes
- * ueber die Benutzertabelle in der Datenbank.
- */
- function login( $username, $password,$token )
- {
- $db = db_connection();
-
- // Lesen des Benutzers aus der DB-Tabelle
- $sql = $db->sql( <<<SQL
-SELECT * FROM {{user}}
- WHERE name={name}
-SQL
- );
- $sql->setString('name',$username);
-
- $row_user = $sql->getRow();
-
- if ( empty($row_user) ) {
-
- // Benutzer ist nicht vorhanden.
- // Trotzdem das Kennwort hashen, um Timingattacken zu verhindern.
- $unusedHash = Password::hash(User::pepperPassword($password),Password::bestAlgoAvailable() );
- return false;
- }
-
- // Pruefen ob Kennwort mit Datenbank uebereinstimmt.
- if ( ! Password::check(User::pepperPassword($password),$row_user['password_hash'],$row_user['password_algo']) )
- {
- return false;
- }
-
- // Behandeln von Klartext-Kennwoertern (Igittigitt).
- if ( $row_user['password_algo'] == OR_PASSWORD_ALGO_PLAIN )
- {
- if ( config('security','password','force_change_if_cleartext') )
- // Kennwort steht in der Datenbank im Klartext.
- // Das Kennwort muss geaendert werden
- return OR_AUTH_STATUS_PW_EXPIRED;
-
- // Anderenfalls ist das Login zwar moeglich, aber das Kennwort wird automatisch neu gehasht, weil der beste Algo erzwungen wird.
- // Das Klartextkennwort waere danach ueberschrieben.
- }
-
- if ( $row_user['password_expires'] != null && $row_user['password_expires'] < time() )
- {
- // Kennwort ist abgelaufen.
-
- // Wenn das kennwort abgelaufen ist, kann es eine bestimmte Dauer noch benutzt und geändert werden.
- // Nach Ablauf dieser Dauer wird das Login abgelehnt.
- if ( $row_user['password_expires'] +(config('security','deny_after_expiration_duration')*60*60) < time() )
- return false; // Abgelaufenes Kennwort wird nicht mehr akzeptiert.
- else
- return OR_AUTH_STATUS_PW_EXPIRED; // Kennwort ist abgelaufen, kann aber noch geändert werden.
- }
-
- if ( $row_user['totp'] == 1 )
- {
- $user = new User($row_user['id']);
- $user->load();
- if ( Password::getTOTPCode($user->otpSecret) == $token )
- return true;
- else
- return OR_AUTH_STATUS_TOKEN_NEEDED;
- }
-
- if ( $row_user['hotp'] == 1 )
- {
- // HOTP not yet implemented.
- }
-
- // Benutzer wurde erfolgreich authentifiziert.
- return true;
- }
-
- public function username()
- {
- return null;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/LdapAuth.class.php b/auth/LdapAuth.class.php
@@ -1,74 +0,0 @@
-<?php
-
-class LdapAuth implements Auth
-{
-
- public function login($username, $password, $token)
- {
- global $conf;
- $db = db_connection();
- $this->mustChangePassword = false;
-
- // Lesen des Benutzers aus der DB-Tabelle
- $sql = $db->sql( <<<SQL
-SELECT * FROM {{user}}
- WHERE name={name}
-SQL
- );
- $sql->setString('name',$username);
-
- $row_user = $sql->getRow();
- $userid = $row_user['id'];
-
- $ldap = new Ldap();
- $ldap->connect();
-
- if ( empty($conf['ldap']['dn']) )
- {
- // Der Benutzername wird im LDAP-Verzeichnis gesucht.
- // Falls gefunden, wird der DN (=der eindeutige Schl�ssel im Verzeichnis) ermittelt.
- $dn = $ldap->searchUser( $username );
-
- if ( empty($dn) )
- {
- Logger::debug( 'User not found in LDAP directory' );
- return false; // Kein LDAP-Account gefunden.
- }
-
- Logger::debug( 'User found: '.$dn );
- }
- else
- {
- $dn = str_replace( '{user}',$username,$conf['ldap']['dn'] );
- }
-
- // LDAP-Login versuchen
- $ok = $ldap->bind( $dn, $password );
-
- Logger::debug( 'LDAP bind: '.($ok?'success':'failed') );
-
- if ( !$ok )
- return false;
-
- $sucheAttribut = $conf['ldap']['authorize']['group_name'];
- $sucheFilter = str_replace('{dn}',$dn,$conf['ldap']['authorize']['group_filter']);
-
- $this->groups = $ldap->searchAttribute( $sucheFilter, $sucheAttribut );
- $user = new User( $userid );
-
- // Html::debug($this->groups,'Gruppen/Ids des Benutzers');
-
- // Verbindung zum LDAP-Server brav beenden
- $ldap->close();
-
- return true;
- }
-
- public function username()
- {
- return null;
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/LdapUserDNAuth.class.php b/auth/LdapUserDNAuth.class.php
@@ -1,60 +0,0 @@
-<?php
-
-/**
- * Authentifizierung gegen einen LDAP-Server.
- *
- * @author Jan Dankert
- */
-class LdapUserDNAuth implements Auth
-{
-
- /**
- * @see Auth::login()
- */
- public function login($username, $password, $token)
- {
- $db = db_connection();
- $this->mustChangePassword = false;
-
- // Lesen des Benutzers aus der DB-Tabelle
- $sql = $db->sql( <<<SQL
-SELECT * FROM {{user}}
- WHERE name={name}
-SQL
- );
- $sql->setString('name',$username);
-
- $row_user = $sql->getRow();
-
- if ( empty($row_user) )
- return false;
-
- // Benutzername ist bereits in der Datenbank.
- $userid = $row_user['id'];
- $ldap_dn = $row_user['ldap_dn'];
-
- if ( empty($ldap_dn ) )
- return false;
-
- Logger::debug( 'checking login via ldap' );
- $ldap = new Ldap();
- $ldap->connect();
-
- // Benutzer ist bereits in Datenbank
- // LDAP-Login mit dem bereits vorhandenen DN versuchen
- $ok = $ldap->bind( $ldap_dn, $password );
-
- // Verbindung zum LDAP-Server brav beenden
- $ldap->close();
-
- return $ok;
- }
-
- public function username()
- {
- return null;
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/OpenIdAuth.class.php b/auth/OpenIdAuth.class.php
@@ -1,503 +0,0 @@
-<?php
-
-
-/**
- * Open-Id Authentisierung gem�� OpenId-Spezifikation 1.0.
- *
- */
-class OpenIdAuth implements Auth
-{
- function username()
- {
- return null;
- }
-
-
- function login( $username, $password, $token )
- {
- return false;
- }
-
-
- function redirect()
- {
- $this->login2();
- return $this->getRedirectUrl();
- }
-
-
- function checkToken()
- {
- $this->checkAuthentication();
- }
-
- /**
- * Open-Id Server, an den die Authentisierungsanfrage gestellt wird.
- *
- * @var String
- */
- var $server;
-
-
- /**
- * Informationen zum Benutzer.
- *
- * @var Array
- */
- var $info;
-
- /**
- * Open-Id Identity.
- *
- * @var String
- */
- var $identity;
-
- /**
- * Fehlermeldung (falls vorhanden).
- *
- * @var String
- */
- var $error;
-
- /**
- * OpenId-Benutzername.
- *
- * @var String
- */
- var $user;
-
- /**
- * OpenId-Provider.
- *
- * @var String
- */
- var $provider;
-
-
- var $supportAX;
- var $supportSREG;
- var $supportOpenId1_1;
- var $supportOpenId2_0;
-
-
- /**
- * Neue Open-Id Anfrage.
- *
- * @param String $user
- * @return OpenId
- */
- function OpenId( $provider='',$user='' )
- {
- $this->provider = $provider;
- $this->user = $user;
- }
-
-
- /**
- * Stellt fest, ob der Server vertrauenswuerdig ist.
- *
- * @return true, wenn vertrauenswuerdig.
- */
- function serverOk()
- {
- global $conf;
- $servers = $conf['security']['openid']['trusted_server'];
-
- if ( empty($servers) )
- {
- return true;
- }
- else
- {
- $serverList = explode(',',$servers);
-
- $http = new Http($this->server);
- if ( !in_array($http->url['host'],$serverList) )
- {
- $this->error = 'Server '.$this->server.' is not trusted';
- return false;
- }
- else
- return true;
- }
-
- }
-
-
-
- /**
- * Authentisierung Schritt 1.<br>
- * Ermitteln der Identity.
- *
- * @return boolean TRUE, wenn Identity ermittelt wurde.
- */
- function login2()
- {
- if ( $this->provider != 'identity' )
- {
- $this->user = config('security','openid','provider.'.$this->provider.'.xrds_uri');
- $this->identity = 'http://specs.openid.net/auth/2.0/identifier_select';
- }
- $this->supportSREG = config('security','openid','provider.'.$this->provider.'.sreg_1_0');
- $this->supportAX = config('security','openid','provider.'.$this->provider.'.ax_1_0' );
-
- // Schritt 1: Identity aus Yadis-Dokument laden.
- $this->getIdentityFromYadis();
-
- // Schritt 2: Fallback auf HTML-Dokument.
- if ( empty($this->server) )
- {
- $this->getIdentityFromHtmlMetaData();
- }
-
- // Falls immer noch kein Servername gefunden wurde, dann Abbruch.
- if ( empty($this->server) )
- {
- if ( empty($this->error) )
- $this->error = 'Unable to locate OpenId-Server in URL';
- return false;
- }
-
- if ( !$this->serverOk() )
- return false; // Server nicht vertrauenswuerdig.
-
- if ( empty($this->identity) )
- // Falls die Identity bis hierher nicht deligiert wurde...
- // Lt. Spezifikation mit Prefix "http://".
- $this->identity = 'http://'.$this->user;
-
- return true;
- }
-
-
-
- /**
- * Erzeugt einen HTTP-Redirect auf den OpenId-Provider.
- */
- public function getRedirectUrl()
- {
- global $conf;
-
- $this->handle = md5(microtime().session_id());
-
- $redirHttp = new Http($this->server);
-
- if ( $this->supportOpenId2_0 )
- $redirHttp->requestParameter['openid.ns' ] = 'http://specs.openid.net/auth/2.0';
-
- $redirHttp->requestParameter['openid.mode' ] = 'checkid_setup';
- $redirHttp->requestParameter['openid.identity' ] = $this->identity;
-
- if ( $this->supportOpenId2_0 )
- $redirHttp->requestParameter['openid.claimed_id'] = $this->identity;
-
-
- // Profilangaben anfordern. E-Mail wird ben�tigt, Name und Sprache sind optional.
-
- if ( $this->supportAX )
- {
- Logger::info("OpenId-Server is using OpenID Attribute Exchange 1.0");
- $redirHttp->requestParameter['openid.ns.ax' ] = 'http://openid.net/srv/ax/1.0';
- $redirHttp->requestParameter['openid.ax.mode' ] = 'fetch_request';
- $redirHttp->requestParameter['openid.ax.type.email' ] = 'http://axschema.org/contact/email';
- $redirHttp->requestParameter['openid.ax.type.username' ] = 'http://axschema.org/namePerson/friendly';
- $redirHttp->requestParameter['openid.ax.type.fullname' ] = 'http://axschema.org/namePerson';
- $redirHttp->requestParameter['openid.ax.type.language' ] = 'http://axschema.org/pref/language';
- $redirHttp->requestParameter['openid.ax.required' ] = 'username,email';
- $redirHttp->requestParameter['openid.ax.if_available' ] = 'language,fullname';
- }
-
- if ( $this->supportSREG )
- {
- Logger::info("OpenId-Server is using OpenID Simple Registration Extension 1.0");
- $redirHttp->requestParameter['openid.ns.sreg' ] = 'http://openid.net/sreg/1.0';
- $redirHttp->requestParameter['openid.sreg.required'] = 'email,nickname';
- $redirHttp->requestParameter['openid.sreg.optional'] = 'fullname,language';
- }
-
- $trustRoot = @$conf['security']['openid']['trust_root'];
- $server = Http::getServer();
- if ( empty($trustRoot) )
- $trustRoot = $server;
-
- $redirHttp->requestParameter['openid.trust_root' ] = slashify($trustRoot);
- $redirHttp->requestParameter['openid.return_to' ] = slashify($server).'openid.'.PHP_EXT;
- //$redirHttp->requestParameter['openid.realm' ] = slashify($server).'openid.'.PHP_EXT;
- $redirHttp->requestParameter['openid.assoc_handle' ] = $this->handle;
-
- return $redirHttp->getUrl();
- }
-
-
-
- /**
- * Ermittelt OpenId-Server und OpenId-Identity aus Yadis-Dokument.<br>
- *
- * @return unknown
- */
- private function getIdentityFromYadis()
- {
- $http = new Http($this->user);
-// $http->url['host'] = $this->user;
-
- $http->header[] = 'Accept: application/xrds+xml';
- if ( ! $http->request() )
- {
- $this->error = 'Unable to get XML delegate information';
- return false;
- }
-
- Logger::debug("OpenId: Found YADIS-document for ".$http->getUrl());
- //die();
- $p = xml_parser_create();
- $ok = xml_parse_into_struct($p, $http->body, $vals, $index);
- xml_parser_free($p);
-
- foreach( $vals as $tag )
- {
- if ( strtolower($tag['tag']) == 'type' )
- {
- if ( $tag['value'] == 'http://openid.net/srv/ax/1.0' )
- $this->supportAX = true;
-
- if ( $tag['value'] == 'http://openid.net/sreg/1.0' )
- $this->supportSREG = true;
-
- if ( $tag['value'] == 'http://openid.net/signon/1.1' )
- $this->supportOpenId1_1 = true;
-
- if ( $tag['value'] == 'http://specs.openid.net/auth/2.0/server' )
- $this->supportOpenId2_0 = true;
- }
-
- if ( strtolower($tag['tag']) == 'uri' )
- {
- $this->server = $tag['value'];
- }
-
- if ( strtolower($tag['tag']) == 'openid:delegate' )
- {
- $this->identity = $tag['value'];
- }
- }
-
- if ( !$this->supportOpenId1_1 && !$this->supportOpenId2_0 )
- {
- $this->error = 'Only OpenId 1.1 and 2.0 is supported but this identity-provider does not seem to support any of these.';
- return false;
- }
- if ( !$this->supportAX && !$this->supportSREG )
- {
- $this->error = 'The identity-provider must support either Attribute-Exchange (AX) oder Simple-Registration (SREG), but it does not seem to support any of these.';
- return false;
- }
- }
-
-
- /**
- * Ermittelt OpenId-Server und OpenId-Identity aus HTML Meta-Tags.<br>
- */
- private function getIdentityFromHtmlMetaData()
- {
- $http = new Http($this->user);
-// $http = new Http();
-// $http->url['host'] = $this->user;
- $http->header[] = 'Accept: text/html';
-
- if ( ! $http->request() )
- {
- $this->error = 'Unable to get HTML delegate information';
- return false;
- }
-
- $seite = $http->body;
-
- // Die Meta-Tags mit regulaerem Ausdruck auslesen.
- $treffer = array();
- preg_match('/rel="openid.server"\s+href="(\S+)"/',$seite,$treffer);
- if ( count($treffer) >= 1 )
- {
- $this->server = $treffer[1];
- $this->supportOpenId1_1 = true;
- }
-
- $treffer = array();
- preg_match('/rel="openid2.provider"\s+href="(\S+)"/',$seite,$treffer);
- if ( count($treffer) >= 1 )
- {
- $this->supportOpenId2_0 = true;
- $this->server = $treffer[1];
- }
-
- $treffer = array();
- preg_match('/rel="openid.delegate"\s+href="(\S+)"/',$seite,$treffer);
- if ( count($treffer) >= 1 )
- $this->identity = $treffer[1];
- }
-
-
- /**
- * Ermittelt den Hostnamen aus der Identity.
- *
- * @return String
- */
- public function getUserFromIdentiy()
- {
- if ( $this->provider == 'identity' )
- {
- $http = new Http($this->identity);
- return $http->url['host'];
- }
- else
- {
- $attribute_name = config('security','openid','provider.'.$this->provider.'.map_attribute');
- return $this->info[$attribute_name];
- }
- }
-
-
- /**
- * Open-Id Login, �berpr�fen der Anmeldung.<br>
- * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
- * Kapitel "4.4. check_authentication"<br>
- * <br>
- * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br>
- * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
- * <br>
- * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der
- * Benutzer angemeldet.<br>
- */
- public function checkAuthentication()
- {
- $queryVars = $this->getQueryParamList();
-
- if ( $queryVars['openid.invalidate_handle'] != $this->handle )
- {
- Http::notAuthorized('Association-Handle mismatch.');
- die();
- $this->error = 'Association-Handle mismatch.';
- return false;
- }
-
- if ( $queryVars['openid.mode'] != 'id_res' )
- {
- Http::notAuthorized('Open-Id: Unknown mode:'.$queryVars['openid.mode']);
- die();
-
- $this->error ='Open-Id: Unknown mode:'.$queryVars['openid.mode'];
- return false;
- }
-
- if ( $this->provider=='identity' && $queryVars['openid.identity'] != $this->identity )
- {
- Http::notAuthorized('Open-Id: Identity mismatch. Wrong identity:'.$queryVars['openid.identity']);
- die();
-
- $this->error ='Open-Id: Identity mismatch. Wrong identity:'.$queryVars['openid.identity'];
- return false;
- }
-
-
- $params = array();
-
- if ( $this->supportAX )
- // Den Namespace-Prefix für AX (attribute exchange) herausfinden.
- // Leider kann das ein anderer Prefix sein, als wir im Request verwendet haben.
- foreach( $queryVars as $request_key=>$request_value )
- if ( substr($request_key,0,10)=='openid.ns.' && $request_value == 'http://openid.net/srv/ax/1.0' )
- $axPrefix = substr($request_key,10);
-
- foreach( $queryVars as $request_key=>$request_value )
- {
- // Benutzer-Attribute ermitteln.
- // Benutzer-Attribute über SREG ermitteln.
- if ( $this->supportSREG && substr($request_key,0,12)=='openid.sreg.' )
- $this->info[ substr($request_key,12) ] = $request_value;
- // Benutzer-Attribute über AX ermitteln.
- elseif ( $this->supportAX && substr($request_key,0,14+strlen($axPrefix))=='openid.'.$axPrefix.'.value.' )
- $this->info[ substr($request_key,14+strlen($axPrefix)) ] = $request_value;
-
- // Alle OpenId-Parameter in den Check-Authentication-Request übertragen.
- if ( substr($request_key,0,7)=='openid.' )
- $params['openid.'.substr($request_key,7) ] = $request_value;
- }
- $params['openid.mode'] = 'check_authentication';
-
- $checkRequest = new Http($this->server);
-
- $checkRequest->method = 'POST'; // Spezifikation verlangt POST.
- $checkRequest->header['Accept'] = 'text/plain';
- $checkRequest->requestParameter = $params;
-
- if ( ! $checkRequest->request() )
- {
- // Der HTTP-Request ging in die Hose.
- $this->error = $checkRequest->error;
- return false;
- }
- //Html::debug($checkRequest);
-
- // Analyse der HTTP-Antwort, Parsen des BODYs.
- // Die Anmeldung ist best�tigt, wenn im BODY die Zeile "is_valid:true" vorhanden ist.
- // Siehe Spezifikation Kapitel 4.4.2
- $result = array();
- foreach( explode("\n",$checkRequest->body) as $line )
- {
- $pair = explode(':',trim($line));
- if (count($pair)==2)
- $result[strtolower($pair[0])] = strtolower($pair[1]);
- }
-
- if ( !array_key_exists('is_valid',$result) )
- {
- // Zeile nicht gefunden.
- Http::notAuthorized('Undefined Open-Id response: "is_valid" expected, but not found');
- die();
-
- $this->error = 'Undefined Open-Id response: "is_valid" expected, but not found';
- return false;
- }
- elseif ( $result['is_valid'] == 'true' )
- {
- // Anmeldung wurde mit "is_valid:true" best�tigt.
- return true;
- }
- else
- {
- // Bestaetigung wurde durch den OpenId-Provider abgelehnt.
- Http::notAuthorized('Server refused login.');
- die();
- $this->error = 'Server refused login.';
- return false;
- }
- }
-
-
- /**
- * Liefert die Query-Parameter aus der aktuellen URL.<br>
- * <br>
- * PHP hat leider die sehr bescheuerte Angewohnheit, Punkte und Leerzeichen in Request-Variablen
- * durch Unterstriche zu ersetzen. Diese Funktion liefert die GET-Parameter ohne diese Ersetzung.
- *
- * @return Parameter der aktuellen URL
- */
- private function getQueryParamList()
- {
- // Quelle: php.net
- $str = $_SERVER['QUERY_STRING'];
- $op = array();
- $pairs = explode("&", $str);
- foreach ($pairs as $pair)
- {
- list($k, $v) = array_map("urldecode", explode("=", $pair));
- $op[$k] = $v;
- }
-
- return $op;
- }
-
-
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/RememberAuth.class.php b/auth/RememberAuth.class.php
@@ -1,61 +0,0 @@
-<?php
-
-use database\Database;
-
-/**
- * Authentifizierung mit einem Login-Token.
- *
- * @author dankert
- */
-class RememberAuth implements Auth
-{
- /**
- * @return null
- */
- public function username()
- {
- // Ermittelt den Benutzernamen aus den Login-Cookies.
- if ( isset($_COOKIE['or_username']) &&
- isset($_COOKIE['or_token' ]) &&
- isset($_COOKIE['or_dbid' ]) )
- {
- $name = $_COOKIE['or_username'];
- try
- {
- $dbid = $_COOKIE['or_dbid'];
-
- global $conf;
- $db = new Database( $conf['database'][$dbid] );
- $db->id = $dbid;
- $db->start();
- Session::setDatabase($db);
-
- // Jetzt den Benutzer laden und nachschauen, ob der Token stimmt.
- $user = User::loadWithName($name);
- $token = $user->loginToken();
-
- // Stimmt der Token?
- if ( $_COOKIE['or_token'] == $token )
- // Token stimmt, Benutzer ist damit angemeldet.
- return $name;
- }
- catch( ObjectNotFoundException $e )
- {
- // Benutzer nicht gefunden.
- }
- }
-
- return null;
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist über den Cookie nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return false;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/SSLAuth.class.php b/auth/SSLAuth.class.php
@@ -1,27 +0,0 @@
-<?php
-
-/**
- * Authentifizierung ueber ein SSL-Zertifikat.
- *
- * @author dankert
- */
-class SSLAuth implements Auth
-{
- public function username()
- {
- $conf = config('security','ssl');
- if ( isset($_SERVER[config('security','ssl','client_cert_dn_env')]))
- return $_SERVER[config('security','ssl','client_cert_dn_env')];
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return false;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/SingleSignonAuth.class.php b/auth/SingleSignonAuth.class.php
@@ -1,24 +0,0 @@
-<?php
-
-/**
- * Single-Signon-Authentifizierung.
- *
- * @author dankert
- */
-class SingleSignonAuth implements Auth
-{
- public function username()
- {
- }
-
-
- /**
- * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
- */
- public function login( $user, $password, $token )
- {
- return false;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/auth/include.inc.php b/auth/include.inc.php
@@ -1,15 +0,0 @@
-<?php
-require_once( OR_AUTHCLASSES_DIR."Auth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."CookieAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."DatabaseAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."GuestAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."HttpAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."IdentAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."InternalAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."LdapAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."LdapUserDNAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."OpenIdAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."RememberAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."SingleSignonAuth.class.".PHP_EXT );
-require_once( OR_AUTHCLASSES_DIR."SSLAuth.class.".PHP_EXT );
-?>-
\ No newline at end of file
diff --git a/init.php b/init.php
@@ -34,20 +34,20 @@ define('OR_TYPE_LINK' ,'link' );
define('OR_TYPE_URL' ,'url' );
-define('OR_ACTIONCLASSES_DIR' ,'./action/' );
+define('OR_MODULES_DIR' ,'./modules/');
+define('OR_ACTIONCLASSES_DIR' ,OR_MODULES_DIR.'cms-core/action/' );
define('OR_FORMCLASSES_DIR' ,'./formClasses/' );
-define('OR_OBJECTCLASSES_DIR' ,'./model/' );
+define('OR_OBJECTCLASSES_DIR' ,OR_MODULES_DIR.'cms-core/model/' );
define('OR_LANGUAGE_DIR' ,'./language/' );
define('OR_DBCLASSES_DIR' ,'./db/' );
-define('OR_DYNAMICCLASSES_DIR','./macro/' );
-define('OR_TEXTCLASSES_DIR' ,'./textClasses/' );
+define('OR_DYNAMICCLASSES_DIR',OR_MODULES_DIR.'cms-macros/macro/' );
+define('OR_TEXTCLASSES_DIR' ,OR_MODULES_DIR.'wikiparser/' );
define('OR_PREFERENCES_DIR' ,'./config/');
define('OR_CONFIG_DIR' ,OR_PREFERENCES_DIR );
define('OR_THEMES_DIR' ,'./themes/' );
define('OR_THEMES_EXT_DIR' ,OR_THEMES_DIR);
define('OR_TMP_DIR' ,'./tmp/' );
define('OR_CONTROLLER_FILE' ,'dispatcher');
-define('OR_MODULES_DIR' ,'./modules/');
define('START_TIME' ,time() );
define('REQUEST_ID' ,'req'.time().rand() );
@@ -70,7 +70,7 @@ define('REQ_PARAM_DATABASE_ID' ,'dbid' );
define('REQ_PARAM_TARGET' ,'target' );
define('OR_SERVICECLASSES_DIR','./util/' );
-define('OR_AUTHCLASSES_DIR' ,'./auth/' );
+define('OR_AUTHCLASSES_DIR' ,OR_MODULES_DIR.'cms-core/auth/' );
/**
diff --git a/macro/Album.class.php b/macro/Album.class.php
@@ -1,92 +0,0 @@
-<?php
-// 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.
-use cms\model\File;
-use cms\model\Folder;
-
-
-/**
- * Erzeugt eine Bilder-Liste.
- *
- * Die Ordner-Id kann als Parameter "folderid" übergeben werden.
- * Falls nicht, wird der aktuelle Ordner, in dem sich die Seite
- * befindet, benutzt.
- *
- * Es wird eine Definitionsliste mit der CSS-Klasse "album" erzeugt, damit
- * bequem eine Auszeichnung per CSS erfolgen kann.
- *
- * Beispiel:
- * <dl class="album">
- * <dt><img src="bild.jpg" width=".." .. /></dt>
- * <dd>Beschreibung</dd>
- * </dl>
- *
- * @author Jan Dankert
- */
-class Album extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'folderid'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates an album.';
-
- var $folderid = 0;
-
- /**
- */
- function execute()
- {
- if ( intval($this->folderid)!=0 )
- $folderid = $this->folderid;
- else
- $folderid = $this->page->parentid;
-
- $f = new Folder($folderid);
-
- $files = $f->getFiles();
-
- $this->output('<dl class="album">');
-
- foreach( $files as $fileid )
- {
- $file = new File($fileid);
- $file->load();
-
- if ( $file->isImage() )
- {
- $file->getImageSize();
- $img = '<img src="'.$this->pathToObject($fileid).'" alt="'.$file->name.'" width="'.$file->width.'" height="'.$file->height.'" />';
- $this->output('<dt>'.$img.'</dt><dd>'.$file->desc.'</dd>');
- }
-
- }
-
- $this->output('</dl>');
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/Atom.class.php b/macro/Atom.class.php
@@ -1,141 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\Page;
-
-
-/**
- * Erstellen eines ATOM-Feeds
- * @author Jan Dankert
- */
-class Atom extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'folderid' =>'Id of the folder whose pages should go into the Atom-Feed, default: the root folder',
- 'feed_url' =>'Url of the feed, default: blank',
- 'feed_title' =>'Title of the feed, default: Name of folder',
- 'feed_description'=>'Description of the feed, default: Description of folder'
- );
-
- var $folderid = 0;
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates an Atom-Feed of pages in a folder';
- var $api;
-
- var $feed_url = '';
- var $feed_title = '';
- var $feed_description = '';
-
- // Erstellen des Hauptmenues
- function execute()
- {
- $feed = array();
-
- // Lesen des Root-Ordners
- if ( intval($this->folderid) == 0 )
- $folder = new Folder( $this->getRootObjectId() );
- else
- $folder = new Folder( intval($this->folderid) );
-
- $folder->load();
-
- if ( $this->feed_title == '' )
- $this->feed_title = $folder->name;
-
- if ( $this->feed_description == '' )
- $this->feed_description = $folder->desc;
-
- $feed['title' ] = $this->feed_title;
- $feed['description'] = $this->feed_description;
- $feed['url' ] = $this->feed_url;
- $feed['items' ] = array();
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjectIds() as $id )
- {
- if ( $id == $this->getObjectId() )
- continue;
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
- if ( $o->isPage ) // Nur wenn Seite
- {
- $p = new Page( $id );
- $p->load();
-
- $item = array();
- $item['title' ] = $p->name;
- $item['description'] = $p->desc;
- $item['date' ] = $p->lastchangeDate;
- if ( empty($this->feed_url) )
- $item['link' ] = $this->pathToObject($id);
- else
- $item['link' ] = $this->feed_url;
-
- $feed['items'][] = $item;
- }
- }
-
- $feed = $this->atomFeed($feed);
-
- $this->output( $feed );
- }
-
-
- function atomFeed($input, $stylesheet='')
- {
- $input["encoding"] = (empty($input["encoding"] ))?"UTF-8":$input["encoding"];
- $input["language"] = (empty($input["language"] ))?"en-us":$input["language"];
-
- if ( empty($input['title' ])) $input['title' ] = '';
- if ( empty($input['description'])) $input['description'] = '';
- if ( empty($input['link' ])) $input['link' ] = '';
- $feed = '<?xml version="1.0" encoding="'.$input["encoding"].'"?>';
- $feed .= (!empty($stylesheet))?"\n".'<?xml-stylesheet type="text/xsl" href="'.$stylesheet.'"?>':"";
- $feed .= <<<__RSS__
-
- <feed xmlns="http://www.w3.org/2005/Atom">
- <title>{$input["title"]}</title>
-
-__RSS__;
- foreach($input["items"] as $item)
- {
- if ( empty($item['title' ])) $item['title' ] = '';
- if ( empty($item['description'])) $item['description'] = '';
- $feed .= "\n<entry>\n<title>".$item["title"]."</title>";
- $feed .= "\n<summary><![CDATA[".$item["description"]."]]></summary>";
- $feed .= "\n<updated>".date('Y-m-d\TH:i:s\Z', $item["date"])."</updated>";
- $feed .= "\n<link href=\"".$item["link"]."\" />";
- $feed .= "\n</entry>\n";
- }
- $feed .= "\n</feed>";
- return $feed;
- }
-}-
\ No newline at end of file
diff --git a/macro/BlockMenu.class.php b/macro/BlockMenu.class.php
@@ -1,137 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2004-12-25 21:05:14 dankert
-// erbt von Klasse Dynamic
-//
-// Revision 1.1 2004/10/14 21:16:12 dankert
-// Erzeugen eines Menues in Bloecken
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Object;
-
-
-/**
- * Erstellen eines Hauptmenues
- * @author Jan Dankert
- */
-class BlockMenu extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between menu entries, default: "·"'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
- var $version = '$Id$';
- var $api;
-
- // Erstellen des Hauptmenues
- function execute()
- {
- // Erstellen des Hauptmenues
-
- // Lesen des Root-Ordners
- $folder = new Folder( $this->getRootObjectId() );
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
- if ( $o->isFolder ) // Nur wenn Ordner
- {
- $f = new Folder( $id );
-
- // Ermitteln eines Objektes mit dem Dateinamen index
- $oid = $f->getObjectIdByFileName('index');
-
- if ( count($f->getLinks())+count($f->getPages()) > 0 )
- {
- $this->output( '
- <!-- sidebox -->
- <table bgcolor="#000000" border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td>
- <table border="0" cellpadding="3" cellspacing="1" width="100%">
- <tr>
- <td bgcolor="#cccccc"><span class="title"> '.$o->name.'</span></a>
- </td>
- </tr>
- <tr>
- <td bgcolor="#ffffff">
- ');
- // Untermenue
- // Schleife ber alle Objekte im aktuellen Ordner
- foreach( $f->getObjectIds() as $xid )
- {
- $o = new Object( $xid );
- $o->languageid = $this->page->languageid;
- $o->load();
-
- // Nur Seiten anzeigen
- if (!$o->isPage && !$o->isLink ) continue;
-
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->getObjectId() == $xid )
- {
- // aktuelle Seite
- $this->output( ' <span class="small">o</span>
- <strong class="nav">'.$o->name.'</strong>
- <br />' );
- }
- else
- {
- $this->output( ' <span class="small">o</span>
- <a class="nav" href="'.$this->page->path_to_object($xid).'">'.$o->name.'</a>
- <br />' );
- }
- //Api::output( '<br/>' );
- }
-
- $this->output( '
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <!-- end sidebox -->
- <br />
- ' );
- }
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/BreadCrumb.class.php b/macro/BreadCrumb.class.php
@@ -1,103 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.3 2007-11-30 23:25:25 dankert
-// Das Men? in der Sprache der zu ver?ffentlichenden Seite erzeugen.
-//
-// Revision 1.2 2005/01/04 19:59:55 dankert
-// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-
-
-/**
- * Erstellen einer sog. Brotkruemel-Navigation
- * @author Jan Dankert
- */
-class BreadCrumb extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'beforeEntry'=>'Chars before an active menu entry'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
-
-
- /**
- * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
- */
- var $beforeEntry = '»';
-
- var $api;
-
- /**
- * Erstellen einer BreadCrumb-Navigation.
- */
- function execute()
- {
- // Erstellen eines Untermenues
-
- // Ermitteln der aktuellen Seite
- $f = new Folder($this->page->parentid);
- $parentIds = $f->parentObjectFileNames(false,true);
- $lastoid = 0;
-
- foreach( $parentIds as $oid=>$filename )
- {
- $of = new Folder($oid);
- $of->languageid = $this->page->languageid;
- $of->load();
- $pl = $of->getFirstPageOrLink();
-
- $this->output( $this->beforeEntry );
-
- if ( is_object($pl) && $pl->objectid != $this->page->objectid )
- $this->output('<a href="'.$this->pathToObject($pl->objectid).'" class="breadcrumb">'.$of->name.'</a>' );
- else
- $this->output('<span class="breadcrumb">'.$of->name.'</span>' );
-
- if ( is_object($pl) )
- $lastoid = $pl->objectid;
- }
-
- if ( $lastoid != $this->page->objectid )
- {
- $this->output( $this->beforeEntry );
- $this->output('<span class="breadcrumb">'.$this->page->name.'</span>' );
- }
-
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/CSVTable.class.php b/macro/CSVTable.class.php
@@ -1,85 +0,0 @@
-<?php
-// 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.
-use cms\model\File;
-
-
-/**
- * Aus einer CSV-Datei wird eine HTML-Tabelle erstellt.
- *
- * @author Jan Dankert
- */
-class CSVList extends Macro
-{
- /**
- * Id der Datei, welche die Werte enthält.
- * @var unknown_type
- */
- var $fileid = 0;
-
- /**
- * CSS-Klasse der Tabelle.
- * @var unknown_type
- */
- var $css_class = 'table';
-
- /**
- * Trennzeichen (Default: Komma).
- * @var unknown_type
- */
- var $seperator = ',';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a HTML-table from a CSV-file';
-
-
-
- function execute()
- {
- $this->output('<table class="'.$this->css_class.'">');
-
- // Datei lesen
- $file = new File( $this->fileid );
- $values = $file->loadValue();
-
- // In einzelne Zeilen zerlegen.
- $lines = explode("\n",$values);
-
- foreach( $lines as $line )
- {
- $this->output('<tr>');
-
- // In einzelne Spalten zerlegen.
- $columns = explode($seperator,$line);
- foreach( $columns as $column )
- {
- $this->output('<td>' );
- $this->output($column);
- $this->output('</td>');
- }
- $this->output('</tr>');
- }
-
- $this->output('</table>');
- }
-}
-
-
-?>-
\ No newline at end of file
diff --git a/macro/ClassicMenu.class.php b/macro/ClassicMenu.class.php
@@ -1,117 +0,0 @@
-<?php
-// 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.
-use cms\model\Folder;
-use cms\model\Page;
-
-
-/**
- * Erstellen eines Menues
- * @author Jan Dankert
- */
-class ClassicMenu extends Macro
-{
- /**
- * Beschreibung dieser Klasse
- * @type String
- */
- var $description = 'This is a dynamic Menue which contains all pages. Folders are opened when useful. Nice standard menu :-)';
-
-
- /**
- * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
- */
- var $css_class = 'macro-classicmenu';
- var $onlySameTemplate = true;
-
-
- // Erstellen des Hauptmenues
- public function execute()
- {
- $rootId = $this->getRootObjectId();
- // Erstellen eines Untermenues
-
- $f = new Folder( $this->page->parentid );
- $this->parentFolders = $f->parentObjectFileNames(false,true);
-
- $this->showFolder( $rootId );
- }
-
- private function showFolder( $oid )
- {
- $this->outputLn('<ul class="'.$this->css_class.'">');
- $f = new Folder( $oid );
-
- // Schleife ueber alle Objekte im aktuellen Ordner
- foreach( $f->getObjects() as $o )
- {
- $o->languageid = $this->page->languageid;
- $o->load();
-
- // Ordner anzeigen
- if ($o->isFolder )
- {
- $nf = new Folder($o->objectid);
- $fp = $nf->getFirstPageOrLink();
-
- if ( is_object($fp) )
- {
-
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->page->objectid == $fp->objectid )
- // aktuelle Seite
- $this->outputLn( '<li class="active">'.$o->name.'' );
- else
- // Link erzeugen
- $this->outputLn( '<li><a href="'.$this->pathToObject($fp->objectid).'">'.$o->name.'</a>' );
-
- if ( in_array($o->objectid,array_keys($this->parentFolders)) )
- {
- $this->showFolder($o->objectid);
- }
-
- $this->outputLn( '</li>' );
- }
- }
-
- if ($o->isPage)
- {
- $page = new Page($o->objectid);
- $page->load();
- if ( $page->templateid != $this->page->templateid && $this->onlySameTemplate )
- continue;
- }
-
- // Seiten und Verknuepfungen anzeigen
- if ($o->isPage || $o->isLink )
- {
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->getObjectId() == $o->objectid)
- // aktuelle Seite
- $this->output( '<li class="active">'.$o->name.'</li>' );
- elseif ( $o->isLink )
- // Link mit HTML-Sonderzeichenumwandlung erzeugen
- $this->output( '<li><a href="'.htmlspecialchars($this->pathToObject($o->objectid)).'">'.$o->name.'</a></li>' );
- else
- // Link erzeugen
- $this->output( '<li><a href="'.$this->pathToObject($o->objectid).'">'.$o->name.'</a></li>' );
- }
- }
- $this->output('</ul>');
- }
-
-}-
\ No newline at end of file
diff --git a/macro/CommonMenu.class.php b/macro/CommonMenu.class.php
@@ -1,101 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.3 2004-12-19 22:35:23 dankert
-// Parameter -Angabe
-//
-// Revision 1.2 2004/12/19 15:19:29 dankert
-// Klasse erbt von "Dynamic"
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Page;
-
-
-/**
- * Erstellen eines Menues
- * @author Jan Dankert
- */
-class CommonMenu extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'beforeEntry'=>'Chars before an active menu entry',
- 'afterEntry' =>'Chars after an active menu entry'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
-
-
- /**
- * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
- */
- var $beforeEntry = '<li><strong>';
- var $afterEntry = '</strong></li>';
-
-
- // Erstellen des Hauptmenues
- function execute()
- {
- // Erstellen eines Untermenues
-
- // Ermitteln der aktuellen Seite
- $thispage = new Page( $this->getObjectId() );
- $thispage->load(); // Seite laden
-
- // uebergeordneter Ordner dieser Seite
- $f = new Folder( $thispage->parentid );
-
- // Schleife ueber alle Objekte im aktuellen Ordner
- foreach( $f->getObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
-
- // Nur Seiten anzeigen
- if (!$o->isPage && !$o->isLink ) continue;
-
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->getObjectId() == $id )
- {
- // aktuelle Seite
- $this->output( '<li><strong>'.$o->name.'</strong></li>' );
- }
- else
- {
- // Link erzeugen
- $this->output( '<li><a href="'.$this->page->path_to_object($id).'">'.$o->name.'</a></li>' );
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/DoiMenu.class.php b/macro/DoiMenu.class.php
@@ -1,132 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.1 2005-01-04 20:31:52 dankert
-// Neues Menue
-//
-// Revision 1.1 2005/01/04 20:00:12 dankert
-// Darstellung eines DHTML-Menues
-//
-// Revision 1.2 2004/12/28 22:57:56 dankert
-// Korrektur Vererbung, "api" ausgebaut
-//
-// Revision 1.1 2004/10/14 21:15:29 dankert
-// Erzeugen und Anzeigen einer Sitemap
-//
-// ---------------------------------------------------------------------------
-use cms\model\File;
-use cms\model\Folder;
-use cms\model\Page;
-
-
-/**
- * Erstellen eines DHTML-Menues (DoiMenu)
- *
- * Diese Klasse erzeugt Javascript-Code fuer das DoiMenu
- *
- * @see http://doimenu.sf.net for details
- * @author Jan Dankert
- */
-class DoiMenu extends Macro
-{
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'You *have to* include doiMenuDOM.js in the page!<br/>Put the code below in head section:<br/><tt><script type="text/javascript" src="{{your-elementname}}.js"></script></tt><br/>The file is distributed with OpenRat';
-
-
- /**
- * Parameter mit Objekt-Id
- * Die Datei mit dieser Id enthaelt Parameter fuer das Menu
- */
- var $parameterFileId = 0;
-
- /**
- * Ausrichtung des Menues.
- * available value : 'horizontal','vertical'.
- */
- var $direction = 'horizontal';
-
-
- /**
- * Erstellen des DHTML-Menues
- */
- function execute()
- {
- // Erstellen eines Untermenues
-
- // Ermitteln der aktuellen Seite
- $thispage = new Page( $this->getObjectId() );
- $thispage->load(); // Seite laden
-
- $this->outputLn('<script name="javascript" type="text/javascript">');
-
- $this->outputLn(" var menu = new TMainMenu('menu','".$this->direction."');");
-
- $ro = new Folder($this->getRootObjectId());
- $this->showFolder( $ro );
-
- if ( intval( $this->parameterFileId ) != 0 )
- {
- $f = new File( intval($this->parameterFileId) );
- $this->outputLn( $f->loadValue() );
- }
-
- $this->outputLn( ' menu.Build()' );
- $this->outputLn( '</script');
- }
-
-
- function showFolder( $fo )
- {
- if ( $fo->objectid == intval($this->getRootObjectId()) )
- $parentMenu = 'menu';
- else
- $parentMenu = 'menu'.$fo->objectid;
-
- foreach( $fo->getObjects() as $o )
- {
- $menu = 'menu'.$o->objectid;
-
- if ( $o->isFolder )
- { $nf = new Folder($o->objectid);
- $pl = $nf->getFirstPageOrLink();
- if ( is_object($pl) )
- {
- $this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($pl->objectid)."','".$o->desc."');");
- $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
- $this->showFolder( $nf );
- }
- }
-
- if ( $o->isPage || $o->isPage )
- {
- $this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($o->objectid)."','".$o->desc."');");
- $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
- }
- }
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/GoogleMaps.class.php b/macro/GoogleMaps.class.php
@@ -1,63 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-
-
-
-/**
- * Bindet eine Google-Maps-Karte ein.
- *
- * @author Jan Dankert
- */
-class GoogleMaps extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'lat' => 'Latitude',
- 'long' => 'Longitude',
- 'zoom' => 'Zoom'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Includes a Google Map.';
-
- var $long = 10; // Default: Hamburg
- var $lat = 53.55; // Default: Hamburg
- var $zoom = 10;
- var $width = 425;
- var $height = 350;
-
- /**
- */
- function execute()
- {
- $this->output('<iframe width="'.$this->width.'" height="'.$this->height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.de/?ie=UTF8&ll='.$this->lat.','.$this->long.'&z='.$this->zoom.'&output=embed"></iframe>');
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/LanguageLinksForPage.class.php b/macro/LanguageLinksForPage.class.php
@@ -1,72 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2012 Tobias Schöne tobias@schoenesnetz.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$
-// ---------------------------------------------------------------------------
-use cms\model\Language;
-
-/**
- * Erstellen einer Liste von Language-Links auf die selbe Seite
- * @author Tobias Schoene
- */
-class LanguageLinksForPage extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between entries'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates language links to the page.';
- var $version = '$Id$';
- var $api;
-
- // Build the navigation links to other languages
- function execute()
- {
- // current language
- $languageId = $this->page->languageid;
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( Language::getAll() as $lid=>$lname)
- {
-
- $l = new Language( $lid );
- $l->load();
- $this->page->languageid = $l->languageid;
- $filename = $this->page->full_filename();
- $filename = str_replace($this->page->path(),".",$filename);
- $this->output( '<li><a href="'.$filename.'">'.strtolower($l->isoCode).'</a></li>' );
-
- }
- $this->page->languageid = $languageId;
- }
-}
-?>-
\ No newline at end of file
diff --git a/macro/LastChanges.class.php b/macro/LastChanges.class.php
@@ -1,163 +0,0 @@
-<?php
-// 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.
-use cms\model\Folder;
-use cms\model\Link;
-use cms\model\Page;
-
-
-/**
- * Erstellen einer Teaser-Liste.
- *
- * @author Jan Dankert
- */
-class LastChanges extends Macro
-{
- var $title_html_tag = 'h3';
- var $css_class = 'macro-lastchanges';
- var $teaserElementId = '';
- var $teaserMaxLength = 100;
- var $plaintext = 'true';
- var $linktitle = 'true';
- var $linktext = 'true';
- var $timeelementid = 0;
- var $folderid = 0;
- var $showPages = true;
- var $showLinks = false;
- var $includeTemplateIds = array();
- var $excludeTemplateIds = array();
- var $limit = -1;
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a teaser list of pages in a folder';
-
- //
- function execute()
- {
- $project = Session::getProject();
-
- if ( $this->folderid === 'self' )
- {
- $page = $this->getPage();
- $page->load();
- $folderid = $page->parentid;
- $f = new Folder( $folderid );
- $changes = $f->getLastChanges();
- }
- elseif ( $this->folderid > 0 )
- {
- $f = new Folder( $this->folderid );
- $changes = $f->getLastChanges();
- }
- else
- $changes = $project->getLastChanges();
-
- $count = 0;
-
- foreach( $changes as $o )
- {
- if ($o['objectid'] == $this->getObjectId() )
- continue;
-
- if ( ($o['typeid']==OR_TYPEID_PAGE && istrue($this->showPages)) ||
- ($o['typeid']==OR_TYPEID_LINK && istrue($this->showLinks)) ) // Nur wenn gewünschter Typ
- {
- if ( $o['typeid']==OR_TYPEID_LINK ) {
- $l = new Link( $o['objectid'] );
- $l->load();
-
- $p = new Page( $l->linkedObjectId );
- }
- elseif ( $o['typeid']==OR_TYPEID_PAGE )
- {
- $p = new Page( $o['objectid'] );
- }
- else
- continue;
-
- $p->load();
-
- // Template zulässig?
- if ( !empty($this->includeTemplateIds) )
- if ( !in_array($p->templateid,$this->includeTemplateIds))
- continue;
-
- // Template zulässig?
- if ( !empty($this->excludeTemplateIds) )
- if ( in_array($p->templateid,$this->excludeTemplateIds))
- continue;
-
- $count++;
- if ( $this->limit >= 0 && $count > $this->limit)
- break; // Maximale Anzahl erreicht.
-
- $desc = $p->desc;
- $p->generate_elements();
-
- if ( !empty($this->teaserElementId) )
- {
- $value = $p->values[$this->teaserElementId];
- $desc = $value->value;
- if ( istrue($this->plaintext) )
- {
- $desc = strip_tags($desc);
- // Und nur wenn die Tags raus sind duerfen wir nun den Text kuerzen.
- // (sonst drohen offene Tags)
- if ( is_numeric($this->teaserMaxLength) && $this->teaserMaxLength > 0 )
- $desc = Text::maxLength($desc,$this->teaserMaxLength);
- }
- }
-
- $time = '';
- if ( !empty($this->timeelementid) )
- {
- $value = $p->values[$this->timeelementid];
- $time = $value->value;
- }
-
- $this->output('<div class="'.$this->css_class.'">');
-
- if ( istrue($this->linktitle) )
- {
- $url = $this->pathToObject($o['objectid']);
- $this->output( '<a href="'.$url.'"><div>' );
- }
-
- $this->output('<h6>'.$time.'</h6>');
-
-
- $this->output( '<h3>');
- $this->output( $p->name );
- $this->output( '</h3>' );
-
- $this->output( '<p>' );
- $this->output( $desc );
- $this->output( '</p>' );
-
- if ( istrue($this->linktitle) )
- {
- $this->output( '</div></a>' );
- }
-
- $this->output( '</div>' );
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/LastPage.class.php b/macro/LastPage.class.php
@@ -1,79 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2005-01-04 19:59:55 dankert
-// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-
-
-/**
- * Erstellen eines Links zur Seite davor
- * @author Jan Dankert
- */
-class LastPage extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between menu entries, default: "·"'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
- var $version = '$Id$';
-
-
- function execute()
- {
- $folder = new Folder( $this->page->parentid );
-
- $lastObject = null;
-
- // Schleife ueber alle Inhalte des Ordners
- foreach( $folder->getObjects() as $o )
- {
- if ( $o->isPage || $o->isLink )
- {
- if ( is_object($lastObject) && $o->objectid == $this->page->objectid )
- {
- $this->output( '<a href="'.$this->pathToObject($lastObject->objectid).' class="next">'.$lastObject->name.'</a>' );
- break;
- }
-
- $lastObject = $o->objectid;
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/Link.class.php b/macro/Link.class.php
@@ -1,56 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2005-01-04 19:59:55 dankert
-// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Object;
-
-
-/**
- * Erstellen eines Links.
- *
- * @author Jan Dankert
- */
-class NextPage extends Macro
-{
- public $targetid = 0;
- public $classes = '';
- public $name = '';
- public $title = '';
-
- function execute()
- {
- // Lesen des Ordners
- $o = new Object( $this->targetid );
- $o->load();
-
- if ( empty($this->name ) ) $this->name = $o->name;
- if ( empty($this->title) ) $this->title = $o->description;
-
- $this->output( '<a href="'.$this->pathToObject($this->targetid).' title="'.$this->title.'" class="'.$this->classes.'">'.$this->name.'</a>' );
- }
-}-
\ No newline at end of file
diff --git a/macro/ListMenu.class.php b/macro/ListMenu.class.php
@@ -1,115 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.1 2005-01-28 23:06:10 dankert
-// Neues Menue in Listenform (HTML-Listen), aehnlich "BlockMenu"
-//
-// Revision 1.2 2004/12/25 21:05:14 dankert
-// erbt von Klasse Dynamic
-//
-// Revision 1.1 2004/10/14 21:16:12 dankert
-// Erzeugen eines Menues in Bloecken
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Object;
-
-
-/**
- * Erstellen eines Hauptmenues
- * @author Jan Dankert
- */
-class ListMenu extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between menu entries, default: "·"'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
- var $version = '$Id$';
- var $api;
-
- // Erstellen des Hauptmenues
- function execute()
- {
- // Erstellen des Hauptmenues
-
- // Lesen des Root-Ordners
- $folder = new Folder( $this->getRootObjectId() );
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
- if ( $o->isFolder ) // Nur wenn Ordner
- {
- $f = new Folder( $id );
- $f->load();
-
- // Ermitteln eines Objektes mit dem Dateinamen index
-// $oid = $f->getObjectIdByFileName('index');
-
- if ( count($f->getLinks())+count($f->getPages()) > 0 )
- {
- $this->output( '<h1 class="title">'.$o->name.'</h1><ul>');
- // Untermenue
- // Schleife ber alle Objekte im aktuellen Ordner
- foreach( $f->getObjectIds() as $xid )
- {
- $o = new Object( $xid );
- $o->languageid = $this->page->languageid;
- $o->load();
-
- // Nur Seiten und Verknuepfungen anzeigen
- if (!$o->isPage && !$o->isLink && !$o->isUrl ) continue;
-
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->getObjectId() == $xid )
- {
- // aktuelle Seite
- $this->output( '<li class="menu">'.$o->name.'</li>' );
- }
- else
- {
- $this->output( '<li class="menu"><a class="menu" href="'.$this->page->path_to_object($xid).'">'.$o->name.'</a></li>' );
- }
- }
-
- $this->output( '</ul><br />' );
- }
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/MainMenu.class.php b/macro/MainMenu.class.php
@@ -1,81 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2004-12-19 15:19:16 dankert
-// Klasse erbt von "Dynamic"
-//
-// Revision 1.1 2004/10/14 21:15:57 dankert
-// Erzeugen eines Hauptmenues
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Object;
-
-
-/**
- * Erstellen eines Hauptmenues
- * @author Jan Dankert
- */
-class MainMenu extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between menu entries, default: "·"'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
- var $version = '$Id$';
-
- // Erstellen des Hauptmenues
- function execute()
- {
- // Lesen des Root-Ordners
- $folder = new Folder( $this->getRootObjectId() );
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
- if ( $o->isFolder ) // Nur wenn Ordner
- {
- $f = new Folder( $id );
-
- // Ermitteln eines Objektes mit dem Dateinamen index
- $oid = $f->getObjectIdByFileName('index');
- if ( is_numeric($oid) && $oid!=0 )
- $this->output( $this->arrowChar.'<a href="'.$this->page->path_to_object($oid).'" title="'.$o->desc.'">'.$o->name.'</a>' );
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/NextPage.class.php b/macro/NextPage.class.php
@@ -1,85 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2005-01-04 19:59:55 dankert
-// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-
-
-/**
- * Erstellen eines Links zur naechsten Seite
- * @author Jan Dankert
- */
-class NextPage extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between menu entries, default: "·"'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
- var $version = '$Id$';
- var $api;
-
-
- function execute()
- {
- // Lesen des Ordners
- $folder = new Folder( $this->page->parentid );
-
- $was = false;
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjects() as $o )
- {
- if ( $o->isPage || $o->isLink ) // Nur wenn Ordner
- {
- if ( $o->objectid == $this->page->objectid )
- {
- $was = true;
- continue;
- }
-
- if ( $was )
- {
- $this->output( '<a href="'.$this->pathToObject($o->objectid).' class="next">'.$o->name.'</a>' );
- break;
- }
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/OpenStreetMap.class.php b/macro/OpenStreetMap.class.php
@@ -1,63 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-
-
-
-/**
- * Bindet die OpenStreetMap ein.
- *
- * @author Jan Dankert
- */
-class OpenStreetMap extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'box' => 'coordinates',
- 'layer' => 'mapnik',
- 'width' => 'Width of iframe',
- 'height' => 'Height of iframe',
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Includes the OpenStreetMap.';
-
- var $box = '9.9396,53.4821,10.184,53.643'; // default: Hamburg
- var $layer = 'mapnik';
- var $width = 425;
- var $height = 350;
-
- /**
- */
- function execute()
- {
- $this->output('<iframe width="'.$this->width.'" height="'.$this->height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox='.$this->box.'&layer='.$this->layer.'" style="border: 1px solid black"></iframe>');
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/PagesNavigation.class.php b/macro/PagesNavigation.class.php
@@ -1,78 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2005-01-04 19:59:55 dankert
-// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
-//
-// Revision 1.1 2004/11/10 22:43:35 dankert
-// Beispiele fuer dynamische Templateelemente
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-
-
-/**
- * Erstellen eines Hauptmenues
- * @author Jan Dankert
- */
-class PagesNavigation extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'arrowChar'=>'String between entries'
- );
-
-
- var $arrowChar = ' · ';
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a page navigation.';
- var $version = '$Id$';
- var $api;
-
- // Erstellen des Hauptmenues
- function execute()
- {
- // Lesen des Root-Ordners
- $folder = new Folder( $this->page->parentid );
-
- $nr = 0;
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjects() as $o )
- {
- $nr++;
- if ( $o->isPage || $o->isLink )
- {
- if ( $o->objectid != $this->page->objectid )
- $this->output( '<a href="'.$this->page->path_to_object($oid).'" title="'.$o->desc.'" class="pagenav">'.$nr.'</a>' );
- else
- $this->output( '<strong>'.$nr.'</strong>' );
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/RSSCreate.class.php b/macro/RSSCreate.class.php
@@ -1,170 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.4 2009-03-16 23:30:02 dankert
-// Unnötigen Aufruf von pathToObject entfernt.
-//
-// Revision 1.3 2007-11-17 02:19:29 dankert
-// Erg?nzung der Version (Default: 0.91), Korrektur, Anpassung an neue API.
-//
-// Revision 1.2 2004/12/28 22:57:56 dankert
-// Korrektur Vererbung, "api" ausgebaut
-//
-// Revision 1.1 2004/10/14 21:14:52 dankert
-// Erzeugen eines RSS-Feeds aus einem Ordner
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-
-
-/**
- * Erstellen eines Hauptmenues
- * @author Jan Dankert
- */
-class RSSCreate extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'htmlentities' =>'Escape HTML-Tags in RSS-Feed, default: false',
- 'folderid' =>'Id of the folder whose pages should go into the RSS-Feed, default: the root folder',
- 'feed_url' =>'Url of the feed, default: blank',
- 'feed_title' =>'Title of the feed, default: Name of folder',
- 'feed_description'=>'Description of the feed, default: Description of folder'
- );
-
- var $htmlentities = false;
- var $folderid = 0;
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates an RSS-Feed of pages in a folder';
- var $api;
-
- var $feed_version = '0.91';
- var $feed_url = '';
- var $feed_title = '';
- var $feed_description = '';
-
- // Erstellen des Hauptmenues
- function execute()
- {
- $feed = array();
-
- // Lesen des Root-Ordners
- if ( intval($this->folderid) == 0 )
- $folder = new Folder( $this->getRootObjectId() );
- else
- $folder = new Folder( intval($this->folderid) );
-
- $folder->load();
-
- if ( $this->feed_title == '' )
- $this->feed_title = $folder->name;
-
- if ( $this->feed_description == '' )
- $this->feed_description = $folder->desc;
-
- $feed['title' ] = $this->feed_title;
- $feed['description'] = $this->feed_description;
- $feed['url' ] = $this->feed_url;
- $feed['items' ] = array();
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjectIds() as $id )
- {
- if ( $id == $this->getObjectId() )
- continue;
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
- if ( $o->isPage ) // Nur wenn Seite
- {
- $p = new Page( $id );
- $p->load();
-
- $item = array();
- $item['title' ] = $p->name;
- $item['description'] = $p->desc;
- $item['pubDate' ] = $p->lastchangeDate;
- if ( empty($this->feed_url) )
- $item['link' ] = $this->pathToObject($id);
- else
- $item['link' ] = $this->feed_url;
-
- $feed['items'][] = $item;
- }
- }
-
- $rss = $this->rss($feed);
-
- if ( $this->htmlentities )
- $rss = htmlentities( $rss );
-
- $this->output( $rss );
- }
-
-
- function rss($input, $stylesheet='')
- {
-// print_r($input);
- // Builds the XML RSS schema using the array
- $input["encoding"] = (empty($input["encoding"] ))?"UTF-8":$input["encoding"];
- $input["language"] = (empty($input["language"] ))?"en-us":$input["language"];
-
- if ( empty($input['title' ])) $input['title' ] = '';
- if ( empty($input['description'])) $input['description'] = '';
- if ( empty($input['link' ])) $input['link' ] = '';
- $rss = '<?xml version="1.0" encoding="'.$input["encoding"].'"?>';
- $rss .= (!empty($stylesheet))?"\n".'<?xml-stylesheet type="text/xsl" href="'.$stylesheet.'"?>':"";
- $rss .= <<<__RSS__
-
- <rss version="{$this->feed_version}">
- <channel>
- <title>{$input["title"]}</title>
- <description>{$input["description"]}</description>
- <link>{$input["link"]}</link>
- <language>{$input["language"]}</language>
- <generator></generator>
-
-__RSS__;
- foreach($input["items"] as $item)
- {
- if ( empty($item['title' ])) $item['title' ] = '';
- if ( empty($item['description'])) $item['description'] = '';
- $data = date("r", $item["pubDate"]);
- $rss .= "\n<item>\n<title>".$item["title"]."</title>";
- $rss .= "\n<description><![CDATA[".$item["description"]."]]></description>";
- if (!empty($item["pubDate"]))
- $rss .= "\n<pubDate>".date("r", $item["pubDate"])."</pubDate>";
- if (!empty($item["link"]))
- $rss .= "\n<link>".$item["link"]."</link>";
- $rss .= "\n</item>\n";
- }
- $rss .= "\n</channel>\n</rss>";
- return $rss;
- }
-}-
\ No newline at end of file
diff --git a/macro/RSSReader.class.php b/macro/RSSReader.class.php
@@ -1,180 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2004-12-19 15:18:50 dankert
-// Speichern des RSS-Feeds in Session (Performance)
-//
-// Revision 1.1 2004/10/14 21:15:13 dankert
-// Lesen eines RSS-Feeds und erzeugen eines HTML-Abschnittes dafuer
-//
-// ---------------------------------------------------------------------------
-
-
-
-/**
- * @author Jan Dankert
- */
-class RSSReader extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'url'=>'URL from which the RSS is fetched'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Reads a RSS-Feed and displays its content as a html list';
-
- var $url = 'http://www.heise.de/newsticker/heise.rdf';
-
-
-
- function execute()
- {
- // Sessionvariable mit CRC verschluesseln, falls es mehrere RSS-Feeds im Projekt gibt
- $sessVar = 'RSSReader_'.crc32($this->url);
- $cache = $this->getSessionVar( $sessVar );
-
- if ( !empty($cache) )
- {
- // Wenn Cache vorhanden, dann diesen ausgeben
- $this->output( $cache );
- }
- else
- {
- // Wenn Cache leer, dann RSS erzeugen und in Session speichern
- $this->create();
- $this->setSessionVar( $sessVar,$this->getOutput() );
- }
- }
-
-
-
- // Erzeugt den Text des RSS-Feeds
- function create()
- {
- $rss = $this->parse( implode('',file($this->url)) );
- $out = array();
-
- $this->output('<ul>');
-
- // Schleife ueber alle Inhalte des RSS-Feeds
- foreach( $rss['items'] as $item )
- {
- $this->output('<li>');
- $this->output('<a href="'.$item['link'].'">'.$item['title'].'</a><br/>'.$item['description']);
- $this->output('</li>');
- }
-
- $this->output('</ul>');
- }
-
-
-
- function parse( $feed )
- {
- // Parses the RSS feed into the array
- $arr = array();
- // Determine encoding
- preg_match('/<\?xml version="1\.0" encoding="(.*)"\?>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["encoding"] = $sarr[1];
- // Determine title
- preg_match('/<title>(.*)<\/title>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["title"] = $sarr[1];
- // Determine title
- preg_match('/<title>(.*)<\/title>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["title"] = $sarr[1];
- // Determine description
- preg_match('/<description>(.*)<\/description>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["description"] = $sarr[1];
- // Determine link
- preg_match('/<link>(.*)<\/link>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["link"] = $sarr[1];
- // Determine language
- preg_match('/<language>(.*)<\/language>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["language"] = $sarr[1];
- // Determine generator
- preg_match('/<generator>(.*)<\/generator>/i', $feed, $sarr);
- if ( !empty($sarr[1]))
- $arr["generator"] = $sarr[1];
- // Strip items
- $parts = explode("<item>", $feed);
- foreach($parts as $part)
- {
- $item = substr($part, 0, strpos($part, "</item>"));
- if ( !empty($item) )
- $items[] = $item;
- }
- // Fill the channel array
- $arr["items"] = array();
- foreach($items as $item)
- {
- $i = array();
-
- // Determine title
- preg_match('/<title>(.*)<\/title>/i', $item, $title);
- if ( !empty($title[1]))
- $i['title'] = $title[1];
- else
- $i['title'] = '';
-
- // Determine pubdate
- preg_match('/<pubDate>(.*)<\/pubDate>/i', $item, $pubdate);
- if ( !empty($pubdate[1]))
- $i['pubDate'] = strtotime($pubdate[1]);
- else
- $i['pubDate'] = '';
-
- // Determine link
- preg_match('/<link>(.*)<\/link>/i', $item, $link);
- if ( !empty($link[1]))
- $i['link'] = $link[1];
- else
- $i['link'] = '';
-
- // Determine description
- if(stristr($item, '<![CDATA['))
- preg_match('/<description><!\[CDATA\[(.*)\]\]><\/description>/is', $item, $description);
- else
- preg_match('/<description>(.*)<\/description>/is', $item, $description);
-
- if ( !empty($description[1]))
- $i['description'] = $description[1];
- else
- $i['description'] = '';
-
- $arr["items"][] = $i;
- }
- return $arr;
- }
-}-
\ No newline at end of file
diff --git a/macro/Sitemap.class.php b/macro/Sitemap.class.php
@@ -1,119 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.2 2004-12-28 22:57:56 dankert
-// Korrektur Vererbung, "api" ausgebaut
-//
-// Revision 1.1 2004/10/14 21:15:29 dankert
-// Erzeugen und Anzeigen einer Sitemap
-//
-// ---------------------------------------------------------------------------
-use cms\model\Folder;
-use cms\model\Object;
-use cms\model\Page;
-
-
-/**
- * Erstellen eines Menues
- * @author Jan Dankert
- */
-class Sitemap extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'beforeEntry'=>'Chars before an active menu entry'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a main menu.';
-
-
- /**
- * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
- */
- var $beforeEntry = '<li><strong>';
- var $afterEntry = '</strong></li>';
-
- var $api;
-
- /**
- * Erstellen einer Sitemap
- */
- function execute()
- {
- // Erstellen eines Untermenues
-
- // Ermitteln der aktuellen Seite
- $thispage = new Page( $this->getObjectId() );
- $thispage->load(); // Seite laden
-
- // uebergeordneter Ordner dieser Seite
- $this->showFolder( $this->getRootObjectId() );
- }
-
- function showFolder( $oid )
- {
- // uebergeordneter Ordner dieser Seite
- $f = new Folder( $oid );
-
- // Schleife ueber alle Objekte im aktuellen Ordner
- foreach( $f->getObjectIds() as $id )
- {
- $o = new Object( $id );
- $o->languageid = $this->page->languageid;
- $o->load();
-
- // Ordner
- if ($o->isFolder )
- {
- $this->output( '<li><strong>'.$o->name.'</strong><br/>' );
- $this->output( '<ul>' );
- $this->showFolder( $id ); // Rekursiver Aufruf dieser Methode
- $this->output( '</ul></li>' );
- }
-
- // Seiten und Verkn?fpungen
- if ($o->isPage || $o->isLink )
- {
- // Wenn aktuelle Seite, dann markieren, sonst Link
- if ( $this->getObjectId() == $id )
- {
- // aktuelle Seite
- $this->output( '<li><strong>'.$o->name.'</strong></li>' );
- }
- else
- {
- // Link erzeugen
- $this->output( '<li><a href="'.$this->pathToObject($id).'">'.$o->name.'</a></li>' );
- }
- }
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/macro/TableFromFile.class.php b/macro/TableFromFile.class.php
@@ -1,89 +0,0 @@
-<?php
-// 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.
-use cms\model\File;
-
-
-/**
- * Erstellt eine HTML-Tabelle aus einer CSV-Datei.
- *
- * @author Jan Dankert
- */
-class TagCloud extends Macro
-{
- /**
- * Beschreibung dieser Klasse
- * @type String
- */
- var $description = '';
-
-
- public $fileid = 0;
- public $separator = ',';
- public $firstlineheader = 1;
- public $firstcolumnheader = 1;
- public $ignorefirstline = 0;
- public $header = 'A,B,C';
- public $encodeHtml = 1;
-
-
- function execute()
- {
- $this->output('<table>');
- $file = new File( $this->fileid );
- $lines = explode("\n",$file->loadValue() );
-
- $firstline = true;
- foreach( $lines as $line )
- {
- if ( $firstline)
- {
- $firstline = false;
- if ( $this->ignorefirstline)
- continue;
- elseif ( $this->firstlineheader )
- $lcelltag = 'th';
- else
- $lcelltag = 'td';
- }
- else
- $lcelltag = 'td';
-
- $columns = explode($this->separator,$line);
-
- $this->output('<tr>');
- $firstcolumn = true;
- foreach( $columns as $column )
- {
- if ($firstcolumn)
- {
- $firstcolumn = false;
- if ( $this->firstcolumnheader )
- $celltag = 'th';
- else
- $celltag = $lcelltag;
-
- if ( $this->encodeHtml) $column = encodeHtml($column);
- $this->output('<'.$celltag.'>'.$column.'</'.$celltag.'>');
- }
- }
- $this->output('</tr>');
- }
- $this->output('</table>');
- }
-
-}-
\ No newline at end of file
diff --git a/macro/TagCloud.class.php b/macro/TagCloud.class.php
@@ -1,66 +0,0 @@
-<?php
-// 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.
-use cms\model\Folder;
-
-
-/**
- * Erstellt eine Tagcloud.
- * @author Jan Dankert
- */
-class TagCloud extends Macro
-{
- /**
- * Beschreibung dieser Klasse
- * @type String
- */
- var $description = '';
-
-
- public $keywordFolderId = 0;
-
-
- // Erstellen des Hauptmenues
- function execute()
- {
- if ( intval($this->keywordFolderId) == 0 )
- {
- $this->output('param keywordfolderid not set');
- return;
- }
-
- $f = new Folder( $this->keywordFolderId );
-
- foreach( $f->getChildObjectIdsByName() as $fid )
- {
- $tf = new Folder($fid);
- if ( !$tf->isFolder)
- continue;
- $tf->load();
-
- $target = $tf->getFirstPage();
-
- if ( $target == null)
- continue;
- $target->load();
-
- // Link zum Tag erzeugen
- $this->output( '<div class="tag" style="font-size:'.(0.5+(sizeof($tf->getObjectIds())*0.1)).'em"><a href="'.$this->pathToObject($target->objectid).'">'.$tf->name.'</a></div>' );
- }
- }
-
-}-
\ No newline at end of file
diff --git a/macro/TagList.class.php b/macro/TagList.class.php
@@ -1,55 +0,0 @@
-<?php
-// 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.
-use cms\model\Folder;
-use cms\model\Link;
-
-
-/**
- * Erstellt eine Tagcloud.
- * @author Jan Dankert
- */
-class TagList extends Macro
-{
- /**
- * Beschreibung dieser Klasse
- * @type String
- */
- var $description = '';
-
- function execute()
- {
- $page = $this->getPage();
- $linkIds = $page->getLinksToMe();
-
- foreach( $linkIds as $linkid )
- {
- $l = new Link( $linkid );
- $l->load();
- $f = new Folder( $l->parentid );
- $f->load();
-
- $target = $f->getFirstPage();
- if ( $target==null) continue;
- $target->load();
-
- // Link erzeugen
- $this->output( '<div class="tag"><a href="'.$this->pathToObject($target->objectid).'">'.$f->name.'</a></div>' );
- }
- }
-
-}-
\ No newline at end of file
diff --git a/macro/TeaserList.class.php b/macro/TeaserList.class.php
@@ -1,114 +0,0 @@
-<?php
-// 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.
-use cms\model\Folder;
-use cms\model\Page;
-
-
-/**
- * Erstellen einer Teaser-Liste.
- *
- * @author Jan Dankert
- */
-class TeaserList extends Macro
-{
- var $folderid = 0;
- var $title_html_tag = 'h2';
- var $time_html_tag = 'h6';
- var $title_css_class = 'teaser';
- var $description_css_class = 'teaser';
- var $link_css_class = 'teaser';
- var $teaserElementId = '';
- var $teaserMaxLength = 100;
- var $plaintext = 'true';
- var $linktitle = 'true';
- var $linktext = 'true';
- var $timeelementid = 0;
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Creates a teaser list of pages in a folder';
-
- // Erstellen des Hauptmenues
- function execute()
- {
- $feed = array();
-
- // Lesen des Root-Ordners
- if ( intval($this->folderid) == 0 )
- $folder = new Folder( $this->getRootObjectId() );
- else
- $folder = new Folder( intval($this->folderid) );
-
- $folder->load();
-
- // Schleife ueber alle Inhalte des Root-Ordners
- foreach( $folder->getObjects() as $o )
- {
- if ( $o->isPage ) // Nur wenn Ordner
- {
- $p = new Page( $o->objectid );
- $p->load();
-
- $desc = $p->desc;
- $p->generate_elements();
-
- if ( !empty($this->teaserElementId) )
- {
- $value = $p->values[$this->teaserElementId];
- $desc = $value->value;
- if ( istrue($this->plaintext) )
- {
- $desc = strip_tags($desc);
- // Und nur wenn die Tags raus sind duerfen wir nun den Text kuerzen.
- // (sonst drohen offene Tags)
- if ( is_numeric($this->teaserMaxLength) && $this->teaserMaxLength > 0 )
- $desc = Text::maxLength($desc,$this->teaserMaxLength);
- }
- }
-
- $time = '';
- if ( !empty($this->timeelementid) )
- {
- $value = $p->values[$this->timeelementid];
- $time = $value->value;
- }
-
- $this->output('<'.$this->time_html_tag.'>'.$time.'</'.$this->time_html_tag.'>');
-
- $url = $this->pathToObject($o->objectid);
-
- $this->output( '<'.$this->title_html_tag.' class="'.$this->title_css_class.'">');
- if ( istrue($this->linktitle) )
- $this->output( '<a href="'.$url.'">'.$p->name.'</a>' );
- else
- $this->output( $p->name );
- $this->output( '</'.$this->title_html_tag.'>' );
-
- $this->output( '<p class="'.$this->description_css_class.'">' );
- if ( istrue($this->linktext) )
- $this->output( '<a href="'.$this->pathToObject($o->objectid).'">'.$desc.'</a>' );
- else
- $this->output( $desc );
-
- $this->output( '</p>' );
- }
- }
- }
-}-
\ No newline at end of file
diff --git a/macro/Youtube.class.php b/macro/Youtube.class.php
@@ -1,59 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-
-
-
-/**
- * Bindet ein Youtube-Video ein.
- *
- * @author Jan Dankert
- */
-class Youtube extends Macro
-{
- /**
- * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $parameters = Array(
- 'id'=>'Video-Id'
- );
-
- /**
- * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
- * @type String
- */
- var $description = 'Includes a youtube video.';
-
- var $id = "0";
- var $width = 320;
- var $height = 265;
-
- /**
- */
- function execute()
- {
- $this->output('<object width="'.$this->width.'" height="'.$this->height.'"><param name="movie" value="http://www.youtube.com/v/'.$this->id.'&hl=de&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$this->id.'&hl=de&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$this->width.'" height="'.$this->height.'"></embed></object>');
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/model/.htaccess b/model/.htaccess
@@ -1,2 +0,0 @@
-order deny,allow
-deny from all-
\ No newline at end of file
diff --git a/model/Acl.class.php b/model/Acl.class.php
@@ -1,504 +0,0 @@
-<?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.
-
-
-
-// Definition der Berechtigungs-Bits
-define('ACL_READ' ,1 );
-define('ACL_WRITE' ,2 );
-define('ACL_PROP' ,4 );
-define('ACL_DELETE' ,8 );
-define('ACL_RELEASE' ,16 );
-define('ACL_PUBLISH' ,32 );
-define('ACL_CREATE_FOLDER',64 );
-define('ACL_CREATE_FILE' ,128 );
-define('ACL_CREATE_LINK' ,256 );
-define('ACL_CREATE_PAGE' ,512 );
-define('ACL_GRANT' ,1024);
-define('ACL_TRANSMIT' ,2048);
-
-
-/**
- * Darstellen einer Berechtigung (ACL "Access Control List")
- * Die Berechtigung zu einem Objekt wird mit einer Liste dieser Objekte dargestellt
- *
- * Falls es mehrere ACLs zu einem Objekt gibt, werden die Berechtigung-Flags addiert.
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
-class Acl
-{
- /**
- * eindeutige ID dieser ACL
- * @type Integer
- */
- var $aclid;
-
- /**
- * ID des Objektes, f?r das diese Berechtigung gilt
- * @type Integer
- */
- var $objectid = 0;
-
- /**
- * ID des Benutzers
- * ( = 0 falls die Berechtigung f?r eine Gruppe gilt)
- * @type Integer
- */
- var $userid = 0;
-
- /**
- * ID der Gruppe
- * ( = 0 falls die Berechtigung f?r einen Benutzer gilt)
- * @type Integer
- */
- var $groupid = 0;
-
- /**
- * ID der Sprache
- * @type Integer
- */
- var $languageid = 0;
-
- /**
- * Name der Sprache
- * @type String
- */
- var $languagename = '';
-
- /**
- * Es handelt sich um eine Standard-Berechtigung
- * (Falls false, dann Zugriffs-Berechtigung)
- * @type Boolean
- */
- var $isDefault = false;
-
- /**
- * Name des Benutzers, f?r den diese Berechtigung gilt
- * @type String
- */
- var $username = '';
-
- /**
- * Name der Gruppe, f?r die diese Berechtigung gilt
- * @type String
- */
- var $groupname = '';
-
- /**
- * Inhalt lesen (ist immer wahr)
- * @type Boolean
- */
- var $read = true;
-
- /**
- * Inhalt bearbeiten
- * @type Boolean
- */
- var $write = false;
-
- /**
- * Eigenschaften bearbeiten
- * @type Boolean
- */
- var $prop = false;
-
- /**
- * Objekt l?schen
- * @type Boolean
- */
- var $delete = false;
-
- /**
- * Objektinhalt freigeben
- * @type Boolean
- */
- var $release = false;
-
- /**
- * Objekt ver?ffentlichen
- * @type Boolean
- */
- var $publish = false;
-
- /**
- * Unterordner anlegen
- * @type Boolean
- */
- var $create_folder = false;
-
- /**
- * Datei anlegen (bzw. hochladen)
- * @type Boolean
- */
- var $create_file = false;
-
- /**
- * Verknuepfung anlegen
- * @type Boolean
- */
- var $create_link = false;
-
- /**
- * Seite anlegen
- * @type Boolean
- */
- var $create_page = false;
-
- /**
- * Berechtigungen vergeben
- * @type Boolean
- */
- var $grant = false;
-
- /**
- * Berechtigungen an Unterobjekte vererben
- * @type Boolean
- */
- var $transmit = false;
-
-
- /**
- * Konstruktor.
- *
- * @param Integer Acl-ID
- */
- function __construct( $aclid = 0 )
- {
- if ( $aclid != 0 )
- $this->aclid = $aclid;
- }
-
-
- /**
- * Laden einer ACL inklusive Benutzer-, Gruppen- und Sprachbezeichnungen.
- * Zum einfachen Laden sollte #loadRaw() benutzt werden.
- */
- function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{acl}}.*,{{user}}.name as username,{{group}}.name as groupname,{{language}}.name as languagename'.
- ' FROM {{acl}} '.
- ' LEFT JOIN {{user}} ON {{user}}.id = {{acl}}.userid '.
- ' LEFT JOIN {{group}} ON {{group}}.id = {{acl}}.groupid '.
- ' LEFT JOIN {{language}} ON {{language}}.id = {{acl}}.languageid '.
- ' WHERE {{acl}}.id={aclid}' );
-
- $sql->setInt('aclid',$this->aclid);
-
- $row = $sql->getRow();
-
- $this->setDatabaseRow( $row );
-
- if ( intval($this->languageid)==0 )
- $this->languagename = lang('GLOBAL_ALL_LANGUAGES');
- else $this->languagename = $row['languagename'];
- $this->username = $row['username' ];
- $this->groupname = $row['groupname' ];
- }
-
-
- /**
- * Laden einer ACL (ohne verknuepfte Namen).
- * Diese Methode ist schneller als #load().
- */
- function loadRaw()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * '.
- ' FROM {{acl}} '.
- ' WHERE {{acl}}.id={aclid}' );
-
- $sql->setInt('aclid',$this->aclid);
-
- $row = $sql->getRow();
-
- $this->setDatabaseRow( $row );
- }
-
-
- /**
- * Setzt die Eigenschaften des Objektes mit einer Datenbank-Ergebniszeile.
- *
- * @param row Ergebniszeile aus ACL-Datenbanktabelle
- */
- function setDatabaseRow( $row )
- {
- $this->aclid = $row['id'];
-
- $this->write = ( $row['is_write' ] == '1' );
- $this->prop = ( $row['is_prop' ] == '1' );
- $this->delete = ( $row['is_delete' ] == '1' );
- $this->release = ( $row['is_release' ] == '1' );
- $this->publish = ( $row['is_publish' ] == '1' );
- $this->create_folder = ( $row['is_create_folder'] == '1' );
- $this->create_file = ( $row['is_create_file' ] == '1' );
- $this->create_page = ( $row['is_create_page' ] == '1' );
- $this->create_link = ( $row['is_create_link' ] == '1' );
- $this->grant = ( $row['is_grant' ] == '1' );
- $this->transmit = ( $row['is_transmit' ] == '1' );
-
- $this->objectid = intval($row['objectid' ]);
- $this->languageid = intval($row['languageid']);
- $this->userid = intval($row['userid' ]);
- $this->groupid = intval($row['groupid' ]);
- }
-
-
- /**
- * Erzeugt eine Liste aller Berechtigungsbits dieser ACL.
- *
- * @return Array (Schluessel=Berechtigungstyp, Wert=boolean)
- */
- function getProperties()
- {
- return Array( 'read' => true,
- 'write' => $this->write,
- 'prop' => $this->prop,
- 'create_folder'=> $this->create_folder,
- 'create_file' => $this->create_file,
- 'create_link' => $this->create_link,
- 'create_page' => $this->create_page,
- 'delete' => $this->delete,
- 'release' => $this->release,
- 'publish' => $this->publish,
- 'grant' => $this->grant,
- 'transmit' => $this->transmit,
- 'is_default' => $this->isDefault,
- 'userid' => $this->userid,
- 'username' => $this->username,
- 'groupid' => $this->groupid,
- 'groupname' => $this->groupname,
- 'languageid' => $this->languageid,
- 'languagename' => $this->languagename,
- 'objectid' => $this->objectid );
-
- }
-
-
- /**
- * Erzeugt eine Liste aller möglichen Berechtigungstypen.
- *
- * @return 0..n-Array
- */
- function getAvailableRights()
- {
- return array( 'read',
- 'write',
- 'prop',
- 'create_folder',
- 'create_file',
- 'create_link',
- 'create_page',
- 'delete',
- 'release',
- 'publish',
- 'grant',
- 'transmit' );
-
- }
-
-
- /**
- * Erzeugt eine Bitmaske mit den Berechtigungen dieser ACL.
- *
- * @return Integer Bitmaske
- */
- function getMask()
- {
- // intval(boolean) erzeugt numerisch 0 oder 1 :)
- $this->mask = ACL_READ; // immer lesen
- $this->mask += ACL_WRITE *intval($this->write );
- $this->mask += ACL_PROP *intval($this->prop );
- $this->mask += ACL_DELETE *intval($this->delete );
- $this->mask += ACL_RELEASE *intval($this->release );
- $this->mask += ACL_PUBLISH *intval($this->publish );
- $this->mask += ACL_CREATE_FOLDER *intval($this->create_folder);
- $this->mask += ACL_CREATE_FILE *intval($this->create_file );
- $this->mask += ACL_CREATE_LINK *intval($this->create_link );
- $this->mask += ACL_CREATE_PAGE *intval($this->create_page );
- $this->mask += ACL_GRANT *intval($this->grant );
- $this->mask += ACL_TRANSMIT *intval($this->transmit );
-
- \Logger::trace('mask of acl '.$this->aclid.': '.$this->mask );
- return $this->mask;
- }
-
-
- /**
- * Erzeugt eine Liste aller gesetzten Berechtigungstypen.
- * Beispiel: Array (0:'read',1:'write',2:'transmit')
- *
- * @return 0..n-Array
- */
- function getTrueProperties()
- {
- $erg = array('read');
- if ( $this->write ) $erg[] = 'write';
- if ( $this->prop ) $erg[] = 'prop';
- if ( $this->create_folder ) $erg[] = 'create_folder';
- if ( $this->create_file ) $erg[] = 'create_file';
- if ( $this->create_link ) $erg[] = 'create_link';
- if ( $this->create_page ) $erg[] = 'create_page';
- if ( $this->delete ) $erg[] = 'delete';
- if ( $this->release ) $erg[] = 'release';
- if ( $this->publish ) $erg[] = 'publish';
- if ( $this->grant ) $erg[] = 'grant';
- if ( $this->transmit ) $erg[] = 'transmit';
-
- return $erg;
- }
-
-
-
- /**
- * ACL unwiderruflich loeschen.
- */
- function delete()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'DELETE FROM {{acl}} '.
- ' WHERE id = {aclid} '.
- ' AND objectid= {objectid}' );
-
- $sql->setInt('aclid' ,$this->aclid );
- $sql->setInt('objectid',$this->objectid);
-
- $sql->query();
-
- $this->aclid = 0;
- }
-
-
- /**
- * ACL der Datenbank hinzufügen.
- */
- function add()
- {
- $db = db_connection();
-
- if ( $this->delete )
- $this->prop = true;
-
- // Pruefen, ob die ACL schon existiert
- $user_comp = intval($this->userid )>0?'={userid}':'IS NULL';
- $group_comp = intval($this->groupid )>0?'={groupid}':'IS NULL';
- $language_comp = intval($this->languageid)>0?'={languageid}':'IS NULL';
-
- $stmt = $db->sql( <<<SQL
- SELECT id FROM {{acl}}
- WHERE userid $user_comp AND
- groupid $group_comp AND
- languageid $language_comp AND
- objectid = {objectid} AND
- is_write = {write} AND
- is_prop = {prop} AND
- is_create_folder = {create_folder} AND
- is_create_file = {create_file} AND
- is_create_link = {create_link} AND
- is_create_page = {create_page} AND
- is_delete = {delete} AND
- is_release = {release} AND
- is_publish = {publish} AND
- is_grant = {grant} AND
- is_transmit = {transmit}
-SQL
-);
-
- if ( intval($this->userid) > 0 )
- $stmt->setInt ('userid',$this->userid);
-
- if ( intval($this->groupid) > 0 )
- $stmt->setInt ('groupid',$this->groupid);
-
- if ( intval($this->languageid) > 0 )
- $stmt->setInt ('languageid',$this->languageid);
-
- $stmt->setInt('objectid',$this->objectid);
- $stmt->setBoolean('write' ,$this->write );
- $stmt->setBoolean('prop' ,$this->prop );
- $stmt->setBoolean('create_folder',$this->create_folder );
- $stmt->setBoolean('create_file' ,$this->create_file );
- $stmt->setBoolean('create_link' ,$this->create_link );
- $stmt->setBoolean('create_page' ,$this->create_page );
- $stmt->setBoolean('delete' ,$this->delete );
- $stmt->setBoolean('release' ,$this->release );
- $stmt->setBoolean('publish' ,$this->publish );
- $stmt->setBoolean('grant' ,$this->grant );
- $stmt->setBoolean('transmit' ,$this->transmit );
-
-
- $aclid = intval($stmt->getOne());
- if ( $aclid > 0 )
- {
- // Eine ACL existiert bereits, wir übernehmen diese ID
- $this->aclid = $aclid;
- return;
- }
-
-
-
-
- $stmt = $db->sql('SELECT MAX(id) FROM {{acl}}');
- $this->aclid = intval($stmt->getOne())+1;
-
- $stmt = $db->sql( <<<SQL
- INSERT INTO {{acl}}
- (id,userid,groupid,objectid,is_write,is_prop,is_create_folder,is_create_file,is_create_link,is_create_page,is_delete,is_release,is_publish,is_grant,is_transmit,languageid)
- VALUES( {aclid},{userid},{groupid},{objectid},{write},{prop},{create_folder},{create_file},{create_link},{create_page},{delete},{release},{publish},{grant},{transmit},{languageid} )
-SQL
-);
-
- $stmt->setInt('aclid' ,$this->aclid );
-
- if ( intval($this->userid) == 0 )
- $stmt->setNull('userid');
- else
- $stmt->setInt ('userid',$this->userid);
-
- if ( intval($this->groupid) == 0 )
- $stmt->setNull('groupid');
- else
- $stmt->setInt ('groupid',$this->groupid);
-
- $stmt->setInt('objectid',$this->objectid);
- $stmt->setBoolean('write' ,$this->write );
- $stmt->setBoolean('prop' ,$this->prop );
- $stmt->setBoolean('create_folder',$this->create_folder );
- $stmt->setBoolean('create_file' ,$this->create_file );
- $stmt->setBoolean('create_link' ,$this->create_link );
- $stmt->setBoolean('create_page' ,$this->create_page );
- $stmt->setBoolean('delete' ,$this->delete );
- $stmt->setBoolean('release' ,$this->release );
- $stmt->setBoolean('publish' ,$this->publish );
- $stmt->setBoolean('grant' ,$this->grant );
- $stmt->setBoolean('transmit' ,$this->transmit );
-
- if ( intval($this->languageid) == 0 )
- $stmt->setNull('languageid');
- else
- $stmt->setInt ('languageid',$this->languageid);
-
- $stmt->query();
- }
-}-
\ No newline at end of file
diff --git a/model/Element.class.php b/model/Element.class.php
@@ -1,502 +0,0 @@
-<?php
-namespace cms\model;
-
-
-
-/**
- * Diese Objektklasse stellt ein Element das.
- *
- * Ein Element ist ein Platzhalter in einem Template und kann verschiedenen
- * Typs sein, z.B. Text oder ein Bild.
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
-class Element
-{
- /**
- * Eindeutige ID dieses Elementes
- * @type Integer
- */
- var $elementid;
-
- /**
- * Template-ID zu der dieses Elementes geh?rt
- * @type Integer
- */
- var $templateid;
-
- /**
- * Typ des Elementes
- * Folgende Typen sind moeglich:
- * <ul>
- * <li>text</li>
- * <li>longtext</li>
- * <li>select</li>
- * <li>number</li>
- * <li>link</li>
- * <li>date</li>
- * <li>insert</li>
- * <li>linkinfo</li>
- * <li>linkdate</li>
- * <li>code</li>
- * <li>info</li>
- * <li>infodate</li>
- * </ul>
- *
- * @type String
- */
- var $type;
-
- /**
- * Logischer Name dieses Elementes
- * @type String
- */
- var $name;
-
- /**
- * Beschreibung zu diesem Element
- * Zu jedem Element kann eine Beschreibung hinterlegt werden, die dem Redakteur bei der Bearbeitung
- * der Inhalte als Bearbeitungshilfe dienen kann.
- * @type String
- */
- var $desc;
-
- /**
- * Objekt-ID eines Ordners, aus diesem Ordner (samt Unterordner)
- * k?nnen zu verlinkende Objekte ausgew?hlt werden
- * @type Integer
- */
- var $folderObjectId = 0;
-
- /**
- * Vorausgew�hltes Objekt.
- * @type Integer
- */
- var $defaultObjectId = 0;
-
- /**
- * Schalter ob dieses Element von Redakteuren bearbeiten werden kann
- * @type Boolean
- */
- var $writable;
-
- /**
- * Schalter, ob dieses Element in allen Sprachen den gleichen Inhalt haben soll
- * @type Boolean
- */
- var $allLanguages;
-
- var $readonlyElementNames = array('copy','linkinfo','linkdate','info','infodate','code','dynamic');
-
- /**
- * Untertyp.
- *
- * @var String
- */
- var $subtype = '';
- var $withIcon = false;
- var $dateformat = 'r';
- var $wiki = false;
- var $html = false;
- var $decimals = 0;
- var $decPoint = '.';
- var $thousandSep = '';
- var $code = '';
- var $defaultText = '';
-
-
- /**
- * Im Konstruktor wird die Element-Id gesetzt
- * @param Integer Element-Id
- */
- function __construct( $elementid=0 )
- {
- if ( intval($elementid)!=0 )
- $this->elementid = $elementid;
- }
-
-
- /**
- * Hinzuf?gen eines Elementes
- * Das aktuelle Element wird in die Datenbank geschrieben.
- */
- function add()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{element}}');
- $this->elementid = intval($sql->getOne())+1;
-
- $sql = $db->sql( 'INSERT INTO {{element}}'.
- ' (id,templateid,name,descr,type,writable) '.
- " VALUES ( {elementid},{templateid},{name},{description},{type},{writable} ) " );
-
- $sql->setInt ( 'elementid' ,$this->elementid );
- $sql->setString ( 'name' ,$this->name );
- $sql->setString ( 'type' ,$this->type );
- $sql->setInt ( 'templateid' ,$this->templateid );
- $sql->setBoolean( 'writable' ,$this->writable );
- $sql->setString ( 'description',$this->desc );
-
- $sql->query();
- }
-
-
- /**
- * Lesen des Elementes aus der Datenbank
- * Alle Eigenschaften des Elementes werden aus der Datenbank gelesen
- * @throws \ObjectNotFoundException
- */
- function load()
- {
- if ( intval($this->elementid) != 0 )
- {
- $db = db_connection();
- $sql = $db->sql( <<<SQL
-SELECT * FROM {{element}}
- WHERE id={elementid}
-SQL
-);
- $sql->setInt( 'elementid',$this->elementid );
- $this->setDatabaseRow( $sql->getRow() );
- }
- }
-
-
- /**
- * @param $prop
- * @throws \ObjectNotFoundException
- */
- function setDatabaseRow($prop )
- {
- if ( count($prop) <= 0 )
- throw new \ObjectNotFoundException("Element not found");
-
- $this->elementid = $prop['id' ];
- $this->templateid = $prop['templateid'];
- $this->name = $prop['name' ];
- $this->desc = $prop['descr' ];
- $this->type = $prop['type' ];
- $this->subtype = $prop['subtype' ];
-
- $this->dateformat = $prop['dateformat'];
- $this->wiki = ( $prop['wiki' ] == '1' );
- $this->withIcon = ( $prop['with_icon' ] == '1' );
- $this->html = ( $prop['html' ] == '1' );
- $this->allLanguages = ( $prop['all_languages'] == '1' );
- $this->writable = ( $prop['writable' ] == '1' );
-
- if ( !$this->writable)
- $this->withIcon = false;
-
- $this->decimals = intval( $prop['decimals' ] );
- $this->decPoint = strval( $prop['dec_point' ] );
- $this->thousandSep = strval( $prop['thousand_sep' ] );
- $this->code = strval( $prop['code' ] );
- $this->defaultText = strval( $prop['default_text' ] );
- $this->folderObjectId = intval( $prop['folderobjectid' ] );
- $this->defaultObjectId = intval( $prop['default_objectid'] );
- }
-
-
- /**
- * Abspeichern des Elementes
- * Das aktuelle Element wird in der Datenbank gespeichert
- */
- function save()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{element}}'.
- ' SET templateid = {templateid},'.
- ' name = {name},'.
- ' descr = {desc},'.
- ' type = {type},'.
- ' subtype = {subtype},'.
- ' with_icon = {withIcon},'.
- ' dateformat = {dateformat},'.
- ' wiki = {wiki},'.
- ' html = {html},'.
- ' all_languages = {allLanguages},'.
- ' writable = {writable},'.
- ' decimals = {decimals},'.
- ' dec_point = {decPoint},'.
- ' thousand_sep = {thousandSep},'.
- ' code = {code},'.
- ' default_text = {defaultText},'.
- ' folderobjectid = {folderObjectId},'.
- ' default_objectid= {defaultObjectId}'.
- ' WHERE id={elementid}' );
-
- $sql->setInt ( 'elementid' ,$this->elementid );
- $sql->setInt ( 'templateid' ,$this->templateid );
- $sql->setString ( 'name' ,$this->name );
- $sql->setString ( 'desc' ,$this->desc );
- $sql->setString ( 'type' ,$this->type );
- $sql->setString ( 'subtype' ,$this->subtype );
- $sql->setBoolean( 'withIcon' ,$this->withIcon );
- $sql->setString ( 'dateformat' ,$this->dateformat );
- $sql->setBoolean( 'wiki' ,$this->wiki );
- $sql->setBoolean( 'html' ,$this->html );
- $sql->setBoolean( 'writable' ,$this->writable );
- $sql->setBoolean( 'allLanguages' ,$this->allLanguages );
- $sql->setInt ( 'decimals' ,$this->decimals );
- $sql->setString ( 'decPoint' ,$this->decPoint );
- $sql->setString ( 'thousandSep' ,$this->thousandSep );
- $sql->setString ( 'code' ,$this->code );
- $sql->setString ( 'defaultText' ,$this->defaultText );
-
- if ( intval($this->folderObjectId)==0 )
- $sql->setNull( 'folderObjectId' );
- else $sql->setInt ( 'folderObjectId' ,$this->folderObjectId );
-
- if ( intval($this->defaultObjectId)==0 )
- $sql->setNull( 'defaultObjectId' );
- else $sql->setInt ( 'defaultObjectId' ,$this->defaultObjectId );
-
- $sql->query();
- }
-
-
-
- /**
- * Setzt den Typ des Elementes und schreibt diesen sofort in die Datenbank.
- *
- * @param String Der neue Typ, siehe getAvailableTypes() f?r m?gliche Typen
- * @see #type
- */
- function setType( $type )
- {
- $this->type = $type;
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{element}}'.
- ' SET type = {type}'.
- ' WHERE id={elementid}' );
-
- $sql->setInt ( 'elementid',$this->elementid );
- $sql->setString ( 'type' ,$this->type );
-
- $sql->query();
- }
-
-
- /**
- * Setzt ein Prefix vor den Elementnamen.
- * @param String Prefix
- */
- function setPrefix( $prefix )
- {
- if ( strrpos($this->name,'%') === FALSE )
- $name = $this->name;
- else
- list( $oldprefix,$name ) = explode('%',$this->name.'%');
-
- $this->name = $prefix.'%'.$name;
- }
-
-
- /**
- * Loeschen des Elementes und aller Inhalte
- */
- function delete()
- {
- $db = db_connection();
-
- // Inhalte l?schen
- $this->deleteValues();
-
- // Element l?schen
- $sql = $db->sql('DELETE FROM {{element}} '.
- ' WHERE id={elementid}' );
- $sql->setInt( 'elementid',$this->elementid );
-
- $sql->query();
- }
-
-
- /**
- * L?schen aller Seiteninhalte mit diesem Element
- * Das Element wird nicht gel?scht.
- */
- function deleteValues()
- {
- $db = db_connection();
-
- // Alle Inhalte mit diesem Element l?schen
- $sql = $db->sql('DELETE FROM {{value}} '.
- ' WHERE elementid={elementid}' );
- $sql->setInt( 'elementid',$this->elementid );
- $sql->query();
- }
-
-
- /**
- * Abhaengig vom Element-Typ werden die zur Darstellung notwendigen Eigenschaften ermittelt.
- * @return array
- */
- function getRelatedProperties()
- {
- $prp = array('text' =>array('withIcon','allLanguages','writable','htmlwiki','defaultText'),
- 'longtext'=>array('withIcon','allLanguages','writable','htmlwiki','defaultText'),
- 'select' =>array('withIcon','allLanguages','writable','defaultText','code'),
- 'number' =>array('withIcon','allLanguages','writable','decPoint','decimals','thousandSep'),
- 'link' =>array('subtype','withIcon','allLanguages','writable','linktype','folderObjectId','defaultObjectId'),
- 'date' =>array('withIcon','allLanguages','writable','dateformat','defaultText'),
- 'list' =>array('subtype','withIcon','allLanguages','writable','folderObjectId','defaultObjectId'),
- 'insert' =>array('subtype','withIcon','allLanguages','writable','folderObjectId','defaultObjectId'),
- 'copy' =>array('prefix','name','defaultText'),
- 'linkinfo'=>array('prefix','subtype','defaultText'),
- 'linkdate'=>array('prefix','subtype','dateformat'),
- 'code' =>array('code'),
- 'dynamic' =>array('subtype','code'),
- 'info' =>array('subtype'),
- 'infodate'=>array('subtype','dateformat') );
- return $prp[ $this->type ];
- }
-
-
-
- function getDefaultValue()
- {
- switch( $this->type )
- {
- case 'text':
- case 'longtext':
- return $this->defaultText;
-
- case 'number';
- return '0';
-
- default:
- }
-
- return lang('EL_TYPE_'.$this->type);
-
- }
-
- /**
- * Ermitteln aller benutzbaren Elementtypen
- * @return array
- */
- function getAvailableTypes()
- {
- return array('text',
- 'longtext',
- 'select',
- 'number',
- 'link',
- 'date',
- 'insert',
- 'copy',
- 'linkinfo',
- 'linkdate',
- 'code',
- 'dynamic',
- 'info',
- 'infodate');
- }
-
-
- /**
- * Ermittelt die Klasse des Element-Typs.<br>
- * Entweder "info", "text" oder "dynamic".
- *
- * @return String
- */
- function getTypeClass()
- {
- switch( $this->type )
- {
- case 'text':
- case 'longtext':
- case 'select':
- case 'number':
- case 'link':
- case 'date':
- case 'list':
- case 'insert':
- return 'text';
-
- case 'code':
- case 'dynamic':
- return 'dynamic';
-
- case 'copy':
- case 'info':
- case 'infodate':
- case 'linkinfo':
- case 'linkdate':
- default:
- return 'info';
- }
- }
-
-
- function getSelectItems()
- {
- $parameters = explode( "\n",$this->code );
- $items = array();
-
- foreach( $parameters as $it )
- {
- $paar = explode( ":",$it,2 );
- $param_name = trim($paar[0]);
-
- if ( count($paar) > 1 )
- $param_value = trim($paar[1]);
- else
- $param_value = trim($paar[0]);
-
- // Wenn Inhalt mit "'" beginnt und mit "'" aufhoert, dann diese Zeichen abschneiden
- if ( substr($param_value,0,1) == "'" && substr($param_value,strlen($param_value)-1,1) == "'" )
- $param_value = substr($param_value,1,strlen($param_value)-2);
-
- $items[$param_name] = $param_value;
- }
- return $items;
- }
-
-
- function getDynamicParameters()
- {
- $parameters = explode( "\n",$this->code );
- $items = array();
-
- foreach( $parameters as $it )
- {
- $paar = explode( ":",$it,2 );
- if ( count($paar) > 1 )
- {
- $param_name = trim($paar[0]);
- $param_value = trim($paar[1]);
-
-// // Wenn Inhalt mit "'" beginnt und mit "'" aufhoert, dann diese Zeichen abschneiden
-// if ( substr($param_value,0,1) == "'" && substr($param_value,strlen($param_value)-1,1) == "'" )
-// $param_value = substr($param_value,1,strlen($param_value)-2);
-
- if ( !empty($param_value) )
- $items[$param_name] = $param_value;
- }
- }
- return $items;
- }
-
-
- /**
- * Ermittelt, ob das Element beschreibbar ist.
- * Bestimmte Typen (z.B. Info-Felder) sind nie beschreibbar, dann wird immer false zur?ckgegeben.
- * Ansonsten wird ermittelt, ob dieses Element als beschreibbar markiert ist.
- */
- function isWritable()
- {
- // Bei bestimmten Feldern immer false zurueckgeben
- if ( in_array($this->type,$this->readonlyElementNames) )
- return false;
-
- return $this->writable;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/File.class.php b/model/File.class.php
@@ -1,709 +0,0 @@
-<?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.
-
-
-// Standard Mime-Type
-define('OR_FILE_DEFAULT_MIMETYPE','application/octet-stream');
-
-
-/**
- * Datei.
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
-class File extends Object
-{
- var $fileid;
-
- var $size = 0;
- var $value = '';
- var $extension = '';
- var $log_filenames = array();
- var $fullFilename = '';
- var $publish = null;
- var $mime_type = '';
-
- /**
- * Breite eines Bildes. Ist nur verfuegbar, wenn vorher
- * #getImageSize() aufgerufen wurde.
- */
- var $width = null;
-
- /**
- * Hoehe eines Bildes. Ist nur verfuegbar, wenn vorher
- * #getImageSize() aufgerufen wurde.
- */
- var $height = null;
-
- var $tmpfile;
-
- var $content_negotiation = false;
-
-
-
- /**
- * Um Probleme mit BLOB-Feldern und Datenbank-Besonderheiten zu vermeiden,
- * kann der Binaerinhalt BASE64-kodiert gespeichert werden.
- * @type Boolean
- */
- var $storeValueAsBase64 = false;
-
-
-
- /**
- * Konstruktor
- *
- * @param Objekt-Id
- */
- function __construct( $objectid='' )
- {
- global $conf;
-
- $db = \Session::getDatabase();
- $this->storeValueAsBase64 = $db->conf['base64'];
-
- parent::__construct( $objectid );
- $this->isFile = true;
- }
-
-
-
- /**
- * Ermitteln des Dateinamens dieser Datei
- *
- * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
- */
- function full_filename()
- {
- if ( !empty($this->fullFilename) )
- return $this->fullFilename;
-
- $filename = parent::full_filename();
-
- if ( $this->content_negotiation && config('publish','negotiation','file_negotiate_type' ) )
- {
- // Link auf Datei: Extension bleibt aufgrund Content-Negotiation leer
- }
- else
- {
- if ( !empty($this->extension) )
- $filename .= '.'.$this->extension;
- }
-
- $this->fullFilename = $filename;
- return $filename;
- }
-
-
-
- /**
- * Ermitteln des Dateinamens dieser Datei (ohne Pfadangabe)
- *
- * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
- */
- function filenameWithExtension()
- {
- if ( $this->extension != '' )
- return $this->filename.'.'.$this->extension;
- else return $this->filename;
- }
-
-
-
- /**
- * Ermitteln aller Eigenschaften
- *
- * @return Array
- */
- function getProperties()
- {
- return array_merge( parent::getProperties(),
- array('full_filename'=>$this->fullFilename,
- 'extension' =>$this->extension,
- 'size' =>$this->size,
- 'mimetype' =>$this->mimetype() ) );
- }
-
-
-
- /**
- * @deprecated
- */
- function getFileObjectIdsByExtension( $extension )
- {
- global $SESS;
- $db = db_connection();
-
- $sqlquery = 'SELECT * FROM {{object}} ';
-
- if ( $extension != '' )
- {
- $sqlquery .= " WHERE extension='";
-
- $ext = explode(',',$extension);
- $sqlquery .= implode( "' OR extension='",$ext );
- $sqlquery .= "' AND typeid=".OR_TYPEID_FILE." AND projectid={projectid}";
- }
- else
- {
- $sqlquery .= " WHERE typeid=".OR_TYPEID_FILE." AND projectid={projectid}";
- }
-
- $sql = $db->sql( $sqlquery );
- $sql->setInt( 'projectid',$SESS['projectid'] );
-
- return $sql->getCol();
- }
-
-
-
- /**
- * Es werden Objekte zu einer Dateierweiterung ermittelt
- *
- * @param String Dateierweiterung ohne fuehrenden Punkt (z.B. 'jpeg')
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByExtension( $extension )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{file}}.objectid FROM {{file}} '.
- ' LEFT JOIN {{object}} '.
- ' ON {{object}}.id={{file}}.objectid'.
- ' WHERE {{file}}.extension={extension}'.
- ' AND {{object}}.projectid={projectid}' );
- $sql->setInt ( 'projectid',$this->projectid );
- $sql->setString( 'extension',$extension );
-
- return $sql->getCol();
- }
-
-
-
- /**
- * Ermittelt den Mime-Type zu dieser Datei
- *
- * @return String Mime-Type
- */
- function mimeType()
- {
- if ( !empty( $this->mime_type ) )
- return $this->mime_type;
-
- global $conf;
- $mime_types = $conf['mime-types'];
-
-
-
- $ext = strtolower( $this->getRealExtension() );
-
- if ( !empty($mime_types[$ext]) )
- $this->mime_type = $mime_types[$ext];
- else
- // Wenn kein Mime-Type gefunden, dann Standartwert setzen
- $this->mime_type = OR_FILE_DEFAULT_MIMETYPE;
-
- return( $this->mime_type );
- }
-
-
-
- /**
- * Ermittelt Breite und H�he des Bildes.<br>
- * Die Werte lassen sich anschlie�end �ber die Eigenschaften "width" und "height" ermitteln.
- */
- function getImageSize()
- {
- if ( is_null($this->width) )
- {
- $this->write(); // Datei schreiben
-
- // Bildinformationen ermitteln
- $size = getimagesize( $this->tmpfile() );
-
- // Breite und Hoehe des aktuellen Bildes
- $this->width = $size[0];
- $this->height = $size[1];
- }
- }
-
-
-
- /**
- * Veraendert die Bildgroesse eines Bildes
- *
- * Diese Methode sollte natuerlich nur bei Bildern ausgefuehrt werden.
- *
- * @param Neue Breite
- * @param Neue Hoehe
- * @param Bildgr��enfaktor
- * @param Altes Format als Integer-Konstante IMG_xxx
- * @param Neues Format als Integer-Konstante IMG_xxx
- * @param Jpeg-Qualitaet (sofern neues Format = Jpeg)
- */
- function imageResize( $newWidth,$newHeight,$factor,$oldformat,$newformat,$jpegquality )
- {
- global $conf;
-
- $this->write(); // Datei schreiben
-
- // Bildinformationen ermitteln
- $size = getimagesize( $this->tmpfile() );
-
- // Breite und Hoehe des aktuellen Bildes
- $oldWidth = $size[0];
- $oldHeight = $size[1];
- $aspectRatio = $oldHeight / $oldWidth; // Seitenverhaeltnis
-
- // Wenn Breite und Hoehe fehlen, dann Bildgroesse beibehalten
- if ( $newWidth == 0 && $newHeight == 0)
- {
- if ( $factor != 0 && $factor != 1 )
- {
- $newWidth = $oldWidth * $factor;
- $newHeight = $oldHeight * $factor;
- $resizing = true;
- }
- else
- {
- $newWidth = $oldWidth;
- $newHeight = $oldHeight;
- $resizing = false;
- }
- }
- else
- {
- $resizing = true;
- }
-
- // Wenn nur Breite oder Hoehe angegeben ist, dann
- // das Seitenverhaeltnis beibehalten
- if ( $newWidth == 0 )
- $newWidth = $newHeight / $aspectRatio;
-
- if ( $newHeight == 0 )
- $newHeight = $newWidth * $aspectRatio;
-
-
- switch( $oldformat )
- {
- case IMG_GIF: // GIF
-
- $oldImage = ImageCreateFromGIF( $this->tmpfile );
- break;
-
- case IMG_JPG: // JPEG
-
- $oldImage = ImageCreateFromJPEG($this->tmpfile);
- break;
-
- case IMG_PNG: // PNG
-
- $oldImage = imagecreatefrompng($this->tmpfile);
- break;
-
- default:
- die('unsupported image format "'.$this->extension.'", cannot load image. resize failed');
- }
-
- // Ab Version 2 der GD-Bibliothek sind TrueColor-Umwandlungen moeglich.
- global $conf;
- $hasTrueColor = $conf['image']['truecolor'];
-
- switch( $newformat )
- {
- case IMG_GIF: // GIF
-
- if ( $resizing )
- {
- $newImage = ImageCreate($newWidth,$newHeight);
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
- else
- {
- $newImage = &$oldImage;
- }
-
- ImageGIF($newImage, $this->tmpfile() );
- $this->extension = 'gif';
-
- break;
-
- case IMG_JPG: // JPEG
-
- if ( !$resizing )
- {
- $newImage = &$oldImage;
- }
- elseif ( $hasTrueColor )
- {
- // Verwende TrueColor (GD2)
- $newImage = imageCreateTrueColor( $newWidth,$newHeight );
- ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
- else
- {
- // GD Version 1.x unterstuetzt kein TrueColor
- $newImage = ImageCreate($newWidth,$newHeight);
-
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
-
- ImageJPEG($newImage, $this->tmpfile,$jpegquality );
- $this->extension = 'jpeg';
-
- break;
-
- case IMG_PNG: // PNG
-
- if ( !$resizing )
- {
- $newImage = &$oldImage;
- }
- elseif ( $hasTrueColor )
- {
- // Verwende TrueColor (GD2)
- $newImage = imageCreateTrueColor( $newWidth,$newHeight );
-
- ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
- else
- {
- // GD Version 1.x unterstuetzt kein TrueColor
- $newImage = ImageCreate($newWidth,$newHeight);
-
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
-
- imagepng( $newImage,$this->tmpfile() );
- $this->extension = 'png';
-
- break;
-
- default:
- die('unsupported image format "'.$newformat.'", cannot resize');
- }
-
- $f = fopen( $this->tmpfile(), "r" );
- $this->value = fread( $f,filesize($this->tmpfile()) );
- fclose( $f );
-
- imagedestroy( $oldImage );
- //imagedestroy( $newImage );
- }
-
-
- /**
- * Lesen der Datei aus der Datenbank.
- *
- * Es werden nur die Meta-Daten (Erweiterung, Gr��e) gelesen. Zum Lesen des
- * Datei-Inhaltes muss #loadValue() aufgerufen werden.
- */
- function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,extension,size'.
- ' FROM {{file}}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $sql->getRow();
-
- if ( count($row)!=0 )
- {
- $this->fileid = $row['id' ];
- $this->extension = $row['extension'];
- $this->size = $row['size' ];
- }
-
- $this->objectLoad();
- }
-
-
-
- /**
- * Unwiderrufliches L�schen der Datei aus der Datenbank.
- */
- function delete()
- {
- $db = db_connection();
-
- // Datei l?schen
- $sql = $db->sql( 'DELETE FROM {{file}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $sql->query();
-
- $this->objectDelete();
- }
-
-
-
- /**
- * Stellt anhand der Dateiendung fest, ob es sich bei dieser Datei um ein Bild handelt
- */
- function isImage()
- {
- return substr($this->mimeType(),0,6)=='image/';
- }
-
-
-
- /**
- * Ermittelt die Datei-Endung.
- *
- * @return String Datei-Endung
- */
- function extension()
- {
- if ($this->extension != '')
- return $this->extension;
-
- $this->load();
- return $this->extension;
- }
-
-
- /**
- * Einen Dateinamen in Dateiname und Extension aufteilen.
- * @param filename Dateiname
- */
- function parse_filename($filename)
- {
- $filename = basename($filename);
-
- $p = strrpos($filename, '.');
- if ($p !== false)
- {
- $this->extension = substr($filename, $p +1);
- $this->filename = substr($filename, 0, $p);
- }
- else
- {
- $this->extension = '';
- $this->filename = $filename;
- }
- }
-
-
- /**
- * Speichert die Datei-Informationen in der Datenbank.
- */
- function save()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( <<<EOF
-UPDATE {{file}} SET
- size = {size},
- extension = {extension}
- WHERE objectid={objectid}
-EOF
-);
- $sql->setString('size' ,$this->size );
- $sql->setString('extension',$this->extension );
- $sql->setString('objectid' ,$this->objectid );
- $sql->query();
-
- $this->objectSave();
- }
-
-
- /**
- * Kopieren des Inhaltes von einer anderen Datei
- * @param ID der Datei, von der der Inhalt kopiert werden soll
- */
- function copyValueFromFile( $otherfileid )
- {
- $of = new File( $otherfileid );
- $this->value = $of->loadValue();
- $this->saveValue();
- }
-
-
- /**
- * Lesen des Inhaltes der Datei aus der Datenbank.
- *
- * @return String Inhalt der Datei
- */
- function loadValue()
- {
- if ( is_file($this->tmpfile()))
- return implode('',file($this->tmpfile())); // From cache
-
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT size,value'.
- ' FROM {{file}}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $sql->getRow();
-
- if ( count($row) != 0 )
- {
- $this->value = $row['value'];
- $this->size = $row['size' ];
- }
-
- if ( $this->storeValueAsBase64 )
- $this->value = base64_decode( $this->value );
-
- // Store in cache.
- $f = fopen( $this->tmpfile(),'w' );
- fwrite( $f,$this->value );
- fclose( $f );
-
- return $this->value;
- }
-
-
- /**
- * Speichert den Inhalt in der Datenbank.
- */
- function saveValue( $value = '' )
- {
- if ( is_file($this->tmpfile()) )
- @unlink( $this->tmpfile() );
-
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{file}}'.
- ' SET value={value}, '.
- ' size={size} '.
- ' WHERE objectid={objectid}' );
- $sql->setString( 'objectid' ,$this->objectid );
- $sql->setInt ( 'size' ,strlen($this->value) );
-
- if ( $this->storeValueAsBase64 )
- $sql->setString( 'value',base64_encode($this->value) );
- else
- $sql->setString( 'value',$this->value );
-
- $sql->query();
- }
-
-
- /**
- * Lesen der Datei aus der Datenbank und schreiben in temporaere Datei
- */
- function write()
- {
- if ( !is_file($this->tmpfile()) )
- $this->loadValue();
- }
-
-
- /**
- * F�gt die Datei der Datenbank hinzu.
- */
- function add()
- {
- $db = db_connection();
-
- $this->objectAdd();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{file}}');
- $this->fileid = intval($sql->getOne())+1;
-
- $sql = $db->sql('INSERT INTO {{file}}'.
- ' (id,objectid,extension,size,value)'.
- " VALUES( {fileid},{objectid},{extension},0,'' )" );
- $sql->setInt ('fileid' ,$this->fileid );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setString('extension',$this->extension );
-
- $sql->query();
-
- $this->saveValue();
- }
-
-
- function publish()
- {
- if ( ! is_object($this->publish) )
- $this->publish = new \Publish();
-
- $this->write();
- $this->publish->copy( $this->tmpfile(),$this->full_filename(),$this->lastchangeDate );
-
- $this->publish->publishedObjects[] = $this->getProperties();
- }
-
-
- /**
- * Ermittelt einen tempor�ren Dateinamen f�r diese Datei.
- */
- function tmpfile()
- {
- if ( $this->tmpfile == '' )
- {
- $db = db_connection();
- $this->tmpfile = $this->getTempFileName( array('db'=>$db->id,'o'.$this->objectid) );
- }
- return $this->tmpfile;
- }
-
-
- /**
- * Setzt den Zeitstempel der Datei auf die aktuelle Zeit.
- *
- * @see objectClasses/Object#setTimestamp()
- */
-
- function setTimestamp()
- {
- @unlink( $this->tmpfile() );
-
- parent::setTimestamp();
- }
-
-
-
- /**
- * Ermittelt die wirksame Datei-Endung. Diese kann sich
- * in der Extra-Dateiendung, aber auch direkt im Dateiname
- * befinden.
- *
- * @return Dateiendung
- */
- function getRealExtension()
- {
- if ( !empty($this->extension))
- {
- return $this->extension;
- }
- else
- {
- $pos = strrpos($this->filename,'.');
- if ( $pos === false )
- return '';
- else
- return substr($this->filename,$pos+1);
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Folder.class.php b/model/Folder.class.php
@@ -1,908 +0,0 @@
-<?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.
-
-
-/**
- * Darstellen eines Ordners
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Folder extends Object
-{
- var $folderid;
- var $projectid;
- var $parentfolders = array();
- var $subfolders = array();
- var $filenames = true;
- var $name = '';
- var $filename = '';
- var $desc = '';
- /**
- * @var \Publish
- */
- public $publish = null;
-
-
- function __construct( $objectid='' )
- {
- parent::__construct( $objectid );
- $this->isFolder = true;
- }
-
-
- function add()
- {
- $this->objectAdd();
-
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{folder}}');
- $this->folderid = intval($sql->getOne())+1;
-
- $sql = $db->sql('INSERT INTO {{folder}}'.
- ' (id,objectid)'.
- ' VALUES( {folderid},{objectid} )' );
- $sql->setInt ('folderid' ,$this->folderid );
- $sql->setInt ('objectid' ,$this->objectid );
-
- $sql->query();
- }
-
-
-
- function getRootFolderId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid IS NULL'.
- ' AND typeid=1'.
- ' AND projectid={projectid}' );
-
- // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden
- if ( isset($this) && isset($this->projectid) )
- {
- $sql->setInt('projectid',$this->projectid );
- }
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid );
- }
-
- // Datenbankabfrage ausfuehren
- return $sql->getOne();
- }
-
-
- function hasFilename( $filename )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT COUNT(*) FROM {{object}}'.' WHERE parentid={objectid} AND filename={filename}');
-
- if ( intval($this->objectid)== 0 )
- $sql->setNull('objectid');
- else
- $sql->setString('objectid', $this->objectid);
-
- $sql->setString('filename', $filename );
-
- return( $sql->getOne() > 0 );
- }
-
-
- public function load()
- {
-// $db = db_connection();
-//
-// $sql = $db->sql('SELECT * FROM {{folder}} WHERE objectid={objectid}');
-// $sql->setInt('objectid',$this->objectid);
-//
-// $row = $sql->getRow( $sql );
-//
- $this->objectLoad();
-
-// $this->folderid = $row['id' ];
- }
-
-
-
- function save()
- {
- $this->objectSave();
- }
-
-
-
- function setOrderId( $orderid )
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{folder}} '.
- ' SET orderid={orderid}'.
- ' WHERE id={folderid}');
- $sql->setInt('folderid',$this->folderid);
- $sql->setInt('orderid' ,$orderid );
-
- $sql->query();
- }
-
-
-
-// function getSubFolders()
-// {
-// global $SESS;
-// $db = db_connection();
-//
-// $sql = $db->sql('SELECT id FROM {{folder}}'.
-// ' WHERE parentid={folderid}'.
-// ' AND projectid={projectid}'.
-// ' ORDER BY orderid ASC' );
-// $sql->setInt('folderid' ,$SESS['folderid' ]);
-// $sql->setInt('projectid',$SESS['projectid']);
-//
-// return( $sql->getCol( $sql ));
-// }
-
-
- // Liest alle Objekte in diesem Ordner
- function getObjectIds()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid={objectid}'.
- ' ORDER BY orderid ASC' );
- $sql->setInt('objectid' ,$this->objectid );
-
- return( $sql->getCol() );
- }
-
-
-
- /**
- * Liest alle Objekte in diesem Ordner
- * @return array[Object] Objekte
- */
- function getObjects()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT {{object}}.*,{{name}}.name,{{name}}.descr'.
- ' FROM {{object}}'.
- ' LEFT JOIN {{name}} '.
- ' ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
- ' WHERE parentid={objectid}'.
- ' ORDER BY orderid ASC' );
- $sql->setInt('languageid',$this->languageid );
- $sql->setInt('objectid' ,$this->objectid );
-
- $liste = array();
- $res = $sql->getAll();
- foreach( $res as $row )
- {
- $o = new Object( $row['id'] );
- $o->setDatabaseRow( $row );
- $liste[] = $o;
- }
-
- return $liste;
- }
-
-
- // Liest alle Objekte in diesem Ordner
- function getObjectIdsByType()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid={objectid}'.
- ' ORDER BY typeid,orderid ASC' );
- $sql->setInt('projectid',$this->projectid );
- $sql->setInt('objectid' ,$this->objectid );
-
- return( $sql->getCol() );
- }
-
-
- // Liest alle Objekte in diesem Ordner sortiert nach dem Namen (nicht Dateinamen!)
- function getChildObjectIdsByName()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT {{object}}.id FROM {{object}}'.
- ' LEFT JOIN {{name}} ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
- ' WHERE parentid={objectid}'.
- ' ORDER BY {{name}}.name,{{object}}.filename ASC');
- $sql->setInt('objectid' , $this->objectid );
- $sql->setInt('languageid', $this->languageid);
- return( $sql->getCol() );
- }
-
-
- // Liest alle Objekte in diesem Ordner
- function getObjectIdsByLastChange()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid={objectid}'.
- ' ORDER BY lastchange_date,orderid ASC' );
- $sql->setInt('projectid',$this->projectid );
- $sql->setInt('objectid' ,$this->objectid );
-
- return( $sql->getCol() );
- }
-
-
- function publish( $withPages,$withFiles,$subdirs = false )
- {
- set_time_limit(300);
- if ( ! is_object($this->publish) )
- $this->publish = new \Publish();
-
- foreach( $this->getObjectIds() as $oid )
- {
- $o = new Object( $oid );
- $o->objectLoadRaw();
-
- if ( $o->isPage && $withPages )
- {
- $p = new Page( $oid );
- $p->load();
- $p->publish = &$this->publish;
- $p->publish();
- }
-
- if ( $o->isFile && $withFiles )
- {
- $f = new File( $oid );
- $f->load();
- $f->publish = &$this->publish;
- $f->publish();
- }
-
- if ( $o->isFolder && $subdirs )
- {
- $f = new Folder( $oid );
- $f->load();
- $f->publish = &$this->publish;
- $f->publish( $withPages,$withFiles,true );
- }
- }
- }
-
-
- function getObjectIdByFileName( $filename )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid={objectid}'.
- ' AND filename={filename}' );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setString('filename' ,$filename );
-
- return( intval($sql->getOne()) );
- }
-
-
-
- /**
- * Ermittelt alle Objekte vom gew�nschten Typ, die sic in
- * diesem Projekt befinden.
- *
- * @see objectClasses/Object#getAllObjectIds()
- * @param types Array
- * @return Liste von Object-Ids
- */
- function getAllObjectIds( $types=array('folder','page','link','file') )
- {
-// Html::debug($types,'Typen');
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE projectid={projectid}'.
- ' AND ( typeid ={is_folder}' .
- ' OR typeid ={is_file}' .
- ' OR typeid ={is_page}' .
- ' OR typeid ={is_link} )' .
- ' ORDER BY orderid ASC' );
-
- if (isset($this) && isset($this->projectid))
- {
- $projectid = $this->projectid;
- }
- else
- {
- $project = \Session::getProject();
- $projectid = $project->projectid;
- }
-
- $sql->setInt('projectid',$projectid);
- $sql->setInt('is_folder',in_array('folder',$types)?OR_TYPEID_FOLDER:0);
- $sql->setInt('is_file' ,in_array('file' ,$types)?OR_TYPEID_FILE:0);
- $sql->setInt('is_page' ,in_array('page' ,$types)?OR_TYPEID_PAGE:0);
- $sql->setInt('is_link' ,in_array('link' ,$types)?OR_TYPEID_LINK:0);
-
- return( $sql->getCol() );
- }
-
-
- public function getRootObjectId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid IS NULL'.
- ' AND projectid={projectid}' );
-
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return( $sql->getOne() );
- }
-
-
- public function getOtherFolders()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE typeid='.OR_TYPEID_FOLDER.
- ' and id != {objectid} '.
- ' AND projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return( $sql->getCol() );
- }
-
-
- function getAllFolders()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE typeid='.OR_TYPEID_FOLDER.
- ' AND projectid={projectid}' );
-
- if ( !isset($this) || !isset($this->projectid) )
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
- else $sql->setInt( 'projectid',$this->projectid );
-
- return( $sql->getCol() );
- }
-
-
- function getPages()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_PAGE.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $sql->getCol();
- }
-
-
- /**
- * Ermittelt die erste Seite oder Verkn�pfung in diesem Ordner.
- *
- * @return Object Objekt
- */
- public function getFirstPage()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid}'.
- ' AND (typeid='.OR_TYPEID_PAGE.')'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- $oid = intval($sql->getOne());
-
- if ( $oid != 0 )
- $o = new Object($oid);
- else
- $o = null;
-
- return $o;
- }
-
-
- /**
- * Ermittelt die erste Seite oder Verkn�pfung in diesem Ordner.
- *
- * @return Object Objekt
- */
- function getFirstPageOrLink()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid}'.
- ' AND (typeid='.OR_TYPEID_PAGE.' OR typeid='.OR_TYPEID_LINK.')'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- $oid = intval($sql->getOne());
-
- if ( $oid != 0 )
- $o = new Object($oid);
- else
- $o = null;
-
- return $o;
- }
-
-
- function getLastPageOrLink()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid}'.
- ' AND (typeid='.OR_TYPEID_PAGE.' OR typeid='.OR_TYPEID_LINK.')'.
- ' ORDER BY orderid DESC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- $oid = intval($sql->getOne());
-
- if ( $oid != 0 )
- $o = new Object($oid);
- else
- $o = null;
-
- return $o;
- }
-
-
- function getFiles()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FILE.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $sql->getCol();
- }
-
-
-
- /**
- * Liefert eine Liste von allen Dateien in diesem Ordner.
- *
- * @return Array Schl�ssel=Objekt-Id, Wert=Dateiname
- */
- function getFileFilenames()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id,filename FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FILE.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $sql->getAssoc();
- }
-
-
- function getLinks()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_LINK.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $sql->getCol();
- }
-
-
- // Rechte f?r diesen Ordner hinzuf?gen
- function addrights( $rights,$inherit = true )
- {
- global $SESS;
-
- $SESS['rights'][$rights['projectid']][$this->folderid]['show'] = true;
-
- if ($rights['read'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['read'] = 1;
- if ($rights['write'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['write'] = 1;
- if ($rights['create'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['create'] = 1;
- if ($rights['delete'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['delete'] = 1;
- if ($rights['publish'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['publish'] = 1;
-
- // Rechte auf Unterordner vererben
- // sowie f?r ?bergeordnete Ordner die Anzeige erzwingen
- if ( $inherit )
- {
- // ?bergeordnete Ordner ermitteln
- $parentfolder = $this->parentObjectFileNames();
-
- // ?bergeordnete Ordner immer anzeigen (Schalter 'show'=true)
- foreach( $parentfolder as $folderid=>$name )
- {
- $f = new Folder( $folderid );
- $f->projectid = $this->projectid;
- $f->addrights( array('projectid'=>$rights['projectid']),false );
- unset($f);
- }
-
- $f = new Folder( 'null' );
- $f->projectid = $this->projectid;
- $f->addrights( array('projectid'=>$rights['projectid']),false );
- unset($f);
-
-
- // Unterordner ermitteln
- //echo "Kurz vor subfolderberechnung, folderid ist ".$this->folderid.'<br>';
- $subfolder = $this->subfolder();
-
- // Rechte weitergeben
- foreach( $subfolder as $folderid=>$name )
- {
- $f = new Folder( $folderid );
- $f->projectid = $this->projectid;
- $f->addrights( $rights,false );
- unset($f);
- }
- }
- }
-
-
- function addParentFolder( $id,$name,$filename='' )
- {
- if ( empty($name) )
- $name = $filename;
-
- if ( empty($name) )
- $name = "($id)";
-
- if ( intval($id) != 0 )
- $this->parentfolders[ $id ] = $name;
- }
-
-
- function checkParentFolders( $with_root, $with_self )
- {
- // Reihenfolge umdrehen
- $this->parentfolders = array_reverse($this->parentfolders,true);
-
- // Ordner ist bereits hoechster Ordner
-// if ( count($this->parentfolders) == 2 && $this->isRoot && $with_root && $with_self )
-// {
-// array_pop ( $this->parentfolders );
-// return;
-// }
-
-
- if ( !$with_root && !empty($this->parentfolders) )
- {
- $keys = array_keys( $this->parentfolders );
- unset( $this->parentfolders[$keys[0]] );
- }
-
- if ( !$with_self && !empty($this->parentfolders) )
- {
- $keys = array_keys( $this->parentfolders );
- unset( $this->parentfolders[$keys[count($keys)-1]] );
- }
- }
-
-
- function parentObjectFileNames( $with_root = false, $with_self = false )
- {
- $db = \Session::getDatabase();
-
- $foid = $this->id;
- $idCache = array();
-
- while( intval($foid)!=0 )
- {
- $sql = $db->sql( <<<SQL
-
-SELECT parentid,id,filename
- FROM {{object}}
- WHERE {{object}}.id={parentid}
-
-SQL
- );
- $sql->setInt('parentid' ,$foid );
-
- $row = $sql->getRow();
-
- if ( in_array($row['id'],$idCache))
- \Http::serverError('fatal: parent-rekursion in object-id: '.$this->objectid.', double-parent-id: '.$row['id']);
- else
- $idCache[] = $row['id'];
-
- $this->addParentfolder( $row['id'],$row['filename'] );
- $foid = $row['parentid'];
- }
-
-
- $this->checkParentFolders($with_root,$with_self);
-
- return $this->parentfolders;
- }
-
- function parentObjectNames( $with_root = false, $with_self = false )
- {
- $db = \Session::getDatabase();
-
- $foid = $this->id;
- $idCache = array();
-
- while( intval($foid)!=0 )
- {
- $sql = $db->sql( <<<SQL
-
-SELECT {{object}}.parentid,{{object}}.id,{{object}}.filename,{{name}}.name FROM {{object}}
- LEFT JOIN {{name}}
- ON {{object}}.id = {{name}}.objectid
- AND {{name}}.languageid = {languageid}
- WHERE {{object}}.id={parentid}
-
-SQL
- );
- $sql->setInt('languageid',$this->languageid);
- $sql->setInt('parentid' ,$foid );
-
- $row = $sql->getRow();
-
- if ( in_array($row['id'],$idCache))
- \Http::serverError('fatal: parent-rekursion in object-id: '.$this->objectid.', double-parent-id: '.$row['id']);
- else
- $idCache[] = $row['id'];
-
- $this->addParentfolder( $row['id'],$row['name'],$row['filename'] );
- $foid = $row['parentid'];
- }
-
- $this->checkParentFolders($with_root,$with_self);
-
- return $this->parentfolders;
- }
-
-
- // Ermitteln aller Unterordner
- //
- function subfolder()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FOLDER.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- $this->subfolders = $sql->getCol();
-
- return $this->subfolders;
- }
-
-
-
- function getSubfolderFilenames()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id,filename FROM {{object}} '.
- ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FOLDER.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $sql->getAssoc();
- }
-
-
-
- /**
- * Ermitteln aller Unterordner (rekursives Absteigen).
- *
- */
- function getAllSubFolderIds()
- {
- global $SESS;
-
- $ids = array();
-
- foreach( $this->getSubFolderIds() as $id )
- {
- $ids[] = $id;
-
- $f = new Folder( $id );
- if ( !empty($this->projectid) )
- $f->projectid = $this->projectid;
-
- // Rekursiver Aufruf für alle Unterordner
- foreach( $f->getAllSubFolderIds() as $xid )
- {
- $ids[] = $xid;
- }
- }
-
- return $ids;
- }
-
-
- /**
- * Loeschen dieses Ordners.
- * Der Ordner wird nur geloescht, wenn er keine Unterelemente mehr enth?lt.
- * Zum Loeschen inklusive Unterelemente dient die Methode deleteAll()
- */
- function delete()
- {
- $db = db_connection();
-
- // Nur loeschen, wenn es keine Unterelemente gibt
- if ( count( $this->getObjectIds() ) == 0 )
- {
- $sql = $db->sql( 'UPDATE {{element}} '.
- ' SET folderobjectid=NULL '.
- ' WHERE folderobjectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
- $sql = $db->sql( 'DELETE FROM {{folder}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
- $this->objectDelete();
- }
- }
-
-
- /**
- * Rekursives loeschen aller Inhalte
- *
- * Loeschen aller Inhalte dieses Ordners
- * inclusive aller Unterelemente
- */
- function deleteAll()
- {
- $db = db_connection();
-
- // L?schen aller Unterordner
- foreach( $this->subfolder() as $folderid )
- {
- $folder = new Folder( $folderid );
- {
- $folder->deleteAll();
- }
- }
-
- // L?schen aller Seiten,Verknuepfungen und Dateien in
- // diesem Ordner
- foreach( $this->getObjectIds() as $oid )
- {
- $object = new Object( $oid );
- {
- $object->load();
-
- if ( $object->isPage )
- {
- $page = new Page( $oid );
- $page->load();
- $page->delete();
- }
-
- if ( $object->isLink )
- {
- $link = new Link( $oid );
- $link->load();
- $link->delete();
- }
-
- if ( $object->isUrl )
- {
- $url = new Url( $oid );
- $url->load();
- $url->delete();
- }
-
- if ( $object->isFile )
- {
- $file = new File( $oid );
- $file->load();
- $file->delete();
- }
- }
- }
-
- // Zum Abschluss den aktuellen Ordner loeschen
- $this->delete();
- }
-
-
- function getSubFolderIds()
- {
- return $this->subfolder();
- }
-
-
-
- /**
- * Ermittelt die letzten Änderung in diesem Ordner.
- * @return Array[Objektid]=Array())
- */
- public function getLastChanges()
- {
-
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT {{object}}.id as objectid,
- {{object}}.lastchange_date as lastchange_date,
- {{object}}.filename as filename,
- {{object}}.typeid as typeid,
- {{name}}.name as name,
- {{user}}.name as username,
- {{user}}.id as userid,
- {{user}}.mail as usermail,
- {{user}}.fullname as userfullname
- FROM {{object}}
- LEFT JOIN {{name}}
- ON {{name}}.objectid = {{object}}.id
- AND {{name}}.languageid = {languageid}
- LEFT JOIN {{user}}
- ON {{user}}.id = {{object}}.lastchange_userid
- WHERE {{object}}.parentid = {folderid}
- ORDER BY {{object}}.lastchange_date DESC
-SQL
- );
-
- // Variablen setzen.
- $sql->setInt( 'folderid', $this->objectid );
-
- $language = \Session::getProjectLanguage();
- $sql->setInt( 'languageid', $language->languageid );
-
- return $sql->getAll();
- }
-
-}
-
-
-?>-
\ No newline at end of file
diff --git a/model/Group.class.php b/model/Group.class.php
@@ -1,379 +0,0 @@
-<?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.
-
-
-
-/**
- * Darstellen einer Benutzergruppe. Eine Gruppe enthaelt beliebig viele Benutzer
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Group
-{
- var $groupid = 0;
- var $error = '';
-
- var $name = '';
- var $fullname = '';
- var $ldap_dn;
- var $tel;
- var $mail;
- var $desc;
- var $style;
- var $isAdmin;
-
-
- // Konstruktor
- function __construct( $groupid='' )
- {
- if ( is_numeric($groupid) )
- $this->groupid = $groupid;
- }
-
-
- // Lesen aller Gruppen aus der Datenbank
- function getAll()
- {
- global $conf;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{group}}' );
-
- return $sql->getAssoc();
- }
-
-
- // Lesen Gruppe aus der Datenbank
- function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{group}}'.
- ' WHERE id={groupid}' );
- $sql->setInt( 'groupid',$this->groupid );
-
- $row = $sql->getRow();
- if ( count($row) > 0 )
- $this->name = $row['name' ];
- else
- $this->name = '';
- }
-
-
- // Lesen einer Gruppe aus der Datenbank
- public static function loadWithName( $name )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{group}}'.
- ' WHERE name={name}' );
- $sql->setString('name',$name );
-
- $row = $sql->getRow();
- if ( count($row) > 0 )
- {
- $group = new Group( $row['id'] );
- $group->load();
-
- return $group;
- }
- else
- {
- throw new \ObjectNotFoundException( "Group does not exist: ".$name);
- }
- }
-
-
- // Speichern Benutzer in der Datenbank
- function save()
- {
- if ( empty($this->name) )
- $this->name = lang('GLOBAL_GROUP').' '.$this->groupid;
-
- $db = db_connection();
-
- // Gruppe speichern
- $sql = $db->sql( 'UPDATE {{group}} '.
- 'SET name = {name} '.
- 'WHERE id={groupid}' );
- $sql->setString( 'name' ,$this->name );
- $sql->setInt ('groupid',$this->groupid );
-
- // Datenbankabfrage ausfuehren
- $sql->query();
- }
-
-
- /**
- * Rueckgabe aller Eigenschaften
- * @return Array
- */
- function getProperties()
- {
- return Array( 'name' =>$this->name,
- 'groupid'=>$this->groupid );
- }
-
-
- // Gruppe hinzufuegen
- function add( $name = '' )
- {
- $db = db_connection();
-
- if ( $name != '' )
- $this->name = $name;
-
- $sql = $db->sql('SELECT MAX(id) FROM {{group}}');
- $this->groupid = intval($sql->getOne())+1;
-
- // Gruppe hinzuf?gen
- $sql = $db->sql( 'INSERT INTO {{group}} '.
- '(id,name) VALUES( {groupid},{name} )');
- $sql->setInt ('groupid',$this->groupid );
- $sql->setString('name' ,$this->name );
-
- // Datenbankbefehl ausfuehren
- $sql->query();
- }
-
-
- // Gruppe entfernen
- function delete()
- {
- $db = db_connection();
-
- // Berechtigungen zu dieser Gruppe loeschen
- $sql = $db->sql( 'DELETE FROM {{acl}} '.
- 'WHERE groupid={groupid}' );
- $sql->setInt ('groupid',$this->groupid );
- $sql->query();
-
-
- // Alle Gruppenzugehoerigkeiten zu dieser Gruppe loeschen
- $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
- 'WHERE groupid={groupid}' );
- $sql->setInt ('groupid',$this->groupid );
- $sql->query();
-
- // Gruppe loeschen
- $sql = $db->sql( 'DELETE FROM {{group}} '.
- 'WHERE id={groupid}' );
- $sql->setInt ('groupid',$this->groupid );
- $sql->query();
- }
-
-
- // Benutzer ermitteln, die Mitglied dieser Gruppe sind
- function getUsers()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{user}}.id,{{user}}.name FROM {{user}} '.
- 'LEFT JOIN {{usergroup}} ON {{usergroup}}.userid={{user}}.id '.
- 'WHERE {{usergroup}}.groupid={groupid}' );
- $sql->setInt('groupid',$this->groupid );
-
- return $sql->getAssoc();
- }
-
-
- // Benutzer ermitteln, die *nicht* Mitglied dieser Gruppe sind
- function getOtherUsers()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{user}}.id,{{user}}.name FROM {{user}}'.
- ' LEFT JOIN {{usergroup}} ON {{usergroup}}.userid={{user}}.id AND {{usergroup}}.groupid={groupid}'.
- ' WHERE {{usergroup}}.groupid IS NULL' );
- $sql->setInt('groupid' ,$this->groupid );
-
- return $sql->getAssoc();
- }
-
-
- // Benutzer einer Gruppe hinzufuegen
- function addUser( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{usergroup}}');
- $usergroupid = intval($sql->getOne())+1;
-
- $sql = $db->sql( 'INSERT INTO {{usergroup}} '.
- ' (id,userid,groupid) '.
- ' VALUES( {usergroupid},{userid},{groupid} )' );
- $sql->setInt('usergroupid',$usergroupid );
- $sql->setInt('userid' ,$userid );
- $sql->setInt('groupid' ,$this->groupid );
-
- $sql->query();
-
- }
-
-
- // Benutzer aus Gruppe entfernen
- function delUser( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
- ' WHERE userid={userid} AND groupid={groupid}' );
- $sql->setInt ('userid' ,$userid );
- $sql->setInt ('groupid' ,$this->groupid );
-
- $sql->query();
- }
-
-
- // Alle Berechtigungen ermitteln
- function getRights()
- {
- global $SESS,$conf_php;
- $db = db_connection();
- $var = array();
-
- // Alle Projekte lesen
- $sql = $db->sql( 'SELECT id,name FROM {{project}}' );
- $projects = $sql->getAssoc();
-
- foreach( $projects as $projectid=>$projectname )
- {
- $var[$projectid] = array();
- $var[$projectid]['name'] = $projectname;
- $var[$projectid]['folders'] = array();
- $var[$projectid]['rights'] = array();
-
- $sql = $db->sql( 'SELECT {{acl}}.* FROM {{acl}}'.
- ' LEFT JOIN {{folder}} ON {{acl}}.folderid = {{folder}}.id'.
- ' WHERE {{folder}}.projectid={projectid}'.
- ' AND {{acl}}.groupid={groupid}' );
- $sql->setInt('projectid',$projectid );
- $sql->setInt('groupid' ,$this->groupid );
-
- $acls = $sql->getAll();
-
- 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 = $db->sql( 'SELECT id FROM {{folder}}'.
- ' WHERE projectid={projectid}' );
- $sql->setInt('projectid',$projectid);
- $folders = $sql->getCol();
-
- $var[$projectid]['folders'] = array();
-
- foreach( $folders as $folderid )
- {
- $folder = new Folder( $folderid );
- $folder->load();
- $var[$projectid]['folders'][$folderid] = implode(' » ',$folder->parentfolder( false,true ));
- }
-
- asort( $var[$projectid]['folders'] );
- }
-
- return $var;
- }
-
-
- // Berechtigung der Gruppe hinzufuegen
- function addRight( $data )
- {
- global $REQ,$SESS;
- $db = db_connection();
-
- $sql = $db->sql('INSERT INTO {{acl}} '.
- '(userid,groupid,folderid,`read`,`write`,`create`,`delete`,publish) '.
- 'VALUES({userid},{groupid},{folderid},{read},{write},{create},{delete},{publish})');
-
- $sql->setNull('userid');
- $sql->setInt ('groupid',$this->groupid);
- $sql->setInt ('projectid',$SESS['projectid']);
- $sql->setInt ('folderid',$data['folderid']);
-
- $sql->setInt ('read' ,$data['read' ]);
- $sql->setInt ('write' ,$data['write' ]);
- $sql->setInt ('create' ,$data['create' ]);
- $sql->setInt ('delete' ,$data['delete' ]);
- $sql->setInt ('publish',$data['publish']);
-
- // Datenbankabfrage ausf?hren
- $sql->query();
- }
-
-
-
- /**
- * Ermitteln aller Berechtigungen dieser Gruppe.<br>
- * Diese Daten werden auf der Gruppenseite in der Administration angezeigt.
- *
- * @return unknown
- */
- function getAllAcls()
- {
- $db = db_connection();
- $sql = $db->sql( 'SELECT {{acl}}.*,{{object}}.projectid,{{language}}.name AS languagename FROM {{acl}}'.
- ' LEFT JOIN {{object}} '.
- ' ON {{object}}.id={{acl}}.objectid '.
- ' LEFT JOIN {{language}} '.
- ' ON {{language}}.id={{acl}}.languageid '.
- ' WHERE ( {{acl}}.groupid={groupid} OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )'.
- ' ORDER BY {{object}}.projectid,{{acl}}.languageid' );
- $sql->setInt ( 'groupid' ,$this->groupid );
-
- $aclList = array();
-
- foreach($sql->getAll() as $row )
- {
- $acl = new Acl();
- $acl->setDatabaseRow( $row );
- $acl->projectid = $row['projectid' ];
- if ( intval($acl->languageid) == 0 )
- $acl->languagename = lang('GLOBAL_ALL_LANGUAGES');
- else
- $acl->languagename = $row['languagename'];
- $aclList[] = $acl;
- }
-
- return $aclList;
- }
-
-
-
- // Berechtigung entfernen
- function delRight( $aclid )
- {
- $sql = $db->sql('DELETE FROM {{acl}} WHERE id={aclid}');
- $sql->setInt( 'aclid',$aclid );
-
- // Datenbankabfrage ausf?hren
- $sql->query( $sql );
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Language.class.php b/model/Language.class.php
@@ -1,287 +0,0 @@
-<?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.
-
-
-/**
- * Darstellen einer Sprache. Jeder Seiteninhalt wird einer Sprache zugeordnet.
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Language
-{
- var $languageid = 0;
- var $error = '';
- var $projectid;
-
- var $name = '';
- var $isoCode = '';
- var $isDefault = false;
-
-
- // Konstruktor
- function __construct( $languageid='' )
- {
- global $SESS;
-
- if ( is_numeric($languageid) )
- $this->languageid = $languageid;
-
-// $this->projectid = $SESS['projectid'];
- }
-
-
-
- /**
- * Stellt fest, ob die angegebene Id existiert.
- */
- function available( $id )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT 1 FROM {{language}} '.
- ' WHERE id={id}');
- $sql->setInt('id' ,$id );
-
- return intval($sql->getOne()) == 1;
- }
-
-
-
- // Lesen aller Sprachen aus der Datenbank
- function getAll()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( "SELECT id,name FROM {{language}} ".
- " WHERE projectid = {projectid} ".
- " ORDER BY name" );
-
- if ( !empty($this) && !empty($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
-
- return $sql->getAssoc();
- }
-
-
- /**
- * Ermittelt die Anzahl aller Sprachen zum aktuellen Projekt.
- */
- function count()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT count(*) FROM {{language}}
- WHERE projectid = {projectid}
-SQL
-);
-
- if ( !empty($this) && !empty($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
-
- return $sql->getOne();
- }
-
-
- // Lesen aus der Datenbank
- function load()
- {
- $db = \Session::getDatabase();
-
- $sql = $db->sql( 'SELECT * FROM {{language}}'.
- ' WHERE id={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
-
- $row = $sql->getRow();
-
- if ( count($row) > 0 )
- {
- $this->name = $row['name' ];
- $this->isoCode = $row['isocode' ];
- $this->projectid = intval( $row['projectid'] );
-
- $this->isDefault = ( $row['is_default'] == '1' );
- }
- }
-
-
- // Speichern der Sprache in der Datenbank
- function save()
- {
- $db = db_connection();
-
- // Gruppe speichern
- $sql = $db->sql( 'UPDATE {{language}} '.
- 'SET name = {name}, '.
- ' isocode = {isocode} '.
- 'WHERE id={languageid}' );
- $sql->setString( 'name' ,$this->name );
- $sql->setString( 'isocode' ,$this->isoCode );
-
- $sql->setInt( 'languageid',$this->languageid );
-
- // Datenbankabfrage ausfuehren
- $sql->query();
- }
-
-
- /**
- * Ermitteln aller Eigenschaften dieser Sprache
- * @return Array
- */
- function getProperties()
- {
- return Array( 'name' =>$this->name,
- 'isocode'=>$this->isoCode );
- }
-
-
- /**
- * Neue Sprache hinzuf?gen
- */
- function add( $isocode='' )
- {
- global $SESS;
- global $iso;
- $db = db_connection();
-
- if ( $isocode != '' )
- {
- // Kleiner Trick, damit "no" (Norwegen) in der .ini-Datei stehen kann
- $isocode = str_replace('_','',$isocode);
-
- $this->isocode = $isocode;
- $codes = \GlobalFunctions::getIsoCodes();
- $this->name = $codes[ $isocode ];
- }
-
- $sql = $db->sql('SELECT MAX(id) FROM {{language}}');
- $this->languageid = intval($sql->getOne())+1;
-
- // Sprache hinzuf?gen
- $sql = $db->sql( 'INSERT INTO {{language}} '.
- '(id,projectid,name,isocode,is_default) VALUES( {languageid},{projectid},{name},{isocode},0 )');
- $sql->setInt ('languageid',$this->languageid );
- $sql->setInt ('projectid' ,$this->projectid );
- $sql->setString('name' ,$this->name );
- $sql->setString('isocode' ,$this->isoCode );
-
- // Datenbankbefehl ausfuehren
- $sql->query();
- }
-
-
- // Diese Sprache als 'default' markieren.
- function setDefault()
- {
- global $SESS;
- $db = db_connection();
-
- // Zuerst alle auf nicht-Standard setzen
- $sql = $db->sql( 'UPDATE {{language}} '.
- ' SET is_default = 0 '.
- ' WHERE projectid={projectid}' );
- $sql->setInt('projectid',$this->projectid );
- $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();
- }
-
-
- function getDefaultId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{language}} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
-
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
-
- return $sql->getOne();
- }
-
-
- // Sprache entfernen
- function delete()
- {
- $db = db_connection();
-
- // Sprache l?schen
-// $sql = $db->sql( 'SELECT COUNT(*) FROM {{language}} WHERE projectid={projectid}' );
-// $sql->setInt( 'projectid',$this->projectid );
-// $count = $sql->getOne( $sql );
-//
-// // Nur l?schen, wenn es mindestens 2 Sprachen gibt
-// if ( $count >= 2 )
-// {
- // Inhalte mit dieser Sprache l?schen
- $sql = $db->sql( 'DELETE FROM {{value}} WHERE languageid={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $sql->query();
-
- // Inhalte mit dieser Sprache l?schen
- $sql = $db->sql( 'DELETE FROM {{name}} WHERE languageid={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $sql->query();
-
- // Sprache l?schen
- $sql = $db->sql( 'DELETE FROM {{language}} WHERE id={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $sql->query();
-
- // Andere Sprache auf "Default" setzen
- $sql = $db->sql( 'SELECT id FROM {{language}} WHERE projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $new_default_languageid = $sql->getOne();
-
- $sql = $db->sql( 'UPDATE {{language}} SET is_default=1 WHERE id={languageid}' );
- $sql->setInt( 'languageid',$new_default_languageid );
- $sql->query();
-// }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Link.class.php b/model/Link.class.php
@@ -1,129 +0,0 @@
-<?php
-namespace cms\model;
-
-
-/**
- * Darstellen einer Verkn�pfung. Eine Verkn�pfung kann auf eine Objekt oder auf
- * eine beliebige Url zeigen
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Link extends Object
-{
- var $linkid;
- var $linkedObjectId = 0;
- var $url = '';
-
- public function __construct( $objectid='' )
- {
- parent::__construct( $objectid );
- $this->isLink = true;
- }
-
-
-
- /**
- * Lesen der Verknuepfung aus der Datenbank
- * @throws \ObjectNotFoundException
- */
- public function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT *'.
- ' FROM {{link}}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $sql->getRow();
-
- if ( count($row ) != 0 )
- {
- $this->linkedObjectId = $row['link_objectid'];
- }
-
- $this->objectLoad();
- }
-
-
- /**
- *
- */
- public function delete()
- {
- $db = db_connection();
-
- // Verkn�pfung l�schen
- $sql = $db->sql( 'DELETE FROM {{link}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
-
- $sql->query();
-
- $this->objectDelete();
- }
-
-
- /**
- *
- */
- public function save()
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{link}} SET '.
- ' link_objectid = {linkobjectid}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setInt ('linkobjectid',$this->linkedObjectId );
-
- $sql->query();
-
- $this->objectSave();
- }
-
-
- public function getProperties()
- {
- return array_merge( parent::getProperties(),
- array( 'objectid' =>$this->objectid,
- 'linkobjectid' =>$this->linkedObjectId
- ));
- }
-
-
- public function getType()
- {
- return 'link';
- }
-
-
- /**
- * Add a new link.
- */
- public function add()
- {
- $this->objectAdd();
-
- $db = db_connection();
-
- $stmt = $db->sql('SELECT MAX(id) FROM {{link}}');
- $this->linkid = intval($stmt->getOne())+1;
-
- $stmt = $db->sql('INSERT INTO {{link}}'.
- ' (id,objectid,link_objectid)'.
- ' VALUES( {linkid},{objectid},{linkobjectid} )' );
- $stmt->setInt ('linkid' ,$this->linkid );
- $stmt->setInt ('objectid' ,$this->objectid );
-
- if ($this->linkedObjectId == 0)
- $stmt->setNull('linkobjectid');
- else
- $stmt->setInt ('linkobjectid',$this->linkedObjectId );
-
- $stmt->query();
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Model.class.php b/model/Model.class.php
@@ -1,283 +0,0 @@
-<?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.
-
-
-
-/**
- * Diese Klasse stellt ein Projektmodell dar. Ein Projektmodell ist eine Darstellungsart
- * der Inhalte. Zu jedem Projektmodell gibt es einen anderen Templatequelltext.
- * Beispiel: Neben HTML gibt es ein Projektmodell fuer WML oder XML. Die Inhalte sind gleich,
- * aber die Art der Ausgabe ist jeweils anders.
- *
- * @package openrat.objects
- * @author $Author$
- * @version $Rev: $
- */
-class Model
-{
- var $modelid = 0;
- var $error = '';
- var $projectid;
-
- var $name = '';
- var $isDefault = false;
-
-
- /**
- * Konstruktor
- */
- function __construct( $modelid='' )
- {
- if ( is_numeric($modelid) )
- $this->modelid = $modelid;
- }
-
-
- /**
- * Stellt fest, ob die angegebene Id existiert.
- */
- function available( $id )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT 1 FROM {{projectmodel}} '.
- ' WHERE id={id}');
- $sql->setInt('id' ,$id );
-
- return intval($sql->getOne()) == 1;
- }
-
-
-
-
- /**
- * Lesen aller Projektmodelle aus der Datenbank
- */
- function getAll()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( "SELECT id,name FROM {{projectmodel}} ".
- " WHERE projectid = {projectid} ".
- " ORDER BY name" );
-
- if ( !empty($this) && !empty($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
-
- return $sql->getAssoc();
- }
-
-
-
- /**
- * Bestimmt die Anzahl aller Varianten fuer das aktuelle Projekt.
- */
- function count()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT count(*) FROM {{projectmodel}}
- WHERE projectid = {projectid}
-SQL
-);
- if ( isset($this) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return $sql->getOne();
- }
-
-
- /**
- * Lesen aus der Datenbank
- */
- function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{projectmodel}}'.
- ' WHERE id={modelid}' );
- $sql->setInt( 'modelid',$this->modelid );
-
- $row = $sql->getRow();
-
- $this->name = $row['name' ];
- $this->projectid = $row['projectid'];
-
- if ( $row['is_default'] == '1' )
- $this->isDefault = true;
- else $this->isDefault = false;
- }
-
-
- /**
- * Speichern des Projektmodells
- */
- function save()
- {
- $db = db_connection();
-
- // Gruppe speichern
- $sql = $db->sql( 'UPDATE {{projectmodel}} '.
- ' SET name = {name} '.
- ' WHERE id={modelid}' );
- $sql->setString( 'name' ,$this->name );
-
- $sql->setInt( 'modelid',$this->modelid );
-
- // Datenbankabfrage ausfuehren
- $sql->query();
- }
-
-
- /**
- * Alle notwendigen Eigenschaften dieses Projektmodells
- * werden als Array zurueckgegeben
- *
- * @return Array
- */
- function getProperties()
- {
- return Array( 'modelid' =>$this->modelid,
- 'projectid'=>$this->projectid,
- 'isDefault'=>$this->isDefault,
- 'name' =>$this->name );
- }
-
-
- /**
- * Modell hinzufuegen
- * @param String Name des Modells (optional)
- */
- function add( $name = '' )
- {
- if ( $name != '' )
- $this->name = $name;
-
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{projectmodel}}');
- $this->modelid = intval($sql->getOne())+1;
-
- // Modell hinzuf?gen
- $sql = $db->sql( 'INSERT INTO {{projectmodel}} '.
- "(id,projectid,name,extension,is_default) VALUES( {modelid},{projectid},{name},'',0 )");
-
- $sql->setInt ('modelid' ,$this->modelid );
- $sql->setInt ('projectid',$this->projectid );
- $sql->setString('name' ,$this->name );
-
- // Datenbankbefehl ausfuehren
- $sql->query();
- }
-
-
- function getDefaultId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{projectmodel}} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt('projectid',$project->projectid);
- }
-
- return $sql->getOne();
- }
-
-
-
- // Diese Sprache als 'default' markieren.
- function setDefault()
- {
- global $SESS;
- $db = db_connection();
-
- // Zuerst alle auf nicht-Standard setzen
- $sql = $db->sql( 'UPDATE {{projectmodel}} '.
- ' SET is_default = 0 '.
- ' WHERE projectid={projectid}' );
- $sql->setInt('projectid',$this->projectid );
- $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();
- }
-
-
- /**
- * Entfernen des Projektmodells aus der Datenbank
- * Es wird dabei nicht geprueft, ob noch ein anders Projektmodell
- * vorhanden ist.
- */
- function delete()
- {
- $db = db_connection();
-
- // Vorlagen zu dieseem Modell loeschen
- $sql = $db->sql( <<<SQL
- DELETE FROM {{templatemodel}}
- WHERE projectmodelid = {modelid}
-SQL
-);
- $sql->setInt( 'modelid',$this->modelid );
- $sql->query();
-
- // Dieses Modell löschen
- $sql = $db->sql( <<<SQL
- DELETE FROM {{projectmodel}}
- WHERE id={modelid}
-SQL
-);
- $sql->setInt( 'modelid',$this->modelid );
- $sql->query();
-
- // Anderes Modell auf "Default" setzen (sofern vorhanden)
- if ( $this->isDefault )
- {
- $sql = $db->sql( 'SELECT id FROM {{projectmodel}} WHERE projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $new_default_modelid = $sql->getOne();
-
- $sql = $db->sql( 'UPDATE {{projectmodel}} SET is_default=1 WHERE id={modelid}' );
- $sql->setInt( 'modelid',$new_default_modelid );
- $sql->query();
- }
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/ModelBase.class.php b/model/ModelBase.class.php
@@ -1,17 +0,0 @@
-<?php
-namespace cms\model;
-
-class ModelBase
-{
- protected function setDatabaseRow( $row )
- {
-
- }
-
- public function getProperties()
- {
- return get_object_vars( $this );
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Object.class.php b/model/Object.class.php
@@ -1,1375 +0,0 @@
-<?php
-
-namespace {
- define('OR_TYPEID_FOLDER',1);
- define('OR_TYPEID_FILE',2);
- define('OR_TYPEID_PAGE',3);
- define('OR_TYPEID_LINK',4);
- define('OR_TYPEID_URL',5);
-
-}
-
-namespace cms\model {
-
- /**
- * Superklasse fuer Objekte im Projektbaum.
- *
- * Dieses Objekt ist die Oberklasse fuer die 4 Klassen Ordner, Datei,
- * Link oder Seite dar.
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
- 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 $description = 'none';
- var $desc = '';
-
- /** Zeitpunkt der Erstellung. Die Variable beinhaltet den Unix-Timestamp.
- * @type Integer
- */
- var $createDate;
-
- /** Zeitpunkt der letzten Aenderung. Die Variable beinhaltet den Unix-Timestamp.
- * @type Integer
- */
- var $lastchangeDate;
-
- /** Benutzer, welcher dieses Objekt erstellt hat.
- * @type User
- */
- public $createUser;
-
- /** Benutzer, welcher dieses Objekt zuletzt geaendert hat.
- * @type User
- */
- public $lastchangeUser;
-
- /**
- * 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 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>.
- * @type Integer
- */
- var $type = null;
-
- /** 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;
-
- var $aclMask = null;
-
- public $typeid;
-
- /** <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 __construct($objectid = '')
- {
- global $SESS;
-
- if ( is_numeric($objectid) )
- {
- $this->objectid = $objectid;
- $this->id = $objectid;
- }
-
-
- $language = \Session::getProjectLanguage();
- if ( is_object($language) )
- $this->languageid = $language->languageid;
-
- $model = \Session::getProjectModel();
- if ( is_object($model) )
- $this->modelid = $model->modelid;
-
- $project = \Session::getProject();
- if ( is_object($project) )
- $this->projectid = $project->projectid;
- }
-
-
- /**
- * Lesen aller Objekte aus dem aktuellen Projekt
- * @return array Alle Objekt-IDs des aktuellen Projektes
- */
- function getAllObjectIds()
- {
- global $SESS;
- $db = db_connection();
-
- if ( ! isset($this->projectid) )
- {
- $project = \Session::getProject();
- $projectid = $project->projectid;
- }
- else
- {
- $projectid = $this->projectid;
- }
-
- $sql = $db->sql('SELECT id from {{object}} '.
- ' WHERE projectid={projectid}');
- $sql->setInt('projectid', $projectid);
-
- return $sql->getCol();
- }
-
-
- // Kompletten Dateinamen des Objektes erzeugen
- function full_filename()
- {
- $path = $this->path();
-
- if ($path != '')
- $path.= '/';
-
- $path.= $this->filename();
-
- return $path;
- }
-
- /**
- * Pr?fen einer Berechtigung zu diesem Objekt
- */
- function checkRight( $type )
- {
- return true;
- }
-
-
- /**
- * Pruefen einer Berechtigung zu diesem Objekt
- */
- function hasRight( $type )
- {
- if ( is_null($this->aclMask) )
- {
- $project = \Session::getProject();
- $language = \Session::getProjectLanguage();
- $user = \Session::getUser();
-
- if ( $user->isAdmin )
- {
- // Administratoren erhalten eine Maske mit allen Rechten
- $this->aclMask = ACL_READ +
- ACL_WRITE +
- ACL_PROP +
- ACL_DELETE +
- ACL_RELEASE +
- ACL_PUBLISH +
- ACL_CREATE_FOLDER +
- ACL_CREATE_FILE +
- ACL_CREATE_LINK +
- ACL_CREATE_PAGE +
- ACL_GRANT +
- ACL_TRANSMIT;
- }
- else
- {
- $this->aclMask = 0;
-
- $db = db_connection();
- $sqlGroupClause = $user->getGroupClause();
- $sql = $db->sql( <<<SQL
-SELECT {{acl}}.* FROM {{acl}}
- LEFT JOIN {{object}}
- ON {{object}}.id={{acl}}.objectid
- WHERE objectid={objectid}
- AND ( languageid={languageid} OR languageid IS NULL )
- AND ( {{acl}}.userid={userid} OR $sqlGroupClause
- OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )
-SQL
- );
-
- $sql->setInt ( 'languageid' ,$language->languageid );
- $sql->setInt ( 'objectid' ,$this->objectid );
- $sql->setInt ( 'userid' ,$user->userid );
-
- foreach($sql->getAll() as $row )
- {
- $acl = new Acl();
- $acl->setDatabaseRow( $row );
-
- $this->aclMask |= $acl->getMask();
- }
- }
- }
-
- if ( readonly() )
- // System ist im Nur-Lese-Zustand
- return $type == ACL_READ && $this->aclMask & $type;
- else
- // Ermittelte Maske auswerten
- return $this->aclMask & $type;
- }
-
-
- /**
- * Typ des Objektes ermitteln
- *
- * @return String der Typ des Objektes entweder 'folder','file','page' oder 'link'
- */
- function getType()
- {
- if ($this->isFolder)
- return OR_TYPE_FOLDER;
- if ($this->isFile)
- return OR_TYPE_FILE;
- if ($this->isPage)
- return OR_TYPE_PAGE;
- if ($this->isLink)
- return OR_TYPE_LINK;
- if ($this->isUrl)
- return OR_TYPE_URL;
-
- return 'unknown';
- }
-
-
- function getProperties()
- {
- return Array( 'id' =>$this->objectid,
- 'objectid' =>$this->objectid,
- 'parentid' =>$this->parentid,
- 'filename' =>$this->filename,
- 'name' =>$this->name,
- 'desc' =>$this->desc,
- 'description' =>$this->desc,
- 'create_date' =>$this->createDate,
- 'create_user' =>$this->createUser->getProperties(),
- 'lastchange_date' =>$this->lastchangeDate,
- 'lastchange_user' =>$this->lastchangeUser->getProperties(),
- 'isFolder' =>$this->isFolder,
- 'isFile' =>$this->isFile,
- 'isLink' =>$this->isLink,
- 'isUrl' =>$this->isUrl,
- 'isPage' =>$this->isPage,
- 'isRoot' =>$this->isRoot,
- 'languageid' =>$this->languageid,
- 'modelid' =>$this->modelid,
- 'projectid' =>$this->projectid,
- 'type' =>$this->getType() );
- }
-
-
- /**
- * 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));
- }
-
-
-
- /**
- * Ueberpruft einen Dateinamen auf Gueltigkeit.
- */
- function goodFilename( $filename )
- {
- // Dateiname muss gueltig sein,
- // ungueltige Zeichen werden entfernt
- $gueltig = 'abcdefghijklmnopqrstuvwxyz0123456789.-_';
- $tmp = strtr($filename, $gueltig, str_repeat('#', strlen($gueltig)));
- return( strtr($this->filename, $tmp, str_repeat('-', strlen($tmp))) );
- }
-
-
-
- /**
- * Ermitteln des Dateinamens und Rueckgabe desselben
- * @return String Dateiname
- */
- function filename()
- {
-
- global $conf;
-
- if ( $conf['filename']['edit'] && $this->filename != '' && $this->filename != $this->objectid )
- {
- $this->filename = $this->goodFilename(trim(strtolower($this->name)));
- return $this->filename;
- }
-
- if ( $this->type == OR_TYPE_FOLDER )
- {
- $this->filename = $this->objectid;
- }
- elseif ( $this->orderid == 1 &&
- !empty($conf['filename']['default']) &&
- !$conf['filename']['edit'] )
- {
- $this->filename = $conf['filename']['default'];
- }
- else
- {
- switch( $conf['filename']['style'] )
- {
- case 'longid':
- // Eine etwas laengere ID als Dateinamen benutzen
- $this->filename = base_convert(str_pad($this->objectid,6,'a'),11,10);
- break;
-
- case 'id':
- // Einfach die Objekt-Id als Dateinamen verwenden.
- $this->filename = $this->objectid;
- break;
-
- case 'short':
- // So kurz wie moeglich: Erhoehen der Basis vom 10 auf 36.
- // Beispiele:
- // 1 -> 1
- // 10 -> a
- $this->filename = base_convert($this->objectid,10,36);
- break;
-
- case 'md5':
- // MD5-Summe als Dateinamen verwenden
- // Achtung: Kollisionen sind unwahrscheinlich, aber theoretisch möglich.
- $this->filename = md5(md5($this->objectid));
- break;
-
- case 'ss':
- // Imitieren von "StoryServer" URLs. Wers braucht.
- $this->filename = '0,'.
- base_convert(str_pad($this->parentid,3,'a'),11,10).
- ','.
- base_convert(str_pad($this->objectid,7,'a'),11,10).
- ',00';
- break;
-
- case 'title':
- // Achtung: Kollisionen sind möglich.
- $this->filename = $this->goodFilename(trim(strtolower($this->name)));
- break;
-
- default:
- // Als Fallback die Objekt-Id als Dateinamen verwenden.
- $this->filename = $this->objectid;
- }
- }
-
- return $this->filename;
- }
-
-
-
- /**
- * Stellt fest, ob das Objekt mit der angegebenen Id existiert.
- */
- public static function available( $objectid )
- {
- $db = db_connection();
-
- // Vielleicht k�nnen wir uns den DB-Zugriff auch ganz sparen.
- if ( !is_numeric($objectid) || $objectid <= 0 )
- return false; // Objekt-Id ung�ltig.
-
- $sql = $db->sql('SELECT 1 FROM {{object}} '.
- ' WHERE id={objectid}');
- $sql->setInt('objectid' , $objectid );
-
- return intval($sql->getOne()) == 1;
- }
-
-
- /**
- * 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
- * @throws \ObjectNotFoundException
- */
- function objectLoad()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT {{object}}.*,' .
- ' {{name}}.name,{{name}}.descr,'.
- ' lastchangeuser.name as lastchange_username, '.
- ' lastchangeuser.fullname as lastchange_userfullname, '.
- ' lastchangeuser.mail as lastchange_usermail, '.
- ' createuser.name as create_username, '.
- ' createuser.fullname as create_userfullname, '.
- ' createuser.mail as create_usermail '.
- ' FROM {{object}}'.
- ' LEFT JOIN {{name}} '.
- ' ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
- ' LEFT JOIN {{user}} as lastchangeuser '.
- ' ON {{object}}.lastchange_userid=lastchangeuser.id '.
- ' LEFT JOIN {{user}} as createuser '.
- ' ON {{object}}.create_userid=createuser.id '.
- ' WHERE {{object}}.id={objectid}');
- $sql->setInt('languageid', $this->languageid);
- $sql->setInt('objectid' , $this->objectid );
-
- $row = $sql->getRow();
-
- if (count($row) == 0)
- throw new \ObjectNotFoundException('object '.$this->objectid.' not found');
-
- $this->setDatabaseRow( $row );
- }
-
-
- /**
- * Lesen der Eigenschaften aus der Datenbank
- * Es werden
- * - die sprachunabhaengigen Daten wie Dateiname, Typ sowie Erstellungs- und Aenderungsdatum geladen
- */
- function objectLoadRaw()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql('SELECT * FROM {{object}}'.
- ' WHERE {{object}}.id={objectid}');
- $sql->setInt('objectid' , $this->objectid );
- $row = $sql->getRow();
-
- if (count($row) == 0)
- die('fatal: Object::objectLoadRaw(): objectid not found: '.$this->objectid.', SQL='.$sql->raw);
-
- $this->parentid = $row['parentid' ];
- $this->filename = $row['filename' ];
- $this->projectid = $row['projectid'];
-
- if ( intval($this->parentid) == 0 )
- $this->isRoot = true;
- else
- $this->isRoot = false;
-
- $this->name = 'n/a';
-
- $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 = ( $row['typeid'] == OR_TYPEID_FOLDER );
- $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 );
-
- }
-
-
- /**
- * Setzt die Eigenschaften des Objektes mit einer Datenbank-Ergebniszeile
- *
- * @param row Ergebniszeile aus Datenbanktabelle
- */
- function setDatabaseRow( $row )
- {
- if ( count($row)==0 )
- die('setDatabaseRow() got empty array, oid='.$this->objectid);
-
- $this->parentid = $row['parentid' ];
- $this->projectid = $row['projectid'];
- $this->filename = $row['filename' ];
- $this->orderid = $row['orderid' ];
-
- if ( intval($this->parentid) == 0 )
- $this->isRoot = true;
- else $this->isRoot = false;
-
- $this->createDate = $row['create_date' ];
- $this->lastchangeDate = $row['lastchange_date'];
-
- $this->createUser = new User();
- $this->createUser->userid = $row['create_userid' ];
- if ( !empty($row['create_username']) )
- {
- $this->createUser->name = $row['create_username' ];
- $this->createUser->fullname = $row['create_userfullname' ];
- $this->createUser->mail = $row['create_usermail' ];
- }
-
- $this->lastchangeUser = new User();
- $this->lastchangeUser->userid = $row['lastchange_userid' ];
-
- if ( !empty($row['lastchange_username']) )
- {
- $this->lastchangeUser->name = $row['lastchange_username' ];
- $this->lastchangeUser->fullname = $row['lastchange_userfullname'];
- $this->lastchangeUser->mail = $row['lastchange_usermail' ];
- }
-
- $this->typeid = $row['typeid'];
-
- $this->isFolder = ( $row['typeid'] == OR_TYPEID_FOLDER );
- $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 )
- {
- $project = \Session::getProject();
- $this->name = $project->name;
- $this->desc = '';
- $this->description = '';
- }
- else
- {
- $this->name = $row['name' ];
- $this->desc = $row['descr'];
- $this->description = $row['descr'];
- }
-
- $this->checkName();
- }
-
-
-
- /**
- * 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 = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND languageid={languageid}');
- $sql->setInt('objectid' , $this->objectid );
- $sql->setInt('languageid', $this->languageid);
- $res = $sql->query();
-
- if ($res->numRows() == 0)
- {
- // Wenn Name in dieser Sprache nicht vorhanden, dann irgendeinen Namen lesen
- $sql = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND name != {blank}');
- $sql->setInt ('objectid' , $this->objectid );
- $sql->setInt ('languageid', $this->languageid);
- $sql->setString('blank' , '' );
-
- $res = $sql->execute();
- }
- $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( $withName = true )
- {
- global $SESS;
- $db = db_connection();
-
- $this->checkFilename();
-
- $sql = $db->sql( <<<SQL
-UPDATE {{object}} SET
- parentid = {parentid},
- lastchange_date = {time} ,
- lastchange_userid = {userid} ,
- filename = {filename}
- WHERE id={objectid}
-SQL
- );
-
-
- if ( $this->isRoot )
- $sql->setNull('parentid');
- else $sql->setInt ('parentid',$this->parentid );
-
-
- $user = \Session::getUser();
- $this->lastchangeUser = $user;
- $this->lastchangeDate = now();
- $sql->setInt ('time' ,$this->lastchangeDate );
- $sql->setInt ('userid' ,$this->lastchangeUser->userid );
- $sql->setString('filename', $this->filename);
- $sql->setInt ('objectid', $this->objectid);
-
-
- $sql->query();
-
- // Nur wenn nicht Wurzelordner
- if ( !$this->isRoot && $withName )
- {
- if ( $this->name == '' )
- $this->name = $this->filename;
-
- $this->objectSaveName();
- }
- }
-
-
-
- /**
- * Aenderungsdatum auf Systemzeit setzen
- */
- function setTimestamp()
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{object}} SET '.
- ' lastchange_date = {time} ,'.
- ' lastchange_userid = {userid} '.
- ' WHERE id={objectid}');
-
- $user = \Session::getUser();
- $this->lastchangeUser = $user;
- $this->lastchangeDate = now();
-
- $sql->setInt ('userid' ,$this->lastchangeUser->userid );
- $sql->setInt ('objectid',$this->objectid );
- $sql->setInt ('time' ,$this->lastchangeDate );
-
- $sql->query();
-
- }
-
-
- public function setCreationTimestamp()
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{object}} SET '.
- ' create_date = {time} '.
- ' WHERE id={objectid}');
-
- $sql->setInt ('objectid',$this->objectid );
- $sql->setInt ('time' ,$this->createDate );
-
- $sql->query();
- }
-
-
- /**
- * Logischen Namen und Beschreibung des Objektes in Datenbank speichern
- * (wird von objectSave() automatisch aufgerufen)
- *
- * @access private
- */
- function ObjectSaveName()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql(<<<SQL
-SELECT COUNT(*) FROM {{name}} WHERE objectid ={objectid} AND languageid={languageid}
-SQL
- );
- $sql->setInt( 'objectid' , $this->objectid );
- $sql->setInt( 'languageid', $this->languageid );
- $count = $sql->getOne();
-
- if ($count > 0)
- {
- $sql = $db->sql( <<<SQL
- UPDATE {{name}} SET
- name = {name},
- descr = {desc}
- WHERE objectid ={objectid}
- AND languageid={languageid}
-SQL
- );
- $sql->setString('name', $this->name);
- $sql->setString('desc', $this->desc);
- $sql->setInt( 'objectid' , $this->objectid );
- $sql->setInt( 'languageid', $this->languageid );
- $sql->query();
- }
- else
- {
- $sql = $db->sql('SELECT MAX(id) FROM {{name}}');
- $nameid = intval($sql->getOne())+1;
-
- $sql = $db->sql('INSERT INTO {{name}}'.' (id,objectid,languageid,name,descr)'.' VALUES( {nameid},{objectid},{languageid},{name},{desc} )');
- $sql->setInt ('objectid' , $this->objectid );
- $sql->setInt ('languageid', $this->languageid );
- $sql->setInt ('nameid', $nameid );
- $sql->setString('name' , $this->name);
- $sql->setString('desc' , $this->desc);
- $sql->query();
- }
- }
-
- /**
- * Objekt loeschen. Es muss sichergestellt sein, dass auch das Unterobjekt geloeschet wird.
- * Diese Methode wird daher normalerweise nur vom Unterobjekt augerufen
- * @access protected
- */
- function objectDelete()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{element}} '.
- ' SET default_objectid=NULL '.
- ' WHERE default_objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
- $sql = $db->sql( 'UPDATE {{value}} '.
- ' SET linkobjectid=NULL '.
- ' WHERE linkobjectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
- $sql = $db->sql( 'UPDATE {{link}} '.
- ' SET link_objectid=NULL '.
- ' WHERE link_objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
-
- // Objekt-Namen l?schen
- $sql = $db->sql('DELETE FROM {{name}} WHERE objectid={objectid}');
- $sql->setInt('objectid', $this->objectid);
- $sql->query();
-
- // ACLs loeschen
- $this->deleteAllACLs();
-
- // Objekt l?schen
- $sql = $db->sql('DELETE FROM {{object}} WHERE id={objectid}');
- $sql->setInt('objectid', $this->objectid);
- $sql->query();
- }
-
-
- /**
- * Objekt hinzufuegen
- */
- function objectAdd()
- {
- global $SESS;
- $db = db_connection();
-
- // Neue Objekt-Id bestimmen
- $sql = $db->sql('SELECT MAX(id) FROM {{object}}');
- $this->objectid = intval($sql->getOne())+1;
-
- $this->checkFilename();
- $sql = $db->sql('INSERT INTO {{object}}'.
- ' (id,parentid,projectid,filename,orderid,create_date,create_userid,lastchange_date,lastchange_userid,typeid)'.
- ' VALUES( {objectid},{parentid},{projectid},{filename},{orderid},{time},{createuserid},{createtime},{userid},{typeid} )');
-
- if ( $this->isRoot )
- $sql->setNull('parentid');
- else $sql->setInt ('parentid',$this->parentid );
-
- $sql->setInt ('objectid' , $this->objectid );
- $sql->setString('filename' , $this->filename );
- $sql->setString('projectid', $this->projectid);
- $sql->setInt ('orderid' , 99999 );
- $sql->setInt ('time' , now() );
- $user = \Session::getUser();
- $sql->setInt ('createuserid' , $user->userid );
- $sql->setInt ('createtime' , now() );
- $user = \Session::getUser();
- $sql->setInt ('userid' , $user->userid );
-
- $sql->setInt( 'typeid',$this->getTypeid());
-
- $sql->query();
-
- if ( !empty($this->name) )
- $this->objectSaveName();
-
- // Standard-Rechte fuer dieses neue Objekt setzen.
- // Der angemeldete Benutzer erhaelt Lese- und Schreibrechte auf
- // das neue Objekt.
- $acl = new Acl();
- $acl->userid = $user->userid;
- $acl->objectid = $this->objectid;
-
- $acl->read = true;
- $acl->write = true;
- $acl->prop = true;
- $acl->delete = true;
- $acl->grant = true;
- if ( $this->isFolder )
- {
- $acl->create_file = true;
- $acl->create_page = true;
- $acl->create_folder = true;
- $acl->create_link = true;
- }
- $acl->add();
-
- // Aus dem Eltern-Ordner vererbbare Berechtigungen uebernehmen.
- $folder = new Folder( $this->parentid );
- foreach( $folder->getAclIds() as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->load();
-
- if ( $acl->transmit ) // ACL is vererbbar, also kopieren.
- {
- $acl->objectid = $this->objectid;
- $acl->add(); // ... und hinzufuegen.
- }
- }
- }
-
-
- /**
- * Pruefung auf Gueltigkeit des Dateinamens
- */
- function checkFilename()
- {
- if ( empty($this->filename) )
- $this->filename = $this->objectid;
-
-// $this->filename = trim(strtolower($this->filename));
-
-// $this->filename = $this->goodFilename( $this->filename);
-
- if ( $this->isRoot )
- return;
-
- if ( !$this->filenameIsUnique( $this->filename ) )
- {
-// $this->filename = $this->objectid;
-//
-// if ( !$this->filenameIsUnique( $this->filename ) )
- $this->filename = $this->filename.'.'.md5(microtime());
- }
- }
-
-
- function filenameIsUnique( $filename )
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
-SELECT COUNT(*) FROM {{object}}
- WHERE parentid={parentid} AND filename={filename}
- AND NOT id = {objectid}
-SQL
- );
-
- $sql->setString('parentid', $this->parentid);
- $sql->setString('filename', $filename );
- $sql->setString('objectid', $this->objectid);
-
-
- return( intval($sql->getOne()) == 0 );
- }
-
-
- /**
- * Pruefung auf Gueltigkeit des logischen Namens
- */
- function checkName()
- {
- if ( empty($this->name) )
- $this->name = $this->filename;
-
- if ( empty($this->name) )
- $this->name = $this->objectid;
- }
-
-
- function getAclIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{acl}} '.
- ' WHERE objectid={objectid}'.
- ' AND ( languageid IS NULL OR '.
- ' languageid = {languageid} )'.
- ' ORDER BY userid,groupid ASC' );
- $sql->setInt('languageid',$this->languageid);
- $sql->setInt('objectid' ,$this->objectid);
-
- return $sql->getCol();
- }
-
-
- function getAllAclIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{acl}} '.
- ' WHERE objectid={objectid}'.
- ' ORDER BY userid,groupid ASC' );
- $sql->setInt('objectid' ,$this->objectid);
-
- return $sql->getCol();
- }
-
-
- function getInheritedAclIds()
- {
- $acls = array();
-
- if ( $this->getType() == 'unknown' )
- $this->load();
-
- // Root-Ordner erhaelt keine Vererbungen
- if ( $this->isRoot )
- return $acls;
-
- $db = db_connection();
- $folder = new Folder( $this->parentid );
-
- foreach( $folder->parentObjectFileNames(true,true) as $oid=>$filename )
- {
- $sql = $db->sql( 'SELECT id FROM {{acl}} '.
- ' WHERE objectid={objectid}'.
- ' AND is_transmit = 1'.
- ' AND ( languageid IS NULL OR '.
- ' languageid = {languageid} )'.
- ' ORDER BY userid,groupid ASC' );
- $sql->setInt('objectid' ,$oid);
- $sql->setInt('languageid',$this->languageid);
- $acls = array_merge( $acls,$sql->getCol() );
- }
-
- return $acls;
- }
-
-
- function getAllInheritedAclIds()
- {
- $acls = array();
-
- if ( $this->getType() == 'unknown' )
- $this->load();
-
- // Root-Ordner erhaelt keine Vererbungen
- if ( $this->isRoot )
- return $acls;
-
- $db = db_connection();
- $folder = new Folder( $this->parentid );
-
- foreach( $folder->parentObjectFileNames(true,true) as $oid=>$filename )
- {
- $sql = $db->sql( 'SELECT id FROM {{acl}} '.
- ' WHERE objectid={objectid}'.
- ' AND is_transmit = 1'.
- ' ORDER BY userid,groupid ASC' );
- $sql->setInt('objectid' ,$oid);
- $acls = array_merge( $acls,$sql->getCol() );
- }
-
- return $acls;
- }
-
-
- /**
- * Ermitteln aller Berechtigungsstufen, die fuer diesen Objekttyp wichtig sind
- */
- function getRelatedAclTypes()
- {
- if ( $this->isFolder )
- return( array('read','write','delete','prop','release','publish','create_folder','create_file','create_page','create_link','grant','transmit') );
- if ( $this->isFile )
- return( array('read','write','delete','prop','release','publish','grant') );
- if ( $this->isPage )
- 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') );
- }
-
-
- /**
- * Ermitteln aller Berechtigungsstufen, die fuer diesen Objekttyp wichtig sind
- */
- function getAssocRelatedAclTypes()
- {
- $rights = array('read','write','delete','prop','release','publish','create_folder','create_file','create_page','create_link','grant','transmit');
- $types = array();
- foreach( $rights as $r )
- $types[$r] = false;
-
- foreach( $this->getRelatedAclTypes() as $t )
- $types[$t] = true;
-
- return $types;
- }
-
- /**
- * Entfernen aller ACLs zu diesem Objekt
- * @access private
- */
- function deleteAllACLs()
- {
- foreach( $this->getAllAclIds() as $aclid )
- {
- $acl = new Acl( $aclid );
- $acl->load();
- $acl->delete();
- }
- }
-
-
-
- /**
- * Liefert einen temporären Dateinamen.
- * @param $attr Attribute fuer den Dateinamen, um diesen eindeutig zu gestalten.
- * @return unknown_type
- */
- public function getTempFileName( $attr = array() )
- {
- global $conf;
-
-// if ( $conf['cache']['enable_cache'] )
-// {
- $filename = \FileUtils::getTempDir().'/openrat';
- foreach( $attr as $a=>$w )
- $filename .= '_'.$a.$w;
-
- $filename .= '.tmp';
- return $filename;
-// }
-// else
-// {
-// $tmpdir = @$conf['cache']['tmp_dir'];
-// $tmpfile = tempnam( $tmpdir,'openrat_tmp' );
-//
-// return $tmpfile;
-// }
- }
-
-
-
- /**
- * Gibt ein fertiges Dateihandle fuer eine temporaere Datei zurück.
- * @return Resource
- */
- protected function getTempFile()
- {
- return tmpfile();
- }
-
-
- public function getTempDir()
- {
- \FileUtils::getTempDir();
- }
-
- /**
- * 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 = $db->sql('UPDATE {{object}} '.' SET orderid={orderid}'.' WHERE id={objectid}');
- $sql->setInt('objectid', $this->objectid);
- $sql->setInt('orderid', $orderid);
-
- $sql->query();
- }
-
-
- /**
- * ?bergeordnete Objekt-ID dieses Objektes neu speichern
- * die Nr. wird sofort in der Datenbank gespeichert.
- *
- * @param Integer ?bergeordnete Objekt-ID
- */
- function setParentId( $parentid )
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{object}} '.' SET parentid={parentid}'.' WHERE id={objectid}');
- $sql->setInt('objectid', $this->objectid);
- $sql->setInt('parentid', $parentid);
-
- $sql->query();
- }
-
-
- function getDependentObjectIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{page}}.objectid FROM {{value}}'.
- ' LEFT JOIN {{page}} '.
- ' ON {{value}}.pageid = {{page}}.id '.
- ' WHERE linkobjectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
-
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einem bestimmten Namen ermittelt
- * @param String Suchbegriff
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByFileName( $text )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{object}} '.
- ' WHERE filename LIKE {filename}'.
- ' AND projectid={projectid}'.
- ' ORDER BY lastchange_date DESC' );
- $sql->setInt ( 'projectid',$this->projectid );
- $sql->setString( 'filename','%'.$text.'%' );
-
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einem Namen ermittelt
- * @param String Suchbegriff
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByName( $text )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{object}}.id FROM {{object}} '.
- ' LEFT JOIN {{name}} '.
- ' ON {{object}}.id={{name}}.objectid'.
- ' WHERE {{name}}.name LIKE {name}'.
- ' AND {{name}}.languageid={languageid}'.
- ' AND {{object}}.projectid={projectid}'.
- ' ORDER BY lastchange_date DESC' );
- $sql->setInt ( 'projectid' ,$this->projectid );
- $sql->setInt ( 'languageid',$this->languageid );
- $sql->setString( 'name' ,'%'.$text.'%' );
-
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einer Beschreibung ermittelt
- * @param String Suchbegriff
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByDescription( $text )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{object}}.id FROM {{object}} '.
- ' LEFT JOIN {{name}} '.
- ' ON {{object}}.id={{name}}.objectid'.
- ' WHERE {{name}}.descr LIKE {desc}'.
- ' AND {{name}}.languageid={languageid}'.
- ' AND {{object}}.projectid={projectid}'.
- ' ORDER BY lastchange_date DESC' );
- $sql->setInt ( 'projectid' ,$this->projectid );
- $sql->setInt ( 'languageid',$this->languageid );
- $sql->setString( 'desc' ,'%'.$text.'%' );
-
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einer UserId ermittelt
- * @param Integer Benutzer-Id der Erstellung
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByCreateUserId( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{object}} '.
- ' WHERE create_userid={userid}'.
- ' AND projectid={projectid}'.
- ' ORDER BY lastchange_date DESC' );
- $sql->setInt ( 'projectid',$this->projectid );
- $sql->setInt ( 'userid' ,$userid );
-
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einer UserId ermittelt
- * @param Integer Benutzer-Id der letzten ?nderung
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByLastChangeUserId( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{object}} '.
- ' WHERE lastchange_userid={userid}'.
- ' AND projectid={projectid}'.
- ' ORDER BY lastchange_date DESC' );
- $sql->setInt ( 'projectid',$this->projectid );
- $sql->setInt ( 'userid' ,$userid );
-
- return $sql->getCol();
- }
-
-
- /**
- * Gibt true zur?ck, wenn die angegebene Objekt-ID existiert
- * @param Integer Objekt-ID
- * @return Boolean
- */
- function isObjectId( $id )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{object}} '.
- ' WHERE id={objectid}'.
- ' AND projectid={projectid}' );
- $sql->setInt ( 'projectid' ,$this->projectid );
- $sql->setInt ( 'objectid' ,$id );
-
- return ($sql->getOne() == intval($id) );
- }
-
-
-
- /**
- * Liefert die Link-Ids, die auf das aktuelle Objekt verweisen.
- * @return array Liste der gefundenen Objekt-IDs
- */
- public function getLinksToMe()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT objectid FROM {{link}} '.
- ' WHERE link_objectid={myid}' );
- $sql->setInt ( 'myid' ,$this->objectid );
-
- return $sql->getCol();
- }
-
- private function getTypeid()
- {
- if ($this->isFolder) return OR_TYPEID_FOLDER;
- 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;
- }
-
-
- }
-
-}?>-
\ No newline at end of file
diff --git a/model/ObjectFactory.php b/model/ObjectFactory.php
@@ -1,54 +0,0 @@
-<?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.
-
-class ObjectFactory
-{
- function create( $objectid )
- {
- $o = new Object( $objectid );
-
- switch( $o->getType() )
- {
- case OR_TYPE_FILE:
- $x = new File( $objectid );
- break;
-
- case OR_TYPE_FOLDER:
- $x = new Folder( $objectid );
- break;
-
- case OR_TYPE_PAGE:
- $x = new Page( $objectid );
- break;
-
- case OR_TYPE_LINK:
- $x = new Link( $objectid );
- break;
-
- default:
- die( "Unknown Object-Typ: ".$o->getType() );
- debug_backtrace();
- }
-
- $x->load();
- return $x;
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Page.class.php b/model/Page.class.php
@@ -1,883 +0,0 @@
-<?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.
-
-
-/**
- * Darstellen einer Seite
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
-
-class Page extends Object
-{
- var $enclosingObjectId = -1; //Id der Seite in die diese Seite im Rahmen der Generierung eingefügt wird
- //Wichtig für include-Values
- var $pageid;
- var $templateid;
- var $template;
-
- var $simple = false;
- var $public = false;
-
- var $el = array();
-
- /**
- * Stellt fest, ob die Editier-Icons angezeigt werden sollen. Dies ist
- * nur der Fall, wenn die Seite auch zum Bearbeiten generiert wird.
- * Wird die Seite zum Veröffentlichen generiert, muss diese Eigenschaft
- * natürlich "false" sein.
- * @var boolean
- */
- var $icons = false;
- var $src = '';
- var $edit = false;
-
- var $content_negotiation = false;
- var $cut_index = false;
- var $default_language = false;
-// var $withLanguage = false;
- var $withLanguage = true;
- var $withModel = true;
-// var $withModel = false;
- var $link = false;
- var $fullFilename = '';
-
- var $log_filenames = array();
- var $modelid = 0;
-
- var $publish = null;
- var $up_path = '';
-
- public $values;
-
-
- function __construct( $objectid='' )
- {
- parent::__construct( $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 = $db->sql( 'SELECT objectid FROM {{page}} '.
- ' WHERE id={pageid}' );
- $sql->setInt('pageid',$pageid);
-
- return $sql->getOne();
- }
-
-
- /**
- * 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 = $db->sql( 'SELECT id FROM {{page}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$objectid);
-
- return $sql->getOne();
- }
-
-
- /**
- * Ermitteln aller Eigenschaften
- *
- * @return Array
- */
- function getProperties()
- {
- return array_merge( parent::getProperties(),
- array('full_filename'=>$this->realFilename(),
- 'pageid' =>$this->pageid,
- 'templateid' =>$this->templateid,
- 'mime_type' =>$this->mimeType() ) );
- }
-
-
- /**
- * 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 );
- }
-
-
-
-
- /**
- * Ermittelt den Pfad zu einem beliebigen Objekt
- *
- * @param Integer Objekt-ID des Zielobjektes
- * @return String Relative Link-angabe, Beispiel: '../../pfad/datei.jpeg'
- */
- public function path_to_object( $objectid )
- {
- global $conf_php,
- $SESS;
- $inhalt = '';
-
- if ( ! Object::available( $objectid) )
- return '';
-
- $param = array('oid'=>'__OID__'.$objectid.'__');
-
- if ( $this->icons )
- $param['withIcons'] = '1';
-
- $object = new Object( $objectid );
- $object->objectLoad();
-
- $cut_index = ( is_object($this->publish) && $this->publish->cut_index );
- $content_negotiation = ( is_object($this->publish) && $this->publish->content_negotiation );
-
- if ( $this->public )
- {
- switch( $object->typeid )
- {
- case OR_TYPEID_FILE:
-
- $inhalt = $this->up_path();
-
- $f = new File( $objectid );
- $f->content_negotiation = $content_negotiation;
- $f->load();
- $inhalt .= $f->full_filename();
- break;
-
- case OR_TYPEID_PAGE:
-
- $inhalt = $this->up_path();
-
- $p = new Page( $objectid );
- $p->languageid = $this->languageid;
- $p->modelid = $this->modelid;
- $p->cut_index = $cut_index;
- $p->content_negotiation = $content_negotiation;
- $p->withLanguage = $this->withLanguage;
- $p->withModel = $this->withModel;
- $p->load();
- $inhalt .= $p->full_filename();
- break;
-
- case OR_TYPEID_LINK:
- $link = new Link( $objectid );
- $link->load();
-
- $linkedObject = new Object( $link->linkedObjectId );
- $linkedObject->objectLoad();
-
- switch( $linkedObject->getType() )
- {
- case OR_TYPEID_FILE:
- $f = new File( $link->linkedObjectId );
- $f->load();
- $f->content_negotiation = $content_negotiation;
- $inhalt = $this->up_path();
- $inhalt .= $f->full_filename();
- break;
-
- case OR_TYPEID_PAGE:
- $p = new Page( $link->linkedObjectId );
- $p->languageid = $this->languageid;
- $p->modelid = $this->modelid;
- $p->cut_index = $cut_index;
- $p->content_negotiation = $content_negotiation;
- $p->withLanguage = $this->withLanguage;
- $p->withModel = $this->withModel;
- $p->load();
- $inhalt = $this->up_path();
- $inhalt .= $p->full_filename();
- break;
- }
- break;
-
- case OR_TYPEID_URL:
- $url = new Url( $objectid );
- $url->load();
- $inhalt = $url->url;
- break;
- }
- }
- else
- {
- // Interne Verlinkungen in der Seitenvorschau
- switch( $object->typeid )
- {
- case OR_TYPEID_FILE:
- $inhalt = \Html::url('file','show',$objectid,$param);
- break;
-
- case OR_TYPEID_PAGE:
- $inhalt = \Html::url('page','show',$objectid,$param);
- break;
-
- case OR_TYPEID_LINK:
- $link = new Link( $objectid );
- $link->load();
-
- $linkedObject = new Object( $link->linkedObjectId );
- $linkedObject->objectLoad();
-
- switch( $linkedObject->typeid )
- {
- case OR_TYPEID_FILE:
- $inhalt = \Html::url('file','show',$link->linkedObjectId,$param);
- break;
-
- case OR_TYPEID_PAGE:
- $inhalt = \Html::url('page','show',$link->linkedObjectId,$param);
- break;
- }
- break;
-
- case OR_TYPEID_URL:
- $url = new Url( $objectid );
- $url->load();
- $inhalt = $url->url;
-
- break;
- }
- }
-
- return $inhalt;
- }
-
-
-
- /**
- * Erzeugt Pr?fix f?r eine relative Pfadangabe
- * Beispiel: Seite liegt in Ordner /pfad/pfad dann '../../'
- *
- * @return String Pfadangabe
- * @access private
- */
- function up_path()
- {
- global $conf;
-
- if ( $conf['filename']['url'] == 'absolute' )
- {
- $this->up_path = '/';
- return $this->up_path;
- }
-
- if ( $this->up_path != '' )
- return $this->up_path;
-
- $folder = new Folder( $this->parentid );
- $folder->load();
- $f = count( $folder->parentObjectFileNames(false,true) );
-
- if ( $f == 0 )
- {
- $this->up_path = './';
- }
- else
- {
- $this->up_path = str_repeat( '../',$f );
- }
-
- return $this->up_path;
- }
-
-
- /**
- * Eine Seite hinzufuegen
- */
- function add()
- {
- $db = db_connection();
-
- $this->objectAdd(); // Hinzuf?gen von Objekt (dabei wird Objekt-ID ermittelt)
-
- $sql = $db->sql('SELECT MAX(id) FROM {{page}}');
- $this->pageid = intval($sql->getOne())+1;
-
- $sql = $db->sql('INSERT INTO {{page}}'.
- ' (id,objectid,templateid)'.
- ' VALUES( {pageid},{objectid},{templateid} )' );
- $sql->setInt ('pageid' ,$this->pageid );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setInt ('templateid',$this->templateid );
-
- $sql->query();
- }
-
-
- /**
- * Seite laden
- */
- function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{page}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $row = $sql->getRow();
-
- $this->pageid = $row['id' ];
- $this->templateid = $row['templateid'];
-
- $this->objectLoad();
- }
-
-
- function delete()
- {
- global $db;
-
- $sql = $db->sql( 'DELETE FROM {{value}} '.
- ' WHERE pageid={pageid}' );
- $sql->setInt('pageid',$this->pageid);
- $sql->query();
-
- $sql = $db->sql( 'DELETE FROM {{page}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $sql->query();
-
- $this->objectDelete();
- }
-
-
- /**
- * Kopieren der Inhalts von einer anderen Seite
- * @param ID der Seite, von der der Inhalt kopiert werden soll
- */
- function copyValuesFromPage( $otherpageid )
- {
- $this->load();
-
- foreach( $this->getElementIds() as $elementid )
- {
- foreach( Language::getAll() as $lid=>$lname )
- {
- $val = new Value();
- $val->publish = false;
- $val->element = new Element( $elementid );
-
- $val->objectid = $otherpageid;
- $val->pageid = Page::getPageIdFromObjectId( $otherpageid );
- $val->languageid = $lid;
- $val->load();
-
- // Inhalt nur speichern, wenn vorher vorhanden
- if ( $val->valueid != 0 )
- {
- $val->objectid = $this->objectid;
- $val->pageid = Page::getPageIdFromObjectId( $this->objectid );
- $val->save();
- }
- }
- }
- }
-
-
-
-
- function save()
- {
- $db = db_connection();
-
- $sql = $db->sql('UPDATE {{page}}'.
- ' SET templateid ={templateid}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt('templateid' ,$this->templateid);
- $sql->setInt('objectid' ,$this->objectid );
- $sql->query();
-
- $this->objectSave();
- }
-
-
-
- function replaceTemplate( $newTemplateId,$replaceElementMap )
- {
- $oldTemplateId = $this->templateid;
-
- $db = db_connection();
-
- // Template-id dieser Seite aendern
- $this->templateid = $newTemplateId;
-
- $sql = $db->sql('UPDATE {{page}}'.
- ' SET templateid ={templateid}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt('templateid' ,$this->templateid);
- $sql->setInt('objectid' ,$this->objectid );
- $sql->query();
-
-
- // Inhalte umschluesseln, d.h. die Element-Ids aendern
- $template = new Template( $oldTemplateId );
- foreach( $template->getElementIds() as $oldElementId )
- {
- if ( !isset($replaceElementMap[$oldElementId]) ||
- intval($replaceElementMap[$oldElementId]) < 1 )
- {
- \Logger::debug( 'deleting value of elementid '.$oldElementId );
- $sql = $db->sql('DELETE FROM {{value}}'.
- ' WHERE pageid={pageid}'.
- ' AND elementid={elementid}' );
- $sql->setInt('pageid' ,$this->pageid);
- $sql->setInt('elementid',$oldElementId );
-
- $sql->query();
- }
- else
- {
- $newElementId = intval($replaceElementMap[$oldElementId]);
-
- \Logger::debug( 'updating elementid '.$oldElementId.' -> '.$newElementId );
- $sql = $db->sql('UPDATE {{value}}'.
- ' SET elementid ={newelementid}'.
- ' WHERE pageid ={pageid}'.
- ' AND elementid={oldelementid}' );
- $sql->setInt('pageid' ,$this->pageid);
- $sql->setInt('oldelementid',$oldElementId );
- $sql->setInt('newelementid',$newElementId );
- $sql->query();
- }
- }
- }
-
-
-
- /**
- * Ermitteln des Dateinamens dieser Seite.
- *
- * Wenn '$this->content_negotiation' auf 'true' steht, wird der Dateiname ggf. gekürzt,
- * so wie er für HTML-Links verwendet wird. Sonst wird immer der echte Dateiname
- * ermittelt.
- *
- * @return String Kompletter Dateiname, z.B. '/pfad/seite.en.html'
- */
- function full_filename()
- {
- $filename = $this->path();
-
- if ( !empty($filename) )
- $filename .= '/';
-
- if ( $this->cut_index && $this->filename == config('publish','default') )
- {
- // Link auf Index-Datei, der Dateiname bleibt leer.
- }
- else
- {
- $format = config('publish','format');
- $format = str_replace('{filename}',$this->filename(),$format );
-
- if ( !$this->withLanguage || $this->content_negotiation && config('publish','negotiation','page_negotiate_language' ) )
- {
- $format = str_replace('{language}' ,'',$format );
- $format = str_replace('{language_sep}','',$format );
- }
- else
- {
- $l = new Language( $this->languageid );
- $l->load();
- $format = str_replace('{language}' ,$l->isoCode ,$format );
- $format = str_replace('{language_sep}',config('publish','language_sep'),$format );
- }
-
- if ( !$this->withModel || $this->content_negotiation && config('publish','negotiation','page_negotiate_type' ) )
- {
- $format = str_replace('{type}' ,'',$format );
- $format = str_replace('{type_sep}','',$format );
- }
- else
- {
- $t = new Template( $this->templateid );
- $t->modelid = $this->modelid;
- $t->load();
- $format = str_replace('{type}' ,$t->extension ,$format );
- $format = str_replace('{type_sep}',config('publish','type_sep'),$format );
- }
- $filename .= $format;
- }
-
- $this->fullFilename = $filename;
- return $filename;
- }
-
-
-// function language_filename()
-// {
-// global $SESS;
-//
-// $db = db_connection();
-//
-// $sql = $db->sql( 'SELECT COUNT(*) FROM {{language}}'.
-// ' WHERE projectid={projectid}' );
-// $sql->setInt('projectid',$SESS['projectid']);
-//
-// if ( $sql->getOne( $sql ) == 1 )
-// {
-// // Wenn es nur eine Sprache gibt, keine Sprachangabe im Dateinamen
-// return '';
-// }
-// else
-// {
-// $sql = $db->sql( 'SELECT isocode FROM {{language}}'.
-// ' WHERE id={languageid}' );
-// $sql->setInt('languageid',$this->languageid);
-// $isocode = $sql->getOne( $sql );
-//
-// return strtolower( $isocode );
-// }
-// }
-
-
- /**
- * Erzeugen der Inhalte zu allen Elementen dieser Seite
- * wird von generate() aufgerufen
- *
- * @access private
- */
- function getElementIds()
- {
- $t = new Template( $this->templateid );
-
- return $t->getElementIds();
- }
-
-
-
- /**
- * Erzeugen der Inhalte zu allen Elementen dieser Seite
- * wird von generate() aufgerufen
- *
- * @access private
- */
- function getElements()
- {
- if ( !isset($this->template) )
- $this->template = new Template( $this->templateid );
-
- return $this->template->getElements();
- }
-
-
-
- /**
- * Erzeugen der Inhalte zu allen Elementen dieser Seite
- * wird von generate() aufgerufen
- *
- * @access private
- */
- function getWritableElements()
- {
- if ( !isset($this->template) )
- $this->template = new Template( $this->templateid );
-
- return $this->template->getWritableElements();
- }
-
-
-
- /**
- * Erzeugen der Inhalte zu allen Elementen dieser Seite
- * wird von generate() aufgerufen
- *
- * @access private
- */
- function generate_elements()
- {
- $this->values = array();
-
- if ( $this->simple )
- $elements = $this->getWritableElements();
- else
- $elements = $this->getElements();
-
- foreach( $elements as $elementid=>$element )
- {
- // neues Inhaltobjekt erzeugen
- $val = new Value();
- $val->publish = $this->public;
- $val->element = $element;
-
- $val->objectid = $this->objectid;
- $val->pageid = $this->pageid;
- $val->languageid = $this->languageid;
- $val->simple = $this->simple;
- $val->modelid = $this->modelid;
- $val->page = $this;
- $val->generate();
- $val->page = null;
- $this->values[$elementid] = $val;
- }
- }
-
-
- /**
- * Erzeugen des Inhaltes der gesamten Seite.
- *
- * @return String Inhalt
- */
- function generate()
- {
- global $conf;
-
- // Setzen der 'locale', damit sprachabhängige Systemausgaben (wie z.B. die
- // Ausgabe von strftime()) in der korrekten Sprache dargestellt werden.
- $language = new Language($this->languageid);
- $language->load();
-
- $locale_conf = $conf['i18n']['locale'];
- if ( isset($locale_conf[strtolower($language->isoCode)]) )
- {
- $locale = $locale_conf[strtolower($language->isoCode)];
- $locale_ok = setlocale(LC_ALL,$locale);
- if ( !$locale_ok )
- // Hat nicht geklappt. Entweder ist das Mapping falsch oder die locale ist
- // nicht korrekt installiert.
- \Logger::warn("Could not set locale '$locale', please check with 'locale -a' if it is installaled correctly");
- }
- else
- {
- setlocale(LC_ALL,'');
- }
-
- if ( $conf['cache']['enable_cache'] && is_file($this->tmpfile() ))
- {
- $this->value = implode('',file($this->tmpfile()));
- return $this->value;
- }
-
- $this->template = new Template( $this->templateid );
- $this->template->modelid = $this->modelid;
- $this->template->load();
- $this->ext = $this->template->extension;
-
- $this->generate_elements();
-
- $src = $this->template->src;
-
- // Ersetzen der Platzhalter durch die Element-Inhalte
-
- foreach( $this->values as $id=>$value )
- {
- $inh = $value->value;
- $src = str_replace( '{{'.$id.'}}',$inh,$src );
-
- // Dynamische Bereiche ein- oder ausblenden
- if ( $inh == '' )
- {
- // Wenn Feld leer
- $src = str_replace( '{{IFEMPTY:'.$id.':BEGIN}}','',$src );
- $src = str_replace( '{{IFEMPTY:'.$id.':END}}' ,'',$src );
-
- $src = \Text::entferneVonBis( $src,'{{IFNOTEMPTY:'.$id.':BEGIN}}','{{IFNOTEMPTY:'.$id.':END}}' );
- }
- else
- {
- // Wenn Feld gefuellt
- $src = str_replace( '{{IFNOTEMPTY:'.$id.':BEGIN}}','',$src );
- $src = str_replace( '{{IFNOTEMPTY:'.$id.':END}}' ,'',$src );
-
- $src = \Text::entferneVonBis( $src,'{{IFEMPTY:'.$id.':BEGIN}}','{{IFEMPTY:'.$id.':END}}' );
- }
-
- if ( $this->icons )
- $src = str_replace( '{{->'.$id.'}}','<a href="javascript:parent.openNewAction(\''.$value->element->name.'\',\'pageelement\',\''.$this->objectid.'_'.$value->element->elementid.'\');" title="'.$value->element->desc.'"><img src="'.OR_THEMES_EXT_DIR.$conf['interface']['theme'].'/images/icon_el_'.$value->element->type.IMG_ICON_EXT.'" border="0" align="left"></a>',$src );
- else
- $src = str_replace( '{{->'.$id.'}}','',$src );
- }
-
- if ( config('publish','escape_8bit_characters') )
- if ( substr($this->mimeType(),-4) == 'html' )
- {
- /*
- *
- $src = htmlentities($src,ENT_NOQUOTES,'UTF-8');
- $src = str_replace('<' , '<', $src);
- $src = str_replace('>' , '>', $src);
- $src = str_replace('&', '&', $src);
- */
- $src = translateutf8tohtml($src);
- }
-
- $this->value = &$src;
-
- // Store in cache.
- $f = fopen( $this->tmpfile(),'w' );
- fwrite( $f,$this->value );
- fclose( $f );
-
- return $this->value;
- }
-
-
- /**
- * Schreiben des Seiteninhaltes in die temporaere Datei
- */
- function write()
- {
- if ( !is_file($this->tmpfile()))
- $this->generate();
- }
-
-
- /**
- * Generieren dieser Seite in Dateisystem und/oder auf FTP-Server
- */
- function publish()
- {
- global $SESS;
- $db = db_connection();
-
- if ( ! is_object($this->publish) )
- $this->publish = new \Publish();
-
- $this->public = true;
-
- $allLanguages = Language::getAll();
- $allModels = Model::getAll();
-
- // Schleife ueber alle Sprachvarianten
- foreach( $allLanguages as $languageid=>$x )
- {
- $this->languageid = $languageid;
- $this->withLanguage = count($allLanguages) > 1 || config('publish','filename_language') == 'always';
- $this->withModel = count($allModels ) > 1 || config('publish','filename_type' ) == 'always';
-
- // Schleife ueber alle Projektvarianten
- foreach( $allModels as $projectmodelid=>$x )
- {
- $this->modelid = $projectmodelid;
-
- $this->load();
- $this->generate();
- $this->write();
-
- // Vorlage ermitteln.
- $t = new Template( $this->templateid );
- $t->modelid = $this->modelid;
- $t->load();
-
- // Nur wenn eine Datei-Endung vorliegt wird die Seite veroeffentlicht
- if ( !empty($t->extension) )
- {
- $this->publish->copy( $this->tmpfile(),$this->full_filename() );
- unlink( $this->tmpfile() );
- $this->publish->publishedObjects[] = $this->getProperties();
- }
- }
- }
-
- }
-
-
- /**
- * Ermittelt den Mime-Type zu dieser Seite
- *
- * @return String Mime-Type
- */
- function mimeType()
- {
- if ( ! is_object($this->template) )
- {
- $this->template = new Template( $this->templateid );
- $this->template->modelid = $this->modelid;
- $this->template->load();
- }
-
- $this->mime_type = $this->template->mimeType();
-
- return( $this->mime_type );
- }
-
-
-
- /**
- * Ermittelt einen tempor�ren Dateinamen f�r diese Seite.
- */
- function tmpfile()
- {
- $db = db_connection();
- $filename = $this->getTempFileName( array('db'=>$db->id,
- 'o' =>$this->objectid,
- 'l' =>$this->languageid,
- 'm' =>$this->modelid,
- 'p' =>intval($this->public),
- 's' =>intval($this->simple) ) );
- return $filename;
- }
-
-
-
- function setTimestamp()
- {
- $tmpFilename = $this->tmpfile();
-
- if ( is_file($tmpFilename) )
- unlink( $tmpFilename);
-
- parent::setTimestamp();
- }
-
-
- /**
- * Ermittelt den Dateinamen dieser Seite, so wie sie auch im Dateisystem steht.
- */
- function realFilename()
- {
- $this->withLanguage = config('publish','filename_language') == 'always' || Language::count() > 1;
- $this->withModel = config('publish','filename_type' ) == 'always' || Model::count() > 1;
-
- return $this->full_filename();
- }
-
-
- /**
- * Stellt fest, ob diese Seite im HTML-Format veröffentlicht wird.
- * @return boolean
- */
- public function isHtml()
- {
- return $this->mimeType()=='text/html';
- }
-}
-
-
-?>
diff --git a/model/Project.class.php b/model/Project.class.php
@@ -1,897 +0,0 @@
-<?php
-
-namespace cms\model;
-
-use database\Database;
-use Session;
-
-
-/**
- * Darstellen eines Projektes
- *
- * @author Jan Dankert
- * @package openrat.objects
- */
-class Project
-{
- // Eigenschaften
- var $projectid;
- var $name;
- var $target_dir;
- var $ftp_url;
- var $ftp_passive;
- var $cmd_after_publish;
- var $content_negotiation;
- var $cut_index;
-
- var $log = array();
-
-
- // Konstruktor
- public function __construct( $projectid='' )
- {
- if ( intval($projectid) != 0 )
- $this->projectid = $projectid;
- }
-
-
- /**
- * Stellt fest, ob die angegebene Projekt-Id existiert.
- * @param $id int Projekt-Id
- * @return boolean
- *
- */
- public function isAvailable($id )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT 1 FROM {{project}} '.
- ' WHERE id={id}');
- $sql->setInt('id' ,$id );
-
- return intval($sql->getOne()) == 1;
- }
-
-
- /**
- * Liefert alle verf?gbaren Projekte.
- * @return array
- */
- public function getAllProjects()
- {
- $db = db_connection();
- $sql = $db->sql( 'SELECT id,name FROM {{project}} '.
- ' ORDER BY name' );
-
- return $sql->getAssoc();
- }
-
-
- // Liefert alle verf?gbaren Projekt-Ids
- public function getAllProjectIds()
- {
- $db = db_connection();
- $sql = $db->sql( 'SELECT id FROM {{project}} '.
- ' ORDER BY name' );
-
- return $sql->getCol();
- }
-
-
- public function getLanguages()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{language}}'.
- ' WHERE projectid={projectid} '.
- ' ORDER BY name' );
- $sql->setInt ('projectid',$this->projectid);
-
- return $sql->getAssoc();
- }
-
-
- public function getLanguageIds()
- {
- return array_keys( $this->getLanguages() );
- }
-
-
- public function getModels()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{projectmodel}}'.
- ' WHERE projectid= {projectid} '.
- ' ORDER BY name' );
- $sql->setInt ('projectid',$this->projectid);
-
- return $sql->getAssoc();
- }
-
-
- public function getModelIds()
- {
- return array_keys( $this->getModels() );
- }
-
-
- public function getTemplateIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{template}}'.
- ' WHERE projectid= {projectid} ' );
- $sql->setInt ('projectid',$this->projectid);
-
- return $sql->getCol();
- }
-
-
- public function getTemplates()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{template}}'.
- ' WHERE projectid= {projectid} ' );
- $sql->setInt ('projectid',$this->projectid);
-
- return $sql->getAssoc();
- }
-
-
- /**
- * Ermitteln des Wurzel-Ordners fuer dieses Projekt.
- *
- * Der Wurzelordner ist der einzige Ordnerhat in diesem
- * Projekt, der kein Elternelement besitzt.
- *
- * @return Objekt-Id des Wurzelordners
- */
- public function getRootObjectId()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT id FROM {{object}}'.
- ' WHERE parentid IS NULL'.
- ' AND projectid={projectid}' );
-
- $sql->setInt('projectid',$this->projectid);
-
- return( $sql->getOne() );
- }
-
-
-
- // Laden
-
- /**
- * @throws \ObjectNotFoundException
- */
- public function load()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{project}} '.
- ' WHERE id={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
-
- $row = $sql->getRow();
-
- if ( empty($row) )
- throw new \ObjectNotFoundException('project '.$this->projectid.' not found');
-
- $this->name = $row['name' ];
- $this->target_dir = $row['target_dir' ];
- $this->ftp_url = $row['ftp_url' ];
- $this->ftp_passive = $row['ftp_passive' ];
- $this->cmd_after_publish = $row['cmd_after_publish' ];
- $this->content_negotiation = $row['content_negotiation'];
- $this->cut_index = $row['cut_index' ];
- }
-
-
- // Laden
- public function loadByName()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{project}} '.
- ' WHERE name={projectname}' );
- $sql->setString( 'projectname',$this->name );
-
- $row = $sql->getRow();
-
- $this->projectid = $row['id' ];
- $this->target_dir = $row['target_dir' ];
- $this->ftp_url = $row['ftp_url' ];
- $this->ftp_passive = $row['ftp_passive' ];
- $this->cmd_after_publish = $row['cmd_after_publish' ];
- $this->content_negotiation = $row['content_negotiation'];
- $this->cut_index = $row['cut_index' ];
- }
-
-
- // Speichern
- public function save()
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- UPDATE {{project}}
- SET name = {name},
- target_dir = {target_dir},
- ftp_url = {ftp_url},
- ftp_passive = {ftp_passive},
- cut_index = {cut_index},
- content_negotiation = {content_negotiation},
- cmd_after_publish = {cmd_after_publish}
- WHERE id= {projectid}
-SQL
-);
-
- $sql->setString('ftp_url' ,$this->ftp_url );
- $sql->setString('name' ,$this->name );
- $sql->setString('target_dir' ,$this->target_dir );
- $sql->setInt ('ftp_passive' ,$this->ftp_passive );
- $sql->setString('cmd_after_publish' ,$this->cmd_after_publish );
- $sql->setInt ('content_negotiation',$this->content_negotiation );
- $sql->setInt ('cut_index' ,$this->cut_index );
- $sql->setInt ('projectid' ,$this->projectid );
-
- $sql->query();
-
- try
- {
- $rootFolder = new Folder( $this->getRootObjectId() );
- $rootFolder->load();
- $rootFolder->filename = $this->name;
- $rootFolder->save();
- }
- catch( \Exception $e )
- {
- \Logger::warn('Project '.$this->projectid.' has not a root folder'."\n".$e->getTraceAsString());
- }
- }
-
-
- // Speichern
- public function getProperties()
- {
- return Array( 'name' =>$this->name,
- 'target_dir' =>$this->target_dir,
- 'ftp_url' =>$this->ftp_url,
- 'ftp_passive' =>$this->ftp_passive,
- 'cmd_after_publish' =>$this->cmd_after_publish,
- 'content_negotiation'=>$this->content_negotiation,
- 'cut_index' =>$this->cut_index,
- 'projectid' =>$this->projectid );
- }
-
-
- // Projekt hinzufuegen
- public function add()
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{project}}');
- $this->projectid = intval($sql->getOne())+1;
-
-
- // Projekt hinzuf?gen
- $sql = $db->sql( 'INSERT INTO {{project}} (id,name,target_dir,ftp_url,ftp_passive,cmd_after_publish,content_negotiation,cut_index) '.
- " VALUES( {projectid},{name},'','',0,'',0,0 ) " );
- $sql->setInt ('projectid',$this->projectid );
- $sql->setString('name' ,$this->name );
-
- $sql->query();
-
- // Modell anlegen
- $model = new Model();
- $model->projectid = $this->projectid;
- $model->name = 'html';
- $model->add();
-
- // Sprache anlegen
- $language = new Language();
- $language->projectid = $this->projectid;
- $language->isoCode = 'en';
- $language->name = 'english';
- $language->add();
-
- // Haupt-Ordner anlegen
- $folder = new Folder();
- $folder->isRoot = true;
- $folder->projectid = $this->projectid;
- $folder->languageid = $language->languageid;
- $folder->filename = $this->name;
- $folder->name = $this->name;
- $folder->isRoot = true;
- $folder->add();
-
- // Template anlegen
- $template = new Template();
- $template->projectid = $this->projectid;
- $template->name = '';
- $template->modelid = $model->modelid;
- $template->languageid = $language->languageid;
- $template->extension = 'html';
- $template->src = '<html><body><h1>Hello world</h1><hr><p>Hello, World.</p></body></html>';
- $template->add();
- $template->save();
-
- // Beispiel-Seite anlegen
- $page = new Page();
- $page->parentid = $folder->objectid;
- $page->projectid = $this->projectid;
- $page->languageid = $language->languageid;
- $page->templateid = $template->templateid;
- $page->filename = '';
- $page->name = 'OpenRat';
- $page->add();
- }
-
-
- // Projekt aus Datenbank entfernen
- public function delete()
- {
- $db = db_connection();
-
- // Root-Ordner rekursiv samt Inhalten loeschen
- $folder = new Folder( $this->getRootObjectId() );
- $folder->deleteAll();
-
-
- foreach( $this->getLanguageIds() as $languageid )
- {
- $language = new Language( $languageid );
- $language->delete();
- }
-
-
- foreach( $this->getTemplateIds() as $templateid )
- {
- $template = new Template( $templateid );
- $template->delete();
- }
-
-
- foreach( $this->getModelIds() as $modelid )
- {
- $model = new Model( $modelid );
- $model->delete();
- }
-
-
- // Projekt l?schen
- $sql = $db->sql( 'DELETE FROM {{project}}'.
- ' WHERE id= {projectid} ' );
- $sql->setInt( 'projectid',$this->projectid );
- $sql->query();
- }
-
- public function getDefaultLanguageId()
- {
- $db = Session::getDatabase();
-
- // ORDER BY deswegen, damit immer mind. eine Sprache
- // gelesen wird
- $sql = $db->sql( 'SELECT id FROM {{language}} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
-
- $sql->setInt('projectid',$this->projectid );
-
- return $sql->getOne();
- }
-
-
- public function getDefaultModelId()
- {
- $db = Session::getDatabase();
-
- // ORDER BY deswegen, damit immer mind. eine Sprache
- // gelesen wird
- $sql = $db->sql( 'SELECT id FROM {{projectmodel}} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
- $sql->setInt('projectid',$this->projectid );
-
- return $sql->getOne();
- }
-
-
-
- /**
- * Entfernt nicht mehr notwendige Inhalte aus dem Archiv.
- */
- public function checkLimit()
- {
- $root = new Folder( $this->getRootObjectId() );
- $root->projectid = $this->projectid;
-
- $pages = $root->getAllObjectIds( array('page') );
- $languages = $this->getLanguageIds();
-
- foreach( $pages as $objectid )
- {
- $page = new Page( $objectid );
- $page->load();
- foreach( $page->getElementIds() as $eid )
- {
- foreach( $languages as $lid )
- {
- $value = new Value();
- $value->element = new Element($eid);
- $value->pageid = $page->pageid;
- $value->languageid = $lid;
-
- $value->checkLimit();
- }
- }
- }
-
- }
-
-
-
- /**
- * Testet die Integrität der Datenbank.
- */
- public function checkLostFiles()
- {
- $this->log = array();
-
- $db = &Session::getDatabase();
-
- // Ordnerstruktur prüfen.
- $sql = $db->sql( <<<EOF
-SELECT thistab.id FROM {{object}} AS thistab
- LEFT JOIN {{object}} AS parenttab
- ON parenttab.id = thistab.parentid
- WHERE thistab.projectid={projectid} AND thistab.parentid IS NOT NULL AND parenttab.id IS NULL
-EOF
-);
- $sql->setInt('projectid',$this->projectid);
-
- $idList = $sql->getCol();
-
- if ( count( $idList ) > 0 )
- {
- $lostAndFoundFolder = new Folder();
- $lostAndFoundFolder->projectid = $this->projectid;
- $lostAndFoundFolder->languageid = $this->getDefaultLanguageId();
- $lostAndFoundFolder->filename = "lostandfound";
- $lostAndFoundFolder->name = 'Lost+found';
- $lostAndFoundFolder->parentid = $this->getRootObjectId();
- $lostAndFoundFolder->add();
-
- foreach( $idList as $id )
- {
- $this->log[] = 'Lost file! Moving '.$id.' to lost+found.';
- $obj = new Object( $id );
- $obj->setParentId( $lostAndFoundFolder->objectid );
- }
- }
-
-
- // Prüfe, ob die Verbindung Projekt->Template->Templatemodell->Projectmodell->Projekt konsistent ist.
- $sql = $db->sql( <<<EOF
-SELECT DISTINCT projectid FROM {{projectmodel}} WHERE id IN (SELECT projectmodelid from {{templatemodel}} WHERE templateid in (SELECT id from {{template}} WHERE projectid={projectid}))
-EOF
-);
- $sql->setInt('projectid',$this->projectid);
-
- $idList = $sql->getCol();
-
- if ( count( $idList ) > 1 )
- {
- \Logger::warn('Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.');
- $this->log[] = 'Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.';
- }
-
- }
-
-
- /**
- * Synchronisation des Projektinhaltes mit dem Dateisystem.
- */
- public function sync()
- {
- global $conf;
- $syncConf = $conf['sync'];
-
- if ( ! $syncConf['enabled'] )
- return;
-
- $syncDir = slashify($syncConf['directory']).$this->name;
-
- }
-
- /**
- * Kopiert ein Projekt von einer Datenbank zu einer anderen.<br>
- * <br>
- * Alle Projektinhalte werden kopiert, die Fremdschluesselbeziehungen werden entsprechend angepasst.<br>
- * <br>
- * Alle Beziehungen zu Benutzern, z.B. "Zuletzt geaendert von", "angelegt von" sowie<br>
- * alle Berechtigungsinformationen gehen verloren!<br>
- *
- * @param string $dbid_destination ID der Ziel-Datenbank
- * @param string $name
- */
- public function copy( $dbid_destination,$name='' )
- {
- \Logger::debug( 'Copying project '.$this->name.' to database '.$dbid_destination );
-
- global $conf;
- $zeit = date('Y-m-d\TH:i:sO');
-
- $db_src = db_connection();
- $db_dest = new Database( $conf['database'][$dbid_destination] );
- $db_dest->id = $dbid_destination;
- $db_dest->start();
-
- $sameDB = ( $db_dest->id == $db_src->id );
-
- // -------------------------------------------------------
- $mapping = array();
- $ids = array('project' => array('foreign_keys'=>array(),
- 'primary_key' =>'id',
- 'unique_idx' =>'name',
- 'erase' =>array()
- ),
- 'language' => array('foreign_keys'=>array('projectid'=>'project'),
- 'primary_key' =>'id'
- ),
- 'projectmodel' => array('foreign_keys'=>array('projectid'=>'project'),
- 'primary_key' =>'id'
- ),
- 'template' => array('foreign_keys'=>array('projectid'=>'project'),
- 'primary_key' =>'id'
- ),
- 'object' => array('foreign_keys'=>array('projectid' =>'project' ),
- 'self_key' =>'parentid',
- 'primary_key' =>'id',
- 'erase' =>array('create_userid','lastchange_userid')
- ),
- 'element' => array('foreign_keys'=>array('templateid' =>'template',
- 'folderobjectid' =>'object',
- 'default_objectid'=>'object' ),
- 'primary_key' =>'id'
- ),
- 'templatemodel'=> array('foreign_keys'=>array('projectmodelid'=>'projectmodel',
- 'templateid' =>'template' ),
- 'primary_key' =>'id',
- 'replace' =>array('text'=>'element')
- ),
- 'name' => array('foreign_keys'=>array('objectid' =>'object',
- 'languageid'=>'language' ),
- 'primary_key' =>'id'
- ),
- 'page' => array('foreign_keys'=>array('objectid' =>'object',
- 'templateid'=>'template' ),
- 'primary_key' =>'id'
- ),
- 'value' => array('foreign_keys'=>array('pageid' =>'page',
- 'languageid'=>'language',
- 'elementid'=>'element',
- 'linkobjectid'=>'object' ),
- 'erase' =>array('lastchange_userid'),
- 'replace' =>array('text'=>'object'),
- 'primary_key' =>'id'
- ),
- 'link' => array('foreign_keys'=>array('objectid' =>'object',
- 'link_objectid'=>'object' ),
- 'primary_key' =>'id'
- ),
- 'folder' => array('foreign_keys'=>array('objectid' =>'object' ),
- 'primary_key' =>'id'
- ),
- 'file' => array('foreign_keys'=>array('objectid' =>'object' ),
- 'primary_key' =>'id',
- 'binary' =>'value'
- ),
-
- );
-
- if ( $sameDB )
- $ids['acl'] = array('foreign_keys'=>array('objectid' => 'object',
- 'languageid' => 'language' ),
- 'primary_key' =>'id'
- );
-
- foreach( $ids as $tabelle=>$data )
- {
- \Logger::debug( 'Copying table '.$tabelle.' ...' );
- $mapping[$tabelle] = array();
- $idcolumn = $data['primary_key'];
-
- // Naechste freie Id in der Zieltabelle ermitteln.
- $stmt = $db_dest->sql( 'SELECT MAX('.$idcolumn.') FROM {t_'.$tabelle.'}');
- $maxid = intval($stmt->getOne());
- $nextid = $maxid;
-
- // Zu �bertragende IDs ermitteln.
- if ( count($data['foreign_keys'])==0 )
- {
- $where = ' WHERE id='.$this->projectid;
- }
- else
- {
- foreach( $data['foreign_keys'] as $fkey_column=>$target_tabelle )
- {
- $where = ' WHERE '.$fkey_column.' IN ('.join(array_keys($mapping[$target_tabelle]),',').')';
- break;
- }
- }
- $stmt = $db_src->sql( 'SELECT '.$idcolumn.' FROM {t_'.$tabelle.'} '.$where);
-
- foreach( $stmt->getCol() as $srcid )
- {
- \Logger::debug('Id '.$srcid.' of table '.$tabelle);
- $mapping[$tabelle][$srcid] = ++$nextid;
-
- $stmt = $db_src->sql( 'SELECT * FROM {t_'.$tabelle.'} WHERE id={id}');
- $stmt->setInt('id',$srcid);
- $row = $stmt->getRow();
-
- // Wert des Prim�rschl�ssels �ndern.
- $row[$idcolumn] = $mapping[$tabelle][$srcid];
-
- // Fremdschl�sselbeziehungen auf neue IDn korrigieren.
- foreach( $data['foreign_keys'] as $fkey_column=>$target_tabelle)
- {
- \Logger::debug($fkey_column.' '.$target_tabelle.' '.$row[$fkey_column]);
-
- if ( intval($row[$fkey_column]) != 0 )
- $row[$fkey_column] = $mapping[$target_tabelle][$row[$fkey_column]];
- }
-
- foreach( array_keys($row) as $key )
- {
- if ( isset($data['unique_idx']) && $key == $data['unique_idx'] )
- {
- // Nachschauen, ob es einen UNIQUE-Key in der Zieltabelle schon gibt.
- $stmt = $db_dest->sql( 'SELECT 1 FROM {t_'.$tabelle.'} WHERE '.$key."='".$row[$key]."'");
-
- if ( intval($stmt->getOne()) == 1 )
- $row[$key] = $row[$key].$zeit;
-
- }
-
- if ( !$sameDB && isset($data['erase']) && in_array($key,$data['erase']) )
- $row[$key] = null;
-
- if ( isset($data['self_key']) && $key == $data['self_key'] && intval($row[$key]) > 0 )
- $row[$key] = $row[$key]+$maxid;
- }
-
- if ( isset($data['replace']) )
- {
- foreach( $data['replace'] as $repl_column=>$repl_tabelle)
- foreach( $mapping[$repl_tabelle] as $oldid=>$newid)
- {
- $row[$repl_column] = str_replace('{'.$oldid.'}','{'.$newid.'}' ,$row[$repl_column]);
- $row[$repl_column] = str_replace('"'.$oldid.'"','"'.$newid.'"' ,$row[$repl_column]);
- $row[$repl_column] = str_replace('->'.$oldid ,'->"'.$newid.'"',$row[$repl_column]);
- }
- }
-
- if ( isset($data['binary']) )
- {
- if ( !$db_src->conf['base64'] && $db_dest->conf['base64'] )
- $row[$data['binary']] = base64_encode($row[$data['binary']]);
- elseif ( $db_src->conf['base64'] && !$db_dest->conf['base64'] )
- $row[$data['binary']] = base64_decode($row[$data['binary']]);
- }
-
- // Daten in Zieltabelle einf�gen.
- $stmt = $db_dest->sql( 'INSERT INTO {t_'.$tabelle.'} ('.join(array_keys($row),',').') VALUES({'.join(array_keys($row),'},{').'})',$dbid_destination);
- foreach( $row as $key=>$value )
- {
- if ( !$sameDB && isset($data['erase']) && in_array($key,$data['erase']) )
- $stmt->setNull($key);
- else
- {
- if(is_bool($value))
- $stmt->setBoolean($key,$value);
- elseif(is_int($value))
- $stmt->setInt($key,$value);
- elseif(is_string($value))
- $stmt->setString($key,$value);
- }
- }
- //$sql = $db->sql( 'INSERT INTO {t_'.$tabelle.'} ('.join(array_keys($row),',').') VALUES('.join($row,',').')',$dbid_destination);
- $stmt->query();
- }
-
- if ( isset($data['self_key']) )
- {
- foreach( $mapping[$tabelle] as $oldid=>$newid )
- {
- $stmt = $db_dest->sql( 'UPDATE {t_'.$tabelle.'} SET '.$data['self_key'].'='.$newid.' WHERE '.$data['self_key'].'='.($oldid+$maxid),$dbid_destination );
- $stmt->query();
- }
- }
- }
-
- \Logger::debug( 'Finished copying project' );
-
- $db_dest->commit();
- }
-
-
-
- /**
- * Ermittelt die Anzahl aller Objekte in diesem Projekt.
- * @return int Anzahl
- */
- public function countObjects()
- {
- $db = db_connection();
- $sql = $db->sql( 'SELECT COUNT(*) FROM {{object}} '.
- ' WHERE projectid = {projectid}' );
- $sql->setInt( 'projectid', $this->projectid );
-
- return $sql->getOne();
-
- }
-
-
-
- /**
- * Ermittelt die Gr��e aller Dateien in diesem Projekt.
- * @return int Summe aller Dateigroessen
- */
- public function size()
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT SUM(size) FROM {{file}}
- LEFT JOIN {{object}}
- ON {{file}}.objectid = {{object}}.id
- WHERE projectid = {projectid}
-SQL
-);
- $sql->setInt( 'projectid', $this->projectid );
-
- return $sql->getOne();
- }
-
-
-
- /**
- * Liefert alle verf?gbaren Projekt-Ids
- */
- public function info()
- {
- $info = array();
-
- $info['count_objects'] = $this->countObjects();
- $info['sum_filesize' ] = $this->size();
-
-
- return $info;
- }
-
-
-
-
- /**
- * Ermittelt projektübergreifend die letzten Änderungen des angemeldeten Benutzers.
- *
- * @return array <string, unknown>
- */
- public function getMyLastChanges()
- {
-
- $db = db_connection();
-
-
- $sql = $db->sql( <<<SQL
- SELECT {{object}}.id as objectid,
- {{object}}.filename as filename,
- {{object}}.typeid as typeid,
- {{object}}.lastchange_date as lastchange_date,
- {{name}}.name as name
- FROM {{object}}
- LEFT JOIN {{name}}
- ON {{name}}.objectid = {{object}}.id
- AND {{name}}.languageid = {languageid}
- LEFT JOIN {{project}}
- ON {{object}}.projectid = {{project}}.id
- WHERE {{object}}.projectid = {projectid}
- AND {{object}}.lastchange_userid = {userid}
- ORDER BY {{object}}.lastchange_date DESC;
-SQL
- );
-
- // Variablen setzen.
- $sql->setInt( 'projectid', $this->projectid );
-
- $language = Session::getProjectLanguage();
- $sql->setInt( 'languageid', $language->languageid );
-
- $user = Session::getUser();
- $sql->setInt( 'userid', $user->userid );
-
- return $sql->getAll();
- }
-
-
- /**
- * Ermittelt projektübergreifend die letzten Änderungen.
- *
- * @return array
- */
- public static function getAllLastChanges()
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT {{object}}.id as objectid,
- {{object}}.lastchange_date as lastchange_date,
- {{object}}.filename as filename,
- {{project}}.id as projectid,
- {{project}}.name as projectname,
- {{user}}.name as username,
- {{user}}.id as userid,
- {{user}}.mail as usermail,
- {{user}}.fullname as userfullname
- FROM {{object}}
- LEFT JOIN {{project}}
- ON {{object}}.projectid = {{project}}.id
- LEFT JOIN {{user}}
- ON {{user}}.id = {{object}}.lastchange_userid
- ORDER BY {{object}}.lastchange_date DESC
- LIMIT 50
-SQL
- );
-
- return $sql->getAll();
- }
-
-
-
- /**
- * Ermittelt die letzten Änderung im Projekt.
- * @return array
- */
- public function getLastChanges()
- {
-
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT {{object}}.id as objectid,
- {{object}}.lastchange_date as lastchange_date,
- {{object}}.filename as filename,
- {{object}}.typeid as typeid,
- {{name}}.name as name,
- {{user}}.name as username,
- {{user}}.id as userid,
- {{user}}.mail as usermail,
- {{user}}.fullname as userfullname
- FROM {{object}}
- LEFT JOIN {{name}}
- ON {{name}}.objectid = {{object}}.id
- AND {{name}}.languageid = {languageid}
- LEFT JOIN {{user}}
- ON {{user}}.id = {{object}}.lastchange_userid
- WHERE {{object}}.projectid = {projectid}
- ORDER BY {{object}}.lastchange_date DESC
-SQL
- );
-
- // Variablen setzen.
- $sql->setInt( 'projectid', $this->projectid );
-
- $language = Session::getProjectLanguage();
- $sql->setInt( 'languageid', $language->languageid );
-
- return $sql->getAll();
- }
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Template.class.php b/model/Template.class.php
@@ -1,440 +0,0 @@
-<?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.
-
-
-/**
- * Logische Darstellung eines Templates
- *
- * @author: $Author$
- * @version: $Revision$
- * @package openrat.objects
- */
-class Template
-{
- /**
- * ID dieses Templates
- * @type Integer
- */
- var $templateid = 0;
-
- /**
- * Projekt-ID des aktuell ausgew?hlten Projektes
- * @type Integer
- */
- var $projectid = 0;
-
- /**
- * Logischer Name
- * @type String
- */
- var $name = 'unnamed';
-
- /**
- * ID der Projektvariante
- * @type Integer
- */
- var $modelid = 0;
-
- /**
- * Dateierweiterung dieses Templates (abh?ngig von der Projektvariante)
- * @type String
- */
- var $extension='';
-
- /**
- * Inhalt des Templates (abh?ngig von der Projektvariante)
- * @type String
- */
- var $src='';
-
- // Konstruktor
- function __construct( $templateid='' )
- {
- $model = \Session::getProjectModel();
- $project = \Session::getProject();
-
- if ( is_object($model) )
- $this->modelid = $model->modelid;
- if ( is_object($project) )
- $this->projectid = $project->projectid;
-
- if ( is_numeric($templateid) )
- $this->templateid = $templateid;
- }
-
-
- /**
- * Ermitteln aller Templates in dem aktuellen Projekt.
- * @return Array mit Id:Name
- */
- function getAll()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{template}}'.
- ' WHERE projectid={projectid}'.
- ' ORDER BY name ASC ' );
- if ( isset($this) && isset($this->projectid) )
- $sql->setInt( 'projectid',$this->projectid );
- else
- {
- $project = \Session::getProject();
- $sql->setInt( 'projectid',$project->projectid );
- }
-
- return $sql->getAssoc();
- }
-
-
- /**
- * Laden des Templates aus der Datenbank und f?llen der Objekteigenschaften
- */
- function load()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{template}}'.
- ' WHERE id={templateid}' );
- $sql->setInt( 'templateid',$this->templateid );
- $row = $sql->getRow();
-
- if ( empty($row) )
- throw new \ObjectNotFoundException("Template not found: ".$this->templateid);
-
- $this->name = $row['name' ];
- $this->projectid = $row['projectid'];
-
- $sql = $db->sql( 'SELECT * FROM {{templatemodel}}'.
- ' WHERE templateid={templateid}'.
- ' AND projectmodelid={modelid}' );
- $sql->setInt( 'templateid',$this->templateid );
- $sql->setInt( 'modelid' ,$this->modelid );
- $row = $sql->getRow();
-
- if ( isset($row['extension']) )
- {
- $this->extension = $row['extension'];
- $this->src = $row['text'];
- }
- else
- {
- $this->extension = null;
- $this->src = null;
- }
-
- }
-
-
- /**
- * Abspeichern des Templates in der Datenbank
- */
- function save()
- {
- if ( $this->name == "" )
- $this->name = lang('GLOBAL_TEMPLATE').' #'.$this->templateid;
-
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{template}}'.
- ' SET name={name}'.
- ' WHERE id={templateid}' );
- $sql->setString( 'name' ,$this->name );
- $sql->setInt ( 'templateid',$this->templateid );
- $sql->query();
-
- $sql = $db->sql( 'SELECT COUNT(*) FROM {{templatemodel}}'.
- ' WHERE templateid={templateid}'.
- ' AND projectmodelid={modelid}' );
- $sql->setInt ( 'templateid' ,$this->templateid );
- $sql->setInt ( 'modelid' ,$this->modelid );
-
- if ( intval($sql->getOne()) > 0 )
- {
- // Vorlagen-Quelltext existiert für diese Varianten schon.
- $sql = $db->sql( 'UPDATE {{templatemodel}}'.
- ' SET extension={extension},'.
- ' text={src} '.
- ' WHERE templateid={templateid}'.
- ' AND projectmodelid={modelid}' );
- }
- else
- {
- // Vorlagen-Quelltext wird für diese Varianten neu angelegt.
- $sql = $db->sql('SELECT MAX(id) FROM {{templatemodel}}');
- $nextid = intval($sql->getOne())+1;
-
- $sql = $db->sql( 'INSERT INTO {{templatemodel}}'.
- ' (id,templateid,projectmodelid,extension,text) '.
- ' VALUES ({id},{templateid},{modelid},{extension},{src}) ');
- $sql->setInt ( 'id',$nextid );
- }
-
- $sql->setString( 'extension' ,$this->extension );
- $sql->setString( 'src' ,$this->src );
- $sql->setInt ( 'templateid' ,$this->templateid );
- $sql->setInt ( 'modelid' ,$this->modelid );
-
- $sql->query();
- }
-
-
- /**
- * Es werden Templates mit einem Inhalt gesucht
- * @param String Suchbegriff
- * @return Array Liste der gefundenen Template-IDs
- */
- function getTemplateIdsByValue( $text )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT templateid FROM {{templatemodel}}'.
- ' WHERE text LIKE {text} '.
- ' AND projectmodelid={modelid}' );
-
- $sql->setInt ( 'modelid',$this->modelid );
- $sql->setString( 'text' ,'%'.$text.'%' );
-
- return $sql->getCol();
- }
-
-
- /**
- * Ermitteln aller Elemente zu diesem Template
- * Es wird eine Liste nur mit den Element-IDs ermittelt und zur?ckgegeben
- * @return Array
- */
- function getElementIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id FROM {{element}}'.
- ' WHERE templateid={templateid}'.
- ' ORDER BY name ASC' );
- $sql->setInt( 'templateid',$this->templateid );
- return $sql->getCol();
- }
-
-
-
- /**
- * Ermitteln aller Elemente zu diesem Template
- * Es wird eine Liste mit den kompletten Elementen ermittelt und zurueckgegeben
- * @return Array
- */
- function getElements()
- {
- $list = array();
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{element}}'.
- ' WHERE templateid={templateid}'.
- ' ORDER BY name ASC' );
- $sql->setInt( 'templateid',$this->templateid );
- foreach($sql->getAll() as $row )
- {
- $e = new Element( $row['id'] );
- $e->setDatabaseRow( $row );
-
- $list[$e->elementid] = $e;
- unset($e);
- }
- return $list;
- }
-
-
-
- /**
- * Ermitteln aller Elemente zu diesem Template
- * Es wird eine Liste mit den kompletten Elementen ermittelt und zurueckgegeben
- * @return Array
- */
- function getWritableElements()
- {
- $list = array();
- $e = new Element();
- $readonlyList = "'".implode("','",$e->readonlyElementNames)."'";
-
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
-SELECT * FROM {{element}}
- WHERE templateid={templateid}
- AND writable=1
- AND type NOT IN ($readonlyList)
- ORDER BY name ASC
-SQL
-);
- $sql->setInt ( 'templateid' ,$this->templateid );
- foreach($sql->getAll() as $row )
- {
- $e = new Element( $row['id'] );
- $e->setDatabaseRow( $row );
-
- $list[$e->elementid] = $e;
- unset($e);
- }
- return $list;
- }
-
-
-
- /**
- * Ermitteln aller Elemente zu diesem Template
- * Es wird eine Liste mit den Element-Namen zur?ckgegeben
- * @return Array
- */
- function getElementNames()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name FROM {{element}}'.
- ' WHERE templateid={templateid}'.
- ' ORDER BY name ASC' );
- $sql->setInt( 'templateid',$this->templateid );
-
- return $sql->getAssoc();
- }
-
-
- /**
- * Hinzuf?gen eines Elementes
- * @param String Name des Elementes
- */
- function addElement( $name,$description='',$type='text' )
- {
- $element = new Element();
- $element->name = $name;
- $element->desc = $description;
- $element->type = $type;
- $element->templateid = $this->templateid;
- $element->wiki = true;
- $element->writable = true;
- $element->add();
- }
-
-
- /**
- * Hinzufuegen eines Templates
- * @param String Name des Templates (optional)
- */
- function add( $name='' )
- {
- if ( !empty($name) )
- $this->name = $name;
-
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{template}}');
- $this->templateid = intval($sql->getOne())+1;
-
- $sql = $db->sql( 'INSERT INTO {{template}}'.
- ' (id,name,projectid)'.
- ' VALUES({templateid},{name},{projectid})' );
- $sql->setInt ('templateid',$this->templateid );
- $sql->setString('name' ,$name );
-
- // Wenn Projektid nicht vorhanden, dann aus Session lesen
- if ( !isset($this->projectid) || intval($this->projectid) == 0 )
- {
- $project = \Session::getProject();
- $this->projectid = $project->projectid;
- }
-
- $sql->setInt ('projectid' ,$this->projectid );
-
- $sql->query();
- }
-
-
- /**
- * Ermitteln alles Objekte (=Seiten), welche auf diesem Template basieren.
- *
- * @return Array Liste von Objekt-IDs
- */
- function getDependentObjectIds()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT objectid FROM {{page}}'.
- ' WHERE templateid={templateid}' );
- $sql->setInt( 'templateid',$this->templateid );
-
- return $sql->getCol();
- }
-
-
- /**
- * Loeschen des Templates
- *
- * Entfernen alle Templateinhalte und des Templates selber
- */
- function delete()
- {
- $db = db_connection();
-
- foreach( $this->getElementIds() as $elementid )
- {
- $element = new Element( $elementid );
- $element->delete();
- }
-
- $sql = $db->sql( 'DELETE FROM {{templatemodel}}'.
- ' WHERE templateid={templateid}' );
- $sql->setInt( 'templateid',$this->templateid );
- $sql->query();
-
- $sql = $db->sql( 'DELETE FROM {{template}}'.
- ' WHERE id={templateid}' );
- $sql->setInt( 'templateid',$this->templateid );
- $sql->query();
- }
-
-
- /**
- * Ermittelt den Mime-Type zu diesem Template.
- *
- * Es wird die Extension des Templates betrachtet und dann mit Hilfe der
- * Konfigurationsdatei 'mime-types.ini' der Mime-Type bestimmt.
- *
- * @return String Mime-Type
- */
- function mimeType()
- {
- global $conf;
- $mime_types = $conf['mime-types'];
-
- // Nur den letzten Teil der Extension auswerten:
- // Aus 'mobile.html' wird nur 'html' verwendet.
- $parts = explode('.',$this->extension);
- $extension = strtolower(array_pop($parts));
-
- if ( !empty($mime_types[$extension]) )
- $this->mime_type = $mime_types[$extension];
- else
- // Wenn kein Mime-Type gefunden, dann Standardwert setzen
- $this->mime_type = 'application/octet-stream';
-
- return( $this->mime_type );
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Url.class.php b/model/Url.class.php
@@ -1,113 +0,0 @@
-<?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
@@ -1,1025 +0,0 @@
-<?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.
-use security\Password;
-
-
-/**
- * Darstellen eines Benutzers
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class User extends ModelBase
-{
- var $userid = 0;
- var $error = '';
-
- var $name = '';
- var $fullname = '';
- var $ldap_dn;
- var $tel;
- var $mail;
- var $desc;
- var $style;
- var $isAdmin;
- var $projects = array();
- var $rights;
- var $loginDate = 0;
-
- var $language;
- var $timezone;
- var $passwordExpires;
- var $passwordAlgo;
-
- var $lastLogin;
- var $otpSecret;
- var $hotp ;
- var $hotpCount;
- var $totp ;
-
-
-
- var $mustChangePassword = false;
- var $groups = null;
- var $loginModuleName = null;
-
- // Konstruktor
- public function __construct( $userid='' )
- {
- if ( is_numeric($userid) )
- $this->userid = $userid;
- }
-
-
- // Lesen Benutzer aus der Datenbank
- function listAll()
- {
- global $conf;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,name '.
- ' FROM {{user}}'.
- ' ORDER BY name' );
-
- return $sql->getAssoc();
- }
-
-
- // Lesen Benutzer aus der Datenbank
- function getAllUsers()
- {
- $list = array();
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * '.
- ' FROM {{user}}'.
- ' ORDER BY name' );
-
- foreach($sql->getAll() as $row )
- {
- $user = new User();
- $user->setDatabaseRow( $row );
-
- $list[] = $user;
- }
-
- return $list;
- }
-
-
- /**
- * Benutzer als aktiven Benutzer in die Session schreiben.
- */
- public function setCurrent()
- {
- $this->loadProjects();
- $this->loginDate = time();
-
- \Session::setUser( $this );
-
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- UPDATE {{user}}
- SET last_login={time}
- WHERE id={userid}
-SQL
- );
- $sql->setInt( 'time' ,time() );
- $sql->setInt( 'userid',$this->userid );
-
- // Datenbankabfrage ausfuehren
- $sql->query();
-
- }
-
-
- /**
- * Erzeugt eine WHERE-Bedingung zur Verwendung in einer SQL-Anfrage.<br>
- * Es wird eine Oder-Liste mit allen Gruppen-Ids erzeugt.
- *
- * @return String SQL-WHERE-Bedingung
- */
- function getGroupClause()
- {
- $groupIds = $this->getGroupIds();
-
- if ( count($groupIds) > 0 )
- $groupclause = ' groupid='.implode(' OR groupid=',$groupIds );
- else
- $groupclause = ' 1=0 ';
-
- return $groupclause;
- }
-
-
- // Prueft, ob der Benutzer fuer ein Projekt berechtigt ist
- function hasProject( $projectid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT COUNT(*)'.
- ' FROM {{acl}}'.
- ' LEFT JOIN {{object}} ON {{object}}.id={{acl}}.objectid '.
- ' WHERE projectid={projectidid} AND '.
- ' ( userid={userid} OR'.
- ' '.$this->getGroupClause().' )' );
- $sql->setInt ( 'userid',$this->userid );
-
- return $sql->getOne() > 0;
- }
-
-
-
- /**
- * Lesen aller Projekte, fuer die der Benutzer berechtigt ist.
- *
- * @return Array [Projekt-Id] = Projekt-Name
- */
- public function getReadableProjects()
- {
- $db = db_connection();
-
- if ( $this->isAdmin )
- {
- // Administratoren haben Rechte auf alle Projekte.
- return Project::getAllProjects();
- }
- else
- {
- $groupClause = $this->getGroupClause();
- $sql = $db->sql(<<<SQL
-SELECT DISTINCT {{project}}.id,{{project}}.name
- FROM {{object}}
- LEFT JOIN {{acl}} ON {{object}}.id = {{acl}}.objectid
- LEFT JOIN {{project}} ON {{project}}.id = {{object}}.projectid
- WHERE {{object}}.parentid IS NULL AND
- {{acl}}.id IS NOT NULL AND
- ( {{acl}}.userid={userid} OR
- $groupClause OR
- ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL))
- ORDER BY {{project}}.name
-SQL
-);
- $sql->setInt ( 'userid',$this->userid );
-
- return $sql->getAssoc();
- }
-
- }
-
-
-
- /**
- * Ermittelt alls Projekte, fuer die der Benutzer berechtigt ist.
- * @return Array [0..n] = Projekt-Id
- */
- function getReadableProjectIds()
- {
- return array_keys( $this->getReadableProjects() );
- }
-
-
- /**
- * Lädt die Liste alle Projekte, fuer die der Benutzer berechtigt ist und
- * speichert diese in diesem Benutzerobjekt.
- */
- function loadProjects()
- {
- $this->projects = $this->getReadableProjects();
- }
-
-
-
- /**
- * Ermittelt zu diesem Benutzer den Login-Token.
- */
- function loginToken()
- {
- global $conf;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT id,mail,name,password_hash FROM {{user}}'.
- ' WHERE id={userid}' );
- $sql->setInt( 'userid',$this->userid );
- $row = $sql->getRow();
-
- if ( count($row) == 0 )
- throw new \ObjectNotFoundException();
-
- // Zusammensetzen des Tokens
- return sha1( $row['password_hash'].$row['name'].$row['id'].$row['mail'] );
- }
-
-
- /**
- * Lesen Benutzer aus der Datenbank.
- */
- public function load()
- {
- global $conf;
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT * FROM {{user}}'.
- ' WHERE id={userid}' );
- $sql->setInt( 'userid',$this->userid );
- $row = $sql->getRow();
-
- if ( count($row) == 0 )
- throw new \ObjectNotFoundException();
-
- $this->setDatabaseRow( $row );
- }
-
-
- /**
- * Benutzerobjekt �ber Benutzernamen ermitteln.<br>
- * Liefert ein neues Benutzerobjekt zur�ck.
- *
- * @static
- * @param name Benutzername
- */
- public static function loadWithName( $name )
- {
- global $conf;
- $db = db_connection();
-
- // Benutzer �ber Namen suchen
- $sql = $db->sql( 'SELECT id FROM {{user}}'.
- ' WHERE name={name}' );
- //Html::debug($sql);
- $sql->setString( 'name',$name );
- $userId = $sql->getOne();
-
- // Benutzer �ber Id instanziieren
- $neuerUser = new \cms\model\User( $userId );
-
- $neuerUser->load();
-
- return $neuerUser;
- }
-
-
-
- /**
- * Stellt fest, ob der Benutzer korrekt geladen ist.
- */
- public function isValid()
- {
- return intval($this->userid) > 0;
- }
-
-
-
- /**
- * Lesen Benutzer aus der Datenbank
- */
- protected function setDatabaseRow( $row )
- {
- global $conf;
-
- $this->userid = $row['id' ];
- $this->name = $row['name' ];
- $this->style = $row['style' ];
- $this->isAdmin = ( $row['is_admin'] == '1');
- $this->ldap_dn = $row['ldap_dn' ];
- $this->fullname = $row['fullname'];
- $this->tel = $row['tel' ];
- $this->mail = $row['mail' ];
- $this->desc = $row['descr' ];
- $this->language = $row['language'];
- $this->timezone = $row['timezone'];
- $this->lastLogin = $row['last_login'];
- $this->otpSecret = $row['otp_secret'];
- $this->hotp = ($row['hotp']==1);
- $this->hotpCount = $row['hotp_counter'];
- $this->totp = ($row['totp']==1);
- $this->passwordExpires = $row['password_expires'];
- $this->passwordAlgo = $row['password_algo'];
-
- if ( $this->fullname == '' )
- $this->fullname = $this->name;
-
- if ( $this->style == '' )
- $this->style = $conf['interface']['style']['default'];
- }
-
-
-
- /**
- * Namen ermitteln.<br>
- * Wenn "fullname" gefuellt, dann diesen benutzen, sonst den Benutzernamen.
- */
- function getName()
- {
- if ( empty($this->fullname))
- return $this->name;
- else
- return $this->fullname;
- }
-
-
-
- /**
- * Liest einen Benutzernamen aus der Datenbank.
- *
- * @param int Benutzer-Id
- * @return String Benutzername
- */
- function getUserName( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT name FROM {{user}}'.
- ' WHERE id={userid}' );
- $sql->setInt( 'userid',$userid );
-
- $name = $sql->getOne();
-
- if ( $name == '' )
- return lang('UNKNOWN');
- else return $name;
- }
-
-
- /**
- * Speichern Benutzer in der Datenbank.
- */
- function save()
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- UPDATE {{user}}
- SET name={name},
- fullname={fullname},
- ldap_dn ={ldap_dn} ,
- tel ={tel} ,
- descr ={desc} ,
- mail ={mail} ,
- style ={style} ,
- language = {language},
- timezone = {timezone},
- is_admin = {isAdmin},
- totp = {totp},
- hotp = {hotp}
- WHERE id={userid}
-SQL
- );
- $sql->setString ( 'name' ,$this->name );
- $sql->setString ( 'fullname',$this->fullname);
- $sql->setString ( 'ldap_dn' ,$this->ldap_dn );
- $sql->setString ( 'tel' ,$this->tel );
- $sql->setString ( 'desc' ,$this->desc );
- $sql->setString ( 'mail' ,$this->mail );
- $sql->setString ( 'style' ,$this->style );
- $sql->setString ( 'language',$this->language);
- $sql->setString ( 'timezone',$this->timezone);
- $sql->setBoolean( 'isAdmin' ,$this->isAdmin );
- $sql->setBoolean( 'totp' ,$this->totp );
- $sql->setBoolean( 'hotp' ,$this->hotp );
- $sql->setInt ( 'userid' ,$this->userid );
-
- // Datenbankabfrage ausfuehren
- $sql->query();
- }
-
-
- /**
- * Benutzer hinzuf�gen
- *
- * @param String $name Benutzername
- */
- function add( $name = '' )
- {
- if ( $name != '' )
- $this->name = $name;
-
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{user}}');
- $this->userid = intval($sql->getOne())+1;
-
- $sql = $db->sql('INSERT INTO {{user}}'.
- ' (id,name,password_hash,ldap_dn,fullname,tel,mail,descr,style,is_admin,password_salt)'.
- " VALUES( {userid},{name},'','','','','','','default',0,'' )" );
- $sql->setInt ('userid',$this->userid);
- $sql->setString('name' ,$this->name );
-
- // Datenbankbefehl ausfuehren
- $sql->query();
-
- $this->addNewUserGroups(); // Neue Gruppen hinzufuegen.
-
- $this->renewOTPSecret();
- }
-
-
-
- /**
- * Zu einem neuen Benutzer automatisch Gruppen hinzufuegen.
- * Diese Methode wird automatisch in "add()" aufgerufen.
- */
- function addNewUserGroups()
- {
- global $conf;
- $groupNames = explode(',',@$conf['security']['newuser']['groups']);
-
- if ( count($groupNames) == 0 )
- return; // Nichts zu tun.
-
- $db = db_connection();
-
- $groupNames = "'".implode("','",$groupNames)."'";
- $sql = $db->sql("SELECT id FROM {{group}} WHERE name IN($groupNames)");
- $groupIds = array_unique( $sql->getCol() );
-
- // Wir brauchen hier nicht weiter pr�fen, ob der Benutzer eine Gruppe schon hat, denn
- // - passiert dies nur bei der Neuanlage eines Benutzers
- // - Enth�lt die Group-Id-Liste eine ID nur 1x.
-
- // Gruppen diesem Benutzer zuordnen.
- foreach( $groupIds as $groupId )
- $this->addGroup( $groupId );
- }
-
-
- /**
- * Benutzer entfernen.<br>
- * Vor dem Entfernen werden alle Referenzen auf diesen Benutzer entfernt:<br>
- * - "Erzeugt von" f�r diesen Benutzer entfernen.<br>
- * - "Letzte �nderung von" f�r diesen Benutzer entfernen<br>
- * - Alle Archivdaten in Dateien mit diesem Benutzer entfernen<br>
- * - Alle Berechtigungen dieses Benutzers l?schen<br>
- * - Alle Gruppenzugehoerigkeiten dieses Benutzers l?schen<br>
- * - Benutzer loeschen<br>
- */
- public function delete()
- {
- $db = db_connection();
-
- // "Erzeugt von" f�r diesen Benutzer entfernen.
- $sql = $db->sql( 'UPDATE {{object}} '.
- 'SET create_userid=null '.
- 'WHERE create_userid={userid}' );
- $sql->setInt ('userid',$this->userid );
- $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();
-
- // 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();
-
- // Alle Berechtigungen dieses Benutzers l?schen
- $sql = $db->sql( 'DELETE FROM {{acl}} '.
- 'WHERE userid={userid}' );
- $sql->setInt ('userid',$this->userid );
- $sql->query();
-
- // Alle Gruppenzugehoerigkeiten dieses Benutzers l?schen
- $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
- 'WHERE userid={userid}' );
- $sql->setInt ('userid',$this->userid );
- $sql->query();
-
- // Benutzer loeschen
- $sql = $db->sql( 'DELETE FROM {{user}} '.
- 'WHERE id={userid}' );
- $sql->setInt ('userid',$this->userid );
- $sql->query();
- }
-
-
- /**
- * Ermitteln der Eigenschaften zu diesem Benutzer
- *
- * @return array Liste der Eigenschaften als assoziatives Array
- */
- public function getProperties()
- {
- return parent::getProperties() + array('id'=>$this->userid,'is_admin'=> $this->isAdmin);
- }
-
-
-
- /**
- * Setzt ein neues Kennwort fuer diesen Benutzer.
- *
- * @param password Kennwortt
- * @param always true, wenn Kennwort dauerhaft.
- */
- function setPassword( $password, $always=true )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{user}} SET password_hash={password},password_algo={algo},password_expires={expires} '.
- 'WHERE id={userid}' );
-
- if ( $always )
- {
- $algo = Password::bestAlgoAvailable();
- $expire = null;
- }
- else
- {
- // Klartext-Kennwort, der Benutzer muss das Kennwort beim nä. Login ändern.
- $algo = OR_PASSWORD_ALGO_PLAIN;
- $expire = time();
- }
-
- // Hashsumme für Kennwort erzeugen
- if ( $expire == null )
- $sql->setNull('expires');
- else
- $sql->setInt('expires',$expire);
-
- $sql->setInt ('algo' ,$algo );
- $sql->setString('password',Password::hash($this->pepperPassword($password),$algo) );
- $sql->setInt ('userid' ,$this->userid );
-
- $sql->query();
- }
-
-
- /**
- * Gruppen ermitteln, in denen der Benutzer Mitglied ist.
- *
- * @return array mit Id:Name
- */
- function getGroups()
- {
- if ( !is_array($this->groups) )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{group}}.id,{{group}}.name FROM {{group}} '.
- 'LEFT JOIN {{usergroup}} ON {{usergroup}}.groupid={{group}}.id '.
- 'WHERE {{usergroup}}.userid={userid}' );
- $sql->setInt('userid',$this->userid );
- $this->groups = $sql->getAssoc();
- }
-
- return $this->groups;
- }
-
-
- // Gruppen ermitteln, in denen der Benutzer Mitglied ist
- function getGroupIds()
- {
- return array_keys( $this->getGroups() );
-
- /*
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT groupid FROM {{usergroup}} '.
- 'WHERE userid={userid}' );
- $sql->setInt('userid',$this->userid );
-
- return $sql->getCol( $sql );
- */
- }
-
-
- // Gruppen ermitteln, in denen der Benutzer *nicht* Mitglied ist
- function getOtherGroups()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{group}}.id,{{group}}.name FROM {{group}}'.
- ' LEFT JOIN {{usergroup}} ON {{usergroup}}.groupid={{group}}.id AND {{usergroup}}.userid={userid}'.
- ' WHERE {{usergroup}}.userid IS NULL' );
- $sql->setInt('userid' ,$this->userid );
-
- return $sql->getAssoc();
- }
-
-
-
- /**
- * Benutzer zu einer Gruppe hinzufuegen.
- *
- * @param groupid die Gruppen-Id
- */
- function addGroup( $groupid )
- {
- $db = db_connection();
-
- $sql = $db->sql('SELECT MAX(id) FROM {{usergroup}}');
- $usergroupid = intval($sql->getOne())+1;
-
- $sql = $db->sql( 'INSERT INTO {{usergroup}} '.
- ' (id,userid,groupid) '.
- ' VALUES( {usergroupid},{userid},{groupid} )' );
- $sql->setInt('usergroupid',$usergroupid );
- $sql->setInt('userid' ,$this->userid );
- $sql->setInt('groupid' ,$groupid );
-
- $sql->query();
-
- }
-
-
-
- /**
- * Benutzer aus Gruppe entfernen.
- *
- * @param groupid die Gruppen-Id
- */
- function delGroup( $groupid )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
- ' WHERE userid={userid} AND groupid={groupid}' );
- $sql->setInt ('userid' ,$this->userid );
- $sql->setInt ('groupid' ,$groupid );
-
- $sql->query();
- }
-
-
- /**
- * Ermitteln aller Rechte des Benutzers im aktuellen Projekt.
- *
- * @param Integer $projectid Projekt-Id
- * @param Integer $languageid Sprache-Id
- */
- function loadRights( $projectid,$languageid )
- {
- }
-
-
- /**
- * Ermitteln aller Berechtigungen des Benutzers.<br>
- * Diese Daten werden auf der Benutzerseite in der Administration angezeigt.
- *
- * @return array
- */
- function getAllAcls()
- {
-
- $this->delRights();
-
- $db = db_connection();
-
- $group_clause = $this->getGroupClause();
-
- $sql = $db->sql( 'SELECT {{acl}}.*,{{object}}.projectid,{{language}}.name AS languagename FROM {{acl}}'.
- ' LEFT JOIN {{object}} '.
- ' ON {{object}}.id={{acl}}.objectid '.
- ' LEFT JOIN {{language}} '.
- ' ON {{language}}.id={{acl}}.languageid '.
- ' WHERE ( {{acl}}.userid={userid} OR '.$group_clause.
- ' OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )'.
- ' ORDER BY {{object}}.projectid,{{acl}}.languageid' );
- $sql->setInt ( 'userid' ,$this->userid );
-
- $aclList = array();
-
- foreach($sql->getAll() as $row )
- {
- $acl = new Acl();
- $acl->setDatabaseRow( $row );
- $acl->projectid = $row['projectid' ];
- if ( intval($acl->languageid) == 0 )
- $acl->languagename = lang('GLOBAL_ALL_LANGUAGES');
- else
- $acl->languagename = $row['languagename'];
- $aclList[] = $acl;
- }
-
- return $aclList;
- }
-
-
- /**
- * Ermitteln aller Berechtigungen.
- * @return array Berechtigungen
- */
- function getRights()
- {
- die('User.class::getRights()');
-
-// $db = db_connection();
-// $var = array();
-//
-// // Alle Projekte lesen
-// $sql = $db->sql( 'SELECT id,name FROM {{project}}' );
-// $projects = $sql->getAssoc( $sql );
-//
-// foreach( $projects as $projectid=>$projectname )
-// {
-// $var[$projectid] = array();
-// $var[$projectid]['name'] = $projectname;
-// $var[$projectid]['folders'] = array();
-// $var[$projectid]['rights'] = array();
-//
-// $sql = $db->sql( 'SELECT {{acl}}.* FROM {{acl}}'.
-// ' LEFT JOIN {{folder}} ON {{acl}}.folderid = {{folder}}.id'.
-// ' WHERE {{folder}}.projectid={projectid}'.
-// ' AND {{acl}}.userid={userid}' );
-// $sql->setInt('projectid',$projectid );
-// $sql->setInt('userid' ,$this->userid );
-//
-// $acls = $sql->getAll( $sql );
-//
-// 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'] = Html::url(array('action'=>'user','subaction'=>'delright','aclid'=>$aclid));
-// }
-//
-// $sql = $db->sql( 'SELECT id FROM {{folder}}'.
-// ' WHERE projectid={projectid}' );
-// $sql->setInt('projectid',$projectid);
-// $folders = $sql->getCol( $sql );
-//
-// $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;
- }
-
-
- /**
- * Entfernt alle Rechte aus diesem Benutzerobjekt.
- */
- function delRights()
- {
- $this->rights = array();
- }
-
-
- /**
- * Ueberpruft, ob der Benutzer ein bestimmtes Recht hat
- *
- * @param $objectid Objekt-Id zu dem Objekt, dessen Rechte untersucht werden sollen
- * @param $type Typ des Rechts (Lesen,Schreiben,...) als Konstante ACL_*
- */
- function hasRight( $objectid,$type )
- {
- global $conf;
- if ( $this->isAdmin && !$conf['security']['readonly'] )
- return true;
-
- if ( $this->isAdmin && $type & ACL_READ )
- return true;
-
- if ( !isset($this->rights[$objectid]) )
- return false;
-
- return $this->rights[$objectid] & $type;
- }
-
-
- /**
- * Berechtigung dem Benutzer hinzufuegen.
- *
- * @param objectid Objekt-Id, zu dem eine Berechtigung hinzugefuegt werden soll
- * @param Art des Rechtes, welches hinzugefuegt werden soll
- */
- function addRight( $objectid,$type )
- {
- global $conf;
-
- if ( $conf['security']['readonly'] )
- if ( $type & ACL_READ )
- $type = ACL_READ;
- else
- $type = 0;
-
- if ( $type & ACL_PUBLISH && $conf['security']['nopublish'] )
- $type -= ACL_PUBLISH;
-
-
- if ( !isset($this->rights[$objectid]) )
- $this->rights[$objectid] = 0;
-
- $this->rights[$objectid] = $this->rights[$objectid] | $type;
- }
-
-
- /**
- * Ermitteln aller zur Verfuegung stehenden Stylesheets
- */
- public function getAvailableStyles()
- {
- global $conf;
- $styles = array();
-
- foreach( $conf['style'] as $key=>$values)
- $styles[$key] = $values['name'];
-
- return $styles;
- }
-
- /**
- * Ueberpruefen des Kennwortes.
- *
- * Es wird festgestellt, ob das Kennwort dem des Benutzers entspricht.
- * Es wird dabei nur gegen die interne Datenbank geprüft. Weitere
- * Loginmodule werden nicht aufgerufen!
- * Diese Methode darf kein Bestandteil des Logins sein, da nur das Kennwort geprüft wird!
- * Kennwortablauf und Token werden nicht geprüft!
- */
- function checkPassword( $password )
- {
- $db = db_connection();
- // Laden des Benutzers aus der Datenbank, um Password-Hash zu ermitteln.
- $sql = $db->sql( 'SELECT * FROM {{user}}'.
- ' WHERE id={userid}' );
- $sql->setInt( 'userid',$this->userid );
- $row_user = $sql->getRow();
-
- // Pruefen ob Kennwort mit Datenbank uebereinstimmt.
- return Password::check($this->pepperPassword($password),$row_user['password_hash'],$row_user['password_algo']);
- }
-
-
- /**
- * Erzeugt ein aussprechbares Kennwort.
- *
- * Inspired by http://www.phpbuilder.com/annotate/message.php3?id=1014451
- *
- * @return String Zuf�lliges Kennwort
- */
- function createPassword()
- {
- global $conf;
-
- $pw = '';
- $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
- $v = 'aeiou'; //vowels
- $a = $c.$v; //both
-
- //use two syllables...
- for ( $i=0; $i < intval($conf['security']['password']['min_length'])/3; $i++ )
- {
- $pw .= $c[rand(0, strlen($c)-1)];
- $pw .= $v[rand(0, strlen($v)-1)];
- $pw .= $a[rand(0, strlen($a)-1)];
- }
- //... and add a nice number
- $pw .= rand(10,99);
-
- return $pw;
- }
-
-
- /**
- * Das Kennwort "pfeffern".
- *
- * Siehe http://de.wikipedia.org/wiki/Salt_%28Kryptologie%29#Pfeffer
- * für weitere Informationen.
- *
- * @param Kennwort
- * @return Das gepfefferte Kennwort
- */
- public function pepperPassword( $pass )
- {
- global $conf;
- return $conf['security']['password']['pepper'].$pass;
- }
-
-
- /**
- * Ermittelt projektübergreifend die letzten Änderungen des Benutzers.
- *
- * @return array <string, unknown>
- */
- public function getLastChanges()
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT {{object}}.id as objectid,
- {{object}}.filename as filename,
- {{object}}.lastchange_date as lastchange_date,
- {{project}}.id as projectid,
- {{project}}.name as projectname
- FROM {{object}}
- LEFT JOIN {{project}}
- ON {{object}}.projectid = {{project}}.id
- WHERE {{object}}.lastchange_userid = {userid}
- ORDER BY {{object}}.lastchange_date DESC
-SQL
- );
-
- $sql->setInt( 'userid', $this->userid );
-
- return $sql->getAll();
-
- }
-
-
- /**
- * Calculate the code, with given secret and point in time.
- *
- * @param string $secret
- * @param int|null $timeSlice
- *
- * @return string
- */
- public function getTOTPCode()
- {
- $codeLength = 6;
- $timeSlice = floor(time() / 30);
- $secretkey = @hex2bin($this->otpSecret);
- // Pack time into binary string
- $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
- // Hash it with users secret key
- $hm = hash_hmac('SHA1', $time, $secretkey, true);
- // Use last nipple of result as index/offset
- $offset = ord(substr($hm, -1)) & 0x0F;
- // grab 4 bytes of the result
- $hashpart = substr($hm, $offset, 4);
- // Unpak binary value
- $value = unpack('N', $hashpart);
- $value = $value[1];
- // Only 32 bits
- $value = $value & 0x7FFFFFFF;
- $modulo = pow(10, $codeLength);
- return str_pad($value % $modulo, $codeLength, '0', STR_PAD_LEFT);
- }
-
-
- /**
- * Erzeugt ein neues OTP-Secret.
- */
- public function renewOTPSecret() {
-
- $secret = Password::randomHexString(64);
-
- $db = db_connection();
-
- $stmt = $db->sql('UPDATE {{user}} SET otp_secret={secret} WHERE id={id}');
-
- $stmt->setString( 'secret', $secret );
- $stmt->setInt ( 'id' , $this->userid );
-
- $stmt->execute();
-
- }
-
-}
-
-?>-
\ No newline at end of file
diff --git a/model/Value.class.php b/model/Value.class.php
@@ -1,1688 +0,0 @@
-<?php
-namespace cms\model;
-use \ObjectNotFoundException;
-use \Logger;
-use \Text;
-use \Html;
-use \Http;
-use \Transformer;
-use \Code;
-
-// 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.
-
-
-
-/**
- * Darstellen einer Inhaltes
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-
-class Value
-{
- /**
- * ID dieser Inhaltes
- * @type Integer
- */
- var $valueid=0;
-
- /**
- * Seiten-Objekt der ?bergeordneten Seite
- * @type Object
- */
- var $page;
-
- /**
- * Seiten-Id der uebergeordneten Seite
- * @type Integer
- */
- var $pageid;
-
- /**
- * Kennzeichen, ob der Inhalt mit dem Inhalt einer anderern Seite verkn�pft wird.
- * @type Object
- */
- var $isLink = false;
-
- /**
- * Objekt-ID, auf die verlinkt wird
- * @type Integer
- */
- var $linkToObjectId=0;
-
- /**
- * Text-Inhalt
- * @type String
- */
- var $text='';
-
- /**
- * Zahl. Auch Flie?kommazahlen werden als Ganzzahl gespeichert
- * @type Integer
- */
- var $number=0;
-
-
- /**
- * Datum als Unix-Timestamp
- * @type Integer
- */
- var $date=0;
-
- /**
- * Element-Objekt
- * @type Object
- */
- var $element;
-
- /**
- * Element-Id
- * @type Integer
- */
- var $elementid;
-
- /**
- * Der eigentliche Inhalt des Elementes
- * @type String
- */
- var $value;
-
- /**
- * TimeStamp der letzten Aenderung
- * @type Integer
- */
- var $lastchangeTimeStamp;
-
- /**
- * Benutzer-ID der letzten Aenderung
- * @type Integer
- */
- var $lastchangeUserId;
-
- /**
- * Benutzername der letzten Aenderung
- * @type Integer
- */
- var $lastchangeUserName;
-
- /**
- * Schalter, ob dieser Inhalt der aktive Inhalt ist
- * @type Boolean
- */
- var $active;
-
- /**
- * Schalter, ob dieser Inhalt der Inhalt ist, der veroeffentlicht
- * werden soll
- * @type Boolean
- */
- var $publish;
-
- /**
- * @type Boolean
- */
- public $simple;
-
- /**
- * Konstruktor
- */
- function __construct()
- {
- $this->lastchangeUserId = 0;
- $this->lastchangeTimeStamp = 0;
-
- $language = \Session::getProjectLanguage();
- if ( is_object($language) )
- $this->languageid = $language->languageid;
- }
-
-
-
-
- function path_to_page( $pageid )
- {
- return $this->page->path_to_object( $pageid );
- }
- function path_to_object( $pageid )
- {
- return $this->path_to_page( $pageid );
- }
-
-
- /**
- * Laden des aktuellen Inhaltes aus der Datenbank
- */
- function load()
- {
- $db = db_connection();
-
- if ( $this->publish )
- $sql = $db->sql( 'SELECT * FROM {{value}}'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}'.
- ' AND publish=1' );
- else
- $sql = $db->sql( 'SELECT * FROM {{value}}'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}'.
- ' AND active=1' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
- $row = $sql->getRow();
-
- if ( count($row) > 0 ) // Wenn Inhalt gefunden
- {
- $this->text = $row['text'];
- $this->valueid = intval($row['id'] );
- $this->linkToObjectId = intval($row['linkobjectid']);
- $this->number = intval($row['number' ]);
- $this->date = intval($row['date' ]);
-
- $this->active = ( $row['active' ]=='1' );
- $this->publish = ( $row['publish']=='1' );
-
- $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
- $this->lastchangeUserId = intval($row['lastchange_userid']);
- }
- }
-
-
- /**
- * Laden eines bestimmten Inhaltes aus der Datenbank
- */
- function loadWithId( $valueid=0 )
- {
- if ( $valueid != 0 )
- $this->valueid = $valueid;
-
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{value}}.*,{{user}}.name as lastchange_username'.
- ' FROM {{value}}'.
- ' LEFT JOIN {{user}} ON {{user}}.id={{value}}.lastchange_userid'.
- ' WHERE {{value}}.id={valueid}' );
- $sql->setInt( 'valueid',$this->valueid);
- $row = $sql->getRow();
-
- $this->text = $row['text' ];
- $this->pageid = intval($row['pageid' ]);
- $this->elementid = intval($row['elementid' ]);
- $this->languageid = intval($row['languageid' ]);
- $this->valueid = intval($row['id' ]);
- $this->linkToObjectId = intval($row['linkobjectid']);
- $this->number = intval($row['number' ]);
- $this->date = intval($row['date' ]);
-
- $this->active = ( $row['active' ]=='1' );
- $this->publish = ( $row['publish']=='1' );
-
- $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
- $this->lastchangeUserId = intval($row['lastchange_userid' ]);
- $this->lastchangeUserName = $row['lastchange_username'];
- }
-
-
- /**
- * Alle Versionen des aktuellen Inhaltes werden ermittelt
- * @return Array
- */
- function getVersionList()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{value}}.*,{{user}}.name as lastchange_username'.
- ' FROM {{value}}'.
- ' LEFT JOIN {{user}} ON {{user}}.id={{value}}.lastchange_userid'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}'.
- ' ORDER BY lastchange_date' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- $list = array();
- foreach($sql->getAll() as $row )
- {
- $val = new Value();
- $val->valueid = $row['id'];
-
- $val->text = $row['text'];
- $val->valueid = intval($row['id'] );
- $val->linkToObjectId = intval($row['linkobjectid']);
- $val->number = intval($row['number' ]);
- $val->date = intval($row['date' ]);
-
- $val->active = ( $row['active' ]=='1' );
- $val->publish = ( $row['publish']=='1' );
-
- $val->lastchangeTimeStamp = intval($row['lastchange_date' ]);
- $val->lastchangeUserId = intval($row['lastchange_userid' ]);
- $val->lastchangeUserName = $row['lastchange_username'];
- $list[] = $val;
- }
- return $list;
- }
-
-
- /**
- * Die Anzahl der Versionen des aktuellen Inhaltes wird ermittelt
- * @return Array
- */
- function getCountVersions()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT COUNT(*) FROM {{value}}'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- return $sql->getOne();
- }
-
-
- function getLastChangeTime()
- {
- $db = db_connection();
-
- $sql = $db->sql(
-<<<SQL
- SELECT lastchange_date FROM {{value}}
- WHERE elementid ={elementid}
- AND pageid ={pageid}
- AND languageid={languageid}
- ORDER BY id DESC
-SQL
- );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- return $sql->getOne();
- }
-
-
-
- /**
- * Inhalt freigeben
- */
- function release()
- {
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{value}}'.
- ' SET publish=0'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- $sql->query();
-
- $sql = $db->sql( 'UPDATE {{value}}'.
- ' SET publish=1'.
- ' WHERE active = 1'.
- ' AND elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- $sql->query();
- }
-
- /**
- * Inhalt speichern
- */
- function save()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = $db->sql( 'UPDATE {{value}}'.
- ' SET active=0'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- $sql->query();
-
- if ( $this->publish )
- {
- // Wenn Inhalt sofort veroeffentlicht werden kann, dann
- // alle anderen Inhalte auf nicht-veroeffentlichen stellen
- $sql = $db->sql( 'UPDATE {{value}}'.
- ' SET publish=0'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
-
- $sql->query();
- }
-
- // Naechste ID aus Datenbank besorgen
- $sql = $db->sql('SELECT MAX(id) FROM {{value}}');
- $this->valueid = intval($sql->getOne())+1;
-
- $sql = $db->sql( <<<SQL
-INSERT INTO {{value}}
- (id ,linkobjectid ,text ,number ,date ,elementid ,pageid ,languageid ,active,publish ,lastchange_date ,lastchange_userid )
- VALUES ({valueid},{linkobjectid},{text},{number},{date},{elementid},{pageid},{languageid},1 ,{publish},{lastchange_date},{lastchange_userid})
-SQL
- );
- $sql->setInt( 'valueid' ,$this->valueid );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid );
-
- if ( intval($this->linkToObjectId)==0)
- $sql->setNull ( 'linkobjectid' );
- else $sql->setInt ( 'linkobjectid',$this->linkToObjectId );
-
- if ( $this->text == '' )
- $sql->setNull ( 'text' );
- else $sql->setString( 'text',$this->text );
-
- if ( intval($this->number)==0)
- $sql->setNull ( 'number' );
- else $sql->setInt ( 'number',$this->number );
-
- if ( intval($this->date)==0)
- $sql->setNull ( 'date' );
- else $sql->setInt ( 'date',$this->date );
-
- $sql->setBoolean( 'publish' ,$this->publish );
- $sql->setInt ( 'lastchange_date' ,now() );
- $user = \Session::getUser();
- $sql->setInt ( 'lastchange_userid',$user->userid );
-
- $sql->query();
-
- // Nur ausfuehren, wenn in Konfiguration aktiviert.
- $limit = config('content','revision-limit');
- if ( isset($limit['enabled']) && $limit['enabled'] )
- $this->checkLimit();
- }
-
-
- /**
- * Pruefen, ob maximale Anzahl von Versionen erreicht.
- * In diesem Fall die zu alten Versionen l�schen.
- */
- function checkLimit()
- {
- $limit = config('content','revision-limit');
-
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
- SELECT id FROM {{value}}
- WHERE elementid = {elementid}
- AND pageid = {pageid}
- AND languageid = {languageid}
- AND active = 0
- AND publish = 0
- ORDER BY id
-SQL
- );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid );
- $values = $sql->getCol();
-
- if ( count($values) > $limit['min-revisions'] )
- {
- $sql = $db->sql( <<<SQL
- DELETE FROM {{value}}
- WHERE elementid = {elementid}
- AND pageid = {pageid}
- AND languageid = {languageid}
- AND active = 0
- AND publish = 0
- AND lastchange_date < {min_date}
- AND id < {min_id}
-SQL
- );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $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();
- }
-
- if ( count($values) > $limit['max-revisions'] )
- {
- $sql = $db->sql( <<<SQL
- DELETE FROM {{value}}
- WHERE elementid = {elementid}
- AND pageid = {pageid}
- AND languageid = {languageid}
- AND active = 0
- AND publish = 0
- AND lastchange_date < {min_date}
- AND id < {min_id}
-SQL
- );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $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();
- }
- }
-
-
-
- /**
- * Diesen Inhalt loeschen
- */
- function delete()
- {
- $db = db_connection();
- $sql = $db->sql( 'DELETE * FROM {{value}}'.
- ' WHERE elementid ={elementid}'.
- ' AND pageid ={pageid}'.
- ' AND languageid={languageid}' );
- $sql->setInt( 'elementid' ,$this->element->elementid );
- $sql->setInt( 'pageid' ,$this->pageid );
- $sql->setInt( 'languageid',$this->languageid);
- $row = $sql->getRow();
- }
-
-
- /**
- * Hier findet die eigentliche Bereitstellung des Inhaltes statt, zu
- * jedem Elementtyp wird ein Inhalt ermittelt.
- *
- * @return void (aber Eigenschaft 'value' wird gesetzt).
- */
- function generate()
- {
- global $conf;
-
- if ( intval($this->valueid)==0 )
- $this->load();
-
- $inhalt = '';
- $raw = false;
-
- global $conf;
-
- if ( $conf['cache']['enable_cache'] && is_file( $this->tmpfile() ))
- {
- $this->value = implode('',file($this->tmpfile() )); // from cache.
- return;
- }
-
- // Inhalt ist mit anderer Seite verkn�pft.
- if ( in_array($this->element->type,array('text','longtext','date','number')) && intval($this->linkToObjectId) != 0 && !$this->isLink )
- {
- $p = new Page( $this->linkToObjectId );
- $p->load();
-
- $v = new Value();
- $v->isLink = true;
- $v->pageid = $p->pageid;
- $v->page = $p;
- $v->simple = $this->simple;
- $v->element = $this->element;
- $v->languageid = $this->languageid;
- //$v->modelid = $this->modelid;
- $v->load();
- $v->generate();
- $this->value = $v->value;
- return;
- }
-
- switch( $this->element->type )
- {
- case 'list' : // nur wg. R�ckw�rtskompabilit�t.
- case 'insert':
-
- $objectid = $this->linkToObjectId;
-
- if ( intval($objectid) == 0 )
- $objectid = $this->element->defaultObjectId;
-
- if ( ! Object::available( $objectid) )
- return;
-
- $object = new Object( $objectid );
- $object->objectLoadRaw();
-
- if ( $object->isFolder )
- {
- if ( $this->simple )
- {
- $f = new Folder( $objectid );
- $f->load();
- $inhalt = $f->name;
- unset( $f );
- }
- else
- {
- if ( $objectid != $this->page->objectid ) // Rekursion vermeiden
- {
- $f = new Folder( $objectid );
- foreach( $f->getObjectIds() as $oid )
- {
- if ( $oid != $this->page->objectid ) // Rekursion vermeiden
- {
- switch( $this->element->subtype )
- {
- case '':
- case 'inline':
- $o = new Object( $oid );
- $o->load();
- switch( $o->getType() )
- {
- case OR_TYPE_PAGE:
- $p = new Page( $oid );
- $p->enclosingObjectId = $this->page->id;
- $p->public = $this->page->public;
- $p->up_path = $this->page->up_path();
- $p->modelid = $this->page->modelid;
- $p->languageid = $this->languageid;
- $p->mime_type = $this->page->mimeType();
- $p->load();
- $p->generate();
- $inhalt .= $p->value;
- unset( $p );
- break;
- case OR_TYPE_LINK:
- $l = new Link( $oid );
- $l->load();
- if ( $l->isLinkToObject )
- {
- $op = new Object( $l->linkedObjectId );
- $op->load();
- if ( $op->isPage )
- {
- $p = new Page( $l->linkedObjectId );
- $p->enclosingObjectId = $this->page->id;
- $p->public = $this->page->public;
- $p->up_path = $this->page->up_path();
- $p->modelid = $this->page->modelid;
- $p->languageid = $this->languageid;
- $p->load();
- $p->generate();
- $inhalt .= $p->value;
- unset( $p );
- }
- }
- break;
- }
- break;
-
- case 'ssi':
- $inhalt .= '<!--#include virtual="'.$this->page->path_to_object($oid).'" -->';
- break;
-
- default:
- $inhalt = '?'.$this->element->subtype.'?';
- }
- }
- else die('FATAL: recursion detected');
- }
- }
- else die('FATAL: recursion detected');
- }
- }
- elseif ( $object->isPage )
- {
- if ( $this->simple )
- {
- $p = new Page( $objectid );
- $p->load();
- $inhalt = $p->name;
- unset( $p );
- }
- else
- {
- if ( $objectid != $this->page->objectid ) // Rekursion vermeiden
- {
- switch( $this->element->subtype )
- {
- case '':
- case 'inline':
- $p = new Page( $objectid );
- $p->enclosingObjectId = $this->page->id;
- $p->public = $this->page->public;
- $p->up_path = $this->page->up_path();
- $p->modelid = $this->page->modelid;
- $p->languageid = $this->languageid;
- $p->mime_type = $this->page->mimeType();
- $p->load();
- $p->generate();
- $inhalt = $p->value;
- unset( $p );
- break;
-
- case 'ssi':
- $inhalt = '<!--#include virtual="'.$this->page->path_to_object($objectid).'" -->';
- break;
-
- default:
- $inhalt = '?'.$this->element->subtype.'?';
- break;
- }
- }
- else die('FATAL: recursion detected');
- }
- }
-
- if ( $this->simple )
- {
- $inhalt = strip_tags( $inhalt );
- $inhalt = str_replace( "\n",'',$inhalt );
- $inhalt = str_replace( "\r",'',$inhalt );
- }
-
- break;
-
-
- case 'link':
-
- $objectid = $this->linkToObjectId;
- if ( intval($objectid) == 0 )
- $objectid = $this->element->defaultObjectId;
-
- if ( $objectid==0 )
- {
- // Link noch nicht gefuellt
- $inhalt = '';
- }
- elseif ( ! Object::available($objectid) )
- {
- $inhalt = $this->simple?'-':'';
- }
- elseif ( $this->simple )
- {
- $o = new Object( $objectid );
- $o->load();
- $inhalt = $o->name;
- }
- elseif ($this->element->subtype == 'image_data_uri' )
- {
- $file = new File($objectid);
- $file->load();
- $inhalt = 'data:'.$file->mimeType().';base64,'.base64_encode($file->loadValue());
- }
- else
- {
- $inhalt = $this->page->path_to_object( $objectid );
- }
-
- break;
-
-
- case 'copy':
-
- list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
-
- if ( empty($targetElementName) )
- break;
-
- $element = new Element();
- $element->name = $linkElementName;
- $element->load();
-
- if ( intval($element->elementid)==0 )
- break;
-
- $linkValue = new Value();
- $linkValue->elementid = $element->elementid;
- $linkValue->element = $element;
- $linkValue->pageid = $this->pageid;
- $linkValue->page = $this->page;
- $linkValue->simple = $this->simple;
- $linkValue->languageid = $this->languageid;
- $linkValue->load();
-
- if ( !Object::available( $linkValue->linkToObjectId ) )
- break;
-
- $linkedPage = new Page( $linkValue->linkToObjectId );
- $linkedPage->load();
-
- $linkedPageTemplate = new Template( $linkedPage->templateid );
- $targetElementId = array_search( $targetElementName, $linkedPageTemplate->getElementNames() );
-
- if ( intval($targetElementId)==0 )
- break;
-
- $targetValue = new Value();
- $targetValue->elementid = $targetElementId;
- $targetValue->element = new Element($targetElementId);
- $targetValue->element->load();
- $targetValue->pageid = $linkedPage->pageid;
- $targetValue->page = $linkedPage;
- $targetValue->simple = $this->simple;
- $targetValue->generate();
-
- $inhalt = $targetValue->value;
-
- break;
-
-
- case 'linkinfo':
-
- @list( $linkElementName, $name ) = explode('%',$this->element->name);
- if ( is_null($name) )
- break;
-
- $template = new Template( $this->page->templateid );
- $elementId = array_search( $linkElementName, $template->getElementNames() );
-
-
- $element = new Element($elementId);
- $element->load();
-
- $linkValue = new Value();
- $linkValue->elementid = $element->elementid;
- $linkValue->element = $element;
- $linkValue->pageid = $this->pageid;
- $linkValue->languageid = $this->languageid;
- $linkValue->load();
-
- $objectid = $linkValue->linkToObjectId;
-
- if ( intval($objectid) == 0 )
- $objectid = $linkValue->element->defaultObjectId;
-
- if ( !Object::available( $objectid ) )
- break;
-
- $linkedObject = new Object( $objectid );
- $linkedObject->languageid = $this->languageid;
- $linkedObject->load();
-
- switch( $this->element->subtype )
- {
- case 'width':
- $f = new File( $objectid );
- $f->load();
- if ( $f->isImage() )
- {
- $f->getImageSize();
- $inhalt = $f->width;
- }
- unset($f);
- break;
-
- case 'height':
- $f = new File( $objectid );
- $f->load();
- if ( $f->isImage() )
- {
- $f->getImageSize();
- $inhalt = $f->height;
- }
- unset($f);
- break;
-
- case 'id':
- $inhalt = $objectid;
- break;
-
- case 'name':
- $inhalt = $linkedObject->name;
- break;
-
- case 'description':
- $inhalt = $linkedObject->description;
- break;
-
- case 'create_user_desc':
- $user = $linkedObject->createUser;
- try
- {
- $user->load();
- $inhalt = $user->desc;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'create_user_fullname':
- $user = $linkedObject->createUser;
- try
- {
- $user->load();
- $inhalt = $user->fullname;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'create_user_mail':
- $user = $linkedObject->createUser;
- try
- {
- $user->load();
- $inhalt = $user->mail;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'create_user_tel':
- $user = $linkedObject->createUser;
- try
- {
- $user->load();
- $inhalt = $user->tel;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'create_user_username':
- $user = $linkedObject->createUser;
- try
- {
- $user->load();
- $inhalt = $user->name;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'lastch_user_desc':
- $user = $linkedObject->lastchangeUser;
- try
- {
- $user->load();
- $inhalt = $user->desc;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'lastch_user_fullname':
- $user = $linkedObject->lastchangeUser;
- try
- {
- $user->load();
- $inhalt = $user->fullname;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'lastch_user_mail':
- $user = $linkedObject->lastchangeUser;
- try
- {
- $user->load();
- $inhalt = $user->mail;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'lastch_user_tel':
- $user = $linkedObject->lastchangeUser;
- try
- {
- $user->load();
- $inhalt = $user->tel;
- }
- catch( ObjectNotFoundException $e )
- {
- }
-
- break;
-
- case 'lastch_user_username':
- $user = $linkedObject->lastchangeUser;
- try
- {
- $user->load();
- $inhalt = $user->name;
- }
- catch( ObjectNotFoundException $e )
- {
- }
- break;
-
- case 'mime-type':
- if ( $linkedObject->isFile )
- {
- $f = new File( $objectid );
- $f->load();
- $inhalt = $f->mimeType();
- unset($f);
- }
- break;
-
- case 'filename':
- $inhalt = $linkedObject->filename();
- break;
-
- case 'full_filename':
- $inhalt = $linkedObject->full_filename();
- break;
-
- default:
- $inhalt = '';
- Logger::error('subtype for linkinfo not implemented:'.$this->element->subtype);
- }
-
- break;
-
- case 'linkdate':
-
- @list( $linkElementName, $name ) = explode('%',$this->element->name);
- if ( is_null($name) )
- break;
-
- $template = new Template( $this->page->templateid );
- $elementId = array_search( $linkElementName, $template->getElementNames() );
-
- $element = new Element($elementId);
- $element->load();
-
- $linkValue = new Value();
- $linkValue->elementid = $element->elementid;
- $linkValue->element = $element;
- $linkValue->pageid = $this->pageid;
- $linkValue->languageid = $this->languageid;
- $linkValue->load();
-
- $objectid = $linkValue->linkToObjectId;
-
- if ( intval($objectid) == 0 )
- $objectid = $linkValue->element->defaultObjectId;
-
- if ( !Object::available( $objectid ) )
- break;
-
- $linkedObject = new Object( $objectid );
- $linkedObject->load();
-
-
- switch( $this->element->subtype )
- {
- case 'date_published':
- // START_TIME wird zu Beginn im Controller gesetzt.
- // So erh�lt jede Datei das gleiche Ver�ffentlichungsdatum.
- $date = START_TIME;
- break;
-
- case 'date_saved':
- $date = $linkedObject->lastchangeDate;
- break;
-
- case 'date_created':
- $date = $linkedObject->createDate;
- break;
-
- default:
- Logger::warn('element:'.$this->element->name.', '.
- 'type:'.$this->element->type.', '.
- 'unknown subtype:'.$this->element->subtype);
- $date = START_TIME;
- }
-
- if ( strpos($this->element->dateformat,'%')!==FALSE )
- $inhalt = strftime( $this->element->dateformat,$date );
- else
- $inhalt = date ( $this->element->dateformat,$date );
- break;
-
- case 'longtext':
- case 'text':
- case 'select':
-
- $inhalt = $this->text;
-
- // Wenn Inhalt leer, dann versuchen, den Inhalt der Default-Sprache zu laden.
- if ( $inhalt == '' && $conf['content']['language']['use_default_language'] )
- {
- $project = \Session::getProject();
- $this->languageid = $project->getDefaultLanguageId();
- $this->load();
- $inhalt = $this->text;
- }
-
- // Wenn Inhalt leer, dann Vorbelegung verwenden
- if ( $inhalt == '' )
- $inhalt = $this->element->defaultText;
-
- // Wenn HTML nicht erlaubt und Wiki-Formatierung aktiv, dann einfache HTML-Tags in Wiki umwandeln
- if ( !$this->element->html && $this->element->wiki && $conf['editor']['wiki']['convert_html'] && $this->page->mimeType()=='text/html' )
- $inhalt = Text::html2Wiki( $inhalt );
-
- // Wenn Wiki-Formatierung aktiv, dann BB-Code umwandeln
- if ( $this->element->wiki && $conf['editor']['wiki']['convert_bbcode'] )
- $inhalt = Text::bbCode2Wiki( $inhalt );
-
- // Wenn HTML nicht erlaubt ist, dann die HTML-Tags ersetzen
- if ( !$this->element->html && !$this->element->wiki && $this->page->mimeType()=='text/html')
- $inhalt = Text::encodeHtml( $inhalt );
-
- // Wenn HTML nicht erlaubt ist, dann Sonderzeichen in HTML �bersetzen
- if ( !$this->element->wiki && !$this->element->wiki && $this->page->mimeType()=='text/html' )
- $inhalt = Text::encodeHtmlSpecialChars( $inhalt );
-
- // Schnellformatierung ('Wiki') durchfuehren
- if ( $this->element->wiki )
- {
- $transformer = new Transformer();
- $transformer->text = $inhalt;
- $transformer->page = $this->page;
- $transformer->element = $this->element;
-
- $transformer->transform();
- $inhalt = $transformer->text;
- }
-
- if ( $this->page->simple )
- {
- $inhalt = strip_tags( $inhalt );
- $inhalt = str_replace( "\n",'',$inhalt );
- $inhalt = str_replace( "\r",'',$inhalt );
- }
-
- // "__OID__nnn__" ersetzen durch einen richtigen Link
- foreach( Text::parseOID($inhalt) as $oid=>$t )
- {
- $url = $this->page->path_to_object($oid);
- $inhalt = str_replace($t,'"'.$url.'"',$inhalt);
- }
-
- break;
-
-
- // Zahl
- //
- // wird im entsprechenden Format angezeigt.
- case 'number':
-
- if ( $this->number == 0 )
- {
- // Zahl ist gleich 0, dann Default-Text
- $inhalt = $this->element->defaultText;
- break;
- }
-
- $number = $this->number / pow(10,$this->element->decimals);
- $inhalt = number_format( $number,$this->element->decimals,$this->element->decPoint,$this->element->thousandSep );
-
- break;
-
-
- // Datum
- case 'date':
-
- $date = $this->date;
-
- if ( intval($date) == 0 )
- {
- // Datum wurde noch nicht eingegeben
- $inhalt = $this->element->defaultText;
- break;
- }
-
- // Datum gemaess Elementeinstellung formatieren
- if ( strpos($this->element->dateformat,'%')!==FALSE )
- $inhalt = strftime( $this->element->dateformat,$date );
- else
- $inhalt = date ( $this->element->dateformat,$date );
- break;
-
-
- // Programmcode (PHP)
- case 'code':
-
- if ( $this->page->simple )
- break;
-
- // Die Ausführung von benutzer-erzeugtem PHP-Code kann in der
- // Konfiguration aus Sicherheitsgründen deaktiviert sein.
- if ( $conf['security']['disable_dynamic_code'] )
- break;
-
- $this->page->load();
-
- // Das Ausführen geschieht über die Klasse "Code".
- // In dieser wird der Code in eine Datei geschrieben und
- // von dort eingebunden.
- $code = new Code();
- $code->page = &$this->page;
- $code->setObjectId( $this->page->objectid );
- $code->delOutput();
- $code->code = $this->element->code;
-
- // Jetzt ausfuehren des temporaeren PHP-Codes
- $code->execute();
-
- // Ausgabe ermitteln.
- $inhalt = $code->getOutput();
-
- break;
-
-
- // Makros (dynamische Klassen)
- case 'dynamic':
-
- if ( $this->page->simple )
- break;
-
- $this->page->load();
- $className = $this->element->subtype;
- $fileName = OR_DYNAMICCLASSES_DIR.$className.'.class.php';
- if ( is_file( $fileName ) )
- {
- // Fuer den Fall, dass ein Makro mehrmals pro Vorlage auftritt
- if ( !class_exists($className) )
- require( $fileName );
-
- if ( class_exists($className) )
- {
- $macro = new $className;
- $macro->page = &$this->page;
-
- if ( method_exists( $macro,'execute' ) )
- {
- //$$macro->delOutput();
- $macro->objectid = $this->page->objectid;
- $macro->page = &$this->page;
-
- foreach( $this->element->getDynamicParameters() as $param_name=>$param_value )
- {
- if ( $param_value[0]=='{')
- {
- $elName = substr($param_value,1,strpos($param_value,'}')-1);
- $template = new Template($this->page->templateid);
- $elements = $template->getElementNames();
- $elementid = array_search($elName,$elements);
-
- $value = new Value();
- $value->elementid = $elementid;
- $value->element = new Element( $elementid );
- $value->element->load();
- $value->pageid = $this->page->pageid;
- $value->languageid = $this->page->languageid;
- $value->load();
-
- $param_value = $value->getRawValue();
- }
- if ( isset( $macro->$param_name ) )
- {
- Logger::debug("Setting parameter for Macro-class $className, ".$param_name.':'.$param_value );
-
- // Die Parameter der Makro-Klasse typisiert setzen.
- if ( is_int($macro->$param_name) )
- $macro->$param_name = intval($param_value);
- elseif ( is_array($macro->$param_name) )
- $macro->$param_name = explode(',',$param_value);
- else
- $macro->$param_name = $param_value;
-
- }
- else
- {
- if ( !$this->publish )
- $inhalt .= "WARNING: Unknown parameter $param_name in macro $className\n";
- }
- }
-
- $macro->execute();
- $inhalt .= $macro->getOutput();
- }
- else
- {
- Logger::warn('element:'.$this->element->name.', '.
- 'class:'.$className.', no method: execute()');
- if ( !$this->publish )
- $inhalt = lang('ERROR_IN_ELEMENT').' (missing method: execute())';
- }
- }
- else
- {
- Logger::warn('element:'.$this->element->name.', '.
- 'class not found:'.$className);
- if ( !$this->publish )
- $inhalt = lang('ERROR_IN_ELEMENT').' (class not found:'.$className.')';
- }
- }
- else
- {
- Logger::warn('element:'.$this->element->name.', '.
- 'file not found:'.$fileName);
- if ( !$this->publish )
- $inhalt = lang('ERROR_IN_ELEMENT').' (file not found:'.$fileName.')';
-
- }
-
- // Wenn HTML-Ausgabe, dann Sonderzeichen in HTML �bersetzen
- if ( $this->page->isHtml() )
- $inhalt = Text::encodeHtmlSpecialChars( $inhalt );
-
- break;
-
-
- // Info-Feld als Datum
- case 'infodate':
-
- if ( $this->page->simple )
- break;
-
- switch( $this->element->subtype )
- {
- case 'date_published':
- // START_TIME wird zu Beginn im Controller gesetzt.
- // So erh�lt jede Datei das gleiche Ver�ffentlichungsdatum.
- $date = START_TIME;
- break;
-
- case 'date_saved':
- $date = $this->page->lastchangeDate;
- break;
-
- case 'date_created':
- $date = $this->page->createDate;
- break;
-
- default:
- Logger::warn('element:'.$this->element->name.', '.
- 'type:'.$this->element->type.', '.
- 'unknown subtype:'.$this->element->subtype);
- if ( !$this->publish )
- $inhalt = lang('ERROR_IN_ELEMENT');
- }
-
- if ( strpos($this->element->dateformat,'%')!==FALSE )
- $inhalt = strftime( $this->element->dateformat,$date );
- else
- $inhalt = date ( $this->element->dateformat,$date );
-
- break;
-
-
- // Info-Feld
- case 'info':
-
- if ( $this->page->simple )
- break;
-
- switch( $this->element->subtype )
- {
- case 'db_id':
- $inhalt = $SESS['dbid'];
- break;
- case 'db_name':
- $inhalt = $conf['database_'.$SESS['dbid']]['description'];
- break;
- case 'project_id':
- $inhalt = $this->page->projectid;
- break;
- case 'project_name':
- $project = new Project( $this->page->projectid );
- $project->load();
- $inhalt = $project->name;
- break;
- case 'language_id':
- $inhalt = $this->page->languageid;
- break;
- case 'language_iso':
- $language = new Language( $this->page->languageid );
- $language->load();
- $inhalt = $language->isoCode;
- break;
- case 'language_name':
- $language = new Language( $this->page->languageid );
- $language->load();
- $inhalt = $language->name;
- break;
- case 'page_id':
- $inhalt = $this->page->objectid;
- break;
- case 'page_name':
- $inhalt = $this->page->name;
- break;
- case 'page_desc':
- $inhalt = $this->page->desc;
- break;
- case 'page_fullfilename':
- $inhalt = $this->page->full_filename();
- break;
- case 'page_filename':
- $inhalt = $this->page->filename();
- break;
- case 'page_extension':
- $inhalt = '';
- break;
- case 'edit_url':
- $raw = true;
- $db = \Session::getDatabase();
- $inhalt = Html::url('index','object',$this->page->objectid,array('dbid'=>$db->id));
- break;
- case 'edit_fullurl':
- $raw = true;
- $inhalt = Http::getServer();
- $db = \Session::getDatabase();
- $params = array('dbid' =>$db->id,
- 'objectid' =>$this->page->objectid,
- 'modelid' =>$this->page->modelid,
- 'languageid'=>$this->page->languageid,
- 'elementid' =>$this->element->elementid );
- $inhalt .= '/'.basename(Html::url('index','object',$this->page->objectid,$params));
- break;
- case 'lastch_user_username':
- $user = $this->page->lastchangeUser;
- $user->load();
- $inhalt = $user->name;
- break;
- case 'lastch_user_fullname':
- $user = $this->page->lastchangeUser;
- $user->load();
- $inhalt = $user->fullname;
- break;
- case 'lastch_user_mail':
- $user = $this->page->lastchangeUser;
- $user->load();
- $inhalt = $user->mail;
- break;
- case 'lastch_user_desc':
- $user = $this->page->lastchangeUser;
- $user->load();
- $inhalt = $user->desc;
- break;
- case 'lastch_user_tel':
- $user = $this->page->lastchangeUser;
- $user->load();
- $inhalt = $user->tel;
- break;
-
- case 'create_user_username':
- $user = $this->page->createUser;
- $user->load();
- $inhalt = $user->name;
- break;
- case 'create_user_fullname':
- $user = $this->page->createUser;
- $user->load();
- $inhalt = $user->fullname;
- break;
- case 'create_user_mail':
- $user = $this->page->createUser;
- $user->load();
- $inhalt = $user->mail;
- break;
- case 'create_user_desc':
- $user = $this->page->createUser;
- $user->load();
- $inhalt = $user->desc;
- break;
- case 'create_user_tel':
- $user = $this->page->createUser;
- $user->load();
- $inhalt = $user->tel;
- break;
-
- case 'act_user_username':
- $user = new User($SESS['user']['id']);
- $user->load();
- $inhalt = $user->name;
- break;
- case 'act_user_fullname':
- $user = new User($SESS['user']['id']);
- $user->load();
- $inhalt = $user->fullname;
- break;
- case 'act_user_mail':
- $user = new User($SESS['user']['id']);
- $user->load();
- $inhalt = $user->mail;
- break;
- case 'act_user_desc':
- $user = new User($SESS['user']['id']);
- $user->load();
- $inhalt = $user->desc;
- break;
- case 'act_user_tel':
- $user = new User($SESS['user']['id']);
- $user->load();
- $inhalt = $user->tel;
- break;
- default:
- Logger::warn('element:'.$this->element->name.', '.
- 'type:'.$this->element->type.', '.
- 'unknown subtype:'.$this->element->subtype);
- // Keine Fehlermeldung in erzeugte Seite schreiben.
- }
-
- break;
-
- default:
- // Unbekannte Elementtypen darf es nicht geben, daher ERROR loggen.
- Logger::error('element:'.$this->element->name.', '.
- 'unknown type:'.$this->element->type);
-
- if ( !$this->publish )
- $inhalt = lang('ERROR_IN_ELEMENT').' ('.$this->element->name.':'.
- 'unknown type:'.$this->element->type.')';
-
- }
-
-
- switch( $this->element->type )
- {
- case 'longtext':
- case 'text':
- case 'select':
-
- if ( $conf['publish']['encode_utf8_in_html'] )
- // Wenn HTML-Ausgabe, dann UTF-8-Zeichen als HTML-Code uebersetzen
- if ( $this->page->isHtml() )
- $inhalt = translateutf8tohtml($inhalt);
- break;
-
- default:
- }
-
-
-
- if ( $this->page->icons && $this->element->withIcon && $this->page->isHtml() )
- {
- // Anklickbaren Link voranstellen.
- $iconLink = '<a href="javascript:parent.openNewAction(\''.$this->element->name.'\',\'pageelement\',\''.$this->page->objectid.'_'.$this->element->elementid.'\');" title="'.$this->element->desc.'"><img src="'.OR_THEMES_EXT_DIR.$conf['interface']['theme'].'/images/icon_el_'.$this->element->type.IMG_ICON_EXT.'" border="0" align="left"></a>';
- $inhalt = $iconLink.$inhalt;
- }
-
- $this->value = $inhalt;
-
-
- // Store in cache.
- $f = fopen( $this->tmpfile(),'w' );
- fwrite( $f,$this->value );
- fclose( $f );
- }
-
-
- /**
- * Es werden Objekte mit einem Inhalt gesucht.
- * @param String Suchbegriff
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByValue( $text )
- {
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{object}}.id FROM {{value}} '.
- ' LEFT JOIN {{page}} '.
- ' ON {{page}}.id={{value}}.pageid '.
- ' LEFT JOIN {{object}} '.
- ' ON {{object}}.id={{page}}.objectid '.
- ' WHERE {{value}}.text LIKE {text}'.
- ' AND {{value}}.languageid={languageid}'.
- ' ORDER BY {{object}}.lastchange_date DESC' );
-
- $sql->setInt ( 'languageid',$this->languageid );
- $sql->setString( 'text' ,'%'.$text.'%' );
- return $sql->getCol();
- }
-
-
- /**
- * Es werden Objekte mit einer UserId ermittelt
- * @param Integer Benutzer-Id der letzten ?nderung
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByLastChangeUserId( $userid )
- {
-
- $db = db_connection();
-
- $sql = $db->sql( 'SELECT {{object}}.id FROM {{value}} '.
- ' LEFT JOIN {{page}} '.
- ' ON {{page}}.id={{value}}.pageid '.
- ' LEFT JOIN {{object}} '.
- ' ON {{object}}.id={{page}}.objectid '.
- ' WHERE {{value}}.lastchange_userid={userid}'.
- ' AND {{value}}.languageid={languageid}'.
- ' ORDER BY {{object}}.lastchange_date DESC' );
- $sql->setInt ( 'languageid',$this->languageid );
- $sql->setInt ( 'userid' ,$userid );
-
- return $sql->getCol();
- }
-
-
-
- /**
- * Es wird das Objekt ermittelt, welches der Benutzer zuletzt ge�ndert hat.
- *
- * @return Integer Objekt-Id
- */
- public static function getLastChangedObjectByUserId( $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
-SELECT {{object}}.id
- FROM {{value}}
- LEFT JOIN {{page}}
- ON {{page}}.id={{value}}.pageid
- LEFT JOIN {{object}}
- ON {{object}}.id={{page}}.objectid
- WHERE {{value}}.lastchange_userid={userid}
- ORDER BY {{value}}.lastchange_date DESC
-SQL
-);
- $sql->setInt ( 'userid' ,$userid );
- return $sql->getOne();
- }
-
-
- /**
- * Es wird das Objekt ermittelt, welches der Benutzer zuletzt ge�ndert hat.
- *
- * @return Integer Objekt-Id
- */
- public static function getLastChangedObjectInProjectByUserId( $projectid, $userid )
- {
- $db = db_connection();
-
- $sql = $db->sql( <<<SQL
-SELECT {{object}}.id
- FROM {{value}}
- LEFT JOIN {{page}}
- ON {{page}}.id={{value}}.pageid
- LEFT JOIN {{object}}
- ON {{object}}.id={{page}}.objectid
- WHERE {{value}}.lastchange_userid={userid}
- AND {{object}}.projectid = {projectid}
- ORDER BY {{value}}.lastchange_date DESC
-SQL
-);
- $sql->setInt ( 'userid' ,$userid );
- $sql->setInt ( 'projectid' ,$projectid );
- return $sql->getOne();
- }
-
-
- /**
- * Ermittelt einen tempor�ren Dateinamen f�r diesen Inhalt.
- */
- function tmpfile()
- {
- $db = db_connection();
- $filename = Object::getTempFileName( array('db'=>$db->id,
- 'va'=>$this->valueid,
- 'el'=>$this->element->elementid,
- 'la'=>$this->languageid,
- 'm' =>$this->page->modelid,
- 'pu'=>intval($this->publish),
- 'si'=>intval($this->page->simple) ) );
- return $filename;
- }
-
-
-
- /**
- * Ermittelt den unbearbeiteten, "rohen" Inhalt.
- *
- * @return Inhalt
- */
- public function getRawValue()
- {
- switch( $this->element->type )
- {
- case 'link':
- return $this->linkToObjectId;
-
- case 'date';
- return $this->date;
-
- default:
- return $this->text;
- }
- }
-}-
\ No newline at end of file
diff --git a/model/include.inc.php b/model/include.inc.php
@@ -1,22 +0,0 @@
-<?php
-namespace cms\model;
-
-// Diese Objekte stehen zeitweise in der Sitzung, daher muessen dieser immer geparst werden.
-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/cms-core/action/.htaccess b/modules/cms-core/action/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/modules/cms-core/action/Action.class.php b/modules/cms-core/action/Action.class.php
@@ -0,0 +1,781 @@
+<?php
+
+namespace {
+
+ class ObjectNotFoundException extends Exception
+ {
+ }
+
+
+ define('OR_NOTICE_OK', 'ok');
+ define('OR_NOTICE_WARN', 'warning');
+ define('OR_NOTICE_ERROR', 'error');
+
+ define('OR_FILTER_ALPHA', 'abc');
+ define('OR_FILTER_ALPHANUM', 'abc123');
+ define('OR_FILTER_FILENAME', 'file');
+ define('OR_FILTER_MAIL', 'mail');
+ define('OR_FILTER_TEXT', 'text');
+ define('OR_FILTER_FULL', 'full');
+ define('OR_FILTER_NUMBER', '123');
+ define('OR_FILTER_RAW', 'raw');
+ define('OR_FILTER_ALL', 'all');
+
+
+}
+
+
+namespace cms\action {
+
+ use cms\model\User;
+ use \DomainException;
+ use \Html;
+ use \Session;
+use \Logger;
+use \Http;
+ use \template_engine\TemplateEngine;
+ use \Text;
+ use \XML;
+use \JSON;
+use \Exception;
+use \LogicException;
+
+// 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.
+
+
+
+
+
+ /**
+ * Eltern-Klasse fuer alle Actions.
+ *
+ * Diese Klasse stellt grundlegende action-uebergreifende Methoden
+ * bereit.
+ * Dient als Ueberklasse fuer alle abgeleiteten Action-Klassen in
+ * diesem Package bzw. Verzeichnis.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ * @abstract
+ */
+ class Action
+ {
+ public $db;
+ public $actionName;
+ public $subActionName;
+ public $actionClassName;
+ public $writable;
+
+ public $publishing;
+ public $refresh;
+
+ protected $templateVars = Array();
+
+ /**
+ * Aktuell angemeldeter Benutzer.<br>
+ * Wird in der Funktion "init()" gesetzt.
+ *
+ * @var Object Benutzer
+ */
+ var $currentUser;
+
+
+ protected function setStyle($style)
+ {
+ $this->setControlVar("new_style", $style);
+ }
+
+
+ function nextView($viewName)
+ {
+ $this->setControlVar("next_view", $viewName);
+ }
+
+
+ /**
+ * Wird durch das Controller-Skript (do.php) nach der Kontruierung des Objektes aufgerufen.
+ * So koennen Unterklassen ihren eigenen Kontruktor besitzen, ohne den Superkontruktor
+ * (=diese Funktion) aufrufen zu m�ssen.
+ */
+ public function init()
+ {
+ global $conf;
+ $this->writable = !$conf['security']['readonly'];
+ $this->publishing = !$conf['security']['nopublish'];
+ $this->currentUser = Session::getUser();
+
+ $this->templateVars['errors'] = array();
+ $this->templateVars['notices'] = array();
+ $this->templateVars['control'] = array();
+ $this->templateVars['output'] = array();
+
+ header('Content-Language: ' . $conf['language']['language_code']);
+
+ $this->refresh = false;
+ }
+
+
+ /**
+ * Liest eine Session-Variable
+ *
+ * @param String $varName Schl�ssel
+ * @return mixed
+ */
+ protected function getSessionVar($varName)
+ {
+ global $SESS;
+
+ if (!isset($SESS[$varName]))
+ return '';
+ else return $SESS[$varName];
+ }
+
+
+ /**
+ * Setzt eine Session-Variable
+ *
+ * @param string $varName Schluessel
+ * @param mixed $value Inhalt
+ * @return mixed
+ */
+ protected function setSessionVar($varName, $value)
+ {
+ global $SESS;
+
+ $SESS[$varName] = $value;
+ }
+
+
+ /**
+ * Ermittelt den Inhalt der gew�nschten Request-Variablen.
+ * Falls nicht vorhanden, wird "" zur�ckgegeben.
+ *
+ * @param String $varName Schl�ssel
+ * @return String Inhalt
+ */
+ protected function getRequestVar($varName, $transcode = OR_FILTER_FULL)
+ {
+ global $REQ;
+
+ if (!isset($REQ[$varName]))
+ return '';
+
+
+ switch ($transcode) {
+ case OR_FILTER_ALPHA:
+ $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+ break;
+
+ case OR_FILTER_ALPHANUM:
+ $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,_-!?%&/()';
+ break;
+
+ case OR_FILTER_FILENAME:
+ // RFC 1738, Section 2.2:
+ // Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
+ // reserved characters used for their reserved purposes may be used
+ // unencoded within a URL.
+ $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$-_.+!*(),' . "'";
+ break;
+
+ case OR_FILTER_MAIL:
+ $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-@';
+ break;
+
+ case OR_FILTER_TEXT:
+ case OR_FILTER_FULL:
+ case OR_FILTER_ALL:
+ // Ausfiltern von Control-Chars ( ASCII < 32 außer CR,LF) und HTML (<,>)
+ $white = '';
+ $white .= chr(10) . chr(13); // Line-Feed, Carriage-Return
+ for ($i = 32; $i <= 59; $i++) $white .= chr($i); // Zahlen
+ // 60: '<'
+ $white .= chr(61);
+ // 62: '>'
+ for ($i = 63; $i <= 126; $i++) $white .= chr($i); // abc
+ for ($i = 128; $i <= 255; $i++) $white .= chr($i); // Sonderzeichen incl. UTF-8, UTF-16 (beginnen mit Bit 1)
+ break;
+
+ case OR_FILTER_NUMBER:
+ $white = '1234567890.';
+ break;
+
+ case OR_FILTER_RAW:
+ return $REQ[$varName];
+
+ default:
+ Http::serverError('Unknown request filter', 'not found: ' . $transcode);
+ return '?';
+ }
+
+ $value = $REQ[$varName];
+ $newValue = Text::clean($value, $white);
+
+ if (strlen($newValue) != strlen($value))
+ $this->addNotice('', '', 'UNEXPECTED_CHARS', OR_NOTICE_WARN);
+
+ return $newValue;
+ }
+
+
+ /**
+ * Ermittelt, ob der aktuelle Request eine Variable mit dem
+ * angegebenen Namen enth�lt.
+ *
+ * @param String $varName Schl�ssel
+ * @return boolean true, falls vorhanden.
+ */
+ protected function hasRequestVar($varName)
+ {
+ global $REQ;
+
+ return (isset($REQ[$varName]) && (!empty($REQ[$varName]) || $REQ[$varName] == '0'));
+ }
+
+
+ /**
+ * Ermittelt die aktuelle Id aus dem Request.<br>
+ * Um welche ID es sich handelt, ist abh�ngig von der Action.
+ *
+ * @return Integer
+ */
+ protected function getRequestId()
+ {
+ if ($this->hasRequestVar('idvar'))
+ return intval($this->getRequestVar($this->getRequestVar('idvar')));
+ else
+ return intval($this->getRequestVar(REQ_PARAM_ID));
+ }
+
+
+ /**
+ * Setzt eine Variable f�r die Oberfl�che.
+ *
+ * @param String $varName Schl�ssel
+ * @param Mixed $value
+ */
+ protected function setTemplateVar($varName, $value)
+ {
+ $this->templateVars['output'][$varName] = $value;
+ }
+
+
+ /**
+ * Setzt eine Variable f�r die Oberfl�che.
+ *
+ * @param String $varName Schl�ssel
+ * @param Mixed $value
+ */
+ protected function setControlVar($varName, $value)
+ {
+ $this->templateVars['control'][$varName] = $value;
+ }
+
+
+ /**
+ * Setzt eine Liste von Variablen f�r die Oberfl�che.
+ *
+ * @param array $varList Assoziatives Array
+ */
+ protected function setTemplateVars($varList)
+ {
+ foreach ($varList as $name => $value) {
+ $this->setTemplateVar($name, $value);
+ }
+ }
+
+
+ /**
+ * F�gt einen Validierungsfehler hinzu.
+ *
+ * @param String $name Name des validierten Eingabefeldes
+ * @param String Textschl�ssel der Fehlermeldung (optional)
+ */
+ protected function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array())
+ {
+ if (!empty($message))
+ $this->addNotice('', '', $message, OR_NOTICE_ERROR, $vars, $log);
+
+ $this->templateVars['errors'][] = $name;
+ }
+
+
+ public function handleResult($result)
+ {
+ // TODO -
+ }
+
+ /**
+ * F�gt ein Meldung hinzu.
+ *
+ * @param String $type Typ des Objektes, zu dem diese Meldung geh�rt.
+ * @param String $name Name des Objektes, zu dem diese Meldung geh�rt.
+ * @param String $text Textschl�ssel der Fehlermeldung (optional)
+ * @param String $status Einer der Werte OR_NOTICE_(OK|WARN|ERROR)
+ * @param array $vars Variablen f�r den Textschl�ssel
+ * @param array $log Weitere Hinweistexte f�r diese Meldung.
+ */
+ protected function addNotice($type, $name, $text, $status = OR_NOTICE_OK, $vars = array(), $log = array())
+ {
+ if ($status === true)
+ $status = OR_NOTICE_OK;
+ elseif ($status === false)
+ $status = OR_NOTICE_ERROR;
+
+ $this->templateVars['notice_status'] = $status;
+ $this->templateVars['status'] = $status;
+ $this->templateVars['success'] = ($status == OR_NOTICE_ERROR ? 'false' : 'true');
+
+ if ($status == OR_NOTICE_OK && isset($_COOKIE['or_ignore_ok_notices']))
+ return;
+
+ if (!is_array($log))
+ $log = array($log);
+
+ if (!is_array($vars))
+ $vars = array($vars);
+
+ $this->templateVars['notices'][] = array('type' => $type,
+ 'name' => $name,
+ 'key' => 'NOTICE_' . $text,
+ 'vars' => $vars,
+ 'text' => lang('NOTICE_' . $text, $vars),
+ 'log' => $log,
+ 'status' => $status);
+ }
+
+
+ /**
+ * Ausgabe des Templates.<br>
+ * <br>
+ * Erst hier soll die Ausgabe auf die Standardausgabe, also die
+ * Ausgabe f�r den Browser, starten.<br>
+ * <br>
+ */
+ public function forward()
+ {
+ Session::close();
+ global $conf;
+
+ $db = db_connection();
+
+ if (is_object($db))
+ $db->commit();
+
+ // Ablaufzeit für den Inhalt auf aktuelle Zeit setzen.
+ header('Expires: ' . substr(date('r', time() - date('Z')), 0, -5) . 'GMT', false);
+
+ if ($conf['security']['content-security-policy'])
+ header('X-Content-Security-Policy: ' . 'allow \'self\'; img-src: *; script-src \'self\'; options inline-script');
+
+
+ $httpAccept = getenv('HTTP_ACCEPT');
+ $types = explode(',', $httpAccept);
+
+ if (version_compare(PHP_VERSION, '4.3.0', '>='))
+ Logger::trace('Output' . "\n" . print_r($this->templateVars, true));
+
+ // Weitere Variablen anreichern.
+ $this->templateVars['session'] = array('name' => session_name(), 'id' => session_id(), 'token' => token());
+ $this->templateVars['version'] = OR_VERSION;
+ $this->templateVars['api'] = '2';
+
+ if (sizeof($types) == 1 && in_array('application/php-array', $types) || $this->getRequestVar('output') == 'php-array') {
+ if (version_compare(PHP_VERSION, '4.3.0', '<'))
+ Http::serverError('application/php-array is only available with PHP >= 4.3');
+
+ header('Content-Type: application/php-array; charset=UTF-8');
+ echo print_r($this->templateVars, true);
+ exit;
+ }
+
+ if (sizeof($types) == 1 && in_array('application/php-serialized', $types) || $this->getRequestVar('output') == 'php') {
+ header('Content-Type: application/php-serialized; charset=UTF-8');
+ echo serialize($this->templateVars);
+ exit;
+ }
+
+ if (sizeof($types) == 1 && in_array('application/json', $types) || $this->getRequestVar('output') == 'json') {
+ $json = new JSON();
+ header('Content-Type: application/json; charset=UTF-8');
+ if (function_exists('json_encode'))
+ // Native Methode ist schneller..
+ echo json_encode($this->templateVars, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PARTIAL_OUTPUT_ON_ERROR);
+ else
+ // Fallback, falls json_encode() nicht existiert...
+ echo $json->encode($this->templateVars);
+ exit;
+ }
+
+ if (sizeof($types) == 1 && in_array('application/xml', $types) || $this->getRequestVar('output') == 'xml') {
+ require_once(OR_SERVICECLASSES_DIR . "XML.class." . PHP_EXT);
+ $xml = new XML();
+ $xml->root = 'server'; // Name des XML-root-Elementes
+ header('Content-Type: application/xml; charset=UTF-8');
+ echo $xml->encode($this->templateVars);
+ exit;
+ }
+
+ header('Content-Type: text/html; charset=UTF-8');
+ $this->setMenu();
+
+ $tplName = $this->actionName . '/' . $this->subActionName;
+
+
+// if (isset($this->actionConfig[$this->subActionName]['target']))
+// $targetSubActionName = $this->actionConfig[$this->subActionName]['target'];
+// else
+ $targetSubActionName = $this->subActionName;
+
+
+ global $REQ;
+ global $PHP_SELF;
+ global $HTTP_SERVER_VARS;
+ global $image_dir;
+ global $view;
+
+ // Übertragen der Ausgabe-Variablen in den aktuellen Kontext
+ //
+ extract($this->templateVars['output']);
+
+ // Setzen einiger Standard-Variablen
+ //
+ $tpl_dir = OR_THEMES_DIR . $conf['interface']['theme'] . '/pages/html/';
+ $image_dir = OR_THEMES_EXT_DIR . $conf['interface']['theme'] . '/images/';
+
+ $user = Session::getUser();
+
+ $self = $HTTP_SERVER_VARS['PHP_SELF'];
+
+ if (!empty($conf['interface']['override_title']))
+ $cms_title = $conf['interface']['override_title'];
+ else
+ $cms_title = OR_TITLE . ' ' . OR_VERSION;
+
+ $subActionName = $this->subActionName;
+ $actionName = $this->actionName;
+ $requestId = $this->getRequestId();
+
+ $iFile = 'themes/default/templates/' . $tplName . '.tpl.out.' . PHP_EXT;
+
+ if (DEVELOPMENT) {
+ $srcXmlFilename = 'themes/default/templates/' . $tplName . '.tpl.src.xml';
+
+ // Das Template kompilieren.
+ // Aus dem XML wird eine PHP-Datei erzeugt.
+ try {
+ $te = new TemplateEngine();
+ $te->compile($srcXmlFilename, $iFile);
+ unset($te);
+ } catch (Exception $e) {
+ throw new DomainException("Compilation failed for Template '$tplName'.", 0, $e);
+ }
+ header("X-CMS-Template-File: " . $iFile);
+ }
+
+
+ if (is_file($iFile))
+ // Einbinden des Templates
+ require_once($iFile);
+ else
+ throw new LogicException("File '$iFile' not found.");
+ }
+
+
+ /**
+ * Ruft eine weitere Subaction auf.
+ *
+ * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben.
+ */
+ protected function callSubAction($subActionName)
+ {
+ return;
+
+ /*
+ *
+ if ( in_array($this->actionName,array('page','file','link','folder')) )
+ Session::setSubaction( $subActionName );
+
+ $this->subActionName = $subActionName;
+
+ Logger::trace("next subaction is '$subActionName'");
+
+ $this->$subActionName();
+ */
+ }
+
+
+ /**
+ * Ruft eine weitere Subaction auf.
+ *
+ * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben.
+ */
+ protected function nextSubAction($subActionName)
+ {
+ $this->subActionName = $subActionName;
+
+ Logger::trace("next subaction is '$subActionName'");
+
+ $methodName = $subActionName . ($_SERVER['REQUEST_METHOD'] == 'POST' ? 'Post' : 'View');
+ $this->$methodName();
+ }
+
+
+ /**
+ * Ermitteln, ob Benutzer Administratorrechte besitzt
+ * @return Boolean TRUE, falls der Benutzer ein Administrator ist.
+ */
+ protected function userIsAdmin()
+ {
+ $user = Session::getUser();
+ return is_object($user) && $user->isAdmin;
+ }
+
+
+ /**
+ * Ermitteln, ob Benutzer Administratorrechte besitzt
+ * @return Boolean TRUE, falls der Benutzer ein Administrator ist.
+ */
+ public function userIsLoggedIn()
+ {
+ $user = Session::getUser();
+ return is_object($user) && $user->isAdmin;
+ }
+
+
+ /**
+ * Ermitteln des Benutzerobjektes aus der Session
+ * @return User
+ */
+ protected function getUserFromSession()
+ {
+ return Session::getUser();
+ }
+
+
+ /**
+ * Benutzen eines sog. "Conditional GET".
+ *
+ * Diese Funktion setzt einen "Last-Modified"-HTTP-Header.
+ * Ist der Inhalt der Seite nicht neuer, so wird der Inhalt
+ * der Seite nicht ausgegeben, sondern nur HTTP-Status 304
+ * ("304 not modified") gesetzt.
+ * Der Rest der Seite muss dann nicht mehr erzeugt werden,
+ * wodurch die Performance stark erhoeht werden kann.
+ *
+ * Credits: Danke an Charles Miller
+ * @see http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers
+ *
+ * Gefunden auf:
+ * @see http://simon.incutio.com/archive/2003/04/23/conditionalGet
+ *
+ * @param Timestamp Letztes Aenderungsdatum des Objektes
+ */
+ protected function lastModified($time, $expirationDuration = 0)
+ {
+ $user = Session::getUser();
+
+ // Conditional-Get eingeschaltet?
+ if (!config('cache', 'conditional_get'))
+ return;
+
+ $expires = substr(date('r', time() + $expirationDuration - date('Z')), 0, -5) . 'GMT';
+ $lastModified = substr(date('r', $time - date('Z')), 0, -5) . 'GMT';
+ $etag = '"' . base_convert($time, 10, 36) . '"';
+
+ // Header senden
+ header('Expires: ' . $expires);
+ header('Last-Modified: ' . $lastModified);
+ header('ETag: ' . $etag);
+
+ // Die vom Interpreter sonst automatisch gesetzten
+ // Header uebersteuern
+ header('Cache-Control: must-revalidate');
+ header('Pragma:');
+
+ // See if the client has provided the required headers
+ $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
+ $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
+
+ // Bug in Apache 2.2, mod_deflat adds '-gzip' to E-Tag
+ if (substr($if_none_match, -6) == '-gzip"')
+ $if_none_match = substr($if_none_match, 0, -6) . '"';
+
+ // At least one of the headers is there - check them
+ if ($if_none_match && $if_none_match != $etag)
+ return; // etag is there but doesn't match
+
+ if ($if_modified_since && $if_modified_since != $lastModified)
+ return; // if-modified-since is there but doesn't match
+
+ if (!$if_modified_since && !$if_none_match)
+ return;
+
+ // Der entfernte Browser bzw. Proxy holt die Seite nun aus seinem Cache
+ header('HTTP/1.0 304 Not Modified');
+ exit; // Sofortiges Skript-Ende
+ }
+
+
+ /**
+ * @param $max int max Anzahl der Sekunden, die die Seite im Browsercache bleiben darf
+ */
+ protected function maxAge($max = 3600)
+ {
+ // Die Header "Last-Modified" und "ETag" wurden bereits in der
+ // Methode "lastModified()" gesetzt.
+
+ header('Expires: ' . substr(date('r', time() - date('Z') + $max), 0, -5) . 'GMT');
+ header('Pragma: '); // 'Pragma' ist Bullshit und
+ // wird von den meisten Browsern ignoriert.
+ header('Cache-Control: public, max-age=' . $max . ", s-maxage=" . $max);
+ }
+
+
+ protected function setMenu()
+ {
+ return;
+
+ $windowMenu = array();
+ $name = $this->actionConfig[$this->subActionName]['menu'];
+ $menuList = explode(',', $this->actionConfig['menu']['menu']);
+ //$menuList = explode(',',$this->actionConfig['menu'][$name]);
+
+ if (isset($this->actionConfig[$this->subActionName]['menuaction']))
+ $actionName = $this->actionConfig[$this->subActionName]['menuaction'];
+ else
+ $actionName = $this->subActionName;
+
+ foreach ($menuList as $menuName) {
+ if (isset($this->actionConfig[$menuName]['alias']))
+ $menuText = 'menu_' . $this->actionName . '_' . $this->actionConfig[$menuName]['alias'];
+ else
+ $menuText = 'menu_' . $this->actionName . '_' . $menuName;
+
+
+ $menuKey = 'accesskey_window_' . $menuName;
+
+ $menuEntry = array('subaction' => $menuName,
+ 'text' => $menuText,
+ 'title' => $menuText . '_DESC',
+ 'key' => $menuKey);
+
+ if ($this->checkMenu($menuName))
+ $menuEntry['url'] = Html::url($actionName, $menuName, $this->getRequestId());
+
+ $windowMenu[] = $menuEntry;
+ }
+ $this->setTemplateVar('windowMenu', $windowMenu);
+ }
+
+
+ /**
+ * Ermittelt, ob der Men�punkt aktiv ist.
+ * Ob ein Men�punkt als aktiv angezeigt werden soll, steht meist erst zur Laufzeit fest.
+ * <br>
+ * Diese Methode kann von den Unterklassen �berschrieben werden.
+ * Falls diese Methode nicht �berschrieben wird, sind alle Men�punkte aktiv.
+ *
+ * @param String $name Logischer Name des Men�punktes
+ * @return boolean TRUE, wenn Men�punkt aktiv ist.
+ */
+ protected function checkMenu($name)
+ {
+ // Standard: Alle Men�punkt sind aktiv.
+ return true;
+ }
+
+
+ /**
+ * Erzeugt einen Redirect auf einen bestimmte URL.
+ */
+ protected function redirect($url)
+ {
+ $this->setControlVar('redirect', $url);
+ }
+
+
+ /**
+ * Sorgt dafür, dass alle anderen Views aktualisiert werden.
+ *
+ * Diese Methode sollte dann aufgerufen werden, wenn Objekte geändert werden
+ * und dies Einfluss auf andere Views hat.
+ */
+ protected function refresh()
+ {
+ $this->refresh = true;
+ $this->setControlVar('refresh', true);
+ }
+
+
+ /**
+ * Setzt eine neue Perspektive für die Sitzung.
+ *
+ * @param String Name der Perspektive
+ */
+ protected function setPerspective($name)
+ {
+ Session::set('perspective', $name);
+ $this->refresh();
+ }
+ }
+
+
+// TODO - nicht benutzt
+ interface ActionResult
+ {
+ public function getErrorField();
+
+ public function isSuccess();
+ }
+
+ class ActionResultSuccess implements ActionResult
+ {
+ public function isSuccess()
+ {
+ return true;
+ }
+
+ public function getErrorField()
+ {
+ return null;
+ }
+ }
+
+ class ActionResultError implements ActionResult
+ {
+ private $fieldName;
+
+ public function __construct($name)
+ {
+ $this->fieldName = $name;
+ }
+
+ public function isSuccess()
+ {
+ return false;
+ }
+
+ public function getErrorField()
+ {
+ return $this->fieldName;
+ }
+ }
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/ConfigurationAction.class.php b/modules/cms-core/action/ConfigurationAction.class.php
@@ -0,0 +1,116 @@
+<?php
+
+namespace cms\action;
+
+// 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; version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+use Session;
+/**
+ * Action-Klasse fuer die Bearbeitung eines Template-Elementes.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class ConfigurationAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ }
+
+
+ public function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+ /**
+ * Anzeigen des Elementes
+ */
+ function showView()
+ {
+ require_once('./util/config-default.php');
+ $conf_default = $conf;
+
+ $conf_cms = Session::getConfig();
+ $conf_cms['system']['server'] = array( 'time' => date('r'),
+ 'os' => php_uname('s'),
+ 'host' => php_uname('n'),
+ 'release'=> php_uname('r'),
+ 'machine'=> php_uname('m'),
+ 'owner' => get_current_user(),
+ 'pid' => getmypid() );
+
+
+ $conf_cms['system']['interpreter'] = array( 'version' => phpversion(),
+ 'SAPI' => php_sapi_name(),
+ 'session-name' => session_name(),
+ 'magic_quotes_gpc' => get_magic_quotes_gpc(),
+ 'magic_quotes_runtime'=> get_magic_quotes_runtime() );
+
+ unset($conf_cms['language']);
+
+ foreach( array('upload_max_filesize',
+ 'file_uploads',
+ 'memory_limit',
+ 'max_execution_time',
+ 'post_max_size',
+ 'display_errors',
+ 'register_globals'
+ ) as $iniName )
+ $conf_cms['system']['environment'][ $iniName ] = ini_get( $iniName );
+
+ $extensions = get_loaded_extensions();
+ asort( $extensions );
+
+ foreach( $extensions as $id=>$extensionName )
+ $conf_cms['system']['interpreter'][ 'extension' ][$extensionName] = 'loaded';
+
+ $flatDefaultConfig = flattenArray('',$conf_default);
+ $flatCMSConfig = flattenArray('',Session::getConfig());
+ $flatConfig = flattenArray('',$conf_cms);
+
+ $config = array();
+ foreach( $flatConfig as $key=>$val )
+ {
+ $config[] = array( 'key'=>$key,'value'=>$val,'class'=>(empty($flatCMSConfig[$key])?'readonly':(isset($flatDefaultConfig[$key]) && $flatDefaultConfig[$key]==$flatConfig[$key]?'default':'changed')));
+ }
+ $this->setTemplateVar('config',$config );
+ }
+}
+
+
+function flattenArray( $prefix,$arr )
+{
+ $new = array();
+ foreach( $arr as $key=>$val)
+ {
+ if ( is_array($val) )
+ $new += flattenArray($prefix.$key.'.',$val);
+ else
+ $new[$prefix.$key] = $key=='password'?'*******************':$val;
+ }
+ return $new;
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/ElementAction.class.php b/modules/cms-core/action/ElementAction.class.php
@@ -0,0 +1,667 @@
+<?php
+
+namespace cms\action;
+
+
+use cms\model\Element;
+use cms\model\Template;
+use cms\model\Folder;
+use cms\model\Object;
+use Text;
+
+
+// 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; version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/**
+ * Action-Klasse fuer die Bearbeitung eines Template-Elementes.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class ElementAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $element;
+
+ private $template;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ if ( $this->getRequestId() == 0 )
+ die('no element-id available');
+
+ $this->element = new Element( $this->getRequestId() );
+ $this->element->load();
+
+ $this->setTemplateVar( 'elementid' ,$this->element->elementid );
+ }
+
+
+
+ /**
+ * Umbenennen des Elementes
+ */
+ function editPost()
+ {
+ $this->element->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM);
+ $this->element->desc = $this->getRequestVar('description','all' );
+
+ $this->element->save();
+ $this->element->load();
+
+ $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+ /**
+ * Umbenennen des Elementes
+ */
+ function deleteView()
+ {
+ $this->setTemplateVar( 'name' ,$this->element->name );
+ }
+
+
+ /**
+ * Entfernen des Elementes
+ */
+ function deletePost()
+ {
+ if ( !$this->hasRequestVar('confirm') )
+ {
+ $this->addValidationError('confirm');
+ return;
+ }
+
+ $type = $this->getRequestVar('type','abc');
+
+ if ( $type == 'value' )
+ {
+ $this->element->deleteValues();
+ $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
+ }
+ elseif ( $type == 'all' )
+ {
+ $this->element->delete();
+ $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
+ }
+ }
+
+
+
+ /**
+ * Aendern des Element-Typs
+ */
+ function typePost()
+ {
+ if ( !$this->userIsAdmin() && $this->getRequestVar('type') == 'code' )
+ {
+ // Code-Elemente fuer Nicht-Administratoren nicht benutzbar
+ $this->addNotice('element',$this->template->name,'CANCELED',OR_NOTICE_ERROR);
+ }
+ else
+ {
+ // Neuen Typ setzen und speichern
+ $this->element->setType( $this->getRequestVar('type') );
+ $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK);
+ }
+ }
+
+
+ /**
+ * Anzeigen des Elementes
+ */
+ function editView()
+ {
+
+ // Name und Beschreibung
+ $this->setTemplateVar('name' ,$this->element->name);
+
+ $this->setTemplateVar('description',$this->element->desc);
+ }
+
+
+
+ function typeView
+ ()
+ {
+ // Die verschiedenen Element-Typen
+ $types = array();
+
+ foreach( $this->element->getAvailableTypes() as $t )
+ $types[ $t ] = 'EL_'.$t;
+
+ // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
+ if ( !$this->userIsAdmin() )
+ unset( $types['code'] );
+
+ // Liste aller Elementtypen
+ $this->setTemplateVar('types',$types);
+
+ // Aktueller Typ
+ $this->setTemplateVar('type',$this->element->type);
+ }
+
+
+
+ /**
+ * Auswahlmaske f�r weitere Einstellungen zum Template-Element.
+ *
+ */
+ function infoView()
+ {
+ $this->setTemplateVar('id' ,$this->element->elementid );
+ $this->setTemplateVar('name',$this->element->name );
+ }
+
+ /**
+ * Auswahlmaske f�r weitere Einstellungen zum Template-Element.
+ *
+ */
+ function propView()
+ {
+ global $conf;
+ $this->setTemplateVar('type',$this->element->type );
+
+ // Abhaengig vom aktuellen Element-Typ die Eigenschaften anzeigen
+ $properties = $this->element->getRelatedProperties();
+
+ foreach( $this->element->getRelatedProperties() as $propertyName )
+ {
+ switch( $propertyName )
+ {
+ case 'withIcon':
+ $this->setTemplateVar('with_icon' ,$this->element->withIcon );
+ break;
+
+ case 'allLanguages':
+ $this->setTemplateVar('all_languages',$this->element->allLanguages);
+ break;
+
+ case 'writable':
+ $this->setTemplateVar('writable' ,$this->element->writable );
+ break;
+
+ case 'subtype':
+
+ $convertToLang = false;
+ switch( $this->element->type )
+ {
+ case 'info':
+ $subtypes = Array('db_id',
+ 'db_name',
+ 'project_id',
+ 'project_name',
+ 'language_id',
+ 'language_iso',
+ 'language_name',
+ 'page_id',
+ 'page_name',
+ 'page_desc',
+ 'page_fullfilename',
+ 'page_filename',
+ 'page_extension',
+ 'edit_url',
+ 'edit_fullurl',
+ 'lastch_user_username',
+ 'lastch_user_fullname',
+ 'lastch_user_mail',
+ 'lastch_user_desc',
+ 'lastch_user_tel',
+ 'create_user_username',
+ 'create_user_fullname',
+ 'create_user_mail',
+ 'create_user_desc',
+ 'create_user_tel',
+ 'act_user_username',
+ 'act_user_fullname',
+ 'act_user_mail',
+ 'act_user_desc',
+ 'act_user_tel' );
+ $convertToLang = true;
+ break;
+
+ case 'infodate':
+ case 'linkdate':
+ $subtypes = Array('date_published',
+ 'date_saved',
+ 'date_created' );
+ $convertToLang = true;
+ break;
+
+ case 'link':
+ $subtypes = Array(
+ 'file',
+ 'image',
+ 'image_data_uri',
+ 'page',
+ 'folder',
+ 'link' );
+ $convertToLang = true;
+ break;
+
+ case 'linkinfo':
+ $subtypes = Array('width',
+ 'height',
+ 'id',
+ 'name',
+ 'description',
+ 'mime-type',
+ 'lastch_user_username',
+ 'lastch_user_fullname',
+ 'lastch_user_mail',
+ 'lastch_user_desc',
+ 'lastch_user_tel',
+ 'create_user_username',
+ 'create_user_fullname',
+ 'create_user_mail',
+ 'create_user_desc',
+ 'create_user_tel',
+ 'filename',
+ 'full_filename' );
+ $convertToLang = true;
+ break;
+
+ case 'insert':
+ $subtypes = Array('inline',
+ 'ssi' );
+ $convertToLang = true;
+ break;
+
+ case 'dynamic':
+
+ $files = Array();
+ $handle = opendir ('./macro');
+ while ( $file = readdir($handle) )
+ {
+ $file = substr($file,0,strlen($file)-10);
+ if ( $file != '' )
+ $files[$file] = $file;
+ }
+ closedir($handle);
+
+ $subtypes = $files;
+ break;
+
+ default:
+ $subtypes = array();
+ break;
+ }
+
+ if ( $convertToLang )
+ {
+ foreach( $subtypes as $t=>$v )
+ {
+ unset($subtypes[$t]);
+ $subtypes[$v] = lang('EL_'.$this->element->type.'_'.$v);
+ }
+ }
+
+ // Variable $subtype muss existieren, um Anzeige des Feldes zu erzwingen.
+ if (!isset($this->element->subtype))
+ $this->element->subtype='';
+
+ $this->setTemplateVar('subtypes',$subtypes );
+ $this->setTemplateVar('subtype' ,$this->element->subtype);
+
+ break;
+
+
+ case 'dateformat':
+
+ $ini_date_format = $conf['date']['format'];
+ $dateformat = array();
+
+ $this->setTemplateVar('dateformat','');
+
+ foreach($ini_date_format as $idx=>$d)
+ {
+ if ( strpos($d,'%')!==FALSE )
+ $dateformat[$idx] = strftime($d);
+ else
+ $dateformat[$idx] = date($d);
+ if ( $d == $this->element->dateformat )
+ $this->setTemplateVar('dateformat',$idx);
+ }
+
+ $this->setTemplateVar('dateformats',$dateformat);
+
+ break;
+
+
+ // Eigenschaften Text und Text-Absatz
+ case 'defaultText':
+
+ switch( $this->element->type )
+ {
+ case 'longtext':
+ $this->setTemplateVar('default_longtext',$this->element->defaultText );
+ break;
+
+ case 'select':
+ case 'text':
+ $this->setTemplateVar('default_text' ,$this->element->defaultText );
+ break;
+ }
+ break;
+
+
+ case 'htmlwiki':
+ if ( !$this->element->wiki && !$this->element->html )
+ $format = 'none';
+ elseif ( $this->element->wiki && !$this->element->html )
+ $format = 'wiki';
+ elseif ( !$this->element->wiki && $this->element->html )
+ $format = 'html';
+ elseif ( $this->element->wiki && $this->element->html )
+ $format = 'wiki,html';
+
+ $this->setTemplateVar('format', $format );
+
+ $formatlist = array();
+ $formatlist['none' ] = 'raw'; // Nur Text, ohne Auszeichnungen
+ // Für einfache Textelemente gibt es keinen HTML-Editor
+ if ( $this->element->type == 'longtext' )
+ $formatlist['html' ] = 'html'; // Text mit HTML-Editor
+ $formatlist['wiki' ] = 'wiki'; // Text mit Markup, HTML nicht erlaubt
+ $formatlist['wiki,html'] = 'wikihtml'; // Text mit Markup, HTML erlaubt
+
+ foreach( $formatlist as $t=>$v )
+ $formatlist[$t] = array('lang'=>'EL_PROP_'.$v);
+
+ $this->setTemplateVar('formatlist', $formatlist );
+ break;
+
+ case 'linktype':
+ $this->setTemplateVar('linktype', $this->element->wiki );
+ $this->setTemplateVar('linktypelist', array('page','file','link') );
+ break;
+
+ case 'prefix':
+ $t = new Template( $this->element->templateid );
+
+ $elements = array();
+ foreach( $t->getElements() as $element )
+ {
+ if ( $element->type == 'link' )
+ $elements[$element->name] = $element->name;
+ }
+ unset($t);
+
+ $this->setTemplateVar('linkelements',$elements );
+
+ list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
+ $this->setTemplateVar('linkelement',$linkElementName );
+
+ break;
+
+ case 'name':
+
+ $names = array();
+
+ foreach( Template::getAll() as $tid=>$name )
+ {
+ $t = new Template( $tid );
+ $t->load();
+
+ foreach( $t->getElements() as $element )
+ {
+ if ( !in_array($element->type,array('copy','linkinfo','link')) )
+ $names[$element->name] = $t->name.' - '.$element->name.' ('.lang('EL_'.$element->type).')';
+ }
+ unset($t);
+ }
+
+
+ $this->setTemplateVar('names',$names );
+
+ list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
+ $this->setTemplateVar('name',$targetElementName );
+ break;
+
+ // Eigenschaften PHP-Code
+ case 'code':
+
+ switch( $this->element->type )
+ {
+
+ case 'select':
+ $this->setTemplateVar('select_items',$this->element->code );
+ break;
+
+ case 'dynamic':
+
+ $className = $this->element->subtype;
+ $fileName = OR_DYNAMICCLASSES_DIR.'/'.$className.'.class.'.PHP_EXT;
+
+ if ( is_file( $fileName ) )
+ {
+ require( $fileName );
+
+ if ( class_exists($className) )
+ {
+ $dynEl = new $className;
+
+ $desc = array();
+
+ $description = $dynEl->description;
+ $paramList = array();
+
+ $old = $this->element->getDynamicParameters();
+ $parameters = '';
+
+ foreach( get_object_vars($dynEl) as $paramName=>$paramDesc )
+ {
+ if ( isset( $dynEl->$paramName ) )
+ {
+ if ( is_object($dynEl->$paramName))
+ continue;
+ if ( is_array($dynEl->$paramName))
+ continue;
+ if ( in_array($paramName,array('output')))
+ continue;
+ $paramList[$paramName] = $dynEl->$paramName;
+
+ $parameters .= $paramName.':';
+ if ( !empty($old[$paramName]) )
+ $parameters .= $old[$paramName];
+ else
+ $parameters .= $dynEl->$paramName;
+ $parameters .= "\n";
+ }
+ }
+
+ $this->setTemplateVar('dynamic_class_description',$dynEl->description );
+ $this->setTemplateVar('dynamic_class_parameters' ,$paramList );
+ $this->setTemplateVar('parameters' ,$parameters );
+ }
+ }
+
+ break;
+
+ case 'code':
+ if ( $conf['security']['disable_dynamic_code'] )
+ $this->addNotice('element',$this->element->name,'CODE_DISABLED',OR_NOTICE_WARN);
+
+ $this->setTemplateVar('code',$this->element->code);
+ break;
+ }
+ break;
+
+
+ case 'decimals':
+ $this->setTemplateVar('decimals' ,$this->element->decimals );
+ break;
+
+ case 'decPoint':
+ $this->setTemplateVar('dec_point' ,$this->element->decPoint );
+ break;
+
+ case 'thousandSep':
+ $this->setTemplateVar('thousand_sep' ,$this->element->thousandSep );
+ break;
+
+
+ // Eigenschaften Link
+ case 'defaultObjectId':
+
+ $objects = array();
+
+ // Ermitteln aller verfuegbaren Objekt-IDs
+ foreach( Folder::getAllObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ switch( $this->element->type )
+ {
+ case 'list':
+ if ( !$o->isFolder )
+ continue 2;
+ break;
+
+ case 'link':
+ if ( !$o->isPage && !$o->isFile && !$o->isLink )
+ continue 2;
+ break;
+ //Change tobias
+ case 'insert':
+ if ( !$o->isFolder && !$o->isPage && !$o->isFile && !$o->isLink )
+ continue 2;
+ break;
+ //Change tobias end
+ default:
+ continue 2;
+ }
+
+ $objects[ $id ] = lang( $o->getType() ).': ';
+
+ if ( !$o->isRoot )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+ $names = $f->parentObjectNames(false,true);
+ foreach( $names as $fid=>$name )
+ $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
+ $objects[ $id ] .= implode( FILE_SEP,$names );
+ }
+
+ $objects[ $id ] .= FILE_SEP.$o->name;
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects',$objects);
+
+ $this->setTemplateVar('default_objectid',$this->element->defaultObjectId);
+
+ break;
+
+
+ case 'folderObjectId':
+
+ $folders = array();
+
+ // Ermitteln aller verf?gbaren Objekt-IDs
+ foreach( Folder::getAllFolders() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ $folders[ $id ] = '';
+ if ( !$o->isRoot )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+ $names = $f->parentObjectNames(true,true);
+ foreach( $names as $fid=>$name )
+ $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
+ $folders[ $id ] = implode( ' » ',$names );
+ $folders[ $id ] .= ' » ';
+ }
+ $folders[ $id ] .= $o->name;
+ }
+
+ asort( $folders ); // Sortieren
+
+ $this->setTemplateVar('folders',$folders);
+
+ $this->setTemplateVar('folderobjectid' ,$this->element->folderObjectId );
+
+ break;
+
+ default:
+ throw new \LogicException('not an element property: '.$propertyName );
+ }
+ }
+ }
+
+
+
+ /**
+ * Speichern der Element-Eigenschaften
+ */
+ function propPost()
+ {
+ global $conf;
+ $ini_date_format = $conf['date']['format'];
+
+ if ( $this->hasRequestVar('dateformat'))
+ $this->element->dateformat = $ini_date_format[$this->getRequestVar('dateformat')];
+ $this->element->subtype = $this->getRequestVar('subtype');
+
+ if ( $this->hasRequestVar('default_longtext'))
+ $this->element->defaultText = $this->getRequestVar('default_longtext',OR_FILTER_RAW);
+ else
+ $this->element->defaultText = $this->getRequestVar('default_text',OR_FILTER_ALPHANUM);
+ $this->element->wiki = in_array('wiki',explode(',',$this->getRequestVar('format')));
+ $this->element->html = in_array('html',explode(',',$this->getRequestVar('format')));
+ $this->element->withIcon = $this->getRequestVar('with_icon') != '';
+ $this->element->allLanguages = $this->getRequestVar('all_languages') != '';
+ $this->element->writable = $this->getRequestVar('writable') != '';
+ $this->element->decimals = $this->getRequestVar('decimals');
+ $this->element->decPoint = $this->getRequestVar('dec_point');
+ $this->element->thousandSep = $this->getRequestVar('thousand_sep');
+ $this->element->folderObjectId = $this->getRequestVar('folderobjectid' );
+ $this->element->defaultObjectId = $this->getRequestVar('default_objectid');
+ if ( $this->hasRequestVar('select_items'))
+ $this->element->code = $this->getRequestVar('select_items');
+ else
+ $this->element->code = $this->getRequestVar('code' ,'raw');
+
+ if ( $this->hasRequestVar('name') )
+ $this->element->name = $this->getRequestVar('name');
+
+ if ( $this->hasRequestVar('linkelement') )
+ $this->element->setPrefix( $this->getRequestVar('linkelement') );
+
+ if ( $this->hasRequestVar('parameters'))
+ $this->element->code = $this->getRequestVar('parameters',OR_FILTER_RAW);
+
+// Html::debug($this->element);
+ $this->element->save();
+ $this->addNotice('element',$this->element->name,'SAVED');
+
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/FileAction.class.php b/modules/cms-core/action/FileAction.class.php
@@ -0,0 +1,815 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\File;
+
+use Http;
+use \Html;
+
+// 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 zum Bearbeiten einer Datei
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class FileAction extends ObjectAction
+{
+ public $security = SECURITY_USER;
+
+ var $file;
+ var $defaultSubAction = 'show';
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->file = new File( $this->getRequestId() );
+ $this->file->load();
+ }
+
+
+ /**
+ * Ersetzt den Inhalt mit einer anderen Datei
+ */
+ public function editPost()
+ {
+ $upload = new Upload();
+
+ $this->file->filename = $upload->filename;
+ $this->file->extension = $upload->extension;
+ $this->file->size = $upload->size;
+ $this->file->save();
+
+ $this->file->value = $upload->value;
+ $this->file->saveValue();
+ $this->file->setTimestamp();
+
+ //$setTemplateVar('tree_refresh',true);
+ $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok');
+ }
+
+
+ public function valuePost()
+ {
+ $this->file->value = $this->getRequestVar('value',OR_FILTER_RAW);
+ $this->file->saveValue();
+
+ $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok');
+ $this->file->setTimestamp();
+ }
+
+
+ /**
+ * Abspeichern der Eigenschaften zu dieser Datei.
+ *
+ */
+ function propPost()
+ {
+ // Eigenschaften speichern
+ $this->file->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME);
+ $this->file->name = $this->getRequestVar('name' ,OR_FILTER_FULL );
+ $this->file->extension = $this->getRequestVar('extension' ,OR_FILTER_FILENAME);
+ $this->file->desc = $this->getRequestVar('description',OR_FILTER_FULL );
+
+ $this->file->save();
+ $this->file->setTimestamp();
+ $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok');
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
+ * auf die Standardausgabe geschrieben
+ */
+ function previewView()
+ {
+ $url = Html::url('file','show',$this->file->objectid,array('target'=>'none') );
+ $this->setTemplateVar('preview_url',$url );
+
+ $this->setTemplateVar('image',$this->file->isImage() );
+
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
+ * auf die Standardausgabe geschrieben
+ */
+ function showView()
+ {
+ $this->lastModified( $this->file->lastchangeDate );
+
+ if ( $this->file->extension == 'gz' )
+ {
+ global $conf;
+ $mime_types = $conf['mime-types'];
+
+ $pos = strrpos($this->file->filename,'.');
+ if ( $pos === false )
+ $ext = '';
+ else
+ $ext = substr($this->file->filename,$pos+1);
+
+ $ext = strtolower($ext);
+
+ if ( !empty($mime_types[$ext]) )
+ $mime_type = $mime_types[$ext];
+ else
+ // Wenn kein Mime-Type gefunden, dann Standartwert setzen
+ $mime_type = OR_FILE_DEFAULT_MIMETYPE;
+
+ header('Content-Type: '.$mime_type );
+ header('Content-Encoding: gzip' );
+ }
+ else
+ {
+ // Angabe Content-Type
+ header('Content-Type: '.$this->file->mimeType() );
+ }
+
+ header('X-File-Id: ' .$this->file->fileid );
+ header('X-Id: ' .$this->file->id );
+
+ // Angabe Content-Disposition
+ // - Bild soll "inline" gezeigt werden
+ // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
+ header('Content-Disposition: inline; filename='.$this->file->filenameWithExtension() );
+ header('Content-Transfer-Encoding: binary' );
+ header('Content-Description: '.$this->file->name );
+
+ $this->file->write(); // Bild aus Datenbank laden
+
+ // Groesse des Bildes in Bytes
+ // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
+ header('Content-Length: '.filesize($this->file->tmpfile()) );
+
+ if ( in_array( getenv('HTTP_ACCEPT'),array('application/php-array','application/php-serialized','application/json','application/xml')))
+ {
+ $this->setTemplateVar('encoding', 'base64');
+ $this->setTemplateVar('value' , base64_encode($this->file->tmpfile()) );
+ }
+ // Unterscheidung, ob PHP-Code in der Datei ausgefuehrt werden soll.
+ elseif ( ( config('publish','enable_php_in_file_content')=='auto' && $this->file->getRealExtension()=='php') ||
+ config('publish','enable_php_in_file_content')===true )
+ // PHP-Code ausfuehren
+ require( $this->file->tmpfile() );
+ else
+ // PHP-Code nicht ausfuehren, Datei direkt auf die Standardausgabe schreiben
+ readfile( $this->file->tmpfile() );
+ exit;
+ }
+
+
+ function imageFormat()
+ {
+ if ( ! function_exists( 'imagetypes' ) )
+ return 0;
+
+ $ext = strtolower($this->file->getRealExtension());
+ $types = imagetypes();
+ $formats = array( 'gif' =>IMG_GIF,
+ 'jpg' =>IMG_JPG,
+ 'jpeg'=>IMG_JPG,
+ 'png' =>IMG_PNG );
+
+ if ( !isset($formats[$ext]) )
+ return 0;
+
+ if ( $types & $formats[$ext] )
+ return $formats[$ext];
+
+ return 0;
+ }
+
+
+
+ function imageExt()
+ {
+ switch( $this->imageFormat() )
+ {
+ case IMG_GIF:
+ return 'GIF';
+ case IMG_JPG:
+ return 'JPEG';
+ case IMG_PNG:
+ return 'PNG';
+ }
+ }
+
+
+
+ function imageFormats()
+ {
+ if ( ! function_exists( 'imagetypes' ) )
+ return array();
+
+ $types = imagetypes();
+ $formats = array( IMG_GIF => 'gif',
+ IMG_JPG => 'jpeg',
+ IMG_PNG => 'png' );
+ $formats2 = $formats;
+
+ foreach( $formats as $b=>$f )
+ if ( !($types & $b) )
+ unset( $formats2[$b] );
+
+ return $formats2;
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function sizeView()
+ {
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $format = $this->imageFormat();
+
+ if ( $format == 0 )
+ {
+ $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN);
+ }
+
+ $formats = $this->imageFormats();
+
+ if ( empty($formats) )
+ $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN);
+
+ $sizes = array();
+ foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s )
+ $sizes[strval($s/100)] = $s.'%';
+
+ $jpeglist = array();
+ for ($i=10; $i<=95; $i+=5)
+ $jpeglist[$i]=$i.'%';
+
+ $this->setTemplateVar('factors' ,$sizes );
+ $this->setTemplateVar('jpeglist' ,$jpeglist );
+ $this->setTemplateVar('formats' ,$formats );
+ $this->setTemplateVar('format' ,$format );
+ $this->setTemplateVar('factor' ,1 );
+
+ $this->file->getImageSize();
+ $this->setTemplateVar('width' ,$this->file->width );
+ $this->setTemplateVar('height',$this->file->height );
+ $this->setTemplateVar('type' ,'input' );
+ }
+
+
+
+
+ /**
+ * Bildgroesse eines Bildes aendern
+ */
+ public function sizePost()
+ {
+ $width = intval($this->getRequestVar('width' ));
+ $height = intval($this->getRequestVar('height' ));
+ $jpegcompression = $this->getRequestVar('jpeg_compression') ;
+ $format = $this->getRequestVar('format' ) ;
+ $factor = $this->getRequestVar('factor' ) ;
+
+ if ( $this->getRequestVar('type') == 'input' &&
+ ! $this->hasRequestVar('width' ) &&
+ ! $this->hasRequestVar('height') )
+ {
+ $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' );
+ $this->addValidationError('height','');
+ $this->callSubAction('size');
+ return;
+ }
+
+ if ( $this->hasRequestVar('copy') )
+ {
+ // Datei neu anlegen.
+ $imageFile = new File($this->file->objectid);
+ $imageFile->load();
+ $imageFile->name = lang('copy_of').' '.$imageFile->name;
+ $imageFile->desription = lang('copy_of').' '.$imageFile->description;
+ $imageFile->filename = $imageFile->filename.'_resized_'.time();
+ $imageFile->add();
+ $imageFile->copyValueFromFile( $this->file->objectid );
+ }
+ else
+ {
+ $imageFile = $this->file;
+ }
+
+ if ( $this->getRequestVar('type') == 'factor')
+ {
+ $width = 0;
+ $height = 0;
+ }
+ else
+ {
+ $factor = 1;
+ }
+
+ $imageFile->write();
+
+ $imageFile->imageResize( intval($width),intval($height),$factor,$this->imageFormat(),$format,$jpegcompression );
+ $imageFile->setTimestamp();
+ $imageFile->save(); // Um z.B. Groesse abzuspeichern
+ $imageFile->saveValue();
+
+ $this->addNotice($imageFile->getType(),$imageFile->name,'IMAGE_RESIZED','ok');
+ }
+
+
+ function propView()
+ {
+
+ global $conf;
+
+ if ( $this->file->filename == $this->file->objectid )
+ $this->file->filename = '';
+
+ // Eigenschaften der Datei uebertragen
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' );
+ $this->setTemplateVar('full_filename',$this->file->full_filename());
+
+ if ( is_file($this->file->tmpfile()))
+ {
+ $this->setTemplateVar('cache_filename' ,$this->file->tmpfile());
+ $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile()));
+ }
+
+ // Alle Seiten mit dieser Datei ermitteln
+ $pages = $this->file->getDependentObjectIds();
+
+ $list = array();
+ foreach( $pages as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url('main','page',$id);
+ $list[$id]['name'] = $o->name;
+ }
+ asort( $list );
+ $this->setTemplateVar('pages',$list);
+ $this->setTemplateVar('edit_filename',$conf['filename']['edit']);
+ }
+
+
+ public function infoView()
+ {
+
+ global $conf;
+
+ if ( $this->file->filename == $this->file->objectid )
+ $this->file->filename = '';
+
+ // Eigenschaften der Datei uebertragen
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' );
+ $this->setTemplateVar('full_filename',$this->file->full_filename());
+
+ if ( is_file($this->file->tmpfile()))
+ {
+ $this->setTemplateVar('cache_filename' ,$this->file->tmpfile());
+ $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile()));
+ }
+
+ // Alle Seiten mit dieser Datei ermitteln
+ $pages = $this->file->getDependentObjectIds();
+
+ $list = array();
+ foreach( $pages as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url('main','page',$id);
+ $list[$id]['name'] = $o->name;
+ }
+ asort( $list );
+ $this->setTemplateVar('pages',$list);
+ $this->setTemplateVar('edit_filename',$conf['filename']['edit']);
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function editView()
+ {
+ global $conf;
+ // MIME-Types aus Datei lesen
+ $this->setTemplateVars( $this->file->getProperties() );
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function upload()
+ {
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function valueView()
+ {
+ global $conf;
+ // MIME-Types aus Datei lesen
+ $this->setTemplateVars( $this->file->getProperties() );
+ $this->setTemplateVar('value',$this->file->loadValue());
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function extractView()
+ {
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $imageFormat = $this->imageFormat();
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function uncompressView()
+ {
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function uncompressPost()
+ {
+ switch( $this->file->extension )
+ {
+ case 'gz':
+ if ( $this->getRequestVar('replace') )
+ {
+ if ( strcmp(substr($this->file->loadValue(),0,2),"\x1f\x8b"))
+ {
+ Http::serverError("Not GZIP format (See RFC 1952)");
+ }
+ $method = ord(substr($this->file->loadValue(),2,1));
+ if ( $method != 8 )
+ {
+ Http::serverError("Unknown GZIP method: $method");
+ }
+ $this->file->value = gzinflate( substr($this->file->loadValue(),10));
+ $this->file->parse_filename( $this->file->filename );
+ $this->file->save();
+ $this->file->saveValue();
+ }
+ else
+ {
+ $newFile = new File();
+ $newFile->name = $this->file->name;
+ $newFile->parentid = $this->file->parentid;
+ $newFile->value = gzinflate( substr($this->file->loadValue(),10));
+ $newFile->parse_filename( $this->file->filename );
+ $newFile->add();
+ }
+
+ break;
+
+ case 'bz2':
+ if ( $this->getRequestVar('replace') )
+ {
+ $this->file->value = bzdecompress($this->file->loadValue());
+ $this->file->parse_filename( $this->file->filename );
+ $this->file->save();
+ $this->file->saveValue();
+ }
+ else
+ {
+ $newFile = new File();
+ $newFile->name = $this->file->name;
+ $newFile->parentid = $this->file->parentid;
+ $newFile->value = bzdecompress( $this->file->loadValue() );
+ $newFile->parse_filename( $this->file->filename );
+ $newFile->add();
+ }
+
+ break;
+
+ default:
+ die( 'cannot uncompress file with extension: '.$this->file->extension );
+ }
+
+ $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK);
+ $this->callSubAction('edit');
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function extractPost()
+ {
+ switch( $this->file->extension )
+ {
+ case 'tar':
+ $folder = new Folder();
+ $folder->parentid = $this->file->parentid;
+ $folder->name = $this->file->name;
+ $folder->filename = $this->file->filename;
+ $folder->add();
+
+ $tar = new ArchiveTar();
+ $tar->openTAR( $this->file->loadValue() );
+
+ foreach( $tar->files as $file )
+ {
+ $newFile = new File();
+ $newFile->name = $file['name'];
+ $newFile->parentid = $folder->objectid;
+ $newFile->value = $file['file'];
+ $newFile->parse_filename( $file['name'] );
+ $newFile->lastchangeDate = $file['time'];
+ $newFile->add();
+
+ $this->addNotice('file',$newFile->name,'ADDED');
+ }
+
+ unset($tar);
+
+ break;
+
+ case 'zip':
+
+ $folder = new Folder();
+ $folder->parentid = $this->file->parentid;
+ $folder->name = $this->file->name;
+ $folder->filename = $this->file->filename;
+ $folder->description = $this->file->fullFilename;
+ $folder->add();
+
+ $zip = new ArchiveUnzip();
+ $zip->open( $this->file->loadValue() );
+
+ $lista = $zip->getList();
+
+ if(sizeof($lista)) foreach($lista as $fileName=>$trash){
+
+
+ $newFile = new File();
+ $newFile->name = basename($fileName);
+ $newFile->description = 'Extracted: '.$this->file->fullFilename.' -> '.$fileName;
+ $newFile->parentid = $folder->objectid;
+ $newFile->parse_filename( basename($fileName) );
+
+ $newFile->value = $zip->unzip($fileName);
+ $newFile->add();
+
+ $this->addNotice('file',$newFile->name,'ADDED');
+ unset($newFile);
+ }
+
+ $zip->close();
+ unset($zip);
+
+ break;
+
+ default:
+ die( 'cannot extract file with extension: '.$this->file->extension );
+ }
+ $this->callSubAction('edit');
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function compressView()
+ {
+ $formats = array();
+ foreach( $this->getCompressionTypes() as $t )
+ $formats[$t] = lang('compression_'.$t);
+
+ $this->setTemplateVar('formats' ,$formats );
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function compressPost()
+ {
+ $format = $this->getRequestVar('format',OR_FILTER_ALPHANUM);
+
+ switch( $format )
+ {
+ case 'gz':
+ if ( $this->getRequestVar('replace',OR_FILTER_NUMBER)=='1' )
+ {
+ $this->file->value = gzencode( $this->file->loadValue(),1 );
+ $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP );
+ $this->file->save();
+ $this->file->saveValue();
+
+ }
+ else
+ {
+ $newFile = new File();
+ $newFile->name = $this->file->name;
+ $newFile->parentid = $this->file->parentid;
+ $newFile->value = gzencode( $this->file->loadValue(),1 );
+ $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP );
+ $newFile->add();
+ }
+
+ break;
+
+ case 'bzip2':
+ if ( $this->getRequestVar('replace')=='1' )
+ {
+ $this->file->value = bzcompress( $this->file->loadValue() );
+ $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' );
+ $this->file->save();
+ $this->file->saveValue();
+
+ }
+ else
+ {
+ $newFile = new File();
+ $newFile->name = $this->file->name;
+ $newFile->parentid = $this->file->parentid;
+ $newFile->value = bzcompress( $this->file->loadValue() );
+ $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' );
+ $newFile->add();
+ }
+
+ break;
+ default:
+ die( 'unknown compress type: '.$format );
+ }
+
+ $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK);
+ $this->callSubAction('edit');
+ }
+
+
+ /**
+ * Datei veroeffentlichen
+ */
+ function pubView()
+ {
+ }
+
+
+ /**
+ * Datei veroeffentlichen
+ */
+ function pubPost()
+ {
+ $this->file->publish();
+ $this->file->publish->close();
+
+ $this->addNotice('file',$this->file->fullFilename,'PUBLISHED'.($this->file->publish->ok?'':'_ERROR'),$this->file->publish->ok,array(),$this->file->publish->log);
+ }
+
+
+
+ function getCompressionTypes()
+ {
+ $compressionTypes = array();
+ if ( function_exists('gzencode' ) ) $compressionTypes[] = 'gz';
+ //if ( function_exists('gzencode' ) ) $compressionTypes[] = 'zip';
+ if ( function_exists('bzipcompress') ) $compressionTypes[] = 'bz2';
+ return $compressionTypes;
+ }
+
+ function getArchiveTypes()
+ {
+ $archiveTypes = array();
+ $archiveTypes[] = 'tar';
+ $archiveTypes[] = 'zip';
+ return $archiveTypes;
+ }
+
+
+
+ function checkMenu( $name )
+ {
+ $archiveTypes = $this->getArchiveTypes();
+ $compressionTypes = $this->getCompressionTypes();
+
+ switch( $name )
+ {
+ case 'uncompress':
+ return !readonly() && in_array($this->file->extension,$compressionTypes);
+
+ case 'compress':
+ return !readonly() && !in_array($this->file->extension,$compressionTypes);
+
+ case 'extract':
+ return !readonly() && in_array($this->file->extension,$archiveTypes);
+
+ case 'size':
+ return !readonly() && $this->file->isImage();
+
+ case 'editvalue':
+ return !readonly() && substr($this->file->mimeType(),0,5)=='text/';
+
+ case 'aclform':
+ return !readonly();
+
+ default:
+ return true;
+ }
+ }
+
+
+
+ /**
+ * 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->file->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->file->objectid ] = array('id'=>$this->file->objectid,'name'=>$this->file->name,'type'=>'file','self'=>true,'children'=>&$elementChildren);
+
+
+ //Html::debug($structure);
+
+ $this->setTemplateVar('outline',$structure);
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/FilebrowserAction.class.php b/modules/cms-core/action/FilebrowserAction.class.php
@@ -0,0 +1,261 @@
+<?php
+
+namespace cms\action;
+
+
+use Http;
+use Session;
+use \Html;
+
+// 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 zum Bearbeiten einer Datei
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class FilebrowserAction extends ObjectAction
+{
+ public $security = SECURITY_USER;
+
+ var $command;
+ var $resourceType;
+
+ /**
+ * Ordner
+ *
+ * @var String
+ */
+ var $currentFolder;
+
+ /**
+ * Aktueller Ordner
+ *
+ * @var Object
+ */
+ var $folder;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ if ( $this->getRequestId() != 0 )
+ {
+ $fid = $this->getRequestId();
+ }
+ else
+ {
+ $project = Session::getProject();
+ $fid = $project->getRootObjectId();
+ }
+
+ $this->folder = new Folder( $fid );
+ $this->folder->load();
+
+
+ }
+
+
+
+ /**
+ *
+ */
+ function show()
+ {
+ Http::notAuthorized('no subaction found');
+ }
+
+
+ /**
+ * Datei-Upload.
+ *
+ */
+ public function directuploadPost()
+ {
+ $upload = new Upload( $this->getRequestVar('name','abc') );
+
+ if ( !$upload->isValid() )
+ {
+ echo 'Upload failed, reason: '.$upload->error;
+ }
+ else
+ {
+ $file = new File();
+ $file->parentid = $this->folder->objectid;
+ $file->name = $upload->filename;
+ $file->filename = $upload->filename;
+ $file->extension = $upload->extension;
+ $file->value = $upload->value;
+ $file->add();
+
+ $newId = $file->objectid;
+ $newUrl = str_replace('&','&',Html::url('file','show',$newId,array('oid'=>'__OID__'.$newId.'__')));
+
+ echo '<script type="text/javascript">' ;
+ echo 'window.parent.CKEDITOR.tools.callFunction('.$this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER).",'".$newUrl."','');</script>";
+ echo '</script>' ;
+ echo 'OK' ;
+ }
+
+ }
+
+
+ public function browseView()
+ {
+ global $conf_php;
+ $funcNum = $this->getRequestVar('CKEditorFuncNum',OR_FILTER_NUMBER);
+
+ if ( ! $this->folder->isRoot )
+ $this->setTemplateVar('up_url',Html::url('filebrowser','browse',$this->folder->parentid,array('CKEditorFuncNum'=>$funcNum)));
+
+ $user = Session::getUser();
+ $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
+ $this->setTemplateVar('style',$user->style );
+
+ $list = array();
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjects() as $o )
+ {
+ $id = $o->objectid;
+
+ if ( $o->hasRight(ACL_READ) )
+ {
+ $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
+ $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
+ $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
+ if ( $list[$id]['desc'] == '' )
+ $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
+
+ $list[$id]['type'] = $o->getType();
+
+ $list[$id]['icon' ] = $o->getType();
+ $list[$id]['class'] = $o->getType();
+ if ( $o->isFolder )
+ $list[$id]['url' ] = Html::url('filebrowser','browse',$id,array('CKEditorFuncNum'=>$funcNum) );
+ else
+ $list[$id]['url' ] = "javascript:window.top.opener.CKEDITOR.tools.callFunction($funcNum,'".Html::url('file','show',$id,array('oid'=>'__OID__'.$id.'__'))."','');window.top.close();window.top.opener.focus();";
+
+
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
+
+ if ( $file->isImage() )
+ {
+ $list[$id]['icon' ] = 'image';
+ $list[$id]['class'] = 'image';
+ //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
+ }
+// if ( substr($file->mimeType(),0,5) == 'text/' )
+// $list[$id]['icon'] = 'text';
+ }
+
+ $list[$id]['date'] = $o->lastchangeDate;
+ $list[$id]['user'] = $o->lastchangeUser;
+ }
+ }
+
+ $this->setTemplateVar('object' ,$list );
+ $this->setTemplateVar('CKEditorFuncNum',$funcNum );
+ $this->setTemplateVar('token',token() );
+ $this->setTemplateVar('id',$this->folder->objectid );
+ }
+
+
+ public function addfolderPost()
+ {
+
+ $filename = $this->getRequestVar('name');
+
+ if ( empty($filename) )
+ {
+ $this->addNotice('folder',$this->name,'ADDED',OR_NOTICE_ERROR);
+ }
+ elseif( !$this->folder->hasRight(ACL_CREATE_FOLDER) )
+ {
+ $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR);
+ }
+ elseif( $this->folder->hasFilename( $filename ) )
+ {
+ $this->addNotice('folder',$this->name,'ERROR',OR_NOTICE_ERROR);
+
+ }
+ else
+ {
+ $newFolder = new Folder();
+ $newFolder->parentid = $this->folder->objectid;
+ $newFolder->filename = $filename;
+ $newFolder->name = $filename;
+ $newFolder->add();
+
+ $this->addNotice('folder',$this->folder->name,'ADDED',OR_NOTICE_OK);
+ }
+ }
+
+
+
+ public function uploadPost()
+ {
+ if ( $this->hasRequestVar('name') )
+ $name = $this->getRequestVar('name','abc');
+ else
+ $name = 'file';
+
+ $upload = new Upload($name);
+
+ if ( !$upload->isValid() )
+ {
+ Html::debug($upload);
+ $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
+ return;
+ }
+ // Pr�fen der maximal erlaubten Dateigr��e.
+ elseif ( $upload->size < 0 )
+ {
+ // Maximale Dateigr��e ist �berschritten
+ $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
+ return;
+ }
+ elseif( $upload->size > 0 )
+ {
+ $file = new File();
+ $file->desc = '';
+ $file->filename = $upload->filename;
+ $file->name = $upload->filename;
+ $file->extension = $upload->extension;
+ $file->size = $upload->size;
+ $file->parentid = $this->folder->objectid;
+
+ $file->value = $upload->value;
+
+ $file->add(); // Datei hinzufuegen
+ $this->folder->setTimestamp();
+ $this->addNotice('file',$file->name,'ADDED','ok');
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/FolderAction.class.php b/modules/cms-core/action/FolderAction.class.php
@@ -0,0 +1,1566 @@
+<?php
+
+namespace cms\action;
+
+use ArchiveTar;
+use cms\model\Template;
+use cms\model\Page;
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\File;
+use cms\model\Link;
+
+use cms\model\Url;
+use Http;
+use Publish;
+use Session;
+use \Html;
+use Text;
+use Upload;
+
+// 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 zum Bearbeiten eines Ordners
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class FolderAction extends ObjectAction
+{
+ public $security = SECURITY_USER;
+
+ private $folder;
+
+ public function __construct()
+ {
+ $this->folder = new Folder( $this->getRequestId() );
+ $this->folder->load();
+ }
+
+
+
+ /**
+ * Neues Objekt anlegen.<br>
+ * Dies kann ein(e) Verzeichnis, Seite, Verkn�pfung oder Datei sein.<br>
+ */
+ public function createPost()
+ {
+ global $conf;
+ $type = $this->getRequestVar('type' );
+
+ switch( $type )
+ {
+ case 'folder':
+ $name = $this->getRequestVar('folder_name');
+
+ if ( !empty($name) )
+ {
+ $f = new Folder();
+ $f->name = $name;
+ $f->parentid = $this->folder->objectid;
+ $f->add();
+ $this->folder->setTimestamp();
+ $this->addNotice('folder',$f->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('folder_name');
+ $this->callSubAction('create');
+ }
+ break;
+
+ case 'file':
+ $upload = new Upload();
+
+ if ( !$upload->isValid() )
+ {
+ $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
+ $this->callSubAction('createfile');
+ return;
+ }
+ // Pr�fen der maximal erlaubten Dateigr��e.
+ elseif ( $upload->size > $this->maxFileSize() )
+ {
+ // Maximale Dateigr��e ist �berschritten
+ $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
+ $this->callSubAction('createfile');
+ return;
+ }
+ elseif( $upload->size > 0 )
+ {
+ $file = new File();
+ $file->desc = '';
+ $file->filename = $upload->filename;
+ $file->name = $upload->filename;
+ $file->extension = $upload->extension;
+ $file->size = $upload->size;
+ $file->parentid = $this->folder->objectid;
+
+ $file->value = $upload->value;
+
+ $file->add(); // Datei hinzufuegen
+ $this->folder->setTimestamp();
+ $this->addNotice('file',$file->name,'ADDED','ok');
+ }
+
+ break;
+
+ case 'page':
+
+ $name = $this->getRequestVar('page_name');
+ if ( !empty($name) )
+ {
+ $page = new Page();
+ $page->name = $name;
+ $page->templateid = $this->getRequestVar('page_templateid');
+ $page->parentid = $this->folder->objectid;
+ $page->add();
+ $this->folder->setTimestamp();
+
+ $this->addNotice('page',$page->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('page_name');
+ $this->callSubAction('create');
+ }
+ break;
+
+ case 'link':
+
+ $name = $this->getRequestVar('link_name');
+ if ( !empty($name) )
+ {
+ $link = new Link();
+ $link->name = $name;
+ $link->parentid = $this->folder->objectid;
+
+ $link->add();
+ $this->folder->setTimestamp();
+
+ $this->addNotice('link',$link->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('link_name');
+ $this->callSubAction('create');
+ }
+
+ break;
+
+ case 'url':
+
+ $urlValue = $this->getRequestVar('url');
+ if ( !empty($urlValue) )
+ {
+ $url = new Url();
+ $url->name = $urlValue;
+ $url->parentid = $this->folder->objectid;
+
+ $url->url = $urlValue;
+
+ $url->add();
+ $this->folder->setTimestamp();
+
+ $this->addNotice('url',$url->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('url');
+ $this->callSubAction('create');
+ }
+
+ break;
+
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('create');
+
+ }
+
+ }
+
+
+
+ public function createfolderPost()
+ {
+ $type = $this->getRequestVar('type' );
+ $name = $this->getRequestVar('name' );
+ $filename = $this->getRequestVar('filename' );
+ $description = $this->getRequestVar('description');
+
+ if ( !empty($name) )
+ {
+ $f = new Folder();
+ $f->name = $name;
+ $f->filename = $name;
+ $f->desc = $description;
+ $f->parentid = $this->folder->objectid;
+
+ $f->add();
+ $this->addNotice('folder',$f->name,'ADDED','ok');
+ $this->setTemplateVar('objectid',$f->objectid);
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('createfolder');
+ }
+
+ $this->folder->setTimestamp();
+ }
+
+
+
+ public function createfilePost()
+ {
+ $type = $this->getRequestVar('type' );
+ $name = $this->getRequestVar('name' );
+ $filename = $this->getRequestVar('filename' );
+ $description = $this->getRequestVar('description');
+
+ $file = new File();
+
+ // Die neue Datei wird über eine URL geladen und dann im CMS gespeichert.
+ if ( $this->hasRequestVar('url') )
+ {
+ $url = $this->getRequestVar('url');
+ $http = new Http();
+ $http->setUrl( $url );
+
+ $ok = $http->request();
+
+ if ( !$ok )
+ {
+ $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error);
+ $this->callSubAction('createfile');
+ return;
+ }
+
+ $file->desc = $description;
+ $file->filename = basename($url);
+ $file->name = !empty($name)?$name:basename($url);
+ $file->size = strlen($http->body);
+ $file->value = $http->body;
+ $file->parentid = $this->folder->objectid;
+ }
+ else
+ {
+ $upload = new Upload();
+
+ if ( $upload->isValid() )
+ {
+ $file->desc = $description;
+ $file->filename = $upload->filename;
+ $file->name = !empty($name)?$name:$upload->filename;
+ $file->extension = $upload->extension;
+ $file->size = $upload->size;
+ $file->parentid = $this->folder->objectid;
+
+ $file->value = $upload->value;
+ }
+ else
+ {
+ if ( $this->hasRequestVar('name') )
+ {
+ $file->name = $this->getRequestVar('name');
+ $file->desc = $this->getRequestVar('description');
+ $file->filename = $this->getRequestVar('filename', OR_FILTER_FILENAME);
+ $file->parentid = $this->folder->objectid;
+ }
+ else
+ {
+ $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
+ $this->callSubAction('createfile');
+ return;
+ }
+
+ }
+ }
+
+ $file->add(); // Datei hinzufuegen
+ $this->addNotice('file',$file->name,'ADDED','ok');
+ $this->setTemplateVar('objectid',$file->objectid);
+
+ $this->folder->setTimestamp();
+ }
+
+
+
+ public function createlinkPost()
+ {
+ $name = $this->getRequestVar('name' );
+ $filename = $this->getRequestVar('filename' );
+ $description = $this->getRequestVar('description');
+
+ if ( !empty($name) )
+ {
+ $link = new Link();
+ $link->filename = $filename;
+ $link->name = $name;
+ $link->desc = $description;
+ $link->parentid = $this->folder->objectid;
+
+ $link->linkedObjectId = $this->getRequestVar('targetobjectid');
+
+ $link->add();
+
+ $this->addNotice('link',$link->name,'ADDED','ok');
+ $this->setTemplateVar('objectid',$link->objectid);
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('createlink');
+ return;
+ }
+
+ $this->folder->setTimestamp();
+ }
+
+ public function createurlPost()
+ {
+ $name = $this->getRequestVar('name' );
+ $description = $this->getRequestVar('description');
+ $filename = $this->getRequestVar('filename' );
+
+ if ( !empty($name) )
+ {
+ $url = new Url();
+ $url->filename = $filename;
+ $url->name = $name;
+ $url->desc = $description;
+ $url->parentid = $this->folder->objectid;
+
+ $url->url = $this->getRequestVar('url');
+
+ $url->add();
+
+ $this->addNotice('url',$url->name,'ADDED','ok');
+ $this->setTemplateVar('objectid',$url->objectid);
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('createurl');
+ return;
+ }
+
+ $this->folder->setTimestamp();
+ }
+
+
+
+ public function createpagePost()
+ {
+ $type = $this->getRequestVar('type' );
+ $name = $this->getRequestVar('name' );
+ $filename = $this->getRequestVar('filename' );
+ $description = $this->getRequestVar('description');
+
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $page = new Page();
+ $page->name = $name;
+ $page->desc = $description;
+ $page->filename = $filename;
+ $page->templateid = $this->getRequestVar('templateid');
+ $page->parentid = $this->folder->objectid;
+
+ $page->add();
+
+ $this->addNotice('page',$page->name,'ADDED','ok');
+ $this->setTemplateVar('objectid',$page->objectid);
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('createpage');
+ return;
+ }
+
+ $this->folder->setTimestamp();
+ }
+
+
+
+ /**
+ * Abspeichern der Ordner-Eigenschaften. Ist der Schalter "delete" gesetzt, wird
+ * der Ordner stattdessen gel?scht.
+ */
+ public function propPost()
+ {
+ // Ordnereigenschaften speichern
+ if ( $this->getRequestVar('name') != '' )
+ $this->folder->name = $this->getRequestVar('name' ,'full');
+ elseif ($this->getRequestVar('filename') != '' )
+ $this->folder->name = $this->getRequestVar('filename',OR_FILTER_ALPHANUM);
+ else
+ {
+ $this->addValidationError('name');
+ $this->addValidationError('filename');
+ //$this->callSubAction('prop');
+ return;
+ }
+
+ $this->folder->filename = $this->getRequestVar('filename' ,OR_FILTER_ALPHANUM);
+ $this->folder->desc = $this->getRequestVar('description','full' );
+ $this->folder->save();
+ $this->addNotice($this->folder->getType(),$this->folder->name,'PROP_SAVED','ok');
+ }
+
+
+ /**
+ * Reihenfolge von Objekten aendern.
+ */
+ public function orderPost()
+ {
+ $ids = $this->folder->getObjectIds();
+ $seq = 0;
+
+ $order = explode(',',$this->getRequestVar('order') );
+
+ foreach( $order as $objectid )
+ {
+ if ( ! in_array($objectid,$ids) )
+ {
+ Http::serverError('Object-Id '.$objectid.' is not in this folder any more');
+ }
+ $seq++; // Sequenz um 1 erhoehen
+
+ $o = new Object( $objectid );
+ $o->setOrderId( $seq );
+
+ unset( $o ); // Selfmade Garbage Collection :-)
+ }
+
+ $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
+ $this->folder->setTimestamp();
+ }
+
+
+ // Reihenfolge von Objekten aendern
+ public function changesequencePost()
+ {
+ $ids = $this->folder->getObjectIds();
+ $seq = 0;
+ foreach( $ids as $id )
+ {
+ $seq++; // Sequenz um 1 erhoehen
+
+ // Die beiden Ordner vertauschen
+ if ( $id == $this->getRequestVar('objectid1') )
+ $id = $this->getRequestVar('objectid2');
+ elseif ( $id == $this->getRequestVar('objectid2') )
+ $id = $this->getRequestVar('objectid1');
+
+ $o = new Object( $id );
+ $o->setOrderId( $seq );
+
+ unset( $o ); // Selfmade Garbage Collection :-)
+ }
+
+ $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
+ $this->folder->setTimestamp();
+
+ // Ordner anzeigen
+ $this->callSubAction('order');
+
+ }
+
+
+ private function OLD__________editPost()
+ {
+ $type = $this->getRequestVar('type'); // Typ der Aktion, z.B "copy" oder "move"
+
+ switch( $type )
+ {
+ case 'move':
+ case 'copy':
+ case 'link':
+ // Liste von m�glichen Zielordnern anzeigen
+
+ $otherfolder = array();
+ foreach( $this->folder->getAllFolders() as $id )
+ {
+ $f = new Folder( $id );
+
+ // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
+ // von Verkn�pfungen vorhanden sein.
+ //
+ // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
+ // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
+ if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) ||
+ ( ( $type=='move' || $type == 'copy' ) &&
+ ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) )
+ // Zielordner hinzuf�gen
+ $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ }
+
+ // Zielordner-Liste alphabetisch sortieren
+ asort( $otherfolder );
+
+ $this->setTemplateVar('folder',$otherfolder);
+
+ break;
+
+ case 'archive':
+ $this->setTemplateVar('ask_filename','');
+ break;
+
+ case 'delete':
+ $this->setTemplateVar('ask_commit','');
+ break;
+
+ default:
+ $this->addValidationError('type');
+ return;
+
+ } // switch
+
+ $ids = $this->folder->getObjectIds();
+ $objectList = array();
+
+ foreach( $ids as $id )
+ {
+ // Nur, wenn Objekt ausgewaehlt wurde
+ if ( !$this->hasRequestVar('obj'.$id) )
+ continue;
+
+ $o = new Object( $id );
+ $o->load();
+
+ // F�r die gew�nschte Aktion m�ssen pro Objekt die entsprechenden Rechte
+ // vorhanden sein.
+ if ( $type == 'copy' && $o->hasRight( ACL_READ ) ||
+ $type == 'move' && $o->hasRight( ACL_DELETE ) ||
+ $type == 'link' && $o->hasRight( ACL_READ ) ||
+ $type == 'archive' && $o->hasRight( ACL_READ ) ||
+ $type == 'delete' && $o->hasRight( ACL_DELETE ) )
+ $objectList[ $id ] = $o->getProperties();
+ }
+
+ $this->setTemplateVar('type' ,$type );
+ $this->setTemplateVar('objectlist',$objectList );
+
+ // Komma-separierte Liste von ausgew�hlten Objekt-Ids erzeugen
+ $this->setTemplateVar('ids',join(array_keys($objectList),',') );
+ }
+
+
+
+ /**
+ * Verschieben/Kopieren/Loeschen/Verknuepfen von mehreren Dateien in diesem Ordner
+ */
+ public function editPost()
+ {
+ $type = $this->getRequestVar('type');
+ $ids = explode(',',$this->getRequestVar('ids'));
+ $targetObjectId = $this->getRequestVar('targetobjectid');
+
+ // Prüfen, ob Schreibrechte im Zielordner bestehen.
+ switch( $type )
+ {
+ case 'move':
+ case 'copy':
+ case 'link':
+ $f = new Folder( $targetObjectId );
+
+ // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
+ // von Verkn�pfungen vorhanden sein.
+ //
+ // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
+ // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
+ if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) ||
+ ( ( $type=='move' || $type == 'copy' ) &&
+ ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) )
+ {
+ // OK
+ }
+ else
+ {
+ $this->addValidationError('targetobjectid','no_rights');
+ return;
+ }
+
+ break;
+ default:
+ }
+
+
+ $ids = $this->folder->getObjectIds();
+ $objectList = array();
+
+ foreach( $ids as $id )
+ {
+ // Nur, wenn Objekt ausgewaehlt wurde
+ if ( !$this->hasRequestVar('obj'.$id) )
+ continue;
+
+ $o = new Object( $id );
+ $o->load();
+
+ // Fuer die gewuenschte Aktion muessen pro Objekt die entsprechenden Rechte
+ // vorhanden sein.
+ if ( $type == 'copy' && $o->hasRight( ACL_READ ) ||
+ $type == 'move' && $o->hasRight( ACL_WRITE ) ||
+ $type == 'link' && $o->hasRight( ACL_READ ) ||
+ $type == 'archive' && $o->hasRight( ACL_READ ) ||
+ $type == 'delete' && $o->hasRight( ACL_DELETE ) )
+ $objectList[ $id ] = $o->getProperties();
+ else
+ $this->addNotice($o->getType(),$o->name,'no_rights',OR_NOTICE_WARN);
+ }
+
+ $ids = array_keys($objectList);
+
+ if ( $type == 'archive' )
+ {
+ require_once('serviceClasses/ArchiveTar.class.php');
+ $tar = new ArchiveTar();
+ $tar->files = array();
+
+ foreach( $ids as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ if ( $o->isFile )
+ {
+ $file = new File($id);
+ $file->load();
+
+ // Datei dem Archiv hinzufügen.
+ $info = array();
+ $info['name'] = $file->filenameWithExtension();
+ $info['file'] = $file->loadValue();
+ $info['mode'] = 0600;
+ $info['size'] = $file->size;
+ $info['time'] = $file->lastchangeDate;
+ $info['user_id' ] = 1000;
+ $info['group_id'] = 1000;
+ $info['user_name' ] = 'nobody';
+ $info['group_name'] = 'nobody';
+
+ $tar->numFiles++;
+ $tar->files[]= $info;
+ }
+ else
+ {
+ // Was anderes als Dateien ignorieren.
+ $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ }
+
+ }
+
+ // TAR speichern.
+ $tarFile = new File();
+ $tarFile->name = lang('GLOBAL_ARCHIVE').' '.$this->getRequestVar('filename');
+ $tarFile->filename = $this->getRequestVar('filename');
+ $tarFile->extension = 'tar';
+ $tarFile->parentid = $this->folder->objectid;
+
+ $tar->__generateTAR();
+ $tarFile->value = $tar->tar_file;
+ $tarFile->add();
+ }
+ else
+ {
+ foreach( $ids as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ switch( $type )
+ {
+ case 'move':
+ if ( $o->isFolder )
+ {
+ $f = new Folder( $id );
+ $allsubfolders = $f->getAllSubFolderIds();
+
+ // Plausibilisierungsprüfung:
+ //
+ // Wenn
+ // - Das Zielverzeichnis sich nicht in einem Unterverzeichnis des zu verschiebenen Ordners liegt
+ // und
+ // - Das Zielverzeichnis nicht der zu verschiebene Ordner ist
+ // dann verschieben
+ if ( !in_array($targetObjectId,$allsubfolders) && $id != $targetObjectId )
+ {
+ $this->addNotice($o->getType(),$o->name,'MOVED','ok');
+ $o->setParentId( $targetObjectId );
+ }
+ else
+ {
+ $this->addNotice($o->getType(),$o->name,'ERROR','error');
+ }
+ }
+ else
+ {
+ $o->setParentId( $targetObjectId );
+ $this->addNotice($o->getType(),$o->name,'MOVED','ok');
+ }
+ break;
+
+ case 'copy':
+ switch( $o->getType() )
+ {
+ case 'folder':
+ // Ordner zur Zeit nicht kopieren
+ // Funktion waere zu verwirrend
+ $this->addNotice($o->getType(),$o->name,'CANNOT_COPY_FOLDER','error');
+ break;
+
+ case 'file':
+ $f = new File( $id );
+ $f->load();
+ $f->filename = '';
+ $f->name = lang('COPY_OF').' '.$f->name;
+ $f->parentid = $targetObjectId;
+ $f->add();
+ $f->copyValueFromFile( $id );
+
+ $this->addNotice($o->getType(),$o->name,'COPIED','ok');
+ break;
+
+ case 'page':
+ $p = new Page( $id );
+ $p->load();
+ $p->filename = '';
+ $p->name = lang('COPY_OF').' '.$p->name;
+ $p->parentid = $targetObjectId;
+ $p->add();
+ $p->copyValuesFromPage( $id );
+ $this->addNotice($o->getType(),$o->name,'COPIED','ok');
+ break;
+
+ case 'link':
+ $l = new Link( $id );
+ $l->load();
+ $l->filename = '';
+ $l->name = lang('COPY_OF').' '.$l->name;
+ $l->parentid = $targetObjectId;
+ $l->add();
+ $this->addNotice($o->getType(),$o->name,'COPIED','ok');
+ break;
+
+ default:
+ die('fatal: what type to delete?');
+ }
+ $notices[] = lang('COPIED');
+ break;
+
+ case 'link':
+
+ if ( $o->isFile ||
+ $o->isPage ) // Nur Seiten oder Dateien sind verknuepfbar
+ {
+ $link = new Link();
+ $link->parentid = $targetObjectId;
+
+ $link->linkedObjectId = $id;
+ $link->isLinkToObject = true;
+ $link->name = lang('LINK_TO').' '.$o->name;
+ $link->add();
+ $this->addNotice($o->getType(),$o->name,'LINKED','ok');
+ }
+ else
+ {
+ $this->addNotice($o->getType(),$o->name,'ERROR','error');
+ }
+ break;
+
+ case 'delete':
+
+ if ( $this->hasRequestVar('confirm') )
+ {
+ switch( $o->getType() )
+ {
+ case 'folder':
+ $f = new Folder( $id );
+ $f->deleteAll();
+ break;
+
+ case 'file':
+ $f = new File( $id );
+ $f->delete();
+ break;
+
+ case 'page':
+ $p = new Page( $id );
+ $p->load();
+ $p->delete();
+ break;
+
+ case 'link':
+ $l = new Link( $id );
+ $l->delete();
+ break;
+
+ case 'url':
+ $u = new Url( $id );
+ $u->delete();
+ break;
+
+ default:
+ throw new \LogicException("Error while deleting: Unknown type: {$o->getType()}");
+ }
+ $this->addNotice($o->getType(),$o->name,'DELETED',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ }
+
+ break;
+
+ default:
+ $this->addNotice($o->getType(),$o->name,'ERROR','error');
+ }
+
+ }
+ }
+
+ $this->folder->setTimestamp();
+ }
+
+
+ /**
+ * Reihenfolge von Objekten aendern.
+ */
+ public function reorderPost()
+ {
+ $type = $this->getRequestVar('type');
+
+ switch( $type )
+ {
+ case 'type':
+ $ids = $this->folder->getObjectIdsByType();
+ break;
+
+ case 'name':
+ $ids = $this->folder->getChildObjectIdsByName();
+ break;
+
+ case 'lastchange':
+ $ids = $this->folder->getObjectIdsByLastChange();
+ break;
+
+ case 'flip':
+ $ids = $this->folder->getObjectIds();
+ $ids = array_reverse( $ids ); // Reihenfolge drehen
+
+ break;
+
+ default:
+ Http::sendStatus(400,'Bad request','Unknown reordertype: '.$type );
+ }
+
+ // Und jetzt die neu ermittelte Reihenfolge speichern
+ $seq = 0;
+ foreach( $ids as $id )
+ {
+ $seq++; // Sequenz um 1 erhoehen
+
+ $o = new Object( $id );
+ $o->setOrderId( $seq );
+
+ unset( $o );
+ }
+ $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
+
+ $this->folder->setTimestamp();
+ }
+
+
+ public function settopPost()
+ {
+ $o = new Object( $this->getRequestVar('objectid1') );
+ $o->setOrderId( 1 );
+
+ $ids = $this->folder->getObjectIds();
+ $seq = 1;
+
+ foreach( $ids as $id )
+ {
+ if ( $id != $this->getRequestVar('objectid1') )
+ {
+ $seq++; // Sequenz um 1 erhoehen
+
+ $o = new Object( $id );
+ $o->setOrderId( $seq );
+
+ unset( $o ); // Selfmade Garbage Collection :-)
+ }
+ }
+
+ $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
+ $this->folder->setTimestamp();
+
+ // Ordner anzeigen
+ $this->callSubAction('order');
+ }
+
+
+ public function setbottomPost()
+ {
+ $ids = $this->folder->getObjectIds();
+ $seq = 0;
+
+ foreach( $ids as $id )
+ {
+ if ( $id != $this->getRequestVar('objectid1') )
+ {
+ $seq++; // Sequenz um 1 erhoehen
+
+ $o = new Object( $id );
+ $o->setOrderId( $seq );
+
+ unset( $o ); // Selfmade Garbage Collection :-)
+ }
+ }
+
+ $seq++; // Sequenz um 1 erhoehen
+ $o = new Object( $this->getRequestVar('objectid1') );
+ $o->setOrderId( $seq );
+
+ $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
+ $this->folder->setTimestamp();
+
+ // Ordner anzeigen
+ $this->callSubAction('order');
+
+ }
+
+
+ /**
+ * Alias für Methode 'create'.
+ */
+ public function newView()
+ {
+ $this->nextSubAction('create');
+ }
+
+
+ /**
+ * Alias für Methode 'create'.
+ */
+ public function newPost()
+ {
+ $this->nextSubAction('create');
+ }
+
+
+ public function createView()
+ {
+ // Maximale Dateigroesse.
+ $maxSizeBytes = $this->maxFileSize();
+ $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
+ $this->setTemplateVar('maxlength',$maxSizeBytes );
+
+ $all_templates = Template::getAll();
+ $this->setTemplateVar('templates' ,$all_templates );
+
+ if ( count($all_templates) == 0 )
+ $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
+
+ $this->setTemplateVar('objectid' ,$this->folder->objectid );
+ }
+
+
+
+ public function createfolderView()
+ {
+ $this->setTemplateVar('objectid' ,$this->folder->objectid );
+ }
+
+
+
+ /**
+ * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br>
+ * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br>
+ *
+ * @return Integer maximale Dateigroesse in Bytes
+ */
+ private function maxFileSize()
+ {
+ global $conf;
+
+ // When querying memory size values:
+ // Many ini memory size values, such as upload_max_filesize,
+ // are stored in the php.ini file in shorthand notation.
+ // ini_get() will return the exact string stored in the php.ini file
+ // and NOT its integer equivalent.
+ $sizes = array(10*1024*1024*1024); // Init with 10GB enough? :)
+
+ foreach( array('upload_max_filesize','post_max_size','memory_limit') as $var )
+ {
+ $v = $this->stringToBytes(ini_get($var));
+
+ if ($v > 0 )
+ $sizes[] = $v;
+ }
+
+ $confMaxSize = intval($conf['content']['file']['max_file_size'])*1024;
+ if ( $confMaxSize > 0 )
+ $sizes[] = $confMaxSize;
+
+ return min($sizes);
+ }
+
+
+ /**
+ * Hochladen einer Datei.
+ *
+ */
+ public function createfileView()
+ {
+ // Maximale Dateigroesse.
+ $maxSizeBytes = $this->maxFileSize();
+ $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
+ $this->setTemplateVar('maxlength',$maxSizeBytes );
+
+ $this->setTemplateVar('objectid',$this->folder->objectid );
+ }
+
+
+ /**
+ * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie
+ * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br>
+ * <br>
+ * Quelle: http://de.php.net/manual/de/function.ini-get.php
+ *
+ * @param String Abgek�rzter Bytewert
+ * @return Integer Byteanzahl
+ */
+ private function stringToBytes($val)
+ {
+ $val = trim($val);
+ $last = strtolower($val{strlen($val)-1});
+ // Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden!
+ switch($last)
+ {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+
+ return intval($val);
+ }
+
+
+
+ public function createlinkView()
+ {
+ $this->setTemplateVar('objectid' ,$this->folder->objectid );
+ }
+
+
+ public function createurlView()
+ {
+ }
+
+
+ public function createpageView()
+ {
+ $all_templates = Template::getAll();
+ $this->setTemplateVar('templates' ,$all_templates );
+ $this->setTemplateVar('objectid' ,$this->folder->objectid );
+
+ if ( count($all_templates) == 0 )
+ $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
+ }
+
+
+ /**
+ * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
+ * auf die Standardausgabe geschrieben
+ */
+ private function previewViewUnused()
+ {
+ $this->setTemplateVar('preview_url',Html::url('folder','show',$this->folder->objectid,array('target'=>'none') ) );
+ }
+
+
+
+ /**
+ * Anzeige aller Objekte in diesem Ordner.
+ */
+ public function previewView()
+ {
+ global $conf_php;
+
+ if ( ! $this->folder->isRoot )
+ $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid));
+
+ $list = array();
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjects() as $o )
+ {
+ /* @var $o Object */
+
+ $id = $o->objectid;
+
+ if ( $o->hasRight(ACL_READ) )
+ {
+ $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
+ $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
+ $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
+ if ( $list[$id]['desc'] == '' )
+ $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
+
+ $list[$id]['type'] = $o->getType();
+ $list[$id]['id' ] = $id;
+
+ $list[$id]['icon' ] = $o->getType();
+ $list[$id]['class'] = $o->getType();
+ $list[$id]['url' ] = Html::url($o->getType(),'',$id);
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
+
+ if ( $file->isImage() )
+ {
+ $list[$id]['icon' ] = 'image';
+ $list[$id]['class'] = 'image';
+ //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
+ }
+// if ( substr($file->mimeType(),0,5) == 'text/' )
+// $list[$id]['icon'] = 'text';
+ }
+
+ $list[$id]['date'] = $o->lastchangeDate;
+ $list[$id]['user'] = $o->lastchangeUser;
+ }
+ }
+
+ $this->setTemplateVar('object' ,$list );
+ }
+
+
+ /**
+ * Anzeige aller Objekte in diesem Ordner.
+ */
+ public function contentView()
+ {
+ global $conf_php;
+
+ if ( ! $this->folder->isRoot )
+ $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid));
+
+ $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
+
+ $list = array();
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjects() as $o )
+ {
+ /* @var $o Object */
+ $id = $o->objectid;
+
+ if ( $o->hasRight(ACL_READ) )
+ {
+ $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
+ $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
+ $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
+ if ( $list[$id]['desc'] == '' )
+ $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('IMAGE').' '.$id;
+
+ $list[$id]['type'] = $o->getType();
+ $list[$id]['id' ] = $id;
+
+ $list[$id]['icon' ] = $o->getType();
+ $list[$id]['class'] = $o->getType();
+ $list[$id]['url' ] = Html::url($o->getType(),'',$id);
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
+
+ if ( $file->isImage() )
+ {
+ $list[$id]['icon' ] = 'image';
+ $list[$id]['class'] = 'image';
+ //$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
+ }
+// if ( substr($file->mimeType(),0,5) == 'text/' )
+// $list[$id]['icon'] = 'text';
+ }
+
+ $list[$id]['date'] = $o->lastchangeDate;
+ $list[$id]['user'] = $o->lastchangeUser;
+ }
+ }
+
+ $this->setTemplateVar('object' ,$list );
+ }
+
+
+ public function editView()
+ {
+ global $conf_php;
+
+ $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
+
+ $list = array();
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjects() as $o )
+ {
+ /* @var $o Object */
+ $id = $o->objectid;
+
+ if ( $o->hasRight(ACL_READ) )
+ {
+ $list[$id]['objectid'] = $id;
+ $list[$id]['id' ] = 'obj'.$id;
+ $list[$id]['name' ] = $o->name;
+ $list[$id]['filename'] = $o->filename;
+ $list[$id]['desc' ] = $o->desc;
+ if ( $list[$id]['desc'] == '' )
+ $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
+
+ $list[$id]['type'] = $o->getType();
+
+ $list[$id]['icon'] = $o->getType();
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ $list[$id]['size'] = $file->size;
+ $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
+
+ if ( substr($file->mimeType(),0,6) == 'image/' )
+ $list[$id]['icon'] = 'image';
+// if ( substr($file->mimeType(),0,5) == 'text/' )
+// $list[$id]['icon'] = 'text';
+ }
+
+ $list[$id]['url' ] = Html::url($o->getType(),'',$id);
+ $list[$id]['date'] = date( lang('DATE_FORMAT'),$o->lastchangeDate );
+ $list[$id]['user'] = $o->lastchangeUser;
+
+ if ( $this->hasRequestVar("markall") || $this->hasRequestVar('obj'.$id) )
+ $this->setTemplateVar('obj'.$id,'1');
+ }
+ }
+
+ if ( $this->folder->hasRight(ACL_WRITE) )
+ {
+ // Alle anderen Ordner ermitteln
+ $otherfolder = array();
+ foreach( $this->folder->getAllFolders() as $id )
+ {
+ $f = new Folder( $id );
+ if ( $f->hasRight( ACL_WRITE ) )
+ $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ }
+ asort( $otherfolder );
+
+ $this->setTemplateVar('folder',$otherfolder);
+
+ // URLs zum Umsortieren der Eintraege
+ $this->setTemplateVar('order_url' ,Html::url('folder','order',$this->folder->id) );
+ }
+
+ $actionList = array();
+ $actionList[] = 'copy';
+ $actionList[] = 'link';
+ $actionList[] = 'archive';
+
+ if ( $this->folder->hasRight(ACL_WRITE) )
+ {
+ $actionList[] = 'move';
+ $actionList[] = 'delete';
+ }
+
+ $this->setTemplateVar('actionlist',$actionList );
+ $this->setTemplateVar('defaulttype',$this->getRequestVar('type','alpha'));
+
+ $this->setTemplateVar('object' ,$list );
+ $this->setTemplateVar('act_objectid',$this->folder->id);
+
+ $rootFolder = new Folder( Folder::getRootFolderId() );
+ $rootFolder->load();
+
+ $this->setTemplateVar('properties' ,$this->folder->getProperties() );
+ $this->setTemplateVar('rootfolderid' ,$rootFolder->id );
+ $this->setTemplateVar('rootfoldername',$rootFolder->name);
+ }
+
+
+
+
+ public function rootView()
+ {
+ $rootFolder = new Folder( Folder::getRootFolderId() );
+ $rootFolder->load();
+
+ $this->setTemplateVar('rootfolderid' ,$rootFolder->id );
+ $this->setTemplateVar('rootfoldername',$rootFolder->name);
+ }
+
+
+
+ /**
+ * Reihenfolge bearbeiten.
+ */
+ public function orderView()
+ {
+ global $conf_php;
+
+ $list = array();
+ $last_objectid = 0;
+
+ // Schleife ueber alle Objekte in diesem Ordner
+ foreach( $this->folder->getObjects() as $o )
+ {
+ /* @var $o Object */
+ $id = $o->objectid;
+
+ if ( $o->hasRight(ACL_READ) )
+ {
+ $list[$id]['id' ] = $id;
+ $list[$id]['name'] = Text::maxLength( $o->name ,30);
+ $list[$id]['filename'] = Text::maxLength( $o->filename ,20);
+ $list[$id]['desc'] = Text::maxLength( $o->desc ,30);
+ if ( $list[$id]['desc'] == '' )
+ $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
+
+ $list[$id]['type'] = $o->getType();
+
+ $list[$id]['icon'] = $o->getType();
+
+ if ( $o->getType() == 'file' )
+ {
+ $file = new File( $id );
+ $file->load();
+ $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
+
+ if ( $file->isImage() )
+ $list[$id]['icon'] = 'image';
+ }
+
+ $list[$id]['url' ] = Html::url($o->getType(),'',$id);
+ $list[$id]['date'] = $o->lastchangeDate;
+ $list[$id]['user'] = $o->lastchangeUser;
+
+ if ( $last_objectid != 0 && $o->hasRight(ACL_WRITE) )
+ {
+ $list[$id ]['upurl' ] = Html::url('folder','changesequence',0,array(
+ 'objectid1'=>$id,
+ 'objectid2'=>$last_objectid));
+ $list[$last_objectid]['downurl' ] = $list[$id]['upurl'];
+ $list[$last_objectid]['bottomurl'] = Html::url('folder','setbottom',0,array(
+ 'objectid1'=>$last_objectid));
+ $list[$id ]['topurl' ] = Html::url('folder','settop',0,array(
+ 'objectid1'=>$id));
+ }
+
+ $last_objectid = $id;
+ }
+ }
+
+ $this->setTemplateVar('flip_url' ,Html::url('folder','reorder',0,array('type'=>'flip' )) );
+ $this->setTemplateVar('orderbyname_url' ,Html::url('folder','reorder',0,array('type'=>'name' )) );
+ $this->setTemplateVar('orderbytype_url' ,Html::url('folder','reorder',0,array('type'=>'type' )) );
+ $this->setTemplateVar('orderbylastchange_url',Html::url('folder','reorder',0,array('type'=>'lastchange')) );
+ $this->setTemplateVar('object' ,$list );
+ $this->setTemplateVar('act_objectid',$this->folder->id);
+ $this->setTemplateVar('token',token() );
+ }
+
+
+
+ /**
+ * Eigenschaften anzeigen.
+ */
+ public function propView()
+ {
+ $this->setTemplateVars( $this->folder->getProperties() );
+ }
+
+ /**
+ * Infos anzeigen.
+ */
+ public function infoView()
+ {
+ $this->setTemplateVars( $this->folder->getProperties() );
+ $this->setTemplateVar( 'full_filename',$this->folder->full_filename() );
+ }
+
+
+
+ /**
+ * 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;
+
+ $parents = $this->folder->parentObjectNames(false,true);
+
+ foreach( $parents as $id=>$name)
+ {
+ //Html::debug($name,"Name");
+
+ unset($children);
+ unset($o);
+ $children = array();
+ $o = array('id'=>$id,'name'=>$name,'type'=>'folder','level'=>++$nr,'children'=>&$children);
+
+ if ( $id == $this->folder->objectid)
+ $o['self'] = true;
+
+ $tmp[$id] = &$o;;
+
+ unset($tmp);
+
+ $tmp = &$children;
+ }
+
+
+ $contents = $this->folder->getObjects();
+
+ unset($children);
+ unset($o);
+
+ $children = array();
+ foreach( $contents as $o )
+ {
+ /* @var $o Object */
+ $children[$o->objectid] = array('id'=>$o->objectid,'name'=>$o->name,'type'=>$o->getType());
+ }
+ $tmp+= $children;
+
+ //Html::debug($structure);
+
+ $this->setTemplateVar('outline',$structure);
+ }
+
+
+ public function pubView()
+ {
+ // Schalter nur anzeigen, wenn sinnvoll
+ $this->setTemplateVar('files' ,count($this->folder->getFiles()) > 0 );
+ $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 );
+ $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 );
+
+ //$this->setTemplateVar('clean' ,$this->folder->isRoot );
+ // Gefaehrliche Option, da dies bestehende Dateien, die evtl. nicht zum CMS gehören, überschreibt.
+ // Daher deaktiviert.
+ $this->setTemplateVar('clean' ,false );
+ }
+
+
+ public function pubPost()
+ {
+ if ( !$this->folder->hasRight( ACL_PUBLISH ) )
+ die('no rights for publish');
+
+ $subdirs = ( $this->hasRequestVar('subdirs') );
+ $pages = ( $this->hasRequestVar('pages' ) );
+ $files = ( $this->hasRequestVar('files' ) );
+
+ Session::close();
+ $publish = new Publish();
+
+ $this->folder->publish = &$publish;
+ $this->folder->publish( $pages,$files,$subdirs );
+ $this->folder->publish->close();
+
+ $list = array();
+ foreach( $publish->publishedObjects as $o )
+ $list[] = $o['full_filename'];
+
+ if ( !$publish->ok )
+ $this->addNotice('folder',$this->folder->name,'PUBLISHED_ERROR',OR_NOTICE_ERROR,array(),$publish->log);
+ else
+ $this->addNotice('folder',$this->folder->name,'PUBLISHED',OR_NOTICE_OK,array(),$list);
+
+ // Wenn gewuenscht, das Zielverzeichnis aufraeumen
+ if ( $this->hasRequestVar('clean') )
+ $publish->clean();
+ }
+
+
+
+ public function checkMenu( $name )
+ {
+ switch( $name)
+ {
+ case 'createfolder':
+ return !readonly() && $this->folder->hasRight(ACL_CREATE_FOLDER);
+
+ case 'createfile':
+ return !readonly() && $this->folder->hasRight(ACL_CREATE_FILE);
+
+ case 'createlink':
+ return !readonly() && $this->folder->hasRight(ACL_CREATE_LINK);
+
+ case 'createpage':
+ return !readonly() && $this->folder->hasRight(ACL_CREATE_PAGE);
+
+ case 'remove':
+ return !readonly() && count($this->folder->getObjectIds()) == 0;
+
+ case 'select':
+ case 'order':
+ case 'aclform':
+ return !readonly();
+
+ default:
+ return true;
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/GroupAction.class.php b/modules/cms-core/action/GroupAction.class.php
@@ -0,0 +1,321 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Acl;
+use cms\model\User;
+use cms\model\Project;
+use cms\model\Group;
+use cms\model\Object;
+use cms\model\Language;
+
+use \Html;
+// 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 zum Bearbeiten einer Benutzergruppe.
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class GroupAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ private $group;
+
+
+ function __construct()
+ {
+ $this->group = new Group( $this->getRequestId() );
+ $this->group->load();
+ $this->setTemplateVar( 'groupid',$this->group->groupid );
+ }
+
+
+
+ function removePost()
+ {
+ if ( $this->hasRequestVar('confirm') )
+ {
+ $this->group->delete();
+
+ $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ }
+ }
+
+
+
+ function removeView()
+ {
+ $this->setTemplateVars( $this->group->getProperties() );
+ }
+
+
+
+ function editPost()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $this->group->name = $this->getRequestVar('name');
+
+ $this->group->save();
+
+ $this->addNotice('group',$this->group->name,'SAVED','ok');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('edit');
+ }
+ }
+
+
+ function adduser()
+ {
+ $this->setTemplateVar('users',$this->group->getOtherUsers());
+ }
+
+
+ /**
+ * Benutzer zur Gruppe hinzuf�gen.<br>
+ * Es kann eine Liste oder eine einzelne Person zur Gruppe hinzugef�gt werden.
+ */
+ function addusertogroup()
+ {
+ $userid = $this->getRequestVar('userid');
+
+ if ( is_array($userid))
+ {
+ // Im Request steht eine Liste von User-Ids.
+ foreach( $userid as $uid )
+ {
+ $this->group->addUser( $uid );
+ }
+ $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OR_NOTICE_OK,array('count'=>count($userid)));
+ }
+ elseif( intval($userid) > 0 )
+ {
+ // Nur 1 Benutzer hinzuf�gen.
+ $this->group->addUser( intval($userid) );
+ $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OK_NOTICE_OK,array('count'=>'1'));
+ }
+ else
+ {
+ // Es wurde kein Benutzer ausgew�hlt.
+ $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ }
+ }
+
+
+
+ /**
+ * Einen Benutzer aus der Gruppe entfernen.
+ */
+ function deluser()
+ {
+ $this->group->delUser( intval($this->getRequestVar('userid')) );
+
+ $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK);
+ }
+
+
+
+ /**
+ * Liste aller Gruppen.
+ */
+ function listingView()
+ {
+ $list = array();
+
+ foreach( Group::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url('main','group',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit'));
+ $list[$id]['name'] = $name;
+ }
+
+ $this->setTemplateVar('el', $list);
+ }
+
+
+ function editView()
+ {
+ $this->setTemplateVars( $this->group->getProperties() );
+ }
+
+
+
+
+
+
+ /**
+ * Liste aller Benutzer in dieser Gruppe.
+ *
+ */
+ function membershipsView()
+ {
+ // Mitgliedschaften ermitteln
+ //
+ $userliste = array();
+
+ $allUsers = User::listAll();
+
+ $actualGroupUsers = $this->group->getUsers();
+
+ foreach( $allUsers as $id=>$name )
+ {
+ $hasUser = array_key_exists($id,$actualGroupUsers);
+ $varName = 'user'.$id;
+ $userliste[$id] = array('name' => $name,
+ 'id' => $id,
+ 'var' => $varName,
+ 'member' => $hasUser
+ );
+ $this->setTemplateVar($varName,$hasUser);
+ }
+ $this->setTemplateVar('memberships',$userliste);
+
+ global $conf;
+ if ($conf['security']['authorize']['type']=='ldap')
+ $this->addNotice('group',$this->group->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
+ }
+
+
+ function membershipsPost()
+ {
+ $allUsers = User::listAll();
+ $groupUsers = $this->group->getUsers();
+
+ foreach( $allUsers as $id=>$name )
+ {
+ $hasUser = array_key_exists($id,$groupUsers);
+
+ if ( !$hasUser && $this->hasRequestVar('user'.$id) )
+ {
+ $this->group->addUser($id);
+ $this->addNotice('user',$name,'ADDED');
+ }
+
+ if ( $hasUser && !$this->hasRequestVar('user'.$id) )
+ {
+ $this->group->delUser($id);
+ $this->addNotice('user',$name,'DELETED');
+ }
+ }
+ }
+
+
+
+
+
+ /**
+ * Anzeigen der Benutzerrechte
+ */
+ function rightsView()
+ {
+ $rights = $this->group->getAllAcls();
+
+ $projects = array();
+
+ foreach( $rights as $acl )
+ {
+ if ( !isset($projects[$acl->projectid]))
+ {
+ $projects[$acl->projectid] = array();
+ $p = new Project($acl->projectid);
+ $p->load();
+ $projects[$acl->projectid]['projectname'] = $p->name;
+ $projects[$acl->projectid]['rights' ] = array();
+ }
+
+ $right = array();
+
+ if ( $acl->languageid > 0 )
+ {
+ $language = new Language($acl->languageid);
+ $language->load();
+ $right['languagename'] = $language->name;
+ }
+ else
+ {
+ $right['languagename'] = lang('ALL_LANGUAGES');
+ }
+
+
+ $o = new Object($acl->objectid);
+ $o->objectLoad();
+ $right['objectname'] = $o->name;
+ $right['objectid' ] = $o->objectid;
+ $right['objecttype'] = $o->getType();
+
+ if ( $acl->groupid > 0 )
+ {
+ $group = new Group($acl->groupid);
+ $group->load();
+ $right['groupname'] = $group->name;
+ }
+ else
+ {
+ // Berechtigung f�r "alle".
+ }
+
+ $right['bits'] = $acl->getProperties();
+
+ $projects[$acl->projectid]['rights'][] = $right;
+ }
+
+ $this->setTemplateVar('projects' ,$projects );
+
+ $this->setTemplateVar('show',Acl::getAvailableRights() );
+ }
+
+
+
+ /**
+ * Men�.
+ *
+ * @param String $menu Men�eintrag.
+ * @return boolean TRUE, wenn Men�eintrag aktiv ist.
+ */
+ function checkMenu( $menu )
+ {
+ switch( $menu )
+ {
+ case 'remove':
+ case 'add':
+ return !readonly();
+
+ case 'users':
+ return true;
+ case 'adduser':
+ // Benutzer k�nnen nur hinzugef�gt werden, wenn noch nicht alle
+ // in der Gruppe sind.
+ return !readonly() && count($this->group->getOtherUsers()) > 0;
+ default:
+ return true;
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/GrouplistAction.class.php b/modules/cms-core/action/GrouplistAction.class.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Group;
+// 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 zum Bearbeiten einer Benutzergruppe.
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class GrouplistAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ function __construct()
+ {
+ }
+
+
+ /**
+ * Liste aller Gruppen.
+ */
+ function showView()
+ {
+ $list = array();
+
+ foreach( Group::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['id' ] = $id;
+ $list[$id]['name'] = $name;
+ }
+
+ $this->setTemplateVar('el', $list);
+ }
+
+
+ function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+
+ function addView()
+ {
+ }
+
+
+ function addPost()
+ {
+ if ( $this->getRequestVar('name') != '')
+ {
+ $this->group = new Group();
+ $this->group->name = $this->getRequestVar('name');
+ $this->group->add();
+ $this->addNotice('group',$this->group->name,'ADDED','ok');
+ $this->callSubAction('listing');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ }
+ }
+
+
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/IndexAction.class.php b/modules/cms-core/action/IndexAction.class.php
@@ -0,0 +1,393 @@
+<?php
+
+namespace cms\action;
+
+use \Auth;
+use cms\model\User;
+use Exception;
+use JSqueeze;
+use Less_Parser;
+use Logger;
+use ObjectNotFoundException;
+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; version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/**
+ * Action-Klasse fuer die Anzeige der Hauptseite.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class IndexAction extends Action
+{
+ public $security = SECURITY_GUEST;
+
+
+ private $perspective;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->perspective = Session::get('perspective');
+
+ if ( !empty($this->perspective))
+ $this->lastModified( config('config','last_modification_time') );
+ }
+
+
+ public function showView()
+ {
+ global $conf;
+
+ // Schauen, ob eine Perspektive existiert.
+ if ( empty($this->perspective) )
+ {
+ // Da keine Perspektive existiert, handelt es sich wohl um den
+ // ersten Aufruf in dieser Sitzung.
+
+ // Versuchen, einen Benutzernamen zu ermitteln, der im Eingabeformular vorausgewählt wird.
+ $modules = explode(',',$conf['security']['modules']['autologin']);
+
+ $username = '';
+ foreach( $modules as $module)
+ {
+ Logger::debug('Auto-Login module: '.$module);
+ $moduleClass = $module.'Auth';
+ $auth = new $moduleClass;
+ $username = $auth->username();
+
+ if ( !empty($username) )
+ {
+ Logger::debug('Auto-Login for User '.$username);
+ break; // Benutzername gefunden.
+ }
+ }
+
+ if ( !empty( $username ) )
+ {
+ try
+ {
+ $user = User::loadWithName( $username );
+ Session::setUser($user);
+ Logger::info('auto-login for user '.$username);
+ $this->setPerspective('start');
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ Logger::warn('Username for autologin does not exist: '.$username);
+ $this->setPerspective('login');
+ }
+ }
+ else
+ {
+ // Kein Auto-Login moeglich, die Anmeldemaske anzeigen.
+ $this->setPerspective('login');
+ }
+ }
+
+ // Theme für den angemeldeten Benuter ermitteln, dieser wird für
+ // den Link auf die CSS-Datei benoetigt.
+ $user = Session::getUser();
+ if ( is_object($user) )
+ $style = $user->style;
+ else
+ $style = config('interface','style','default');
+
+ $jsFiles = $this->getJSFiles();
+ $cssFiles = $this->getCSSFiles();
+ $themeCss = $this->getThemeCSS();
+
+ // HTML-Datei direkt einbinden.
+ require('themes/default/layout/index.php');
+ exit;
+ }
+
+
+ private function getCSSFiles()
+ {
+ $productionCSSFile = OR_THEMES_DIR . 'default/production/combined.min.css';
+
+ if (PRODUCTION)
+ {
+ return array(
+ $productionCSSFile
+ );
+ }
+
+ $outFiles = array();
+
+ $css = array();
+ $css[] = OR_THEMES_EXT_DIR . 'default/css/openrat-ui';
+ $css[] = OR_THEMES_EXT_DIR . 'default/css/openrat-workbench';
+
+ // Komponentenbasiertes CSS
+ $elements = parse_ini_file(OR_THEMES_DIR . config('interface', 'theme') . '/include/elements.ini.' . PHP_EXT);
+
+ foreach (array_keys($elements) as $c)
+ {
+ $componentCssFile = OR_MODULES_DIR . 'template-engine/components/html/' . $c . '/' . $c;
+ if (is_file($componentCssFile . '.less'))
+ $css[] = $componentCssFile;
+ }
+
+ $modified = false;
+ foreach ($css as $cssF)
+ {
+ $lessFile = $cssF . '.less';
+ $cssFile = $cssF . '.css';
+ $cssMinFile = $cssF . '.min.css';
+
+ if (! is_file($lessFile))
+ {
+ Logger::warn("Stylesheet not found: $lessFile");
+ continue;
+ }
+ elseif (! is_file($cssFile) || ! is_writable($cssFile))
+ {
+ Logger::warn("Stylesheet output file not found or not writable: $cssFile");
+ continue;
+ }
+ elseif (! is_file($cssMinFile) || ! is_writable($cssMinFile))
+ {
+ Logger::warn("Stylesheet output file not found or not writable: $cssMinFile");
+ continue;
+ }
+ else
+ {
+ if (filemtime($lessFile) > filemtime($cssMinFile))
+ {
+ // LESS-Source wurde geändert, CSS-Version muss aktualisiert werden.
+ $modified = true;
+
+ // Den absoluten Pfad zur LESS-Datei ermitteln. Dieser wird vom LESS-Parser für den korrekten Link
+ // auf die LESS-Datei in der Sourcemap benötigt.
+ $pfx = substr(realpath($lessFile),0,0-strlen(basename($lessFile)));
+
+ $parser = new Less_Parser(array(
+ 'sourceMap' => true,
+ 'indentation' => ' ',
+ 'outputSourceFiles' => false,
+ 'sourceMapBasepath' => $pfx
+ ));
+
+
+ $parser->parseFile( ltrim($lessFile,'./') );
+ $source = $parser->getCss();
+
+ file_put_contents($cssFile, $source);
+
+ $parser = new Less_Parser(array(
+ 'compress' => true,
+ 'sourceMap' => false,
+ 'indentation' => ''
+ ));
+ $parser->parseFile($lessFile);
+ $source = $parser->getCss();
+
+
+ file_put_contents($cssMinFile, $source);
+ }
+
+ $outFiles[] = $cssFile;
+ }
+ }
+
+ if ($modified)
+ {
+ if ( !is_writable($productionCSSFile))
+ {
+ Logger::warn('not writable: '.$productionCSSFile);
+ }
+ else
+ {
+ file_put_contents($productionCSSFile,'');
+ foreach ($css as $cssF)
+ {
+ $cssMinFile = $cssF . '.min.css';
+ if ( is_file($cssMinFile))
+ file_put_contents($productionCSSFile,file_get_contents($cssMinFile),FILE_APPEND);
+ }
+ }
+ }
+
+ return $outFiles;
+ }
+
+
+
+ private function getThemeCSS()
+ {
+ // Je Theme die Theme-CSS-Datei ausgeben.
+ $lessFile = OR_THEMES_EXT_DIR . 'default/css/openrat-theme.less';
+ $css = '';
+
+
+ foreach (array_keys(config('style')) as $styleId)
+ {
+ try
+ {
+ $parser = new Less_Parser(array(
+ 'sourceMap' => DEVELOPMENT,
+ 'indentation' => ' ',
+ 'outputSourceFiles' => false
+ ));
+ $parser->parseFile($lessFile,basename($lessFile));
+
+ $styleConfig = config('style-default') + config('style', $styleId);
+ $lessVars = array(
+ 'cms-theme-id' => strtolower($styleId),
+ 'cms-image-path' => 'themes/default/images/'
+ );
+
+ foreach ($styleConfig as $styleSetting => $value)
+ $lessVars['cms-' . strtolower(strtr($styleSetting, '_', '-'))] = $value;
+ $parser->modifyVars($lessVars);
+ $css .= $parser->getCss();
+ }
+ catch (Exception $e)
+ {
+ $css .= "\n\n/* WARNING!\n LESS Parser failed on file '$lessFile'. Reason: " . $e->__toString() . " */\n\n";
+ }
+ }
+
+ if (PRODUCTION)
+ {
+ return $css; // Should we minify here? Bandwidth vs. cpu-load.
+ }
+ else
+ {
+ return $css;
+ }
+ }
+
+
+
+ private function getJSFiles()
+ {
+ $productionJSFile = OR_THEMES_DIR . 'default/production/combined.min.js';
+
+ if (PRODUCTION)
+ {
+ return array(
+ $productionJSFile
+ );
+ }
+ else
+ {
+ $js = array();
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-1.12.4';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-ui/js/jquery-ui-1.8.16.custom';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery.scrollTo';
+ // $js[] = OR_THEMES_EXT_DIR default/js/jquery.mjs.nestedSortable.js"></script>
+
+ // Jquery-Plugins
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orHint';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orSearch';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orLinkify';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orTree';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orLoadView';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-orAutoheight';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/plugin/jquery-plugin-svg';
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/jquery-qrcode';
+ // OpenRat internal JS
+ $js[] = OR_THEMES_EXT_DIR . 'default/js/openrat';
+ $js[] = OR_THEMES_EXT_DIR . '../editor/markitup/markitup/jquery.markitup';
+ $js[] = OR_THEMES_EXT_DIR . '../editor/editor/ckeditor';
+ $js[] = OR_THEMES_EXT_DIR . '../editor/ace/src-min-noconflict/ace';
+ $js[] = OR_THEMES_EXT_DIR . '../editor/editor/adapters/jquery';
+
+ // Komponentenbasiertes Javascript
+ $elements = parse_ini_file(OR_THEMES_DIR . config('interface', 'theme') . '/include/elements.ini.' . PHP_EXT);
+
+ foreach (array_keys($elements) as $c)
+ {
+ $componentJsFile = OR_MODULES_DIR . '/template-engine/components/html/' . $c . '/' . $c;
+ if (is_file($componentJsFile . '.js'))
+ $js[] = $componentJsFile;
+ }
+
+ $outDevJsFiles = array();
+ $outProJsFiles = array();
+ $lastModTime = 0;
+
+ foreach ($js as $jsFile)
+ {
+ $jsFileMin = $jsFile . '.min.js';
+ $jsFileNormal = $jsFile . '.js';
+
+ if (!is_file($jsFileNormal) && !is_file($jsFileMin))
+ {
+ Logger::warn("No Javascript file found for $jsFile");
+ continue;
+ }
+ elseif (is_file($jsFileNormal) && !is_file($jsFileMin))
+ {
+ Logger::warn("No Min-Javascript file found for $jsFile");
+ continue;
+ }
+ elseif (!is_file($jsFileNormal) && is_file($jsFileMin))
+ {
+ // Nur eine Min-Version existiert. Das ist ok.
+ $outDevJsFiles[] = $jsFileMin;
+ $outProJsFiles[] = $jsFileMin;
+ $modTime = filemtime($jsFileMin);
+ }
+ else
+ {
+ if ( filemtime($jsFileNormal) > filemtime($jsFileMin) )
+ {
+ if ( is_writable( $jsFileMin))
+ $jz = new JSqueeze();
+ file_put_contents( $jsFileMin, $jz->squeeze(file_get_contents($jsFileNormal)));
+ $modTime = time();
+ }
+ else
+ {
+ $modTime = filemtime($jsFileMin);
+ }
+ $outDevJsFiles[] = $jsFileNormal;
+ $outProJsFiles[] = $jsFileMin;
+ }
+ $lastModTime = max($lastModTime, $modTime);
+ }
+
+ if ($lastModTime > filemtime($productionJSFile))
+ {
+ if (! is_writable($productionJSFile))
+ {
+ Logger::warn("Not writable: " . $productionJSFile);
+ }
+ else
+ {
+ file_put_contents($productionJSFile, '');
+ foreach ($outProJsFiles as $srcFile)
+ file_put_contents($productionJSFile, file_get_contents($srcFile), FILE_APPEND);
+ }
+ }
+ }
+
+ return $outDevJsFiles;
+ }
+
+
+
+}
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/LanguageAction.class.php b/modules/cms-core/action/LanguageAction.class.php
@@ -0,0 +1,275 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Language;
+use Session;
+use \Html;
+// 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 die Bearbeitung einer Sprache
+ * @version $Id$
+ * @author $Author$
+ * @package openrat.actions
+ */
+class LanguageAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $defaultSubAction = 'listing';
+
+ /**
+ * Zu bearbeitende Sprache, wird im Kontruktor instanziiert
+ * @type Language
+ */
+ var $language;
+ var $project;
+
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->language = new Language( $this->getRequestId() );
+ $this->language->load();
+
+ $this->project = Session::getProject();
+ }
+
+
+ /**
+ * Setzen der Sprache als Standardsprache.
+ * Diese Sprache wird benutzt beim Ausw?hlen des Projektes sowie
+ * als Default-Sprache bei mehrsprachigen Webseiten ("content-negotiation")
+ */
+ function setdefaultPost()
+ {
+ $this->language->setDefault();
+ }
+
+
+
+ /**
+ * Anzeigen der L�schbest�tigungs-Maske.
+ */
+ function removeView()
+ {
+ $this->setTemplateVar('name' ,$this->language->name );
+ }
+
+
+ /**
+ * L�schen der Sprache.
+ */
+ function removePost()
+ {
+ if ( $this->getRequestVar('confirm') == '1' )
+ $this->language->delete();
+ }
+
+
+ function propView()
+ {
+ $this->nextSubAction('advanced');
+ }
+
+ /**
+ * Speichern der Sprache
+ */
+ function advancedPost()
+ {
+ global $conf;
+
+ if ( $this->hasRequestVar('name') )
+ {
+ $this->language->name = $this->getRequestVar('name' );
+ $this->language->isoCode = $this->getRequestVar('isocode');
+ }
+ else
+ {
+ $countryList = $conf['countries'];
+ $iso = $this->getRequestVar('isocode');
+ $this->language->name = $countryList[$iso];
+ $this->language->isoCode = strtolower( $iso );
+ }
+
+ $this->language->save();
+ }
+
+
+
+ /**
+ * Speichern der Sprache
+ */
+ function editPost()
+ {
+ global $conf;
+
+ if ( $this->hasRequestVar('name') )
+ {
+ $this->language->name = $this->getRequestVar('name' );
+ $this->language->isoCode = $this->getRequestVar('isocode');
+ }
+ else
+ {
+ $countryList = $conf['countries'];
+ $iso = $this->getRequestVar('isocode');
+ $this->language->name = $countryList[$iso];
+ $this->language->isoCode = strtolower( $iso );
+ }
+
+ $this->language->save();
+ }
+
+
+
+ function listingView()
+ {
+ global $conf;
+ $countryList = $conf['countries'];
+
+ $list = array();
+
+ $actLanguage = Session::getProjectLanguage();
+ $this->setTemplateVar('act_languageid',$actLanguage->languageid);
+
+ foreach( $this->project->getLanguageIds() as $id )
+ {
+ $l = new Language( $id );
+ $l->load();
+
+ unset( $countryList[strtoupper($l->isoCode)] );
+
+ $list[$id] = array();
+ $list[$id]['name' ] = $l->name;
+ $list[$id]['isocode'] = $l->isoCode;
+
+ if ( $this->userIsAdmin() )
+ {
+ $list[$id]['url' ] = Html::url('language','edit',$id,
+ array() );
+
+ if ( ! $l->isDefault )
+ $list[$id]['default_url'] = Html::url( 'language','setdefault',$id );
+ }
+
+ if ( $actLanguage->languageid != $l->languageid )
+ $list[$id]['select_url'] = Html::url( 'index','language',$id );
+ }
+
+// if ( $this->userIsAdmin() )
+// {
+// asort($countryList);
+// $this->setTemplateVar('isocodes',$countryList);
+// }
+
+ $this->setTemplateVar('el',$list);
+ }
+
+
+
+ function editView()
+ {
+ global $conf;
+ $countryList = $conf['countries'];
+
+ foreach( $this->project->getLanguageIds() as $id )
+ {
+ if ( $id == $this->language->languageid )
+ continue;
+
+ $l = new Language( $id );
+ $l->load();
+
+ unset( $countryList[$l->isoCode] );
+ }
+
+ asort( $countryList );
+ $this->setTemplateVar('isocodes' ,$countryList );
+ $this->setTemplateVar('isocode' ,strtoupper($this->language->isoCode) );
+ }
+
+
+
+ function advancedView()
+ {
+ $this->setTemplateVar('isocode',$this->language->isoCode);
+ $this->setTemplateVar('name' ,$this->language->name );
+ }
+
+
+
+
+
+ function checkmenu( $menu )
+ {
+ switch( $menu )
+ {
+ case 'remove':
+ $actLanguage = Session::getProjectLanguage();
+ return
+ !readonly() &&
+ $this->userIsAdmin() &&
+ isset($this->language) &&
+ count( $this->language->getAll() ) >= 2 &&
+ $actLanguage->languageid != $this->language->languageid;
+
+ case 'add':
+ return
+ !readonly() && $this->userIsAdmin();
+
+ default:
+ return true;
+ }
+ }
+
+
+ /**
+ * 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();
+ $languagelistChildren = array();
+
+ $structure[0] = array('id'=>'0','name'=>lang('LANGUAGES'),'type'=>'languagelist','level'=>1,'children'=>&$languagelistChildren);
+
+ $languagelistChildren[ $this->language->languageid ] = array('id'=>$this->language->languageid,'name'=>$this->language->name,'type'=>'language','self'=>true);
+
+
+ //Html::debug($structure);
+
+ $this->setTemplateVar('outline',$structure);
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/LanguagelistAction.class.php b/modules/cms-core/action/LanguagelistAction.class.php
@@ -0,0 +1,148 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Language;
+
+
+
+use Session;
+use \Html;
+
+// 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 die Bearbeitung einer Sprache
+ * @version $Id$
+ * @author $Author$
+ * @package openrat.actions
+ */
+class LanguagelistAction extends Action
+{
+ public $security = SECURITY_USER;
+
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->project = Session::getProject();
+ }
+
+
+
+ function showView()
+ {
+ global $conf;
+ $countryList = $conf['countries'];
+
+ $list = array();
+
+ $actLanguage = Session::getProjectLanguage();
+ $this->setTemplateVar('act_languageid',$actLanguage->languageid);
+
+ foreach( $this->project->getLanguageIds() as $id )
+ {
+ $l = new Language( $id );
+ $l->load();
+
+ unset( $countryList[strtoupper($l->isoCode)] );
+
+ $list[$id] = array();
+ $list[$id]['name' ] = $l->name;
+ $list[$id]['isocode'] = $l->isoCode;
+
+ if ( $this->userIsAdmin() )
+ {
+ $list[$id]['id' ] = $id;
+
+ if ( ! $l->isDefault )
+ $list[$id]['default_url'] = Html::url( 'language','setdefault',$id );
+ }
+
+ if ( $actLanguage->languageid != $l->languageid )
+ $list[$id]['select_url'] = Html::url( 'index','language',$id );
+ }
+
+// if ( $this->userIsAdmin() )
+// {
+// asort($countryList);
+// $this->setTemplateVar('isocodes',$countryList);
+// }
+
+ $this->setTemplateVar('el',$list);
+ }
+
+
+
+ function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+
+
+ /**
+ * Sprache hinzufuegen
+ */
+ function addView()
+ {
+ global $conf;
+ $countryList = $conf['countries'];
+
+ $language = Session::getProjectLanguage();
+
+ foreach( $this->project->getLanguageIds() as $id )
+ {
+
+ if ( $id == $language->languageid )
+ continue;
+
+ $l = new Language( $id );
+ $l->load();
+
+ unset( $countryList[$l->isoCode] );
+ }
+
+ asort( $countryList );
+ $this->setTemplateVar('isocodes' ,$countryList );
+ $this->setTemplateVar('isocode' ,'' );
+ }
+
+
+ function addPost()
+ {
+ global $conf;
+ $countryList = $conf['countries'];
+
+ // Hinzufuegen einer Sprache
+ $iso = $this->getRequestVar('isocode');
+ $language = new Language();
+ $language->projectid = $this->project->projectid;
+ $language->isoCode = $iso;
+ $language->name = $countryList[$iso];
+ $language->add();
+
+ $this->addNotice('language',$language->name,'ADDED','ok');
+ }
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/LinkAction.class.php b/modules/cms-core/action/LinkAction.class.php
@@ -0,0 +1,191 @@
+<?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 LinkAction extends ObjectAction
+{
+ public $security = SECURITY_USER;
+
+ private $link;
+
+ /**
+ * 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()
+ {
+ $this->link->linkedObjectId = $this->getRequestVar('targetobjectid');
+
+ $this->link->save();
+ $this->link->setTimestamp();
+ Session::setObject( $this->link );
+
+ $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+ 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 );
+ }
+
+
+
+ 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/modules/cms-core/action/LoginAction.class.php b/modules/cms-core/action/LoginAction.class.php
@@ -0,0 +1,2187 @@
+<?php
+
+namespace cms\action;
+
+
+use cms\model\User;
+use cms\model\Project;
+use cms\model\Group;
+use cms\model\Value;
+use cms\model\Element;
+use cms\model\Page;
+use cms\model\Object;
+use cms\model\Language;
+use cms\model\Model;
+
+
+use \database\Database;
+use \DB;
+use \DbUpdate;
+use \Exception;
+use \Http;
+use \InternalAuth;
+use \Logger;
+use \ObjectNotFoundException;
+use \OpenRatException;
+use \security\Password;
+use \Session;
+use \Html;
+use \Mail;
+use \Text;
+
+
+// OpenRat Content Management System
+// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+define('PROJECTID_ADMIN',-1);
+
+/**
+ * Action-Klasse fuer die Start-Action
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class LoginAction extends Action
+{
+ public $security = SECURITY_GUEST;
+
+
+ /**
+ * Eine Datenbankverbindugn wird aufgebaut und initalisiert.
+ *
+ * @param $dbid Datenbank-Id
+ * @throws OpenRatException
+ */
+ private function setDb( $dbid )
+ {
+ global $conf;
+
+ if ( !isset($conf['database'][$dbid] ))
+ Http::serverError( 'unknown DB-Id: '.$dbid );
+
+ $db = db_connection();
+ if ( is_object($db) )
+ $db->rollback();
+
+ try
+ {
+ $db = new Database( $conf['database'][$dbid] );
+ $db->id = $dbid;
+ $db->start(); // Transaktion starten.
+ Session::setDatabase( $db );
+ }catch(\Exception $e)
+ {
+ throw new OpenRatException('DATABASE_ERROR_CONNECTION',$e->getMessage() );
+ }
+ }
+
+
+ /**
+ * Prueft, ob der Parameter 'dbid' übergeben wurde.
+ * @throws OpenRatException
+ */
+ function checkForDb()
+ {
+ global $conf;
+ $dbid = $this->getRequestVar('dbid');
+
+ if ( $dbid != '' )
+ $this->setDb( $dbid );
+ }
+
+
+ /**
+ * @throws OpenRatException
+ */
+ function setDefaultDb()
+ {
+ if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) )
+ {
+ $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID);
+ }
+ else
+ {
+ global $conf;
+
+ if ( !isset($conf['database']['default']) )
+ Http::serverError('default-database not set');
+
+ $dbid = $conf['database']['default'];
+ }
+
+ $this->setDb( $dbid );
+ }
+
+
+ /**
+ * Führt ein Login durch.
+ * @param $name string Benutzername
+ * @param $pw string Password
+ * @param $pw1 string new Password
+ * @param $pw2 string new Password repeated
+ * @return bool
+ * @throws ObjectNotFoundException
+ */
+ private function checkLogin($name, $pw, $pw1, $pw2 )
+ {
+ Logger::debug( "Login user: '$name'.'" );
+
+ global $conf;
+ global $SESS;
+
+ unset( $SESS['user'] );
+
+
+ $db = db_connection();
+
+ if ( !is_object($db) )
+ {
+ $this->addNotice('database','','DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('no connection'));
+ //$this->callSubAction('showlogin');
+ return false;
+ }
+
+ if ( !$db->available )
+ {
+ $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error));
+ //$this->callSubAction('showlogin');
+ return false;
+ }
+
+ $ip = getenv("REMOTE_ADDR");
+
+ $user = new User();
+ $user->name = $name;
+
+ $ok = $user->checkPassword( $pw );
+
+ $mustChangePassword = $user->mustChangePassword;
+
+ if ( $mustChangePassword )
+ {
+ // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
+ // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
+ if ( empty($pw1) )
+ {
+ }
+ elseif ( $pw1 != $pw2 )
+ {
+ $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
+ $this->addValidationError('password2','');
+ }
+ elseif ( strlen($pw2) < $conf['security']['password']['min_length'] )
+ {
+ $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
+ $this->addValidationError('password2','');
+ }
+ else
+ {
+ // Kennw?rter identisch und lang genug.
+ $user->setPassword( $pw1,true );
+
+ // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen.
+ $ok = true;
+ $mustChangePassword = false;
+
+ $pw = $pw1;
+ }
+ }
+
+ // Falls Login erfolgreich
+ if ( $ok )
+ {
+ // Login war erfolgreich!
+ $user->load();
+ $user->setCurrent();
+
+ if ($user->passwordAlgo != Password::bestAlgoAvailable() )
+ // Re-Hash the password with a better hash algo.
+ $user->setPassword($pw);
+
+
+ Logger::info( "login successful for {$user->name} from IP $ip" );
+
+ return true;
+ }
+ else
+ {
+ Logger::info( "login failed for user {$user->name} from IP $ip" );
+
+ return false;
+ }
+ }
+
+
+ /**
+ * Anzeigen der Loginmaske.
+ *
+ * Es wird nur die Loginmaske angezeigt.
+ * @throws OpenRatException
+ */
+ function loginView()
+ {
+ // Hier nie "304 not modified" setzen, da sonst keine
+ // Login-Fehlermeldung erscheinen kann.
+ global $conf;
+
+ $sso = $conf['security']['sso'];
+ $ssl = $conf['security']['ssl'];
+
+ $ssl_trust = false;
+ $ssl_user_var = '';
+ extract( $ssl, EXTR_PREFIX_ALL, 'ssl' );
+
+ if ( $sso['enable'] )
+ {
+ $authid = $this->getRequestVar( $sso['auth_param_name']);
+
+ if ( empty( $authid) )
+ Http::notAuthorized( 'no authorization data (no auth-id)');
+
+ if ( $sso['auth_param_serialized'] )
+ $authid = unserialize( $authid );
+
+ $purl = parse_url($sso['url']);
+ // Verbindung zu URL herstellen.
+ $errno=0; $errstr='';
+ $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30);
+ if ( !$fp )
+ {
+ echo "Connection failed: $errstr ($errno)";
+ }
+ else
+ {
+ $http_get = $purl['path'];
+ if ( !empty($purl['query']) )
+ $http_get .= '?'.$purl['query'];
+
+ $header = array();
+
+ $header[] = "GET $http_get HTTP/1.0";
+ $header[] ="Host: ".$purl['host'];
+ $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)";
+ $header[] = "Connection: Close";
+
+ if ( $sso['cookie'] )
+ {
+ $cookie = 'Cookie: ';
+ if ( is_array($authid))
+ foreach( $authid as $cookiename=>$cookievalue)
+ $cookie .= $cookiename.'='.$cookievalue."; ";
+ else
+ $cookie .= $sso['cookie_name'].'='.$authid;
+
+ $header[] = $cookie;
+ }
+
+// Html::debug($header);
+ fputs ($fp, implode("\r\n",$header)."\r\n\r\n");
+
+ $inhalt=array();
+ while (!feof($fp)) {
+ $inhalt[] = fgets($fp,128);
+ }
+ fclose($fp);
+
+ $html = implode('',$inhalt);
+// Html::debug($html);
+ if ( !preg_match($sso['expect_regexp'],$html) )
+ Http::notAuthorized('auth failed');
+ $treffer=0;
+ if ( !preg_match($sso['username_regexp'],$html,$treffer) )
+ Http::notAuthorized('auth failed');
+ if ( !isset($treffer[1]) )
+ Http::notAuthorized('authorization failed');
+
+ $username = $treffer[1];
+
+// Html::debug( $treffer );
+ $this->setDefaultDb();
+
+ $user = User::loadWithName( $username );
+
+ if ( ! $user->isValid( ))
+ Http::notAuthorized('authorization failed: user not found: '.$username);
+
+ $user->setCurrent();
+
+ $this->callSubAction('show');
+ }
+ }
+
+ elseif ( $ssl_trust )
+ {
+ if ( empty($ssl_user_var) )
+ Http::serverError( 'please set environment variable name in ssl-configuration.' );
+
+ $username = getenv( $ssl_user_var );
+
+ if ( empty($username) )
+ Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' );
+
+ $this->setDefaultDb();
+
+ $user = User::loadWithName( $username );
+
+ if ( !$user->isValid() )
+ Http::serverError( 'unknown username: '.$username );
+
+ $user->setCurrent();
+
+ $this->callSubAction('show');
+ }
+
+ foreach( $conf['database'] as $dbid => $dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbid] = array('key' => $dbid,
+ 'value' => empty($dbconf['name'])?$dbid:Text::maxLength($dbconf['name']),
+ 'title' => @$dbconf['description'] );
+ }
+
+
+ if ( empty($dbids) )
+ $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
+
+ if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) )
+ $this->setTemplateVar('login_name',$_COOKIE['or_username']);
+
+ if ( !isset($this->templateVars['login_name']) )
+ $this->setTemplateVar('login_name',@$conf['security']['default']['username']);
+
+ if ( @$this->templateVars['login_name']== @$conf['security']['default']['username'])
+ $this->setTemplateVar('login_password',@$conf['security']['default']['password']);
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ $db = Session::getDatabase();
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ elseif( isset($this->templateVars['actid']) )
+ ;
+ elseif ( isset($_COOKIE['or_dbid']) && isset($dbids[$_COOKIE['or_dbid']]) )
+ // DB-Id aus dem Cookie lesen.
+ $this->setTemplateVar('actdbid',$_COOKIE['or_dbid'] );
+ else
+ $this->setTemplateVar('actdbid',$conf['login']['default-database']);
+
+
+ // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen.
+ $ssl_user_var = $conf['security']['ssl']['client_cert_dn_env'];
+ if ( !empty($ssl_user_var) )
+ {
+ $username = getenv( $ssl_user_var );
+
+ if ( empty($username) )
+ {
+ // Nothing to do.
+ // if user has no valid client cert he could not access this form.
+ }
+ else {
+
+ // Benutzername ist in Eingabemaske unver�nderlich
+ $this->setTemplateVar('force_username',$username);
+ }
+
+ }
+
+ $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
+
+ $this->setTemplateVar('register' ,$conf['login' ]['register' ]);
+ $this->setTemplateVar('send_password',$conf['login' ]['send_password']);
+
+ // Versuchen, einen Benutzernamen zu ermitteln, der im Eingabeformular vorausgewählt wird.
+ $modules = explode(',',$conf['security']['modules']['preselect']);
+
+ $username = '';
+ foreach( $modules as $module)
+ {
+ Logger::debug('Preselecting module: '.$module);
+ $moduleClass = $module.'Auth';
+ /** @var \Auth $auth */
+ $auth = new $moduleClass;
+ $username = $auth->username();
+
+ if ( !empty($username) )
+ {
+ Logger::debug('Preselecting User '.$username);
+ break; // Benutzername gefunden.
+ }
+ }
+
+ $this->setTemplateVar('login_name',$username);
+ }
+
+
+
+ /**
+ * Anzeigen der Loginmaske.
+ *
+ * Es wird nur die Loginmaske angezeigt.
+ * Hier nie "304 not modified" setzen, da sonst keine
+ * Login-Fehlermeldung erscheinen kann
+ */
+ function openidView()
+ {
+ global $conf;
+
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbname] = array('key' =>$dbname,
+ 'value'=>Text::maxLength($dbconf['description']),
+ 'title'=>$dbconf['description'].(isset($dbconf['host'])?' ('.$dbconf['host'].')':'') );
+ }
+
+ $openid_provider = array();
+ foreach( explode(',',$conf['security']['openid']['provider']['name']) as $provider )
+ $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name');
+ $this->setTemplateVar('openid_providers',$openid_provider);
+ $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity'));
+ //$this->setTemplateVar('openid_provider','identity');
+
+
+ if ( empty($dbids) )
+ $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
+
+ if ( !isset($_COOKIE['or_username']) )
+ $this->setTemplateVar('login_name',$_COOKIE['or_username']);
+ else
+ $this->setTemplateVar('login_name',$conf['security']['default']['username']);
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ $db = Session::getDatabase();
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ else
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+
+ $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
+
+ }
+
+
+
+ /**
+ * Erzeugt ein Projekt-Auswahlmenue.
+ */
+ function projectmenu()
+ {
+ $user = Session::getUser();
+
+ if ( $user->mustChangePassword )
+ {
+ $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
+ $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu ?ndern.
+ }
+
+
+ // Diese Seite gilt pro Sitzung.
+ $this->lastModified( $user->loginDate );
+
+ // Projekte ermitteln
+ $projects = $user->projects;
+
+ $list = array();
+
+ foreach( $projects as $id=>$name )
+ {
+ $p = array();
+ $p['url' ] = Html::url('index','project',$id);
+ $p['name'] = $name;
+ $p['id' ] = $id;
+
+ $tmpProject = new Project( $id );
+ $p['defaultmodelid' ] = $tmpProject->getDefaultModelId();
+ $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId();
+ $p['models' ] = $tmpProject->getModels();
+ $p['languages' ] = $tmpProject->getLanguages();
+
+ $list[] = $p;
+ }
+
+ $this->setTemplateVar('projects',$list);
+
+ if ( empty($list) )
+ {
+ // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben.
+ if ( $this->userIsAdmin() )
+ // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen
+ $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
+ else
+ // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf?gung steht
+ $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
+ }
+
+ $this->metaValues();
+ }
+
+
+
+ /**
+ * Erzeugt eine Anwendungsliste.
+ */
+ function applications()
+ {
+ global $conf;
+
+ // Diese Seite gilt pro Sitzung.
+ $user = Session::getUser();
+ $userGroups = $user->getGroups();
+ $this->lastModified( $user->loginDate );
+
+ // Applikationen ermitteln
+ $list = array();
+ foreach( $conf['applications'] as $id=>$app )
+ {
+ if ( !is_array($app) )
+ continue;
+
+ if ( isset($app['group']) )
+ if ( !in_array($app['group'],$userGroups) )
+ continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden.
+
+ $p = array();
+ $p['url'] = $app['url'];
+ $p['description'] = @$app['description'];
+ if ( isset($app['param']) )
+ {
+ $p['url'] .= strpos($p['url'],'?')!==false?'&':'?';
+ $p['url'] .= $app['param'].'='.session_id();
+ }
+ $p['name'] = $app['name'];
+
+ $list[] = $p;
+ }
+
+
+ $this->metaValues();
+ $this->setTemplateVar('applications',$list);
+ }
+
+
+
+ /**
+ * Ermittelt Meta-Angaben f?r den HTML-Kopf.<br>
+ * Falls der Browser die Meta-Angaben entsprechend auswertet, k?nnen ?ber feste Browser-Men?s
+ die Projekt direkt ausgew?hlt werden.
+ */
+ function metaValues()
+ {
+ global $conf;
+ $metaList = array();
+
+ $user = Session::getUser();
+ if ( is_object($user) )
+ {
+ // Projekte ermitteln
+ $projects = $user->projects;
+ foreach( $projects as $id=>$name )
+ {
+ $metaList[] = array('name' => 'chapter',
+ 'url' => Html::url('index','project',$id),
+ 'title'=> $name );
+ }
+
+ if ( $this->userIsAdmin() )
+ {
+ $metaList[] = array('name' => 'appendix',
+ 'url' => Html::url('index','projectmenu',0 ),
+ 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) );
+
+ $metaList[] = array('name' => 'chapter',
+ 'url' => Html::url('index','administration',0),
+ 'title'=> lang('administration') );
+ }
+
+ // Applikationen ermitteln
+ foreach( $conf['applications'] as $id=>$app )
+ {
+ if ( !is_array($app) )
+ continue;
+ $appUrl = $app['url'];
+ if ( isset($app['param']) )
+ {
+ $appUrl .= strpos($appUrl,'?')!==false?'&':'?';
+ $appUrl .= $app['param'].'='.session_id();
+ }
+
+ $metaList[] = array('name' => 'bookmark',
+ 'url' => $appUrl ,
+ 'title'=> $app['name'] );
+ }
+ }
+
+ $project = Session::getProject();
+ if ( is_object($project) && $project->projectid > 0 )
+ {
+ $languages =$project->getLanguages();
+
+ foreach( $project->getModels() as $modelid=>$modelname )
+ {
+ foreach( $languages as $languageid=>$languagename )
+ {
+
+ $metaList[] = array('name' => 'subsection',
+ 'url' => Html::url('index',
+ 'project',
+ $project->projectid,
+ array('languageid'=>$languageid,
+ 'modelid' =>$modelid) ),
+ 'title'=> $modelname.' - '.$languagename
+ );
+ }
+ }
+ }
+
+ $metaList[] = array('name' => 'author',
+ 'url' => $conf['login']['logo']['url'],
+ 'title'=> $conf['login']['logo']['url'] );
+
+ $metaList[] = array('name' => 'top',
+ 'url' => Html::url('index','logout',0 ),
+ 'title'=> 'Start' );
+
+ $metaList[] = array('name' => 'contents',
+ 'url' => Html::url('index','projectmenu',0 ),
+ 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) );
+
+
+ $this->setTemplateVar('metaList',$metaList);
+ }
+
+
+
+ /**
+ * Open-Id Login, ?berpr?fen der Anmeldung.<br>
+ * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
+ * Kapitel "4.4. check_authentication"<br>
+ * <br>
+ * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur?ck.<br>
+ * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
+ * <br>
+ * Es muss noch beim OpenId-Provider die Best?tigung eingeholt werden, danach ist der
+ * Benutzer angemeldet.<br>
+ */
+ public function openidloginView()
+ {
+ global $conf;
+ $openId = Session::get('openid');
+
+ if ( !$openId->checkAuthentication() )
+ {
+ Http::notAuthorized('OpenId-Login failed' );
+ die();
+ $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ //Html::debug($openId);
+
+ // Anmeldung wurde mit "is_valid:true" best?tigt.
+ // Der Benutzer ist jetzt eingeloggt.
+ $username = $openId->getUserFromIdentiy();
+
+ Logger::debug("OpenId-Login successful for $username");
+
+ if ( empty($username) )
+ {
+ // Es konnte kein Benutzername ermittelt werden.
+ Http::notAuthorized('no username supplied by openid provider' );
+ die();
+ $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ $user = User::loadWithName( $username );
+
+ if ( $user->userid <=0)
+ {
+ // Benutzer ist (noch) nicht vorhanden.
+ if ( $conf['security']['openid']['add']) // Anlegen?
+ {
+ $user->name = $username;
+ $user->add();
+
+ $user->mail = @$openId->info['email'];
+ $user->fullname = @$openId->info['fullname'];
+ $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht)
+ }
+ else
+ {
+ Logger::debug("OpenId-Login failed for $username");
+ // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht).
+ Http::notAuthorized('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
+ die();
+
+ $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
+ $this->addValidationError('openid_url','');
+ return;
+ }
+ }
+ else
+ {
+ // Benutzer ist bereits vorhanden.
+ if ( @$conf['security']['openid']['update_user'])
+ {
+ $user->fullname = @$openId->info['fullname'];
+ $user->mail = @$openId->info['email'];
+ $user->save();
+ }
+ }
+
+ Logger::info("User login successful: ".$username);
+ $user->setCurrent(); // Benutzer ist jetzt in der Sitzung.
+
+ $this->setStyle( $user->style );
+ $this->setPerspective('start');
+
+ $server = Http::getServer();
+ Logger::debug("Redirecting to $server");
+ header('Location: '.slashify($server) );
+ exit();
+ }
+
+
+ /**
+ * Login.
+ */
+ function openidPost()
+ {
+ global $conf;
+
+ $this->checkForDb();
+ Session::setUser('');
+
+ if ( $conf['login']['nologin'] )
+ Http::notAuthorized('login disabled');
+
+ $openid_user = $this->getRequestVar('openid_url' );
+ $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
+ $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
+ $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
+ $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
+
+ // Cookie setzen
+ setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) );
+
+ // Login mit Open-Id.
+ if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) )
+ {
+ $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user);
+
+ if ( ! $openId->login() )
+ {
+ $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ Session::set('openid',$openId);
+ $this->redirect( $openId->getRedirectUrl() );
+ return;
+ }
+ }
+
+
+ /**
+ * Synchronisiert die bisherigen Gruppen des Benutzers mit den Gruppen, die sich aus der Authentifzierung ergeben haben.
+ *
+ * @param $user User Benutzerobjekt
+ * @param $groups array $groups Einfaches Array von Gruppennamen.
+ */
+ private function checkGroups($user, $groups)
+ {
+ if ( $groups == null )
+ return;
+
+ $oldGroups = $user->getGroups();
+
+ foreach( $oldGroups as $id=>$name)
+ {
+ if ( !in_array($name,$groups) )
+ $user->delGroup($id);
+ }
+
+ foreach( $groups as $name)
+ {
+ if ( ! in_array($name,$oldGroups))
+ {
+ try
+ {
+ $group = Group::loadWithName( $name );
+ $user->addGroup($group->groupid);
+ }
+ catch (ObjectNotFoundException $e)
+ {
+ // Gruppe fehlt. Anlegen?
+ if ( config('ldap','authorize','auto_add' ) )
+ {
+ // Die Gruppe in der OpenRat-Datenbank hinzufuegen.
+ $g = new Group();
+ $g->name = $group;
+ $g->add(); // Gruppe hinzufuegen
+ $user->addGroup($g->groupid); // Und Gruppe dem Benutzer hinzufuegen.
+ }
+
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Login.
+ * Zuerst wird die Datenbankverbindung aufgebaut und falls notwendig, aktualisiert.
+ */
+ function loginPost()
+ {
+ global $conf;
+
+ if ( $this->hasRequestVar('dbid'))
+ {
+ $dbid = $this->getRequestVar('dbid');
+
+ if ( !is_array($conf['database'][$dbid]) )
+ $this->addValidationError('dbid');
+
+ try {
+
+
+ $db = new Database($conf['database'][$dbid], true);
+ $db->id = $dbid;
+ }
+ catch( Exception $e) {
+ throw new OpenRatException('DATABASE_ERROR_CONNECTION',$e->getMessage());
+ }
+
+ // Datenbank aktualisieren, sofern notwendig.
+ require_once( OR_DBCLASSES_DIR.'DbUpdate.class.'.PHP_EXT );
+ $updater = new DbUpdate();
+ $updater->update( $db );
+
+ unset($db);
+ }
+
+ $this->checkForDb();
+
+ Session::setUser(''); // Altes Login entfernen.
+
+ if ( $conf['login']['nologin'] )
+ Http::notAuthorized('login disabled');
+
+ $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
+ $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
+ $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
+ $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
+ $token = $this->getRequestVar('user_token' ,OR_FILTER_ALPHANUM);
+
+ // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
+ // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
+ if ( empty($newPassword1) )
+ {
+ // Kein neues Kennwort,
+ // nichts zu tun...
+ }
+ else
+ {
+ $auth = new InternalAuth();
+
+ if ( $auth->login($loginName, $loginPassword,$token) || $auth->mustChangePassword )
+ {
+ if ( $newPassword1 != $newPassword2 )
+ {
+ $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
+ $this->addValidationError('password2','');
+ return;
+ }
+ elseif ( strlen($newPassword1) < $conf['security']['password']['min_length'] )
+ {
+ $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
+ $this->addValidationError('password2','');
+ return;
+ }
+ else
+ {
+ // Kennwoerter identisch und lang genug.
+ $user = User::loadWithName($loginName);
+ $user->setPassword( $newPassword1,true );
+
+ // Das neue gesetzte Kennwort für die weitere Authentifizierung benutzen.
+ $loginPassword = $newPassword1;
+ }
+ }
+ else
+ {
+ // Anmeldung gescheitert.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
+ $this->addValidationError('login_name' ,'');
+ $this->addValidationError('login_password','');
+ return;
+ }
+ }
+
+ // Cookie setzen
+ $cookieLifetime = 60*60*24*30*12*2; // 2 Jahre.
+ setcookie('or_username',$loginName ,time()+$cookieLifetime );
+ setcookie('or_dbid' ,$this->getRequestVar('dbid'),time()+$cookieLifetime );
+
+ // Authentifzierungs-Module.
+ $modules = explode(',',$conf['security']['modules']['authenticate']);
+
+ $loginOk = false;
+ $mustChangePassword = false;
+ $tokenFailed = false;
+ $groups = null;
+ $lastModule = null;
+
+ // Jedes Authentifizierungsmodul durchlaufen, bis ein Login erfolgreich ist.
+ foreach( $modules as $module)
+ {
+ $moduleClass = $module.'Auth';
+ $auth = new $moduleClass;
+ Logger::info('Trying to login with module '.$moduleClass);
+ $loginStatus = $auth->login( $loginName,$loginPassword, $token );
+ $loginOk = $loginStatus === true || $loginStatus === OR_AUTH_STATUS_SUCCESS;
+
+ if ( $loginStatus === OR_AUTH_STATUS_PW_EXPIRED )
+ $mustChangePassword = true;
+ if ( $loginStatus === OR_AUTH_STATUS_TOKEN_NEEDED )
+ $tokenFailed = true;
+
+ if ( $loginOk )
+ {
+ Logger::info('Login successful for '.$loginName);
+ $lastModule = $module;
+
+ if ( isset($auth->groups ) )
+ $groups = $auth->groups;
+
+ break; // Login erfolgreich, erstes Modul gewinnt.
+ }
+ }
+
+ /*
+ $loginOk = $this->checkLogin( $loginName,
+ $loginPassword,
+ $newPassword1,
+ $newPassword2 );
+ */
+
+
+ if ( $loginOk )
+ {
+
+ try
+ {
+ // Benutzer über den Benutzernamen laden.
+ $user = User::loadWithName($loginName);
+ $user->loginModuleName = $lastModule;
+// Session::setUser($user);
+ $user->setCurrent();
+
+ if ($user->passwordAlgo != Password::bestAlgoAvailable() )
+ // Re-Hash the password with a better hash algo.
+ $user->setPassword($loginPassword);
+
+ }
+ catch( ObjectNotFoundException $ex )
+ {
+ // Benutzer wurde zwar authentifiziert, ist aber in der
+ // internen Datenbank nicht vorhanden
+ if ( $conf['security']['newuser']['autoadd'] )
+ {
+ // Neue Benutzer in die interne Datenbank uebernehmen.
+ $user = new User();
+ $user->name = $loginName;
+ $user->fullname = $loginName;
+ $user->add();
+ $user->save();
+ }
+ else
+ {
+ // Benutzer soll nicht angelegt werden.
+ // Daher ist die Anmeldung hier gescheitert.
+ $loginOk = false;
+ }
+ }
+ }
+
+ Password::delay();
+
+ $ip = getenv("REMOTE_ADDR");
+
+ if ( !$loginOk )
+ {
+ // Anmeldung nicht erfolgreich
+
+ Logger::debug("Login failed for user '$loginName' from IP $ip");
+
+ if ( $tokenFailed )
+ {
+ // Token falsch.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED_TOKEN_FAILED','error' );
+ $this->addValidationError('user_token','');
+ }
+ elseif ( $mustChangePassword )
+ {
+ // Anmeldung gescheitert, Benutzer muss Kennwort ?ndern.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' );
+ $this->addValidationError('password1','');
+ $this->addValidationError('password2','');
+ }
+ else
+ {
+ // Anmeldung gescheitert.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
+ $this->addValidationError('login_name' ,'');
+ $this->addValidationError('login_password','');
+ }
+
+
+ //$this->callSubAction('login');
+ return;
+ }
+ else
+ {
+
+ Logger::debug("Login successful for user '$loginName' from IP $ip");
+
+ $this->checkGroups( $user, $groups );
+
+ if ( $this->hasRequestVar('remember') )
+ {
+ // Cookie setzen
+ setcookie('or_username',$user->name ,time()+(60*60*24*30*12*2) );
+ setcookie('or_token' ,$user->loginToken(),time()+(60*60*24*30*12*2) );
+ }
+
+ // Anmeldung erfolgreich.
+ if ( config('security','renew_session_login') )
+ $this->recreateSession();
+
+ $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname));
+
+ $this->setStyle( $user->style );
+
+ $this->evaluateRequestVars();
+
+ $object = Session::getObject();
+ // Falls noch kein Objekt ausgewaehlt, dann das zuletzt ge?nderte benutzen.
+ if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] )
+ {
+ $objectid = Value::getLastChangedObjectByUserId($user->userid);
+ if ( Object::available($objectid))
+ {
+ $object = new Object($objectid);
+ $object->load();
+ Session::setObject($object);
+
+ $project = new Project( $object->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+ }
+
+ $this->setStyle( $user->style ); // Benutzer-Style setzen
+
+ $langFile = OR_LANGUAGE_DIR.'lang-'.$user->language.'.'.PHP_EXT;
+
+ // Pruefen, ob Sprache vorhanden ist.
+ if ( !file_exists( $langFile ) )
+ {
+ // Nur Warnung ins Log schreiben, keinen Fehler werfen
+ // Es ist möglich, dass Sprachen entfernt werden.
+ Logger::warn("Languagefile $langFile does not exist.");
+ }
+ else
+ {
+ require( $langFile );
+ global $conf;
+ $conf['language'] = $lang;
+ $conf['language']['language_code'] = $user->language;
+ Session::setConfig( $conf );
+ }
+
+
+
+ // Entscheiden, welche Perspektive als erstes angezeigt werden soll.
+
+ $allProjects = Project::getAllProjects();
+
+ if ( $conf['login']['start']['start_single_project'] &&
+ count($allProjects) == 1 )
+ {
+ // Das einzige Projekt sofort starten.
+ $projectIds = array_keys($allProjects);
+
+ $project = new Project($projectIds[0]);
+ $project->load();
+ $language = new Language( $project->getDefaultLanguageId() );
+ $language->load();
+ $model = new Model( $project->getDefaultModelId() );
+ $model->load();
+
+ Session::setProject( $project );
+ Session::setProjectLanguage( $language );
+ Session::setProjectModel( $model );
+
+
+ $this->setPerspective('normal');
+ }
+ elseif ( $conf['login']['start']['start_lastchanged_object'] )
+ {
+ $user = Session::getUser();
+ $objectid = Value::getLastChangedObjectByUserId($user->userid);
+ if ( Object::available($objectid))
+ {
+ // Das Projekt des zuletzt geänderten Objekts ermitteln
+ // und dieses Projekt starten.
+ $o = new Object( $objectid );
+ $o->load();
+
+ $project = new Project($o->projectid);
+ $project->load();
+ $language = new Language( $project->getDefaultLanguageId() );
+ $language->load();
+ $model = new Model( $project->getDefaultModelId() );
+ $model->load();
+
+ Session::setProject( $project );
+ Session::setProjectLanguage( $language );
+ Session::setProjectModel( $model );
+
+ $this->setPerspective('normal');
+ }
+ else
+ {
+ // Benutzer hat noch nie eine Änderung durchgefuehrt.
+ // Erstmal die Startseite anzeigen.
+ $this->setPerspective('start');
+ }
+ }
+
+ else
+ {
+ // Erstmal die Startseite anzeigen.
+ $this->setPerspective('start');
+ }
+ }
+
+ }
+
+
+ /**
+ * Benutzer meldet sich ab.
+ */
+ function logoutPost()
+ {
+ global $conf;
+
+ $user = Session::getUser();
+ if ( is_object($user) )
+ $this->setTemplateVar('login_username',$user->name);
+
+ // Ausgew?hlte Objekte merken, um nach dem n?. Login wieder sofort auszuw?hlen.
+ $o = Session::getObject();
+ if ( is_object($o) )
+ $this->setTemplateVar('objectid',$o->objectid);
+ $p = Session::getProject();
+ if ( is_object($p) )
+ $this->setTemplateVar('projectid',$p->projectid);
+ $l = Session::getProjectLanguage();
+ if ( is_object($l) )
+ $this->setTemplateVar('languageid',$l->languageid);
+ $m = Session::getProjectModel();
+ if ( is_object($m) )
+ $this->setTemplateVar('modelid',$m->modelid);
+ $db = db_connection();
+ if ( is_object($db) )
+ $this->setTemplateVar('dbid',$db->id);
+
+ /*
+ // Alle Variablen aus der Sitzung entfernen.
+ session_unset();
+
+ // Damit wird die Session gel�scht, nicht nur die Session-Daten!
+ if ( ini_get("session.use_cookies") )
+ {
+ $params = session_get_cookie_params();
+ setcookie( session_name(),'', time() - 3600,
+ $params["path"],$params["domain"],$params["secure"],$params["httponly"] );
+ }
+
+ // Loeschen der Session.
+ session_destroy();
+ */
+ if ( config('security','renew_session_logout') )
+ $this->recreateSession();
+
+ session_unset();
+
+ if ( @$conf['theme']['compiler']['compile_at_logout'] )
+ {
+ foreach( $conf['action'] as $actionName => $actionConfig )
+ {
+ foreach( $actionConfig as $subActionName=>$subaction )
+ {
+ if ( is_array($subaction) &&
+ !isset($subaction['goto' ]) &&
+ !isset($subaction['direct']) &&
+ !isset($subaction['action']) &&
+ !isset($subaction['async' ]) &&
+ !isset($subaction['alias' ]) &&
+ $subActionName != 'menu' )
+ {
+ $engine = new template_engine\TemplateEngine();
+ $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName);
+ }
+ }
+ }
+ }
+
+ // Login-Token löschen:
+ // Wenn der Benutzer sich abmelden will, dann soll auch die automatische
+ // Anmeldung deaktiviert werden.
+ setcookie('or_token' ,'',0 );
+
+ // Umleiten auf eine definierte URL.s
+ $redirect_url = @$conf['security']['logout']['redirect_url'];
+
+ if ( !empty($redirect_url) )
+ {
+ $this->redirect($redirect_url);
+ }
+
+ Session::set('perspective','login');
+
+ // Style zurücksetzen.
+ // Der Style des Benutzers koennte auch stehen bleiben. Aber dann gäbe es Rückschlüsse darauf, wer zuletzt angemeldet war (Sicherheit!).
+ $this->setStyle( config('interface','style','default') );
+ $this->refresh();
+ }
+
+
+
+ /**
+ * Benutzer meldet sich ab.
+ */
+ function logoutView()
+ {
+ }
+
+
+ /**
+ * Ausw?hlen der Administration.
+ */
+ function administration()
+ {
+ Session::setProject( new Project(-1) );
+ }
+
+
+
+ /**
+ * Ausgeben von maschinenlesbaren Benutzerinformationen.
+ *
+ * Diese Funktion dient dem Single-Signon f?r fremde Anwendungen, welche
+ * die Benutzerinformationen des angemeldeten Benutzers aus dieser
+ * Anwendung auslesen k?nnen.
+ */
+ function userinfo()
+ {
+ $user = Session::getUser();
+ $info = array('username' => $user->name,
+ 'fullname' => $user->fullname,
+ 'mail' => $user->mail,
+ 'telephone' => $user->tel,
+ 'style' => $user->style,
+ 'admin' => $user->isAdmin?'true':'false',
+ 'ldap' => $user->ldap_dn,
+ 'groups' => implode(',',$user->getGroups()),
+ 'description'=> $user->desc
+ );
+
+ // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die
+ // Informationen per XML aus.
+ if ( $this->hasRequestVar('xml') )
+ {
+ header('Content-Type: text/xml');
+ echo '<userinfo>';
+ foreach( $info as $n=>$i )
+ echo '<'.$n.'>'.$i.'</'.$n.'>'."\n";
+ echo '</userinfo>';
+
+ }
+
+ // Sonst normale Textausgabe im INI-Datei-Format.
+ else
+ {
+ header('Content-Type: text/plain');
+ foreach( $info as $n=>$i )
+ echo $n.'="'.$i."\"\n";
+ }
+
+ exit; // Fertig.
+ }
+
+
+ function project()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
+
+ Session::setUser( $user );
+ }
+
+
+ function object()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) );
+
+ Session::setUser( $user );
+ }
+
+
+ function language()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) );
+ }
+
+
+ function model()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) );
+
+ $user = Session::getUser();
+ }
+
+
+ /**
+ * Auswerten der Request-Variablen.
+ *
+ * @param Array $add
+ */
+ function evaluateRequestVars( $add = array() )
+ {
+ global $REQ;
+ $vars = $REQ + $add;
+
+ $db = db_connection();
+ if ( !is_object($db) )
+ {
+ if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
+ $this->setDb($vars[REQ_PARAM_DATABASE_ID]);
+ else
+ Http::serverError('no database available.');
+ }
+ else
+ {
+ // Pr�ft, ob die �bergebene Datenbank-Id mit der
+ // aktuellen �bereinstimmt.
+ // Falls nicht, muss ein Re-Login erfolgen.
+ if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
+ if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+ }
+
+
+ if ( isset($vars[REQ_PARAM_OBJECT_ID]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) )
+ {
+ $object = new Object( $vars[REQ_PARAM_OBJECT_ID] );
+ $object->objectLoadRaw();
+ Session::setObject( $object );
+
+ $project = new Project( $object->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+ elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) )
+ {
+ $language = new Language( $vars[REQ_PARAM_LANGUAGE_ID] );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $project = new Project( $language->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $model = Session::getProjectModel();
+ if ( !is_object($model) )
+ {
+ $model = new Model( $project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+
+ $object = Session::getObject();
+ if ( is_object($object) && $object->projectid == $project->projectid )
+ {
+ $object->objectLoadRaw();
+ Session::setObject( $object );
+ }
+ else
+ {
+ Session::setObject( '' );
+ }
+ }
+ elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) )
+ {
+ $model = new Model( $vars[REQ_PARAM_MODEL_ID] );
+ $model->load();
+ Session::setProjectModel( $model );
+
+ $project = new Project( $model->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = Session::getProjectLanguage();
+ if ( !is_object($language) || $language->projectid != $project->projectid )
+ {
+ $language = new Language( $project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+ }
+
+ $object = Session::getObject();
+ $object->objectLoadRaw();
+ if ( is_object($object) && $object->projectid == $project->projectid )
+ {
+ $object->objectLoadRaw();
+ Session::setObject( $object );
+ }
+ else
+ {
+ Session::setObject( '' );
+ }
+ }
+ elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) )
+ {
+ $project = new Project( $vars[REQ_PARAM_PROJECT_ID] );
+ $project->load();
+
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+
+ $object = Session::getObject();
+ if ( is_object($object) && $object->projectid == $project->projectid )
+ {
+ $object->objectLoadRaw();
+ Session::setObject( $object );
+ }
+ else
+ {
+ Session::setObject( '' );
+ }
+ }
+ }
+
+
+ function showtree()
+ {
+ Session::set('showtree',true );
+ }
+
+
+ function hidetree()
+ {
+ Session::set('showtree',false );
+ }
+
+
+ function switchuser()
+ {
+ $user = Session::getUser();
+
+ if ( ! $user->isAdmin )
+ Http::notAuthorized("");
+
+ $this->recreateSession();
+
+ $newUser = new User( $this->getRequestId() );
+ $newUser->load();
+
+ $newUser->setCurrent();
+ }
+
+
+ function show()
+ {
+ global $conf;
+ global $PHP_AUTH_USER;
+ global $PHP_AUTH_PW;
+
+ $user = Session::getUser();
+ // Gast-Login
+ if ( ! is_object($user) )
+ {
+ if ( $conf['security']['guest']['enable'] )
+ {
+ $this->setDefaultDb();
+ $username = $conf['security']['guest']['user'];
+ $user = User::loadWithName($username);
+ if ( $user->userid > 0 )
+ $user->setCurrent();
+ else
+ {
+ Logger::warn('Guest login failed, user not found: '.$username);
+ $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) );
+ $user = null;
+ }
+ }
+ }
+
+ if ( ! is_object($user) )
+ {
+ switch( $conf['security']['login']['type'] )
+ {
+
+ // Authorization ueber HTTP
+ //
+ case 'http':
+ $ok = false;
+
+ if ( isset($_SERVER['PHP_AUTH_USER']) )
+ {
+ $this->setDefaultDb();
+ $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] );
+ }
+
+ if ( ! $ok )
+ {
+ header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' );
+ header( 'HTTP/1.0 401 Unauthorized' );
+ echo 'Authorization Required!';
+ exit;
+ }
+ break;
+
+ case 'form':
+ // Benutzer ist nicht angemeldet
+ $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske
+ return;
+ break;
+
+ default:
+ Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' );
+ }
+ }
+
+ if ( $user->mustChangePassword )
+ {
+ $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
+ $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu ?ndern.
+ }
+
+ // Seite ?ndert sich nur 1x pro Session
+ $this->lastModified( $user->loginDate );
+
+ $projectid = intval( $this->getRequestVar('projectid' ) );
+ $languageid = intval( $this->getRequestVar('languageid') );
+ $modelid = intval( $this->getRequestVar('modelid' ) );
+ $objectid = intval( $this->getRequestVar('objectid' ) );
+ $elementid = intval( $this->getRequestVar('elementid' ) );
+
+ if ( $projectid != 0 )
+ {
+ $project = new Project( $projectid );
+ $project->load();
+ Session::setProject($project);
+ }
+ elseif ( $languageid != 0 )
+ {
+ $language = new Language( $languageid );
+ $language->load();
+ Session::setProjectLanguage($language);
+ }
+ elseif ( $modelid != 0 )
+ {
+ $model = new Model( $modelid );
+ $model->load();
+ Session::setProjectModel($model);
+ }
+ elseif ( $objectid != 0 )
+ {
+ $object = new Object( $objectid );
+ $object->objectLoad();
+ Session::setObject($object);
+ }
+ if ( $elementid != 0 )
+ {
+ $element = new Element( $elementid );
+ Session::setElement($element);
+ }
+
+ $project = Session::getProject();
+ $object = Session::getObject();
+ $elementid = 0;
+
+ if ( is_object($project) )
+ {
+ if ( $project->projectid == PROJECTID_ADMIN )
+ {
+ $project->name = lang('ADMINISTRATION');
+ Session::setProject( $project );
+
+ Session::setProjectLanguage( '' );
+ Session::setProjectModel ( '' );
+ Session::setObject ( '' );
+ }
+
+ $this->setTemplateVar( 'title',$project->name );
+
+ if ( is_object($object) )
+ {
+ $type = $object->getType();
+
+ if ( $type == 'page' )
+ {
+ $page = new Page($object->objectid);
+ $page->load();
+ $elementList = $page->getWritableElements();
+ if ( count($elementList) == 1 )
+ $elementid = current(array_keys($elementList));
+ }
+
+ if ( $elementid > 0 )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) );
+ else
+ $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) );
+ }
+ else
+ {
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
+ }
+ }
+ elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN )
+ {
+ if ( $this->hasRequestVar('projectid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) );
+ elseif ( $this->hasRequestVar('groupid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) );
+ elseif ( $this->hasRequestVar('userid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) );
+ else
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
+ }
+ else
+ {
+ $this->callSubAction( 'projectmenu' );
+ }
+
+
+ $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) );
+
+ $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) );
+ $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) );
+ $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) );
+ $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) );
+ $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) );
+ $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) );
+
+ $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] );
+
+ $this->metaValues();
+ }
+
+
+
+ function checkMenu( $name )
+ {
+ global $conf;
+
+ switch( $name )
+ {
+ case 'applications':
+ // Men?punkt "Anwendungen" wird nur angezeigt, wenn weitere Anwendungen
+ // konfiguriert sind.
+ return count(@$conf['applications']) > 0;
+
+ case 'register': // Registrierung
+ // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
+ return @$conf['login']['register'] && @$conf['security']['auth']['type'] == 'database';
+
+ case 'password': // Kennwort vergessen
+ // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
+ // Deaktiviert, falls LDAP-Lookup aktiviert ist.
+ return @$conf['login']['send_password'] && @$conf['security']['auth']['type'] == 'database'
+ && !@$conf['security']['auth']['userdn'];
+
+ case 'administration':
+ // "Administration" nat?rlich nur f?r Administratoren.
+ return $this->userIsAdmin();
+
+ case 'login':
+ return !@$conf['login']['nologin'];
+
+ case 'logout':
+ return true;
+
+ case 'projectmenu':
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+
+ /**
+ * Maske anzeigen, um Benutzer zu registrieren.
+ */
+ public function registerView()
+ {
+
+ }
+
+
+ /**
+ * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen.
+ * Maske anzeigen, damit Benuter Registriercode anzeigen kann.
+ */
+ public function registercodeView()
+ {
+ global $conf;
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbname] = $dbconf['description'];
+ }
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ $db = Session::getDatabase();
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ else
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+
+
+
+ }
+
+
+
+ public function registerPost()
+ {
+ global $conf;
+
+ Session::set('registerMail',$this->getRequestVar('mail') );
+
+ srand ((double)microtime()*1000003);
+ $registerCode = rand();
+
+ Session::set('registerCode',$registerCode );
+
+ $email_address = $this->getRequestVar('mail',OR_FILTER_MAIL);
+
+ if ( ! Mail::checkAddress($email_address) )
+ {
+ $this->addValidationError('mail');
+ return;
+ }
+
+ // E-Mail and die eingegebene Adresse verschicken
+ $mail = new Mail($email_address,
+ 'register_commit_code','register_commit_code');
+ $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable
+
+ if ( $mail->send() )
+ {
+ $this->addNotice('','','mail_sent',OR_NOTICE_OK);
+ $this->nextView('registeruserdata');
+ }
+ else
+ {
+ $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error);
+ return;
+ }
+
+ $this->nextView('registercode');
+ }
+
+
+ /**
+ * Benutzerregistierung.
+ * Benutzer hat Best?tigungscode erhalten und eingegeben.
+ */
+ function registercodePost()
+ {
+ global $conf;
+ $this->checkForDb();
+
+ $origRegisterCode = Session::get('registerCode');
+ $inputRegisterCode = $this->getRequestVar('code');
+
+ if ( $origRegisterCode != $inputRegisterCode )
+ {
+ // Best?tigungscode stimmt nicht.
+ $this->addValidationError('code','code_not_match');
+ return;
+ }
+
+ // Best?tigungscode stimmt ?berein.
+ // Neuen Benutzer anlegen.
+
+ if ( !$this->hasRequestVar('username') )
+ {
+ $this->addValidationError('username');
+ return;
+ }
+
+ $user = User::loadWithName( $this->getRequestVar('username') );
+ if ( $user->isValid() )
+ {
+ $this->addValidationError('username','USER_ALREADY_IN_DATABASE');
+ return;
+ }
+
+ if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] )
+ {
+ $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length']));
+ return;
+ }
+
+ $newUser = new User();
+ $newUser->name = $this->getRequestVar('username');
+ $newUser->add();
+
+ $newUser->mail = Session::get('registerMail');
+ $newUser->save();
+
+ $newUser->setPassword( $this->getRequestVar('password'),true );
+
+ $this->addNotice('user',$newUser->name,'user_added','ok');
+
+ $this->nextView('login');
+ }
+
+
+
+ /**
+ * Vergessenes Kennwort zusenden lassen.
+ */
+ function passwordView()
+ {
+ // TODO: Attribut "Password" abfragen
+ foreach( config('database') as $dbname=>$dbconf )
+ {
+ $dbconf = $dbconf + config('database-default','defaults');
+ if ( $dbconf['enabled'] )
+ $dbids[$dbname] = $dbconf['description'];
+ }
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+
+ $db = Session::getDatabase();
+
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ else
+ $this->setTemplateVar('actdbid',config('database-default','default-id'));
+ }
+
+
+ /*
+ function changepassword()
+ {
+ }
+ */
+
+
+ /*
+ function setnewpassword()
+ {
+ $oldPw = $this->getRequestVar('password_old' );
+ $newPw1 = $this->getRequestVar('password_new_1');
+ $newPw2 = $this->getRequestVar('password_new_2');
+
+ if ( $newPw1 == $newPw2 )
+ {
+ // Aktuellen Benutzer aus der Sitzung ermitteln
+ $user = $this->getUserFromSession();
+
+ // Altes Kennwort pr?fen.
+ $ok = $user->checkPassword( $oldPw );
+
+ if ( $ok ) // Altes Kennwort ist ok.
+ {
+ $user->setPassword( $newPw1 ); // Setze neues Kennwort
+ $user->mustChangePassword = false;
+ Session::setUser($user);
+ $this->addNotice('user',$user->name,'password_set','ok');
+ }
+ else
+ {
+ // Altes Kennwort falsch.
+ $this->addNotice('user',$user->name,'password_error','error');
+ }
+ }
+ else
+ {
+ // Beide neuen Kennw?rter stimmen nicht ?berein
+ $this->addNotice('user',$user->name,'passwords_not_match','error');
+ }
+ }
+ */
+
+
+ /**
+ * Einen Kennwort-Anforderungscode an den Benutzer senden.
+ */
+ function passwordPost()
+ {
+ if ( !$this->hasRequestVar('username') )
+ {
+ $this->addValidationError('username');
+ return;
+ }
+
+ $this->checkForDb();
+
+ $user = User::loadWithName( $this->getRequestVar("username") );
+ // Html::debug($user);
+ Password::delay();
+ if ( $user->isValid() )
+ {
+ srand ((double)microtime()*1000003);
+ $code = rand();
+ $this->setSessionVar("password_commit_code",$code);
+
+ $eMail = new Mail( $user->mail,'password_commit_code' );
+ $eMail->setVar('name',$user->getName());
+ $eMail->setVar('code',$code);
+ if ( $eMail->send() )
+ $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK);
+ else
+ $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error);
+
+ }
+ else
+ {
+ //$this->addNotice('','user','username_not_found');
+ // Trotzdem vort?uschen, eine E-Mail zu senden, damit die G?ltigkeit
+ // eines Benutzernamens nicht von au?en gepr?ft werden kann.
+ //
+ $this->addNotice('user',$this->getRequestVar("username"),'mail_sent');
+
+ }
+
+ $this->setSessionVar("password_commit_name",$user->name);
+ $this->nextView('passwordcode');
+ }
+
+
+
+ /**
+ * Anzeige Formular zum Eingeben des Kennwort-Codes.
+ *
+ */
+ function passwordcodeView()
+ {
+
+ }
+
+
+ /**
+ * Neues Kennwort erzeugen und dem Benutzer zusenden.
+ */
+ function passwordcodePost()
+ {
+ $username = $this->getSessionVar("password_commit_name");
+
+ if ( $this->getRequestVar("code")=='' ||
+ $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") )
+ {
+ $this->addValidationError('code','PASSWORDCODE_NOT_MATCH');
+ return;
+ }
+
+ $user = User::loadWithName( $username );
+
+ if ( !$user->isValid() )
+ {
+ // Benutzer konnte nicht geladen werden.
+ $this->addNotice('user',$username,'error',OR_NOTICE_ERROR);
+ return;
+ }
+
+ $newPw = User::createPassword(); // Neues Kennwort erzeugen.
+
+ $eMail = new Mail( $user->mail,'password_new' );
+ $eMail->setVar('name' ,$user->getName());
+ $eMail->setVar('password',$newPw );
+
+ if ( $eMail->send() )
+ {
+ $user->setPassword( $newPw, false ); // Kennwort muss beim n?. Login ge?ndert werden.
+ $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK);
+ }
+ else
+ {
+ // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den
+ // Code per E-Mail erhalten hat.
+ $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error);
+ }
+ }
+
+
+ /**
+ * Erzeugt eine neue Sitzung.
+ */
+ function recreateSession()
+ {
+
+ // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht.
+ if ( version_compare(phpversion(),"4.3.2","<") )
+ {
+ $randlen = 32;
+ $randval = "0123456789abcdefghijklmnopqrstuvwxyz";
+ $newid = "";
+ for ($i = 1; $i <= $randlen; $i++)
+ {
+ $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1);
+ }
+ session_id( $newid );
+ }
+ elseif( version_compare(phpversion(),"4.3.2","==") )
+ {
+ session_regenerate_id();
+
+ // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt.
+ if ( ini_get("session.use_cookies") )
+ setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" );
+ }
+ elseif ( version_compare(phpversion(),"5.1.0",">") )
+ {
+ session_regenerate_id(true);
+ }
+ else
+ {
+ // 5.1.0 > PHP >= 4.3.3
+ }
+ }
+
+
+ function licenseView()
+ {
+ $software = array();
+
+ $software[] = array('name' =>'OpenRat Content Management System',
+ 'url' =>'http://www.openrat.de/',
+ 'license'=>'GPL v2');
+ $software[] = array('name' =>'jQuery Core Javascript Framework',
+ 'url' =>'http://jquery.com/',
+ 'license'=>'MPL, GPL v2');
+ $software[] = array('name' =>'jQuery UI Javascript Framework',
+ 'url' =>'http://jqueryui.com/',
+ 'license'=>'MPL, GPL v2');
+ $software[] = array('name' =>'GeSHi - Generic Syntax Highlighter',
+ 'url' =>'http://qbnz.com/highlighter/',
+ 'license'=>'GPL v2');
+ $software[] = array('name' =>'CKEditor',
+ 'url' =>'http://ckeditor.com/',
+ 'license'=>'GPL v2');
+ $software[] = array('name' =>'960 Grid System CSS',
+ 'url' =>'http://960.gs/',
+ 'license'=>'GPL v3, MIT');
+ $software[] = array('name' =>'TAR file format',
+ 'url' =>'http://www.phpclasses.org/package/529',
+ 'license'=>'LGPL');
+ $software[] = array('name' =>'JSON file format',
+ 'url' =>'http://pear.php.net/pepr/pepr-proposal-show.php?id=198',
+ 'license'=>'BSD');
+
+ $this->setTemplateVar('software',$software);
+ }
+
+
+ function pingView()
+ {
+ echo "1";
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/ModelAction.class.php b/modules/cms-core/action/ModelAction.class.php
@@ -0,0 +1,209 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Model;
+
+
+
+use Session;
+use \Html;
+
+// 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 zum Bearbeiten eines Projetmodells
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class ModelAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $defaultSubAction = 'listing';
+ var $model;
+
+
+ function __construct()
+ {
+ $this->model = new Model( $this->getRequestId() );
+ $this->model->load();
+
+ $this->project = Session::getProject();
+ }
+
+
+
+
+ /**
+ * Entfernen der Variante.<br>
+ * Es wird ein Best�tigungsdialog angezeigt.
+ */
+ function removeView()
+ {
+ $this->model->load();
+
+ $this->setTemplateVar( 'name',$this->model->name );
+ }
+
+
+ /**
+ * Löschen des Models.
+ */
+ function removePost()
+ {
+ if ( $this->hasRequestVar('confirm') )
+ {
+ $this->model->delete();
+ $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice('model',$this->model->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ }
+ }
+
+
+
+ // Speichern eines Modells
+ function editPost()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $this->model->name = $this->getRequestVar('name');
+ $this->model->save();
+ $this->addNotice('model',$this->model->name,'SAVED','ok');
+ }
+ else
+ {
+ $this->addNotice('model',$this->model->name,'NOT_SAVED','error');
+ }
+
+ // Baum aktualisieren
+// $this->setTemplateVar('tree_refresh',true);
+ }
+
+
+ function setdefaultPost()
+ {
+ if ( !$this->userIsAdmin() ) exit();
+
+ $this->model->setDefault();
+
+ $this->callSubAction('listing');
+ }
+
+
+ function listingView()
+ {
+ global $conf_php;
+ $actModel = Session::getProjectModel();
+
+// $var['act_modelid'] = $this->getSessionVar('modelid');
+
+ $list = array();
+ foreach( $this->project->getModelIds() as $id )
+ {
+ $m = new Model( $id );
+ $m->load();
+
+ $list[$id]['name'] = $m->name;
+
+ if ( $this->userIsAdmin() )
+ $list[$id]['url' ] = Html::url('model','edit',$id,
+ array() );
+
+ if ( ! $m->isDefault && $this->userIsAdmin() )
+ $list[$id]['default_url'] = Html::url('model','setdefault',$id);
+
+ if ( $actModel->modelid != $m->modelid )
+ $list[$id]['select_url' ] = Html::url('index','model',$id);
+ }
+ $this->setTemplateVar( 'el',$list );
+ $this->setTemplateVar( 'add',$this->userIsAdmin() );
+ }
+
+
+ /**
+ * Bearbeiten der Variante.
+ * Ermitteln aller Eigenschaften der Variante.
+ */
+ function editView()
+ {
+ $this->model->load();
+
+ $this->setTemplateVars( $this->model->getProperties() );
+ }
+
+
+ function checkmenu( $menu )
+ {
+ switch( $menu )
+ {
+ case 'remove':
+ $actModel = Session::getProjectModel();
+ return
+ !readonly() &&
+ $this->userIsAdmin() &&
+ is_object($this->model) &&
+ count( $this->model->getAll() ) >= 2 &&
+ $actModel->modelid != $this->model->modelid;
+
+ case 'add':
+ return
+ !readonly() && $this->userIsAdmin();
+
+ default:
+ return true;
+ }
+ }
+
+
+ /**
+ * 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();
+ $modellistChildren = array();
+
+ $structure[0] = array('id'=>'0','name'=>lang('MODELS'),'type'=>'modellist','level'=>1,'children'=>&$modellistChildren);
+
+ $modellistChildren[ $this->model->modelid ] = array('id'=>$this->model->modelid,'name'=>$this->model->name,'type'=>'model','self'=>true);
+
+
+ //Html::debug($structure);
+
+ $this->setTemplateVar('outline',$structure);
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/ModellistAction.class.php b/modules/cms-core/action/ModellistAction.class.php
@@ -0,0 +1,118 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Model;
+use Html;
+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 zum Bearbeiten eines Projetmodells
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class ModellistAction extends Action
+{
+ /**
+ * @var Model
+ */
+ public $model;
+
+ public $security = SECURITY_USER;
+
+ private $project;
+
+ function __construct()
+ {
+ if ( $this->getRequestId() != 0 )
+ {
+ $this->model = new Model( $this->getRequestId() );
+ $this->model->load();
+ }
+
+ $this->project = Session::getProject();
+ }
+
+
+ function showView()
+ {
+ global $conf_php;
+ $actModel = Session::getProjectModel();
+
+// $var['act_modelid'] = $this->getSessionVar('modelid');
+
+ $list = array();
+ foreach( $this->project->getModelIds() as $id )
+ {
+ $m = new Model( $id );
+ $m->load();
+
+ $list[$id]['name'] = $m->name;
+
+ if ( $this->userIsAdmin() )
+ $list[$id]['id' ] = $id;
+
+ if ( ! $m->isDefault && $this->userIsAdmin() )
+ $list[$id]['default_url'] = Html::url('model','setdefault',$id);
+
+ if ( $actModel->modelid != $m->modelid )
+ $list[$id]['select_url' ] = Html::url('index','model',$id);
+ }
+ $this->setTemplateVar( 'el',$list );
+ $this->setTemplateVar( 'add',$this->userIsAdmin() );
+ }
+
+
+ /**
+ * Bearbeiten der Variante.
+ * Ermitteln aller Eigenschaften der Variante.
+ */
+ function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+
+
+ function addView()
+ {
+ }
+
+
+ function addPost()
+ {
+ $model = new Model();
+ $model->projectid = $this->project->projectid;
+ $model->name = $this->getRequestVar('name');
+ $model->add();
+
+ // Wenn kein Namen eingegeben, dann einen setzen.
+ if ( empty($model->name) )
+ {
+ // Name ist "Variante <id>"
+ $model->name = lang('MODEL').' '.$model->modelid;
+ $model->save();
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/ObjectAction.class.php b/modules/cms-core/action/ObjectAction.class.php
@@ -0,0 +1,480 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Acl;
+use cms\model\User;
+use cms\model\Group;
+use cms\model\Page;
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\Language;
+use cms\model\File;
+use cms\model\Link;
+
+// 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 zum Bearbeiten eines Ordners
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class ObjectAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ private $objectid;
+
+ public function copyView()
+ {
+ $this->actionName = 'object';
+ global $conf_php;
+
+ $sourceObject = new Object( $this->getRequestId());
+ $sourceObject->load();
+
+ $targetFolder = new Object( $this->getRequestVar('targetFolderId',OR_FILTER_NUMBER));
+ $targetFolder->load();
+
+ $this->setTemplateVar('source' ,$sourceObject->getProperties() );
+ $this->setTemplateVar('sourceId',$sourceObject->objectid );
+ $this->setTemplateVar('target' ,$targetFolder->getProperties() );
+ $this->setTemplateVar('targetId',$targetFolder->objectid );
+ $this->setTemplateVar('types' ,array('move'=>'move','moveandlink'=>'moveandlink','copy'=>'copy','link'=>'link') );
+
+ if ( ! $targetFolder->hasRight(ACL_WRITE) )
+ {
+ $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
+ }
+ }
+
+
+ /**
+ * Ein Fileobjekt wird in einen neuen Ordner kopiert oder verschoben.
+ */
+ public function copyPost()
+ {
+ $type = $this->getRequestVar('type');
+ $targetObjectId = $this->getRequestVar('targetid',OR_FILTER_NUMBER);
+ $sourceObjectId = $this->getRequestVar('sourceid',OR_FILTER_NUMBER);
+
+ $sourceObject = new Object( $sourceObjectId );
+ $sourceObject->load();
+
+ $targetFolder = new Object( $targetObjectId );
+ $targetFolder->load();
+
+ // Prüfen, ob Schreibrechte im Zielordner bestehen.
+ if ( ! $targetFolder->hasRight(ACL_WRITE) )
+ {
+ $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
+ return;
+ }
+
+ switch( $type )
+ {
+ case 'move':
+
+ if ( $sourceObject->isFolder )
+ {
+ $f = new Folder( $sourceObjectId );
+ $allsubfolders = $f->getAllSubFolderIds();
+
+ // Plausibilisierungsprüfung:
+ //
+ // Wenn
+ // - Das Zielverzeichnis sich nicht in einem Unterverzeichnis des zu verschiebenen Ordners liegt
+ // und
+ // - Das Zielverzeichnis nicht der zu verschiebene Ordner ist
+ // dann verschieben
+ if ( in_array($targetObjectId,$allsubfolders) || $sourceObjectId == $targetObjectId )
+ {
+ $this->addNotice('folder',$sourceObject->name,'ERROR',OR_NOTICE_ERROR);
+ return;
+ }
+ }
+
+ // TODO:
+ // Beim Verschieben und Kopieren muss im Zielordner die Berechtigung
+ // zum Erstellen von Ordner, Dateien oder Seiten vorhanden sein.
+ $sourceObject->setParentId( $targetObjectId );
+ $this->addNotice($sourceObject->type, $sourceObject->name, 'moved');
+ break;
+
+ case 'moveandlink':
+
+ $oldParentId = $sourceObject->parentid;
+
+ $sourceObject->setParentId( $targetObjectId );
+ $this->addNotice($sourceObject->type, $sourceObject->name, 'moved');
+
+ $link = new Link();
+ $link->parentid = $oldParentId;
+ $link->name = lang('LINK_TO').' '.$sourceObject->name;
+ $link->filename = $sourceObject->filename;
+ $link->linkedObjectId = $sourceObjectId;
+ $link->add();
+ $this->addNotice('link', $link->name, 'added');
+
+ break;
+
+ case 'copy':
+
+ switch( $sourceObject->getType() )
+ {
+ case 'folder':
+ // Ordner zur Zeit nicht kopieren
+ // Funktion waere zu verwirrend
+ $this->addNotice($sourceObject->getType(),$sourceObject->name,'CANNOT_COPY_FOLDER','error');
+ break;
+
+ case 'file':
+ $f = new File( $sourceObjectId );
+ $f->load();
+ $f->filename = '';
+ $f->name = lang('COPY_OF').' '.$f->name;
+ $f->parentid = $targetObjectId;
+ $f->add();
+ $f->copyValueFromFile( $sourceObjectId );
+
+ $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
+ break;
+
+ case 'page':
+ $p = new Page( $sourceObjectId );
+ $p->load();
+ $p->filename = '';
+ $p->name = lang('COPY_OF').' '.$p->name;
+ $p->parentid = $targetObjectId;
+ $p->add();
+ $p->copyValuesFromPage( $sourceObjectId );
+ $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
+ break;
+
+ case 'link':
+ $l = new Link( $sourceObjectId );
+ $l->load();
+ $l->filename = '';
+ $l->name = lang('COPY_OF').' '.$l->name;
+ $l->parentid = $targetObjectId;
+ $l->add();
+ $this->addNotice($sourceObject->getType(),$sourceObject->name,'COPIED','ok');
+ break;
+
+ default:
+ Http::serverError('fatal: unknown type while deleting');
+ }
+ break;
+
+ case 'link':
+
+ // Beim Verkn�pfen muss im Zielordner die Berechtigung zum Erstellen
+ // von Verkn�pfungen vorhanden sein.
+ if ( ! $targetFolder->hasRight(ACL_CREATE_LINK) )
+ {
+ $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR);
+ return;
+ }
+
+ $link = new Link();
+ $link->parentid = $targetObjectId;
+ $link->name = lang('LINK_TO').' '.$sourceObject->name;
+ $link->filename = $sourceObject->filename;
+ $link->linkedObjectId = $sourceObjectId;
+ $link->isLinkToObject = true;
+ $link->add();
+ $this->addNotice('link', $link->name, 'added');
+ // OK
+ break;
+
+ default:
+ Http::serverError('Unknown type for copying');
+ break;
+ }
+
+ $targetFolder->setTimestamp();
+
+ }
+
+ /**
+ * ACL zu einem Objekt setzen
+ *
+ * @access public
+ */
+ function aclformPost()
+ {
+ $acl = new Acl();
+
+ $acl->objectid = $this->getRequestId();
+
+ // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
+ // diesem Objekt die ACLs zu aendern.
+ $o = new Object( $acl->objectid );
+
+ if ( !$o->hasRight( ACL_GRANT ) )
+ die('uh?'); // Scheiss Hacker.
+
+ // Handelt es sich um eine Benutzer- oder Gruppen ACL?
+ switch( $this->getRequestVar('type') )
+ {
+ case 'user':
+ $acl->userid = $this->getRequestVar('userid' );
+
+ if ( $acl->userid <= 0 )
+ {
+ $this->addValidationError('type' );
+ $this->addValidationError('userid','');
+ $this->callSubAction('aclform');
+ return;
+ }
+ break;
+ case 'group':
+ $acl->groupid = $this->getRequestVar('groupid');
+ if ( $acl->groupid <= 0 )
+ {
+ $this->addValidationError('type' );
+ $this->addValidationError('groupid','');
+ $this->callSubAction('aclform');
+ return;
+ }
+ break;
+ case 'all':
+ break;
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('aclform');
+ return;
+ }
+
+ $acl->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID);
+
+ $acl->write = ( $this->hasRequestVar('write' ) );
+ $acl->prop = ( $this->hasRequestVar('prop' ) );
+ $acl->delete = ( $this->hasRequestVar('delete' ) );
+ $acl->release = ( $this->hasRequestVar('release' ) );
+ $acl->publish = ( $this->hasRequestVar('publish' ) );
+ $acl->create_folder = ( $this->hasRequestVar('create_folder') );
+ $acl->create_file = ( $this->hasRequestVar('create_file' ) );
+ $acl->create_link = ( $this->hasRequestVar('create_link' ) );
+ $acl->create_page = ( $this->hasRequestVar('create_page' ) );
+ $acl->grant = ( $this->hasRequestVar('grant' ) );
+ $acl->transmit = ( $this->hasRequestVar('transmit' ) );
+
+ $acl->add();
+
+ // Falls die Berechtigung vererbbar ist, dann diese sofort an
+ // Unterobjekte vererben.
+ if ( $acl->transmit )
+ {
+ $folder = new Folder( $acl->objectid );
+ $oids = $folder->getObjectIds();
+ foreach( $folder->getAllSubfolderIds() as $sfid )
+ {
+ $subfolder = new Folder( $sfid );
+ $oids = array_merge($oids,$subfolder->getObjectIds());
+ }
+
+ foreach( $oids as $oid )
+ {
+ $acl->objectid = $oid;
+ $acl->add();
+ }
+ }
+
+
+
+
+ $this->addNotice('','','ADDED',OR_NOTICE_OK);
+
+ $o->setTimestamp();
+ }
+
+
+
+ /**
+ * Alle Rechte anzeigen
+ */
+ function rightsView()
+ {
+ $this->actionName = 'object';
+ $o = new Object( $this->getRequestId() );
+ $o->objectLoadRaw();
+ $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
+ $this->setTemplateVar( 'type',$o->getType() );
+
+ $acllist = array();
+
+ /*
+ foreach( $o->getAllInheritedAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+ $key = 'au'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
+ $acllist[$key] = $acl->getProperties();
+ }
+ */
+
+ foreach( $o->getAllAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+ $key = 'bu'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
+ $acllist[$key] = $acl->getProperties();
+ $acllist[$key]['aclid'] = $aclid;
+ }
+ ksort( $acllist );
+
+ $this->setTemplateVar('acls',$acllist );
+
+ $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
+ }
+
+
+
+ /**
+ * Alle Rechte anzeigen
+ */
+ function inheritView()
+ {
+ $this->actionName = 'object';
+
+ $o = new Object( $this->getRequestId() );
+ $o->objectLoadRaw();
+ $this->setTemplateVar( 'type',$o->getType() );
+
+ $acllist = array();
+ $this->setTemplateVar('acls',$acllist );
+ }
+
+
+
+ /**
+ *
+ * @return unknown_type
+ */
+ function inheritPost()
+ {
+ Session::close();
+
+ $folder = new Folder( $this->getRequestId() );
+ $folder->load();
+
+ if ( ! $this->hasRequestVar('inherit') )
+ {
+ $this->addNotice('folder',$folder->name,'NOTHING_DONE',OR_NOTICE_WARN);
+ return;
+ }
+
+
+ $aclids = $folder->getAllAclIds();
+
+ $newAclList = array();
+ foreach( $aclids as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+ if ( $acl->transmit )
+ $newAclList[] = $acl;
+ }
+ Logger::debug('inheriting '.count($newAclList).' acls');
+
+ $oids = $folder->getObjectIds();
+
+ foreach( $folder->getAllSubfolderIds() as $sfid )
+ {
+ $subfolder = new Folder( $sfid );
+
+ $oids = array_merge($oids,$subfolder->getObjectIds());
+ }
+
+ foreach( $oids as $oid )
+ {
+ $object = new Object( $oid );
+
+ // Die alten ACLs des Objektes löschen.
+ foreach( $object->getAllAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->objectid = $oid;
+ $acl->delete();
+ Logger::debug('removing acl '.$aclid.' for object '.$oid);
+ }
+
+ // Vererbbare ACLs des aktuellen Ordners anwenden.
+ foreach( $newAclList as $newAcl )
+ {
+ $newAcl->objectid = $oid;
+ $newAcl->add();
+ Logger::debug('adding new acl '.$newAcl->aclid.' for object '.$oid);
+ }
+ }
+
+ $this->addNotice('folder',$folder->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+ /**
+ * Formular anzeigen, um Rechte hinzufuegen
+ */
+ function aclformView()
+ {
+ $this->actionName = 'object';
+
+ $o = new Object( $this->getRequestId() );
+ $o->objectLoadRaw();
+
+ $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
+ $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
+
+ $this->setTemplateVar('users' ,User::listAll() );
+ $this->setTemplateVar('groups' ,Group::getAll() );
+
+ $languages = array(0=>lang('ALL_LANGUAGES'));
+ $languages += Language::getAll();
+ $this->setTemplateVar('languages',$languages );
+ $this->setTemplateVar('objectid' ,$o->objectid );
+ $this->setTemplateVar('action' ,$this->actionName);
+ }
+
+
+
+ /**
+ * Entfernen einer ACL
+ *
+ * @access protected
+ */
+ function delaclPost()
+ {
+ $acl = new Acl($this->getRequestVar('aclid'));
+ $acl->objectid = $this->getRequestId();
+
+ // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
+ // diesem Objekt die ACLs zu aendern.
+ $o = new Object( $this->getRequestId() );
+
+ if ( !$o->hasRight( ACL_GRANT ) )
+ Http::notAuthorized('no grant rights'); // Da wollte uns wohl einer vereimern.
+
+ $acl->delete(); // Weg mit der ACL
+
+ $this->addNotice('','','DELETED',OR_NOTICE_OK);
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/PageAction.class.php b/modules/cms-core/action/PageAction.class.php
@@ -0,0 +1,880 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Project;
+use cms\model\Value;
+use cms\model\Element;
+use cms\model\Template;
+use cms\model\Page;
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\Language;
+use cms\model\Model;
+use \Html;
+use Http;
+use Logger;
+use Session;
+
+
+/**
+ * Action-Klasse zum Bearbeiten einer Seite
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class PageAction extends ObjectAction
+{
+ public $security = SECURITY_USER;
+
+ var $page;
+ var $defaultSubAction = 'show';
+
+
+ function __construct()
+ {
+ $this->page = new Page( $this->getRequestId() );
+ $this->page->load();
+
+ // Hier kann leider nicht das Datum der letzten Änderung verwendet werden,
+ // da sich die Seite auch danach ändern kann, z.B. durch Includes anderer
+ // Seiten oder Änderung einer Vorlage oder Änderung des Dateinamens einer
+ // verlinkten Datei.
+ //$this->lastModified( time() );
+ }
+
+
+ /**
+ * Alle Daten aus dem Formular speichern
+ */
+ function formPost()
+ {
+ $this->page->public = true;
+ $this->page->simple = true;
+
+ foreach( $this->page->getElements() as $elementid=>$name )
+ {
+ if ( $this->hasRequestVar('saveid'.$elementid) )
+ {
+ $value = new Value();
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $value->objectid );
+ $value->element = new Element( $elementid );
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ // Eingegebenen Inhalt aus dem Request lesen
+ $inhalt = $this->getRequestVar( 'id'.$elementid );
+
+ // Den Inhalt speichern.
+ switch( $value->element->type )
+ {
+ case 'number':
+ $value->number = $inhalt * pow(10,$value->element->decimals);
+ break;
+
+ case 'date':
+ $value->date = strtotime( $inhalt );
+ break;
+
+ case 'text':
+ case 'longtext':
+ case 'select':
+ $value->text = $inhalt;
+ break;
+
+ case 'link':
+ case 'list':
+ case 'insert':
+ $value->linkToObjectId = intval($inhalt);
+ break;
+ }
+
+ $value->page = &$this->page;
+
+ // Ermitteln, ob Inhalt sofort freigegeben werden kann und soll
+ if ( $this->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') )
+ $value->publish = true;
+ else
+ $value->publish = false;
+
+// Html::debug($inhalt,'Eingabe');
+// Html::debug($value,'Inhalt');
+
+ // Inhalt speichern.
+ // Inhalt in allen Sprachen gleich?
+ if ( $value->element->allLanguages )
+ {
+ // Inhalt fuer jede Sprache einzeln speichern.
+ $p = new Project();
+ foreach( $p->getLanguageIds() as $languageid )
+ {
+ $value->languageid = $languageid;
+ $value->save();
+ }
+ }
+ else
+ {
+ // sonst nur 1x speichern (fuer die aktuelle Sprache)
+ $value->languageid = $this->getSessionVar(REQ_PARAM_LANGUAGE_ID);
+ $value->save();
+ }
+ }
+ }
+ $this->page->setTimestamp(); // "Letzte Aenderung" setzen
+
+ if ( $this->hasRequestVar('publish') )
+ $this->callSubAction( 'pubnow' );
+ else
+ $this->callSubAction( 'el' );
+ }
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ function editPost()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals);
+ $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
+ $value->text = $this->getRequestVar('text');
+
+ // Vorschau anzeigen
+ if ( $value->element->type=='longtext' && ($this->hasRequestVar('preview')||$this->hasRequestVar('addmarkup')) )
+ {
+ if ( $this->hasRequestVar('preview') )
+ {
+ $value->page = $this->page;
+ $value->simple = false;
+ $value->page->languageid = $value->languageid;
+ $value->page->load();
+ $value->generate();
+ $this->setTemplateVar('preview_text',$value->value );
+ }
+
+ if ( $this->hasRequestVar('addmarkup') )
+ {
+ $addText = $this->getRequestVar('addtext');
+
+ if ( !empty($addText) ) // Nur, wenn ein Text eingegeben wurde
+ {
+ $addText = $this->getRequestVar('addtext');
+
+ if ( $this->hasRequestVar('strong') )
+ $value->text .= '*'.$addText.'*';
+
+ if ( $this->hasRequestVar('emphatic') )
+ $value->text .= '_'.$addText.'_';
+
+ if ( $this->hasRequestVar('link') )
+ $value->text .= '"'.$addText.'"->"'.$this->getRequestVar('objectid').'"';
+ }
+
+ if ( $this->hasRequestVar('table') )
+ $value->text .= "|$addText | |\n|$addText | |\n|$addText | |\n";
+
+ if ( $this->hasRequestVar('list') )
+ $value->text .= "\n- ".$addText."\n".'- '.$addText."\n".'- '.$addText."\n";
+
+ if ( $this->hasRequestVar('numlist') )
+ $value->text .= "\n# ".$addText."\n".'# '.$addText."\n".'# '.$addText."\n";
+
+ if ( $this->hasRequestVar('image') )
+ $value->text .= '{'.$this->getRequestVar('objectid').'}';
+ }
+
+ // Ermitteln aller verlinkbaren Objekte (fuer Editor)
+ $objects = array();
+
+ foreach( Folder::getAllObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ if ( $o->getType() != 'folder' )
+ {
+ $f = new Folder( $o->parentid );
+ $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': ';
+ $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= FILE_SEP.$o->name;
+ }
+ }
+ asort($objects);
+ $this->setTemplateVar( 'objects' ,$objects );
+
+ $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) );
+ $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) );
+ $this->setTemplateVar( 'html' ,$value->element->html );
+ $this->setTemplateVar( 'wiki' ,$value->element->wiki );
+ $this->setTemplateVar( 'text' ,$value->text );
+ $this->setTemplateVar( 'name' ,$value->element->name );
+ $this->setTemplateVar( 'desc' ,$value->element->desc );
+ $this->setTemplateVar( 'objectid',$this->page->objectid );
+ return;
+ }
+
+ if ( $this->hasRequestVar('year') ) // Wird ein Datum gespeichert?
+ {
+ // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden
+ if ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') )
+ $value->date = strtotime($this->getRequestVar('ansidate') );
+ else
+ // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen
+ $value->date = mktime( $this->getRequestVar('hour' ),
+ $this->getRequestVar('minute'),
+ $this->getRequestVar('second'),
+ $this->getRequestVar('month' ),
+ $this->getRequestVar('day' ),
+ $this->getRequestVar('year' ) );
+ }
+ else $value->date = 0; // Datum nicht gesetzt.
+
+ $value->text = $this->getRequestVar('text');
+
+ $value->page = new Page( $value->objectid );
+ $value->page->load();
+
+ // Inhalt sofort freigegeben, wenn
+ // - Recht vorhanden
+ // - Freigabe gewuenscht
+ if ( $value->page->hasRight( ACL_RELEASE ) && $this->getRequestVar('release')!='' )
+ $value->publish = true;
+ else
+ $value->publish = false;
+
+ // Inhalt speichern
+
+ // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt
+ // fuer jede Sprache einzeln gespeichert.
+ if ( $value->element->allLanguages )
+ {
+ $project = Session::getProject();
+ foreach( $project->getLanguageIds() as $languageid )
+ {
+ $value->languageid = $languageid;
+ $value->save();
+ }
+ }
+ else
+ {
+ // sonst nur 1x speichern (fuer die aktuelle Sprache)
+ $value->save();
+ }
+
+ $this->page->setTimestamp(); // "Letzte Aenderung" setzen
+
+ // Falls ausgewaehlt die Seite sofort veroeffentlichen
+ if ( $this->hasRequestVar('publish') )
+ $this->callSubAction( 'pubnow' ); // Weiter zum veroeffentlichen
+ else
+ $this->callSubAction( 'el' ); // Element-Liste anzeigen
+ }
+
+
+
+ /**
+ * Eigenschaften der Seite speichern
+ */
+ function propPost()
+ {
+ if ( $this->getRequestVar('name')!='' )
+ {
+ $this->page->name = $this->getRequestVar('name' ,OR_FILTER_FULL );
+ $this->page->filename = $this->getRequestVar('filename' ,OR_FILTER_FILENAME);
+ $this->page->desc = $this->getRequestVar('description',OR_FILTER_FULL );
+
+ $this->page->save();
+ $this->addNotice($this->page->getType(),$this->page->name,'PROP_SAVED','ok');
+
+ if ( $this->hasRequestVar('creationTimestamp') && $this->currentUser->isAdmin )
+ $this->page->createDate = $this->getRequestVar('creationTimestamp',OR_FILTER_NUMBER);
+ $this->page->setCreationTimestamp();
+ }
+ else
+ {
+ $this->addValidationError('name');
+ }
+ }
+
+
+
+ /**
+ * Die Eigenschaften der Seite anzeigen
+ */
+ function propView()
+ {
+ $this->setTemplateVar('id',$this->page->objectid);
+
+ $this->page->public = true;
+ $this->page->load();
+ $this->page->full_filename();
+
+ if ( $this->page->filename == $this->page->objectid )
+ $this->page->filename = '';
+
+ $this->setTemplateVars( $this->page->getProperties() );
+
+ if ( $this->userIsAdmin() )
+ {
+ $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
+ }
+
+ $template = new Template( $this->page->templateid );
+ $template->load();
+ $this->setTemplateVar('template_name',$template->name);
+
+ // Alle Ordner ermitteln
+// $this->setTemplateVar('act_folderobjectid',$this->page->parentid);
+//
+// $folders = array();
+// $folder = new Folder( $this->page->parentid );
+
+// foreach( $folder->getOtherFolders() as $oid )
+// {
+// $f = new Folder( $oid );
+// $folders[$oid] = implode( FILE_SEP,$f->parentObjectNames(true,true) );
+// }
+// asort( $folders );
+// $this->setTemplateVar('folder',$folders);
+
+ $templates = Array();
+ foreach( Template::getAll() as $id=>$name )
+ {
+ if ( $id != $this->page->templateid )
+ $templates[$id]=$name;
+ }
+ $this->setTemplateVar('templates',$templates);
+ }
+
+
+
+ /**
+ * Die Eigenschaften der Seite anzeigen
+ */
+ function infoView()
+ {
+ $this->setTemplateVar('id',$this->page->objectid);
+
+ $this->page->public = true;
+ $this->page->load();
+ $this->page->full_filename();
+
+ if ( $this->page->filename == $this->page->objectid )
+ $this->page->filename = '';
+
+ $this->setTemplateVars( $this->page->getProperties() );
+
+ if ( $this->userIsAdmin() )
+ {
+ $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
+ }
+
+ $template = new Template( $this->page->templateid );
+ $template->load();
+ $this->setTemplateVar('template_name',$template->name);
+
+
+ }
+
+
+
+
+ /**
+ * Austauschen der Vorlage vorbereiten
+ *
+ * Es wird ein Formualr erzeugt, in dem der Benutzer auswaehlen kann, welche Elemente
+ * in welches Element uebernommen werden sollen
+ */
+ public function changetemplateselectelementsView()
+ {
+ $newTemplateId = $this->getRequestVar( 'newtemplateid' );
+
+ if ( $newTemplateId != 0 )
+ {
+ $this->setTemplateVar('newtemplateid',$newTemplateId );
+
+ $oldElements = array();
+ $oldTemplate = new Template( $this->page->templateid );
+ $newTemplate = new Template( $newTemplateId );
+
+ foreach( $oldTemplate->getElementIds() as $elementid )
+ {
+ $e = new Element( $elementid );
+ $e->load();
+
+ if ( !$e->isWritable() )
+ continue;
+
+ $oldElement = array();
+ $oldElement['name'] = $e->name.' - '.lang('EL_'.$e->type );
+ $oldElement['id' ] = $e->elementid;
+
+ $newElements = Array();
+ $newElements[0] = lang('ELEMENT_DELETE_VALUES');
+
+ foreach( $newTemplate->getElementIds() as $newelementid )
+ {
+ $ne = new Element( $newelementid );
+ $ne->load();
+
+ // Nur neue Elemente anbieten, deren Typ identisch ist
+ if ( $ne->type == $e->type )
+ $newElements[$newelementid] = lang('ELEMENT').': '.$ne->name.' - '.lang('EL_'.$e->type );
+ }
+ $oldElement['newElementsName'] = 'from'.$e->elementid;
+ $oldElement['newElementsList'] = $newElements;
+ $oldElements[$elementid] = $oldElement;
+ }
+ $this->setTemplateVar('elements',$oldElements );
+ }
+ else
+ {
+ $this->callSubAction('prop');
+ }
+ }
+
+
+
+ /**
+ * Die Vorlage der Seite austauschen
+ *
+ * Die Vorlage wird ausgetauscht, die Inhalte werden gemaess der Benutzereingaben kopiert
+ */
+ public function changetemplateselectelementsPost()
+ {
+ $newTemplateId = $this->getRequestVar('newtemplateid');
+ $replaceElementMap = Array();
+
+ $oldTemplate = new Template( $this->page->templateid );
+ foreach( $oldTemplate->getElementIds() as $elementid )
+ $replaceElementMap[$elementid] = $this->getRequestVar('from'.$elementid);
+
+ if ( $newTemplateId != 0 )
+ {
+ $this->page->replaceTemplate( $newTemplateId,$replaceElementMap );
+ $this->addNotice('page',$this->page->name,'SAVED',OR_NOTICE_OK);
+ }
+ else
+ $this->addNotice('page',$this->page->name,'NOT_SAVED',OR_NOTICE_WARN);
+ }
+
+
+
+
+ /**
+ * Alle Elemente der Seite anzeigen
+ */
+ function editView()
+ {
+ $this->page->public = true;
+ $this->page->simple = true;
+ $this->page->generate_elements();
+
+ $list = array();
+
+ // Schleife ueber alle Inhalte der Seite
+ foreach( $this->page->values as $id=>$value )
+ {
+ // Element wird nur angezeigt, wenn es editierbar ist
+ if ( $value->element->isWritable() )
+ {
+ $list[$id] = array();
+ $list[$id]['name'] = $value->element->name;
+ $list[$id]['pageelementid' ] = $this->page->objectid.'_'.$id;
+ $list[$id]['desc'] = $value->element->desc;
+ $list[$id]['type'] = $value->element->type;
+
+ $list[$id]['archive_count'] = intval($value->getCountVersions());
+ if ( $list[$id]['archive_count'] > 0 )
+ $list[$id]['archive_url'] = Html::url( 'pageelement','archive',$this->page->id,array('elementid'=>$id) );
+
+ // Inhalt anzeigen
+ $list[$id]['value'] = $value->value;
+ }
+ }
+
+ $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array('withIcons'=>'1') ) );
+ $this->setTemplateVar('properties',$this->page->getProperties() );
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Alle editierbaren Felder in einem Formular bereitstellen
+ */
+ function formView()
+ {
+ global $conf_php;
+
+ $this->page->public = false;
+ $this->page->simple = true;
+ $this->page->generate_elements();
+
+ $list = array();
+
+ foreach( $this->page->values as $id=>$value )
+ {
+ if ( $value->element->isWritable() )
+ {
+ $list[$id] = array();
+ $list[$id]['name'] = $value->element->name;
+ $list[$id]['desc'] = $value->element->desc;
+ $list[$id]['type'] = $value->element->type;
+ $list[$id]['id' ] = 'id'.$value->element->elementid;
+ $list[$id]['saveid'] = 'saveid'.$value->element->elementid;
+
+ switch( $value->element->type )
+ {
+ case 'text':
+ case 'longtext':
+ $list[$id]['value'] = $value->text;
+ break;
+
+ case 'date':
+ $list[$id]['value'] = date( 'Y-m-d H:i:s',$value->date );
+ break;
+
+ case 'number':
+ $list[$id]['value'] = $value->number / pow(10,$value->element->decimals);
+ break;
+
+ case 'select':
+ $list[$id]['list' ] = $value->element->getSelectItems();
+ $list[$id]['value'] = $value->text;
+ break;
+
+ case 'link':
+ $objects = array();
+
+ foreach( Folder::getAllObjectIds() as $oid )
+ {
+ $o = new Object( $oid );
+ $o->load();
+
+ if ( $o->getType() != 'folder' )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+
+ $objects[ $oid ] = lang( $o->getType() ).': ';
+ $objects[ $oid ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ $objects[ $oid ] .= ' » '.$o->name;
+ }
+ }
+
+ asort( $objects ); // Sortieren
+
+ $list[$id]['list' ] = $objects;
+ $list[$id]['value'] = $value->linkToObjectId;
+ break;
+
+ case 'list':
+ $objects = array();
+ foreach( Folder::getAllFolders() as $oid )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+
+ $objects[ $oid ] = lang( $f->getType() ).': ';
+ $objects[ $oid ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('list' ,$objects);
+ $this->setTemplateVar('value',$this->value->linkToObjectId);
+
+ break;
+ }
+ }
+ }
+
+ $this->setTemplateVar( 'release',$this->page->hasRight(ACL_RELEASE) );
+ $this->setTemplateVar( 'publish',$this->page->hasRight(ACL_PUBLISH) );
+
+ $this->setWindowMenu( 'elements' );
+ $this->setTemplateVar('el',$list);
+ }
+
+
+
+ /**
+ * Seite anzeigen
+ */
+ function previewView()
+ {
+ $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid ) );
+ }
+
+ /**
+ * Seite anzeigen
+ */
+ function showView()
+ {
+ // Seite definieren
+ if ( $this->hasRequestVar('withIcons') )
+ $this->page->icons = true;
+
+ $this->page->load();
+ $this->page->generate();
+ $this->page->write();
+
+ header('Content-Type: '.$this->page->mimeType().'; charset=UTF-8' );
+
+ // HTTP-Header mit Sprachinformation setzen.
+ $language = Session::getProjectLanguage();
+ header('Content-Language: '.$language->isoCode);
+
+ Logger::debug("preview page: ".$this->page->tmpfile() );
+
+ // Wenn
+ if ( ( config('publish','enable_php_in_page_content')=='auto' && $this->page->template->extension == 'php') ||
+ config('publish','enable_php_in_page_content')===true )
+ require( $this->page->tmpfile() );
+ else
+ readfile( $this->page->tmpfile() );
+
+ exit();
+ }
+
+
+
+ /**
+ * Den Quellcode der Seite anzeigen
+ *
+ * Alle HTML-Sonderzeichen werden maskiert
+ */
+ function src()
+ {
+ $language = Session::getProjectLanguage();
+ $model = Session::getProjectModel();
+
+ $this->page->languageid = $language->languageid;
+ $this->page->modelid = $model->modelid;
+
+ $this->page->withLanguage = config('publish','filename_language') == 'always' || count(Language::count()) > 1;
+ $this->page->withModel = config('publish','filename_type' ) == 'always' || count(Model::count() ) > 1;
+
+ $this->page->public = true;
+ $this->page->load();
+
+ $src = $this->page->generate();
+
+ // HTML Highlighting
+
+ //$src = preg_replace( '|<(.+)( .+)?'.'>|Us' , '<strong><$1</strong>$2<strong>></strong>', $src);
+ //$src = preg_replace( '|([a-zA-Z]+)="(.+)"|Us' , '<em>$1</em>=<var>"$2"</var>' , $src);
+ $src = htmlentities($src);
+
+ $this->setTemplateVar('src',$src);
+ }
+
+
+
+
+ /**
+ * Die Eigenschaften der Seite anzeigen
+ */
+ function changetemplateView()
+ {
+ $this->page->public = true;
+ $this->page->load();
+
+ $this->setTemplateVars( $this->page->getProperties() );
+
+ if ( $this->userIsAdmin() )
+ {
+ $this->setTemplateVar('template_url',Html::url('main','template',$this->page->templateid));
+ }
+
+ $template = new Template( $this->page->templateid );
+ $template->load();
+ $this->setTemplateVar('template_name',$template->name);
+
+ $templates = Array();
+ foreach( Template::getAll() as $id=>$name )
+ {
+ if ( $id != $this->page->templateid )
+ $templates[$id]=$name;
+ }
+ $this->setTemplateVar('templates',$templates);
+ }
+
+
+
+
+
+ /**
+ * Seite veroeffentlichen
+ *
+ * Es wird ein Formular angzeigt, mit dem die Seite veroeffentlicht
+ * werden kann
+ */
+ function pubView()
+ {
+ }
+
+
+
+ /**
+ * Seite veroeffentlichen
+ *
+ * Die Seite wird generiert.
+ */
+ function pubPost()
+ {
+ if ( !$this->page->hasRight( ACL_PUBLISH ) )
+ Http::notAuthorized( 'no right for publish' );
+
+ Session::close();
+
+ $this->page->public = true;
+ $this->page->publish();
+ $this->page->publish->close();
+
+// foreach( $this->page->publish->publishedObjects as $o )
+// {
+// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
+// }
+
+ $this->addNotice( 'page',
+ $this->page->fullFilename,
+ 'PUBLISHED'.($this->page->publish->ok?'':'_ERROR'),
+ $this->page->publish->ok,
+ array(),
+ $this->page->publish->log );
+ }
+
+
+ function setWindowMenu( $type ) {
+ switch( $type)
+ {
+ case 'elements':
+ $menu = array( array('subaction'=>'el' ,'text'=>'all'),
+ array('subaction'=>'form','text'=>'change' ) );
+ $this->setTemplateVar('windowMenu',$menu);
+ break;
+ case 'acl':
+ $menu = array( array('subaction'=>'rights' ,'text'=>'show'),
+ array('subaction'=>'aclform','text'=>'add' ) );
+ $this->setTemplateVar('windowMenu',$menu);
+ break;
+
+ }
+ }
+
+
+ /**
+ * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
+ *
+ * @see actionClasses/Action#checkMenu($name)
+ */
+ function checkMenu( $menu ) {
+
+ switch( $menu)
+ {
+ case 'changetemplate':
+ // Template nur austauschbar, wenn es mind. 2 gibt.
+ return (!readonly() && count(Template::getAll()) > 1);
+
+ case 'aclform':
+ return !readonly();
+
+ case 'form':
+ return !readonly();
+
+ default:
+ return true;
+
+ }
+ }
+
+
+ /**
+ * 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->page->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->page->objectid ] = array('id'=>$this->page->objectid,'name'=>$this->page->name,'type'=>'page','self'=>true,'children'=>&$elementChildren);
+
+ $template = new Template( $this->page->templateid );
+ $elements = $template->getElementNames();
+
+ foreach( $elements as $id=>$name )
+ {
+ $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/modules/cms-core/action/PageelementAction.class.php b/modules/cms-core/action/PageelementAction.class.php
@@ -0,0 +1,1540 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\User;
+use cms\model\Value;
+use cms\model\Element;
+use cms\model\Template;
+use cms\model\Page;
+use cms\model\Folder;
+use cms\model\Object;
+use Html;
+use Http;
+use Session;
+use Transformer;
+use \Text;
+
+// 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 zum Bearbeiten eines Seitenelementes
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class PageelementAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $defaultSubAction = 'edit';
+
+
+ /**
+ * Enthaelt das Seitenobjekt
+ * @type Object
+ */
+ var $page;
+
+ /**
+ * Enthaelt das Elementobjekt
+ * @type Object
+ */
+ var $element;
+
+
+ /**
+ * Enth�lt den Inhalt
+ *
+ * @var Object
+ */
+ var $value;
+
+
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->value = new Value();
+
+ $id = $this->getRequestVar('id');
+ $ids = explode('_',$id);
+ if ( count($ids) > 1 )
+ {
+ list( $pageid, $elementid ) = $ids;
+ }
+ else
+ {
+ $pageid = $this->getRequestId();
+ $elementid = $this->getRequestVar('elementid');
+ }
+
+ if ( $pageid != 0 )
+ {
+ $this->page = new Page( $pageid );
+ $this->page->load();
+ }
+
+ if ( $elementid != 0 )
+ {
+ $this->elementid = $elementid;
+ $this->element = new Element( $elementid );
+ }
+ }
+
+
+
+ /**
+ * Anzeigen des Element-Inhaltes.
+ */
+ public function propView()
+ {
+ Http::noContent();
+
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->page = $this->page;
+ $this->value->simple = false;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+ $this->value->load();
+
+ $this->setTemplateVar('name' ,$this->value->element->name );
+ $this->setTemplateVar('description' ,$this->value->element->desc );
+ $this->setTemplateVar('elementid' ,$this->value->element->elementid);
+ $this->setTemplateVar('element_type',$this->value->element->type );
+
+ $user = new User( $this->value->lastchangeUserId );
+ $user->load();
+ $this->setTemplateVar('lastchange_user',$user);
+ $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp);
+
+ $t = new Template( $this->page->templateid );
+ $t->load();
+ $this->setTemplateVar('template_name',$t->name );
+ $this->setTemplateVar('template_url' ,Html::url('template','prop',$t->templateid) );
+
+ $this->setTemplateVar('element_name' ,$this->value->element->name );
+ $this->setTemplateVar('element_url' ,Html::url('element','name',$this->value->element->elementid) );
+
+ }
+
+
+
+ /**
+ * Anzeigen des Element-Inhaltes.
+ */
+ public function infoView()
+ {
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->page = $this->page;
+ $this->value->simple = false;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+ $this->value->load();
+
+ $this->setTemplateVar('name' ,$this->value->element->name );
+ $this->setTemplateVar('description' ,$this->value->element->desc );
+ $this->setTemplateVar('elementid' ,$this->value->element->elementid);
+ $this->setTemplateVar('element_type',$this->value->element->type );
+
+ $user = new User( $this->value->lastchangeUserId );
+ $user->load();
+ $this->setTemplateVar('lastchange_user',$user->getProperties());
+ $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp);
+
+ $t = new Template( $this->page->templateid );
+ $t->load();
+ $this->setTemplateVar('template_name',$t->name );
+ $this->setTemplateVar('template_id' ,$t->templateid );
+
+ $this->setTemplateVar('element_name' ,$this->value->element->name );
+ $this->setTemplateVar('element_id' ,$this->value->element->elementid );
+
+ }
+
+
+
+ /**
+ * Anzeigen des Element-Inhaltes.
+ */
+ public function structureView()
+ {
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->page = $this->page;
+ $this->value->simple = false;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+ $this->value->load();
+
+ if ( $this->value->element->type == 'longtext' && $this->value->element->wiki )
+ {
+ $this->setTemplateVar('text',$this->value->text);
+ }
+
+ }
+
+
+
+ /**
+ * Normaler Editiermodus.
+ *
+ * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
+ */
+ public function editView()
+ {
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+
+ if ( intval($this->value->valueid)!=0 )
+ $this->value->loadWithId();
+ else
+ $this->value->load();
+
+ $this->setTemplateVar('name' ,$this->value->element->name );
+ $this->setTemplateVar('desc' ,$this->value->element->desc );
+ $this->setTemplateVar('elementid',$this->value->element->elementid);
+ $this->setTemplateVar('type' ,$this->value->element->type );
+ $this->setTemplateVar('value_time',time() );
+
+
+ $this->value->page = new Page( $this->page->objectid );
+ $this->value->page->languageid = $this->value->languageid;
+ $this->value->page->load();
+
+ $this->setTemplateVar( 'objectid',$this->value->page->objectid );
+
+ if ( $this->value->page->hasRight(ACL_RELEASE) )
+ $this->setTemplateVar( 'release',true );
+ if ( $this->value->page->hasRight(ACL_PUBLISH) )
+ $this->setTemplateVar( 'publish',false );
+
+ $funktionName = 'edit'.$this->value->element->type;
+
+ if ( ! method_exists($this,$funktionName) )
+ Http::serverError('Method does not exist: PageElementAction#'.$funktionName );
+
+ $this->$funktionName(); // Aufruf der Funktion "edit<Elementtyp>()".
+ }
+
+
+
+ /**
+ * Vorschau.
+ */
+ public function previewView()
+ {
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+ $this->value->public = true;
+ $this->value->simple = true;
+
+ if ( intval($this->value->valueid)!=0 )
+ $this->value->loadWithId();
+ else
+ $this->value->load();
+
+
+ $this->value->page = new Page( $this->page->objectid );
+ $this->value->page->languageid = $this->value->languageid;
+ $this->value->page->load();
+
+ $this->value->generate();
+ $this->setTemplateVar('preview' ,$this->value->value );
+ }
+
+
+
+ /**
+ * Datum bearbeiten.
+ *
+ */
+ private function editdate()
+ {
+ global $conf;
+ $date = $this->value->date;
+
+ // Wenn Datum nicht vorhanden...
+ if ( $date == 0 )
+ // ... dann aktuelles Datum (gerundet auf 1 Minute) verwenden
+ $date = intval(time()/60)*60;
+
+ $this->setTemplateVar('ansidate',date( 'Y-m-d H:i:s',$date ) );
+ $this->setTemplateVar('date' ,$date);
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+
+
+ // Wenn Datum nicht vorhanden, dann aktuelles Datum verwenden
+ if ( $this->hasRequestVar('year') )
+ {
+ $date = mktime( $this->getRequestVar('hour'),
+ $this->getRequestVar('minute'),
+ $this->getRequestVar('second'),
+ $this->getRequestVar('month'),
+ $this->getRequestVar('day'),
+ $this->getRequestVar('year') );
+ }
+ $year = intval(date('Y',$date));
+ $month = intval(date('n',$date));
+ $day = intval(date('j',$date));
+ $hour = intval(date('G',$date));
+ $minute = intval(date('i',$date));
+ $second = intval(date('s',$date));
+ $this->setTemplateVar('year' ,$year );
+ $this->setTemplateVar('month' ,$month );
+ $this->setTemplateVar('day' ,$day );
+ $this->setTemplateVar('hour' ,$hour );
+ $this->setTemplateVar('minute',$minute );
+ $this->setTemplateVar('second',$second );
+
+ $this->setTemplateVar('monthname',lang('DATE_MONTH'.date('n',$date)) );
+ $this->setTemplateVar('yearname' ,date('Y',$date) );
+
+
+ // Zwischenberechnungen
+ $heuteTag = intval(date('j'));
+ $monatLetzterTag = intval(date('t',$date));
+ $monatErsterDatum = $date-(($day-1)*86400);
+ $wocheNr = date( 'W',$monatErsterDatum );
+ $wochentagErster = date( 'w',$monatErsterDatum );
+
+
+ $weekdayOffset = intval($conf['editor']['calendar']['weekday_offset']);
+
+ // Alle Wochentage
+ $weekdays = array();
+ for ( $i=0; $i<=6; $i++ )
+ {
+ $wday = ($i+$weekdayOffset)%7;
+ $weekdays[$wday] = lang('DATE_WEEKDAY'.$wday);
+ }
+
+ $this->setTemplateVar('weekdays',$weekdays);
+
+
+ $monat = array();
+ $d = 0;
+ $begin = false;
+ do
+ {
+ $woche = array(); // Neue Woche
+
+ for ( $i=0; $i<=6; $i++ ) // Alle Wochentage der Woche
+ {
+ $wday = ($i+$weekdayOffset)%7;
+ $tag = array(); // Neuer Tag
+
+ if (!$begin && $wday == $wochentagErster)
+ $begin = true;
+
+ if ( $begin && $d < $monatLetzterTag )
+ {
+ $d++;
+ $tag['nr'] = $d;
+ $tag['today'] = ($year==date('Y') && $month==date('n') && $d==$heuteTag);
+ if ($d != $day)
+ $tag['url'] = Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>$year ,
+ 'month' =>$month ,
+ 'day' =>$d ,
+ 'hour' =>$hour ,
+ 'minute'=>$minute,
+ 'second'=>$second ) );
+ else
+ $tag['url'] = '';
+ }
+ else
+ {
+ $tag['nr' ]='';
+ $tag['today' ]=false;
+ $tag['url' ]='';
+ }
+ $woche[] = $tag;
+
+ }
+ $monat[$wocheNr] = $woche;
+ $wocheNr++;
+ }
+ while( $d < $monatLetzterTag-1 );
+ // Html::debug($monat);
+ $this->setTemplateVar('weeklist',$monat);
+
+ $this->setTemplateVar('actdate' ,date( lang('DATE_FORMAT'),$date ) );
+ $this->setTemplateVar('todayurl',Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>date('Y'),
+ 'month' =>date('n'),
+ 'day' =>date('j'),
+ 'hour' =>date('G'),
+ 'minute'=>date('i'),
+ 'second'=>date('s') ) ) );
+ $this->setTemplateVar('lastyearurl',Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>$year-1,
+ 'month' =>$month ,
+ 'day' =>$day ,
+ 'hour' =>$hour ,
+ 'minute'=>$minute,
+ 'second'=>$second ) ) );
+ $this->setTemplateVar('nextyearurl',Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>$year+1 ,
+ 'month' =>$month ,
+ 'day' =>$day ,
+ 'hour' =>$hour ,
+ 'minute'=>$minute,
+ 'second'=>$second ) ) );
+ $this->setTemplateVar('lastmonthurl',Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>$year ,
+ 'month' =>$month-1,
+ 'day' =>$day ,
+ 'hour' =>$hour ,
+ 'minute'=>$minute,
+ 'second'=>$second ) ) );
+ $this->setTemplateVar('nextmonthurl',Html::url( 'pageelement','edit','',
+ array('elementid'=>$this->element->elementid,'mode'=>'edit',
+ 'year' =>$year ,
+ 'month' =>$month+1,
+ 'day' =>$day ,
+ 'hour' =>$hour ,
+ 'minute'=>$minute,
+ 'second'=>$second ) ) );
+
+ // $this->setTemplateVar('date' ,$date);
+
+
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+
+
+ $all_years = array();
+ $all_months = array();
+ $all_days = array();
+ $all_hours = array();
+ $all_minutes = array();
+ for( $i=$year-100; $i<=$year+100;$i++ ) $all_years [$i] = $i;
+ for( $i=1; $i<=12; $i++ ) $all_months [$i] = lang('DATE_MONTH'.$i);
+ for( $i=1; $i<=31; $i++ ) $all_days [$i] = str_pad($i,2,'0',STR_PAD_LEFT);
+ for( $i=0; $i<=23; $i++ ) $all_hours [$i] = str_pad($i,2,'0',STR_PAD_LEFT);
+ for( $i=0; $i<=59; $i++ ) $all_minutes[$i] = str_pad($i,2,'0',STR_PAD_LEFT);
+
+ $this->setTemplateVar('all_years' ,$all_years );
+ $this->setTemplateVar('all_months' ,$all_months );
+ $this->setTemplateVar('all_days' ,$all_days );
+ $this->setTemplateVar('all_hours' ,$all_hours );
+ $this->setTemplateVar('all_minutes',$all_minutes);
+ $this->setTemplateVar('all_seconds',$all_minutes);
+ }
+
+
+
+ /**
+ * Verkn�pfung bearbeiten.
+ *
+ */
+ private function editlink()
+ {
+ $this->setTemplateVar('rootfolderid',Folder::getRootFolderId() );
+
+ // Ermitteln, welche Objekttypen verlinkt werden d�rfen.
+ $type = $this->value->element->subtype;
+
+ if ( substr($type,0,5) == 'image' )
+ $type = 'file';
+
+ if ( !in_array($type,array('file','page','link','folder')) )
+ $types = array('file','page','link'); // Fallback: Der Link kann auf Seiten,Dateien und Verknüpfungen zeigen
+ else
+ $types = array($type); // gewünschten Typ verwenden
+
+ $objects = array();
+
+ foreach( Folder::getAllObjectIds($types) as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ // if ( in_array( $o->getType(),$types ))
+ // {
+ $f = new Folder( $o->parentid );
+ // $f->load();
+
+ $objects[ $id ] = lang( $o->getType() ).': ';
+ $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= FILE_SEP.$o->name;
+ // }
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects' ,$objects);
+ $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
+
+ $this->setTemplateVar('types',implode(',',$types));
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else
+ $this->setTemplateVar('old_pageaction','show' );
+ }
+
+
+
+ function linkView()
+ {
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = $this->page->pageid;
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+ $this->value->publish = false;
+ $this->value->load();
+
+ $this->setTemplateVar('name' ,$this->value->element->name );
+ $this->setTemplateVar('desc' ,$this->value->element->desc );
+
+ $this->setTemplateVar('rootfolderid' ,Folder::getRootFolderId() );
+
+ // Ermitteln, welche Objekttypen verlinkt werden d�rfen.
+ if ( empty($this->value->element->subtype) )
+ $types = array('page','file','link'); // Fallback: Alle erlauben :)
+ else
+ $types = explode(',',$this->value->element->subtype );
+
+ $objects = array();
+
+ $objects[ 0 ] = lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt"
+
+
+ $t = new Template( $this->page->templateid );
+
+ foreach( $t->getDependentObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ // if ( in_array( $o->getType(),$types ))
+ // {
+ $f = new Folder( $o->parentid );
+ // $f->load();
+
+ $objects[ $id ] = lang( $o->getType() ).': ';
+ $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= FILE_SEP.$o->name;
+ // }
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects' ,$objects);
+ $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+
+ $this->value->page = new Page( $this->page->objectid );
+ $this->value->page->languageid = $this->value->languageid;
+ $this->value->page->load();
+
+ $this->setTemplateVar( 'release',$this->value->page->hasRight(ACL_RELEASE) );
+ $this->setTemplateVar( 'publish',$this->value->page->hasRight(ACL_PUBLISH) );
+
+ $this->setTemplateVar( 'objectid',$this->value->page->objectid );
+ }
+
+
+
+ /**
+ * Auswahlbox.
+ *
+ */
+ private function editselect()
+ {
+ $this->setTemplateVar( 'items',$this->value->element->getSelectItems() );
+ $this->setTemplateVar( 'text' ,$this->value->text );
+
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+ }
+
+
+
+ /**
+ * Einf�gen-Element.
+ *
+ */
+ private function editlist()
+ {
+ $this->editinsert();
+ }
+
+
+
+ /**
+ * Einf�gen-Element.
+ *
+ */
+ private function editinsert()
+ {
+ // Auswahl ueber alle Elementtypen
+ $objects = array();
+ //Änderung der möglichen Types
+ $types = array('file','page','link');
+ $objects[ 0 ] = lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt"
+ //Auch Dateien dazu
+ foreach( Folder::getAllObjectIds($types) as $id )
+ {
+ $f = new Folder( $id );
+ $f->load();
+
+ $objects[ $id ] = lang( $f->getType() ).': ';
+ $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ }
+
+ foreach( Folder::getAllFolders() as $id )
+ {
+ $f = new Folder( $id );
+ $f->load();
+
+ $objects[ $id ] = lang( $f->getType() ).': ';
+ $objects[ $id ] .= implode( ' » ',$f->parentObjectNames(false,true) );
+ }
+
+ asort( $objects ); // Sortieren
+
+ $this->setTemplateVar('objects' ,$objects);
+ $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId);
+
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+ }
+
+
+
+ /**
+ * Zahl bearbeiten.
+ *
+ */
+ private function editnumber()
+ {
+ $this->setTemplateVar('number',$this->value->number / pow(10,$this->value->element->decimals) );
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+ }
+
+
+ /**
+ * Ein Element der Seite bearbeiten
+ *
+ * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
+ */
+ private function editlongtext()
+ {
+ if ($this->value->element->wiki)
+ $this->setTemplateVar( 'editor','wiki' );
+ elseif ($this->value->element->html)
+ $this->setTemplateVar( 'editor','html' );
+ else
+ $this->setTemplateVar( 'editor','text' );
+
+ if ( !isset($this->templateVars['text']))
+ // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits
+ // einen Text eingegeben hat (Vorschaufunktion).
+ $this->setTemplateVar( 'text',$this->linkifyOIDs( $this->value->text ) );
+
+ /*
+ *
+ if (! $this->isEditMode() )
+ {
+ $this->value->generate(); // Inhalt erzeugen.
+ $this->setTemplateVar('text',$this->linkifyOIDs( $this->value->value ));
+ }
+ */
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+
+
+
+ if ( $this->element->wiki )
+ {
+ $project = Session::getProject();
+ $languages = $project->getLanguages();
+
+ if ( count($languages) > 1 )
+ {
+ $languages[$this->value->languageid] = $languages[$this->value->languageid].' *';
+ $this->setTemplateVar('languages',$languages);
+ }
+
+ if ( $this->hasRequestVar('otherlanguageid') )
+ {
+ $lid = $this->getRequestVar('otherlanguageid');
+ $otherValue = new Value();
+ $otherValue->languageid = $lid;
+ $otherValue->pageid = $this->value->pageid;
+ $otherValue->element = $this->value->element;
+ $otherValue->elementid = $this->value->elementid;
+ $otherValue->publish = $this->value->publish;
+ $otherValue->load();
+ $this->setTemplateVar('languagetext' ,wordwrap($otherValue->text,100) );
+ $this->setTemplateVar('languagename' ,$languages[$lid] );
+ $this->setTemplateVar('otherlanguageid',$lid );
+ }
+
+ if ( !isset($this->templateVars['text']))
+ // Möglicherweise ist die Ausgabevariable bereits gesetzt, wenn man bereits
+ // einen Text eingegeben hat (Vorschaufunktion).
+ $this->setTemplateVar( 'text',$this->value->text );
+ }
+
+ }
+
+
+
+ /**
+ * Ein Element der Seite bearbeiten
+ *
+ * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann.
+ */
+ private function edittext()
+ {
+ $this->setTemplateVar( 'text',$this->value->text );
+
+ if ( $this->getSessionVar('pageaction') != '' )
+ $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction'));
+ else $this->setTemplateVar('old_pageaction','show' );
+ }
+
+
+
+ /**
+ * Wiederherstellung eines alten Inhaltes.
+ */
+ public function usePost()
+ {
+ $this->value->valueid = $this->getRequestVar('valueid');
+ $this->value->loadWithId();
+ $this->value->element = new Element( $this->value->elementid );
+
+ if ( $this->value->pageid != $this->page->pageid )
+ Http::serverError( 'Cannot find value','page-id does not match' );
+
+ // Pruefen, ob Berechtigung zum Freigeben besteht
+ //$this->value->release = $this->page->hasRight(ACL_RELEASE);
+ $this->value->release = false;
+
+ // Inhalt wieder herstellen, in dem er neu gespeichert wird.
+ $this->value->save();
+
+ $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_USE_FROM_ARCHIVE',OR_NOTICE_OK);
+ }
+
+
+
+ /**
+ * Freigeben eines Inhaltes
+ */
+ public function releasePost()
+ {
+ $this->value->valueid = intval($this->getRequestVar('valueid'));
+ $this->value->loadWithId();
+
+ if ( $this->value->pageid != $this->page->pageid )
+ die( 'cannot release, bad page' );
+
+ // Pruefen, ob Berechtigung zum Freigeben besteht
+ if ( !$this->page->hasRight(ACL_RELEASE) )
+ Http::notAuthorized( 'Cannot release','no right' );
+
+ // Inhalt freigeben
+ $this->value->release();
+
+ $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_RELEASED',OR_NOTICE_OK);
+ }
+
+
+ /**
+ * Erzeugt eine Liste aller Versionsst?nde zu diesem Inhalt
+ */
+ public function historyView()
+ {
+ $this->page->public = true;
+ $this->page->simple = true;
+ $this->page->load();
+ $this->value->page = &$this->page;
+
+ $this->value->simple = true;
+ $language = Session::getProjectLanguage();
+ $this->value->languageid = $language->languageid;
+ $this->value->objectid = $this->page->objectid;
+ $this->value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+ $this->value->element = &$this->element;
+ $this->value->element->load();
+
+ $list = array();
+ // $version_list = array();
+ $lfd_nr = 0;
+
+ foreach( $this->value->getVersionList() as $value )
+ {
+ $lfd_nr++;
+ $value->element = &$this->element;
+ $value->page = &$this->page;
+ $value->simple = true;
+ $value->generate();
+
+
+ // $date = date( lang('DATE_FORMAT'),$value->lastchangeTimeStamp);
+
+ // if ( in_array( $this->element->type,array('text','longtext') ) )
+ // $version_list[ $value->valueid ] = '('.$lfd_nr.') '.$date;
+
+ $zeile = array( 'value' => Text::maxLaenge( 50,$value->value),
+ 'objectid' => $this->page->objectid,
+ 'date' => $value->lastchangeTimeStamp,
+ 'lfd_nr' => $lfd_nr,
+ 'id' => $value->valueid,
+ 'valueid' => $value->valueid,
+ 'user' => $value->lastchangeUserName );
+
+ // Nicht aktive Inhalte k�nnen direkt bearbeitet werden und sind
+ // nach dem Speichern dann wieder aktiv (nat�rlich als n�chster/neuer Inhalt)
+ if ( ! $value->active )
+ $zeile['useUrl'] = Html::url('pageelement','usevalue',$this->page->objectid,array('valueid' =>$value->valueid,'mode'=>'edit'));
+
+ // Freigeben des Inhaltes.
+ // Nur das aktive Inhaltselement kann freigegeben werden. Nat�rlich auch nur,
+ // wenn es nicht schon freigegeben ist.
+ if ( ! $value->publish && $value->active )
+ $zeile['releaseUrl'] = Html::url('pageelement','release',$this->page->objectid,array('valueid' =>$value->valueid ));
+
+ $zeile['public'] = $value->publish;
+ $zeile['active'] = $value->active;
+
+ $list[$lfd_nr] = $zeile;
+
+ }
+
+ if ( in_array( $this->value->element->type, array('longtext') ) && $lfd_nr >= 2 )
+ {
+ $this->setTemplateVar('compareid',$list[$lfd_nr-1]['id']);
+ $this->setTemplateVar('withid' ,$list[$lfd_nr ]['id']);
+ }
+
+ $this->setTemplateVar('name' ,$this->element->name);
+ $this->setTemplateVar('el' ,$list );
+ }
+
+
+ /**
+ * Vergleicht 2 Versionen eines Inhaltes
+ */
+ function diffView()
+ {
+ $value1id = $this->getRequestVar('compareid');
+ $value2id = $this->getRequestVar('withid' );
+
+ // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen
+ if ( $value1id == $value2id )
+ {
+ $this->addValidationError('compareid' );
+ $this->addValidationError('withid' ,'');
+ $this->callSubAction('archive');
+ return;
+ }
+
+ // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen
+ if ( $value1id > $value2id )
+ list($value1id,$value2id) = array( $value2id,$value1id );
+
+
+ $value1 = new Value( $value1id );
+ $value2 = new Value( $value2id );
+ $value1->valueid = $value1id;
+ $value2->valueid = $value2id;
+
+ $value1->loadWithId();
+ $value2->loadWithId();
+
+ $this->setTemplateVar('date_left' ,$value1->lastchangeTimeStamp);
+ $this->setTemplateVar('date_right',$value2->lastchangeTimeStamp);
+
+ $text1 = explode("\n",$value1->text);
+ $text2 = explode("\n",$value2->text);
+
+ // Unterschiede feststellen.
+ $res_diff = Text::diff($text1,$text2);
+
+ list( $text1,$text2 ) = $res_diff;
+
+ $diff = array();
+ $i = 0;
+ while( isset($text1[$i]) || isset($text2[$i]) )
+ {
+ $line = array();
+
+ if ( isset($text1[$i]['text']) )
+ $line['left'] = $text1[$i];
+
+ if ( isset($text2[$i]['text']) )
+ $line['right'] = $text2[$i];
+
+ $i++;
+ $diff[] = $line;
+ }
+ $this->setTemplateVar('diff',$diff );
+ }
+
+
+
+ /**
+ * Ein Element der Seite speichern.
+ */
+ public function editPost()
+ {
+ $this->element->load();
+ $type = $this->element->type;
+
+ if ( empty($type))
+ die('Error: No element type available.');
+
+ $funktionName = 'save'.$type;
+
+ $this->$funktionName(); // Aufruf Methode "save<ElementTyp>()"
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savetext()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ if ( $this->hasRequestVar('linkobjectid') )
+ $value->linkToObjectId = $this->getRequestVar('linkobjectid');
+ else
+ $value->text = $this->getRequestVar('text','raw');
+
+ $this->afterSave($value);
+ }
+
+
+
+ /**
+ * Nach dem Speichern weitere Dinge ausfuehren.<br>
+ * - Inhalt freigeben<br>
+ * - Seite veroeffentlichen<br>
+ * - Inhalt fuer andere Sprachen speichern<br>
+ * - Hinweis ueber erfolgtes Speichern ausgeben<br>
+ * <br>
+ * Nicht zu verwechseln mit <i>Aftershave</i> :)
+ */
+ private function afterSave( $value )
+ {
+ $value->page = new Page( $value->objectid );
+ $value->page->load();
+
+
+ // Inhalt sofort freigegeben, wenn
+ // - Recht vorhanden
+ // - Freigabe gewuenscht
+ if ( $value->page->hasRight( ACL_RELEASE ) && $this->hasRequestVar('release') )
+ $value->publish = true;
+ else
+ $value->publish = false;
+
+ // Up-To-Date-Check
+ $lastChangeTime = $value->getLastChangeTime();
+ if ( $lastChangeTime > $this->getRequestVar('value_time') )
+ {
+ $this->addNotice('pageelement',$value->element->name,'CONCURRENT_VALUE_CHANGE',OR_NOTICE_WARN,array('last_change_time'=>date(lang('DATE_FORMAT'),$lastChangeTime)));
+ }
+
+ // Inhalt speichern
+
+ // Wenn Inhalt in allen Sprachen gleich ist, dann wird der Inhalt
+ // fuer jede Sprache einzeln gespeichert.
+ if ( $value->element->allLanguages )
+ {
+ $project = Session::getProject();
+ foreach( $project->getLanguageIds() as $languageid )
+ {
+ $value->languageid = $languageid;
+ $value->save();
+ }
+ }
+ else
+ {
+ // sonst nur 1x speichern (fuer die aktuelle Sprache)
+ $value->save();
+ }
+
+ $this->addNotice('pageelement',$value->element->name,'SAVED',OR_NOTICE_OK);
+ $this->page->setTimestamp(); // "Letzte Aenderung" setzen
+
+ // Falls ausgewaehlt die Seite sofort veroeffentlichen
+ if ( $value->page->hasRight( ACL_PUBLISH ) && $this->hasRequestVar('publish') )
+ {
+ $this->page->publish();
+ $this->addNotice('pageelement',$value->element->name,'PUBLISHED',OR_NOTICE_OK);
+ }
+ }
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savelongtext()
+ {
+ global $conf;
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+
+ if ( $this->hasRequestVar('linkobjectid') )
+ $value->linkToObjectId = $this->getRequestVar('linkobjectid');
+ else
+ $value->text = $this->compactOIDs( $this->getRequestVar('text','raw') );
+
+ // Vorschau anzeigen
+ if ( $this->hasRequestVar('preview' ) ||
+ $this->hasRequestVar('addmarkup') )
+ {
+ $inputText = $this->getRequestVar('text','raw');
+
+ if ( $this->hasRequestVar('preview') )
+ {
+ $value->page = $this->page;
+ $value->simple = false;
+ $value->page->languageid = $value->languageid;
+ $value->page->load();
+ $value->generate();
+ $this->setTemplateVar('preview',$value->value );
+ }
+
+ if ( $this->hasRequestVar('addmarkup') )
+ {
+ $conf_tags = $conf['editor']['text-markup'];
+
+ if ( $this->hasRequestVar('addtext') ) // Nur, wenn ein Text eingegeben wurde
+ {
+ $addText = $this->getRequestVar('addtext','raw');
+
+ if ( $this->hasRequestVar('strong') )
+ $inputText .= $conf_tags['strong-begin'].$addText.$conf_tags['strong-end'];
+
+ if ( $this->hasRequestVar('emphatic') )
+ $inputText .= $conf_tags['emphatic-begin'].$addText.$conf_tags['emphatic-end'];
+
+ if ( $this->hasRequestVar('link') )
+ $inputText .= '"'.$addText.'"'.$conf_tags['linkto'].'"'.$this->parseOID($this->getRequestVar('objectid')).'"';
+ }
+
+ if ( $this->hasRequestVar('table') )
+ $inputText .= "\n".
+ $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n".
+ $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n".
+ $conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep'].' '.$addText.' '.$conf_tags['table-cell-sep']."\n";
+
+ if ( $this->hasRequestVar('list') )
+ $inputText .= "\n".
+ $conf_tags['list-unnumbered'].' '.$addText."\n".
+ $conf_tags['list-unnumbered'].' '.$addText."\n".
+ $conf_tags['list-unnumbered'].' '.$addText."\n";
+
+ if ( $this->hasRequestVar('numlist') )
+ $inputText .= "\n".
+ $conf_tags['list-numbered'].' '.$addText."\n".
+ $conf_tags['list-numbered'].' '.$addText."\n".
+ $conf_tags['list-numbered'].' '.$addText."\n";
+
+ if ( $this->hasRequestVar('image') )
+ $inputText .= $conf_tags['image-begin'].$this->parseOID($this->getRequestVar('objectid')).$conf_tags['image-end'];
+ }
+
+ // Ermitteln aller verlinkbaren Objekte (fuer Editor)
+ /*
+ $objects = array();
+
+ foreach( Folder::getAllObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->load();
+
+ if ( $o->getType() != 'folder' )
+ {
+ $f = new Folder( $o->parentid );
+ $objects[ $id ] = lang( 'GLOBAL_'.$o->getType() ).': ';
+ $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) );
+ $objects[ $id ] .= FILE_SEP.$o->name;
+ }
+ }
+ asort($objects);
+ $this->setTemplateVar( 'objects' ,$objects );
+ */
+
+ $this->setTemplateVar( 'release' ,$this->page->hasRight(ACL_RELEASE) );
+ $this->setTemplateVar( 'publish' ,$this->page->hasRight(ACL_PUBLISH) );
+ $this->setTemplateVar( 'html' ,$value->element->html );
+ $this->setTemplateVar( 'wiki' ,$value->element->wiki );
+ $this->setTemplateVar( 'text' ,$inputText );
+ $this->setTemplateVar( 'name' ,$value->element->name );
+ $this->setTemplateVar( 'desc' ,$value->element->desc );
+ $this->setTemplateVar( 'objectid',$this->page->objectid );
+
+ $this->setTemplateVar( 'mode' ,'edit' );
+ }
+ else
+ {
+ $this->afterSave($value);
+ }
+
+ }
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savedate()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ if ( $this->hasRequestVar('linkobjectid') )
+ $value->linkToObjectId = $this->getRequestVar('linkobjectid');
+ elseif ( $this->hasRequestVar('date') )
+ // Wenn ein Timestamp übergeben wurde, dann dieses verwenden
+ $value->date = $this->getRequestVar('date');
+ elseif ( $this->getRequestVar('ansidate') != $this->getRequestVar('ansidate_orig') )
+ // Wenn ein ANSI-Datum eingegeben wurde, dann dieses verwenden
+ $value->date = strtotime($this->getRequestVar('ansidate') );
+ else
+ // Sonst die Zeitwerte einzeln zu einem Datum zusammensetzen
+ $value->date = mktime( $this->getRequestVar('hour' ),
+ $this->getRequestVar('minute'),
+ $this->getRequestVar('second'),
+ $this->getRequestVar('month' ),
+ $this->getRequestVar('day' ),
+ $this->getRequestVar('year' ) );
+
+ $this->afterSave($value);
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function saveselect()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ $value->text = $this->getRequestVar('text');
+
+ $this->afterSave($value);
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savelink()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ if ( $this->hasRequestVar('linkurl') )
+ $value->linkToObjectId = $this->parseOID($this->getRequestVar('linkurl'));
+ else
+ $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
+
+ $this->afterSave($value);
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savelist()
+ {
+ $this->saveinsert();
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function saveinsert()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ $value->linkToObjectId = intval($this->getRequestVar('linkobjectid'));
+
+ $this->afterSave($value);
+ }
+
+
+
+ /**
+ * Element speichern
+ *
+ * Der Inhalt eines Elementes wird abgespeichert
+ */
+ private function savenumber()
+ {
+ $value = new Value();
+ $language = Session::getProjectLanguage();
+ $value->languageid = $language->languageid;
+ $value->objectid = $this->page->objectid;
+ $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid );
+
+ if ( $this->hasRequestVar('elementid') )
+ $value->element = new Element( $this->getRequestVar('elementid') );
+ else
+ $value->element = Session::getElement();
+
+ $value->element->load();
+ $value->publish = false;
+ $value->load();
+
+ if ( $this->hasRequestVar('linkobjectid') )
+ $value->linkToObjectId = $this->getRequestVar('linkobjectid');
+ else
+ $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals);
+
+ $this->afterSave($value);
+ }
+
+
+ function exportlongtext()
+ {
+ $types = array();
+
+ foreach( array('odf','plaintext') as $type )
+ {
+ $types[$type] = lang('FILETYPE_'.$type);
+ }
+
+ $this->setTemplateVar('types',$types);
+ }
+
+
+ function importlongtext()
+ {
+ $types = array();
+
+ foreach( array('odf','plaintext') as $type )
+ {
+ $types[$type] = lang('FILETYPE_'.$type);
+ }
+ $this->setTemplateVar('types',$types);
+ }
+
+
+ function doexportlongtext()
+ {
+ $type = $this->getRequestVar('type');
+ switch($type)
+ {
+ case 'odf':
+
+ // Angabe Content-Type
+ // header('Content-Type: '.$this->file->mimeType());
+ // header('X-File-Id: '.$this->file->fileid);
+
+ // header('Content-Disposition: inline; filename='.$this->id.'.odt');
+ header('Content-Transfer-Encoding: binary');
+ // header('Content-Description: '.$this->file->name);
+
+ echo $this->createOdfDocument();
+
+ exit;
+
+ default:
+ }
+
+ exit;
+ }
+
+
+ /**
+ * ODF erzeugen.<br>
+ * vorerst ZURUECKGESTELLT!
+ *
+ * @return unknown
+ */
+ private function createOdfDocument()
+ {
+ // TODO: ODF ist nicht ganz ohne.
+ $transformer = new Transformer();
+ $transformer->text = $this->value->text;
+ $transformer->type = 'odf';
+ $transformer->transform();
+ return $transformer->text;
+ }
+
+
+
+ /**
+ * Men�eintr�ge aktivieren/deaktivieren.
+ *
+ * @param String $name
+ * @return boolean
+ */
+ function checkMenu( $name )
+ {
+ $type = $this->element->type;
+
+ switch( $name )
+ {
+ case 'edit':
+ case 'prop':
+ return true;
+
+ case 'archive':
+ // Archiv ist nur verf�gbar, wenn es mind. 1 Version des Inhaltes gibt.
+
+ if ( $this->subActionName!='diff' && is_object($this->value) )
+ return $this->value->getCountVersions() > 0;
+ else
+ return true;
+
+ case 'link':
+ // Verkn�pfung zu anderen Seiten ist nur m�glich f�r
+ // Datum, Text, Textabsatz, Ganzzahl.
+ return in_array($type,array('date','text','longtext','number'));
+
+ default:
+ return false;
+ }
+ }
+
+
+ function linkifyOIDs( $text )
+ {
+ foreach( Text::parseOID($text) as $oid=>$t )
+ {
+ $url = $this->page->path_to_object($oid);
+ $text = str_replace($t,'"'.$url.'"',$text);
+ }
+
+ return $text;
+ }
+
+
+ function compactOIDs( $text )
+ {
+ foreach( Text::parseOID($text) as $oid=>$t )
+ {
+ $text = str_replace($t,'"?__OID__'.$oid.'__"',$text);
+ }
+
+ return $text;
+ }
+
+
+ function parseOID( $text )
+ {
+ $treffer = array();
+ preg_match_all('/(.*)__OID__([0-9]+)__(.*)/', $text, $treffer,PREG_SET_ORDER);
+
+ $oid = $treffer[0][2];
+
+ if ( !empty($oid) )
+ return $oid;
+ else
+ return intval($text);
+ }
+
+ /**
+ * Seite veroeffentlichen
+ *
+ * Es wird ein Formular angzeigt, mit dem die Seite veroeffentlicht
+ * werden kann
+ */
+ public function pubView()
+ {
+ }
+
+
+
+ /**
+ * Seite veroeffentlichen
+ *
+ * Die Seite wird generiert.
+ */
+ function pubPost()
+ {
+ if ( !$this->page->hasRight( ACL_PUBLISH ) )
+ Http::notAuthorized( 'no right for publish' );
+
+ $this->page->public = true;
+ $this->page->publish();
+ $this->page->publish->close();
+
+// foreach( $this->page->publish->publishedObjects as $o )
+// {
+// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
+// }
+
+ $this->addNotice( 'page',
+ $this->page->fullFilename,
+ 'PUBLISHED'.($this->page->publish->ok?'':'_ERROR'),
+ $this->page->publish->ok,
+ array(),
+ $this->page->publish->log );
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/ProfileAction.class.php b/modules/cms-core/action/ProfileAction.class.php
@@ -0,0 +1,313 @@
+<?php
+
+namespace cms\action;
+
+
+// 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.
+use LogicException;
+use Mail;
+use security\Base2n;
+use \Session;
+
+
+/**
+ * Action-Klasse zum Bearbeiten des Benutzerprofiles
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class ProfileAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ private $user;
+ var $defaultSubAction = 'edit';
+
+ /**
+ * Konstruktor.
+ * Setzen der Benutzer-Objektes.
+ */
+ function __construct()
+ {
+ $this->user = Session::getUser();
+ }
+
+
+ /**
+ * Abspeichern des Profiles
+ */
+ function editPost()
+ {
+ $this->user->fullname = $this->getRequestVar('fullname');
+ $this->user->tel = $this->getRequestVar('tel' );
+ $this->user->desc = $this->getRequestVar('desc' );
+ $this->user->style = $this->getRequestVar('style' );
+ $this->user->language = $this->getRequestVar('language');
+ $this->user->timezone = $this->getRequestVar('timezone');
+ $this->user->hotp = $this->hasRequestVar('hotp' );
+ $this->user->totp = $this->hasRequestVar('totp' );
+
+
+ $this->setStyle( $this->user->style ); // Style sofort anwenden
+ Session::setUser( $this->user );
+
+ if ( !empty($this->user->fullname) )
+ {
+ $this->user->save();
+ $this->setStyle($this->user->style);
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+ }
+ else
+ {
+ $this->addValidationError('fullname');
+ }
+
+
+ // Ausgewählte Sprache sofort verwenden.
+ $l = $this->getRequestVar('language');
+
+ $this->setLanguage($l);
+ }
+
+
+
+ /**
+ * Anzeigen einer Maske zum Ändern des Kennwortes.
+ */
+ function pwView()
+ {
+ // Kennwortänderung funktioniert natürlich nur in der internen Datenbank.
+ //
+ // Hier wird festgestellt, ob der Benutzer sich über die interne Datenbank angemeldet hat.
+ // Nur dann kann man auch sein Kennwort ändern.
+ $user = $this->getUserFromSession();
+ $pwchangePossible = in_array( strtolower($user->loginModuleName), array('cookieauth','internal'));
+ $this->setTemplateVar('pwchange_enabled', $pwchangePossible);
+ }
+
+
+
+ /**
+ * Anzeige einer Maske zum Ändern der E-Mail-Adresse
+ */
+ function mailView()
+ {
+ }
+
+
+
+ /*
+ * Es wird eine E-Mail mit einem Freischaltcode an die eingegebene Adresse geschickt.
+ */
+ function mailPost()
+ {
+ srand ((double)microtime()*1000003);
+ $code = rand(); // Zufalls-Freischaltcode erzeugen
+ $newMail = $this->getRequestVar('mail');
+
+ if ( empty($newMail) )
+ {
+ // Keine E-Mail-Adresse eingegeben.
+ $this->addValidationError('mail');
+ return;
+ }
+ else
+ {
+ // Der Freischaltcode wird in der Sitzung gespeichert.
+ Session::set('mailChangeCode',$code );
+ Session::set('mailChangeMail',$newMail);
+
+ // E-Mail an die neue Adresse senden.
+ $mail = new Mail( $newMail,'mail_change_code' );
+ $mail->setVar('code',$code );
+ $mail->setVar('name',$this->user->getName());
+
+ if ( $mail->send() )
+ {
+ $this->addNotice('user',$this->user->name,'mail_sent',OR_NOTICE_OK); // Meldung
+ $this->nextView('confirmmail');
+ }
+ else
+ {
+ $this->addNotice('user',$this->user->name,'mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); // Meldung
+ return;
+ }
+ }
+ }
+
+
+
+ /**
+ * Anzeige einer Maske, in die der Freischaltcode für das
+ * Ändern der E-Mail-Adresse eingetragen werden muss.
+ */
+ function confirmmailView()
+ {
+ }
+
+
+
+ /**
+ * Abspeichern der neuen E-Mail-Adresse
+ */
+ function confirmmailPost()
+ {
+ $sessionCode = Session::get('mailChangeCode');
+ $newMail = Session::get('mailChangeMail');
+ $inputRegisterCode = $this->getRequestVar('code');
+
+ if ( $sessionCode == $inputRegisterCode )
+ {
+ // Best�tigungscode stimmt �berein.
+ // E-Mail-Adresse �ndern.
+ $this->user->mail = $newMail;
+ $this->user->save();
+
+ $this->addNotice('user',$this->user->name,'SAVED',OR_NOTICE_OK);
+ }
+ else
+ {
+ // Best�tigungscode stimmt nicht.
+ $this->addValidationError('code','code_not_match');
+ }
+
+ }
+
+
+
+ public function pwPost()
+ {
+ if ( ! $this->user->checkPassword( $this->getRequestVar('act_password') ) )
+ {
+ $this->addValidationError('act_password');
+ }
+ elseif ( $this->getRequestVar('password1') == '' )
+ {
+ $this->addValidationError('password1');
+ }
+ elseif ( $this->getRequestVar('password1') != $this->getRequestVar('password2') )
+ {
+ $this->addValidationError('password2','PASSWORDS_DO_NOT_MATCH');
+ }
+ elseif ( strlen($this->getRequestVar('password1'))<intval(config('security','password','min_length')) )
+ {
+ $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>config('security','password','min_length')));
+ }
+ else
+ {
+ $this->user->setPassword( $this->getRequestVar('password1') );
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+ }
+ }
+
+
+
+ /**
+ * Anzeige aller Benutzer-Eigenschaften.
+ */
+ function editView()
+ {
+ $issuer = urlencode(config('application','operator'));
+ $account = $this->user->name.'@'.$_SERVER['SERVER_NAME'];
+
+ $base32 = new Base2n(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', FALSE, TRUE, TRUE);
+ $secret = $base32->encode(hex2bin($this->user->otpSecret));
+ $counter = $this->user->hotpCount;
+
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
+
+ $this->setTemplateVar('timezone_list',timezone_identifiers_list() );
+
+ $languages = explode(',',config('i18n','available'));
+ foreach($languages as $id=>$name)
+ {
+ unset($languages[$id]);
+ $languages[$name] = $name;
+ }
+ $this->setTemplateVar('language_list',$languages);
+
+ $this->setTemplateVars(
+ $this->user->getProperties() +
+ array('totpSecretUrl' => "otpauth://totp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}",
+ 'hotpSecretUrl' => "otpauth://hotp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}&counter={$counter}"
+ )
+ );
+
+
+ }
+
+
+
+ /**
+ * Anzeige aller Gruppen des angemeldeten Benutzers.
+ *
+ */
+ function membershipsView()
+ {
+ $this->setTemplateVar( 'groups',$this->user->getGroups() );
+ }
+
+
+
+ /**
+ * @param String $name Menüpunkt
+ * @return boolean true, falls Menüpunkt zugelassen
+ */
+ function checkMenu( $name )
+ {
+ global $conf;
+
+ switch( $name )
+ {
+ case 'pwchange':
+ // Die Funktion "Kennwort setzen" ist nur aktiv, wenn als Authentifizierungs-Backend
+ // auch die interne Benutzerdatenbank eingesetzt wird.
+ return @$conf['security']['auth']['type'] == 'database'
+ && !@$conf['security']['auth']['userdn'];
+
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * Setzt eine Sprache für den Benutzer.
+ *
+ * @param $l string Sprache
+ */
+ public function setLanguage($l)
+ {
+ global $conf;
+ $langFile = OR_LANGUAGE_DIR . 'lang-' . $l . '.' . PHP_EXT;
+
+ // Pruefen, ob Sprache vorhanden ist.
+ if (!file_exists($langFile))
+ throw new LogicException("Languagefile $langFile does not exist.");
+
+ $lang = array();
+ require($langFile); // Setzt $lang
+ global $conf;
+ $conf['language'] = $lang;
+ $conf['language']['language_code'] = $l;
+ Session::setConfig($conf);
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/ProjectAction.class.php b/modules/cms-core/action/ProjectAction.class.php
@@ -0,0 +1,351 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Project;
+use cms\model\Folder;
+
+// 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 zum Bearbeiten eines Projektes
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class ProjectAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ var $project;
+ var $defaultSubAction = 'listing';
+
+
+ function __construct()
+ {
+ $this->project = new Project( $this->getRequestId() );
+ $this->project->load();
+ }
+
+
+ function editPost()
+ {
+ if ( $this->getRequestVar('name') != '')
+ {
+ $this->project->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM);
+ $this->project->target_dir = $this->getRequestVar('target_dir' ,OR_FILTER_RAW );
+ $this->project->ftp_url = $this->getRequestVar('ftp_url' ,OR_FILTER_RAW );
+ $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,OR_FILTER_RAW );
+ $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,OR_FILTER_RAW );
+ $this->project->content_negotiation = $this->getRequestVar('content_negotiation',OR_FILTER_NUMBER );
+ $this->project->cut_index = $this->getRequestVar('cut_index' ,OR_FILTER_NUMBER );
+
+ $this->addNotice('project',$this->project->name,'SAVED','ok');
+ $this->project->save(); // speichern
+
+ $root = new Folder( $this->project->getRootObjectId() );
+ $root->setTimestamp();
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('edit');
+ }
+ }
+
+
+
+ /**
+ * Liste aller Projekte anzeigen.
+ *
+ */
+ function listingView()
+ {
+ global $conf_php;
+
+ // Projekte ermitteln
+ $list = array();
+
+ foreach(Project::getAllProjects() as $id=> $name )
+ {
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url('project','edit',$id);
+ $list[$id]['use_url' ] = Html::url('tree' ,'load',0 ,array('projectid'=>$id,'target'=>'tree'));
+ $list[$id]['name' ] = $name;
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Auswaehlen und starten eines Projektes.
+ */
+ function select()
+ {
+ $user = Session::getUser();
+ $projects = $user->projects;
+
+ // Administrator sieht Administrationsbereich
+ if ( $user->isAdmin )
+ $projects = array_merge( array("-1"=>lang('ADMINISTRATION')),$projects );
+
+ // Projekte ermitteln
+ $list = array();
+
+ foreach( $projects as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['url' ] = Html::url('index','project',$id);
+ $list[$id]['name'] = $name;
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Anzeige der Eigenschaften des Projektes.
+ */
+ function editView()
+ {
+ $extraProperties = array('rootobjectid'=>$this->project->getRootObjectId());
+
+ $this->setTemplateVars( $this->project->getProperties() + $extraProperties );
+
+ }
+
+
+ function removeView()
+ {
+ $this->setTemplateVar( 'name',$this->project->name );
+ }
+
+
+ function removePost()
+ {
+ if ( !$this->hasRequestVar('delete') )
+ {
+ $this->addValidationError('delete');
+ return;
+ }
+
+ // Gesamtes Projekt loeschen
+ $this->project->delete();
+
+ $this->setTemplateVar('tree_refresh',true);
+ $this->addNotice('project',$this->project->name,'DELETED');
+ }
+
+
+
+ /**
+ * Anzeige View fuer Wartung.
+ */
+ function maintenanceView()
+ {
+ }
+
+
+
+ /**
+ * Wartung durchfuehren.
+ */
+ function maintenancePost()
+ {
+ switch( $this->getRequestVar('type') )
+ {
+ case 'check_files':
+ // Konsistenzprüfungen
+ $this->project->checkLostFiles();
+ $status = empty($this->project->log) ? OR_NOTICE_OK : OR_NOTICE_ERROR;
+
+ $this->addNotice('project',$this->project->name,'DONE',$status,array(),$this->project->log);
+ break;
+
+ case 'check_limit':
+ // Alte Versionen löschen.
+ $this->project->checkLimit();
+ $this->addNotice('project',$this->project->name,'DONE');
+ break;
+
+ default:
+ $this->addValidationError('type');
+ return;
+ }
+ }
+
+
+
+ /**
+ * Synchronisation mit dem Dateisystem.
+ */
+ public function syncPost()
+ {
+
+ }
+
+
+ /**
+ * Synchronisation mit dem Dateisystem.
+ */
+ public function syncView()
+ {
+ global $conf;
+ $syncConf = $conf['sync'];
+
+ if ( ! $syncConf['enabled'] )
+ return;
+
+ $syncDir = slashify($syncConf['directory']).$this->project->name;
+
+
+ }
+
+
+ /**
+ * Import aus dem Dateisystem.
+ */
+ public function importView()
+ {
+
+ }
+
+
+ /**
+ * Import aus dem Dateisystem.
+ */
+ public function importPost()
+ {
+
+ }
+
+
+ /**
+ * Export in Dateisystem.
+ */
+ public function exportView()
+ {
+
+ }
+
+
+ /**
+ * Export in Dateisystem.
+ */
+ public function exportPost()
+ {
+
+ }
+
+
+ /**
+ * Projekt exportieren.
+ */
+ public function copyView()
+ {
+
+ }
+
+
+ /**
+ * Projekt exportieren.
+ */
+ public function copyPost()
+ {
+ $db = db_connection();
+ $this->setTemplateVar( 'dbid',$db->id );
+
+ global $conf;
+ $dbids = array();
+
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'])
+ $dbids[$dbname] = $dbconf['description'];
+ }
+ $this->setTemplateVar( 'dbids',$dbids );
+
+
+ if ( $this->hasRequestVar('ok') )
+ {
+ $this->project->export( $this->getRequestVar('dbid') );
+
+ $this->addNotice('project',$this->project->name,'DONE');
+ $this->setTemplateVar('done',true);
+ }
+ }
+
+
+
+ /**
+ * Ausgabe PHPINFO.
+ *
+ */
+ function phpinfo()
+ {
+ global $conf;
+ if ( !@$conf['security']['show_system_info'] )
+ Http::sendStatus(403,'Forbidden','Display of system information is disabled by configuration');
+
+ phpinfo();
+ }
+
+
+
+
+ function infoView()
+ {
+ $this->setTemplateVar( 'info', $this->project->info() );
+ }
+
+
+
+
+ /**
+ * @param String $name Menüpunkt
+ * @return boolean true, falls Menüpunkt zugelassen
+ */
+ function checkMenu( $name )
+ {
+ global $conf;
+
+ switch( $name )
+ {
+ case 'remove':
+ return !readonly();
+ case 'maintenance':
+ return !readonly();
+
+ default:
+ return true;
+ }
+ }
+
+
+ /**
+ * Ermittelt die letzten Änderungen, die im aktuellen Projekt gemacht worden sind.
+ */
+ public function historyView()
+ {
+ $result = $this->project->getLastChanges();
+
+ $this->setTemplateVar('timeline', $result);
+ }
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/ProjectlistAction.class.php b/modules/cms-core/action/ProjectlistAction.class.php
@@ -0,0 +1,125 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Project;
+
+// 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 zum Bearbeiten eines Projektes
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class ProjectlistAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ function __construct()
+ {
+ }
+
+
+ public function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+ /**
+ * Liste aller Projekte anzeigen.
+ *
+ */
+ public function showView()
+ {
+ global $conf_php;
+
+ // Projekte ermitteln
+ $list = array();
+
+ foreach(Project::getAllProjects() as $id=> $name )
+ {
+ $list[$id] = array();
+ $list[$id]['id' ] = $id;
+ $list[$id]['name' ] = $name;
+ }
+ $this->setTemplateVar('projects',$list);
+ }
+
+
+
+ function addView()
+ {
+ $this->setTemplateVar( 'projects',Project::getAllProjects() );
+ }
+
+
+ /**
+ * Projekt hinzufuegen.
+ *
+ */
+ function addPost()
+ {
+ if ( !$this->hasRequestVar('type') )
+ {
+ $this->addValidationError('type');
+ $this->callSubAction('add');
+ return;
+ }
+ else
+ {
+ switch( $this->getRequestVar('type') )
+ {
+ case 'empty':
+ if ( !$this->hasRequestVar('name') )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ return;
+ }
+ $this->project = new Project();
+ $this->project->name = $this->getRequestVar('name');
+ $this->project->add();
+ $this->addNotice('project',$this->project->name,'ADDED');
+ break;
+ case 'copy':
+ $db = db_connection();
+ $project = new Project($this->getRequestVar('projectid'));
+ $project->load();
+ $project->export($db->id);
+ $this->addNotice('project',$project->name,'DONE');
+ break;
+ default:
+ Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') );
+ }
+
+ }
+ }
+
+
+ /**
+ * Ermittelt die letzten Änderungen, die in allen Projekten gemacht worden sind.
+ */
+ function historyView()
+ {
+ $result = Project::getAllLastChanges();
+ $this->setTemplateVar('timeline', $result);
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/SearchAction.class.php b/modules/cms-core/action/SearchAction.class.php
@@ -0,0 +1,238 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\User;
+use cms\model\Value;
+use cms\model\Template;
+use cms\model\Object;
+use cms\model\File;
+
+
+
+use Session;
+use \Html;
+
+
+
+// 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.
+
+
+define('SEARCH_FLAG_ID' , 1);
+define('SEARCH_FLAG_NAME' , 2);
+define('SEARCH_FLAG_FILENAME' , 4);
+define('SEARCH_FLAG_DESCRIPTION', 8);
+define('SEARCH_FLAG_VALUE' ,16);
+
+
+/**
+ * Action-Klasse fuer die Suchfunktion.
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class SearchAction extends Action
+{
+ public $security = SECURITY_USER;
+
+
+ /**
+ * leerer Kontruktor
+ */
+ function __construct()
+ {
+ }
+
+
+
+ public function editView()
+ {
+ $user = Session::getUser();
+ $this->setTemplateVar( 'users' ,User::listAll() );
+ $this->setTemplateVar( 'act_userid',$user->userid );
+ }
+
+ /**
+ * Durchf?hren der Suche
+ * und Anzeige der Ergebnisse
+ */
+ public function resultView()
+ {
+ $suchText = $this->getRequestVar('text');
+ $searchFlags = 0;
+
+ if ( $this->hasRequestVar('id' ) ) $searchFlags |= SEARCH_FLAG_ID;
+ if ( $this->hasRequestVar('filename' ) ) $searchFlags |= SEARCH_FLAG_FILENAME;
+ if ( $this->hasRequestVar('name' ) ) $searchFlags |= SEARCH_FLAG_NAME;
+ if ( $this->hasRequestVar('description') ) $searchFlags |= SEARCH_FLAG_DESCRIPTION;
+ if ( $this->hasRequestVar('content' ) ) $searchFlags |= SEARCH_FLAG_VALUE;
+
+ $this->performSearch($suchText, $searchFlags);
+
+ /*
+ case 'lastchange_user':
+ $e = new Value();
+
+ $language = Session::getProjectLanguage();
+ $e->languageid = $language->languageid;
+
+ $listObjectIds = $e->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') );
+ break;
+ }*/
+ }
+
+
+
+ /**
+ * Durchf?hren der Suche
+ * und Anzeige der Ergebnisse
+ */
+ public function quicksearchView()
+ {
+ global $conf;
+
+ $text = $this->getRequestVar('search');
+
+ $flag = $conf['search']['quicksearch']['flag'];
+ $searchFlags = 0;
+ if ( $flag['id' ] ) $searchFlags |= SEARCH_FLAG_ID;
+ if ( $flag['name' ] ) $searchFlags |= SEARCH_FLAG_NAME;
+ if ( $flag['filename' ] ) $searchFlags |= SEARCH_FLAG_FILENAME;
+ if ( $flag['description'] ) $searchFlags |= SEARCH_FLAG_DESCRIPTION;
+ if ( $flag['content' ] ) $searchFlags |= SEARCH_FLAG_VALUE;
+
+ $this->performSearch($text, $searchFlags);
+ }
+
+
+
+ /**
+ * Durchf?hren der Suche
+ * und Anzeige der Ergebnisse
+ */
+ private function performSearch( $text, $flag)
+ {
+ global $conf;
+
+ $listObjectIds = array();
+ $listTemplateIds = array();
+
+ $project = Session::getProject();
+ if ( is_object($project) && $project->projectid == -1 )
+ {
+ $resultList = array();
+
+ $user = User::loadWithName($text);
+ if ( is_object($user) )
+ {
+ $userResult = array( 'url' => Html::url('template','',$templateid),
+ 'type' => 'user',
+ 'name' => $user->name,
+ 'desc' => lang('NO_DESCRIPTION_AVAILABLE'),
+ 'lastchange_date' => 0 );
+ }
+ $resultList[] = $userResult;
+
+ $this->setTemplateVar( 'result',$resultList );
+ }
+ else
+ {
+ if ( $flag & SEARCH_FLAG_ID && Object::available( intval($text) ) )
+ $listObjectIds[] = intval( $text );
+
+ if ( $flag & SEARCH_FLAG_NAME )
+ {
+ $o = new Object();
+ $listObjectIds += $o->getObjectIdsByName( $text );
+ }
+
+ if ( $flag & SEARCH_FLAG_DESCRIPTION )
+ {
+ $o = new Object();
+ $listObjectIds += $o->getObjectIdsByDescription( $text );
+ }
+
+ if ( $flag & SEARCH_FLAG_FILENAME )
+ {
+ $o = new Object();
+ $listObjectIds += $o->getObjectIdsByFilename( $text );
+
+ $f = new File();
+ $listObjectIds += $f->getObjectIdsByExtension( $text );
+ }
+
+ // Inhalte durchsuchen
+ if ( $flag & SEARCH_FLAG_VALUE )
+ {
+ $e = new Value();
+ $listObjectIds += $e->getObjectIdsByValue( $text );
+
+ $template = new Template();
+ $listTemplateIds += $template->getTemplateIdsByValue( $text );
+ }
+
+ $this->explainResult( $listObjectIds, $listTemplateIds );
+ }
+
+ }
+
+
+ /**
+ *
+ */
+ private function explainResult( $listObjectIds, $listTemplateIds )
+ {
+ $resultList = array();
+
+ foreach( $listObjectIds as $objectid )
+ {
+ $o = new Object( $objectid );
+ $o->load();
+ $resultList[$objectid] = array();
+ $resultList[$objectid]['id' ] = $objectid;
+ $resultList[$objectid]['url' ] = Html::url($o->getType(),'',$objectid);
+ $resultList[$objectid]['type'] = $o->getType();
+ $resultList[$objectid]['name'] = $o->name;
+ $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate;
+
+ if ( $o->desc != '' )
+ $resultList[$objectid]['desc'] = $o->desc;
+ else
+ $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ }
+
+ foreach( $listTemplateIds as $templateid )
+ {
+ $t = new Template( $templateid );
+ $t->load();
+ $resultList['t'.$templateid] = array();
+ $resultList['t'.$templateid]['id' ] = $templateid;
+ $resultList['t'.$templateid]['url' ] = Html::url('template','',$templateid);
+ $resultList['t'.$templateid]['type'] = 'template';
+ $resultList['t'.$templateid]['name'] = $t->name;
+ $resultList['t'.$templateid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ $resultList['t'.$templateid]['lastchange_date'] = 0;
+ }
+
+ $this->setTemplateVar( 'result',$resultList );
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/StartAction.class.php b/modules/cms-core/action/StartAction.class.php
@@ -0,0 +1,1704 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\User;
+use cms\model\Project;
+use cms\model\Value;
+use cms\model\Element;
+use cms\model\Page;
+use cms\model\Object;
+use cms\model\Language;
+use cms\model\Model;
+
+
+use database\Database;
+use Http;
+use Logger;
+use \security\Password;
+use Session;
+use \Html;
+use \Mail;
+
+// OpenRat Content Management System
+// Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+if ( !defined('PROJECTID_ADMIN') )
+ define('PROJECTID_ADMIN',-1);
+
+/**
+ * Action-Klasse fuer die Start-Action
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class StartAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $mustChangePassword = false;
+
+ function setDb( $dbid )
+ {
+ global $conf;
+
+ if ( !isset($conf['database'][$dbid] ))
+ Http::serverError( 'unknown DB-Id: '.$dbid );
+
+ $db = db_connection();
+ if ( is_object($db) )
+ {
+ $db->rollback();
+ }
+
+ $db = new Database( $conf['database'][$dbid] );
+ $db->id = $dbid;
+ $db->start();
+ Session::setDatabase( $db );
+ }
+
+
+
+ function checkForDb()
+ {
+ global $conf;
+ $dbid = $this->getRequestVar('dbid');
+
+ if ( $dbid != '' )
+ $this->setDb( $dbid );
+ }
+
+
+
+ function setDefaultDb()
+ {
+ if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) )
+ {
+ $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID);
+ }
+ else
+ {
+ global $conf;
+
+ if ( !isset($conf['database']['default']) )
+ Http::serverError('default-database not set');
+
+ $dbid = $conf['database']['default'];
+ }
+
+ $this->setDb( $dbid );
+ }
+
+
+
+ function checkLogin( $name,$pw,$pw1,$pw2 )
+ {
+ Logger::debug( "login user $name" );
+
+ global $conf;
+ global $SESS;
+
+ unset( $SESS['user'] );
+
+
+ $db = db_connection();
+
+ if ( !$db->available )
+ {
+ $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error));
+ $this->callSubAction('showlogin');
+ return false;
+ }
+
+ $ip = getenv("REMOTE_ADDR");
+
+ $user = new User();
+ $user->name = $name;
+
+ $ok = $user->checkPassword( $pw );
+
+ $this->mustChangePassword = $user->mustChangePassword;
+
+ if ( $this->mustChangePassword )
+ {
+ // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen.
+ // Wir versuchen hier, das neue zu setzen (sofern eingegeben).
+ if ( empty($pw1) )
+ {
+ }
+ elseif ( $pw1 != $pw2 )
+ {
+ $this->addValidationError('password1','PASSWORDS_DO_NOT_MATCH');
+ $this->addValidationError('password2','');
+ }
+ elseif ( strlen($pw2) < $conf['security']['password']['min_length'] )
+ {
+ $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=>$conf['security']['password']['min_length']));
+ $this->addValidationError('password2','');
+ }
+ else
+ {
+ // Kennw�rter identisch und lang genug.
+ $user->setPassword( $pw1,true );
+
+ // Das neue Kennwort ist gesetzt, die Anmeldung ist also doch noch gelungen.
+ $ok = true;
+ $this->mustChangePassword = false;
+ $user->mustChangePassword = false;
+ }
+ }
+
+ // Falls Login erfolgreich
+ if ( $ok )
+ {
+ // Login war erfolgreich!
+ $user->load();
+ $user->setCurrent();
+ Logger::info( 'login successful' );
+
+ return true;
+ }
+ else
+ {
+ Logger::info( "login for user $name failed" );
+
+ return false;
+ }
+ }
+
+
+
+ /**
+ * Anzeigen der Loginmaske.
+ *
+ * Es wird nur die Loginmaske angezeigt.
+ * Hier nie "304 not modified" setzen, da sonst keine
+ * Login-Fehlermeldung erscheinen kann
+ */
+ function loginView()
+ {
+ global $conf;
+ $sso = $conf['security']['sso'];
+ $ssl = $conf['security']['ssl'];
+
+ $ssl_trust = false;
+ $ssl_user_var = '';
+ extract( $ssl, EXTR_PREFIX_ALL, 'ssl' );
+
+ if ( $sso['enable'] )
+ {
+ $authid = $this->getRequestVar( $sso['auth_param_name']);
+
+ if ( empty( $authid) )
+ Http::notAuthorized( 'no authorization data (no auth-id)');
+
+ if ( $sso['auth_param_serialized'] )
+ $authid = unserialize( $authid );
+
+ $purl = parse_url($sso['url']);
+ // Verbindung zu URL herstellen.
+ $errno=0; $errstr='';
+ $fp = fsockopen ($purl['host'],80, $errno, $errstr, 30);
+ if ( !$fp )
+ {
+ echo "Connection failed: $errstr ($errno)";
+ }
+ else
+ {
+ $http_get = $purl['path'];
+ if ( !empty($purl['query']) )
+ $http_get .= '?'.$purl['query'];
+
+ $header = array();
+
+ $header[] = "GET $http_get HTTP/1.0";
+ $header[] ="Host: ".$purl['host'];
+ $header[] = "User-Agent: Mozilla/5.0 (OpenRat CMS Single Sign-on Check)";
+ $header[] = "Connection: Close";
+
+ if ( $sso['cookie'] )
+ {
+ $cookie = 'Cookie: ';
+ if ( is_array($authid))
+ foreach( $authid as $cookiename=>$cookievalue)
+ $cookie .= $cookiename.'='.$cookievalue."; ";
+ else
+ $cookie .= $sso['cookie_name'].'='.$authid;
+
+ $header[] = $cookie;
+ }
+
+// Html::debug($header);
+ fputs ($fp, implode("\r\n",$header)."\r\n\r\n");
+
+ $inhalt=array();
+ while (!feof($fp)) {
+ $inhalt[] = fgets($fp,128);
+ }
+ fclose($fp);
+
+ $html = implode('',$inhalt);
+// Html::debug($html);
+ if ( !preg_match($sso['expect_regexp'],$html) )
+ Http::notAuthorized('auth failed');
+ $treffer=0;
+ if ( !preg_match($sso['username_regexp'],$html,$treffer) )
+ Http::notAuthorized('auth failed');
+ if ( !isset($treffer[1]) )
+ Http::notAuthorized('authorization failed');
+
+ $username = $treffer[1];
+
+// Html::debug( $treffer );
+ $this->setDefaultDb();
+
+ $user = User::loadWithName( $username );
+
+ if ( ! $user->isValid( ))
+ Http::notAuthorized('authorization failed: user not found: '.$username);
+
+ $user->setCurrent();
+
+ $this->callSubAction('show');
+ }
+ }
+
+ elseif ( $ssl_trust )
+ {
+ if ( empty($ssl_user_var) )
+ Http::serverError( 'please set environment variable name in ssl-configuration.' );
+
+ $username = getenv( $ssl_user_var );
+
+ if ( empty($username) )
+ Http::notAuthorized( 'no username in client certificate ('.$ssl_user_var.') (or there is no client certificate...?)' );
+
+ $this->setDefaultDb();
+
+ $user = User::loadWithName( $username );
+
+ if ( !$user->isValid() )
+ Http::serverError( 'unknown username: '.$username );
+
+ $user->setCurrent();
+
+ $this->callSubAction('show');
+ }
+
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbname] = array('key' =>$dbname,
+ 'value'=>Text::maxLength($dbconf['description']),
+ 'title'=>$dbconf['description'].' ('.$dbconf['host'].')' );
+ }
+
+ $openid_provider = array();
+ foreach( explode(',',$conf['security']['openid']['provider']) as $provider )
+ $openid_provider[$provider] = config('security','openid','provider.'.$provider.'.name');
+ $this->setTemplateVar('openid_providers',$openid_provider);
+ $this->setTemplateVar('openid_user_identity',config('security','openid','user_identity'));
+ //$this->setTemplateVar('openid_provider','identity');
+
+
+ if ( empty($dbids) )
+ $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN);
+
+ if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) )
+ $this->setTemplateVar('login_name',$_COOKIE['or_username']);
+
+ if ( !isset($this->templateVars['login_name']) )
+ $this->setTemplateVar('login_name',@$conf['security']['default']['username']);
+
+ if ( $this->templateVars['login_name']== @$conf['security']['default']['username'])
+ $this->setTemplateVar('login_password',@$conf['security']['default']['password']);
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ $db = Session::getDatabase();
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ elseif( isset($this->templateVars['actid']) )
+ ;
+ else
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+
+
+ // Den Benutzernamen aus dem Client-Zertifikat lesen und in die Loginmaske eintragen.
+ $ssl_user_var = $conf['security']['ssl']['user_var'];
+ if ( !empty($ssl_user_var) )
+ {
+ $username = getenv( $ssl_user_var );
+
+ if ( empty($username) )
+ {
+ echo lang('ERROR_LOGIN_BROKEN_SSL_CERT');
+ Logger::warn( 'no username in SSL client certificate (var='.$ssl_user_var.').' );
+ exit;
+ }
+
+ // Benutzername ist in Eingabemaske unveränderlich
+ $this->setTemplateVar('force_username',$username);
+ }
+
+ $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) );
+ $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) );
+
+ $this->setTemplateVar('register' ,$conf['login' ]['register' ]);
+ $this->setTemplateVar('send_password',$conf['login' ]['send_password']);
+ }
+
+
+
+ /**
+ * Setzt die neue Projekt-Id und lädt die Workbench neu.
+ *
+ */
+ public function projectmenuPost()
+ {
+
+ $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
+ $this->setPerspective('normal');
+ }
+
+
+ /**
+ * Erzeugt ein Projekt-Auswahlmenue.
+ */
+ public function projectmenuView()
+ {
+ $user = Session::getUser();
+
+ if ( $user->mustChangePassword )
+ {
+ $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
+ $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern.
+ }
+
+
+ // Diese Seite gilt pro Sitzung.
+ //$this->lastModified( $user->loginDate );
+
+ // Projekte ermitteln
+ $projects = $user->getReadableProjects();
+
+ $list = array();
+
+ foreach( $projects as $id=>$name )
+ {
+ $p = array();
+ $p['url' ] = Html::url('start','project',$id);
+ $p['name'] = $name;
+ $p['id' ] = $id;
+
+ $tmpProject = new Project( $id );
+ $p['defaultmodelid' ] = $tmpProject->getDefaultModelId();
+ $p['defaultlanguageid'] = $tmpProject->getDefaultLanguageId();
+ $p['models' ] = $tmpProject->getModels();
+ $p['languages' ] = $tmpProject->getLanguages();
+
+ $list[] = $p;
+ }
+
+ $this->setTemplateVar('projects',$list);
+
+ if ( empty($list) )
+ {
+ // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben.
+ if ( $this->userIsAdmin() )
+ // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen
+ $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
+ else
+ // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf�gung steht
+ $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN);
+ }
+
+ //$this->metaValues();
+ }
+
+
+
+ /**
+ * Erzeugt eine Anwendungsliste.
+ */
+ public function applicationsView()
+ {
+ global $conf;
+
+ // Diese Seite gilt pro Sitzung.
+ $user = Session::getUser();
+ $userGroups = $user->getGroups();
+ $this->lastModified( $user->loginDate );
+
+ // Applikationen ermitteln
+ $list = array();
+ foreach( $conf['applications'] as $id=>$app )
+ {
+ if ( !is_array($app) )
+ continue;
+
+ if ( isset($app['group']) )
+ if ( !in_array($app['group'],$userGroups) )
+ continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden.
+
+ $p = array();
+ $p['url'] = $app['url'];
+ $p['description'] = @$app['description'];
+ if ( isset($app['param']) )
+ {
+ $p['url'] .= strpos($p['url'],'?')!==false?'&':'?';
+ $p['url'] .= $app['param'].'='.session_id();
+ }
+ $p['name'] = $app['name'];
+
+ $list[] = $p;
+ }
+
+
+ $this->metaValues();
+ $this->setTemplateVar('applications',$list);
+ }
+
+
+
+ /**
+ * Ermittelt Meta-Angaben f�r den HTML-Kopf.<br>
+ * Falls der Browser die Meta-Angaben entsprechend auswertet, k�nnen �ber feste Browser-Men�s die Projekt direkt ausgew�hlt werden.
+ * @Unused
+ */
+ private function metaValues()
+ {
+ global $conf;
+ $metaList = array();
+
+ $user = Session::getUser();
+ if ( is_object($user) )
+ {
+ // Projekte ermitteln
+ $projects = $user->projects;
+ foreach( $projects as $id=>$name )
+ {
+ $metaList[] = array('name' => 'chapter',
+ 'url' => Html::url('index','project',$id),
+ 'title'=> $name );
+ }
+
+ if ( $this->userIsAdmin() )
+ {
+ $metaList[] = array('name' => 'appendix',
+ 'url' => Html::url('index','projectmenu',0 ),
+ 'title'=> lang('MENU_TREETITLE_ADMINISTRATION' ) );
+
+ $metaList[] = array('name' => 'chapter',
+ 'url' => Html::url('index','administration',0),
+ 'title'=> lang('administration') );
+ }
+
+ // Applikationen ermitteln
+ foreach( $conf['applications'] as $id=>$app )
+ {
+ if ( !is_array($app) )
+ continue;
+ $appUrl = $app['url'];
+ if ( isset($app['param']) )
+ {
+ $appUrl .= strpos($appUrl,'?')!==false?'&':'?';
+ $appUrl .= $app['param'].'='.session_id();
+ }
+
+ $metaList[] = array('name' => 'bookmark',
+ 'url' => $appUrl ,
+ 'title'=> $app['name'] );
+ }
+ }
+
+ $project = Session::getProject();
+ if ( is_object($project) && $project->projectid > 0 )
+ {
+ $languages =$project->getLanguages();
+
+ foreach( $project->getModels() as $modelid=>$modelname )
+ {
+ foreach( $languages as $languageid=>$languagename )
+ {
+
+ $metaList[] = array('name' => 'subsection',
+ 'url' => Html::url('index',
+ 'project',
+ $project->projectid,
+ array('languageid'=>$languageid,
+ 'modelid' =>$modelid) ),
+ 'title'=> $modelname.' - '.$languagename
+ );
+ }
+ }
+ }
+
+ $metaList[] = array('name' => 'author',
+ 'url' => $conf['login']['logo']['url'],
+ 'title'=> $conf['login']['logo']['url'] );
+
+ $metaList[] = array('name' => 'top',
+ 'url' => Html::url('index','logout',0 ),
+ 'title'=> 'Start' );
+
+ $metaList[] = array('name' => 'contents',
+ 'url' => Html::url('index','projectmenu',0 ),
+ 'title'=> lang('MENU_TREETITLE_PROJECTMENU' ) );
+
+
+ $this->setTemplateVar('metaList',$metaList);
+ }
+
+
+
+ /**
+ * Open-Id Login, �berpr�fen der Anmeldung.<br>
+ * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
+ * Kapitel "4.4. check_authentication"<br>
+ * <br>
+ * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br>
+ * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
+ * <br>
+ * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der
+ * Benutzer angemeldet.<br>
+ */
+ function openid()
+ {
+ global $conf;
+ $openId = Session::get('openid');
+
+ if ( !$openId->checkAuthentication() )
+ {
+ $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ //Html::debug($openId);
+
+ // Anmeldung wurde mit "is_valid:true" best�tigt.
+ // Der Benutzer ist jetzt eingeloggt.
+ $username = $openId->getUserFromIdentiy();
+
+ if ( empty($username) )
+ {
+ // Es konnte kein Benutzername ermittelt werden.
+ $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ $user = User::loadWithName( $username );
+
+ if ( $user->userid <=0)
+ {
+ // Benutzer ist (noch) nicht vorhanden.
+ if ( $conf['security']['openid']['add']) // Anlegen?
+ {
+ $user->name = $username;
+ $user->add();
+
+ $user->mail = $openId->info['email'];
+ $user->fullname = $openId->info['fullname'];
+ $user->save(); // Um E-Mail zu speichern (wird bei add() nicht gemacht)
+ }
+ else
+ {
+ // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht).
+ $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+ }
+ else
+ {
+ // Benutzer ist bereits vorhanden.
+ if ( @$conf['security']['openid']['update_user'])
+ {
+ $user->fullname = $openId->info['fullname'];
+ $user->mail = $openId->info['email'];
+ $user->save();
+ }
+ }
+
+ $user->setCurrent(); // Benutzer ist jetzt in der Sitzung.
+ }
+
+
+ /**
+ * Login.
+ */
+ function loginPost()
+ {
+ global $conf;
+
+ $this->checkForDb();
+ Session::setUser('');
+
+ if ( $conf['login']['nologin'] )
+ Http::notAuthorized('login disabled');
+
+ $openid_user = $this->getRequestVar('openid_url' );
+ $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM);
+ $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM);
+ $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM);
+ $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM);
+
+ // Cookie setzen
+ setcookie('or_username',$loginName,time()+(60*60*24*30*12*2) );
+
+ // Login mit Open-Id.
+ if ( $this->hasRequestVar('openid_provider') && ($this->getRequestVar('openid_provider') != 'identity' || !empty($openid_user)) )
+ {
+ $openId = new OpenId($this->getRequestVar('openid_provider'),$openid_user);
+
+ if ( ! $openId->login() )
+ {
+ $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) );
+ $this->addValidationError('openid_url','');
+ $this->callSubAction('showlogin');
+ return;
+ }
+
+ Session::set('openid',$openId);
+ $openId->redirect();
+ die('Unreachable Code');
+ }
+
+
+ // Ermitteln, ob der Baum angezeigt werden soll
+ // Ist die Breite zu klein, dann wird der Baum nicht angezeigt
+ Session::set('showtree',intval($this->getRequestVar('screenwidth')) > $conf['interface']['min_width'] );
+
+ $loginOk = $this->checkLogin( $loginName,
+ $loginPassword,
+ $newPassword1,
+ $newPassword2 );
+
+ usleep(hexdec(Password::randomHexString(1))); // delay: 0-255 ms
+
+ if ( !$loginOk )
+ {
+
+ if ( $this->mustChangePassword )
+ {
+ // Anmeldung gescheitert, Benutzer muss Kennwort �ndern.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' );
+ $this->addValidationError('password1','');
+ $this->addValidationError('password2','');
+ }
+ else
+ {
+ // Anmeldung gescheitert.
+ $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$loginName) );
+ $this->addValidationError('login_name' ,'');
+ $this->addValidationError('login_password','');
+ }
+
+ Logger::debug("Login failed for user '$loginName'");
+
+ $this->callSubAction('login');
+ return;
+ }
+ else
+ {
+ Logger::debug("Login successful for user '$loginName'");
+
+ // Anmeldung erfolgreich.
+ if ( config('security','renew_session_login') )
+ $this->recreateSession();
+
+ $user = Session::getUser();
+ $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname));
+
+ $this->evaluateRequestVars();
+
+ $object = Session::getObject();
+ // Falls noch kein Objekt ausgew�hlt, dann das zuletzt ge�nderte benutzen.
+ if ( !is_object($object) && @$conf['login']['start']['start_lastchanged_object'] )
+ {
+ $objectid = Value::getLastChangedObjectByUserId($user->userid);
+ if ( Object::available($objectid))
+ {
+ $object = new Object($objectid);
+ $object->load();
+ Session::setObject($object);
+ }
+
+ $project = new Project( $object->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+ }
+
+ $this->refresh(); // Benutzer ist angemeldet: Andere Views könnte das interessieren.
+ }
+
+
+ /**
+ * Benutzer meldet sich ab.
+ */
+ function logoutPost()
+ {
+ global $conf;
+
+ $user = Session::getUser();
+ if ( is_object($user) )
+ $this->setTemplateVar('login_username',$user->name);
+
+ // Ausgew�hlte Objekte merken, um nach dem n�. Login wieder sofort auszuw�hlen.
+ $o = Session::getObject();
+ if ( is_object($o) )
+ $this->setTemplateVar('objectid',$o->objectid);
+ $p = Session::getProject();
+ if ( is_object($p) )
+ $this->setTemplateVar('projectid',$p->projectid);
+ $l = Session::getProjectLanguage();
+ if ( is_object($l) )
+ $this->setTemplateVar('languageid',$l->languageid);
+ $m = Session::getProjectModel();
+ if ( is_object($m) )
+ $this->setTemplateVar('modelid',$m->modelid);
+ $db = db_connection();
+ if ( is_object($db) )
+ $this->setTemplateVar('dbid',$db->id);
+
+ /*
+ // Alle Variablen aus der Sitzung entfernen.
+ session_unset();
+
+ // Damit wird die Session gelöscht, nicht nur die Session-Daten!
+ if ( ini_get("session.use_cookies") )
+ {
+ $params = session_get_cookie_params();
+ setcookie( session_name(),'', time() - 3600,
+ $params["path"],$params["domain"],$params["secure"],$params["httponly"] );
+ }
+
+ // Loeschen der Session.
+ session_destroy();
+ */
+ if ( config('security','renew_session_logout') )
+ $this->recreateSession();
+
+ session_unset();
+
+ if ( @$conf['theme']['compiler']['compile_at_logout'] )
+ {
+ foreach( $conf['action'] as $actionName => $actionConfig )
+ {
+ foreach( $actionConfig as $subActionName=>$subaction )
+ {
+ if ( is_array($subaction) &&
+ !isset($subaction['goto' ]) &&
+ !isset($subaction['direct']) &&
+ !isset($subaction['action']) &&
+ !isset($subaction['alias' ]) &&
+ $subActionName != 'menu' )
+ {
+ $engine = new template_engine\TemplateEngine();
+ $engine->compile( strtolower(str_replace('Action','',$actionName)).'/'.$subActionName);
+ }
+ }
+ }
+ }
+
+ // Umleiten auf eine definierte URL.s
+ $redirect_url = @$conf['security']['logout']['redirect_url'];
+
+ if ( !empty($redirect_url) )
+ {
+ header('Location: '.$redirect_url);
+ exit;
+ }
+ }
+
+
+
+ /**
+ * Benutzer meldet sich ab.
+ */
+ function logoutView()
+ {
+ }
+
+
+ /**
+ * Ausw�hlen der Administration.
+ */
+ function administrationPost()
+ {
+ Session::setProject( new Project(-1) );
+ Session::set('perspective','administration');
+ $this->refresh();
+ }
+
+
+
+ /**
+ * Auswaehlen des Benutzer-Profiles.
+ */
+ function profilePost()
+ {
+ Session::set('perspective','profile');
+ $this->refresh();
+ }
+
+
+
+ /**
+ * Auswaehlen der Startseite.
+ */
+ function startPost()
+ {
+ Session::set('perspective','start');
+ $this->refresh();
+ }
+
+
+
+ /**
+ * Ausgeben von maschinenlesbaren Benutzerinformationen.
+ *
+ * Diese Funktion dient dem Single-Signon f�r fremde Anwendungen, welche
+ * die Benutzerinformationen des angemeldeten Benutzers aus dieser
+ * Anwendung auslesen k�nnen.
+ */
+ function userinfo()
+ {
+ $user = Session::getUser();
+ $info = array('username' => $user->name,
+ 'fullname' => $user->fullname,
+ 'mail' => $user->mail,
+ 'telephone' => $user->tel,
+ 'style' => $user->style,
+ 'admin' => $user->isAdmin?'true':'false',
+ 'ldap' => $user->ldap_dn,
+ 'groups' => implode(',',$user->getGroups()),
+ 'description'=> $user->desc
+ );
+
+ // Wenn der HTTP-Parameter "xml" vorhanden ist, dann geben wir die
+ // Informationen per XML aus.
+ if ( $this->hasRequestVar('xml') )
+ {
+ header('Content-Type: text/xml');
+ echo '<userinfo>';
+ foreach( $info as $n=>$i )
+ echo '<'.$n.'>'.$i.'</'.$n.'>'."\n";
+ echo '</userinfo>';
+
+ }
+
+ // Sonst normale Textausgabe im INI-Datei-Format.
+ else
+ {
+ header('Content-Type: text/plain');
+ foreach( $info as $n=>$i )
+ echo $n.'="'.$i."\"\n";
+ }
+
+ exit; // Fertig.
+ }
+
+
+ function project()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
+
+ Session::setUser( $user );
+ }
+
+
+ function object()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) );
+
+ Session::setUser( $user );
+ }
+
+
+ function languagePost()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ Http::serverError('No user in session');
+ return;
+ }
+
+ $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) );
+ }
+
+
+ function modelPost()
+ {
+ $user = Session::getUser();
+ if ( ! is_object($user) )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+
+ $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) );
+ }
+
+
+ /**
+ * Auswerten der Request-Variablen.
+ *
+ * @param Array $add
+ */
+ private function evaluateRequestVars( $add = array() )
+ {
+ global $REQ;
+ $vars = $REQ + $add;
+
+ $db = db_connection();
+ if ( !is_object($db) )
+ {
+ if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
+ $this->setDb($vars[REQ_PARAM_DATABASE_ID]);
+ else
+ Http::serverError('no database available.');
+ }
+ else
+ {
+ // Prüft, ob die übergebene Datenbank-Id mit der
+ // aktuellen übereinstimmt.
+ // Falls nicht, muss ein Re-Login erfolgen.
+ if ( isset($vars[REQ_PARAM_DATABASE_ID]) )
+ if ( $db->id != $vars[REQ_PARAM_DATABASE_ID] )
+ {
+ $this->callSubAction('show');
+ return;
+ }
+ }
+
+
+ if ( isset($vars[REQ_PARAM_OBJECT_ID]) && Object::available($vars[REQ_PARAM_OBJECT_ID]) )
+ {
+ $object = new Object( $vars[REQ_PARAM_OBJECT_ID] );
+ $object->objectLoadRaw();
+ // Session::setObject( $object ); // Unnötig
+
+ $project = new Project( $object->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&&Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&&Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+ elseif ( isset($vars[REQ_PARAM_LANGUAGE_ID]) && Language::available($vars[REQ_PARAM_LANGUAGE_ID]) )
+ {
+ $language = new Language( $vars[REQ_PARAM_LANGUAGE_ID] );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $project = new Project( $language->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $model = Session::getProjectModel();
+ if ( !is_object($model) )
+ {
+ $model = new Model( $project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+
+ }
+ elseif ( isset($vars[REQ_PARAM_MODEL_ID]) && Model::available($vars[REQ_PARAM_MODEL_ID]) )
+ {
+ $model = new Model( $vars[REQ_PARAM_MODEL_ID] );
+ $model->load();
+ Session::setProjectModel( $model );
+
+ $project = new Project( $model->projectid );
+ $project->load();
+ Session::setProject( $project );
+
+ $language = Session::getProjectLanguage();
+ if ( !is_object($language) || $language->projectid != $project->projectid )
+ {
+ $language = new Language( $project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+ }
+ }
+ elseif ( isset($vars[REQ_PARAM_PROJECT_ID])&&Project::isAvailable($vars[REQ_PARAM_PROJECT_ID]) )
+ {
+ $project = new Project( $vars[REQ_PARAM_PROJECT_ID] );
+ $project->load();
+
+ Session::setProject( $project );
+
+ $language = new Language( isset($vars[REQ_PARAM_LANGUAGE_ID])&& Language::available($vars[REQ_PARAM_LANGUAGE_ID])?$vars[REQ_PARAM_LANGUAGE_ID]:$project->getDefaultLanguageId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( isset($vars[REQ_PARAM_MODEL_ID])&& Model::available($vars[REQ_PARAM_MODEL_ID])?$vars[REQ_PARAM_MODEL_ID]:$project->getDefaultModelId() );
+ $model->load();
+ Session::setProjectModel( $model );
+ }
+ }
+
+
+ function showtree()
+ {
+ Session::set('showtree',true );
+ }
+
+
+ function hidetree()
+ {
+ Session::set('showtree',false );
+ }
+
+
+ function switchuser()
+ {
+ $user = Session::getUser();
+
+ if ( ! $user->isAdmin )
+ Http::notAuthorized("");
+
+ $this->recreateSession();
+
+ $newUser = new User( $this->getRequestId() );
+ $newUser->load();
+
+ $newUser->setCurrent();
+ }
+
+
+ function show()
+ {
+ global $conf;
+ global $PHP_AUTH_USER;
+ global $PHP_AUTH_PW;
+
+ $user = Session::getUser();
+ // Gast-Login
+ if ( ! is_object($user) )
+ {
+ if ( $conf['security']['guest']['enable'] )
+ {
+ $this->setDefaultDb();
+ $username = $conf['security']['guest']['user'];
+ $user = User::loadWithName($username);
+ if ( $user->userid > 0 )
+ $user->setCurrent();
+ else
+ {
+ Logger::warn('Guest login failed, user not found: '.$username);
+ $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) );
+ $user = null;
+ }
+ }
+ }
+
+ if ( ! is_object($user) )
+ {
+ switch( $conf['security']['login']['type'] )
+ {
+
+ // Authorization ueber HTTP
+ //
+ case 'http':
+ $ok = false;
+
+ if ( isset($_SERVER['PHP_AUTH_USER']) )
+ {
+ $this->setDefaultDb();
+ $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] );
+ }
+
+ if ( ! $ok )
+ {
+ header( 'WWW-Authenticate: Basic realm="'.OR_TITLE.' - '.lang('HTTP_REALM').'"' );
+ header( 'HTTP/1.0 401 Unauthorized' );
+ echo 'Authorization Required!';
+ exit;
+ }
+ break;
+
+ case 'form':
+ // Benutzer ist nicht angemeldet
+ $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske
+ return;
+ break;
+
+ default:
+ Http::serverError('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' );
+ }
+ }
+
+ if ( $user->mustChangePassword )
+ {
+ $this->addNotice( 'user',$user->name,'PASSWORD_TIMEOUT','warn' );
+ $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu �ndern.
+ }
+
+ // Seite �ndert sich nur 1x pro Session
+ $this->lastModified( $user->loginDate );
+
+ $projectid = intval( $this->getRequestVar('projectid' ) );
+ $languageid = intval( $this->getRequestVar('languageid') );
+ $modelid = intval( $this->getRequestVar('modelid' ) );
+ $objectid = intval( $this->getRequestVar('objectid' ) );
+ $elementid = intval( $this->getRequestVar('elementid' ) );
+
+ if ( $projectid != 0 )
+ {
+ $project = new Project( $projectid );
+ $project->load();
+ Session::setProject($project);
+ }
+ elseif ( $languageid != 0 )
+ {
+ $language = new Language( $languageid );
+ $language->load();
+ Session::setProjectLanguage($language);
+ }
+ elseif ( $modelid != 0 )
+ {
+ $model = new Model( $modelid );
+ $model->load();
+ Session::setProjectModel($model);
+ }
+ elseif ( $objectid != 0 )
+ {
+ $object = new Object( $objectid );
+ $object->objectLoad();
+ Session::setObject($object);
+ }
+ if ( $elementid != 0 )
+ {
+ $element = new Element( $elementid );
+ Session::setElement($element);
+ }
+
+ $project = Session::getProject();
+ $object = Session::getObject();
+ $elementid = 0;
+
+ if ( is_object($project) )
+ {
+ if ( $project->projectid == PROJECTID_ADMIN )
+ {
+ $project->name = lang('ADMINISTRATION');
+ Session::setProject( $project );
+
+ Session::setProjectLanguage( '' );
+ Session::setProjectModel ( '' );
+ Session::setObject ( '' );
+ }
+
+ $this->setTemplateVar( 'title',$project->name );
+
+ if ( is_object($object) )
+ {
+ $type = $object->getType();
+
+ if ( $type == 'page' )
+ {
+ $page = new Page($object->objectid);
+ $page->load();
+ $elementList = $page->getWritableElements();
+ if ( count($elementList) == 1 )
+ $elementid = current(array_keys($elementList));
+ }
+
+ if ( $elementid > 0 )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','pageelement',$object->objectid,array('elementid'=>$elementid,'targetSubAction'=>'edit')) );
+ else
+ $this->setTemplateVar( 'frame_src_main',Html::url('main',$type,$object->objectid) );
+ }
+ else
+ {
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
+ }
+ }
+ elseif ( is_object($project) && $project->projectid == PROJECTID_ADMIN )
+ {
+ if ( $this->hasRequestVar('projectid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','project',$this->getRequestVar('projectid')) );
+ elseif ( $this->hasRequestVar('groupid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','group' ,$this->getRequestVar('groupid' )) );
+ elseif ( $this->hasRequestVar('userid') )
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','user' ,$this->getRequestVar('userid' )) );
+ else
+ $this->setTemplateVar( 'frame_src_main',Html::url('main','empty',0,array(REQ_PARAM_TARGETSUBACTION=>'blank')) );
+ }
+ else
+ {
+ $this->callSubAction( 'projectmenu' );
+ }
+
+
+ $this->setTemplateVar( 'show_tree',(Session::get('showtree')==true) );
+
+ $this->setTemplateVar( 'frame_src_title' ,Html::url( 'title' ) );
+ $this->setTemplateVar( 'frame_src_tree_menu' ,Html::url( 'treemenu' ) );
+ $this->setTemplateVar( 'frame_src_tree_title',Html::url( 'treetitle' ) );
+ $this->setTemplateVar( 'frame_src_tree' ,Html::url( 'tree' ,'load' ) );
+ $this->setTemplateVar( 'frame_src_clipboard' ,Html::url( 'clipboard' ) );
+ $this->setTemplateVar( 'frame_src_status' ,Html::url( 'status' ) );
+
+ $this->setTemplateVar( 'tree_width',$conf['interface']['tree_width'] );
+
+ $this->metaValues();
+ }
+
+
+
+ function checkMenu( $name )
+ {
+ global $conf;
+
+ switch( $name )
+ {
+ case 'applications':
+ // Men�punkt "Anwendungen" wird nur angezeigt, wenn weitere Anwendungen
+ // konfiguriert sind.
+ return count(@$conf['applications']) > 0;
+
+ case 'register': // Registrierung
+ // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
+ return @$conf['login']['register'] && @$conf['security']['auth']['type'] == 'database';
+
+ case 'password': // Kennwort vergessen
+ // Nur, wenn aktiviert und gegen eigene Datenbank authentisiert wird.
+ // Deaktiviert, falls LDAP-Lookup aktiviert ist.
+ return @$conf['login']['send_password'] && @$conf['security']['auth']['type'] == 'database'
+ && !@$conf['security']['auth']['userdn'];
+
+ case 'administration':
+ // "Administration" nat�rlich nur f�r Administratoren.
+ return $this->userIsAdmin();
+
+ case 'login':
+ return !@$conf['login']['nologin'];
+
+ case 'logout':
+ return true;
+
+ case 'projectmenu':
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+
+ /**
+ * Maske anzeigen, um Benutzer zu registrieren.
+ */
+ function register()
+ {
+
+ }
+
+
+ /**
+ * Registriercode erzeugen und per E-Mail dem Benutzer mitteilen.
+ * Maske anzeigen, damit Benuter Registriercode anzeigen kann.
+ */
+ public function registercode()
+ {
+ $email_address = $this->getRequestVar('mail','mail');
+
+ if ( ! Mail::checkAddress($email_address) )
+ {
+ $this->addValidationError('mail');
+ $this->setTemplateVar('mail',$email_address);
+ $this->callSubAction('register');
+ return;
+ }
+
+
+ srand ((double)microtime()*1000003);
+ $registerCode = rand();
+
+ Session::set('registerCode',$registerCode );
+
+ // E-Mail and die eingegebene Adresse verschicken
+ $mail = new Mail($email_address,
+ 'register_commit_code','register_commit_code');
+ $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable
+
+ if ( $mail->send() )
+ {
+ $this->addNotice('','','mail_sent',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error);
+ $this->callSubAction('register');
+ return;
+ }
+ }
+
+
+
+ public function registeruserdata()
+ {
+ global $conf;
+
+ Session::set('registerMail',$this->getRequestVar('mail') );
+ // TODO: Attribut "Password" abfragen
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbname] = $dbconf['description'];
+ }
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+ $db = Session::getDatabase();
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ else
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+ }
+
+
+ /**
+ * Benutzerregistierung.
+ * Benutzer hat Best�tigungscode erhalten und eingegeben.
+ */
+ public function registercommit()
+ {
+ global $conf;
+ $this->checkForDb();
+
+ $origRegisterCode = Session::get('registerCode');
+ $inputRegisterCode = $this->getRequestVar('code');
+
+ if ( $origRegisterCode != $inputRegisterCode )
+ {
+ // Best�tigungscode stimmt nicht.
+ $this->addValidationError('code','code_not_match');
+ $this->callSubAction('registeruserdata');
+ return;
+ }
+
+ // Best�tigungscode stimmt �berein.
+ // Neuen Benutzer anlegen.
+
+ if ( !$this->hasRequestVar('username') )
+ {
+ $this->addValidationError('username');
+ $this->callSubAction('registeruserdata');
+ return;
+ }
+
+ $user = User::loadWithName( $this->getRequestVar('username') );
+ if ( $user->isValid() )
+ {
+ $this->addValidationError('username','USER_ALREADY_IN_DATABASE');
+ $this->callSubAction('registeruserdata');
+ return;
+ }
+
+ if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] )
+ {
+ $this->addValidationError('password','password_minlength',array('minlength'=>$conf['security']['password']['min_length']));
+ $this->callSubAction('registeruserdata');
+ return;
+ }
+
+ $newUser = new User();
+ $newUser->name = $this->getRequestVar('username');
+ $newUser->add();
+
+ $newUser->mail = Session::get('registerMail');
+ $newUser->save();
+
+ $newUser->setPassword( $this->getRequestVar('password'),true );
+
+ $this->addNotice('user',$newUser->name,'user_added','ok');
+ }
+
+
+
+ /**
+ * Vergessenes Kennwort zusenden lassen.
+ */
+ public function password()
+ {
+ global $conf;
+
+ // TODO: Attribut "Password" abfragen
+ foreach( $conf['database'] as $dbname=>$dbconf )
+ {
+ if ( is_array($dbconf) && $dbconf['enabled'] )
+ $dbids[$dbname] = $dbconf['description'];
+ }
+
+ $this->setTemplateVar( 'dbids',$dbids );
+
+
+ $db = Session::getDatabase();
+
+ if ( is_object($db) )
+ $this->setTemplateVar('actdbid',$db->id);
+ else
+ $this->setTemplateVar('actdbid',$conf['database']['default']);
+
+ }
+
+
+ /*
+ function changepassword()
+ {
+ }
+ */
+
+
+ /*
+ function setnewpassword()
+ {
+ $oldPw = $this->getRequestVar('password_old' );
+ $newPw1 = $this->getRequestVar('password_new_1');
+ $newPw2 = $this->getRequestVar('password_new_2');
+
+ if ( $newPw1 == $newPw2 )
+ {
+ // Aktuellen Benutzer aus der Sitzung ermitteln
+ $user = $this->getUserFromSession();
+
+ // Altes Kennwort pr�fen.
+ $ok = $user->checkPassword( $oldPw );
+
+ if ( $ok ) // Altes Kennwort ist ok.
+ {
+ $user->setPassword( $newPw1 ); // Setze neues Kennwort
+ $user->mustChangePassword = false;
+ Session::setUser($user);
+ $this->addNotice('user',$user->name,'password_set','ok');
+ }
+ else
+ {
+ // Altes Kennwort falsch.
+ $this->addNotice('user',$user->name,'password_error','error');
+ }
+ }
+ else
+ {
+ // Beide neuen Kennw�rter stimmen nicht �berein
+ $this->addNotice('user',$user->name,'passwords_not_match','error');
+ }
+ }
+ */
+
+
+ /**
+ * Einen Kennwort-Anforderungscode an den Benutzer senden.
+ */
+ public function passwordcode()
+ {
+ if ( !$this->hasRequestVar('username') )
+ {
+ $this->addValidationError('username');
+ $this->callSubAction('password');
+ return;
+ }
+
+ $this->checkForDb();
+
+ $user = User::loadWithName( $this->getRequestVar("username") );
+
+ Password::delay();
+
+ // Html::debug($user);
+ if ( $user->isValid() )
+ {
+ srand ((double)microtime()*1000003);
+ $code = rand();
+ $this->setSessionVar("password_commit_code",$code);
+
+ $eMail = new Mail( $user->mail,'password_commit_code' );
+ $eMail->setVar('name',$user->getName());
+ $eMail->setVar('code',$code);
+ if ( $eMail->send() )
+ $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK);
+ else
+ $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error);
+
+ }
+ else
+ {
+ //$this->addNotice('','user','username_not_found');
+ // Trotzdem vort�uschen, eine E-Mail zu senden, damit die G�ltigkeit
+ // eines Benutzernamens nicht von au�en gepr�ft werden kann.
+ //
+ $this->addNotice('user',$this->getRequestVar("username"),'mail_sent');
+ }
+
+ $this->setSessionVar("password_commit_name",$user->name);
+ }
+
+
+
+ /**
+ * Anzeige Formular zum Eingeben des Kennwort-Codes.
+ *
+ */
+ public function passwordinputcode()
+ {
+
+ }
+
+
+ /**
+ * Neues Kennwort erzeugen und dem Benutzer zusenden.
+ */
+ public function passwordcommit()
+ {
+ $username = $this->getSessionVar("password_commit_name");
+
+ if ( $this->getRequestVar("code")=='' ||
+ $this->getSessionVar("password_commit_code") != $this->getRequestVar("code") )
+ {
+ $this->addValidationError('code','PASSWORDCODE_NOT_MATCH');
+ $this->callSubAction('passwordinputcode');
+ return;
+ }
+
+ $user = User::loadWithName( $username );
+
+ if ( !$user->isValid() )
+ {
+ // Benutzer konnte nicht geladen werden.
+ $this->addNotice('user',$username,'error',OR_NOTICE_ERROR);
+ return;
+ }
+
+ $newPw = User::createPassword(); // Neues Kennwort erzeugen.
+
+ $eMail = new Mail( $user->mail,'password_new' );
+ $eMail->setVar('name' ,$user->getName());
+ $eMail->setVar('password',$newPw );
+
+ if ( $eMail->send() )
+ {
+ $user->setPassword( $newPw, false ); // Kennwort muss beim n�. Login ge�ndert werden.
+ $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK);
+ }
+ else
+ {
+ // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den
+ // Code per E-Mail erhalten hat.
+ $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error);
+ }
+ }
+
+
+ /**
+ * Erzeugt eine neue Sitzung.
+ */
+ private function recreateSession()
+ {
+
+ // PHP < 4.3.2 kennt die Funktion session_regenerate_id() nicht.
+ if ( version_compare(phpversion(),"4.3.2","<") )
+ {
+ $randlen = 32;
+ $randval = "0123456789abcdefghijklmnopqrstuvwxyz";
+ $newid = "";
+ for ($i = 1; $i <= $randlen; $i++)
+ {
+ $newid .= substr($randval, rand(0,(strlen($randval) - 1)), 1);
+ }
+ session_id( $newid );
+ }
+ elseif( version_compare(phpversion(),"4.3.2","==") )
+ {
+ session_regenerate_id();
+
+ // Bug in PHP 4.3.2: Session-Cookie wird nicht neu gesetzt.
+ if ( ini_get("session.use_cookies") )
+ setcookie( session_name(),session_id(),ini_get("session.cookie_lifetime"),"/" );
+ }
+ elseif ( version_compare(phpversion(),"5.1.0",">") )
+ {
+ session_regenerate_id(true);
+ }
+ else
+ {
+ // 5.1.0 > PHP >= 4.3.3
+ }
+ }
+
+
+
+
+
+
+ /**
+ * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer im aktuellen Projekt gemacht worden sind.
+ */
+ public function userprojecttimelineView()
+ {
+ $project = Session::getProject();
+ $result = $project->getMyLastChanges();
+
+ $this->setTemplateVar('timeline', $result);
+ }
+
+
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php
@@ -0,0 +1,571 @@
+<?php
+
+namespace cms\action;
+
+namespace cms\action;
+use cms\model\Element;
+use cms\model\Template;
+use cms\model\Page;
+
+
+
+use Session;
+use \Html;
+use \Text;
+
+// OpenRat Content Management System
+// Copyright (C) 2002-2009 Jan Dankert
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/**
+ * Action-Klasse zum Bearbeiten einer Seitenvorlage.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+
+class TemplateAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $defaultSubAction = 'show';
+ var $template;
+ var $element;
+
+
+ function __construct()
+ {
+ $this->template = new Template( $this->getRequestId() );
+ $this->template->load();
+ $this->setTemplateVar( 'templateid',$this->template->templateid );
+
+ if ( intval($this->getRequestVar('elementid')) != 0 )
+ {
+ $this->element = new Element( $this->getRequestVar('elementid') );
+ $this->element->load();
+ $this->setTemplateVar( 'elementid',$this->element->elementid );
+ }
+ }
+
+
+ function srcPost()
+ {
+ // Speichern des Quelltextes
+ //
+ $text = $this->getRequestVar('src','raw');
+
+ foreach( $this->template->getElementNames() as $elid=>$elname )
+ {
+ $text = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}',$text );
+ $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFEMPTY:' .$elid.':BEGIN}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY' ).':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFEMPTY:' .$elid.':END}}' ,$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFNOTEMPTY:'.$elid.':BEGIN}}',$text );
+ $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_END' ).'}}','{{IFNOTEMPTY:'.$elid.':END}}' ,$text );
+ }
+
+ $this->template->src = $text;
+ $this->template->save();
+ $this->template->load();
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+
+ function srcelementPost()
+ {
+ $text = $this->template->src;
+
+ switch( $this->getRequestVar('type') )
+ {
+ case 'addelement':
+ $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
+ break;
+
+ case 'addicon':
+ $text .= "\n".'{{->'.$this->getRequestVar('writable_elementid').'}}';
+ break;
+
+ case 'addifempty':
+ $text .= "\n".'{{IFEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
+ break;
+
+ case 'addifnotempty':
+ $text .= "\n".'{{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}} {{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
+ break;
+
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('srcelement');
+ return;
+ }
+
+ $this->template->src = $text;
+
+ $this->template->save();
+ $this->template->load();
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+ // Speichern der Template-Eigenschaftens
+ //
+ function propPost()
+ {
+
+ if ($this->getRequestVar('name') == "")
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('name');
+ return;
+ }
+ else
+ {
+ $this->template->name = $this->getRequestVar('name');
+ $this->template->save();
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+ }
+
+
+ // Speichern der Template-Eigenschaftens
+ //
+ function removePost()
+ {
+ if ( $this->getRequestVar('delete') != '' )
+ {
+ $this->template->delete();
+ $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK);
+ }
+ else
+ {
+ $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN);
+ }
+ }
+
+
+ /**
+ * Entfernen der Vorlage
+ */
+ function removeView()
+ {
+ $this->setTemplateVar('name',$this->template->name);
+ }
+
+
+ /**
+ * Anzeigen aller Seiten der Vorlage.
+ */
+ function infoView()
+ {
+ $pages = array();
+ $pageids = $this->template->getDependentObjectIds();
+
+ foreach( $pageids as $pageid )
+ {
+ $page = new Page($pageid);
+ $page->load();
+
+ $pages[$pageid] = $page->name;
+ }
+
+ $this->setTemplateVar('pages',$pages);
+ $this->setTemplateVar('id' ,$this->template->templateid);
+ }
+
+
+ // Speichern der Dateiendung
+ //
+ function extensionPost()
+ {
+ if ( $this->getRequestVar('type') == "list" )
+ $this->template->extension = $this->getRequestVar('extension');
+ else
+ $this->template->extension = $this->getRequestVar('extensiontext');
+
+ $this->template->save();
+ $this->addNotice('template',$this->template->name,'SAVED','ok');
+ }
+
+
+ function addelView()
+ {
+ // Die verschiedenen Element-Typen
+ $types = array();
+
+ foreach( Element::getAvailableTypes() as $t )
+ {
+ $types[ $t ] = 'EL_'.$t;
+ }
+
+ // Code-Element nur fuer Administratoren (da voller Systemzugriff!)
+ if ( !$this->userIsAdmin() )
+ unset( $types['code'] );
+
+ $this->setTemplateVar('types',$types);
+ }
+
+
+
+ /*
+ * Neues Element hinzufuegen.
+ */
+ function addelPost()
+ {
+
+ $name = $this->getRequestVar('name',OR_FILTER_ALPHANUM);
+ if ( empty($name) )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('addel');
+ return;
+ }
+
+ $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('type') );
+ $this->setTemplateVar('tree_refresh',true);
+
+ if ( $this->hasRequestVar('addtotemplate') )
+ {
+ $elnames = $this->template->getElementNames();
+ $elid = array_search($name,$elnames);
+ $this->template->src .= "\n".'{{'.$elid.'}}';
+ $this->template->save();
+ }
+
+ $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+ /**
+ * Eigenschaften einer Vorlage anzeigen
+ */
+ function propView()
+ {
+ $this->setTemplateVar('name' ,$this->template->name );
+ $this->setTemplateVar('extension',$this->template->extension );
+ $this->setTemplateVar('mime_type',$this->template->mimeType() );
+ }
+
+
+
+ /**
+ * Eigenschaften einer Vorlage anzeigen
+ */
+ function extensionView()
+ {
+
+ global $conf;
+ $mime_types = array();
+ foreach( $conf['mime-types'] as $ext=>$type )
+ $mime_types[$ext] = $ext.' - '.$type;
+
+ $this->setTemplateVar('mime_types',$mime_types);
+
+ $this->setTemplateVar('extension' ,$this->template->extension);
+ $this->setTemplateVar('extensiontext',$this->template->extension);
+
+ if ( isset($mime_types[$this->template->extension]) )
+ $this->setTemplateVar('type','list');
+ else
+ $this->setTemplateVar('type','text');
+ }
+
+
+
+ /**
+ * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt
+ * auf die Standardausgabe geschrieben
+ */
+ function previewView()
+ {
+ $this->setTemplateVar('preview_url',Html::url('template','show',$this->template->templateid,array('target'=>'none') ) );
+ }
+
+
+
+
+ /**
+ * Voransicht einer Vorlage
+ */
+ function showView()
+ {
+ header('Content-Type: '.$this->template->mimeType().'; charset='.$this->getCharset() );
+ $text = $this->template->src;
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+ $url = Html::url( 'element','edit',$this->template->templateid,array('elementid'=>$elid));
+
+ $text = str_replace('{{'.$elid.'}}',$element->name,
+ $text );
+ $text = str_replace('{{->'.$elid.'}}','',
+ $text );
+
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}','',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}','',
+ $text );
+
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}','',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}','',
+ $text );
+
+ unset( $element );
+ }
+
+ echo $text;
+
+ exit();
+ }
+
+
+ /**
+ * Bearbeiten einer Vorlage
+ */
+ function editView()
+ {
+ // Elemente laden
+ $list = array();
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $list[$elid] = array();
+ $list[$elid]['id' ] = $elid;
+ $list[$elid]['name' ] = $element->name;
+ $list[$elid]['description'] = $element->desc;
+ $list[$elid]['type' ] = $element->type;
+
+ unset( $element );
+ }
+ $this->setTemplateVar('elements',$list);
+
+
+ $text = Text::encodeHtml( $this->template->src );
+ $text = str_replace("\n",'<br/>',$text);
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+ $url = 'javascript:openNewAction(\''.$element->name.'\',\'element\',\''.$elid.'\');';
+
+ $text = str_replace('{{'.$elid.'}}',
+ '<a href="'.$url.'" class="element el_'.
+ $element->getTypeClass().'" title="'.$element->desc.'">{{'.
+ $element->name.'}}</a>',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '<a href="'.$url.'" class="element el_'.
+ $element->getTypeClass().'" title="'.$element->desc.'">{{->'.
+ $element->name.'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
+ $text );
+
+ unset( $element );
+ }
+
+ $this->setTemplateVar('text',$text);
+ }
+
+
+ function srcelementView()
+ {
+ $elements = array();
+ $writable_elements = array();
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $elements[$elid] = $element->name;
+
+ if ( $element->isWritable() )
+ $writable_elements[$elid] = $element->name;
+ }
+
+ $this->setTemplateVar('elements' ,$elements );
+ $this->setTemplateVar('writable_elements',$writable_elements);
+ }
+
+
+
+ /**
+ * Anzeigen des Template-Quellcodes
+ */
+ function srcView()
+ {
+ $text = $this->template->src;
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $text = str_replace('{{'.$elid.'}}',
+ '{{'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '{{->'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
+ }
+
+ $this->setTemplateVar( 'src',$text );
+
+ }
+
+
+ // Anzeigen aller Templates
+ //
+ function listingView()
+ {
+ global $conf_php;
+
+ $list = array();
+
+ foreach( Template::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['name'] = $name;
+ $list[$id]['url' ] = Html::url('template','el',$id,array());
+ }
+
+// $var['templatemodelid'] = htmlentities( $id );
+// $var['text'] = htmlentities( $text );
+ $this->setTemplateVar('templates',$list);
+ }
+
+
+ /**
+ * Anzeigen der Maske zum Veröffentlichen.
+ */
+ public function pubView()
+ {
+
+ }
+
+
+
+ /**
+ * Veröffentlichen.
+ */
+ public function pubPost()
+ {
+ $objectIds = $this->template->getDependentObjectIds();
+
+ Session::close();
+
+ foreach( $objectIds as $objectid )
+ {
+ $page = new Page( $objectid );
+
+ if ( !$page->hasRight( ACL_PUBLISH ) )
+ continue;
+
+ $page->public = true;
+ $page->publish();
+ $page->publish->close();
+
+ // foreach( $this->page->publish->publishedObjects as $o )
+ // {
+ // $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok');
+ // }
+
+ $this->addNotice( 'page',
+ $page->fullFilename,
+ 'PUBLISHED'.($page->publish->ok?'':'_ERROR'),
+ $page->publish->ok,
+ array(),
+ $page->publish->log );
+ }
+ }
+
+
+
+ /**
+ * Stellt fest, welche Menüeinträge ggf. ausgeblendet werden.
+ *
+ * @see actionClasses/Action#checkMenu($name)
+ */
+ function checkMenu( $menu ) {
+
+ switch( $menu)
+ {
+ case 'srcelement':
+ // Platzhalter nur hinzufuegbar, wenn es welche gibt.
+ return is_object($this->template) &&
+ (count($this->template->getElementIds()) > 0);
+
+ case 'remove':
+ // Entfernen von Templates nur dann erlaubt, wenn keine Seiten auf diesem Template basieren.
+ return is_object($this->template) &&
+ (count($this->template->getDependentObjectIds()) == 0);
+
+ case 'pages':
+ // Anzeige von Seiten nur dann sinnvoll, wenn es auch Seiten gibt.
+ return is_object($this->template) &&
+ (count($this->template->getDependentObjectIds()) > 0);
+
+ case 'add':
+ case 'addel':
+ return !readonly();
+
+ default:
+ return true;
+
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/TemplatelistAction.class.php b/modules/cms-core/action/TemplatelistAction.class.php
@@ -0,0 +1,233 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Element;
+use cms\model\Template;
+use Session;
+
+// OpenRat Content Management System
+// Copyright (C) 2002-2009 Jan Dankert
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/**
+ * Action-Klasse zum Bearbeiten einer Seitenvorlage.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+
+class TemplatelistAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ function __construct()
+ {
+ }
+
+
+
+ /**
+ * Bearbeiten einer Vorlage
+ */
+ function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+
+ // Anzeigen aller Templates
+ //
+ function showView()
+ {
+ global $conf_php;
+
+ $list = array();
+
+ foreach( Template::getAll() as $id=>$name )
+ {
+ $list[$id] = array();
+ $list[$id]['name'] = $name;
+ $list[$id]['id' ] = $id;
+ }
+
+// $var['templatemodelid'] = htmlentities( $id );
+// $var['text'] = htmlentities( $text );
+ $this->setTemplateVar('templates',$list);
+ }
+
+
+
+ /**
+ * Vorlage hinzuf�gen.
+ */
+ function addView()
+ {
+ $this->setTemplateVar( 'templates',Template::getAll() );
+
+ $examples = array();
+ $dir = opendir( 'examples/templates');
+ while( $file = readdir($dir) )
+ {
+ if ( substr($file,0,1) != '.')
+ {
+ $examples[$file] = $file;
+ }
+ }
+
+ $this->setTemplateVar( 'examples',$examples );
+ $this->setTemplateVar( 'templateid','' );
+ $this->setTemplateVar( 'example','' );
+ }
+
+
+
+ function addPost()
+ {
+ // Hinzufuegen eines Templates
+ if ( $this->getRequestVar('name') == '' )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ return;
+ }
+
+ // Hinzufuegen eines Templates
+ switch( $this->getRequestVar('type') )
+ {
+ case 'empty':
+
+ // Neues Template anlegen.
+ $template = new Template();
+ $template->add( $this->getRequestVar('name') );
+ $this->addNotice('template',$template->name,'ADDED','ok');
+ break;
+
+ case 'copy':
+
+ $copy_templateid = intval($this->getRequestVar('templateid') );
+
+ if ( $copy_templateid == 0 )
+ {
+ $this->addValidationError('templateid');
+ return;
+ }
+
+ // Neues Template anlegen.
+ $template = new Template();
+ $template->add( $this->getRequestVar('name') );
+ $this->addNotice('template',$template->name,'ADDED','ok');
+
+ // Template kopieren.
+ $copy_template = new Template( $copy_templateid );
+ $copy_template->load();
+ $elementMapping = array();
+ foreach( $copy_template->getElements() as $element )
+ {
+ /* @type $element Element */
+ $element->load();
+ $oldelementId = $element->elementid;
+ $element->templateid = $template->templateid;
+ $element->add();
+ $element->save();
+
+ $elementMapping[$oldelementId] = $element->elementid;
+ }
+
+ $project = Session::getProject();
+ foreach( $project->getModelIds() as $modelid )
+ {
+ // Template laden
+ $copy_template->modelid = $modelid;
+ $copy_template->load();
+
+ $template->modelid = $modelid;
+ $src = $copy_template->src;
+
+ // Elemente im Quelltext an die geänderten Element-Idn anpassen.
+ foreach( $elementMapping as $oldId=>$newId)
+ $src = str_replace('{{'.$oldId.'}}','{{'.$newId.'}}',$src);
+
+ $template->src = $src;
+ $template->extension = $copy_template->extension;
+ $template->save();
+ }
+
+ $this->addNotice('template',$copy_template->name,'COPIED','ok');
+
+ break;
+
+ case 'example':
+
+ // Neues Template anlegen.
+ $template = new Template();
+
+ $model = Session::getProjectModel();
+ $template->modelid = $model->modelid;
+
+ $template->add( $this->getRequestVar('name') );
+
+ $example = parse_ini_file('examples/templates/'.$this->getRequestVar('example'),true);
+
+ foreach( $example as $exampleKey=>$exampleElement )
+ {
+ if ( !is_array($exampleElement) )
+ {
+ $template->$exampleKey = $exampleElement;
+ }
+ else
+ {
+ $element = new Element();
+ $element->templateid = $template->templateid;
+ $element->name = $exampleKey;
+ $element->writable = true;
+ $element->add();
+
+ foreach( $exampleElement as $ePropName=>$ePropValue)
+ $element->$ePropName = $ePropValue;
+
+ $element->defaultText = str_replace(';',"\n",$element->defaultText);
+ $element->save();
+// Html::debug($element,"Element");
+ }
+ }
+// Html::debug($template,"Template");
+ $template->name = $this->getRequestVar('name');
+ $template->src = str_replace(';',"\n",$template->src);
+
+ foreach( $template->getElementNames() as $elid=>$elname )
+ {
+ $template->src = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}' ,$template->src );
+ $template->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$template->src );
+ }
+
+ $template->save();
+ $this->addNotice('template',$template->name,'ADDED','ok');
+
+ break;
+ default:
+ $this->addValidationError('type');
+ $this->callSubAction('add');
+ return;
+ }
+
+
+ $this->setTemplateVar('tree_refresh',true);
+ }
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/TitleAction.class.php b/modules/cms-core/action/TitleAction.class.php
@@ -0,0 +1,134 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Project;
+use cms\model\Object;
+use cms\model\Language;
+use cms\model\Model;
+
+use Session;
+use \Html;
+// OpenRat Content Management System
+// Copyright (C) 2002-2009 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+/**
+ * Actionklasse zum Anzeigen der Titelleiste.
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class TitleAction extends Action
+{
+ public $security = SECURITY_GUEST;
+
+ /**
+ * Fuellen der Variablen und Anzeigen der Titelleiste
+ */
+ public function showView()
+ {
+ $this->setTemplateVar('buildinfo',OR_TITLE.' '.OR_VERSION.' - build '.config('build','build') );
+
+ $user = Session::getUser();
+ if ( !is_object($user) )
+ return; // Kein Benutzer angemeldet.
+
+
+ $db = Session::getDatabase();
+ $this->setTemplateVar('dbname',$db->conf['name'].(readonly()?' ('.lang('readonly').')':''));
+ $this->setTemplateVar('dbid' ,$db->id);
+
+ $databases = array();
+
+ $this->setTemplateVar('username' ,$user->name );
+ $this->setTemplateVar('userfullname',$user->fullname);
+
+ $project = Session::getProject();
+ if ( is_object($project) )
+ {
+ $this->setTemplateVar('projectname',$project->name);
+ $this->setTemplateVar('projects' ,Project::getAllProjects() );
+ }
+
+
+
+ $language = Session::getProjectLanguage();
+ if ( is_object($language) )
+ {
+ $this->setTemplateVar('languagename',$language->name);
+ $this->setTemplateVar('languages',Language::getAll() );
+ }
+
+ $model = Session::getProjectModel();
+ if ( is_object($model) )
+ {
+ $this->setTemplateVar('modelname',$model->name);
+ $this->setTemplateVar('models' ,Model::getAll() );
+ }
+
+ // Urls zum Benutzerprofil und zum Abmelden
+ //$this->setTemplateVar('profile_url',Html::url( 'profile' ));
+ //$this->setTemplateVar('logout_url' ,Html::url( 'index','logout' ));
+ $this->setTemplateVar('isAdmin',$this->userIsAdmin() );
+ $this->setTemplateVar('isLoggedIn',$this->userIsLoggedIn() );
+
+ if ( config('interface','session','auto_extend') )
+ {
+ $this->setTemplateVar('ping_url' ,Html::url('title','ping') );
+ $this->setTemplateVar('ping_timeout',ini_get('session.gc_maxlifetime')-60 );
+ }
+ }
+
+
+ public function pingView()
+ {
+ $this->setTemplateVar('ping',true );
+ $this->setTemplateVar('time',date('r') );
+ }
+
+
+ public function historyView()
+ {
+ $resultList = array();
+
+ $history = Session::get('history');
+
+ if ( is_array($history) )
+ {
+ foreach( array_reverse($history) as $objectid )
+ {
+ $o = new Object( $objectid );
+ $o->load();
+ $resultList[$objectid] = array();
+ $resultList[$objectid]['url'] = Html::url($o->getType(),'',$objectid);
+ $resultList[$objectid]['type'] = $o->getType();
+ $resultList[$objectid]['name'] = $o->name;
+ $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate;
+
+ if ( $o->desc != '' )
+ $resultList[$objectid]['desc'] = $o->desc;
+ else
+ $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
+ }
+ }
+
+ $this->setTemplateVar( 'history',$resultList );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/TreeAction.class.php b/modules/cms-core/action/TreeAction.class.php
@@ -0,0 +1,377 @@
+<?php
+
+namespace cms\action;
+
+use AdministrationTree;
+use cms\model\Language;
+use cms\model\Model;
+
+use Exception;
+use JSqueeze;
+use Less_Parser;
+use Logger;
+use ObjectNotFoundException;
+use ProjectTree;
+use Session;
+use \Html;
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/**
+ * Action-Klasse zum Laden/Anzeigen des Navigations-Baumes
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+
+class TreeAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ var $tree;
+
+
+ /**
+ * ?ffnen aller Baumelemente
+ */
+ function openall()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->all();
+ Session::setTree( $this->tree );
+ }
+
+
+// function refresh()
+// {
+// $this->tree = Session::getTree();
+// $this->tree->refresh();
+// Session::setTree( $this->tree );
+// }
+
+
+ /**
+ * ?ffnen eines Baumelementes
+ */
+ function open()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->open( $this->getRequestId() );
+ Session::setTree( $this->tree );
+ }
+
+
+ /**
+ * Schlie?en eines Baumelementes
+ */
+ function close()
+ {
+ $this->tree = Session::getTree();
+ $this->tree->close( $this->getRequestId() );
+ Session::setTree( $this->tree );
+ }
+
+
+ /**
+ * Neues Laden des Baumes
+ */
+ private function load()
+ {
+ global $SESS;
+
+ $project = Session::getProject();
+ $projectid = $project->projectid;
+
+ Logger::debug( "Initializing Tree for Project ".$projectid);
+
+ if ( $projectid == -1 )
+ {
+ $this->tree = new AdministrationTree();
+ }
+ else
+ {
+ $this->tree = new ProjectTree();
+ $this->tree->projectId = $projectid;
+ }
+
+ Session::setTree( $this->tree );
+ }
+
+
+ /**
+ * Liefert ein Array mit allen Zeilen des Baumes.
+ *
+ * Ruft sich intern rekursiv auf.
+ *
+ * @param $elId
+ * @param $tiefe
+ * @param $isLast
+ * @return unknown_type
+ */
+ function outputElement( $elId,$tiefe,$isLast )
+ {
+ $treeElement = $this->tree->elements[$elId];
+
+ $zeilen = array();
+ $zeile = array();
+
+ global $class;
+ $zeile['class'] = $class;
+ if ( $this->getRequestId() == $elId )
+ $zeile['class'] = 'opened';
+ if ( $this->getRequestId() == $elId )
+ $class ='active';
+
+ if ( !isset($tree_last) )
+ $tree_last=array();
+
+ $zeile['cols'] = array();
+
+ for ( $i=1; $i<=$tiefe-1; $i++ )
+ {
+ if ( $isLast[$i] )
+ $zeile['cols'][] = 'blank';
+ else
+ $zeile['cols'][] = 'line';
+ }
+
+ if ( $tiefe == 0 )
+ {
+ }
+ elseif ( $treeElement->type != "" )
+ {
+ if ( count($treeElement->subElementIds) == 0 )
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'plus_end';
+ else $zeile['image'] = 'plus';
+
+ $zeile['image_url' ] = Html::url('tree','open',$elId);
+ $zeile['image_url_desc'] = lang('TREE_OPEN_ELEMENT');
+ }
+ else
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'minus_end';
+ else $zeile['image'] = 'minus';
+
+ $zeile['image_url' ] = Html::url('tree','close',$elId);
+ $zeile['image_url_desc'] = lang('TREE_CLOSE_ELEMENT');
+ }
+ }
+ else
+ {
+ if ( $isLast[$tiefe] )
+ $zeile['image'] = 'none_end';
+ else $zeile['image'] = 'none';
+ }
+
+
+
+ $zeile['icon'] = $treeElement->icon;
+ $zeile['text'] = $treeElement->text;
+ $zeile['desc'] = $treeElement->description;
+ $zeile['name'] = $elId;
+
+ // Url setzen
+ if ( $treeElement->url != "" )
+ $zeile['url'] = $treeElement->url;
+
+ // HTML-Target setzen
+ if ( $treeElement->target != "" )
+ $zeile['target'] = $treeElement->target;
+ else
+ $zeile['target'] = 'cms_main';
+
+ $zeile['colspan'] = 20 - count( $zeile['cols'] ) - intval(isset($zeile['image']));
+
+ $zeilen[] = $zeile;
+ // Rekursiv alle Unter-Elemente lesen
+ $nr = 0;
+ foreach( $this->tree->elements[$elId]->subElementIds as $subElementId )
+ {
+ $nr++;
+ if ( $nr == count($this->tree->elements[$elId]->subElementIds) )
+ $isLast[$tiefe+1] = true;
+ else $isLast[$tiefe+1] = false;
+
+ // Rekursiver Aufruf
+ $zeilen = array_merge( $zeilen,$this->outputElement( $subElementId,$tiefe+1,$isLast ) );
+ }
+
+ if ( $this->getRequestId() == $elId )
+ $class ='';
+
+ return $zeilen;
+ }
+
+
+ /**
+ * Anzeigen des Baumes
+ */
+ public function treeView()
+ {
+ return;
+ $this->load();
+
+ $project = Session::getProject();
+ if ( is_object($project) )
+ {
+ $this->setTemplateVar('projectname',$project->name);
+ }
+
+ $this->tree = Session::getTree();
+
+ //if ( $this->getRequestVar('target')!='tree' )
+ $this->tree->refresh();
+
+ $var = array();
+ $var['zeilen'] = $this->outputElement( 0,0,array() );
+ $var['zeilen'] = array();
+
+ $this->setTemplateVars( $var );
+ }
+
+
+ /**
+ * Anzeigen des Baumes fuer asynchrone Anfragen.
+ */
+ function loadAll()
+ {
+ $this->tree = Session::getTree();
+
+ $this->setTemplateVar( 'lines',$this->outputElement( 0,0,array() ) );
+ $this->setTemplateVar( 'tree',$this->tree->elements );
+ }
+
+ /**
+ * Anzeigen des Baumes fuer asynchrone Anfragen.
+ */
+ public function loadEntryView()
+ {
+ exit;
+ $this->tree = Session::getTree();
+
+ $this->setTemplateVar( 'lines',$this->outputElement( 0,0,array() ) );
+ $this->setTemplateVar( 'tree',$this->tree->elements );
+ }
+
+
+
+ /**
+ * Anzeigen des Baumes fuer asynchrone Anfragen.
+ */
+ public function loadBranchView()
+ {
+ $project = Session::getProject();
+ $projectid = $project->projectid;
+
+ Logger::debug( "Initializing Tree for Project ".$projectid);
+
+ if ( $projectid == -1 )
+ {
+ $tree = new AdministrationTree();
+ }
+ else
+ {
+ $tree = new ProjectTree();
+ $tree->projectId = $projectid;
+ }
+
+
+ $type = $this->getRequestVar('type');
+
+ $tree->tempElements = array();
+
+ if ( intval($this->getRequestVar('id')) != 0 )
+ $tree->$type( $this->getRequestId() );
+ else
+ $tree->$type();
+
+ $branch = array();
+ foreach( $tree->tempElements as $element )
+ {
+ $branch[] = get_object_vars($element);
+ }
+
+ $this->setTemplateVar( 'branch',$branch );
+ }
+
+
+ /**
+ * Inhalt des Projektes anzeigen.
+ */
+ private function content()
+ {
+ if ( $this->hasRequestVar('projectid') )
+ $this->load();
+
+ // Nichts - denn der Baum lädt sich über AJAX selbst.
+ }
+
+
+ /**
+ * Projekt-Einstellungen anzeigen.
+ */
+ public function settingsView()
+ {
+ $this->setTemplateVar( 'languages' ,Language::getAll() );
+ $this->setTemplateVar( 'languageid',Session::getProjectLanguage()->languageid );
+ $this->setTemplateVar( 'models' ,Model::getAll() );
+ $this->setTemplateVar( 'modelid' ,Session::getProjectModel()->modelid );
+ }
+
+ public function settingsPost()
+ {
+ $language = new Language( $this->getRequestVar(REQ_PARAM_LANGUAGE_ID,OR_FILTER_NUMBER) );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $model = new Model( $this->getRequestVar(REQ_PARAM_MODEL_ID,OR_FILTER_NUMBER) );
+ $model->load();
+ Session::setProjectModel( $model );
+
+ $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK);
+ $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK);
+ $this->refresh();
+ }
+
+
+ public function languagePost()
+ {
+ $language = new Language( $this->getRequestId() );
+ $language->load();
+ Session::setProjectLanguage( $language );
+
+ $this->addNotice('language',$language->name,'DONE',OR_NOTICE_OK);
+ $this->refresh();
+ }
+
+
+ public function modelPost()
+ {
+ $model = new Model( $this->getRequestId() );
+ $model->load();
+ Session::setProjectModel( $model );
+
+ $this->addNotice('model' ,$model->name ,'DONE',OR_NOTICE_OK);
+ $this->refresh();
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/UrlAction.class.php b/modules/cms-core/action/UrlAction.class.php
@@ -0,0 +1,189 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Folder;
+use cms\model\Url;
+
+
+
+
+
+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 $url;
+ var $defaultSubAction = 'prop';
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->url = new Url( $this->getRequestId() );
+ $this->url->load();
+ }
+
+
+
+ function remove()
+ {
+ $this->setTemplateVars( $this->url->getProperties() );
+ }
+
+
+
+ function delete()
+ {
+ if ( $this->hasRequestVar("delete") )
+ {
+ $this->url->delete();
+ $this->addNotice('url',$this->url->name,'DELETED');
+ }
+ }
+
+
+
+ /**
+ * Abspeichern der Eigenschaften
+ */
+ function propPost()
+ {
+ // Wenn Name gefuellt, dann Datenbank-Update
+ if ( $this->getRequestVar('name') != '' )
+ {
+ // Eigenschaften speichern
+ $this->url->name = $this->getRequestVar('name' ,'full');
+ $this->url->desc = $this->getRequestVar('description','full');
+
+ $this->url->save();
+ $this->url->setTimestamp();
+ Session::setObject( $this->url );
+ }
+ }
+
+
+ /**
+ * Abspeichern der Eigenschaften
+ */
+ function editPost()
+ {
+ $this->url->url = $this->getRequestVar('url');
+ $this->url->save();
+ $this->url->setTimestamp();
+ Session::setObject( $this->url );
+
+ $this->addNotice('url',$this->url->name,'SAVED',OR_NOTICE_OK);
+ }
+
+
+
+ public function editView()
+ {
+ $this->setTemplateVars( $this->url->getProperties() );
+
+ // Typ der Verknuepfung
+ $this->setTemplateVar('type' ,$this->url->getType() );
+ $this->setTemplateVar('url' ,$this->url->url );
+ }
+
+
+
+ function propView()
+ {
+ $this->setTemplateVars( $this->url->getProperties() );
+ }
+
+
+
+ function infoView()
+ {
+ $this->setTemplateVars( $this->url->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->url->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->url->objectid ] = array('id'=>$this->url->objectid,'name'=>$this->url->name,'type'=>'url','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/modules/cms-core/action/UserAction.class.php b/modules/cms-core/action/UserAction.class.php
@@ -0,0 +1,506 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Acl;
+use cms\model\User;
+use cms\model\Project;
+use cms\model\Group;
+use cms\model\Object;
+use cms\model\Language;
+
+
+use Http;
+use security\Base2n;
+use \security\Password;
+use \Session;
+use \Html;
+use \Mail;
+
+// 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 zum Bearbeiten eines Benutzers
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class UserAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ var $user;
+ var $defaultSubAction = 'edit';
+
+
+ /**
+ * UserAction constructor.
+ * @throws \ObjectNotFoundException
+ */
+ function __construct()
+ {
+ $this->user = new User( $this->getRequestId() );
+ $this->user->load();
+ $this->setTemplateVar('userid',$this->user->userid);
+ }
+
+
+ function editPost()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ // Benutzer speichern
+ $this->user->name = $this->getRequestVar('name' );
+ $this->user->fullname = $this->getRequestVar('fullname');
+ $this->user->isAdmin = $this->hasRequestVar('is_admin');
+ $this->user->ldap_dn = $this->getRequestVar('ldap_dn' );
+ $this->user->tel = $this->getRequestVar('tel' );
+ $this->user->desc = $this->getRequestVar('desc' );
+ $this->user->language = $this->getRequestVar('language');
+ $this->user->timezone = $this->getRequestVar('timezone');
+ $this->user->hotp = $this->hasRequestVar('hotp' );
+ $this->user->totp = $this->hasRequestVar('totp' );
+
+ global $conf;
+ if ( @$conf['security']['user']['show_admin_mail'] )
+ $this->user->mail = $this->getRequestVar('mail' );
+
+ $this->user->style = $this->getRequestVar('style' );
+
+ $this->user->save();
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('edit');
+ }
+ }
+
+
+
+ function removeView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+ }
+
+
+
+ function removePost()
+ {
+ if ( $this->hasRequestVar('confirm') )
+ {
+ $this->user->delete();
+ $this->addNotice('user',$this->user->name,'DELETED','ok');
+ }
+ else
+ {
+ $this->addValidationError('confirm');
+ return;
+ }
+ }
+
+
+ function addgrouptouser()
+ {
+ $this->user->addGroup( $this->getRequestVar('groupid') );
+
+ $this->addNotice('user',$this->user->name,'ADDED','ok');
+ }
+
+
+ function addgroup()
+ {
+ // Alle hinzufuegbaren Gruppen ermitteln
+ $this->setTemplateVar('groups',$this->user->getOtherGroups());
+ }
+
+
+ function delgroup()
+ {
+ $this->user->delGroup( $this->getRequestVar('groupid') );
+
+ $this->addNotice('user',$this->user->name,'DELETED','ok');
+ }
+
+
+ /**
+ * Das Kennwort wird an den Benutzer geschickt
+ *
+ * @access private
+ */
+ function mailPw( $pw )
+ {
+ $to = $this->user->fullname.' <'.$this->user->mail.'>';
+ $mail = new Mail($to,'USER_MAIL');
+
+ $mail->setVar('username',$this->user->name );
+ $mail->setVar('password',$pw );
+ $mail->setVar('name' ,$this->user->getName() );
+
+ $mail->send();
+ }
+
+
+ /**
+ * Aendern des Kennwortes
+ */
+ public function pwPost()
+ {
+ global $conf;
+
+ $pw1 = $this->getRequestVar('password1');
+ $pw2 = $this->getRequestVar('password2');
+
+ $type = $this->getRequestVar('type');
+
+ switch( $type )
+ {
+ case 'input':
+ if ( strlen($pw1)<intval($conf['security']['password']['min_length']) )
+ {
+ $this->addValidationError('password1');
+ return;
+ }
+ elseif ( $pw1 != $pw2 )
+ {
+ $this->addValidationError('password2');
+ return;
+ }
+ else
+ {
+ $newPassword = $pw1;
+ }
+ break;
+ case 'proposal';
+ $newPassword = $this->getRequestVar('password_proposal');
+ break;
+ case 'random';
+ $newPassword = $this->user->createPassword();
+ break;
+ default:
+ Http::serverError('Type unknown: '.$type);
+ }
+
+ // Kennwoerter identisch und lang genug
+ $this->user->setPassword($newPassword,!$this->hasRequestVar('timeout') ); // Kennwort setzen
+
+ // E-Mail mit dem neuen Kennwort an Benutzer senden
+ if ( $this->hasRequestVar('email') && !empty($this->user->mail) && $conf['mail']['enabled'] )
+ {
+ $this->mailPw( $newPassword );
+ $this->addNotice('user',$this->user->name,'MAIL_SENT','ok');
+ }
+
+ $this->addNotice('user',$this->user->name,'SAVED','ok');
+
+ }
+
+
+
+ function listingView()
+ {
+ $list = array();
+
+ foreach( User::getAllUsers() as $user )
+ {
+ /* @var $user User */
+ $list[$user->userid] = $user->getProperties();
+ $list[$user->userid]['url' ] = Html::url('main','user',$user->userid,
+ array(REQ_PARAM_TARGETSUBACTION=>'edit') );
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Eigenschaften des Benutzers ermitteln.
+ */
+ function editView()
+ {
+ global $conf;
+
+ $issuer = urlencode(config('application','operator'));
+ $account = $this->user->name.'@'.$_SERVER['SERVER_NAME'];
+
+ $base32 = new Base2n(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', FALSE, TRUE, TRUE);
+ $secret = $base32->encode(@hex2bin($this->user->otpSecret));
+
+ $counter = $this->user->hotpCount;
+
+ $this->setTemplateVars(
+ $this->user->getProperties() +
+ array('totpSecretUrl' => "otpauth://totp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}",
+ 'hotpSecretUrl' => "otpauth://hotp/{$issuer}:{$account}?secret={$secret}&issuer={$issuer}&counter={$counter}"
+ )
+ + array('totpToken'=>Password::getTOTPCode($this->user->otpSecret))
+ );
+
+ $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
+
+ $this->setTemplateVar('timezone_list',timezone_identifiers_list() );
+
+ $languages = explode(',',$conf['i18n']['available']);
+ foreach($languages as $id=>$name)
+ {
+ unset($languages[$id]);
+ $languages[$name] = $name;
+ }
+ $this->setTemplateVar('language_list',$languages);
+
+ }
+
+
+
+
+ /**
+ * Eigenschaften des Benutzers anzeigen
+ */
+ function infoView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $gravatarConfig = config('interface','gravatar');
+
+ $this->setTemplateVar( 'image', 'about:blank' );
+ if ( is_array($gravatarConfig) )
+ {
+ extract($gravatarConfig);
+
+ if ( isset($enable) && $enable && !empty($this->user->mail) )
+ {
+ $url = 'http://www.gravatar.com/avatar/'.md5($this->user->mail).'?';
+ if ( isset($size))
+ $url .= '&s='.$size;
+ if ( isset($default))
+ $url .= '&d='.$default;
+ if ( isset($rating))
+ $url .= '&r='.$rating;
+
+ $this->setTemplateVar( 'image', $url );
+ }
+ }
+ }
+
+
+ function membershipsView()
+ {
+ $gruppenListe = array();
+
+ $allGroups = Group::getAll();
+ $userGroups = $this->user->getGroups();
+
+ foreach( $allGroups as $id=>$name )
+ {
+
+ $hasGroup = array_key_exists($id,$userGroups);
+ $varName = 'group'.$id;
+ $gruppenListe[$id] = array('name' =>$name,
+ 'id' =>$id,
+ 'var' =>$varName,
+ 'member' =>$hasGroup
+ );
+ $this->setTemplateVar($varName,$hasGroup);
+ }
+ $this->setTemplateVar('memberships',$gruppenListe);
+
+ global $conf;
+ if ($conf['security']['authorize']['type']=='ldap')
+ $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN);
+ }
+
+
+ function membershipsPost()
+ {
+ $allGroups = Group::getAll();
+ $userGroups = $this->user->getGroups();
+ $aenderung = false;
+
+ foreach( $allGroups as $id=>$name )
+ {
+ $hasGroup = array_key_exists($id,$userGroups);
+
+ if ( !$hasGroup && $this->hasRequestVar('group'.$id) )
+ {
+ $this->user->addGroup($id);
+ $this->addNotice('group',$name,'ADDED');
+ $aenderung = true;
+ }
+
+ if ( $hasGroup && !$this->hasRequestVar('group'.$id) )
+ {
+ $this->user->delGroup($id);
+ $this->addNotice('group',$name,'DELETED');
+ $aenderung = true;
+ }
+ }
+
+ if ( ! $aenderung )
+ $this->addNotice('group',$name,'NOTHING_DONE');
+ }
+
+
+ /**
+ * Aendern des Kennwortes
+ */
+ function pwView()
+ {
+ $this->setTemplateVars( $this->user->getProperties() );
+
+ $this->setTemplateVar('password_proposal', $this->user->createPassword() );
+ }
+
+
+ /**
+ * Anzeigen der Benutzerrechte
+ * @throws \ObjectNotFoundException
+ */
+ function rightsView()
+ {
+ $rights = $this->user->getAllAcls();
+
+ $projects = array();
+
+ foreach( $rights as $acl )
+ {
+ /* @var $acl Acl */
+ if ( !isset($projects[$acl->projectid]))
+ {
+ $projects[$acl->projectid] = array();
+ $p = new Project($acl->projectid);
+ $p->load();
+ $projects[$acl->projectid]['projectname'] = $p->name;
+ $projects[$acl->projectid]['rights' ] = array();
+ }
+
+ $right = array();
+
+ if ( $acl->languageid > 0 )
+ {
+ $language = new Language($acl->languageid);
+ $language->load();
+ $right['languagename'] = $language->name;
+ }
+ else
+ {
+ $right['languagename'] = lang('ALL_LANGUAGES');
+ }
+
+
+ $o = new Object($acl->objectid);
+ $o->objectLoad();
+ $right['objectname'] = $o->name;
+ $right['objectid' ] = $o->objectid;
+ $right['objecttype'] = $o->getType();
+
+ if ( $acl->userid > 0 )
+ {
+ $user = new User($acl->userid);
+ $user->load();
+ $right['username'] = $user->name;
+ }
+ elseif ( $acl->groupid > 0 )
+ {
+ $group = new Group($acl->groupid);
+ $group->load();
+ $right['groupname'] = $group->name;
+ }
+ else
+ {
+ ;
+ // Berechtigung fuer "alle".
+ }
+
+// $show = array();
+// foreach( $acl->getProperties() as $p=>$set)
+// $show[$p] = $set;
+//
+// $right['show'] = $show;
+ $right['bits'] = $acl->getProperties();
+
+ $projects[$acl->projectid]['rights'][] = $right;
+ }
+
+ $this->setTemplateVar('projects' ,$projects );
+
+ $this->setTemplateVar('show',Acl::getAvailableRights() );
+
+ if ( $this->user->isAdmin )
+ $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',OR_NOTICE_WARN);
+ }
+
+
+ /**
+ * @param String $name Men�punkt
+ * @return boolean
+ */
+ function checkMenu( $menu )
+ {
+ global $conf;
+
+ switch( $menu )
+ {
+ case 'add':
+ case 'remove':
+ return !readonly();
+
+ case 'addgroup':
+ return !readonly() && count($this->user->getOtherGroups()) > 0;
+
+ case 'groups':
+ return !readonly() && count(Group::getAll()) > 0;
+
+ case 'pw':
+ return !readonly()
+ && @$conf['security']['auth']['type'] == 'database'
+ && !@$conf['security']['auth']['userdn'];
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Wechselt zu einem ausgewählten User.
+ * @throws \ObjectNotFoundException
+ */
+ public function switchPost()
+ {
+ // User laden...
+ $user = new User( $this->getRequestId() );
+ $user->load();
+
+ // Und in der Sitzung speichern.
+ Session::setUser( $user );
+
+ $this->refresh();
+ }
+
+
+ /**
+ * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer in allen Projekten gemacht worden sind.
+ */
+ public function historyView()
+ {
+ $result = $this->user->getLastChanges();
+ $this->setTemplateVar('timeline', $result);
+ }
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/UserlistAction.class.php b/modules/cms-core/action/UserlistAction.class.php
@@ -0,0 +1,87 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\User;
+
+// 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 zum Bearbeiten eines Benutzers
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.actions
+ */
+class UserlistAction extends Action
+{
+ public $security = SECURITY_ADMIN;
+
+ function __construct()
+ {
+ }
+
+
+ function showView()
+ {
+ $list = array();
+
+ foreach( User::getAllUsers() as $user )
+ {
+ $list[$user->userid] = $user->getProperties();
+ $list[$user->userid]['id' ] = $user->userid;
+ }
+ $this->setTemplateVar('el',$list);
+ }
+
+
+ /**
+ * Eigenschaften des Benutzers anzeigen
+ */
+ function editView()
+ {
+ $this->nextSubAction('show');
+ }
+
+
+
+ function addView()
+ {
+ }
+
+
+
+ function addPost()
+ {
+ if ( $this->getRequestVar('name') != '' )
+ {
+ $this->user = new User();
+ $this->user->add( $this->getRequestVar('name') );
+ $this->addNotice('user',$this->user->name,'ADDED','ok');
+ }
+ else
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ }
+ }
+
+
+
+
+}+
\ No newline at end of file
diff --git a/modules/cms-core/action/WebdavAction.class.php b/modules/cms-core/action/WebdavAction.class.php
@@ -0,0 +1,1217 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\User;
+use cms\model\Project;
+use cms\model\Page;
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\File;
+use cms\model\Link;
+
+
+/**
+ * Action-Klasse fuer WebDAV.<br>
+ *
+ * Das virtuelle Ordnersystem dieses CMS kann �ber das WebDAV-Protokoll
+ * dargestellt werden.
+ *
+ * Diese Klasse nimmt die Anfragen von WebDAV-Clients entgegen, zerlegt die
+ * Anfrage und erzeugt eine Antwort, die im HTTP-Body zur�ck �bertragen
+ * wird.
+ * <br>
+ * WebDAV ist spezifiziert in der RFC 2518.<br>
+ * Siehe <code>http://www.ietf.org/rfc/rfc2518.txt</code><br>
+ *
+ * Implementiert wird DAV-Level 1 (d.h. ohne LOCK).
+ *
+ * Der Zugang über WebDAV beinhaltet einige Nachteile:
+ * - Login ist nur mit Name/Kennwort möglich (kein OpenId)
+ * - Nur die Standard-Datenbank kann verwendet werden
+ * - Der Client muss Cookies unterstützen
+ *
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+
+class WebdavAction extends Action
+{
+ public $security = SECURITY_USER;
+
+ // Zahlreiche Instanzvariablen, die im Konstruktor
+ // beim Zerlegen der Anfrag gef�llt werden.
+ var $defaultSubAction = 'show';
+ var $database;
+ var $depth;
+ var $project;
+ var $folder;
+ var $obj;
+ var $filename;
+ var $pathnames = array();
+ var $uri;
+ var $headers;
+ var $requestType;
+ var $request;
+ var $destination = null;
+ var $fullSkriptName;
+ var $create;
+ var $readonly;
+ var $maxFileSize;
+ var $webdav_conf;
+ var $overwrite = false;
+
+
+ /**
+ * Im Kontruktor wird der Request analysiert und ggf. eine Authentifzierung
+ * durchgefuehrt.
+ */
+ function __construct()
+ {
+ if (!defined('E_STRICT'))
+ define('E_STRICT', 2048);
+
+ // Nicht notwendig, da wir den Error-Handler umbiegen:
+ error_reporting(0); // PHP-Fehlermeldungen zerstoeren XML-Dokument, daher ausschalten.
+
+ // PHP-Fehler ins Log schreiben, damit die Ausgabe nicht zerstoert wird.
+ if (version_compare(PHP_VERSION, '5.0.0', '>'))
+ set_error_handler('webdavErrorHandler',E_ERROR | E_WARNING);
+ else
+ set_error_handler('webdavErrorHandler');
+
+
+ //Changed tobias
+ //global $conf;
+ $prefs = new Preferences();
+ $conf = $prefs->load();
+ //End changed Tobias
+ $this->webdav_conf = $conf['webdav'];
+
+ if ( $this->webdav_conf['compliant_to_redmond'] )
+ header('MS-Author-Via: DAV' ); // Extrawurst fuer MS-Clients.
+
+ if ( $this->webdav_conf['expose_openrat'] )
+ header('X-Dav-powered-by: OpenRat CMS'); // Bandbreite verschwenden :)
+
+ Logger::trace( 'WEBDAV: URI='.$_SERVER['REQUEST_URI']);
+
+ if ( !$conf['webdav']['enable'])
+ {
+ Logger::warn( 'WEBDAV is disabled by configuration' );
+ $this->httpStatus('403 Forbidden');
+ exit;
+ }
+
+ $this->create = $this->webdav_conf['create'];
+ $this->readonly = $this->webdav_conf['readonly'];
+ $this->maxFileSize = $this->webdav_conf['max_file_size'];
+
+ Logger::debug( 'WEBDAV method is '.$_GET['subaction'] );
+
+ $this->headers = getallheaders();
+ /* DAV compliant servers MUST support the "0", "1" and
+ * "infinity" behaviors. By default, the PROPFIND method without a Depth
+ * header MUST act as if a "Depth: infinity" header was included. */
+ if ( !isset($this->headers['Depth']) )
+ $this->depth = 1;
+ elseif ( strtolower($this->headers['Depth'])=='infinity')
+ $this->depth = 1;
+ else
+ $this->depth = intval($this->headers['Depth']);
+
+ if ( isset($this->headers['Destination']) )
+ $this->destination = $this->headers['Destination'];
+
+ if ( isset($this->headers['Overwrite']) )
+ $this->overwrite = $this->headers['Overwrite'] == 'T';
+
+ // Pr�fen, ob Benutzer angemeldet ist.
+ $user = $this->getUserFromSession();
+
+ // Authentisierung erzwingen (au�er bei Methode OPTIONS).
+ // For the motivation for not checking OPTIONS requests see
+ // http://pear.php.net/bugs/bug.php?id=5363
+ if ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] != 'options' )
+ {
+ Logger::debug( 'Checking Authentication' );
+
+ if ( !is_object(Session::getDatabase()) )
+ $this->setDefaultDb();
+
+ $ok = false;
+ if ( isset($_SERVER['PHP_AUTH_USER']) )
+ {
+ $user = new User();
+ $user->name = $_SERVER['PHP_AUTH_USER'];
+
+ $ok = $user->checkPassword( $_SERVER['PHP_AUTH_PW'] );
+
+ if ( $ok )
+ {
+ $user->load();
+ $user->setCurrent();
+ $this->redirectWithSessionId();
+ }
+ }
+
+ if ( !$ok )
+ {
+ // Client ist nicht angemeldet, daher wird nun die
+ // Authentisierung angefordert.
+ Logger::debug( 'Requesting Client to authenticate' );
+ header('WWW-Authenticate: Basic realm="'.OR_TITLE.'"');
+ $this->httpStatus('401 Unauthorized');
+ exit;
+ }
+ }
+ elseif ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] == 'options' )
+ {
+ $this->setDefaultDb();
+ }
+
+
+ $this->fullSkriptName = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'/';
+
+ if ( $this->webdav_conf['session_in_uri'] )
+ $sos = 1+strlen(session_id())+strlen($this->webdav_conf['session_in_uri_prefix']);
+ else
+ $sos = 0;
+
+ // URL parsen.
+ $uri = substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']) + $sos);
+
+ Logger::debug( 'WebDAV: URI="'.$uri.'"' );
+
+ $uri = $this->parseURI( $uri );
+ $this->requestType = $uri['type' ];
+ $this->folder = $uri['folder' ];
+ $this->obj = $uri['object' ];
+ $this->project = $uri['project'];
+
+ $this->fullSkriptName .= implode('/',$uri['path']);
+
+ if ( is_object($this->obj) && $this->obj->isFolder )
+ $this->fullSkriptName .= '/';
+
+ /*
+ * Verzeichnisse muessen mit einem '/' enden. Falls nicht, Redirect aussfuehren.
+ *
+ * RFC 2518, 5.2 Collection Resources, Page 11:
+ * "For example, if a client invokes a
+ * method on http://foo.bar/blah (no trailing slash), the resource
+ * http://foo.bar/blah/ (trailing slash) may respond as if the operation
+ * were invoked on it, and should return a content-location header with
+ * http://foo.bar/blah/ in it. In general clients SHOULD use the "/"
+ * form of collection names."
+ */
+ if ( is_object($this->obj) &&
+ $this->obj->isFolder &&
+ $_GET['subaction'] == 'get' &&
+ substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1 ) != '/' )
+ {
+ Logger::debug( 'WebDAV: Redirecting lame client to slashyfied URL' );
+
+ header('HTTP/1.1 302 Moved Temporarily');
+ header('Location: '.$_SERVER['REQUEST_URI'].'/');
+ exit;
+ }
+
+ // Falls vorhanden, den "Destination"-Header parsen.
+ if ( isset($_SERVER['HTTP_DESTINATION']) )
+ {
+ $destUri = parse_url( $_SERVER['HTTP_DESTINATION'] );
+
+ $uri = substr($destUri['path'],strlen($_SERVER['SCRIPT_NAME'])+$sos);
+
+ // URL parsen.
+ $this->destination = $this->parseURI( $uri );
+ }
+
+ // Den Request-BODY aus der Standardeingabe lesen.
+ $this->request = implode('',file('php://input'));
+ }
+
+
+
+ /**
+ * Falls ein WebDAV-Client keine Cookies setzen kann (was HTTP/1.1 eigentlich
+ * der Fall sein sollte), kann die Session-Id in die URL eingetragen
+ * werden. Dies muss in der Konfiguration aktiviert werden.
+ */
+ function redirectWithSessionId()
+ {
+ if ( $this->webdav_conf['session_in_uri'] )
+ {
+ header('Location: '.dirname($_SERVER['REQUEST_URI']).'/'. $this->webdav_conf['session_in_uri_prefix'].session_id().'/'.basename($_SERVER['REQUEST_URI']));
+ //$this->httpStatus('303 See Other');
+ $this->httpStatus('302 Moved');
+ }
+ }
+
+
+
+ /**
+ * Da im WebDAV-Request keine Datenbank-Id angegeben werden kann, benutzen
+ * wir hier die Standard-Datenbank.
+ */
+ function setDefaultDb()
+ {
+ global $conf;
+
+ if ( !isset($conf['database']['default']) )
+ {
+ Logger::error('No default database in configuration');
+ $this->httpStatus('500 Internal Server Error - no default-database in configuration');
+ }
+
+ $dbid = $conf['database']['default'];
+
+ $db = new DB( $conf['database'][$dbid] );
+ $db->id = $dbid;
+ Session::setDatabase( $db );
+ }
+
+
+
+ function allowed_methods()
+ {
+
+ if ($this->readonly)
+ return array('OPTIONS','HEAD','GET','PROPFIND'); // Readonly-Modus
+ else
+ // PROPPATCH unterstuetzen wir garnicht, aber lt. Spec sollten wir das.
+ return array('OPTIONS','HEAD','GET','PROPFIND','DELETE','PUT','COPY','MOVE','MKCOL','PROPPATCH');
+ }
+
+
+
+ /**
+ * HTTP-Methode OPTIONS.<br>
+ * <br>
+ * Es werden die verfuegbaren Methoden ermittelt und ausgegeben.
+ */
+ function options()
+ {
+ header('DAV: 1'); // Wir haben DAV-Level 1.
+ header('Allow: '.implode(', ',$this->allowed_methods()) );
+
+ $this->httpStatus( '200 OK' );
+ }
+
+
+
+ /**
+ * Setzt einen HTTP-Status.<br>
+ * <br>
+ * Es wird ein HTTP-Status gesetzt, zus�tzlich wird der Status in den Header "X-WebDAV-Status" geschrieben.<br>
+ * Ist der Status nicht 200 oder 207 (hier folgt ein BODY), wird das Skript beendet.
+ */
+ function httpStatus( $status = true )
+ {
+ if ( $status === true )
+ $status = '200 OK';
+
+ Logger::debug('WEBDAV: HTTP-Status: '.$status);
+
+ header('HTTP/1.1 '.$status);
+ header('X-WebDAV-Status: '.$status,true);
+
+ // RFC 2616 (HTTP/1.1), Section 10.4.6 "405 Method Not Allowed" says:
+ // "[...] The response MUST include an
+ // Allow header containing a list of valid methods for the requested
+ // resource."
+ //
+ // RFC 2616 (HTTP/1.1), Section 14.7 "Allow" says:
+ // "[...] An Allow header field MUST be
+ // present in a 405 (Method Not Allowed) response."
+ if ( substr($status,0,3) == '405' )
+ header('Allow: '.implode(', ',$this->allowed_methods()) );
+ }
+
+
+
+ /**
+ * WebDav-HEAD-Methode.
+ */
+ function head()
+ {
+ if ( $this->obj == null )
+ {
+ $this->httpStatus( '404 Not Found' );
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isPage )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isLink )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ elseif( $this->obj->isFile )
+ {
+ $this->httpStatus( '200 OK' );
+ }
+ }
+
+
+
+ /**
+ * WebDav-GET-Methode.
+ * Die gew�nschte Datei wird geladen und im HTTP-Body mitgeliefert.
+ */
+ function get()
+ {
+ if ( $this->obj->isFolder )
+ $this->getDirectory();
+ elseif( $this->obj->isPage )
+ {
+ $this->httpStatus( '200 OK' );
+
+ header('Content-Type: text/html');
+
+ $page = new Page( $this->obj->objectid );
+ $page->load();
+ echo '<html><head><title>OpenRat WEBDAV Access</title></head>';
+ echo '<body>';
+ echo '<h1>'.$page->full_filename().'</h1>';
+ echo '<pre>';
+ echo 'No Content available';
+ echo '</pre>';
+ echo '</body>';
+ echo '</html>';
+ }
+ elseif( $this->obj->isLink )
+ {
+ $this->httpStatus( '200 OK' );
+
+ header('Content-Type: text/plain');
+
+ $link = new Link( $this->obj->objectid );
+ $link->load();
+ echo 'url: ' .$link->url ."\n";
+ echo 'target-id: '.$link->linkedObjectId."\n";
+ }
+ elseif( $this->obj->isFile )
+ {
+ $this->httpStatus( '200 OK' );
+
+ $file = new File( $this->obj->objectid );
+ $file->load();
+
+ header('Content-Type: '.$file->mimeType() );
+ header('X-File-Id: '.$file->fileid );
+
+ // Angabe Content-Disposition
+ // - Bild soll "inline" gezeigt werden
+ // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte
+ header('Content-Disposition: inline; filename='.$file->filenameWithExtension() );
+ header('Content-Transfer-Encoding: binary' );
+ header('Content-Description: '.$file->name );
+
+ $file->write(); // Bild aus Datenbank laden und in tempor�re Datei schreiben
+
+ // Groesse des Bildes in Bytes
+ // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen
+ header('Content-Length: '.filesize($file->tmpfile()) );
+ readfile( $file->tmpfile() );
+ }
+ }
+
+
+
+ /**
+ * Erzeugt ein Unix-�hnliche Ausgabe des Verzeichnisses als HTML.
+ */
+ function getDirectory()
+ {
+ $this->httpStatus( '200 OK' );
+
+ // Verzeichnis ausgeben
+ header('Content-Type: text/html');
+ $nl = "\n";
+ $titel = 'Index of '.htmlspecialchars($this->fullSkriptName);
+ $format = "%15s %-19s %-s\n";
+
+ echo '<html><head><title>'.$titel.'</title></head>';
+ echo '<body>';
+ echo '<h1>'.$titel.'</h1>'.$nl;
+ echo '<pre>';
+
+ printf($format, "Size", "Last modified", "Filename");
+
+ if ( $this->requestType == 'projectlist' )
+ {
+ foreach(Project::getAllProjects() as $projectName )
+ {
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $z;
+ $objektinhalt['size' ] = 1;
+ echo '<a href="'.$this->fullSkriptName.'/'.$projectName.'"> </a>';
+ }
+ }
+ elseif( $this->requestType == 'object' ) // Verzeichnisinhalt
+ {
+ $objects = $this->folder->getObjects();
+
+ foreach( $objects as $object )
+ {
+ printf($format,
+ number_format(1),
+ strftime("%Y-%m-%d %H:%M:%S",$object->lastchangeDate ),
+ '<a href="'.$object->filename.'">'.$object->filename.'</a>');
+ echo $nl;
+ }
+ }
+
+ echo '</pre>';
+ echo '</body>';
+ echo '</html>';
+ }
+
+
+
+ /**
+ * Die Methode LOCK sollte garnicht aufgerufen werden, da wir nur
+ * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 412 (Precondition failed)
+ */
+ function lock()
+ {
+ $this->httpStatus('412 Precondition failed');
+ $this->options();
+ }
+
+
+
+ /**
+ * Die Methode UNLOCK sollte garnicht aufgerufen werden, da wir nur
+ * Dav-Level 1 implementieren und dies dem Client auch mitteilen.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 412 (Precondition failed)
+ */
+ function unlock()
+ {
+ $this->httpStatus('412 Precondition failed');
+ $this->options();
+ }
+
+
+
+ /**
+ * Die Methode POST ist bei WebDav nicht sinnvoll.<br>
+ * <br>
+ * Ausgabe von HTTP-Status 405 (Method Not Allowed)
+ */
+ function post()
+ {
+ // Die Methode POST ist bei Webdav nicht sinnvoll.
+ $this->httpStatus('405 Method Not Allowed' );
+ }
+
+
+
+ /**
+ * Verzeichnis anlegen.
+ */
+ function mkcol()
+ {
+
+ if ( !empty($this->request) )
+ {
+ $this->httpStatus('415 Unsupported Media Type' ); // Kein Body erlaubt
+ }
+ elseif ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
+ }
+ elseif ( !$this->folder->hasRight( ACL_CREATE_FOLDER ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
+ }
+ elseif ( $this->obj == null )
+ {
+ // Die URI ist noch nicht vorhanden
+ $f = new Folder();
+ $f->filename = basename($this->fullSkriptName);
+ $f->parentid = $this->folder->objectid;
+ $f->projectid = $this->project->projectid;
+ $f->add();
+ $this->httpStatus('201 Created');
+ }
+ else
+ {
+ // MKCOL ist nicht moeglich, wenn die URI schon existiert.
+ Logger::warn('MKCOL-Request to an existing resource');
+ $this->httpStatus('405 Method Not Allowed' );
+ }
+ }
+
+
+
+ /**
+ * Objekt l�schen.
+ */
+ function delete()
+ {
+ if ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden' ); // Kein Schreibzugriff erlaubt
+ }
+ else
+ {
+ if ( $this->obj == null )
+ {
+ // Nicht existente URIs kann man auch nicht loeschen.
+ $this->httpStatus('404 Not Found' );
+ }
+ elseif ( ! $this->obj->hasRight( ACL_DELETE ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf die Resource nicht loeschen
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ $f = new Folder( $this->obj->objectid );
+ $f->deleteAll();
+ $this->httpStatus( true ); // OK
+ Logger::debug('Deleted folder with id '.$this->obj->objectid );
+ }
+ elseif ( $this->obj->isFile )
+ {
+ $f = new File( $this->obj->objectid );
+ $f->delete();
+ $this->httpStatus( true ); // OK
+ }
+ elseif ( $this->obj->isPage )
+ {
+ $p = new Page( $this->obj->objectid );
+ $p->delete();
+ $this->httpStatus( true ); // OK
+ }
+ elseif ( $this->obj->isLink )
+ {
+ $l = new Link( $this->obj->objectid );
+ $l->delete();
+ $this->httpStatus( true ); // OK
+ }
+
+ }
+ }
+
+
+
+ /**
+ * Kopieren eines Objektes.<br>
+ * Momentan ist nur das Kopieren einer Datei implementiert.<br>
+ * Das Kopieren von Ordnern, Verkn�pfungen und Seiten ist nicht moeglich.
+ */
+ function copy()
+ {
+ if ( $this->readonly || !$this->create )
+ {
+ Logger::error('WEBDAV: COPY request, but readonly or no creating');
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif( $this->obj == null )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ Logger::error('WEBDAV: COPY request, but Source not found');
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif ( $this->destination == null )
+ {
+ Logger::error('WEBDAV: COPY request, but no "Destination:"-Header');
+ // $this->httpStatus('405 Not Allowed' );
+ $this->httpStatus('412 Precondition failed');
+ }
+ else
+ {
+ // URL parsen.
+ $dest = $this->destination;
+ $destinationProject = $dest['project'];
+ $destinationFolder = $dest['folder' ];
+ $destinationObject = $dest['object' ];
+
+ if ( $dest['type'] != 'object' )
+ {
+ Logger::debug('WEBDAV: COPY request, but "Destination:"-Header mismatch');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( $this->project->projectid != $destinationProject->projectid )
+ {
+ // Kopieren in anderes Projekt nicht moeglich.
+ Logger::debug('WEBDAV: COPY request denied, project does not match');
+ $this->httpStatus('403 Forbidden');
+ }
+ elseif ( $destinationObject != null )
+ {
+ Logger::debug('WEBDAV: COPY request denied, Destination exists. Overwriting is not supported');
+ $this->httpStatus('403 Forbidden');
+ }
+ elseif ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
+ {
+ $this->httpStatus('403 Forbidden' ); // Benutzer darf das nicht
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isFolder)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Folder-Copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isLink)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Link copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ elseif ( is_object($destinationObject) && $destinationObject->isPage)
+ {
+ Logger::debug('WEBDAV: COPY request denied, Page copy not implemented');
+ $this->httpStatus('405 Not Allowed');
+ }
+ else
+ {
+ $f = new File();
+ $f->filename = basename($_SERVER['HTTP_DESTINATION']);
+ $f->name = '';
+ $f->parentid = $destinationFolder->objectid;
+ $f->projectid = $this->project->projectid;
+ $f->add();
+ $f->copyValueFromFile( $this->obj->objectid );
+
+ Logger::debug('WEBDAV: COPY request accepted' );
+ // Objekt wird in anderen Ordner kopiert.
+ $this->httpStatus('201 Created' );
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Verschieben eines Objektes.<br>
+ * <br>
+ * Folgende Operationen sind m�glich:<br>
+ * - Unbenennen eines Objektes (alle Typen)<br>
+ * - Verschieben eines Objektes (alle Typen) in einen anderen Ordner.<br>
+ */
+ function move()
+ {
+ if ( $this->readonly )
+ {
+ $this->httpStatus('403 Forbidden - Readonly Mode' ); // Schreibgeschuetzt
+ }
+ elseif ( !$this->create )
+ {
+ $this->httpStatus('403 Forbidden - No creation' ); // Schreibgeschuetzt
+ }
+ elseif( $this->obj == null )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ $this->httpStatus('404 Not Found' );
+ }
+ elseif( is_object($this->obj) && ! $this->obj->hasRight( ACL_WRITE ) )
+ {
+ // Was nicht da ist, laesst sich auch nicht verschieben.
+ Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
+ $this->httpStatus('403 Forbidden' );
+ }
+ elseif ( $this->destination == null )
+ {
+ Logger::error('WEBDAV: MOVE request, but no "Destination:"-Header');
+ // $this->httpStatus('405 Not Allowed' );
+ $this->httpStatus('412 Precondition failed');
+ }
+ else
+ {
+ $dest = $this->destination;
+ $destinationProject = $dest['project'];
+ $destinationFolder = $dest['folder' ];
+ $destinationObject = $dest['object' ];
+
+ if ( $dest['type'] != 'object' )
+ {
+ Logger::debug('WEBDAV: MOVE request, but "Destination:"-Header mismatch');
+ $this->httpStatus('405 Not Allowed');
+ return;
+ }
+
+ if ( is_object($destinationFolder) && ! $destinationFolder->hasRight( ACL_CREATE_FILE ) )
+ {
+ Logger::error('Source '.$this->obj->objectid.' is not writable: Forbidden');
+ $this->httpStatus('403 Forbidden' );
+ }
+
+ if ( $destinationObject != null )
+ {
+ Logger::debug('WEBDAV: MOVE request denied, destination exists');
+ $this->httpStatus('412 Precondition Failed');
+ return;
+ }
+
+ if ( $this->project->projectid != $destinationProject->projectid )
+ {
+ // Verschieben in anderes Projekt nicht moeglich.
+ Logger::debug('WEBDAV: MOVE request denied, project does not match');
+ $this->httpStatus('405 Not Allowed');
+ return;
+ }
+
+ if ( $this->folder->objectid == $destinationFolder->objectid )
+ {
+ Logger::debug('WEBDAV: MOVE request accepted, object renamed');
+ // Resource bleibt in gleichem Ordner.
+ $this->obj->filename = basename($_SERVER['HTTP_DESTINATION']);
+ $this->obj->objectSave(false);
+ $this->httpStatus('201 Created' );
+ return;
+ }
+
+ if ( $destinationFolder->isFolder )
+ {
+ Logger::debug('WEBDAV: MOVE request accepted, Destination: '.$destinationFolder->filename );
+ // Objekt wird in anderen Ordner verschoben.
+ $this->obj->setParentId( $destinationFolder->objectid );
+ $this->httpStatus('201 Created' );
+ return;
+ }
+
+ Logger::warn('WEBDAV: MOVE request failed' );
+ $this->httpStatus('500 Internal Server Error' );
+ }
+ }
+
+
+
+ /**
+ * Anlegen oder �berschreiben Dateien �ber PUT.<br>
+ * Dateien k�nnen neu angelegt und �berschrieben werden.<br>
+ * <br>
+ * Seiten k�nnen nicht �berschrieben werden. Wird versucht,
+ * eine Seite mit PUT zu �berschreiben, wird der Status "405 Not Allowed" gemeldet.<br>
+ */
+ function put()
+ {
+ // TODO: 409 (Conflict) wenn �bergeordneter Ordner nicht da.
+
+ if ( $this->webdav_conf['readonly'] )
+ {
+ $this->httpStatus('405 Not Allowed' );
+ }
+ elseif ( strlen($this->request) > $this->maxFileSize*1000 )
+ {
+ // Maximale Dateigroesse ueberschritten.
+ // Der Status 207 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :)
+ $this->httpStatus('507 Insufficient Storage' );
+ }
+ elseif ( $this->obj == null )
+ {
+ // Neue Datei anlegen
+ if ( !$this->webdav_conf['create'] )
+ {
+ Logger::warn('WEBDAV: Creation of files not allowed by configuration' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+
+ if ( ! $this->folder->hasRight( ACL_CREATE_FILE ) )
+ {
+ $this->httpStatus('403 Forbidden');
+ return;
+ }
+
+ $file = new File();
+ $file->filename = basename($this->fullSkriptName);
+ $file->extension = '';
+ $file->size = strlen($this->request);
+ $file->parentid = $this->folder->objectid;
+ $file->projectid = $this->project->projectid;
+ $file->value = $this->request;
+ $file->add();
+ $this->httpStatus('201 Created');
+ return;
+ }
+ elseif ( $this->obj->isFile )
+ {
+ if ( ! $this->obj->hasRight( ACL_WRITE ) )
+ {
+ Logger::debug('PUT failed, parent folder not writable by user' );
+ $this->httpStatus('403 Forbidden');
+ return;
+ }
+
+ // Bestehende Datei ueberschreiben.
+ $file = new File( $this->obj->objectid );
+ $file->saveValue( $this->request );
+ $file->setTimestamp();
+ $this->httpStatus('204 No Content');
+ Logger::debug('PUT ok, file is created' );
+ return;
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ Logger::error('PUT on folder is not supported, use PROPFIND. Lame client?' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+ else
+ {
+ // Fuer andere Objekttypen (Links, Seiten) ist kein PUT moeglich.
+ Logger::warn('PUT only available for files, pages and links are ignored' );
+ $this->httpStatus('405 Not Allowed' );
+ }
+ }
+
+
+
+ /**
+ * WebDav-Methode PROPFIND.
+ *
+ * Diese Methode wird
+ * - beim Ermitteln von Verzeichnisinhalten und
+ * - beim Ermitteln von Metainformationen zu einer Datei
+ * verwendet.
+ *
+ * Das Ergebnis wird in einer XML-Zeichenkette geliefert.
+ */
+ function propfind()
+ {
+ switch( $this->requestType )
+ {
+ case 'projectlist': // Projektliste
+
+ $inhalte = array();
+
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $z;
+ $objektinhalt['size' ] = 1;
+ $objektinhalt['name' ] = $this->fullSkriptName;
+ $objektinhalt['displayname' ] = '';
+ $objektinhalt['type'] = 'folder';
+
+ $inhalte[] = $objektinhalt;
+
+ foreach(Project::getAllProjects() as $projectid=> $projectName )
+ {
+ $project = new Project( $projectid );
+ $rootObjectId = $project->getRootObjectId();
+ $folder = new Folder( $rootObjectId );
+ $folder->load();
+
+ $objektinhalt = array();
+ $z = 30*365.25*24*60*60;
+ $objektinhalt['createdate' ] = $z;
+ $objektinhalt['lastchangedate'] = $folder->lastchangeDate;
+ $objektinhalt['size' ] = $project->size();
+ $objektinhalt['name' ] = $this->fullSkriptName.$projectName.'/';
+ $objektinhalt['displayname' ] = $projectName;
+ $objektinhalt['type'] = 'folder';
+ $inhalte[] = $objektinhalt;
+ }
+
+ $this->multiStatus( $inhalte );
+ break;
+
+ case 'object': // Verzeichnisinhalt
+
+ if ( $this->obj == null )
+ {
+ // Objekt existiert nicht.
+ Logger::trace( 'WEBDAV: PROPFIND of non-existent object');
+ $this->httpStatus('404 Not Found');
+ return;
+ }
+ elseif ( $this->obj->isFolder )
+ {
+ if ( ! $this->obj->hasRight( ACL_READ ))
+ {
+ Logger::debug( 'Folder '.$this->obj->objectid.': access denied');
+ $this->httpStatus('403 Forbidden');
+ }
+
+ $inhalte = array();
+
+ $objektinhalt = array();
+ $objektinhalt['createdate' ] = $this->obj->createDate;
+ $objektinhalt['lastchangedate'] = $this->obj->lastchangeDate;
+ $objektinhalt['name' ] = $this->fullSkriptName;
+ $objektinhalt['displayname' ] = basename($this->fullSkriptName);
+ $objektinhalt['type' ] = 'folder';
+ $objektinhalt['size' ] = 0;
+ $inhalte[] = $objektinhalt;
+
+ if ( $this->depth > 0 )
+ {
+ $objects = $this->folder->getObjects();
+ foreach( $objects as $object )
+ {
+ if ( ! $object->hasRight( ACL_READ ))
+ continue;
+
+ //$object->loadRaw();
+ $objektinhalt = array();
+ $objektinhalt['createdate' ] = $object->createDate;
+ $objektinhalt['lastchangedate'] = $object->lastchangeDate;
+ $objektinhalt['displayname' ] = $object->filename;
+
+ switch( $object->getType() )
+ {
+
+ case OR_TYPE_FOLDER:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename.'/';
+ $objektinhalt['type'] = 'folder';
+ $objektinhalt['size'] = 0;
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_FILE:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $file = new File($object->objectid);
+ $file->load();
+ $objektinhalt['size'] = $file->size;
+ $objektinhalt['mime'] = 'application/x-non-readable';
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_LINK:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $objektinhalt['size'] = 0;
+ $objektinhalt['mime'] = 'application/x-non-readable';
+ $inhalte[] = $objektinhalt;
+ break;
+ case OR_TYPE_PAGE:
+ $objektinhalt['name'] = $this->fullSkriptName.$object->filename;
+ $objektinhalt['type'] = 'file';
+ $objektinhalt['size'] = 0;
+ $inhalte[] = $objektinhalt;
+ break;
+ default:
+ }
+ }
+ }
+ Logger::trace( 'WEBDAV: PROPFIND-2');
+
+// if ( count($inhalte)==0 )
+// $inhalte[] = array('createdate'=>0,'lastchangedate'=>0,'name'=>'empty','size'=>0,'type'=>'file');
+
+ Logger::trace('Anzahl Dateien:'.count($inhalte));
+ $this->multiStatus( $inhalte );
+ }
+ else
+ {
+ $object = $this->obj;
+ Logger::trace( 'WEBDAV: PROPFIND of file');
+ $objektinhalt = array();
+ $objektinhalt = array();
+ $objektinhalt['name'] = $this->fullSkriptName.'/'.$object->filename.'/';
+ $objektinhalt['displayname'] = $object->filename;
+ $objektinhalt['createdate' ] = $object->createDate;
+ $objektinhalt['lastchangedate'] = $object->lastchangeDate;
+ $file = new File( $this->obj->objectid );
+ $file->load();
+ $objektinhalt['size' ] = $file->size;
+ $objektinhalt['type' ] = 'file';
+
+
+ $this->multiStatus( array($objektinhalt) );
+ }
+ break;
+
+ default:
+ Logger::warn('Internal Error, unknown request type: '. $this->requestType);
+ $this->httpStatus('500 Internal Server Error');
+ }
+ }
+
+
+ /**
+ * Webdav-Methode PROPPATCH ist nicht implementiert.
+ */
+ function proppatch()
+ {
+ // TODO: Multistatus erzeugen.
+ // Evtl. ist '409 Conflict' besser?
+ $this->httpStatus('405 Not Allowed');
+ }
+
+
+ /**
+ * Erzeugt einen Multi-Status.
+ * @access private
+ */
+ function multiStatus( $files )
+ {
+ $this->httpStatus('207 Multi-Status');
+ header('Content-Type: text/xml; charset=utf-8');
+
+ $response = '';
+ $response .= '<?xml version="1.0" encoding="utf-8" ?>';
+ $response .= '<d:multistatus xmlns:d="DAV:">';
+
+ foreach( $files as $file )
+ $response .= $this->getResponse( $file['name'],$file );
+
+ $response .= '</d:multistatus>';
+ Logger::trace('PROPFIND: '.$response);
+
+ $response = utf8_encode($response);
+
+ header('Content-Length: '.strlen($response));
+ echo $response;
+ }
+
+
+ /**
+ * Erzeugt ein "response"-Element, welches in ein "multistatus"-element verwendet werden kann.
+ */
+ function getResponse( $file,$options )
+ {
+ // TODO: Nur angeforderte Elemente erzeugen.
+ $response = '';
+ $response .= '<d:response>';
+ $response .= '<d:href>'.$file.'</d:href>';
+ $response .= '<d:propstat>';
+ $response .= '<d:prop>';
+ // $response .= '<d:source></d:source>';
+ $response .= '<d:creationdate>'.date('r',$options['createdate']).'</d:creationdate>';
+ $response .= '<d:displayname>'.$options['displayname'].'</d:displayname>';
+ $response .= '<d:getcontentlength>'.$options['size'].'</d:getcontentlength>';
+ $response .= '<d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">'.date('r',$options['lastchangedate']).'</d:getlastmodified>';
+
+ if ( $options['type'] == 'folder')
+ $response .= '<d:resourcetype><d:collection/></d:resourcetype>';
+ else
+ $response .= '<d:resourcetype />';
+
+ $response .= '<d:categories />';
+ $response .= '<d:fields></d:fields>';
+
+
+
+// $response .= '<d:getcontenttype>text/html</d:getcontenttype>';
+// $response .= '<d:getcontentlength />';
+// $response .= '<d:getcontentlanguage />';
+// $response .= '<d:executable />';
+// $response .= '<d:resourcetype>';
+// $response .= '<d:collection />';
+// $response .= '</d:resourcetype>';
+// $response .= '<d:getetag />';
+
+ $response .= '</d:prop>';
+ $response .= '<d:status>HTTP/1.1 200 OK</d:status>';
+ $response .= '</d:propstat>';
+ $response .= '</d:response>';
+
+ return $response;
+ }
+
+
+
+ /**
+ * URI parsen.
+ */
+ function parseURI( $uri )
+ {
+ // Ergebnis initialisieren (damit alle Schl�ssel vorhanden sind)
+ $ergebnis = array('type' => null,
+ 'project' => null,
+ 'path' => array(),
+ 'folder' => null,
+ 'object' => null );
+
+ Logger::trace( 'WEBDAV: Parsen der URI '.$uri);
+ $uriParts = explode('/',$uri);
+
+ $nr = 0;
+ $f = null;
+ $o = null;
+ $ergebnis['type'] = 'projectlist';
+
+ foreach( $uriParts as $uriPart )
+ {
+ if ( empty( $uriPart))
+ continue;
+
+ $ergebnis['path'][] = $uriPart;
+
+ if ( $f == null )
+ {
+ // URI='/project/'
+ // Name des Projektes in der URL, es wird das Projekt geladen.
+ $ergebnis['type'] = 'object';
+
+ $p = new Project();
+ $p->name = $uriPart;
+ Logger::trace("Projektname: ".$p->name);
+ $p->loadByName();
+ $ergebnis['project'] = $p;
+ // Das Projekt hat weder Sprache noch Variante gesetzt.
+ //Session::setProjectLanguage( new Language( $this->project->getDefaultLanguageId() ) );
+ //Session::setProjectModel ( new Model ( $this->project->getDefaultModelId() ) );
+
+ $oid = $p->getRootObjectId();
+
+ $f = new Folder($oid);
+ $ergebnis['object'] = $f;
+ $ergebnis['folder'] = $f;
+
+ }
+ else
+ {
+ if ( $ergebnis['object'] == null )
+ {
+ $this->httpStatus('409 Conflict');
+ exit;
+ }
+
+ $oid = $f->getObjectIdByFileName($uriPart);
+
+ if ( $oid == 0 )
+ {
+ Logger::trace( 'WEBDAV: URL-Part does not exist: '.$uriPart);
+ $ergebnis['object'] = null;
+ }
+ else
+ {
+ Logger::trace( 'Teil '.$uriPart);
+ $o = new Object($oid);
+ $o->load();
+ $ergebnis['object'] = $o;
+
+ if ( $o->isFolder )
+ {
+ $f = new Folder($oid);
+ $ergebnis['folder'] = $f;
+ }
+ }
+ }
+ }
+
+ return $ergebnis;
+ }
+}
+
+
+
+/**
+ * Fehler-Handler fuer WEBDAV.<br>
+ * Bei einem Laufzeitfehler ist eine Ausgabe des Fehlers auf der Standardausgabe sinnlos,
+ * da der WebDAV-Client dies nicht lesen oder erkennen kann.
+ * Daher wird der Fehler-Handler umgebogen, so dass nur ein Logeintrag sowie ein
+ * Server-Fehler erzeugt wird.
+ */
+function webdavErrorHandler($errno, $errstr, $errfile, $errline)
+{
+ Logger::warn('WEBDAV ERROR: '.$errno.'/'.$errstr.'/file:'.$errfile.'/line:'.$errline);
+
+ // Wir teilen dem Client mit, dass auf dem Server was schief gelaufen ist.
+ WebdavAction::httpStatus('500 Internal Server Error, WebDAV-Request failed with "'.$errstr.'"');
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/action/WorkbenchAction.class.php b/modules/cms-core/action/WorkbenchAction.class.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace cms\action;
+
+use cms\model\Value;
+use cms\model\Folder;
+use cms\model\Object;
+
+use Logger;
+use Session;
+
+/**
+ * Action-Klasse zum Anzeigen der Workbench
+ * @author Jan Dankert
+ * @package openrat.actions
+ */
+class WorkbenchAction extends Action
+{
+ public $security = SECURITY_GUEST;
+
+ private $perspective;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ global $conf;
+ $this->perspective = Session::get('perspective');
+
+
+
+ }
+
+
+ /**
+ * Ersetzt den Inhalt mit einer anderen Datei
+ */
+ public function showView()
+ {
+ global $conf;
+ global $preselectedobjects;
+
+
+ $preselectedobjects = array();;
+ // Zuletzt geändertes Objekt laden.
+ if ( $this->perspective == 'normal' )
+ {
+ $project = Session::getProject();
+ $rootFolder = new Folder( $project->getRootObjectId() );
+ $rootFolder->load();
+ $preselectedobjects[] = $rootFolder;
+
+ if ( $conf['login']['start']['start_lastchanged_object'] )
+ {
+ $user = Session::getUser();
+
+ $objectid = Value::getLastChangedObjectInProjectByUserId($project->projectid, $user->userid);
+ if ( Object::available($objectid))
+ {
+ $object = new Object($objectid);
+ $object->load();
+
+ Logger::debug('preselecting object '.$objectid);
+ $preselectedobjects[] = $object;
+ }
+ }
+ }
+
+ global $viewconfig;
+
+ Logger::debug('Workbench is using perspektive: '.$this->perspective);
+ $viewconfig = parse_ini_file('themes/default/layout/perspective/'.$this->perspective.'.ini.php',true);
+
+ require_once('themes/default/layout/perspective/window.php');
+ require_once('themes/default/layout/perspective/'.$this->perspective.'.php');
+ // Ausgabe fertig.
+ exit;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/Auth.class.php b/modules/cms-core/auth/Auth.class.php
@@ -0,0 +1,28 @@
+<?php
+
+
+DEFINE('OR_AUTH_STATUS_SUCCESS',1);
+DEFINE('OR_AUTH_STATUS_FAILED',2);
+DEFINE('OR_AUTH_STATUS_PW_EXPIRED',3);
+DEFINE('OR_AUTH_STATUS_TOKEN_NEEDED',4);
+
+interface Auth
+{
+ /**
+ * Prüft den eingegebenen Benutzernamen und das Kennwort
+ * auf Richtigkeit.
+ *
+ * @param Benutzername
+ * @param Kennwort
+ */
+ function login( $username, $password, $token );
+
+
+ /**
+ * Ermittelt den Benutzernamen.
+ * Der Benutzername wird verwendet, um die Loginmaske vorauszufüllen.
+ */
+ function username();
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/CookieAuth.class.php b/modules/cms-core/auth/CookieAuth.class.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Authentifizierung als Gast-User.
+ *
+ * Falls konfiguriert, wird der Gast-Benutzer voreingestellt.
+ *
+ * @author dankert
+ */
+class CookieAuth implements Auth
+{
+ public function username()
+ {
+ if ( isset($_COOKIE['or_username']) )
+ return $_COOKIE['or_username'];
+ else
+ return null;
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return false;
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/DatabaseAuth.class.php b/modules/cms-core/auth/DatabaseAuth.class.php
@@ -0,0 +1,46 @@
+<?php
+
+use database\Database;
+
+/**
+ * Authentifzierung über eine externe Datenbank.
+ * @author dankert
+ *
+ */
+class DatabaseAuth implements Auth
+{
+
+ /**
+ * Login.
+ */
+ public function login( $user, $password, $token )
+ {
+ global $conf;
+
+ $authDbConf = $conf['security']['authdb'];
+
+ if ( ! $authDbConf['enable'] )
+ return false;
+
+ $authdb = new Database( $authDbConf );
+
+ $sql = $authdb->sql( $conf['security']['authdb']['sql'] );
+ $algo = $authdb->sql( $conf['security']['authdb']['hash_algo'] );
+ $sql->setString('username',$user );
+ $sql->setString('password',hash($algo,$password));
+ $row = $sql->getRow();
+ $ok = !empty($row);
+
+ // noch nicht implementiert: $authdb->close();
+
+ return $ok?OR_AUTH_STATUS_SUCCESS:OR_AUTH_STATUS_FAILED;
+ }
+
+ public function username()
+ {
+ return null;
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/GuestAuth.class.php b/modules/cms-core/auth/GuestAuth.class.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Authentifizierung als Gast-User.
+ *
+ * Falls konfiguriert, wird der Gast-Benutzer voreingestellt.
+ *
+ * @author dankert
+ */
+class GuestAuth implements Auth
+{
+ public function username()
+ {
+ global $conf;
+ $guestConf = $conf['security']['guest'];
+
+ if ( $guestConf['enable'] )
+ return $guestConf['user'];
+ else
+ return null;
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return false;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/HttpAuth.class.php b/modules/cms-core/auth/HttpAuth.class.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * HTTP-Authentifzierung.
+ *
+ * Das vom Benutzer eingegebene Kennwort wird gegen eine HTTP-Adresse
+ * geprüft, bei der HTTP-Auth aktiviert ist.
+ *
+ * @author Jan Dankert
+ */
+class HttpAuth implements Auth
+{
+
+ /**
+ * Dieses Loginmodul kann keinen Namen feststellen.
+ */
+ public function username()
+ {
+ return null;
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes.
+ *
+ * Das Kennwort wird gegen einen HTTP-Server geprüft.
+ */
+ public function login( $user, $password, $token )
+ {
+ global $conf;
+
+ $http = new Http( $conf['security']['http']['url'] );
+ $http->method = 'HEAD';
+ $http->setBasicAuthentication( $this->name, $password );
+
+ $ok = $http->request();
+
+ return $ok;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/IdentAuth.class.php b/modules/cms-core/auth/IdentAuth.class.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Authentifizierung via Ident-Server.
+ *
+ * Der Benutzername wird über einen Ident-Server, der auf dem
+ * Client installiert sein muss, ermittelt.
+ *
+ * @author dankert
+ */
+class IdentAuth implements Auth
+{
+ public function username()
+ {
+ $ip = Http::getClientIP();
+ $port = Http::getClientPort();
+ $identPort = 113;
+ if ( !$socket = @fsockopen($ip,$identPort,$errno, $errstr,10 ))
+ {
+ return null;
+ }
+
+ $line = $port.','.$_SERVER['SERVER_PORT']."\r\n";
+ @fwrite($socket, $line);
+ $line = @fgets($socket, 1000); // 1000 octets according to RFC 1413
+ fclose($socket);
+
+ $array = explode(':', $line, 4);
+ if (count($array) >= 4 && ! strcasecmp(trim($array[1]), 'USERID'))
+ {
+ $username = trim($array[3]);
+ Logger::debug('Ident: User-Id: '.$username );
+ return $username;
+ }
+ elseif (count($array) >= 3 && ! strcasecmp(trim($array[1]), 'ERROR'))
+ {
+ Logger::debug('Ident: Error: '.trim($array[2]) );
+ return null;
+ }
+ else
+ {
+ Logger::warn('Ident: Invalid ident server response: '.$line);
+ return null;
+ }
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return OR_AUTH_STATUS_FAILED;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/InternalAuth.class.php b/modules/cms-core/auth/InternalAuth.class.php
@@ -0,0 +1,97 @@
+<?php
+
+use cms\model\User;
+use security\Password;
+
+/**
+ * Authentifizierungsmodul für die interne Benutzerdatenbank.
+ *
+ * @author Jan Dankert
+ *
+ */
+class InternalAuth implements Auth
+{
+ var $mustChangePassword = false;
+
+ /**
+ * Ueberpruefen des Kennwortes
+ * ueber die Benutzertabelle in der Datenbank.
+ */
+ function login( $username, $password,$token )
+ {
+ $db = db_connection();
+
+ // Lesen des Benutzers aus der DB-Tabelle
+ $sql = $db->sql( <<<SQL
+SELECT * FROM {{user}}
+ WHERE name={name}
+SQL
+ );
+ $sql->setString('name',$username);
+
+ $row_user = $sql->getRow();
+
+ if ( empty($row_user) ) {
+
+ // Benutzer ist nicht vorhanden.
+ // Trotzdem das Kennwort hashen, um Timingattacken zu verhindern.
+ $unusedHash = Password::hash(User::pepperPassword($password),Password::bestAlgoAvailable() );
+ return false;
+ }
+
+ // Pruefen ob Kennwort mit Datenbank uebereinstimmt.
+ if ( ! Password::check(User::pepperPassword($password),$row_user['password_hash'],$row_user['password_algo']) )
+ {
+ return false;
+ }
+
+ // Behandeln von Klartext-Kennwoertern (Igittigitt).
+ if ( $row_user['password_algo'] == OR_PASSWORD_ALGO_PLAIN )
+ {
+ if ( config('security','password','force_change_if_cleartext') )
+ // Kennwort steht in der Datenbank im Klartext.
+ // Das Kennwort muss geaendert werden
+ return OR_AUTH_STATUS_PW_EXPIRED;
+
+ // Anderenfalls ist das Login zwar moeglich, aber das Kennwort wird automatisch neu gehasht, weil der beste Algo erzwungen wird.
+ // Das Klartextkennwort waere danach ueberschrieben.
+ }
+
+ if ( $row_user['password_expires'] != null && $row_user['password_expires'] < time() )
+ {
+ // Kennwort ist abgelaufen.
+
+ // Wenn das kennwort abgelaufen ist, kann es eine bestimmte Dauer noch benutzt und geändert werden.
+ // Nach Ablauf dieser Dauer wird das Login abgelehnt.
+ if ( $row_user['password_expires'] +(config('security','deny_after_expiration_duration')*60*60) < time() )
+ return false; // Abgelaufenes Kennwort wird nicht mehr akzeptiert.
+ else
+ return OR_AUTH_STATUS_PW_EXPIRED; // Kennwort ist abgelaufen, kann aber noch geändert werden.
+ }
+
+ if ( $row_user['totp'] == 1 )
+ {
+ $user = new User($row_user['id']);
+ $user->load();
+ if ( Password::getTOTPCode($user->otpSecret) == $token )
+ return true;
+ else
+ return OR_AUTH_STATUS_TOKEN_NEEDED;
+ }
+
+ if ( $row_user['hotp'] == 1 )
+ {
+ // HOTP not yet implemented.
+ }
+
+ // Benutzer wurde erfolgreich authentifiziert.
+ return true;
+ }
+
+ public function username()
+ {
+ return null;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/LdapAuth.class.php b/modules/cms-core/auth/LdapAuth.class.php
@@ -0,0 +1,74 @@
+<?php
+
+class LdapAuth implements Auth
+{
+
+ public function login($username, $password, $token)
+ {
+ global $conf;
+ $db = db_connection();
+ $this->mustChangePassword = false;
+
+ // Lesen des Benutzers aus der DB-Tabelle
+ $sql = $db->sql( <<<SQL
+SELECT * FROM {{user}}
+ WHERE name={name}
+SQL
+ );
+ $sql->setString('name',$username);
+
+ $row_user = $sql->getRow();
+ $userid = $row_user['id'];
+
+ $ldap = new Ldap();
+ $ldap->connect();
+
+ if ( empty($conf['ldap']['dn']) )
+ {
+ // Der Benutzername wird im LDAP-Verzeichnis gesucht.
+ // Falls gefunden, wird der DN (=der eindeutige Schl�ssel im Verzeichnis) ermittelt.
+ $dn = $ldap->searchUser( $username );
+
+ if ( empty($dn) )
+ {
+ Logger::debug( 'User not found in LDAP directory' );
+ return false; // Kein LDAP-Account gefunden.
+ }
+
+ Logger::debug( 'User found: '.$dn );
+ }
+ else
+ {
+ $dn = str_replace( '{user}',$username,$conf['ldap']['dn'] );
+ }
+
+ // LDAP-Login versuchen
+ $ok = $ldap->bind( $dn, $password );
+
+ Logger::debug( 'LDAP bind: '.($ok?'success':'failed') );
+
+ if ( !$ok )
+ return false;
+
+ $sucheAttribut = $conf['ldap']['authorize']['group_name'];
+ $sucheFilter = str_replace('{dn}',$dn,$conf['ldap']['authorize']['group_filter']);
+
+ $this->groups = $ldap->searchAttribute( $sucheFilter, $sucheAttribut );
+ $user = new User( $userid );
+
+ // Html::debug($this->groups,'Gruppen/Ids des Benutzers');
+
+ // Verbindung zum LDAP-Server brav beenden
+ $ldap->close();
+
+ return true;
+ }
+
+ public function username()
+ {
+ return null;
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/LdapUserDNAuth.class.php b/modules/cms-core/auth/LdapUserDNAuth.class.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * Authentifizierung gegen einen LDAP-Server.
+ *
+ * @author Jan Dankert
+ */
+class LdapUserDNAuth implements Auth
+{
+
+ /**
+ * @see Auth::login()
+ */
+ public function login($username, $password, $token)
+ {
+ $db = db_connection();
+ $this->mustChangePassword = false;
+
+ // Lesen des Benutzers aus der DB-Tabelle
+ $sql = $db->sql( <<<SQL
+SELECT * FROM {{user}}
+ WHERE name={name}
+SQL
+ );
+ $sql->setString('name',$username);
+
+ $row_user = $sql->getRow();
+
+ if ( empty($row_user) )
+ return false;
+
+ // Benutzername ist bereits in der Datenbank.
+ $userid = $row_user['id'];
+ $ldap_dn = $row_user['ldap_dn'];
+
+ if ( empty($ldap_dn ) )
+ return false;
+
+ Logger::debug( 'checking login via ldap' );
+ $ldap = new Ldap();
+ $ldap->connect();
+
+ // Benutzer ist bereits in Datenbank
+ // LDAP-Login mit dem bereits vorhandenen DN versuchen
+ $ok = $ldap->bind( $ldap_dn, $password );
+
+ // Verbindung zum LDAP-Server brav beenden
+ $ldap->close();
+
+ return $ok;
+ }
+
+ public function username()
+ {
+ return null;
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/OpenIdAuth.class.php b/modules/cms-core/auth/OpenIdAuth.class.php
@@ -0,0 +1,503 @@
+<?php
+
+
+/**
+ * Open-Id Authentisierung gem�� OpenId-Spezifikation 1.0.
+ *
+ */
+class OpenIdAuth implements Auth
+{
+ function username()
+ {
+ return null;
+ }
+
+
+ function login( $username, $password, $token )
+ {
+ return false;
+ }
+
+
+ function redirect()
+ {
+ $this->login2();
+ return $this->getRedirectUrl();
+ }
+
+
+ function checkToken()
+ {
+ $this->checkAuthentication();
+ }
+
+ /**
+ * Open-Id Server, an den die Authentisierungsanfrage gestellt wird.
+ *
+ * @var String
+ */
+ var $server;
+
+
+ /**
+ * Informationen zum Benutzer.
+ *
+ * @var Array
+ */
+ var $info;
+
+ /**
+ * Open-Id Identity.
+ *
+ * @var String
+ */
+ var $identity;
+
+ /**
+ * Fehlermeldung (falls vorhanden).
+ *
+ * @var String
+ */
+ var $error;
+
+ /**
+ * OpenId-Benutzername.
+ *
+ * @var String
+ */
+ var $user;
+
+ /**
+ * OpenId-Provider.
+ *
+ * @var String
+ */
+ var $provider;
+
+
+ var $supportAX;
+ var $supportSREG;
+ var $supportOpenId1_1;
+ var $supportOpenId2_0;
+
+
+ /**
+ * Neue Open-Id Anfrage.
+ *
+ * @param String $user
+ * @return OpenId
+ */
+ function OpenId( $provider='',$user='' )
+ {
+ $this->provider = $provider;
+ $this->user = $user;
+ }
+
+
+ /**
+ * Stellt fest, ob der Server vertrauenswuerdig ist.
+ *
+ * @return true, wenn vertrauenswuerdig.
+ */
+ function serverOk()
+ {
+ global $conf;
+ $servers = $conf['security']['openid']['trusted_server'];
+
+ if ( empty($servers) )
+ {
+ return true;
+ }
+ else
+ {
+ $serverList = explode(',',$servers);
+
+ $http = new Http($this->server);
+ if ( !in_array($http->url['host'],$serverList) )
+ {
+ $this->error = 'Server '.$this->server.' is not trusted';
+ return false;
+ }
+ else
+ return true;
+ }
+
+ }
+
+
+
+ /**
+ * Authentisierung Schritt 1.<br>
+ * Ermitteln der Identity.
+ *
+ * @return boolean TRUE, wenn Identity ermittelt wurde.
+ */
+ function login2()
+ {
+ if ( $this->provider != 'identity' )
+ {
+ $this->user = config('security','openid','provider.'.$this->provider.'.xrds_uri');
+ $this->identity = 'http://specs.openid.net/auth/2.0/identifier_select';
+ }
+ $this->supportSREG = config('security','openid','provider.'.$this->provider.'.sreg_1_0');
+ $this->supportAX = config('security','openid','provider.'.$this->provider.'.ax_1_0' );
+
+ // Schritt 1: Identity aus Yadis-Dokument laden.
+ $this->getIdentityFromYadis();
+
+ // Schritt 2: Fallback auf HTML-Dokument.
+ if ( empty($this->server) )
+ {
+ $this->getIdentityFromHtmlMetaData();
+ }
+
+ // Falls immer noch kein Servername gefunden wurde, dann Abbruch.
+ if ( empty($this->server) )
+ {
+ if ( empty($this->error) )
+ $this->error = 'Unable to locate OpenId-Server in URL';
+ return false;
+ }
+
+ if ( !$this->serverOk() )
+ return false; // Server nicht vertrauenswuerdig.
+
+ if ( empty($this->identity) )
+ // Falls die Identity bis hierher nicht deligiert wurde...
+ // Lt. Spezifikation mit Prefix "http://".
+ $this->identity = 'http://'.$this->user;
+
+ return true;
+ }
+
+
+
+ /**
+ * Erzeugt einen HTTP-Redirect auf den OpenId-Provider.
+ */
+ public function getRedirectUrl()
+ {
+ global $conf;
+
+ $this->handle = md5(microtime().session_id());
+
+ $redirHttp = new Http($this->server);
+
+ if ( $this->supportOpenId2_0 )
+ $redirHttp->requestParameter['openid.ns' ] = 'http://specs.openid.net/auth/2.0';
+
+ $redirHttp->requestParameter['openid.mode' ] = 'checkid_setup';
+ $redirHttp->requestParameter['openid.identity' ] = $this->identity;
+
+ if ( $this->supportOpenId2_0 )
+ $redirHttp->requestParameter['openid.claimed_id'] = $this->identity;
+
+
+ // Profilangaben anfordern. E-Mail wird ben�tigt, Name und Sprache sind optional.
+
+ if ( $this->supportAX )
+ {
+ Logger::info("OpenId-Server is using OpenID Attribute Exchange 1.0");
+ $redirHttp->requestParameter['openid.ns.ax' ] = 'http://openid.net/srv/ax/1.0';
+ $redirHttp->requestParameter['openid.ax.mode' ] = 'fetch_request';
+ $redirHttp->requestParameter['openid.ax.type.email' ] = 'http://axschema.org/contact/email';
+ $redirHttp->requestParameter['openid.ax.type.username' ] = 'http://axschema.org/namePerson/friendly';
+ $redirHttp->requestParameter['openid.ax.type.fullname' ] = 'http://axschema.org/namePerson';
+ $redirHttp->requestParameter['openid.ax.type.language' ] = 'http://axschema.org/pref/language';
+ $redirHttp->requestParameter['openid.ax.required' ] = 'username,email';
+ $redirHttp->requestParameter['openid.ax.if_available' ] = 'language,fullname';
+ }
+
+ if ( $this->supportSREG )
+ {
+ Logger::info("OpenId-Server is using OpenID Simple Registration Extension 1.0");
+ $redirHttp->requestParameter['openid.ns.sreg' ] = 'http://openid.net/sreg/1.0';
+ $redirHttp->requestParameter['openid.sreg.required'] = 'email,nickname';
+ $redirHttp->requestParameter['openid.sreg.optional'] = 'fullname,language';
+ }
+
+ $trustRoot = @$conf['security']['openid']['trust_root'];
+ $server = Http::getServer();
+ if ( empty($trustRoot) )
+ $trustRoot = $server;
+
+ $redirHttp->requestParameter['openid.trust_root' ] = slashify($trustRoot);
+ $redirHttp->requestParameter['openid.return_to' ] = slashify($server).'openid.'.PHP_EXT;
+ //$redirHttp->requestParameter['openid.realm' ] = slashify($server).'openid.'.PHP_EXT;
+ $redirHttp->requestParameter['openid.assoc_handle' ] = $this->handle;
+
+ return $redirHttp->getUrl();
+ }
+
+
+
+ /**
+ * Ermittelt OpenId-Server und OpenId-Identity aus Yadis-Dokument.<br>
+ *
+ * @return unknown
+ */
+ private function getIdentityFromYadis()
+ {
+ $http = new Http($this->user);
+// $http->url['host'] = $this->user;
+
+ $http->header[] = 'Accept: application/xrds+xml';
+ if ( ! $http->request() )
+ {
+ $this->error = 'Unable to get XML delegate information';
+ return false;
+ }
+
+ Logger::debug("OpenId: Found YADIS-document for ".$http->getUrl());
+ //die();
+ $p = xml_parser_create();
+ $ok = xml_parse_into_struct($p, $http->body, $vals, $index);
+ xml_parser_free($p);
+
+ foreach( $vals as $tag )
+ {
+ if ( strtolower($tag['tag']) == 'type' )
+ {
+ if ( $tag['value'] == 'http://openid.net/srv/ax/1.0' )
+ $this->supportAX = true;
+
+ if ( $tag['value'] == 'http://openid.net/sreg/1.0' )
+ $this->supportSREG = true;
+
+ if ( $tag['value'] == 'http://openid.net/signon/1.1' )
+ $this->supportOpenId1_1 = true;
+
+ if ( $tag['value'] == 'http://specs.openid.net/auth/2.0/server' )
+ $this->supportOpenId2_0 = true;
+ }
+
+ if ( strtolower($tag['tag']) == 'uri' )
+ {
+ $this->server = $tag['value'];
+ }
+
+ if ( strtolower($tag['tag']) == 'openid:delegate' )
+ {
+ $this->identity = $tag['value'];
+ }
+ }
+
+ if ( !$this->supportOpenId1_1 && !$this->supportOpenId2_0 )
+ {
+ $this->error = 'Only OpenId 1.1 and 2.0 is supported but this identity-provider does not seem to support any of these.';
+ return false;
+ }
+ if ( !$this->supportAX && !$this->supportSREG )
+ {
+ $this->error = 'The identity-provider must support either Attribute-Exchange (AX) oder Simple-Registration (SREG), but it does not seem to support any of these.';
+ return false;
+ }
+ }
+
+
+ /**
+ * Ermittelt OpenId-Server und OpenId-Identity aus HTML Meta-Tags.<br>
+ */
+ private function getIdentityFromHtmlMetaData()
+ {
+ $http = new Http($this->user);
+// $http = new Http();
+// $http->url['host'] = $this->user;
+ $http->header[] = 'Accept: text/html';
+
+ if ( ! $http->request() )
+ {
+ $this->error = 'Unable to get HTML delegate information';
+ return false;
+ }
+
+ $seite = $http->body;
+
+ // Die Meta-Tags mit regulaerem Ausdruck auslesen.
+ $treffer = array();
+ preg_match('/rel="openid.server"\s+href="(\S+)"/',$seite,$treffer);
+ if ( count($treffer) >= 1 )
+ {
+ $this->server = $treffer[1];
+ $this->supportOpenId1_1 = true;
+ }
+
+ $treffer = array();
+ preg_match('/rel="openid2.provider"\s+href="(\S+)"/',$seite,$treffer);
+ if ( count($treffer) >= 1 )
+ {
+ $this->supportOpenId2_0 = true;
+ $this->server = $treffer[1];
+ }
+
+ $treffer = array();
+ preg_match('/rel="openid.delegate"\s+href="(\S+)"/',$seite,$treffer);
+ if ( count($treffer) >= 1 )
+ $this->identity = $treffer[1];
+ }
+
+
+ /**
+ * Ermittelt den Hostnamen aus der Identity.
+ *
+ * @return String
+ */
+ public function getUserFromIdentiy()
+ {
+ if ( $this->provider == 'identity' )
+ {
+ $http = new Http($this->identity);
+ return $http->url['host'];
+ }
+ else
+ {
+ $attribute_name = config('security','openid','provider.'.$this->provider.'.map_attribute');
+ return $this->info[$attribute_name];
+ }
+ }
+
+
+ /**
+ * Open-Id Login, �berpr�fen der Anmeldung.<br>
+ * Spezifikation: http://openid.net/specs/openid-authentication-1_1.html<br>
+ * Kapitel "4.4. check_authentication"<br>
+ * <br>
+ * Im 2. Schritt (Mode "id_res") erfolgte ein Redirect vom Open-Id Provider an OpenRat zur�ck.<br>
+ * Wir befinden uns nun im darauf folgenden Request des Browsers.<br>
+ * <br>
+ * Es muss noch beim OpenId-Provider die Best�tigung eingeholt werden, danach ist der
+ * Benutzer angemeldet.<br>
+ */
+ public function checkAuthentication()
+ {
+ $queryVars = $this->getQueryParamList();
+
+ if ( $queryVars['openid.invalidate_handle'] != $this->handle )
+ {
+ Http::notAuthorized('Association-Handle mismatch.');
+ die();
+ $this->error = 'Association-Handle mismatch.';
+ return false;
+ }
+
+ if ( $queryVars['openid.mode'] != 'id_res' )
+ {
+ Http::notAuthorized('Open-Id: Unknown mode:'.$queryVars['openid.mode']);
+ die();
+
+ $this->error ='Open-Id: Unknown mode:'.$queryVars['openid.mode'];
+ return false;
+ }
+
+ if ( $this->provider=='identity' && $queryVars['openid.identity'] != $this->identity )
+ {
+ Http::notAuthorized('Open-Id: Identity mismatch. Wrong identity:'.$queryVars['openid.identity']);
+ die();
+
+ $this->error ='Open-Id: Identity mismatch. Wrong identity:'.$queryVars['openid.identity'];
+ return false;
+ }
+
+
+ $params = array();
+
+ if ( $this->supportAX )
+ // Den Namespace-Prefix für AX (attribute exchange) herausfinden.
+ // Leider kann das ein anderer Prefix sein, als wir im Request verwendet haben.
+ foreach( $queryVars as $request_key=>$request_value )
+ if ( substr($request_key,0,10)=='openid.ns.' && $request_value == 'http://openid.net/srv/ax/1.0' )
+ $axPrefix = substr($request_key,10);
+
+ foreach( $queryVars as $request_key=>$request_value )
+ {
+ // Benutzer-Attribute ermitteln.
+ // Benutzer-Attribute über SREG ermitteln.
+ if ( $this->supportSREG && substr($request_key,0,12)=='openid.sreg.' )
+ $this->info[ substr($request_key,12) ] = $request_value;
+ // Benutzer-Attribute über AX ermitteln.
+ elseif ( $this->supportAX && substr($request_key,0,14+strlen($axPrefix))=='openid.'.$axPrefix.'.value.' )
+ $this->info[ substr($request_key,14+strlen($axPrefix)) ] = $request_value;
+
+ // Alle OpenId-Parameter in den Check-Authentication-Request übertragen.
+ if ( substr($request_key,0,7)=='openid.' )
+ $params['openid.'.substr($request_key,7) ] = $request_value;
+ }
+ $params['openid.mode'] = 'check_authentication';
+
+ $checkRequest = new Http($this->server);
+
+ $checkRequest->method = 'POST'; // Spezifikation verlangt POST.
+ $checkRequest->header['Accept'] = 'text/plain';
+ $checkRequest->requestParameter = $params;
+
+ if ( ! $checkRequest->request() )
+ {
+ // Der HTTP-Request ging in die Hose.
+ $this->error = $checkRequest->error;
+ return false;
+ }
+ //Html::debug($checkRequest);
+
+ // Analyse der HTTP-Antwort, Parsen des BODYs.
+ // Die Anmeldung ist best�tigt, wenn im BODY die Zeile "is_valid:true" vorhanden ist.
+ // Siehe Spezifikation Kapitel 4.4.2
+ $result = array();
+ foreach( explode("\n",$checkRequest->body) as $line )
+ {
+ $pair = explode(':',trim($line));
+ if (count($pair)==2)
+ $result[strtolower($pair[0])] = strtolower($pair[1]);
+ }
+
+ if ( !array_key_exists('is_valid',$result) )
+ {
+ // Zeile nicht gefunden.
+ Http::notAuthorized('Undefined Open-Id response: "is_valid" expected, but not found');
+ die();
+
+ $this->error = 'Undefined Open-Id response: "is_valid" expected, but not found';
+ return false;
+ }
+ elseif ( $result['is_valid'] == 'true' )
+ {
+ // Anmeldung wurde mit "is_valid:true" best�tigt.
+ return true;
+ }
+ else
+ {
+ // Bestaetigung wurde durch den OpenId-Provider abgelehnt.
+ Http::notAuthorized('Server refused login.');
+ die();
+ $this->error = 'Server refused login.';
+ return false;
+ }
+ }
+
+
+ /**
+ * Liefert die Query-Parameter aus der aktuellen URL.<br>
+ * <br>
+ * PHP hat leider die sehr bescheuerte Angewohnheit, Punkte und Leerzeichen in Request-Variablen
+ * durch Unterstriche zu ersetzen. Diese Funktion liefert die GET-Parameter ohne diese Ersetzung.
+ *
+ * @return Parameter der aktuellen URL
+ */
+ private function getQueryParamList()
+ {
+ // Quelle: php.net
+ $str = $_SERVER['QUERY_STRING'];
+ $op = array();
+ $pairs = explode("&", $str);
+ foreach ($pairs as $pair)
+ {
+ list($k, $v) = array_map("urldecode", explode("=", $pair));
+ $op[$k] = $v;
+ }
+
+ return $op;
+ }
+
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/RememberAuth.class.php b/modules/cms-core/auth/RememberAuth.class.php
@@ -0,0 +1,61 @@
+<?php
+
+use database\Database;
+
+/**
+ * Authentifizierung mit einem Login-Token.
+ *
+ * @author dankert
+ */
+class RememberAuth implements Auth
+{
+ /**
+ * @return null
+ */
+ public function username()
+ {
+ // Ermittelt den Benutzernamen aus den Login-Cookies.
+ if ( isset($_COOKIE['or_username']) &&
+ isset($_COOKIE['or_token' ]) &&
+ isset($_COOKIE['or_dbid' ]) )
+ {
+ $name = $_COOKIE['or_username'];
+ try
+ {
+ $dbid = $_COOKIE['or_dbid'];
+
+ global $conf;
+ $db = new Database( $conf['database'][$dbid] );
+ $db->id = $dbid;
+ $db->start();
+ Session::setDatabase($db);
+
+ // Jetzt den Benutzer laden und nachschauen, ob der Token stimmt.
+ $user = User::loadWithName($name);
+ $token = $user->loginToken();
+
+ // Stimmt der Token?
+ if ( $_COOKIE['or_token'] == $token )
+ // Token stimmt, Benutzer ist damit angemeldet.
+ return $name;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ // Benutzer nicht gefunden.
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist über den Cookie nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return false;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/SSLAuth.class.php b/modules/cms-core/auth/SSLAuth.class.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Authentifizierung ueber ein SSL-Zertifikat.
+ *
+ * @author dankert
+ */
+class SSLAuth implements Auth
+{
+ public function username()
+ {
+ $conf = config('security','ssl');
+ if ( isset($_SERVER[config('security','ssl','client_cert_dn_env')]))
+ return $_SERVER[config('security','ssl','client_cert_dn_env')];
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return false;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/SingleSignonAuth.class.php b/modules/cms-core/auth/SingleSignonAuth.class.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Single-Signon-Authentifizierung.
+ *
+ * @author dankert
+ */
+class SingleSignonAuth implements Auth
+{
+ public function username()
+ {
+ }
+
+
+ /**
+ * Ueberpruefen des Kennwortes ist über Ident nicht möglich.
+ */
+ public function login( $user, $password, $token )
+ {
+ return false;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/auth/include.inc.php b/modules/cms-core/auth/include.inc.php
@@ -0,0 +1,15 @@
+<?php
+require_once( OR_AUTHCLASSES_DIR."Auth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."CookieAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."DatabaseAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."GuestAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."HttpAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."IdentAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."InternalAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."LdapAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."LdapUserDNAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."OpenIdAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."RememberAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."SingleSignonAuth.class.".PHP_EXT );
+require_once( OR_AUTHCLASSES_DIR."SSLAuth.class.".PHP_EXT );
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/.htaccess b/modules/cms-core/model/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/modules/cms-core/model/Acl.class.php b/modules/cms-core/model/Acl.class.php
@@ -0,0 +1,504 @@
+<?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.
+
+
+
+// Definition der Berechtigungs-Bits
+define('ACL_READ' ,1 );
+define('ACL_WRITE' ,2 );
+define('ACL_PROP' ,4 );
+define('ACL_DELETE' ,8 );
+define('ACL_RELEASE' ,16 );
+define('ACL_PUBLISH' ,32 );
+define('ACL_CREATE_FOLDER',64 );
+define('ACL_CREATE_FILE' ,128 );
+define('ACL_CREATE_LINK' ,256 );
+define('ACL_CREATE_PAGE' ,512 );
+define('ACL_GRANT' ,1024);
+define('ACL_TRANSMIT' ,2048);
+
+
+/**
+ * Darstellen einer Berechtigung (ACL "Access Control List")
+ * Die Berechtigung zu einem Objekt wird mit einer Liste dieser Objekte dargestellt
+ *
+ * Falls es mehrere ACLs zu einem Objekt gibt, werden die Berechtigung-Flags addiert.
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+class Acl
+{
+ /**
+ * eindeutige ID dieser ACL
+ * @type Integer
+ */
+ var $aclid;
+
+ /**
+ * ID des Objektes, f?r das diese Berechtigung gilt
+ * @type Integer
+ */
+ var $objectid = 0;
+
+ /**
+ * ID des Benutzers
+ * ( = 0 falls die Berechtigung f?r eine Gruppe gilt)
+ * @type Integer
+ */
+ var $userid = 0;
+
+ /**
+ * ID der Gruppe
+ * ( = 0 falls die Berechtigung f?r einen Benutzer gilt)
+ * @type Integer
+ */
+ var $groupid = 0;
+
+ /**
+ * ID der Sprache
+ * @type Integer
+ */
+ var $languageid = 0;
+
+ /**
+ * Name der Sprache
+ * @type String
+ */
+ var $languagename = '';
+
+ /**
+ * Es handelt sich um eine Standard-Berechtigung
+ * (Falls false, dann Zugriffs-Berechtigung)
+ * @type Boolean
+ */
+ var $isDefault = false;
+
+ /**
+ * Name des Benutzers, f?r den diese Berechtigung gilt
+ * @type String
+ */
+ var $username = '';
+
+ /**
+ * Name der Gruppe, f?r die diese Berechtigung gilt
+ * @type String
+ */
+ var $groupname = '';
+
+ /**
+ * Inhalt lesen (ist immer wahr)
+ * @type Boolean
+ */
+ var $read = true;
+
+ /**
+ * Inhalt bearbeiten
+ * @type Boolean
+ */
+ var $write = false;
+
+ /**
+ * Eigenschaften bearbeiten
+ * @type Boolean
+ */
+ var $prop = false;
+
+ /**
+ * Objekt l?schen
+ * @type Boolean
+ */
+ var $delete = false;
+
+ /**
+ * Objektinhalt freigeben
+ * @type Boolean
+ */
+ var $release = false;
+
+ /**
+ * Objekt ver?ffentlichen
+ * @type Boolean
+ */
+ var $publish = false;
+
+ /**
+ * Unterordner anlegen
+ * @type Boolean
+ */
+ var $create_folder = false;
+
+ /**
+ * Datei anlegen (bzw. hochladen)
+ * @type Boolean
+ */
+ var $create_file = false;
+
+ /**
+ * Verknuepfung anlegen
+ * @type Boolean
+ */
+ var $create_link = false;
+
+ /**
+ * Seite anlegen
+ * @type Boolean
+ */
+ var $create_page = false;
+
+ /**
+ * Berechtigungen vergeben
+ * @type Boolean
+ */
+ var $grant = false;
+
+ /**
+ * Berechtigungen an Unterobjekte vererben
+ * @type Boolean
+ */
+ var $transmit = false;
+
+
+ /**
+ * Konstruktor.
+ *
+ * @param Integer Acl-ID
+ */
+ function __construct( $aclid = 0 )
+ {
+ if ( $aclid != 0 )
+ $this->aclid = $aclid;
+ }
+
+
+ /**
+ * Laden einer ACL inklusive Benutzer-, Gruppen- und Sprachbezeichnungen.
+ * Zum einfachen Laden sollte #loadRaw() benutzt werden.
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{acl}}.*,{{user}}.name as username,{{group}}.name as groupname,{{language}}.name as languagename'.
+ ' FROM {{acl}} '.
+ ' LEFT JOIN {{user}} ON {{user}}.id = {{acl}}.userid '.
+ ' LEFT JOIN {{group}} ON {{group}}.id = {{acl}}.groupid '.
+ ' LEFT JOIN {{language}} ON {{language}}.id = {{acl}}.languageid '.
+ ' WHERE {{acl}}.id={aclid}' );
+
+ $sql->setInt('aclid',$this->aclid);
+
+ $row = $sql->getRow();
+
+ $this->setDatabaseRow( $row );
+
+ if ( intval($this->languageid)==0 )
+ $this->languagename = lang('GLOBAL_ALL_LANGUAGES');
+ else $this->languagename = $row['languagename'];
+ $this->username = $row['username' ];
+ $this->groupname = $row['groupname' ];
+ }
+
+
+ /**
+ * Laden einer ACL (ohne verknuepfte Namen).
+ * Diese Methode ist schneller als #load().
+ */
+ function loadRaw()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * '.
+ ' FROM {{acl}} '.
+ ' WHERE {{acl}}.id={aclid}' );
+
+ $sql->setInt('aclid',$this->aclid);
+
+ $row = $sql->getRow();
+
+ $this->setDatabaseRow( $row );
+ }
+
+
+ /**
+ * Setzt die Eigenschaften des Objektes mit einer Datenbank-Ergebniszeile.
+ *
+ * @param row Ergebniszeile aus ACL-Datenbanktabelle
+ */
+ function setDatabaseRow( $row )
+ {
+ $this->aclid = $row['id'];
+
+ $this->write = ( $row['is_write' ] == '1' );
+ $this->prop = ( $row['is_prop' ] == '1' );
+ $this->delete = ( $row['is_delete' ] == '1' );
+ $this->release = ( $row['is_release' ] == '1' );
+ $this->publish = ( $row['is_publish' ] == '1' );
+ $this->create_folder = ( $row['is_create_folder'] == '1' );
+ $this->create_file = ( $row['is_create_file' ] == '1' );
+ $this->create_page = ( $row['is_create_page' ] == '1' );
+ $this->create_link = ( $row['is_create_link' ] == '1' );
+ $this->grant = ( $row['is_grant' ] == '1' );
+ $this->transmit = ( $row['is_transmit' ] == '1' );
+
+ $this->objectid = intval($row['objectid' ]);
+ $this->languageid = intval($row['languageid']);
+ $this->userid = intval($row['userid' ]);
+ $this->groupid = intval($row['groupid' ]);
+ }
+
+
+ /**
+ * Erzeugt eine Liste aller Berechtigungsbits dieser ACL.
+ *
+ * @return Array (Schluessel=Berechtigungstyp, Wert=boolean)
+ */
+ function getProperties()
+ {
+ return Array( 'read' => true,
+ 'write' => $this->write,
+ 'prop' => $this->prop,
+ 'create_folder'=> $this->create_folder,
+ 'create_file' => $this->create_file,
+ 'create_link' => $this->create_link,
+ 'create_page' => $this->create_page,
+ 'delete' => $this->delete,
+ 'release' => $this->release,
+ 'publish' => $this->publish,
+ 'grant' => $this->grant,
+ 'transmit' => $this->transmit,
+ 'is_default' => $this->isDefault,
+ 'userid' => $this->userid,
+ 'username' => $this->username,
+ 'groupid' => $this->groupid,
+ 'groupname' => $this->groupname,
+ 'languageid' => $this->languageid,
+ 'languagename' => $this->languagename,
+ 'objectid' => $this->objectid );
+
+ }
+
+
+ /**
+ * Erzeugt eine Liste aller möglichen Berechtigungstypen.
+ *
+ * @return 0..n-Array
+ */
+ function getAvailableRights()
+ {
+ return array( 'read',
+ 'write',
+ 'prop',
+ 'create_folder',
+ 'create_file',
+ 'create_link',
+ 'create_page',
+ 'delete',
+ 'release',
+ 'publish',
+ 'grant',
+ 'transmit' );
+
+ }
+
+
+ /**
+ * Erzeugt eine Bitmaske mit den Berechtigungen dieser ACL.
+ *
+ * @return Integer Bitmaske
+ */
+ function getMask()
+ {
+ // intval(boolean) erzeugt numerisch 0 oder 1 :)
+ $this->mask = ACL_READ; // immer lesen
+ $this->mask += ACL_WRITE *intval($this->write );
+ $this->mask += ACL_PROP *intval($this->prop );
+ $this->mask += ACL_DELETE *intval($this->delete );
+ $this->mask += ACL_RELEASE *intval($this->release );
+ $this->mask += ACL_PUBLISH *intval($this->publish );
+ $this->mask += ACL_CREATE_FOLDER *intval($this->create_folder);
+ $this->mask += ACL_CREATE_FILE *intval($this->create_file );
+ $this->mask += ACL_CREATE_LINK *intval($this->create_link );
+ $this->mask += ACL_CREATE_PAGE *intval($this->create_page );
+ $this->mask += ACL_GRANT *intval($this->grant );
+ $this->mask += ACL_TRANSMIT *intval($this->transmit );
+
+ \Logger::trace('mask of acl '.$this->aclid.': '.$this->mask );
+ return $this->mask;
+ }
+
+
+ /**
+ * Erzeugt eine Liste aller gesetzten Berechtigungstypen.
+ * Beispiel: Array (0:'read',1:'write',2:'transmit')
+ *
+ * @return 0..n-Array
+ */
+ function getTrueProperties()
+ {
+ $erg = array('read');
+ if ( $this->write ) $erg[] = 'write';
+ if ( $this->prop ) $erg[] = 'prop';
+ if ( $this->create_folder ) $erg[] = 'create_folder';
+ if ( $this->create_file ) $erg[] = 'create_file';
+ if ( $this->create_link ) $erg[] = 'create_link';
+ if ( $this->create_page ) $erg[] = 'create_page';
+ if ( $this->delete ) $erg[] = 'delete';
+ if ( $this->release ) $erg[] = 'release';
+ if ( $this->publish ) $erg[] = 'publish';
+ if ( $this->grant ) $erg[] = 'grant';
+ if ( $this->transmit ) $erg[] = 'transmit';
+
+ return $erg;
+ }
+
+
+
+ /**
+ * ACL unwiderruflich loeschen.
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'DELETE FROM {{acl}} '.
+ ' WHERE id = {aclid} '.
+ ' AND objectid= {objectid}' );
+
+ $sql->setInt('aclid' ,$this->aclid );
+ $sql->setInt('objectid',$this->objectid);
+
+ $sql->query();
+
+ $this->aclid = 0;
+ }
+
+
+ /**
+ * ACL der Datenbank hinzufügen.
+ */
+ function add()
+ {
+ $db = db_connection();
+
+ if ( $this->delete )
+ $this->prop = true;
+
+ // Pruefen, ob die ACL schon existiert
+ $user_comp = intval($this->userid )>0?'={userid}':'IS NULL';
+ $group_comp = intval($this->groupid )>0?'={groupid}':'IS NULL';
+ $language_comp = intval($this->languageid)>0?'={languageid}':'IS NULL';
+
+ $stmt = $db->sql( <<<SQL
+ SELECT id FROM {{acl}}
+ WHERE userid $user_comp AND
+ groupid $group_comp AND
+ languageid $language_comp AND
+ objectid = {objectid} AND
+ is_write = {write} AND
+ is_prop = {prop} AND
+ is_create_folder = {create_folder} AND
+ is_create_file = {create_file} AND
+ is_create_link = {create_link} AND
+ is_create_page = {create_page} AND
+ is_delete = {delete} AND
+ is_release = {release} AND
+ is_publish = {publish} AND
+ is_grant = {grant} AND
+ is_transmit = {transmit}
+SQL
+);
+
+ if ( intval($this->userid) > 0 )
+ $stmt->setInt ('userid',$this->userid);
+
+ if ( intval($this->groupid) > 0 )
+ $stmt->setInt ('groupid',$this->groupid);
+
+ if ( intval($this->languageid) > 0 )
+ $stmt->setInt ('languageid',$this->languageid);
+
+ $stmt->setInt('objectid',$this->objectid);
+ $stmt->setBoolean('write' ,$this->write );
+ $stmt->setBoolean('prop' ,$this->prop );
+ $stmt->setBoolean('create_folder',$this->create_folder );
+ $stmt->setBoolean('create_file' ,$this->create_file );
+ $stmt->setBoolean('create_link' ,$this->create_link );
+ $stmt->setBoolean('create_page' ,$this->create_page );
+ $stmt->setBoolean('delete' ,$this->delete );
+ $stmt->setBoolean('release' ,$this->release );
+ $stmt->setBoolean('publish' ,$this->publish );
+ $stmt->setBoolean('grant' ,$this->grant );
+ $stmt->setBoolean('transmit' ,$this->transmit );
+
+
+ $aclid = intval($stmt->getOne());
+ if ( $aclid > 0 )
+ {
+ // Eine ACL existiert bereits, wir übernehmen diese ID
+ $this->aclid = $aclid;
+ return;
+ }
+
+
+
+
+ $stmt = $db->sql('SELECT MAX(id) FROM {{acl}}');
+ $this->aclid = intval($stmt->getOne())+1;
+
+ $stmt = $db->sql( <<<SQL
+ INSERT INTO {{acl}}
+ (id,userid,groupid,objectid,is_write,is_prop,is_create_folder,is_create_file,is_create_link,is_create_page,is_delete,is_release,is_publish,is_grant,is_transmit,languageid)
+ VALUES( {aclid},{userid},{groupid},{objectid},{write},{prop},{create_folder},{create_file},{create_link},{create_page},{delete},{release},{publish},{grant},{transmit},{languageid} )
+SQL
+);
+
+ $stmt->setInt('aclid' ,$this->aclid );
+
+ if ( intval($this->userid) == 0 )
+ $stmt->setNull('userid');
+ else
+ $stmt->setInt ('userid',$this->userid);
+
+ if ( intval($this->groupid) == 0 )
+ $stmt->setNull('groupid');
+ else
+ $stmt->setInt ('groupid',$this->groupid);
+
+ $stmt->setInt('objectid',$this->objectid);
+ $stmt->setBoolean('write' ,$this->write );
+ $stmt->setBoolean('prop' ,$this->prop );
+ $stmt->setBoolean('create_folder',$this->create_folder );
+ $stmt->setBoolean('create_file' ,$this->create_file );
+ $stmt->setBoolean('create_link' ,$this->create_link );
+ $stmt->setBoolean('create_page' ,$this->create_page );
+ $stmt->setBoolean('delete' ,$this->delete );
+ $stmt->setBoolean('release' ,$this->release );
+ $stmt->setBoolean('publish' ,$this->publish );
+ $stmt->setBoolean('grant' ,$this->grant );
+ $stmt->setBoolean('transmit' ,$this->transmit );
+
+ if ( intval($this->languageid) == 0 )
+ $stmt->setNull('languageid');
+ else
+ $stmt->setInt ('languageid',$this->languageid);
+
+ $stmt->query();
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/model/Element.class.php b/modules/cms-core/model/Element.class.php
@@ -0,0 +1,502 @@
+<?php
+namespace cms\model;
+
+
+
+/**
+ * Diese Objektklasse stellt ein Element das.
+ *
+ * Ein Element ist ein Platzhalter in einem Template und kann verschiedenen
+ * Typs sein, z.B. Text oder ein Bild.
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+class Element
+{
+ /**
+ * Eindeutige ID dieses Elementes
+ * @type Integer
+ */
+ var $elementid;
+
+ /**
+ * Template-ID zu der dieses Elementes geh?rt
+ * @type Integer
+ */
+ var $templateid;
+
+ /**
+ * Typ des Elementes
+ * Folgende Typen sind moeglich:
+ * <ul>
+ * <li>text</li>
+ * <li>longtext</li>
+ * <li>select</li>
+ * <li>number</li>
+ * <li>link</li>
+ * <li>date</li>
+ * <li>insert</li>
+ * <li>linkinfo</li>
+ * <li>linkdate</li>
+ * <li>code</li>
+ * <li>info</li>
+ * <li>infodate</li>
+ * </ul>
+ *
+ * @type String
+ */
+ var $type;
+
+ /**
+ * Logischer Name dieses Elementes
+ * @type String
+ */
+ var $name;
+
+ /**
+ * Beschreibung zu diesem Element
+ * Zu jedem Element kann eine Beschreibung hinterlegt werden, die dem Redakteur bei der Bearbeitung
+ * der Inhalte als Bearbeitungshilfe dienen kann.
+ * @type String
+ */
+ var $desc;
+
+ /**
+ * Objekt-ID eines Ordners, aus diesem Ordner (samt Unterordner)
+ * k?nnen zu verlinkende Objekte ausgew?hlt werden
+ * @type Integer
+ */
+ var $folderObjectId = 0;
+
+ /**
+ * Vorausgew�hltes Objekt.
+ * @type Integer
+ */
+ var $defaultObjectId = 0;
+
+ /**
+ * Schalter ob dieses Element von Redakteuren bearbeiten werden kann
+ * @type Boolean
+ */
+ var $writable;
+
+ /**
+ * Schalter, ob dieses Element in allen Sprachen den gleichen Inhalt haben soll
+ * @type Boolean
+ */
+ var $allLanguages;
+
+ var $readonlyElementNames = array('copy','linkinfo','linkdate','info','infodate','code','dynamic');
+
+ /**
+ * Untertyp.
+ *
+ * @var String
+ */
+ var $subtype = '';
+ var $withIcon = false;
+ var $dateformat = 'r';
+ var $wiki = false;
+ var $html = false;
+ var $decimals = 0;
+ var $decPoint = '.';
+ var $thousandSep = '';
+ var $code = '';
+ var $defaultText = '';
+
+
+ /**
+ * Im Konstruktor wird die Element-Id gesetzt
+ * @param Integer Element-Id
+ */
+ function __construct( $elementid=0 )
+ {
+ if ( intval($elementid)!=0 )
+ $this->elementid = $elementid;
+ }
+
+
+ /**
+ * Hinzuf?gen eines Elementes
+ * Das aktuelle Element wird in die Datenbank geschrieben.
+ */
+ function add()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{element}}');
+ $this->elementid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( 'INSERT INTO {{element}}'.
+ ' (id,templateid,name,descr,type,writable) '.
+ " VALUES ( {elementid},{templateid},{name},{description},{type},{writable} ) " );
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'type' ,$this->type );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setBoolean( 'writable' ,$this->writable );
+ $sql->setString ( 'description',$this->desc );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Lesen des Elementes aus der Datenbank
+ * Alle Eigenschaften des Elementes werden aus der Datenbank gelesen
+ * @throws \ObjectNotFoundException
+ */
+ function load()
+ {
+ if ( intval($this->elementid) != 0 )
+ {
+ $db = db_connection();
+ $sql = $db->sql( <<<SQL
+SELECT * FROM {{element}}
+ WHERE id={elementid}
+SQL
+);
+ $sql->setInt( 'elementid',$this->elementid );
+ $this->setDatabaseRow( $sql->getRow() );
+ }
+ }
+
+
+ /**
+ * @param $prop
+ * @throws \ObjectNotFoundException
+ */
+ function setDatabaseRow($prop )
+ {
+ if ( count($prop) <= 0 )
+ throw new \ObjectNotFoundException("Element not found");
+
+ $this->elementid = $prop['id' ];
+ $this->templateid = $prop['templateid'];
+ $this->name = $prop['name' ];
+ $this->desc = $prop['descr' ];
+ $this->type = $prop['type' ];
+ $this->subtype = $prop['subtype' ];
+
+ $this->dateformat = $prop['dateformat'];
+ $this->wiki = ( $prop['wiki' ] == '1' );
+ $this->withIcon = ( $prop['with_icon' ] == '1' );
+ $this->html = ( $prop['html' ] == '1' );
+ $this->allLanguages = ( $prop['all_languages'] == '1' );
+ $this->writable = ( $prop['writable' ] == '1' );
+
+ if ( !$this->writable)
+ $this->withIcon = false;
+
+ $this->decimals = intval( $prop['decimals' ] );
+ $this->decPoint = strval( $prop['dec_point' ] );
+ $this->thousandSep = strval( $prop['thousand_sep' ] );
+ $this->code = strval( $prop['code' ] );
+ $this->defaultText = strval( $prop['default_text' ] );
+ $this->folderObjectId = intval( $prop['folderobjectid' ] );
+ $this->defaultObjectId = intval( $prop['default_objectid'] );
+ }
+
+
+ /**
+ * Abspeichern des Elementes
+ * Das aktuelle Element wird in der Datenbank gespeichert
+ */
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{element}}'.
+ ' SET templateid = {templateid},'.
+ ' name = {name},'.
+ ' descr = {desc},'.
+ ' type = {type},'.
+ ' subtype = {subtype},'.
+ ' with_icon = {withIcon},'.
+ ' dateformat = {dateformat},'.
+ ' wiki = {wiki},'.
+ ' html = {html},'.
+ ' all_languages = {allLanguages},'.
+ ' writable = {writable},'.
+ ' decimals = {decimals},'.
+ ' dec_point = {decPoint},'.
+ ' thousand_sep = {thousandSep},'.
+ ' code = {code},'.
+ ' default_text = {defaultText},'.
+ ' folderobjectid = {folderObjectId},'.
+ ' default_objectid= {defaultObjectId}'.
+ ' WHERE id={elementid}' );
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'desc' ,$this->desc );
+ $sql->setString ( 'type' ,$this->type );
+ $sql->setString ( 'subtype' ,$this->subtype );
+ $sql->setBoolean( 'withIcon' ,$this->withIcon );
+ $sql->setString ( 'dateformat' ,$this->dateformat );
+ $sql->setBoolean( 'wiki' ,$this->wiki );
+ $sql->setBoolean( 'html' ,$this->html );
+ $sql->setBoolean( 'writable' ,$this->writable );
+ $sql->setBoolean( 'allLanguages' ,$this->allLanguages );
+ $sql->setInt ( 'decimals' ,$this->decimals );
+ $sql->setString ( 'decPoint' ,$this->decPoint );
+ $sql->setString ( 'thousandSep' ,$this->thousandSep );
+ $sql->setString ( 'code' ,$this->code );
+ $sql->setString ( 'defaultText' ,$this->defaultText );
+
+ if ( intval($this->folderObjectId)==0 )
+ $sql->setNull( 'folderObjectId' );
+ else $sql->setInt ( 'folderObjectId' ,$this->folderObjectId );
+
+ if ( intval($this->defaultObjectId)==0 )
+ $sql->setNull( 'defaultObjectId' );
+ else $sql->setInt ( 'defaultObjectId' ,$this->defaultObjectId );
+
+ $sql->query();
+ }
+
+
+
+ /**
+ * Setzt den Typ des Elementes und schreibt diesen sofort in die Datenbank.
+ *
+ * @param String Der neue Typ, siehe getAvailableTypes() f?r m?gliche Typen
+ * @see #type
+ */
+ function setType( $type )
+ {
+ $this->type = $type;
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{element}}'.
+ ' SET type = {type}'.
+ ' WHERE id={elementid}' );
+
+ $sql->setInt ( 'elementid',$this->elementid );
+ $sql->setString ( 'type' ,$this->type );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Setzt ein Prefix vor den Elementnamen.
+ * @param String Prefix
+ */
+ function setPrefix( $prefix )
+ {
+ if ( strrpos($this->name,'%') === FALSE )
+ $name = $this->name;
+ else
+ list( $oldprefix,$name ) = explode('%',$this->name.'%');
+
+ $this->name = $prefix.'%'.$name;
+ }
+
+
+ /**
+ * Loeschen des Elementes und aller Inhalte
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Inhalte l?schen
+ $this->deleteValues();
+
+ // Element l?schen
+ $sql = $db->sql('DELETE FROM {{element}} '.
+ ' WHERE id={elementid}' );
+ $sql->setInt( 'elementid',$this->elementid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * L?schen aller Seiteninhalte mit diesem Element
+ * Das Element wird nicht gel?scht.
+ */
+ function deleteValues()
+ {
+ $db = db_connection();
+
+ // Alle Inhalte mit diesem Element l?schen
+ $sql = $db->sql('DELETE FROM {{value}} '.
+ ' WHERE elementid={elementid}' );
+ $sql->setInt( 'elementid',$this->elementid );
+ $sql->query();
+ }
+
+
+ /**
+ * Abhaengig vom Element-Typ werden die zur Darstellung notwendigen Eigenschaften ermittelt.
+ * @return array
+ */
+ function getRelatedProperties()
+ {
+ $prp = array('text' =>array('withIcon','allLanguages','writable','htmlwiki','defaultText'),
+ 'longtext'=>array('withIcon','allLanguages','writable','htmlwiki','defaultText'),
+ 'select' =>array('withIcon','allLanguages','writable','defaultText','code'),
+ 'number' =>array('withIcon','allLanguages','writable','decPoint','decimals','thousandSep'),
+ 'link' =>array('subtype','withIcon','allLanguages','writable','linktype','folderObjectId','defaultObjectId'),
+ 'date' =>array('withIcon','allLanguages','writable','dateformat','defaultText'),
+ 'list' =>array('subtype','withIcon','allLanguages','writable','folderObjectId','defaultObjectId'),
+ 'insert' =>array('subtype','withIcon','allLanguages','writable','folderObjectId','defaultObjectId'),
+ 'copy' =>array('prefix','name','defaultText'),
+ 'linkinfo'=>array('prefix','subtype','defaultText'),
+ 'linkdate'=>array('prefix','subtype','dateformat'),
+ 'code' =>array('code'),
+ 'dynamic' =>array('subtype','code'),
+ 'info' =>array('subtype'),
+ 'infodate'=>array('subtype','dateformat') );
+ return $prp[ $this->type ];
+ }
+
+
+
+ function getDefaultValue()
+ {
+ switch( $this->type )
+ {
+ case 'text':
+ case 'longtext':
+ return $this->defaultText;
+
+ case 'number';
+ return '0';
+
+ default:
+ }
+
+ return lang('EL_TYPE_'.$this->type);
+
+ }
+
+ /**
+ * Ermitteln aller benutzbaren Elementtypen
+ * @return array
+ */
+ function getAvailableTypes()
+ {
+ return array('text',
+ 'longtext',
+ 'select',
+ 'number',
+ 'link',
+ 'date',
+ 'insert',
+ 'copy',
+ 'linkinfo',
+ 'linkdate',
+ 'code',
+ 'dynamic',
+ 'info',
+ 'infodate');
+ }
+
+
+ /**
+ * Ermittelt die Klasse des Element-Typs.<br>
+ * Entweder "info", "text" oder "dynamic".
+ *
+ * @return String
+ */
+ function getTypeClass()
+ {
+ switch( $this->type )
+ {
+ case 'text':
+ case 'longtext':
+ case 'select':
+ case 'number':
+ case 'link':
+ case 'date':
+ case 'list':
+ case 'insert':
+ return 'text';
+
+ case 'code':
+ case 'dynamic':
+ return 'dynamic';
+
+ case 'copy':
+ case 'info':
+ case 'infodate':
+ case 'linkinfo':
+ case 'linkdate':
+ default:
+ return 'info';
+ }
+ }
+
+
+ function getSelectItems()
+ {
+ $parameters = explode( "\n",$this->code );
+ $items = array();
+
+ foreach( $parameters as $it )
+ {
+ $paar = explode( ":",$it,2 );
+ $param_name = trim($paar[0]);
+
+ if ( count($paar) > 1 )
+ $param_value = trim($paar[1]);
+ else
+ $param_value = trim($paar[0]);
+
+ // Wenn Inhalt mit "'" beginnt und mit "'" aufhoert, dann diese Zeichen abschneiden
+ if ( substr($param_value,0,1) == "'" && substr($param_value,strlen($param_value)-1,1) == "'" )
+ $param_value = substr($param_value,1,strlen($param_value)-2);
+
+ $items[$param_name] = $param_value;
+ }
+ return $items;
+ }
+
+
+ function getDynamicParameters()
+ {
+ $parameters = explode( "\n",$this->code );
+ $items = array();
+
+ foreach( $parameters as $it )
+ {
+ $paar = explode( ":",$it,2 );
+ if ( count($paar) > 1 )
+ {
+ $param_name = trim($paar[0]);
+ $param_value = trim($paar[1]);
+
+// // Wenn Inhalt mit "'" beginnt und mit "'" aufhoert, dann diese Zeichen abschneiden
+// if ( substr($param_value,0,1) == "'" && substr($param_value,strlen($param_value)-1,1) == "'" )
+// $param_value = substr($param_value,1,strlen($param_value)-2);
+
+ if ( !empty($param_value) )
+ $items[$param_name] = $param_value;
+ }
+ }
+ return $items;
+ }
+
+
+ /**
+ * Ermittelt, ob das Element beschreibbar ist.
+ * Bestimmte Typen (z.B. Info-Felder) sind nie beschreibbar, dann wird immer false zur?ckgegeben.
+ * Ansonsten wird ermittelt, ob dieses Element als beschreibbar markiert ist.
+ */
+ function isWritable()
+ {
+ // Bei bestimmten Feldern immer false zurueckgeben
+ if ( in_array($this->type,$this->readonlyElementNames) )
+ return false;
+
+ return $this->writable;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/File.class.php b/modules/cms-core/model/File.class.php
@@ -0,0 +1,709 @@
+<?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.
+
+
+// Standard Mime-Type
+define('OR_FILE_DEFAULT_MIMETYPE','application/octet-stream');
+
+
+/**
+ * Datei.
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+class File extends Object
+{
+ var $fileid;
+
+ var $size = 0;
+ var $value = '';
+ var $extension = '';
+ var $log_filenames = array();
+ var $fullFilename = '';
+ var $publish = null;
+ var $mime_type = '';
+
+ /**
+ * Breite eines Bildes. Ist nur verfuegbar, wenn vorher
+ * #getImageSize() aufgerufen wurde.
+ */
+ var $width = null;
+
+ /**
+ * Hoehe eines Bildes. Ist nur verfuegbar, wenn vorher
+ * #getImageSize() aufgerufen wurde.
+ */
+ var $height = null;
+
+ var $tmpfile;
+
+ var $content_negotiation = false;
+
+
+
+ /**
+ * Um Probleme mit BLOB-Feldern und Datenbank-Besonderheiten zu vermeiden,
+ * kann der Binaerinhalt BASE64-kodiert gespeichert werden.
+ * @type Boolean
+ */
+ var $storeValueAsBase64 = false;
+
+
+
+ /**
+ * Konstruktor
+ *
+ * @param Objekt-Id
+ */
+ function __construct( $objectid='' )
+ {
+ global $conf;
+
+ $db = \Session::getDatabase();
+ $this->storeValueAsBase64 = $db->conf['base64'];
+
+ parent::__construct( $objectid );
+ $this->isFile = true;
+ }
+
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function full_filename()
+ {
+ if ( !empty($this->fullFilename) )
+ return $this->fullFilename;
+
+ $filename = parent::full_filename();
+
+ if ( $this->content_negotiation && config('publish','negotiation','file_negotiate_type' ) )
+ {
+ // Link auf Datei: Extension bleibt aufgrund Content-Negotiation leer
+ }
+ else
+ {
+ if ( !empty($this->extension) )
+ $filename .= '.'.$this->extension;
+ }
+
+ $this->fullFilename = $filename;
+ return $filename;
+ }
+
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei (ohne Pfadangabe)
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function filenameWithExtension()
+ {
+ if ( $this->extension != '' )
+ return $this->filename.'.'.$this->extension;
+ else return $this->filename;
+ }
+
+
+
+ /**
+ * Ermitteln aller Eigenschaften
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ array('full_filename'=>$this->fullFilename,
+ 'extension' =>$this->extension,
+ 'size' =>$this->size,
+ 'mimetype' =>$this->mimetype() ) );
+ }
+
+
+
+ /**
+ * @deprecated
+ */
+ function getFileObjectIdsByExtension( $extension )
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sqlquery = 'SELECT * FROM {{object}} ';
+
+ if ( $extension != '' )
+ {
+ $sqlquery .= " WHERE extension='";
+
+ $ext = explode(',',$extension);
+ $sqlquery .= implode( "' OR extension='",$ext );
+ $sqlquery .= "' AND typeid=".OR_TYPEID_FILE." AND projectid={projectid}";
+ }
+ else
+ {
+ $sqlquery .= " WHERE typeid=".OR_TYPEID_FILE." AND projectid={projectid}";
+ }
+
+ $sql = $db->sql( $sqlquery );
+ $sql->setInt( 'projectid',$SESS['projectid'] );
+
+ return $sql->getCol();
+ }
+
+
+
+ /**
+ * Es werden Objekte zu einer Dateierweiterung ermittelt
+ *
+ * @param String Dateierweiterung ohne fuehrenden Punkt (z.B. 'jpeg')
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByExtension( $extension )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{file}}.objectid FROM {{file}} '.
+ ' LEFT JOIN {{object}} '.
+ ' ON {{object}}.id={{file}}.objectid'.
+ ' WHERE {{file}}.extension={extension}'.
+ ' AND {{object}}.projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setString( 'extension',$extension );
+
+ return $sql->getCol();
+ }
+
+
+
+ /**
+ * Ermittelt den Mime-Type zu dieser Datei
+ *
+ * @return String Mime-Type
+ */
+ function mimeType()
+ {
+ if ( !empty( $this->mime_type ) )
+ return $this->mime_type;
+
+ global $conf;
+ $mime_types = $conf['mime-types'];
+
+
+
+ $ext = strtolower( $this->getRealExtension() );
+
+ if ( !empty($mime_types[$ext]) )
+ $this->mime_type = $mime_types[$ext];
+ else
+ // Wenn kein Mime-Type gefunden, dann Standartwert setzen
+ $this->mime_type = OR_FILE_DEFAULT_MIMETYPE;
+
+ return( $this->mime_type );
+ }
+
+
+
+ /**
+ * Ermittelt Breite und H�he des Bildes.<br>
+ * Die Werte lassen sich anschlie�end �ber die Eigenschaften "width" und "height" ermitteln.
+ */
+ function getImageSize()
+ {
+ if ( is_null($this->width) )
+ {
+ $this->write(); // Datei schreiben
+
+ // Bildinformationen ermitteln
+ $size = getimagesize( $this->tmpfile() );
+
+ // Breite und Hoehe des aktuellen Bildes
+ $this->width = $size[0];
+ $this->height = $size[1];
+ }
+ }
+
+
+
+ /**
+ * Veraendert die Bildgroesse eines Bildes
+ *
+ * Diese Methode sollte natuerlich nur bei Bildern ausgefuehrt werden.
+ *
+ * @param Neue Breite
+ * @param Neue Hoehe
+ * @param Bildgr��enfaktor
+ * @param Altes Format als Integer-Konstante IMG_xxx
+ * @param Neues Format als Integer-Konstante IMG_xxx
+ * @param Jpeg-Qualitaet (sofern neues Format = Jpeg)
+ */
+ function imageResize( $newWidth,$newHeight,$factor,$oldformat,$newformat,$jpegquality )
+ {
+ global $conf;
+
+ $this->write(); // Datei schreiben
+
+ // Bildinformationen ermitteln
+ $size = getimagesize( $this->tmpfile() );
+
+ // Breite und Hoehe des aktuellen Bildes
+ $oldWidth = $size[0];
+ $oldHeight = $size[1];
+ $aspectRatio = $oldHeight / $oldWidth; // Seitenverhaeltnis
+
+ // Wenn Breite und Hoehe fehlen, dann Bildgroesse beibehalten
+ if ( $newWidth == 0 && $newHeight == 0)
+ {
+ if ( $factor != 0 && $factor != 1 )
+ {
+ $newWidth = $oldWidth * $factor;
+ $newHeight = $oldHeight * $factor;
+ $resizing = true;
+ }
+ else
+ {
+ $newWidth = $oldWidth;
+ $newHeight = $oldHeight;
+ $resizing = false;
+ }
+ }
+ else
+ {
+ $resizing = true;
+ }
+
+ // Wenn nur Breite oder Hoehe angegeben ist, dann
+ // das Seitenverhaeltnis beibehalten
+ if ( $newWidth == 0 )
+ $newWidth = $newHeight / $aspectRatio;
+
+ if ( $newHeight == 0 )
+ $newHeight = $newWidth * $aspectRatio;
+
+
+ switch( $oldformat )
+ {
+ case IMG_GIF: // GIF
+
+ $oldImage = ImageCreateFromGIF( $this->tmpfile );
+ break;
+
+ case IMG_JPG: // JPEG
+
+ $oldImage = ImageCreateFromJPEG($this->tmpfile);
+ break;
+
+ case IMG_PNG: // PNG
+
+ $oldImage = imagecreatefrompng($this->tmpfile);
+ break;
+
+ default:
+ die('unsupported image format "'.$this->extension.'", cannot load image. resize failed');
+ }
+
+ // Ab Version 2 der GD-Bibliothek sind TrueColor-Umwandlungen moeglich.
+ global $conf;
+ $hasTrueColor = $conf['image']['truecolor'];
+
+ switch( $newformat )
+ {
+ case IMG_GIF: // GIF
+
+ if ( $resizing )
+ {
+ $newImage = ImageCreate($newWidth,$newHeight);
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ $newImage = &$oldImage;
+ }
+
+ ImageGIF($newImage, $this->tmpfile() );
+ $this->extension = 'gif';
+
+ break;
+
+ case IMG_JPG: // JPEG
+
+ if ( !$resizing )
+ {
+ $newImage = &$oldImage;
+ }
+ elseif ( $hasTrueColor )
+ {
+ // Verwende TrueColor (GD2)
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterstuetzt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ ImageJPEG($newImage, $this->tmpfile,$jpegquality );
+ $this->extension = 'jpeg';
+
+ break;
+
+ case IMG_PNG: // PNG
+
+ if ( !$resizing )
+ {
+ $newImage = &$oldImage;
+ }
+ elseif ( $hasTrueColor )
+ {
+ // Verwende TrueColor (GD2)
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterstuetzt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ imagepng( $newImage,$this->tmpfile() );
+ $this->extension = 'png';
+
+ break;
+
+ default:
+ die('unsupported image format "'.$newformat.'", cannot resize');
+ }
+
+ $f = fopen( $this->tmpfile(), "r" );
+ $this->value = fread( $f,filesize($this->tmpfile()) );
+ fclose( $f );
+
+ imagedestroy( $oldImage );
+ //imagedestroy( $newImage );
+ }
+
+
+ /**
+ * Lesen der Datei aus der Datenbank.
+ *
+ * Es werden nur die Meta-Daten (Erweiterung, Gr��e) gelesen. Zum Lesen des
+ * Datei-Inhaltes muss #loadValue() aufgerufen werden.
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,extension,size'.
+ ' FROM {{file}}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $sql->getRow();
+
+ if ( count($row)!=0 )
+ {
+ $this->fileid = $row['id' ];
+ $this->extension = $row['extension'];
+ $this->size = $row['size' ];
+ }
+
+ $this->objectLoad();
+ }
+
+
+
+ /**
+ * Unwiderrufliches L�schen der Datei aus der Datenbank.
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Datei l?schen
+ $sql = $db->sql( 'DELETE FROM {{file}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $sql->query();
+
+ $this->objectDelete();
+ }
+
+
+
+ /**
+ * Stellt anhand der Dateiendung fest, ob es sich bei dieser Datei um ein Bild handelt
+ */
+ function isImage()
+ {
+ return substr($this->mimeType(),0,6)=='image/';
+ }
+
+
+
+ /**
+ * Ermittelt die Datei-Endung.
+ *
+ * @return String Datei-Endung
+ */
+ function extension()
+ {
+ if ($this->extension != '')
+ return $this->extension;
+
+ $this->load();
+ return $this->extension;
+ }
+
+
+ /**
+ * Einen Dateinamen in Dateiname und Extension aufteilen.
+ * @param filename Dateiname
+ */
+ function parse_filename($filename)
+ {
+ $filename = basename($filename);
+
+ $p = strrpos($filename, '.');
+ if ($p !== false)
+ {
+ $this->extension = substr($filename, $p +1);
+ $this->filename = substr($filename, 0, $p);
+ }
+ else
+ {
+ $this->extension = '';
+ $this->filename = $filename;
+ }
+ }
+
+
+ /**
+ * Speichert die Datei-Informationen in der Datenbank.
+ */
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( <<<EOF
+UPDATE {{file}} SET
+ size = {size},
+ extension = {extension}
+ WHERE objectid={objectid}
+EOF
+);
+ $sql->setString('size' ,$this->size );
+ $sql->setString('extension',$this->extension );
+ $sql->setString('objectid' ,$this->objectid );
+ $sql->query();
+
+ $this->objectSave();
+ }
+
+
+ /**
+ * Kopieren des Inhaltes von einer anderen Datei
+ * @param ID der Datei, von der der Inhalt kopiert werden soll
+ */
+ function copyValueFromFile( $otherfileid )
+ {
+ $of = new File( $otherfileid );
+ $this->value = $of->loadValue();
+ $this->saveValue();
+ }
+
+
+ /**
+ * Lesen des Inhaltes der Datei aus der Datenbank.
+ *
+ * @return String Inhalt der Datei
+ */
+ function loadValue()
+ {
+ if ( is_file($this->tmpfile()))
+ return implode('',file($this->tmpfile())); // From cache
+
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT size,value'.
+ ' FROM {{file}}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $sql->getRow();
+
+ if ( count($row) != 0 )
+ {
+ $this->value = $row['value'];
+ $this->size = $row['size' ];
+ }
+
+ if ( $this->storeValueAsBase64 )
+ $this->value = base64_decode( $this->value );
+
+ // Store in cache.
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->value );
+ fclose( $f );
+
+ return $this->value;
+ }
+
+
+ /**
+ * Speichert den Inhalt in der Datenbank.
+ */
+ function saveValue( $value = '' )
+ {
+ if ( is_file($this->tmpfile()) )
+ @unlink( $this->tmpfile() );
+
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{file}}'.
+ ' SET value={value}, '.
+ ' size={size} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setString( 'objectid' ,$this->objectid );
+ $sql->setInt ( 'size' ,strlen($this->value) );
+
+ if ( $this->storeValueAsBase64 )
+ $sql->setString( 'value',base64_encode($this->value) );
+ else
+ $sql->setString( 'value',$this->value );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Lesen der Datei aus der Datenbank und schreiben in temporaere Datei
+ */
+ function write()
+ {
+ if ( !is_file($this->tmpfile()) )
+ $this->loadValue();
+ }
+
+
+ /**
+ * F�gt die Datei der Datenbank hinzu.
+ */
+ function add()
+ {
+ $db = db_connection();
+
+ $this->objectAdd();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{file}}');
+ $this->fileid = intval($sql->getOne())+1;
+
+ $sql = $db->sql('INSERT INTO {{file}}'.
+ ' (id,objectid,extension,size,value)'.
+ " VALUES( {fileid},{objectid},{extension},0,'' )" );
+ $sql->setInt ('fileid' ,$this->fileid );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('extension',$this->extension );
+
+ $sql->query();
+
+ $this->saveValue();
+ }
+
+
+ function publish()
+ {
+ if ( ! is_object($this->publish) )
+ $this->publish = new \Publish();
+
+ $this->write();
+ $this->publish->copy( $this->tmpfile(),$this->full_filename(),$this->lastchangeDate );
+
+ $this->publish->publishedObjects[] = $this->getProperties();
+ }
+
+
+ /**
+ * Ermittelt einen tempor�ren Dateinamen f�r diese Datei.
+ */
+ function tmpfile()
+ {
+ if ( $this->tmpfile == '' )
+ {
+ $db = db_connection();
+ $this->tmpfile = $this->getTempFileName( array('db'=>$db->id,'o'.$this->objectid) );
+ }
+ return $this->tmpfile;
+ }
+
+
+ /**
+ * Setzt den Zeitstempel der Datei auf die aktuelle Zeit.
+ *
+ * @see objectClasses/Object#setTimestamp()
+ */
+
+ function setTimestamp()
+ {
+ @unlink( $this->tmpfile() );
+
+ parent::setTimestamp();
+ }
+
+
+
+ /**
+ * Ermittelt die wirksame Datei-Endung. Diese kann sich
+ * in der Extra-Dateiendung, aber auch direkt im Dateiname
+ * befinden.
+ *
+ * @return Dateiendung
+ */
+ function getRealExtension()
+ {
+ if ( !empty($this->extension))
+ {
+ return $this->extension;
+ }
+ else
+ {
+ $pos = strrpos($this->filename,'.');
+ if ( $pos === false )
+ return '';
+ else
+ return substr($this->filename,$pos+1);
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Folder.class.php b/modules/cms-core/model/Folder.class.php
@@ -0,0 +1,908 @@
+<?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.
+
+
+/**
+ * Darstellen eines Ordners
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Folder extends Object
+{
+ var $folderid;
+ var $projectid;
+ var $parentfolders = array();
+ var $subfolders = array();
+ var $filenames = true;
+ var $name = '';
+ var $filename = '';
+ var $desc = '';
+ /**
+ * @var \Publish
+ */
+ public $publish = null;
+
+
+ function __construct( $objectid='' )
+ {
+ parent::__construct( $objectid );
+ $this->isFolder = true;
+ }
+
+
+ function add()
+ {
+ $this->objectAdd();
+
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{folder}}');
+ $this->folderid = intval($sql->getOne())+1;
+
+ $sql = $db->sql('INSERT INTO {{folder}}'.
+ ' (id,objectid)'.
+ ' VALUES( {folderid},{objectid} )' );
+ $sql->setInt ('folderid' ,$this->folderid );
+ $sql->setInt ('objectid' ,$this->objectid );
+
+ $sql->query();
+ }
+
+
+
+ function getRootFolderId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid IS NULL'.
+ ' AND typeid=1'.
+ ' AND projectid={projectid}' );
+
+ // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden
+ if ( isset($this) && isset($this->projectid) )
+ {
+ $sql->setInt('projectid',$this->projectid );
+ }
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid );
+ }
+
+ // Datenbankabfrage ausfuehren
+ return $sql->getOne();
+ }
+
+
+ function hasFilename( $filename )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT COUNT(*) FROM {{object}}'.' WHERE parentid={objectid} AND filename={filename}');
+
+ if ( intval($this->objectid)== 0 )
+ $sql->setNull('objectid');
+ else
+ $sql->setString('objectid', $this->objectid);
+
+ $sql->setString('filename', $filename );
+
+ return( $sql->getOne() > 0 );
+ }
+
+
+ public function load()
+ {
+// $db = db_connection();
+//
+// $sql = $db->sql('SELECT * FROM {{folder}} WHERE objectid={objectid}');
+// $sql->setInt('objectid',$this->objectid);
+//
+// $row = $sql->getRow( $sql );
+//
+ $this->objectLoad();
+
+// $this->folderid = $row['id' ];
+ }
+
+
+
+ function save()
+ {
+ $this->objectSave();
+ }
+
+
+
+ function setOrderId( $orderid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{folder}} '.
+ ' SET orderid={orderid}'.
+ ' WHERE id={folderid}');
+ $sql->setInt('folderid',$this->folderid);
+ $sql->setInt('orderid' ,$orderid );
+
+ $sql->query();
+ }
+
+
+
+// function getSubFolders()
+// {
+// global $SESS;
+// $db = db_connection();
+//
+// $sql = $db->sql('SELECT id FROM {{folder}}'.
+// ' WHERE parentid={folderid}'.
+// ' AND projectid={projectid}'.
+// ' ORDER BY orderid ASC' );
+// $sql->setInt('folderid' ,$SESS['folderid' ]);
+// $sql->setInt('projectid',$SESS['projectid']);
+//
+// return( $sql->getCol( $sql ));
+// }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $sql->getCol() );
+ }
+
+
+
+ /**
+ * Liest alle Objekte in diesem Ordner
+ * @return array[Object] Objekte
+ */
+ function getObjects()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT {{object}}.*,{{name}}.name,{{name}}.descr'.
+ ' FROM {{object}}'.
+ ' LEFT JOIN {{name}} '.
+ ' ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('languageid',$this->languageid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ $liste = array();
+ $res = $sql->getAll();
+ foreach( $res as $row )
+ {
+ $o = new Object( $row['id'] );
+ $o->setDatabaseRow( $row );
+ $liste[] = $o;
+ }
+
+ return $liste;
+ }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIdsByType()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY typeid,orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $sql->getCol() );
+ }
+
+
+ // Liest alle Objekte in diesem Ordner sortiert nach dem Namen (nicht Dateinamen!)
+ function getChildObjectIdsByName()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT {{object}}.id FROM {{object}}'.
+ ' LEFT JOIN {{name}} ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY {{name}}.name,{{object}}.filename ASC');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $this->languageid);
+ return( $sql->getCol() );
+ }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIdsByLastChange()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY lastchange_date,orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $sql->getCol() );
+ }
+
+
+ function publish( $withPages,$withFiles,$subdirs = false )
+ {
+ set_time_limit(300);
+ if ( ! is_object($this->publish) )
+ $this->publish = new \Publish();
+
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $o = new Object( $oid );
+ $o->objectLoadRaw();
+
+ if ( $o->isPage && $withPages )
+ {
+ $p = new Page( $oid );
+ $p->load();
+ $p->publish = &$this->publish;
+ $p->publish();
+ }
+
+ if ( $o->isFile && $withFiles )
+ {
+ $f = new File( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish();
+ }
+
+ if ( $o->isFolder && $subdirs )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish( $withPages,$withFiles,true );
+ }
+ }
+ }
+
+
+ function getObjectIdByFileName( $filename )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid={objectid}'.
+ ' AND filename={filename}' );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('filename' ,$filename );
+
+ return( intval($sql->getOne()) );
+ }
+
+
+
+ /**
+ * Ermittelt alle Objekte vom gew�nschten Typ, die sic in
+ * diesem Projekt befinden.
+ *
+ * @see objectClasses/Object#getAllObjectIds()
+ * @param types Array
+ * @return Liste von Object-Ids
+ */
+ function getAllObjectIds( $types=array('folder','page','link','file') )
+ {
+// Html::debug($types,'Typen');
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE projectid={projectid}'.
+ ' AND ( typeid ={is_folder}' .
+ ' OR typeid ={is_file}' .
+ ' OR typeid ={is_page}' .
+ ' OR typeid ={is_link} )' .
+ ' ORDER BY orderid ASC' );
+
+ if (isset($this) && isset($this->projectid))
+ {
+ $projectid = $this->projectid;
+ }
+ else
+ {
+ $project = \Session::getProject();
+ $projectid = $project->projectid;
+ }
+
+ $sql->setInt('projectid',$projectid);
+ $sql->setInt('is_folder',in_array('folder',$types)?OR_TYPEID_FOLDER:0);
+ $sql->setInt('is_file' ,in_array('file' ,$types)?OR_TYPEID_FILE:0);
+ $sql->setInt('is_page' ,in_array('page' ,$types)?OR_TYPEID_PAGE:0);
+ $sql->setInt('is_link' ,in_array('link' ,$types)?OR_TYPEID_LINK:0);
+
+ return( $sql->getCol() );
+ }
+
+
+ public function getRootObjectId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return( $sql->getOne() );
+ }
+
+
+ public function getOtherFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE typeid='.OR_TYPEID_FOLDER.
+ ' and id != {objectid} '.
+ ' AND projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return( $sql->getCol() );
+ }
+
+
+ function getAllFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE typeid='.OR_TYPEID_FOLDER.
+ ' AND projectid={projectid}' );
+
+ if ( !isset($this) || !isset($this->projectid) )
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+ else $sql->setInt( 'projectid',$this->projectid );
+
+ return( $sql->getCol() );
+ }
+
+
+ function getPages()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_PAGE.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Ermittelt die erste Seite oder Verkn�pfung in diesem Ordner.
+ *
+ * @return Object Objekt
+ */
+ public function getFirstPage()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid}'.
+ ' AND (typeid='.OR_TYPEID_PAGE.')'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $oid = intval($sql->getOne());
+
+ if ( $oid != 0 )
+ $o = new Object($oid);
+ else
+ $o = null;
+
+ return $o;
+ }
+
+
+ /**
+ * Ermittelt die erste Seite oder Verkn�pfung in diesem Ordner.
+ *
+ * @return Object Objekt
+ */
+ function getFirstPageOrLink()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid}'.
+ ' AND (typeid='.OR_TYPEID_PAGE.' OR typeid='.OR_TYPEID_LINK.')'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $oid = intval($sql->getOne());
+
+ if ( $oid != 0 )
+ $o = new Object($oid);
+ else
+ $o = null;
+
+ return $o;
+ }
+
+
+ function getLastPageOrLink()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid}'.
+ ' AND (typeid='.OR_TYPEID_PAGE.' OR typeid='.OR_TYPEID_LINK.')'.
+ ' ORDER BY orderid DESC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $oid = intval($sql->getOne());
+
+ if ( $oid != 0 )
+ $o = new Object($oid);
+ else
+ $o = null;
+
+ return $o;
+ }
+
+
+ function getFiles()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FILE.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $sql->getCol();
+ }
+
+
+
+ /**
+ * Liefert eine Liste von allen Dateien in diesem Ordner.
+ *
+ * @return Array Schl�ssel=Objekt-Id, Wert=Dateiname
+ */
+ function getFileFilenames()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id,filename FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FILE.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $sql->getAssoc();
+ }
+
+
+ function getLinks()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_LINK.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $sql->getCol();
+ }
+
+
+ // Rechte f?r diesen Ordner hinzuf?gen
+ function addrights( $rights,$inherit = true )
+ {
+ global $SESS;
+
+ $SESS['rights'][$rights['projectid']][$this->folderid]['show'] = true;
+
+ if ($rights['read'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['read'] = 1;
+ if ($rights['write'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['write'] = 1;
+ if ($rights['create'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['create'] = 1;
+ if ($rights['delete'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['delete'] = 1;
+ if ($rights['publish'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['publish'] = 1;
+
+ // Rechte auf Unterordner vererben
+ // sowie f?r ?bergeordnete Ordner die Anzeige erzwingen
+ if ( $inherit )
+ {
+ // ?bergeordnete Ordner ermitteln
+ $parentfolder = $this->parentObjectFileNames();
+
+ // ?bergeordnete Ordner immer anzeigen (Schalter 'show'=true)
+ foreach( $parentfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+ }
+
+ $f = new Folder( 'null' );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+
+
+ // Unterordner ermitteln
+ //echo "Kurz vor subfolderberechnung, folderid ist ".$this->folderid.'<br>';
+ $subfolder = $this->subfolder();
+
+ // Rechte weitergeben
+ foreach( $subfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( $rights,false );
+ unset($f);
+ }
+ }
+ }
+
+
+ function addParentFolder( $id,$name,$filename='' )
+ {
+ if ( empty($name) )
+ $name = $filename;
+
+ if ( empty($name) )
+ $name = "($id)";
+
+ if ( intval($id) != 0 )
+ $this->parentfolders[ $id ] = $name;
+ }
+
+
+ function checkParentFolders( $with_root, $with_self )
+ {
+ // Reihenfolge umdrehen
+ $this->parentfolders = array_reverse($this->parentfolders,true);
+
+ // Ordner ist bereits hoechster Ordner
+// if ( count($this->parentfolders) == 2 && $this->isRoot && $with_root && $with_self )
+// {
+// array_pop ( $this->parentfolders );
+// return;
+// }
+
+
+ if ( !$with_root && !empty($this->parentfolders) )
+ {
+ $keys = array_keys( $this->parentfolders );
+ unset( $this->parentfolders[$keys[0]] );
+ }
+
+ if ( !$with_self && !empty($this->parentfolders) )
+ {
+ $keys = array_keys( $this->parentfolders );
+ unset( $this->parentfolders[$keys[count($keys)-1]] );
+ }
+ }
+
+
+ function parentObjectFileNames( $with_root = false, $with_self = false )
+ {
+ $db = \Session::getDatabase();
+
+ $foid = $this->id;
+ $idCache = array();
+
+ while( intval($foid)!=0 )
+ {
+ $sql = $db->sql( <<<SQL
+
+SELECT parentid,id,filename
+ FROM {{object}}
+ WHERE {{object}}.id={parentid}
+
+SQL
+ );
+ $sql->setInt('parentid' ,$foid );
+
+ $row = $sql->getRow();
+
+ if ( in_array($row['id'],$idCache))
+ \Http::serverError('fatal: parent-rekursion in object-id: '.$this->objectid.', double-parent-id: '.$row['id']);
+ else
+ $idCache[] = $row['id'];
+
+ $this->addParentfolder( $row['id'],$row['filename'] );
+ $foid = $row['parentid'];
+ }
+
+
+ $this->checkParentFolders($with_root,$with_self);
+
+ return $this->parentfolders;
+ }
+
+ function parentObjectNames( $with_root = false, $with_self = false )
+ {
+ $db = \Session::getDatabase();
+
+ $foid = $this->id;
+ $idCache = array();
+
+ while( intval($foid)!=0 )
+ {
+ $sql = $db->sql( <<<SQL
+
+SELECT {{object}}.parentid,{{object}}.id,{{object}}.filename,{{name}}.name FROM {{object}}
+ LEFT JOIN {{name}}
+ ON {{object}}.id = {{name}}.objectid
+ AND {{name}}.languageid = {languageid}
+ WHERE {{object}}.id={parentid}
+
+SQL
+ );
+ $sql->setInt('languageid',$this->languageid);
+ $sql->setInt('parentid' ,$foid );
+
+ $row = $sql->getRow();
+
+ if ( in_array($row['id'],$idCache))
+ \Http::serverError('fatal: parent-rekursion in object-id: '.$this->objectid.', double-parent-id: '.$row['id']);
+ else
+ $idCache[] = $row['id'];
+
+ $this->addParentfolder( $row['id'],$row['name'],$row['filename'] );
+ $foid = $row['parentid'];
+ }
+
+ $this->checkParentFolders($with_root,$with_self);
+
+ return $this->parentfolders;
+ }
+
+
+ // Ermitteln aller Unterordner
+ //
+ function subfolder()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FOLDER.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $this->subfolders = $sql->getCol();
+
+ return $this->subfolders;
+ }
+
+
+
+ function getSubfolderFilenames()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id,filename FROM {{object}} '.
+ ' WHERE parentid={objectid} AND typeid='.OR_TYPEID_FOLDER.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $sql->getAssoc();
+ }
+
+
+
+ /**
+ * Ermitteln aller Unterordner (rekursives Absteigen).
+ *
+ */
+ function getAllSubFolderIds()
+ {
+ global $SESS;
+
+ $ids = array();
+
+ foreach( $this->getSubFolderIds() as $id )
+ {
+ $ids[] = $id;
+
+ $f = new Folder( $id );
+ if ( !empty($this->projectid) )
+ $f->projectid = $this->projectid;
+
+ // Rekursiver Aufruf für alle Unterordner
+ foreach( $f->getAllSubFolderIds() as $xid )
+ {
+ $ids[] = $xid;
+ }
+ }
+
+ return $ids;
+ }
+
+
+ /**
+ * Loeschen dieses Ordners.
+ * Der Ordner wird nur geloescht, wenn er keine Unterelemente mehr enth?lt.
+ * Zum Loeschen inklusive Unterelemente dient die Methode deleteAll()
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Nur loeschen, wenn es keine Unterelemente gibt
+ if ( count( $this->getObjectIds() ) == 0 )
+ {
+ $sql = $db->sql( 'UPDATE {{element}} '.
+ ' SET folderobjectid=NULL '.
+ ' WHERE folderobjectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+ $sql = $db->sql( 'DELETE FROM {{folder}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+ $this->objectDelete();
+ }
+ }
+
+
+ /**
+ * Rekursives loeschen aller Inhalte
+ *
+ * Loeschen aller Inhalte dieses Ordners
+ * inclusive aller Unterelemente
+ */
+ function deleteAll()
+ {
+ $db = db_connection();
+
+ // L?schen aller Unterordner
+ foreach( $this->subfolder() as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ {
+ $folder->deleteAll();
+ }
+ }
+
+ // L?schen aller Seiten,Verknuepfungen und Dateien in
+ // diesem Ordner
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $object = new Object( $oid );
+ {
+ $object->load();
+
+ if ( $object->isPage )
+ {
+ $page = new Page( $oid );
+ $page->load();
+ $page->delete();
+ }
+
+ if ( $object->isLink )
+ {
+ $link = new Link( $oid );
+ $link->load();
+ $link->delete();
+ }
+
+ if ( $object->isUrl )
+ {
+ $url = new Url( $oid );
+ $url->load();
+ $url->delete();
+ }
+
+ if ( $object->isFile )
+ {
+ $file = new File( $oid );
+ $file->load();
+ $file->delete();
+ }
+ }
+ }
+
+ // Zum Abschluss den aktuellen Ordner loeschen
+ $this->delete();
+ }
+
+
+ function getSubFolderIds()
+ {
+ return $this->subfolder();
+ }
+
+
+
+ /**
+ * Ermittelt die letzten Änderung in diesem Ordner.
+ * @return Array[Objektid]=Array())
+ */
+ public function getLastChanges()
+ {
+
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT {{object}}.id as objectid,
+ {{object}}.lastchange_date as lastchange_date,
+ {{object}}.filename as filename,
+ {{object}}.typeid as typeid,
+ {{name}}.name as name,
+ {{user}}.name as username,
+ {{user}}.id as userid,
+ {{user}}.mail as usermail,
+ {{user}}.fullname as userfullname
+ FROM {{object}}
+ LEFT JOIN {{name}}
+ ON {{name}}.objectid = {{object}}.id
+ AND {{name}}.languageid = {languageid}
+ LEFT JOIN {{user}}
+ ON {{user}}.id = {{object}}.lastchange_userid
+ WHERE {{object}}.parentid = {folderid}
+ ORDER BY {{object}}.lastchange_date DESC
+SQL
+ );
+
+ // Variablen setzen.
+ $sql->setInt( 'folderid', $this->objectid );
+
+ $language = \Session::getProjectLanguage();
+ $sql->setInt( 'languageid', $language->languageid );
+
+ return $sql->getAll();
+ }
+
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Group.class.php b/modules/cms-core/model/Group.class.php
@@ -0,0 +1,379 @@
+<?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.
+
+
+
+/**
+ * Darstellen einer Benutzergruppe. Eine Gruppe enthaelt beliebig viele Benutzer
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Group
+{
+ var $groupid = 0;
+ var $error = '';
+
+ var $name = '';
+ var $fullname = '';
+ var $ldap_dn;
+ var $tel;
+ var $mail;
+ var $desc;
+ var $style;
+ var $isAdmin;
+
+
+ // Konstruktor
+ function __construct( $groupid='' )
+ {
+ if ( is_numeric($groupid) )
+ $this->groupid = $groupid;
+ }
+
+
+ // Lesen aller Gruppen aus der Datenbank
+ function getAll()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{group}}' );
+
+ return $sql->getAssoc();
+ }
+
+
+ // Lesen Gruppe aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{group}}'.
+ ' WHERE id={groupid}' );
+ $sql->setInt( 'groupid',$this->groupid );
+
+ $row = $sql->getRow();
+ if ( count($row) > 0 )
+ $this->name = $row['name' ];
+ else
+ $this->name = '';
+ }
+
+
+ // Lesen einer Gruppe aus der Datenbank
+ public static function loadWithName( $name )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{group}}'.
+ ' WHERE name={name}' );
+ $sql->setString('name',$name );
+
+ $row = $sql->getRow();
+ if ( count($row) > 0 )
+ {
+ $group = new Group( $row['id'] );
+ $group->load();
+
+ return $group;
+ }
+ else
+ {
+ throw new \ObjectNotFoundException( "Group does not exist: ".$name);
+ }
+ }
+
+
+ // Speichern Benutzer in der Datenbank
+ function save()
+ {
+ if ( empty($this->name) )
+ $this->name = lang('GLOBAL_GROUP').' '.$this->groupid;
+
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = $db->sql( 'UPDATE {{group}} '.
+ 'SET name = {name} '.
+ 'WHERE id={groupid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setInt ('groupid',$this->groupid );
+
+ // Datenbankabfrage ausfuehren
+ $sql->query();
+ }
+
+
+ /**
+ * Rueckgabe aller Eigenschaften
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'groupid'=>$this->groupid );
+ }
+
+
+ // Gruppe hinzufuegen
+ function add( $name = '' )
+ {
+ $db = db_connection();
+
+ if ( $name != '' )
+ $this->name = $name;
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{group}}');
+ $this->groupid = intval($sql->getOne())+1;
+
+ // Gruppe hinzuf?gen
+ $sql = $db->sql( 'INSERT INTO {{group}} '.
+ '(id,name) VALUES( {groupid},{name} )');
+ $sql->setInt ('groupid',$this->groupid );
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $sql->query();
+ }
+
+
+ // Gruppe entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Berechtigungen zu dieser Gruppe loeschen
+ $sql = $db->sql( 'DELETE FROM {{acl}} '.
+ 'WHERE groupid={groupid}' );
+ $sql->setInt ('groupid',$this->groupid );
+ $sql->query();
+
+
+ // Alle Gruppenzugehoerigkeiten zu dieser Gruppe loeschen
+ $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
+ 'WHERE groupid={groupid}' );
+ $sql->setInt ('groupid',$this->groupid );
+ $sql->query();
+
+ // Gruppe loeschen
+ $sql = $db->sql( 'DELETE FROM {{group}} '.
+ 'WHERE id={groupid}' );
+ $sql->setInt ('groupid',$this->groupid );
+ $sql->query();
+ }
+
+
+ // Benutzer ermitteln, die Mitglied dieser Gruppe sind
+ function getUsers()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{user}}.id,{{user}}.name FROM {{user}} '.
+ 'LEFT JOIN {{usergroup}} ON {{usergroup}}.userid={{user}}.id '.
+ 'WHERE {{usergroup}}.groupid={groupid}' );
+ $sql->setInt('groupid',$this->groupid );
+
+ return $sql->getAssoc();
+ }
+
+
+ // Benutzer ermitteln, die *nicht* Mitglied dieser Gruppe sind
+ function getOtherUsers()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{user}}.id,{{user}}.name FROM {{user}}'.
+ ' LEFT JOIN {{usergroup}} ON {{usergroup}}.userid={{user}}.id AND {{usergroup}}.groupid={groupid}'.
+ ' WHERE {{usergroup}}.groupid IS NULL' );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ return $sql->getAssoc();
+ }
+
+
+ // Benutzer einer Gruppe hinzufuegen
+ function addUser( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{usergroup}}');
+ $usergroupid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( 'INSERT INTO {{usergroup}} '.
+ ' (id,userid,groupid) '.
+ ' VALUES( {usergroupid},{userid},{groupid} )' );
+ $sql->setInt('usergroupid',$usergroupid );
+ $sql->setInt('userid' ,$userid );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ $sql->query();
+
+ }
+
+
+ // Benutzer aus Gruppe entfernen
+ function delUser( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
+ ' WHERE userid={userid} AND groupid={groupid}' );
+ $sql->setInt ('userid' ,$userid );
+ $sql->setInt ('groupid' ,$this->groupid );
+
+ $sql->query();
+ }
+
+
+ // Alle Berechtigungen ermitteln
+ function getRights()
+ {
+ global $SESS,$conf_php;
+ $db = db_connection();
+ $var = array();
+
+ // Alle Projekte lesen
+ $sql = $db->sql( 'SELECT id,name FROM {{project}}' );
+ $projects = $sql->getAssoc();
+
+ foreach( $projects as $projectid=>$projectname )
+ {
+ $var[$projectid] = array();
+ $var[$projectid]['name'] = $projectname;
+ $var[$projectid]['folders'] = array();
+ $var[$projectid]['rights'] = array();
+
+ $sql = $db->sql( 'SELECT {{acl}}.* FROM {{acl}}'.
+ ' LEFT JOIN {{folder}} ON {{acl}}.folderid = {{folder}}.id'.
+ ' WHERE {{folder}}.projectid={projectid}'.
+ ' AND {{acl}}.groupid={groupid}' );
+ $sql->setInt('projectid',$projectid );
+ $sql->setInt('groupid' ,$this->groupid );
+
+ $acls = $sql->getAll();
+
+ 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 = $db->sql( 'SELECT id FROM {{folder}}'.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$projectid);
+ $folders = $sql->getCol();
+
+ $var[$projectid]['folders'] = array();
+
+ foreach( $folders as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ $folder->load();
+ $var[$projectid]['folders'][$folderid] = implode(' » ',$folder->parentfolder( false,true ));
+ }
+
+ asort( $var[$projectid]['folders'] );
+ }
+
+ return $var;
+ }
+
+
+ // Berechtigung der Gruppe hinzufuegen
+ function addRight( $data )
+ {
+ global $REQ,$SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('INSERT INTO {{acl}} '.
+ '(userid,groupid,folderid,`read`,`write`,`create`,`delete`,publish) '.
+ 'VALUES({userid},{groupid},{folderid},{read},{write},{create},{delete},{publish})');
+
+ $sql->setNull('userid');
+ $sql->setInt ('groupid',$this->groupid);
+ $sql->setInt ('projectid',$SESS['projectid']);
+ $sql->setInt ('folderid',$data['folderid']);
+
+ $sql->setInt ('read' ,$data['read' ]);
+ $sql->setInt ('write' ,$data['write' ]);
+ $sql->setInt ('create' ,$data['create' ]);
+ $sql->setInt ('delete' ,$data['delete' ]);
+ $sql->setInt ('publish',$data['publish']);
+
+ // Datenbankabfrage ausf?hren
+ $sql->query();
+ }
+
+
+
+ /**
+ * Ermitteln aller Berechtigungen dieser Gruppe.<br>
+ * Diese Daten werden auf der Gruppenseite in der Administration angezeigt.
+ *
+ * @return unknown
+ */
+ function getAllAcls()
+ {
+ $db = db_connection();
+ $sql = $db->sql( 'SELECT {{acl}}.*,{{object}}.projectid,{{language}}.name AS languagename FROM {{acl}}'.
+ ' LEFT JOIN {{object}} '.
+ ' ON {{object}}.id={{acl}}.objectid '.
+ ' LEFT JOIN {{language}} '.
+ ' ON {{language}}.id={{acl}}.languageid '.
+ ' WHERE ( {{acl}}.groupid={groupid} OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )'.
+ ' ORDER BY {{object}}.projectid,{{acl}}.languageid' );
+ $sql->setInt ( 'groupid' ,$this->groupid );
+
+ $aclList = array();
+
+ foreach($sql->getAll() as $row )
+ {
+ $acl = new Acl();
+ $acl->setDatabaseRow( $row );
+ $acl->projectid = $row['projectid' ];
+ if ( intval($acl->languageid) == 0 )
+ $acl->languagename = lang('GLOBAL_ALL_LANGUAGES');
+ else
+ $acl->languagename = $row['languagename'];
+ $aclList[] = $acl;
+ }
+
+ return $aclList;
+ }
+
+
+
+ // Berechtigung entfernen
+ function delRight( $aclid )
+ {
+ $sql = $db->sql('DELETE FROM {{acl}} WHERE id={aclid}');
+ $sql->setInt( 'aclid',$aclid );
+
+ // Datenbankabfrage ausf?hren
+ $sql->query( $sql );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Language.class.php b/modules/cms-core/model/Language.class.php
@@ -0,0 +1,287 @@
+<?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.
+
+
+/**
+ * Darstellen einer Sprache. Jeder Seiteninhalt wird einer Sprache zugeordnet.
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Language
+{
+ var $languageid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isoCode = '';
+ var $isDefault = false;
+
+
+ // Konstruktor
+ function __construct( $languageid='' )
+ {
+ global $SESS;
+
+ if ( is_numeric($languageid) )
+ $this->languageid = $languageid;
+
+// $this->projectid = $SESS['projectid'];
+ }
+
+
+
+ /**
+ * Stellt fest, ob die angegebene Id existiert.
+ */
+ function available( $id )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT 1 FROM {{language}} '.
+ ' WHERE id={id}');
+ $sql->setInt('id' ,$id );
+
+ return intval($sql->getOne()) == 1;
+ }
+
+
+
+ // Lesen aller Sprachen aus der Datenbank
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( "SELECT id,name FROM {{language}} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( !empty($this) && !empty($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+
+ return $sql->getAssoc();
+ }
+
+
+ /**
+ * Ermittelt die Anzahl aller Sprachen zum aktuellen Projekt.
+ */
+ function count()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT count(*) FROM {{language}}
+ WHERE projectid = {projectid}
+SQL
+);
+
+ if ( !empty($this) && !empty($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+
+ return $sql->getOne();
+ }
+
+
+ // Lesen aus der Datenbank
+ function load()
+ {
+ $db = \Session::getDatabase();
+
+ $sql = $db->sql( 'SELECT * FROM {{language}}'.
+ ' WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+
+ $row = $sql->getRow();
+
+ if ( count($row) > 0 )
+ {
+ $this->name = $row['name' ];
+ $this->isoCode = $row['isocode' ];
+ $this->projectid = intval( $row['projectid'] );
+
+ $this->isDefault = ( $row['is_default'] == '1' );
+ }
+ }
+
+
+ // Speichern der Sprache in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = $db->sql( 'UPDATE {{language}} '.
+ 'SET name = {name}, '.
+ ' isocode = {isocode} '.
+ 'WHERE id={languageid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setString( 'isocode' ,$this->isoCode );
+
+ $sql->setInt( 'languageid',$this->languageid );
+
+ // Datenbankabfrage ausfuehren
+ $sql->query();
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften dieser Sprache
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'isocode'=>$this->isoCode );
+ }
+
+
+ /**
+ * Neue Sprache hinzuf?gen
+ */
+ function add( $isocode='' )
+ {
+ global $SESS;
+ global $iso;
+ $db = db_connection();
+
+ if ( $isocode != '' )
+ {
+ // Kleiner Trick, damit "no" (Norwegen) in der .ini-Datei stehen kann
+ $isocode = str_replace('_','',$isocode);
+
+ $this->isocode = $isocode;
+ $codes = \GlobalFunctions::getIsoCodes();
+ $this->name = $codes[ $isocode ];
+ }
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{language}}');
+ $this->languageid = intval($sql->getOne())+1;
+
+ // Sprache hinzuf?gen
+ $sql = $db->sql( 'INSERT INTO {{language}} '.
+ '(id,projectid,name,isocode,is_default) VALUES( {languageid},{projectid},{name},{isocode},0 )');
+ $sql->setInt ('languageid',$this->languageid );
+ $sql->setInt ('projectid' ,$this->projectid );
+ $sql->setString('name' ,$this->name );
+ $sql->setString('isocode' ,$this->isoCode );
+
+ // Datenbankbefehl ausfuehren
+ $sql->query();
+ }
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = $db->sql( 'UPDATE {{language}} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$this->projectid );
+ $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();
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{language}} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+
+ return $sql->getOne();
+ }
+
+
+ // Sprache entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Sprache l?schen
+// $sql = $db->sql( 'SELECT COUNT(*) FROM {{language}} WHERE projectid={projectid}' );
+// $sql->setInt( 'projectid',$this->projectid );
+// $count = $sql->getOne( $sql );
+//
+// // Nur l?schen, wenn es mindestens 2 Sprachen gibt
+// if ( $count >= 2 )
+// {
+ // Inhalte mit dieser Sprache l?schen
+ $sql = $db->sql( 'DELETE FROM {{value}} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $sql->query();
+
+ // Inhalte mit dieser Sprache l?schen
+ $sql = $db->sql( 'DELETE FROM {{name}} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $sql->query();
+
+ // Sprache l?schen
+ $sql = $db->sql( 'DELETE FROM {{language}} WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $sql->query();
+
+ // Andere Sprache auf "Default" setzen
+ $sql = $db->sql( 'SELECT id FROM {{language}} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_languageid = $sql->getOne();
+
+ $sql = $db->sql( 'UPDATE {{language}} SET is_default=1 WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$new_default_languageid );
+ $sql->query();
+// }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Link.class.php b/modules/cms-core/model/Link.class.php
@@ -0,0 +1,129 @@
+<?php
+namespace cms\model;
+
+
+/**
+ * Darstellen einer Verkn�pfung. Eine Verkn�pfung kann auf eine Objekt oder auf
+ * eine beliebige Url zeigen
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Link extends Object
+{
+ var $linkid;
+ var $linkedObjectId = 0;
+ var $url = '';
+
+ public function __construct( $objectid='' )
+ {
+ parent::__construct( $objectid );
+ $this->isLink = true;
+ }
+
+
+
+ /**
+ * Lesen der Verknuepfung aus der Datenbank
+ * @throws \ObjectNotFoundException
+ */
+ public function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT *'.
+ ' FROM {{link}}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $sql->getRow();
+
+ if ( count($row ) != 0 )
+ {
+ $this->linkedObjectId = $row['link_objectid'];
+ }
+
+ $this->objectLoad();
+ }
+
+
+ /**
+ *
+ */
+ public function delete()
+ {
+ $db = db_connection();
+
+ // Verkn�pfung l�schen
+ $sql = $db->sql( 'DELETE FROM {{link}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+
+ $sql->query();
+
+ $this->objectDelete();
+ }
+
+
+ /**
+ *
+ */
+ public function save()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{link}} SET '.
+ ' link_objectid = {linkobjectid}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setInt ('linkobjectid',$this->linkedObjectId );
+
+ $sql->query();
+
+ $this->objectSave();
+ }
+
+
+ public function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ array( 'objectid' =>$this->objectid,
+ 'linkobjectid' =>$this->linkedObjectId
+ ));
+ }
+
+
+ public function getType()
+ {
+ return 'link';
+ }
+
+
+ /**
+ * Add a new link.
+ */
+ public function add()
+ {
+ $this->objectAdd();
+
+ $db = db_connection();
+
+ $stmt = $db->sql('SELECT MAX(id) FROM {{link}}');
+ $this->linkid = intval($stmt->getOne())+1;
+
+ $stmt = $db->sql('INSERT INTO {{link}}'.
+ ' (id,objectid,link_objectid)'.
+ ' VALUES( {linkid},{objectid},{linkobjectid} )' );
+ $stmt->setInt ('linkid' ,$this->linkid );
+ $stmt->setInt ('objectid' ,$this->objectid );
+
+ if ($this->linkedObjectId == 0)
+ $stmt->setNull('linkobjectid');
+ else
+ $stmt->setInt ('linkobjectid',$this->linkedObjectId );
+
+ $stmt->query();
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Model.class.php b/modules/cms-core/model/Model.class.php
@@ -0,0 +1,283 @@
+<?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.
+
+
+
+/**
+ * Diese Klasse stellt ein Projektmodell dar. Ein Projektmodell ist eine Darstellungsart
+ * der Inhalte. Zu jedem Projektmodell gibt es einen anderen Templatequelltext.
+ * Beispiel: Neben HTML gibt es ein Projektmodell fuer WML oder XML. Die Inhalte sind gleich,
+ * aber die Art der Ausgabe ist jeweils anders.
+ *
+ * @package openrat.objects
+ * @author $Author$
+ * @version $Rev: $
+ */
+class Model
+{
+ var $modelid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isDefault = false;
+
+
+ /**
+ * Konstruktor
+ */
+ function __construct( $modelid='' )
+ {
+ if ( is_numeric($modelid) )
+ $this->modelid = $modelid;
+ }
+
+
+ /**
+ * Stellt fest, ob die angegebene Id existiert.
+ */
+ function available( $id )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT 1 FROM {{projectmodel}} '.
+ ' WHERE id={id}');
+ $sql->setInt('id' ,$id );
+
+ return intval($sql->getOne()) == 1;
+ }
+
+
+
+
+ /**
+ * Lesen aller Projektmodelle aus der Datenbank
+ */
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( "SELECT id,name FROM {{projectmodel}} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( !empty($this) && !empty($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+
+ return $sql->getAssoc();
+ }
+
+
+
+ /**
+ * Bestimmt die Anzahl aller Varianten fuer das aktuelle Projekt.
+ */
+ function count()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT count(*) FROM {{projectmodel}}
+ WHERE projectid = {projectid}
+SQL
+);
+ if ( isset($this) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $sql->getOne();
+ }
+
+
+ /**
+ * Lesen aus der Datenbank
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{projectmodel}}'.
+ ' WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$this->modelid );
+
+ $row = $sql->getRow();
+
+ $this->name = $row['name' ];
+ $this->projectid = $row['projectid'];
+
+ if ( $row['is_default'] == '1' )
+ $this->isDefault = true;
+ else $this->isDefault = false;
+ }
+
+
+ /**
+ * Speichern des Projektmodells
+ */
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = $db->sql( 'UPDATE {{projectmodel}} '.
+ ' SET name = {name} '.
+ ' WHERE id={modelid}' );
+ $sql->setString( 'name' ,$this->name );
+
+ $sql->setInt( 'modelid',$this->modelid );
+
+ // Datenbankabfrage ausfuehren
+ $sql->query();
+ }
+
+
+ /**
+ * Alle notwendigen Eigenschaften dieses Projektmodells
+ * werden als Array zurueckgegeben
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'modelid' =>$this->modelid,
+ 'projectid'=>$this->projectid,
+ 'isDefault'=>$this->isDefault,
+ 'name' =>$this->name );
+ }
+
+
+ /**
+ * Modell hinzufuegen
+ * @param String Name des Modells (optional)
+ */
+ function add( $name = '' )
+ {
+ if ( $name != '' )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{projectmodel}}');
+ $this->modelid = intval($sql->getOne())+1;
+
+ // Modell hinzuf?gen
+ $sql = $db->sql( 'INSERT INTO {{projectmodel}} '.
+ "(id,projectid,name,extension,is_default) VALUES( {modelid},{projectid},{name},'',0 )");
+
+ $sql->setInt ('modelid' ,$this->modelid );
+ $sql->setInt ('projectid',$this->projectid );
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $sql->query();
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{projectmodel}} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt('projectid',$project->projectid);
+ }
+
+ return $sql->getOne();
+ }
+
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = $db->sql( 'UPDATE {{projectmodel}} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$this->projectid );
+ $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();
+ }
+
+
+ /**
+ * Entfernen des Projektmodells aus der Datenbank
+ * Es wird dabei nicht geprueft, ob noch ein anders Projektmodell
+ * vorhanden ist.
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Vorlagen zu dieseem Modell loeschen
+ $sql = $db->sql( <<<SQL
+ DELETE FROM {{templatemodel}}
+ WHERE projectmodelid = {modelid}
+SQL
+);
+ $sql->setInt( 'modelid',$this->modelid );
+ $sql->query();
+
+ // Dieses Modell löschen
+ $sql = $db->sql( <<<SQL
+ DELETE FROM {{projectmodel}}
+ WHERE id={modelid}
+SQL
+);
+ $sql->setInt( 'modelid',$this->modelid );
+ $sql->query();
+
+ // Anderes Modell auf "Default" setzen (sofern vorhanden)
+ if ( $this->isDefault )
+ {
+ $sql = $db->sql( 'SELECT id FROM {{projectmodel}} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_modelid = $sql->getOne();
+
+ $sql = $db->sql( 'UPDATE {{projectmodel}} SET is_default=1 WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$new_default_modelid );
+ $sql->query();
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/ModelBase.class.php b/modules/cms-core/model/ModelBase.class.php
@@ -0,0 +1,17 @@
+<?php
+namespace cms\model;
+
+class ModelBase
+{
+ protected function setDatabaseRow( $row )
+ {
+
+ }
+
+ public function getProperties()
+ {
+ return get_object_vars( $this );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Object.class.php b/modules/cms-core/model/Object.class.php
@@ -0,0 +1,1375 @@
+<?php
+
+namespace {
+ define('OR_TYPEID_FOLDER',1);
+ define('OR_TYPEID_FILE',2);
+ define('OR_TYPEID_PAGE',3);
+ define('OR_TYPEID_LINK',4);
+ define('OR_TYPEID_URL',5);
+
+}
+
+namespace cms\model {
+
+ /**
+ * Superklasse fuer Objekte im Projektbaum.
+ *
+ * Dieses Objekt ist die Oberklasse fuer die 4 Klassen Ordner, Datei,
+ * Link oder Seite dar.
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+ 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 $description = 'none';
+ var $desc = '';
+
+ /** Zeitpunkt der Erstellung. Die Variable beinhaltet den Unix-Timestamp.
+ * @type Integer
+ */
+ var $createDate;
+
+ /** Zeitpunkt der letzten Aenderung. Die Variable beinhaltet den Unix-Timestamp.
+ * @type Integer
+ */
+ var $lastchangeDate;
+
+ /** Benutzer, welcher dieses Objekt erstellt hat.
+ * @type User
+ */
+ public $createUser;
+
+ /** Benutzer, welcher dieses Objekt zuletzt geaendert hat.
+ * @type User
+ */
+ public $lastchangeUser;
+
+ /**
+ * 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 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>.
+ * @type Integer
+ */
+ var $type = null;
+
+ /** 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;
+
+ var $aclMask = null;
+
+ public $typeid;
+
+ /** <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 __construct($objectid = '')
+ {
+ global $SESS;
+
+ if ( is_numeric($objectid) )
+ {
+ $this->objectid = $objectid;
+ $this->id = $objectid;
+ }
+
+
+ $language = \Session::getProjectLanguage();
+ if ( is_object($language) )
+ $this->languageid = $language->languageid;
+
+ $model = \Session::getProjectModel();
+ if ( is_object($model) )
+ $this->modelid = $model->modelid;
+
+ $project = \Session::getProject();
+ if ( is_object($project) )
+ $this->projectid = $project->projectid;
+ }
+
+
+ /**
+ * Lesen aller Objekte aus dem aktuellen Projekt
+ * @return array Alle Objekt-IDs des aktuellen Projektes
+ */
+ function getAllObjectIds()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ if ( ! isset($this->projectid) )
+ {
+ $project = \Session::getProject();
+ $projectid = $project->projectid;
+ }
+ else
+ {
+ $projectid = $this->projectid;
+ }
+
+ $sql = $db->sql('SELECT id from {{object}} '.
+ ' WHERE projectid={projectid}');
+ $sql->setInt('projectid', $projectid);
+
+ return $sql->getCol();
+ }
+
+
+ // Kompletten Dateinamen des Objektes erzeugen
+ function full_filename()
+ {
+ $path = $this->path();
+
+ if ($path != '')
+ $path.= '/';
+
+ $path.= $this->filename();
+
+ return $path;
+ }
+
+ /**
+ * Pr?fen einer Berechtigung zu diesem Objekt
+ */
+ function checkRight( $type )
+ {
+ return true;
+ }
+
+
+ /**
+ * Pruefen einer Berechtigung zu diesem Objekt
+ */
+ function hasRight( $type )
+ {
+ if ( is_null($this->aclMask) )
+ {
+ $project = \Session::getProject();
+ $language = \Session::getProjectLanguage();
+ $user = \Session::getUser();
+
+ if ( $user->isAdmin )
+ {
+ // Administratoren erhalten eine Maske mit allen Rechten
+ $this->aclMask = ACL_READ +
+ ACL_WRITE +
+ ACL_PROP +
+ ACL_DELETE +
+ ACL_RELEASE +
+ ACL_PUBLISH +
+ ACL_CREATE_FOLDER +
+ ACL_CREATE_FILE +
+ ACL_CREATE_LINK +
+ ACL_CREATE_PAGE +
+ ACL_GRANT +
+ ACL_TRANSMIT;
+ }
+ else
+ {
+ $this->aclMask = 0;
+
+ $db = db_connection();
+ $sqlGroupClause = $user->getGroupClause();
+ $sql = $db->sql( <<<SQL
+SELECT {{acl}}.* FROM {{acl}}
+ LEFT JOIN {{object}}
+ ON {{object}}.id={{acl}}.objectid
+ WHERE objectid={objectid}
+ AND ( languageid={languageid} OR languageid IS NULL )
+ AND ( {{acl}}.userid={userid} OR $sqlGroupClause
+ OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )
+SQL
+ );
+
+ $sql->setInt ( 'languageid' ,$language->languageid );
+ $sql->setInt ( 'objectid' ,$this->objectid );
+ $sql->setInt ( 'userid' ,$user->userid );
+
+ foreach($sql->getAll() as $row )
+ {
+ $acl = new Acl();
+ $acl->setDatabaseRow( $row );
+
+ $this->aclMask |= $acl->getMask();
+ }
+ }
+ }
+
+ if ( readonly() )
+ // System ist im Nur-Lese-Zustand
+ return $type == ACL_READ && $this->aclMask & $type;
+ else
+ // Ermittelte Maske auswerten
+ return $this->aclMask & $type;
+ }
+
+
+ /**
+ * Typ des Objektes ermitteln
+ *
+ * @return String der Typ des Objektes entweder 'folder','file','page' oder 'link'
+ */
+ function getType()
+ {
+ if ($this->isFolder)
+ return OR_TYPE_FOLDER;
+ if ($this->isFile)
+ return OR_TYPE_FILE;
+ if ($this->isPage)
+ return OR_TYPE_PAGE;
+ if ($this->isLink)
+ return OR_TYPE_LINK;
+ if ($this->isUrl)
+ return OR_TYPE_URL;
+
+ return 'unknown';
+ }
+
+
+ function getProperties()
+ {
+ return Array( 'id' =>$this->objectid,
+ 'objectid' =>$this->objectid,
+ 'parentid' =>$this->parentid,
+ 'filename' =>$this->filename,
+ 'name' =>$this->name,
+ 'desc' =>$this->desc,
+ 'description' =>$this->desc,
+ 'create_date' =>$this->createDate,
+ 'create_user' =>$this->createUser->getProperties(),
+ 'lastchange_date' =>$this->lastchangeDate,
+ 'lastchange_user' =>$this->lastchangeUser->getProperties(),
+ 'isFolder' =>$this->isFolder,
+ 'isFile' =>$this->isFile,
+ 'isLink' =>$this->isLink,
+ 'isUrl' =>$this->isUrl,
+ 'isPage' =>$this->isPage,
+ 'isRoot' =>$this->isRoot,
+ 'languageid' =>$this->languageid,
+ 'modelid' =>$this->modelid,
+ 'projectid' =>$this->projectid,
+ 'type' =>$this->getType() );
+ }
+
+
+ /**
+ * 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));
+ }
+
+
+
+ /**
+ * Ueberpruft einen Dateinamen auf Gueltigkeit.
+ */
+ function goodFilename( $filename )
+ {
+ // Dateiname muss gueltig sein,
+ // ungueltige Zeichen werden entfernt
+ $gueltig = 'abcdefghijklmnopqrstuvwxyz0123456789.-_';
+ $tmp = strtr($filename, $gueltig, str_repeat('#', strlen($gueltig)));
+ return( strtr($this->filename, $tmp, str_repeat('-', strlen($tmp))) );
+ }
+
+
+
+ /**
+ * Ermitteln des Dateinamens und Rueckgabe desselben
+ * @return String Dateiname
+ */
+ function filename()
+ {
+
+ global $conf;
+
+ if ( $conf['filename']['edit'] && $this->filename != '' && $this->filename != $this->objectid )
+ {
+ $this->filename = $this->goodFilename(trim(strtolower($this->name)));
+ return $this->filename;
+ }
+
+ if ( $this->type == OR_TYPE_FOLDER )
+ {
+ $this->filename = $this->objectid;
+ }
+ elseif ( $this->orderid == 1 &&
+ !empty($conf['filename']['default']) &&
+ !$conf['filename']['edit'] )
+ {
+ $this->filename = $conf['filename']['default'];
+ }
+ else
+ {
+ switch( $conf['filename']['style'] )
+ {
+ case 'longid':
+ // Eine etwas laengere ID als Dateinamen benutzen
+ $this->filename = base_convert(str_pad($this->objectid,6,'a'),11,10);
+ break;
+
+ case 'id':
+ // Einfach die Objekt-Id als Dateinamen verwenden.
+ $this->filename = $this->objectid;
+ break;
+
+ case 'short':
+ // So kurz wie moeglich: Erhoehen der Basis vom 10 auf 36.
+ // Beispiele:
+ // 1 -> 1
+ // 10 -> a
+ $this->filename = base_convert($this->objectid,10,36);
+ break;
+
+ case 'md5':
+ // MD5-Summe als Dateinamen verwenden
+ // Achtung: Kollisionen sind unwahrscheinlich, aber theoretisch möglich.
+ $this->filename = md5(md5($this->objectid));
+ break;
+
+ case 'ss':
+ // Imitieren von "StoryServer" URLs. Wers braucht.
+ $this->filename = '0,'.
+ base_convert(str_pad($this->parentid,3,'a'),11,10).
+ ','.
+ base_convert(str_pad($this->objectid,7,'a'),11,10).
+ ',00';
+ break;
+
+ case 'title':
+ // Achtung: Kollisionen sind möglich.
+ $this->filename = $this->goodFilename(trim(strtolower($this->name)));
+ break;
+
+ default:
+ // Als Fallback die Objekt-Id als Dateinamen verwenden.
+ $this->filename = $this->objectid;
+ }
+ }
+
+ return $this->filename;
+ }
+
+
+
+ /**
+ * Stellt fest, ob das Objekt mit der angegebenen Id existiert.
+ */
+ public static function available( $objectid )
+ {
+ $db = db_connection();
+
+ // Vielleicht k�nnen wir uns den DB-Zugriff auch ganz sparen.
+ if ( !is_numeric($objectid) || $objectid <= 0 )
+ return false; // Objekt-Id ung�ltig.
+
+ $sql = $db->sql('SELECT 1 FROM {{object}} '.
+ ' WHERE id={objectid}');
+ $sql->setInt('objectid' , $objectid );
+
+ return intval($sql->getOne()) == 1;
+ }
+
+
+ /**
+ * 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
+ * @throws \ObjectNotFoundException
+ */
+ function objectLoad()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT {{object}}.*,' .
+ ' {{name}}.name,{{name}}.descr,'.
+ ' lastchangeuser.name as lastchange_username, '.
+ ' lastchangeuser.fullname as lastchange_userfullname, '.
+ ' lastchangeuser.mail as lastchange_usermail, '.
+ ' createuser.name as create_username, '.
+ ' createuser.fullname as create_userfullname, '.
+ ' createuser.mail as create_usermail '.
+ ' FROM {{object}}'.
+ ' LEFT JOIN {{name}} '.
+ ' ON {{object}}.id={{name}}.objectid AND {{name}}.languageid={languageid} '.
+ ' LEFT JOIN {{user}} as lastchangeuser '.
+ ' ON {{object}}.lastchange_userid=lastchangeuser.id '.
+ ' LEFT JOIN {{user}} as createuser '.
+ ' ON {{object}}.create_userid=createuser.id '.
+ ' WHERE {{object}}.id={objectid}');
+ $sql->setInt('languageid', $this->languageid);
+ $sql->setInt('objectid' , $this->objectid );
+
+ $row = $sql->getRow();
+
+ if (count($row) == 0)
+ throw new \ObjectNotFoundException('object '.$this->objectid.' not found');
+
+ $this->setDatabaseRow( $row );
+ }
+
+
+ /**
+ * Lesen der Eigenschaften aus der Datenbank
+ * Es werden
+ * - die sprachunabhaengigen Daten wie Dateiname, Typ sowie Erstellungs- und Aenderungsdatum geladen
+ */
+ function objectLoadRaw()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT * FROM {{object}}'.
+ ' WHERE {{object}}.id={objectid}');
+ $sql->setInt('objectid' , $this->objectid );
+ $row = $sql->getRow();
+
+ if (count($row) == 0)
+ die('fatal: Object::objectLoadRaw(): objectid not found: '.$this->objectid.', SQL='.$sql->raw);
+
+ $this->parentid = $row['parentid' ];
+ $this->filename = $row['filename' ];
+ $this->projectid = $row['projectid'];
+
+ if ( intval($this->parentid) == 0 )
+ $this->isRoot = true;
+ else
+ $this->isRoot = false;
+
+ $this->name = 'n/a';
+
+ $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 = ( $row['typeid'] == OR_TYPEID_FOLDER );
+ $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 );
+
+ }
+
+
+ /**
+ * Setzt die Eigenschaften des Objektes mit einer Datenbank-Ergebniszeile
+ *
+ * @param row Ergebniszeile aus Datenbanktabelle
+ */
+ function setDatabaseRow( $row )
+ {
+ if ( count($row)==0 )
+ die('setDatabaseRow() got empty array, oid='.$this->objectid);
+
+ $this->parentid = $row['parentid' ];
+ $this->projectid = $row['projectid'];
+ $this->filename = $row['filename' ];
+ $this->orderid = $row['orderid' ];
+
+ if ( intval($this->parentid) == 0 )
+ $this->isRoot = true;
+ else $this->isRoot = false;
+
+ $this->createDate = $row['create_date' ];
+ $this->lastchangeDate = $row['lastchange_date'];
+
+ $this->createUser = new User();
+ $this->createUser->userid = $row['create_userid' ];
+ if ( !empty($row['create_username']) )
+ {
+ $this->createUser->name = $row['create_username' ];
+ $this->createUser->fullname = $row['create_userfullname' ];
+ $this->createUser->mail = $row['create_usermail' ];
+ }
+
+ $this->lastchangeUser = new User();
+ $this->lastchangeUser->userid = $row['lastchange_userid' ];
+
+ if ( !empty($row['lastchange_username']) )
+ {
+ $this->lastchangeUser->name = $row['lastchange_username' ];
+ $this->lastchangeUser->fullname = $row['lastchange_userfullname'];
+ $this->lastchangeUser->mail = $row['lastchange_usermail' ];
+ }
+
+ $this->typeid = $row['typeid'];
+
+ $this->isFolder = ( $row['typeid'] == OR_TYPEID_FOLDER );
+ $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 )
+ {
+ $project = \Session::getProject();
+ $this->name = $project->name;
+ $this->desc = '';
+ $this->description = '';
+ }
+ else
+ {
+ $this->name = $row['name' ];
+ $this->desc = $row['descr'];
+ $this->description = $row['descr'];
+ }
+
+ $this->checkName();
+ }
+
+
+
+ /**
+ * 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 = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND languageid={languageid}');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $this->languageid);
+ $res = $sql->query();
+
+ if ($res->numRows() == 0)
+ {
+ // Wenn Name in dieser Sprache nicht vorhanden, dann irgendeinen Namen lesen
+ $sql = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND name != {blank}');
+ $sql->setInt ('objectid' , $this->objectid );
+ $sql->setInt ('languageid', $this->languageid);
+ $sql->setString('blank' , '' );
+
+ $res = $sql->execute();
+ }
+ $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( $withName = true )
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $this->checkFilename();
+
+ $sql = $db->sql( <<<SQL
+UPDATE {{object}} SET
+ parentid = {parentid},
+ lastchange_date = {time} ,
+ lastchange_userid = {userid} ,
+ filename = {filename}
+ WHERE id={objectid}
+SQL
+ );
+
+
+ if ( $this->isRoot )
+ $sql->setNull('parentid');
+ else $sql->setInt ('parentid',$this->parentid );
+
+
+ $user = \Session::getUser();
+ $this->lastchangeUser = $user;
+ $this->lastchangeDate = now();
+ $sql->setInt ('time' ,$this->lastchangeDate );
+ $sql->setInt ('userid' ,$this->lastchangeUser->userid );
+ $sql->setString('filename', $this->filename);
+ $sql->setInt ('objectid', $this->objectid);
+
+
+ $sql->query();
+
+ // Nur wenn nicht Wurzelordner
+ if ( !$this->isRoot && $withName )
+ {
+ if ( $this->name == '' )
+ $this->name = $this->filename;
+
+ $this->objectSaveName();
+ }
+ }
+
+
+
+ /**
+ * Aenderungsdatum auf Systemzeit setzen
+ */
+ function setTimestamp()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{object}} SET '.
+ ' lastchange_date = {time} ,'.
+ ' lastchange_userid = {userid} '.
+ ' WHERE id={objectid}');
+
+ $user = \Session::getUser();
+ $this->lastchangeUser = $user;
+ $this->lastchangeDate = now();
+
+ $sql->setInt ('userid' ,$this->lastchangeUser->userid );
+ $sql->setInt ('objectid',$this->objectid );
+ $sql->setInt ('time' ,$this->lastchangeDate );
+
+ $sql->query();
+
+ }
+
+
+ public function setCreationTimestamp()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{object}} SET '.
+ ' create_date = {time} '.
+ ' WHERE id={objectid}');
+
+ $sql->setInt ('objectid',$this->objectid );
+ $sql->setInt ('time' ,$this->createDate );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Logischen Namen und Beschreibung des Objektes in Datenbank speichern
+ * (wird von objectSave() automatisch aufgerufen)
+ *
+ * @access private
+ */
+ function ObjectSaveName()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql(<<<SQL
+SELECT COUNT(*) FROM {{name}} WHERE objectid ={objectid} AND languageid={languageid}
+SQL
+ );
+ $sql->setInt( 'objectid' , $this->objectid );
+ $sql->setInt( 'languageid', $this->languageid );
+ $count = $sql->getOne();
+
+ if ($count > 0)
+ {
+ $sql = $db->sql( <<<SQL
+ UPDATE {{name}} SET
+ name = {name},
+ descr = {desc}
+ WHERE objectid ={objectid}
+ AND languageid={languageid}
+SQL
+ );
+ $sql->setString('name', $this->name);
+ $sql->setString('desc', $this->desc);
+ $sql->setInt( 'objectid' , $this->objectid );
+ $sql->setInt( 'languageid', $this->languageid );
+ $sql->query();
+ }
+ else
+ {
+ $sql = $db->sql('SELECT MAX(id) FROM {{name}}');
+ $nameid = intval($sql->getOne())+1;
+
+ $sql = $db->sql('INSERT INTO {{name}}'.' (id,objectid,languageid,name,descr)'.' VALUES( {nameid},{objectid},{languageid},{name},{desc} )');
+ $sql->setInt ('objectid' , $this->objectid );
+ $sql->setInt ('languageid', $this->languageid );
+ $sql->setInt ('nameid', $nameid );
+ $sql->setString('name' , $this->name);
+ $sql->setString('desc' , $this->desc);
+ $sql->query();
+ }
+ }
+
+ /**
+ * Objekt loeschen. Es muss sichergestellt sein, dass auch das Unterobjekt geloeschet wird.
+ * Diese Methode wird daher normalerweise nur vom Unterobjekt augerufen
+ * @access protected
+ */
+ function objectDelete()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{element}} '.
+ ' SET default_objectid=NULL '.
+ ' WHERE default_objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+ $sql = $db->sql( 'UPDATE {{value}} '.
+ ' SET linkobjectid=NULL '.
+ ' WHERE linkobjectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+ $sql = $db->sql( 'UPDATE {{link}} '.
+ ' SET link_objectid=NULL '.
+ ' WHERE link_objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+
+ // Objekt-Namen l?schen
+ $sql = $db->sql('DELETE FROM {{name}} WHERE objectid={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->query();
+
+ // ACLs loeschen
+ $this->deleteAllACLs();
+
+ // Objekt l?schen
+ $sql = $db->sql('DELETE FROM {{object}} WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->query();
+ }
+
+
+ /**
+ * Objekt hinzufuegen
+ */
+ function objectAdd()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Neue Objekt-Id bestimmen
+ $sql = $db->sql('SELECT MAX(id) FROM {{object}}');
+ $this->objectid = intval($sql->getOne())+1;
+
+ $this->checkFilename();
+ $sql = $db->sql('INSERT INTO {{object}}'.
+ ' (id,parentid,projectid,filename,orderid,create_date,create_userid,lastchange_date,lastchange_userid,typeid)'.
+ ' VALUES( {objectid},{parentid},{projectid},{filename},{orderid},{time},{createuserid},{createtime},{userid},{typeid} )');
+
+ if ( $this->isRoot )
+ $sql->setNull('parentid');
+ else $sql->setInt ('parentid',$this->parentid );
+
+ $sql->setInt ('objectid' , $this->objectid );
+ $sql->setString('filename' , $this->filename );
+ $sql->setString('projectid', $this->projectid);
+ $sql->setInt ('orderid' , 99999 );
+ $sql->setInt ('time' , now() );
+ $user = \Session::getUser();
+ $sql->setInt ('createuserid' , $user->userid );
+ $sql->setInt ('createtime' , now() );
+ $user = \Session::getUser();
+ $sql->setInt ('userid' , $user->userid );
+
+ $sql->setInt( 'typeid',$this->getTypeid());
+
+ $sql->query();
+
+ if ( !empty($this->name) )
+ $this->objectSaveName();
+
+ // Standard-Rechte fuer dieses neue Objekt setzen.
+ // Der angemeldete Benutzer erhaelt Lese- und Schreibrechte auf
+ // das neue Objekt.
+ $acl = new Acl();
+ $acl->userid = $user->userid;
+ $acl->objectid = $this->objectid;
+
+ $acl->read = true;
+ $acl->write = true;
+ $acl->prop = true;
+ $acl->delete = true;
+ $acl->grant = true;
+ if ( $this->isFolder )
+ {
+ $acl->create_file = true;
+ $acl->create_page = true;
+ $acl->create_folder = true;
+ $acl->create_link = true;
+ }
+ $acl->add();
+
+ // Aus dem Eltern-Ordner vererbbare Berechtigungen uebernehmen.
+ $folder = new Folder( $this->parentid );
+ foreach( $folder->getAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+
+ if ( $acl->transmit ) // ACL is vererbbar, also kopieren.
+ {
+ $acl->objectid = $this->objectid;
+ $acl->add(); // ... und hinzufuegen.
+ }
+ }
+ }
+
+
+ /**
+ * Pruefung auf Gueltigkeit des Dateinamens
+ */
+ function checkFilename()
+ {
+ if ( empty($this->filename) )
+ $this->filename = $this->objectid;
+
+// $this->filename = trim(strtolower($this->filename));
+
+// $this->filename = $this->goodFilename( $this->filename);
+
+ if ( $this->isRoot )
+ return;
+
+ if ( !$this->filenameIsUnique( $this->filename ) )
+ {
+// $this->filename = $this->objectid;
+//
+// if ( !$this->filenameIsUnique( $this->filename ) )
+ $this->filename = $this->filename.'.'.md5(microtime());
+ }
+ }
+
+
+ function filenameIsUnique( $filename )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+SELECT COUNT(*) FROM {{object}}
+ WHERE parentid={parentid} AND filename={filename}
+ AND NOT id = {objectid}
+SQL
+ );
+
+ $sql->setString('parentid', $this->parentid);
+ $sql->setString('filename', $filename );
+ $sql->setString('objectid', $this->objectid);
+
+
+ return( intval($sql->getOne()) == 0 );
+ }
+
+
+ /**
+ * Pruefung auf Gueltigkeit des logischen Namens
+ */
+ function checkName()
+ {
+ if ( empty($this->name) )
+ $this->name = $this->filename;
+
+ if ( empty($this->name) )
+ $this->name = $this->objectid;
+ }
+
+
+ function getAclIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{acl}} '.
+ ' WHERE objectid={objectid}'.
+ ' AND ( languageid IS NULL OR '.
+ ' languageid = {languageid} )'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('languageid',$this->languageid);
+ $sql->setInt('objectid' ,$this->objectid);
+
+ return $sql->getCol();
+ }
+
+
+ function getAllAclIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{acl}} '.
+ ' WHERE objectid={objectid}'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$this->objectid);
+
+ return $sql->getCol();
+ }
+
+
+ function getInheritedAclIds()
+ {
+ $acls = array();
+
+ if ( $this->getType() == 'unknown' )
+ $this->load();
+
+ // Root-Ordner erhaelt keine Vererbungen
+ if ( $this->isRoot )
+ return $acls;
+
+ $db = db_connection();
+ $folder = new Folder( $this->parentid );
+
+ foreach( $folder->parentObjectFileNames(true,true) as $oid=>$filename )
+ {
+ $sql = $db->sql( 'SELECT id FROM {{acl}} '.
+ ' WHERE objectid={objectid}'.
+ ' AND is_transmit = 1'.
+ ' AND ( languageid IS NULL OR '.
+ ' languageid = {languageid} )'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$oid);
+ $sql->setInt('languageid',$this->languageid);
+ $acls = array_merge( $acls,$sql->getCol() );
+ }
+
+ return $acls;
+ }
+
+
+ function getAllInheritedAclIds()
+ {
+ $acls = array();
+
+ if ( $this->getType() == 'unknown' )
+ $this->load();
+
+ // Root-Ordner erhaelt keine Vererbungen
+ if ( $this->isRoot )
+ return $acls;
+
+ $db = db_connection();
+ $folder = new Folder( $this->parentid );
+
+ foreach( $folder->parentObjectFileNames(true,true) as $oid=>$filename )
+ {
+ $sql = $db->sql( 'SELECT id FROM {{acl}} '.
+ ' WHERE objectid={objectid}'.
+ ' AND is_transmit = 1'.
+ ' ORDER BY userid,groupid ASC' );
+ $sql->setInt('objectid' ,$oid);
+ $acls = array_merge( $acls,$sql->getCol() );
+ }
+
+ return $acls;
+ }
+
+
+ /**
+ * Ermitteln aller Berechtigungsstufen, die fuer diesen Objekttyp wichtig sind
+ */
+ function getRelatedAclTypes()
+ {
+ if ( $this->isFolder )
+ return( array('read','write','delete','prop','release','publish','create_folder','create_file','create_page','create_link','grant','transmit') );
+ if ( $this->isFile )
+ return( array('read','write','delete','prop','release','publish','grant') );
+ if ( $this->isPage )
+ 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') );
+ }
+
+
+ /**
+ * Ermitteln aller Berechtigungsstufen, die fuer diesen Objekttyp wichtig sind
+ */
+ function getAssocRelatedAclTypes()
+ {
+ $rights = array('read','write','delete','prop','release','publish','create_folder','create_file','create_page','create_link','grant','transmit');
+ $types = array();
+ foreach( $rights as $r )
+ $types[$r] = false;
+
+ foreach( $this->getRelatedAclTypes() as $t )
+ $types[$t] = true;
+
+ return $types;
+ }
+
+ /**
+ * Entfernen aller ACLs zu diesem Objekt
+ * @access private
+ */
+ function deleteAllACLs()
+ {
+ foreach( $this->getAllAclIds() as $aclid )
+ {
+ $acl = new Acl( $aclid );
+ $acl->load();
+ $acl->delete();
+ }
+ }
+
+
+
+ /**
+ * Liefert einen temporären Dateinamen.
+ * @param $attr Attribute fuer den Dateinamen, um diesen eindeutig zu gestalten.
+ * @return unknown_type
+ */
+ public function getTempFileName( $attr = array() )
+ {
+ global $conf;
+
+// if ( $conf['cache']['enable_cache'] )
+// {
+ $filename = \FileUtils::getTempDir().'/openrat';
+ foreach( $attr as $a=>$w )
+ $filename .= '_'.$a.$w;
+
+ $filename .= '.tmp';
+ return $filename;
+// }
+// else
+// {
+// $tmpdir = @$conf['cache']['tmp_dir'];
+// $tmpfile = tempnam( $tmpdir,'openrat_tmp' );
+//
+// return $tmpfile;
+// }
+ }
+
+
+
+ /**
+ * Gibt ein fertiges Dateihandle fuer eine temporaere Datei zurück.
+ * @return Resource
+ */
+ protected function getTempFile()
+ {
+ return tmpfile();
+ }
+
+
+ public function getTempDir()
+ {
+ \FileUtils::getTempDir();
+ }
+
+ /**
+ * 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 = $db->sql('UPDATE {{object}} '.' SET orderid={orderid}'.' WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->setInt('orderid', $orderid);
+
+ $sql->query();
+ }
+
+
+ /**
+ * ?bergeordnete Objekt-ID dieses Objektes neu speichern
+ * die Nr. wird sofort in der Datenbank gespeichert.
+ *
+ * @param Integer ?bergeordnete Objekt-ID
+ */
+ function setParentId( $parentid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{object}} '.' SET parentid={parentid}'.' WHERE id={objectid}');
+ $sql->setInt('objectid', $this->objectid);
+ $sql->setInt('parentid', $parentid);
+
+ $sql->query();
+ }
+
+
+ function getDependentObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{page}}.objectid FROM {{value}}'.
+ ' LEFT JOIN {{page}} '.
+ ' ON {{value}}.pageid = {{page}}.id '.
+ ' WHERE linkobjectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einem bestimmten Namen ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByFileName( $text )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{object}} '.
+ ' WHERE filename LIKE {filename}'.
+ ' AND projectid={projectid}'.
+ ' ORDER BY lastchange_date DESC' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setString( 'filename','%'.$text.'%' );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einem Namen ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByName( $text )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{object}}.id FROM {{object}} '.
+ ' LEFT JOIN {{name}} '.
+ ' ON {{object}}.id={{name}}.objectid'.
+ ' WHERE {{name}}.name LIKE {name}'.
+ ' AND {{name}}.languageid={languageid}'.
+ ' AND {{object}}.projectid={projectid}'.
+ ' ORDER BY lastchange_date DESC' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'name' ,'%'.$text.'%' );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einer Beschreibung ermittelt
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByDescription( $text )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{object}}.id FROM {{object}} '.
+ ' LEFT JOIN {{name}} '.
+ ' ON {{object}}.id={{name}}.objectid'.
+ ' WHERE {{name}}.descr LIKE {desc}'.
+ ' AND {{name}}.languageid={languageid}'.
+ ' AND {{object}}.projectid={projectid}'.
+ ' ORDER BY lastchange_date DESC' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'desc' ,'%'.$text.'%' );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der Erstellung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByCreateUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{object}} '.
+ ' WHERE create_userid={userid}'.
+ ' AND projectid={projectid}'.
+ ' ORDER BY lastchange_date DESC' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der letzten ?nderung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByLastChangeUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{object}} '.
+ ' WHERE lastchange_userid={userid}'.
+ ' AND projectid={projectid}'.
+ ' ORDER BY lastchange_date DESC' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Gibt true zur?ck, wenn die angegebene Objekt-ID existiert
+ * @param Integer Objekt-ID
+ * @return Boolean
+ */
+ function isObjectId( $id )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{object}} '.
+ ' WHERE id={objectid}'.
+ ' AND projectid={projectid}' );
+ $sql->setInt ( 'projectid' ,$this->projectid );
+ $sql->setInt ( 'objectid' ,$id );
+
+ return ($sql->getOne() == intval($id) );
+ }
+
+
+
+ /**
+ * Liefert die Link-Ids, die auf das aktuelle Objekt verweisen.
+ * @return array Liste der gefundenen Objekt-IDs
+ */
+ public function getLinksToMe()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT objectid FROM {{link}} '.
+ ' WHERE link_objectid={myid}' );
+ $sql->setInt ( 'myid' ,$this->objectid );
+
+ return $sql->getCol();
+ }
+
+ private function getTypeid()
+ {
+ if ($this->isFolder) return OR_TYPEID_FOLDER;
+ 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;
+ }
+
+
+ }
+
+}?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/ObjectFactory.php b/modules/cms-core/model/ObjectFactory.php
@@ -0,0 +1,54 @@
+<?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.
+
+class ObjectFactory
+{
+ function create( $objectid )
+ {
+ $o = new Object( $objectid );
+
+ switch( $o->getType() )
+ {
+ case OR_TYPE_FILE:
+ $x = new File( $objectid );
+ break;
+
+ case OR_TYPE_FOLDER:
+ $x = new Folder( $objectid );
+ break;
+
+ case OR_TYPE_PAGE:
+ $x = new Page( $objectid );
+ break;
+
+ case OR_TYPE_LINK:
+ $x = new Link( $objectid );
+ break;
+
+ default:
+ die( "Unknown Object-Typ: ".$o->getType() );
+ debug_backtrace();
+ }
+
+ $x->load();
+ return $x;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Page.class.php b/modules/cms-core/model/Page.class.php
@@ -0,0 +1,883 @@
+<?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.
+
+
+/**
+ * Darstellen einer Seite
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+
+class Page extends Object
+{
+ var $enclosingObjectId = -1; //Id der Seite in die diese Seite im Rahmen der Generierung eingefügt wird
+ //Wichtig für include-Values
+ var $pageid;
+ var $templateid;
+ var $template;
+
+ var $simple = false;
+ var $public = false;
+
+ var $el = array();
+
+ /**
+ * Stellt fest, ob die Editier-Icons angezeigt werden sollen. Dies ist
+ * nur der Fall, wenn die Seite auch zum Bearbeiten generiert wird.
+ * Wird die Seite zum Veröffentlichen generiert, muss diese Eigenschaft
+ * natürlich "false" sein.
+ * @var boolean
+ */
+ var $icons = false;
+ var $src = '';
+ var $edit = false;
+
+ var $content_negotiation = false;
+ var $cut_index = false;
+ var $default_language = false;
+// var $withLanguage = false;
+ var $withLanguage = true;
+ var $withModel = true;
+// var $withModel = false;
+ var $link = false;
+ var $fullFilename = '';
+
+ var $log_filenames = array();
+ var $modelid = 0;
+
+ var $publish = null;
+ var $up_path = '';
+
+ public $values;
+
+
+ function __construct( $objectid='' )
+ {
+ parent::__construct( $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 = $db->sql( 'SELECT objectid FROM {{page}} '.
+ ' WHERE id={pageid}' );
+ $sql->setInt('pageid',$pageid);
+
+ return $sql->getOne();
+ }
+
+
+ /**
+ * 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 = $db->sql( 'SELECT id FROM {{page}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$objectid);
+
+ return $sql->getOne();
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ array('full_filename'=>$this->realFilename(),
+ 'pageid' =>$this->pageid,
+ 'templateid' =>$this->templateid,
+ 'mime_type' =>$this->mimeType() ) );
+ }
+
+
+ /**
+ * 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 );
+ }
+
+
+
+
+ /**
+ * Ermittelt den Pfad zu einem beliebigen Objekt
+ *
+ * @param Integer Objekt-ID des Zielobjektes
+ * @return String Relative Link-angabe, Beispiel: '../../pfad/datei.jpeg'
+ */
+ public function path_to_object( $objectid )
+ {
+ global $conf_php,
+ $SESS;
+ $inhalt = '';
+
+ if ( ! Object::available( $objectid) )
+ return '';
+
+ $param = array('oid'=>'__OID__'.$objectid.'__');
+
+ if ( $this->icons )
+ $param['withIcons'] = '1';
+
+ $object = new Object( $objectid );
+ $object->objectLoad();
+
+ $cut_index = ( is_object($this->publish) && $this->publish->cut_index );
+ $content_negotiation = ( is_object($this->publish) && $this->publish->content_negotiation );
+
+ if ( $this->public )
+ {
+ switch( $object->typeid )
+ {
+ case OR_TYPEID_FILE:
+
+ $inhalt = $this->up_path();
+
+ $f = new File( $objectid );
+ $f->content_negotiation = $content_negotiation;
+ $f->load();
+ $inhalt .= $f->full_filename();
+ break;
+
+ case OR_TYPEID_PAGE:
+
+ $inhalt = $this->up_path();
+
+ $p = new Page( $objectid );
+ $p->languageid = $this->languageid;
+ $p->modelid = $this->modelid;
+ $p->cut_index = $cut_index;
+ $p->content_negotiation = $content_negotiation;
+ $p->withLanguage = $this->withLanguage;
+ $p->withModel = $this->withModel;
+ $p->load();
+ $inhalt .= $p->full_filename();
+ break;
+
+ case OR_TYPEID_LINK:
+ $link = new Link( $objectid );
+ $link->load();
+
+ $linkedObject = new Object( $link->linkedObjectId );
+ $linkedObject->objectLoad();
+
+ switch( $linkedObject->getType() )
+ {
+ case OR_TYPEID_FILE:
+ $f = new File( $link->linkedObjectId );
+ $f->load();
+ $f->content_negotiation = $content_negotiation;
+ $inhalt = $this->up_path();
+ $inhalt .= $f->full_filename();
+ break;
+
+ case OR_TYPEID_PAGE:
+ $p = new Page( $link->linkedObjectId );
+ $p->languageid = $this->languageid;
+ $p->modelid = $this->modelid;
+ $p->cut_index = $cut_index;
+ $p->content_negotiation = $content_negotiation;
+ $p->withLanguage = $this->withLanguage;
+ $p->withModel = $this->withModel;
+ $p->load();
+ $inhalt = $this->up_path();
+ $inhalt .= $p->full_filename();
+ break;
+ }
+ break;
+
+ case OR_TYPEID_URL:
+ $url = new Url( $objectid );
+ $url->load();
+ $inhalt = $url->url;
+ break;
+ }
+ }
+ else
+ {
+ // Interne Verlinkungen in der Seitenvorschau
+ switch( $object->typeid )
+ {
+ case OR_TYPEID_FILE:
+ $inhalt = \Html::url('file','show',$objectid,$param);
+ break;
+
+ case OR_TYPEID_PAGE:
+ $inhalt = \Html::url('page','show',$objectid,$param);
+ break;
+
+ case OR_TYPEID_LINK:
+ $link = new Link( $objectid );
+ $link->load();
+
+ $linkedObject = new Object( $link->linkedObjectId );
+ $linkedObject->objectLoad();
+
+ switch( $linkedObject->typeid )
+ {
+ case OR_TYPEID_FILE:
+ $inhalt = \Html::url('file','show',$link->linkedObjectId,$param);
+ break;
+
+ case OR_TYPEID_PAGE:
+ $inhalt = \Html::url('page','show',$link->linkedObjectId,$param);
+ break;
+ }
+ break;
+
+ case OR_TYPEID_URL:
+ $url = new Url( $objectid );
+ $url->load();
+ $inhalt = $url->url;
+
+ break;
+ }
+ }
+
+ return $inhalt;
+ }
+
+
+
+ /**
+ * Erzeugt Pr?fix f?r eine relative Pfadangabe
+ * Beispiel: Seite liegt in Ordner /pfad/pfad dann '../../'
+ *
+ * @return String Pfadangabe
+ * @access private
+ */
+ function up_path()
+ {
+ global $conf;
+
+ if ( $conf['filename']['url'] == 'absolute' )
+ {
+ $this->up_path = '/';
+ return $this->up_path;
+ }
+
+ if ( $this->up_path != '' )
+ return $this->up_path;
+
+ $folder = new Folder( $this->parentid );
+ $folder->load();
+ $f = count( $folder->parentObjectFileNames(false,true) );
+
+ if ( $f == 0 )
+ {
+ $this->up_path = './';
+ }
+ else
+ {
+ $this->up_path = str_repeat( '../',$f );
+ }
+
+ return $this->up_path;
+ }
+
+
+ /**
+ * Eine Seite hinzufuegen
+ */
+ function add()
+ {
+ $db = db_connection();
+
+ $this->objectAdd(); // Hinzuf?gen von Objekt (dabei wird Objekt-ID ermittelt)
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{page}}');
+ $this->pageid = intval($sql->getOne())+1;
+
+ $sql = $db->sql('INSERT INTO {{page}}'.
+ ' (id,objectid,templateid)'.
+ ' VALUES( {pageid},{objectid},{templateid} )' );
+ $sql->setInt ('pageid' ,$this->pageid );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setInt ('templateid',$this->templateid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Seite laden
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{page}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $row = $sql->getRow();
+
+ $this->pageid = $row['id' ];
+ $this->templateid = $row['templateid'];
+
+ $this->objectLoad();
+ }
+
+
+ function delete()
+ {
+ global $db;
+
+ $sql = $db->sql( 'DELETE FROM {{value}} '.
+ ' WHERE pageid={pageid}' );
+ $sql->setInt('pageid',$this->pageid);
+ $sql->query();
+
+ $sql = $db->sql( 'DELETE FROM {{page}} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $sql->query();
+
+ $this->objectDelete();
+ }
+
+
+ /**
+ * Kopieren der Inhalts von einer anderen Seite
+ * @param ID der Seite, von der der Inhalt kopiert werden soll
+ */
+ function copyValuesFromPage( $otherpageid )
+ {
+ $this->load();
+
+ foreach( $this->getElementIds() as $elementid )
+ {
+ foreach( Language::getAll() as $lid=>$lname )
+ {
+ $val = new Value();
+ $val->publish = false;
+ $val->element = new Element( $elementid );
+
+ $val->objectid = $otherpageid;
+ $val->pageid = Page::getPageIdFromObjectId( $otherpageid );
+ $val->languageid = $lid;
+ $val->load();
+
+ // Inhalt nur speichern, wenn vorher vorhanden
+ if ( $val->valueid != 0 )
+ {
+ $val->objectid = $this->objectid;
+ $val->pageid = Page::getPageIdFromObjectId( $this->objectid );
+ $val->save();
+ }
+ }
+ }
+ }
+
+
+
+
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('UPDATE {{page}}'.
+ ' SET templateid ={templateid}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('templateid' ,$this->templateid);
+ $sql->setInt('objectid' ,$this->objectid );
+ $sql->query();
+
+ $this->objectSave();
+ }
+
+
+
+ function replaceTemplate( $newTemplateId,$replaceElementMap )
+ {
+ $oldTemplateId = $this->templateid;
+
+ $db = db_connection();
+
+ // Template-id dieser Seite aendern
+ $this->templateid = $newTemplateId;
+
+ $sql = $db->sql('UPDATE {{page}}'.
+ ' SET templateid ={templateid}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('templateid' ,$this->templateid);
+ $sql->setInt('objectid' ,$this->objectid );
+ $sql->query();
+
+
+ // Inhalte umschluesseln, d.h. die Element-Ids aendern
+ $template = new Template( $oldTemplateId );
+ foreach( $template->getElementIds() as $oldElementId )
+ {
+ if ( !isset($replaceElementMap[$oldElementId]) ||
+ intval($replaceElementMap[$oldElementId]) < 1 )
+ {
+ \Logger::debug( 'deleting value of elementid '.$oldElementId );
+ $sql = $db->sql('DELETE FROM {{value}}'.
+ ' WHERE pageid={pageid}'.
+ ' AND elementid={elementid}' );
+ $sql->setInt('pageid' ,$this->pageid);
+ $sql->setInt('elementid',$oldElementId );
+
+ $sql->query();
+ }
+ else
+ {
+ $newElementId = intval($replaceElementMap[$oldElementId]);
+
+ \Logger::debug( 'updating elementid '.$oldElementId.' -> '.$newElementId );
+ $sql = $db->sql('UPDATE {{value}}'.
+ ' SET elementid ={newelementid}'.
+ ' WHERE pageid ={pageid}'.
+ ' AND elementid={oldelementid}' );
+ $sql->setInt('pageid' ,$this->pageid);
+ $sql->setInt('oldelementid',$oldElementId );
+ $sql->setInt('newelementid',$newElementId );
+ $sql->query();
+ }
+ }
+ }
+
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Seite.
+ *
+ * Wenn '$this->content_negotiation' auf 'true' steht, wird der Dateiname ggf. gekürzt,
+ * so wie er für HTML-Links verwendet wird. Sonst wird immer der echte Dateiname
+ * ermittelt.
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/seite.en.html'
+ */
+ function full_filename()
+ {
+ $filename = $this->path();
+
+ if ( !empty($filename) )
+ $filename .= '/';
+
+ if ( $this->cut_index && $this->filename == config('publish','default') )
+ {
+ // Link auf Index-Datei, der Dateiname bleibt leer.
+ }
+ else
+ {
+ $format = config('publish','format');
+ $format = str_replace('{filename}',$this->filename(),$format );
+
+ if ( !$this->withLanguage || $this->content_negotiation && config('publish','negotiation','page_negotiate_language' ) )
+ {
+ $format = str_replace('{language}' ,'',$format );
+ $format = str_replace('{language_sep}','',$format );
+ }
+ else
+ {
+ $l = new Language( $this->languageid );
+ $l->load();
+ $format = str_replace('{language}' ,$l->isoCode ,$format );
+ $format = str_replace('{language_sep}',config('publish','language_sep'),$format );
+ }
+
+ if ( !$this->withModel || $this->content_negotiation && config('publish','negotiation','page_negotiate_type' ) )
+ {
+ $format = str_replace('{type}' ,'',$format );
+ $format = str_replace('{type_sep}','',$format );
+ }
+ else
+ {
+ $t = new Template( $this->templateid );
+ $t->modelid = $this->modelid;
+ $t->load();
+ $format = str_replace('{type}' ,$t->extension ,$format );
+ $format = str_replace('{type_sep}',config('publish','type_sep'),$format );
+ }
+ $filename .= $format;
+ }
+
+ $this->fullFilename = $filename;
+ return $filename;
+ }
+
+
+// function language_filename()
+// {
+// global $SESS;
+//
+// $db = db_connection();
+//
+// $sql = $db->sql( 'SELECT COUNT(*) FROM {{language}}'.
+// ' WHERE projectid={projectid}' );
+// $sql->setInt('projectid',$SESS['projectid']);
+//
+// if ( $sql->getOne( $sql ) == 1 )
+// {
+// // Wenn es nur eine Sprache gibt, keine Sprachangabe im Dateinamen
+// return '';
+// }
+// else
+// {
+// $sql = $db->sql( 'SELECT isocode FROM {{language}}'.
+// ' WHERE id={languageid}' );
+// $sql->setInt('languageid',$this->languageid);
+// $isocode = $sql->getOne( $sql );
+//
+// return strtolower( $isocode );
+// }
+// }
+
+
+ /**
+ * Erzeugen der Inhalte zu allen Elementen dieser Seite
+ * wird von generate() aufgerufen
+ *
+ * @access private
+ */
+ function getElementIds()
+ {
+ $t = new Template( $this->templateid );
+
+ return $t->getElementIds();
+ }
+
+
+
+ /**
+ * Erzeugen der Inhalte zu allen Elementen dieser Seite
+ * wird von generate() aufgerufen
+ *
+ * @access private
+ */
+ function getElements()
+ {
+ if ( !isset($this->template) )
+ $this->template = new Template( $this->templateid );
+
+ return $this->template->getElements();
+ }
+
+
+
+ /**
+ * Erzeugen der Inhalte zu allen Elementen dieser Seite
+ * wird von generate() aufgerufen
+ *
+ * @access private
+ */
+ function getWritableElements()
+ {
+ if ( !isset($this->template) )
+ $this->template = new Template( $this->templateid );
+
+ return $this->template->getWritableElements();
+ }
+
+
+
+ /**
+ * Erzeugen der Inhalte zu allen Elementen dieser Seite
+ * wird von generate() aufgerufen
+ *
+ * @access private
+ */
+ function generate_elements()
+ {
+ $this->values = array();
+
+ if ( $this->simple )
+ $elements = $this->getWritableElements();
+ else
+ $elements = $this->getElements();
+
+ foreach( $elements as $elementid=>$element )
+ {
+ // neues Inhaltobjekt erzeugen
+ $val = new Value();
+ $val->publish = $this->public;
+ $val->element = $element;
+
+ $val->objectid = $this->objectid;
+ $val->pageid = $this->pageid;
+ $val->languageid = $this->languageid;
+ $val->simple = $this->simple;
+ $val->modelid = $this->modelid;
+ $val->page = $this;
+ $val->generate();
+ $val->page = null;
+ $this->values[$elementid] = $val;
+ }
+ }
+
+
+ /**
+ * Erzeugen des Inhaltes der gesamten Seite.
+ *
+ * @return String Inhalt
+ */
+ function generate()
+ {
+ global $conf;
+
+ // Setzen der 'locale', damit sprachabhängige Systemausgaben (wie z.B. die
+ // Ausgabe von strftime()) in der korrekten Sprache dargestellt werden.
+ $language = new Language($this->languageid);
+ $language->load();
+
+ $locale_conf = $conf['i18n']['locale'];
+ if ( isset($locale_conf[strtolower($language->isoCode)]) )
+ {
+ $locale = $locale_conf[strtolower($language->isoCode)];
+ $locale_ok = setlocale(LC_ALL,$locale);
+ if ( !$locale_ok )
+ // Hat nicht geklappt. Entweder ist das Mapping falsch oder die locale ist
+ // nicht korrekt installiert.
+ \Logger::warn("Could not set locale '$locale', please check with 'locale -a' if it is installaled correctly");
+ }
+ else
+ {
+ setlocale(LC_ALL,'');
+ }
+
+ if ( $conf['cache']['enable_cache'] && is_file($this->tmpfile() ))
+ {
+ $this->value = implode('',file($this->tmpfile()));
+ return $this->value;
+ }
+
+ $this->template = new Template( $this->templateid );
+ $this->template->modelid = $this->modelid;
+ $this->template->load();
+ $this->ext = $this->template->extension;
+
+ $this->generate_elements();
+
+ $src = $this->template->src;
+
+ // Ersetzen der Platzhalter durch die Element-Inhalte
+
+ foreach( $this->values as $id=>$value )
+ {
+ $inh = $value->value;
+ $src = str_replace( '{{'.$id.'}}',$inh,$src );
+
+ // Dynamische Bereiche ein- oder ausblenden
+ if ( $inh == '' )
+ {
+ // Wenn Feld leer
+ $src = str_replace( '{{IFEMPTY:'.$id.':BEGIN}}','',$src );
+ $src = str_replace( '{{IFEMPTY:'.$id.':END}}' ,'',$src );
+
+ $src = \Text::entferneVonBis( $src,'{{IFNOTEMPTY:'.$id.':BEGIN}}','{{IFNOTEMPTY:'.$id.':END}}' );
+ }
+ else
+ {
+ // Wenn Feld gefuellt
+ $src = str_replace( '{{IFNOTEMPTY:'.$id.':BEGIN}}','',$src );
+ $src = str_replace( '{{IFNOTEMPTY:'.$id.':END}}' ,'',$src );
+
+ $src = \Text::entferneVonBis( $src,'{{IFEMPTY:'.$id.':BEGIN}}','{{IFEMPTY:'.$id.':END}}' );
+ }
+
+ if ( $this->icons )
+ $src = str_replace( '{{->'.$id.'}}','<a href="javascript:parent.openNewAction(\''.$value->element->name.'\',\'pageelement\',\''.$this->objectid.'_'.$value->element->elementid.'\');" title="'.$value->element->desc.'"><img src="'.OR_THEMES_EXT_DIR.$conf['interface']['theme'].'/images/icon_el_'.$value->element->type.IMG_ICON_EXT.'" border="0" align="left"></a>',$src );
+ else
+ $src = str_replace( '{{->'.$id.'}}','',$src );
+ }
+
+ if ( config('publish','escape_8bit_characters') )
+ if ( substr($this->mimeType(),-4) == 'html' )
+ {
+ /*
+ *
+ $src = htmlentities($src,ENT_NOQUOTES,'UTF-8');
+ $src = str_replace('<' , '<', $src);
+ $src = str_replace('>' , '>', $src);
+ $src = str_replace('&', '&', $src);
+ */
+ $src = translateutf8tohtml($src);
+ }
+
+ $this->value = &$src;
+
+ // Store in cache.
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->value );
+ fclose( $f );
+
+ return $this->value;
+ }
+
+
+ /**
+ * Schreiben des Seiteninhaltes in die temporaere Datei
+ */
+ function write()
+ {
+ if ( !is_file($this->tmpfile()))
+ $this->generate();
+ }
+
+
+ /**
+ * Generieren dieser Seite in Dateisystem und/oder auf FTP-Server
+ */
+ function publish()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ if ( ! is_object($this->publish) )
+ $this->publish = new \Publish();
+
+ $this->public = true;
+
+ $allLanguages = Language::getAll();
+ $allModels = Model::getAll();
+
+ // Schleife ueber alle Sprachvarianten
+ foreach( $allLanguages as $languageid=>$x )
+ {
+ $this->languageid = $languageid;
+ $this->withLanguage = count($allLanguages) > 1 || config('publish','filename_language') == 'always';
+ $this->withModel = count($allModels ) > 1 || config('publish','filename_type' ) == 'always';
+
+ // Schleife ueber alle Projektvarianten
+ foreach( $allModels as $projectmodelid=>$x )
+ {
+ $this->modelid = $projectmodelid;
+
+ $this->load();
+ $this->generate();
+ $this->write();
+
+ // Vorlage ermitteln.
+ $t = new Template( $this->templateid );
+ $t->modelid = $this->modelid;
+ $t->load();
+
+ // Nur wenn eine Datei-Endung vorliegt wird die Seite veroeffentlicht
+ if ( !empty($t->extension) )
+ {
+ $this->publish->copy( $this->tmpfile(),$this->full_filename() );
+ unlink( $this->tmpfile() );
+ $this->publish->publishedObjects[] = $this->getProperties();
+ }
+ }
+ }
+
+ }
+
+
+ /**
+ * Ermittelt den Mime-Type zu dieser Seite
+ *
+ * @return String Mime-Type
+ */
+ function mimeType()
+ {
+ if ( ! is_object($this->template) )
+ {
+ $this->template = new Template( $this->templateid );
+ $this->template->modelid = $this->modelid;
+ $this->template->load();
+ }
+
+ $this->mime_type = $this->template->mimeType();
+
+ return( $this->mime_type );
+ }
+
+
+
+ /**
+ * Ermittelt einen tempor�ren Dateinamen f�r diese Seite.
+ */
+ function tmpfile()
+ {
+ $db = db_connection();
+ $filename = $this->getTempFileName( array('db'=>$db->id,
+ 'o' =>$this->objectid,
+ 'l' =>$this->languageid,
+ 'm' =>$this->modelid,
+ 'p' =>intval($this->public),
+ 's' =>intval($this->simple) ) );
+ return $filename;
+ }
+
+
+
+ function setTimestamp()
+ {
+ $tmpFilename = $this->tmpfile();
+
+ if ( is_file($tmpFilename) )
+ unlink( $tmpFilename);
+
+ parent::setTimestamp();
+ }
+
+
+ /**
+ * Ermittelt den Dateinamen dieser Seite, so wie sie auch im Dateisystem steht.
+ */
+ function realFilename()
+ {
+ $this->withLanguage = config('publish','filename_language') == 'always' || Language::count() > 1;
+ $this->withModel = config('publish','filename_type' ) == 'always' || Model::count() > 1;
+
+ return $this->full_filename();
+ }
+
+
+ /**
+ * Stellt fest, ob diese Seite im HTML-Format veröffentlicht wird.
+ * @return boolean
+ */
+ public function isHtml()
+ {
+ return $this->mimeType()=='text/html';
+ }
+}
+
+
+?>
diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php
@@ -0,0 +1,897 @@
+<?php
+
+namespace cms\model;
+
+use database\Database;
+use Session;
+
+
+/**
+ * Darstellen eines Projektes
+ *
+ * @author Jan Dankert
+ * @package openrat.objects
+ */
+class Project
+{
+ // Eigenschaften
+ var $projectid;
+ var $name;
+ var $target_dir;
+ var $ftp_url;
+ var $ftp_passive;
+ var $cmd_after_publish;
+ var $content_negotiation;
+ var $cut_index;
+
+ var $log = array();
+
+
+ // Konstruktor
+ public function __construct( $projectid='' )
+ {
+ if ( intval($projectid) != 0 )
+ $this->projectid = $projectid;
+ }
+
+
+ /**
+ * Stellt fest, ob die angegebene Projekt-Id existiert.
+ * @param $id int Projekt-Id
+ * @return boolean
+ *
+ */
+ public function isAvailable($id )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT 1 FROM {{project}} '.
+ ' WHERE id={id}');
+ $sql->setInt('id' ,$id );
+
+ return intval($sql->getOne()) == 1;
+ }
+
+
+ /**
+ * Liefert alle verf?gbaren Projekte.
+ * @return array
+ */
+ public function getAllProjects()
+ {
+ $db = db_connection();
+ $sql = $db->sql( 'SELECT id,name FROM {{project}} '.
+ ' ORDER BY name' );
+
+ return $sql->getAssoc();
+ }
+
+
+ // Liefert alle verf?gbaren Projekt-Ids
+ public function getAllProjectIds()
+ {
+ $db = db_connection();
+ $sql = $db->sql( 'SELECT id FROM {{project}} '.
+ ' ORDER BY name' );
+
+ return $sql->getCol();
+ }
+
+
+ public function getLanguages()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{language}}'.
+ ' WHERE projectid={projectid} '.
+ ' ORDER BY name' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $sql->getAssoc();
+ }
+
+
+ public function getLanguageIds()
+ {
+ return array_keys( $this->getLanguages() );
+ }
+
+
+ public function getModels()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{projectmodel}}'.
+ ' WHERE projectid= {projectid} '.
+ ' ORDER BY name' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $sql->getAssoc();
+ }
+
+
+ public function getModelIds()
+ {
+ return array_keys( $this->getModels() );
+ }
+
+
+ public function getTemplateIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{template}}'.
+ ' WHERE projectid= {projectid} ' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $sql->getCol();
+ }
+
+
+ public function getTemplates()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{template}}'.
+ ' WHERE projectid= {projectid} ' );
+ $sql->setInt ('projectid',$this->projectid);
+
+ return $sql->getAssoc();
+ }
+
+
+ /**
+ * Ermitteln des Wurzel-Ordners fuer dieses Projekt.
+ *
+ * Der Wurzelordner ist der einzige Ordnerhat in diesem
+ * Projekt, der kein Elternelement besitzt.
+ *
+ * @return Objekt-Id des Wurzelordners
+ */
+ public function getRootObjectId()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT id FROM {{object}}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ $sql->setInt('projectid',$this->projectid);
+
+ return( $sql->getOne() );
+ }
+
+
+
+ // Laden
+
+ /**
+ * @throws \ObjectNotFoundException
+ */
+ public function load()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{project}} '.
+ ' WHERE id={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+
+ $row = $sql->getRow();
+
+ if ( empty($row) )
+ throw new \ObjectNotFoundException('project '.$this->projectid.' not found');
+
+ $this->name = $row['name' ];
+ $this->target_dir = $row['target_dir' ];
+ $this->ftp_url = $row['ftp_url' ];
+ $this->ftp_passive = $row['ftp_passive' ];
+ $this->cmd_after_publish = $row['cmd_after_publish' ];
+ $this->content_negotiation = $row['content_negotiation'];
+ $this->cut_index = $row['cut_index' ];
+ }
+
+
+ // Laden
+ public function loadByName()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{project}} '.
+ ' WHERE name={projectname}' );
+ $sql->setString( 'projectname',$this->name );
+
+ $row = $sql->getRow();
+
+ $this->projectid = $row['id' ];
+ $this->target_dir = $row['target_dir' ];
+ $this->ftp_url = $row['ftp_url' ];
+ $this->ftp_passive = $row['ftp_passive' ];
+ $this->cmd_after_publish = $row['cmd_after_publish' ];
+ $this->content_negotiation = $row['content_negotiation'];
+ $this->cut_index = $row['cut_index' ];
+ }
+
+
+ // Speichern
+ public function save()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ UPDATE {{project}}
+ SET name = {name},
+ target_dir = {target_dir},
+ ftp_url = {ftp_url},
+ ftp_passive = {ftp_passive},
+ cut_index = {cut_index},
+ content_negotiation = {content_negotiation},
+ cmd_after_publish = {cmd_after_publish}
+ WHERE id= {projectid}
+SQL
+);
+
+ $sql->setString('ftp_url' ,$this->ftp_url );
+ $sql->setString('name' ,$this->name );
+ $sql->setString('target_dir' ,$this->target_dir );
+ $sql->setInt ('ftp_passive' ,$this->ftp_passive );
+ $sql->setString('cmd_after_publish' ,$this->cmd_after_publish );
+ $sql->setInt ('content_negotiation',$this->content_negotiation );
+ $sql->setInt ('cut_index' ,$this->cut_index );
+ $sql->setInt ('projectid' ,$this->projectid );
+
+ $sql->query();
+
+ try
+ {
+ $rootFolder = new Folder( $this->getRootObjectId() );
+ $rootFolder->load();
+ $rootFolder->filename = $this->name;
+ $rootFolder->save();
+ }
+ catch( \Exception $e )
+ {
+ \Logger::warn('Project '.$this->projectid.' has not a root folder'."\n".$e->getTraceAsString());
+ }
+ }
+
+
+ // Speichern
+ public function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'target_dir' =>$this->target_dir,
+ 'ftp_url' =>$this->ftp_url,
+ 'ftp_passive' =>$this->ftp_passive,
+ 'cmd_after_publish' =>$this->cmd_after_publish,
+ 'content_negotiation'=>$this->content_negotiation,
+ 'cut_index' =>$this->cut_index,
+ 'projectid' =>$this->projectid );
+ }
+
+
+ // Projekt hinzufuegen
+ public function add()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{project}}');
+ $this->projectid = intval($sql->getOne())+1;
+
+
+ // Projekt hinzuf?gen
+ $sql = $db->sql( 'INSERT INTO {{project}} (id,name,target_dir,ftp_url,ftp_passive,cmd_after_publish,content_negotiation,cut_index) '.
+ " VALUES( {projectid},{name},'','',0,'',0,0 ) " );
+ $sql->setInt ('projectid',$this->projectid );
+ $sql->setString('name' ,$this->name );
+
+ $sql->query();
+
+ // Modell anlegen
+ $model = new Model();
+ $model->projectid = $this->projectid;
+ $model->name = 'html';
+ $model->add();
+
+ // Sprache anlegen
+ $language = new Language();
+ $language->projectid = $this->projectid;
+ $language->isoCode = 'en';
+ $language->name = 'english';
+ $language->add();
+
+ // Haupt-Ordner anlegen
+ $folder = new Folder();
+ $folder->isRoot = true;
+ $folder->projectid = $this->projectid;
+ $folder->languageid = $language->languageid;
+ $folder->filename = $this->name;
+ $folder->name = $this->name;
+ $folder->isRoot = true;
+ $folder->add();
+
+ // Template anlegen
+ $template = new Template();
+ $template->projectid = $this->projectid;
+ $template->name = '';
+ $template->modelid = $model->modelid;
+ $template->languageid = $language->languageid;
+ $template->extension = 'html';
+ $template->src = '<html><body><h1>Hello world</h1><hr><p>Hello, World.</p></body></html>';
+ $template->add();
+ $template->save();
+
+ // Beispiel-Seite anlegen
+ $page = new Page();
+ $page->parentid = $folder->objectid;
+ $page->projectid = $this->projectid;
+ $page->languageid = $language->languageid;
+ $page->templateid = $template->templateid;
+ $page->filename = '';
+ $page->name = 'OpenRat';
+ $page->add();
+ }
+
+
+ // Projekt aus Datenbank entfernen
+ public function delete()
+ {
+ $db = db_connection();
+
+ // Root-Ordner rekursiv samt Inhalten loeschen
+ $folder = new Folder( $this->getRootObjectId() );
+ $folder->deleteAll();
+
+
+ foreach( $this->getLanguageIds() as $languageid )
+ {
+ $language = new Language( $languageid );
+ $language->delete();
+ }
+
+
+ foreach( $this->getTemplateIds() as $templateid )
+ {
+ $template = new Template( $templateid );
+ $template->delete();
+ }
+
+
+ foreach( $this->getModelIds() as $modelid )
+ {
+ $model = new Model( $modelid );
+ $model->delete();
+ }
+
+
+ // Projekt l?schen
+ $sql = $db->sql( 'DELETE FROM {{project}}'.
+ ' WHERE id= {projectid} ' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $sql->query();
+ }
+
+ public function getDefaultLanguageId()
+ {
+ $db = Session::getDatabase();
+
+ // ORDER BY deswegen, damit immer mind. eine Sprache
+ // gelesen wird
+ $sql = $db->sql( 'SELECT id FROM {{language}} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+
+ $sql->setInt('projectid',$this->projectid );
+
+ return $sql->getOne();
+ }
+
+
+ public function getDefaultModelId()
+ {
+ $db = Session::getDatabase();
+
+ // ORDER BY deswegen, damit immer mind. eine Sprache
+ // gelesen wird
+ $sql = $db->sql( 'SELECT id FROM {{projectmodel}} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+ $sql->setInt('projectid',$this->projectid );
+
+ return $sql->getOne();
+ }
+
+
+
+ /**
+ * Entfernt nicht mehr notwendige Inhalte aus dem Archiv.
+ */
+ public function checkLimit()
+ {
+ $root = new Folder( $this->getRootObjectId() );
+ $root->projectid = $this->projectid;
+
+ $pages = $root->getAllObjectIds( array('page') );
+ $languages = $this->getLanguageIds();
+
+ foreach( $pages as $objectid )
+ {
+ $page = new Page( $objectid );
+ $page->load();
+ foreach( $page->getElementIds() as $eid )
+ {
+ foreach( $languages as $lid )
+ {
+ $value = new Value();
+ $value->element = new Element($eid);
+ $value->pageid = $page->pageid;
+ $value->languageid = $lid;
+
+ $value->checkLimit();
+ }
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Testet die Integrität der Datenbank.
+ */
+ public function checkLostFiles()
+ {
+ $this->log = array();
+
+ $db = &Session::getDatabase();
+
+ // Ordnerstruktur prüfen.
+ $sql = $db->sql( <<<EOF
+SELECT thistab.id FROM {{object}} AS thistab
+ LEFT JOIN {{object}} AS parenttab
+ ON parenttab.id = thistab.parentid
+ WHERE thistab.projectid={projectid} AND thistab.parentid IS NOT NULL AND parenttab.id IS NULL
+EOF
+);
+ $sql->setInt('projectid',$this->projectid);
+
+ $idList = $sql->getCol();
+
+ if ( count( $idList ) > 0 )
+ {
+ $lostAndFoundFolder = new Folder();
+ $lostAndFoundFolder->projectid = $this->projectid;
+ $lostAndFoundFolder->languageid = $this->getDefaultLanguageId();
+ $lostAndFoundFolder->filename = "lostandfound";
+ $lostAndFoundFolder->name = 'Lost+found';
+ $lostAndFoundFolder->parentid = $this->getRootObjectId();
+ $lostAndFoundFolder->add();
+
+ foreach( $idList as $id )
+ {
+ $this->log[] = 'Lost file! Moving '.$id.' to lost+found.';
+ $obj = new Object( $id );
+ $obj->setParentId( $lostAndFoundFolder->objectid );
+ }
+ }
+
+
+ // Prüfe, ob die Verbindung Projekt->Template->Templatemodell->Projectmodell->Projekt konsistent ist.
+ $sql = $db->sql( <<<EOF
+SELECT DISTINCT projectid FROM {{projectmodel}} WHERE id IN (SELECT projectmodelid from {{templatemodel}} WHERE templateid in (SELECT id from {{template}} WHERE projectid={projectid}))
+EOF
+);
+ $sql->setInt('projectid',$this->projectid);
+
+ $idList = $sql->getCol();
+
+ if ( count( $idList ) > 1 )
+ {
+ \Logger::warn('Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.');
+ $this->log[] = 'Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.';
+ }
+
+ }
+
+
+ /**
+ * Synchronisation des Projektinhaltes mit dem Dateisystem.
+ */
+ public function sync()
+ {
+ global $conf;
+ $syncConf = $conf['sync'];
+
+ if ( ! $syncConf['enabled'] )
+ return;
+
+ $syncDir = slashify($syncConf['directory']).$this->name;
+
+ }
+
+ /**
+ * Kopiert ein Projekt von einer Datenbank zu einer anderen.<br>
+ * <br>
+ * Alle Projektinhalte werden kopiert, die Fremdschluesselbeziehungen werden entsprechend angepasst.<br>
+ * <br>
+ * Alle Beziehungen zu Benutzern, z.B. "Zuletzt geaendert von", "angelegt von" sowie<br>
+ * alle Berechtigungsinformationen gehen verloren!<br>
+ *
+ * @param string $dbid_destination ID der Ziel-Datenbank
+ * @param string $name
+ */
+ public function copy( $dbid_destination,$name='' )
+ {
+ \Logger::debug( 'Copying project '.$this->name.' to database '.$dbid_destination );
+
+ global $conf;
+ $zeit = date('Y-m-d\TH:i:sO');
+
+ $db_src = db_connection();
+ $db_dest = new Database( $conf['database'][$dbid_destination] );
+ $db_dest->id = $dbid_destination;
+ $db_dest->start();
+
+ $sameDB = ( $db_dest->id == $db_src->id );
+
+ // -------------------------------------------------------
+ $mapping = array();
+ $ids = array('project' => array('foreign_keys'=>array(),
+ 'primary_key' =>'id',
+ 'unique_idx' =>'name',
+ 'erase' =>array()
+ ),
+ 'language' => array('foreign_keys'=>array('projectid'=>'project'),
+ 'primary_key' =>'id'
+ ),
+ 'projectmodel' => array('foreign_keys'=>array('projectid'=>'project'),
+ 'primary_key' =>'id'
+ ),
+ 'template' => array('foreign_keys'=>array('projectid'=>'project'),
+ 'primary_key' =>'id'
+ ),
+ 'object' => array('foreign_keys'=>array('projectid' =>'project' ),
+ 'self_key' =>'parentid',
+ 'primary_key' =>'id',
+ 'erase' =>array('create_userid','lastchange_userid')
+ ),
+ 'element' => array('foreign_keys'=>array('templateid' =>'template',
+ 'folderobjectid' =>'object',
+ 'default_objectid'=>'object' ),
+ 'primary_key' =>'id'
+ ),
+ 'templatemodel'=> array('foreign_keys'=>array('projectmodelid'=>'projectmodel',
+ 'templateid' =>'template' ),
+ 'primary_key' =>'id',
+ 'replace' =>array('text'=>'element')
+ ),
+ 'name' => array('foreign_keys'=>array('objectid' =>'object',
+ 'languageid'=>'language' ),
+ 'primary_key' =>'id'
+ ),
+ 'page' => array('foreign_keys'=>array('objectid' =>'object',
+ 'templateid'=>'template' ),
+ 'primary_key' =>'id'
+ ),
+ 'value' => array('foreign_keys'=>array('pageid' =>'page',
+ 'languageid'=>'language',
+ 'elementid'=>'element',
+ 'linkobjectid'=>'object' ),
+ 'erase' =>array('lastchange_userid'),
+ 'replace' =>array('text'=>'object'),
+ 'primary_key' =>'id'
+ ),
+ 'link' => array('foreign_keys'=>array('objectid' =>'object',
+ 'link_objectid'=>'object' ),
+ 'primary_key' =>'id'
+ ),
+ 'folder' => array('foreign_keys'=>array('objectid' =>'object' ),
+ 'primary_key' =>'id'
+ ),
+ 'file' => array('foreign_keys'=>array('objectid' =>'object' ),
+ 'primary_key' =>'id',
+ 'binary' =>'value'
+ ),
+
+ );
+
+ if ( $sameDB )
+ $ids['acl'] = array('foreign_keys'=>array('objectid' => 'object',
+ 'languageid' => 'language' ),
+ 'primary_key' =>'id'
+ );
+
+ foreach( $ids as $tabelle=>$data )
+ {
+ \Logger::debug( 'Copying table '.$tabelle.' ...' );
+ $mapping[$tabelle] = array();
+ $idcolumn = $data['primary_key'];
+
+ // Naechste freie Id in der Zieltabelle ermitteln.
+ $stmt = $db_dest->sql( 'SELECT MAX('.$idcolumn.') FROM {t_'.$tabelle.'}');
+ $maxid = intval($stmt->getOne());
+ $nextid = $maxid;
+
+ // Zu �bertragende IDs ermitteln.
+ if ( count($data['foreign_keys'])==0 )
+ {
+ $where = ' WHERE id='.$this->projectid;
+ }
+ else
+ {
+ foreach( $data['foreign_keys'] as $fkey_column=>$target_tabelle )
+ {
+ $where = ' WHERE '.$fkey_column.' IN ('.join(array_keys($mapping[$target_tabelle]),',').')';
+ break;
+ }
+ }
+ $stmt = $db_src->sql( 'SELECT '.$idcolumn.' FROM {t_'.$tabelle.'} '.$where);
+
+ foreach( $stmt->getCol() as $srcid )
+ {
+ \Logger::debug('Id '.$srcid.' of table '.$tabelle);
+ $mapping[$tabelle][$srcid] = ++$nextid;
+
+ $stmt = $db_src->sql( 'SELECT * FROM {t_'.$tabelle.'} WHERE id={id}');
+ $stmt->setInt('id',$srcid);
+ $row = $stmt->getRow();
+
+ // Wert des Prim�rschl�ssels �ndern.
+ $row[$idcolumn] = $mapping[$tabelle][$srcid];
+
+ // Fremdschl�sselbeziehungen auf neue IDn korrigieren.
+ foreach( $data['foreign_keys'] as $fkey_column=>$target_tabelle)
+ {
+ \Logger::debug($fkey_column.' '.$target_tabelle.' '.$row[$fkey_column]);
+
+ if ( intval($row[$fkey_column]) != 0 )
+ $row[$fkey_column] = $mapping[$target_tabelle][$row[$fkey_column]];
+ }
+
+ foreach( array_keys($row) as $key )
+ {
+ if ( isset($data['unique_idx']) && $key == $data['unique_idx'] )
+ {
+ // Nachschauen, ob es einen UNIQUE-Key in der Zieltabelle schon gibt.
+ $stmt = $db_dest->sql( 'SELECT 1 FROM {t_'.$tabelle.'} WHERE '.$key."='".$row[$key]."'");
+
+ if ( intval($stmt->getOne()) == 1 )
+ $row[$key] = $row[$key].$zeit;
+
+ }
+
+ if ( !$sameDB && isset($data['erase']) && in_array($key,$data['erase']) )
+ $row[$key] = null;
+
+ if ( isset($data['self_key']) && $key == $data['self_key'] && intval($row[$key]) > 0 )
+ $row[$key] = $row[$key]+$maxid;
+ }
+
+ if ( isset($data['replace']) )
+ {
+ foreach( $data['replace'] as $repl_column=>$repl_tabelle)
+ foreach( $mapping[$repl_tabelle] as $oldid=>$newid)
+ {
+ $row[$repl_column] = str_replace('{'.$oldid.'}','{'.$newid.'}' ,$row[$repl_column]);
+ $row[$repl_column] = str_replace('"'.$oldid.'"','"'.$newid.'"' ,$row[$repl_column]);
+ $row[$repl_column] = str_replace('->'.$oldid ,'->"'.$newid.'"',$row[$repl_column]);
+ }
+ }
+
+ if ( isset($data['binary']) )
+ {
+ if ( !$db_src->conf['base64'] && $db_dest->conf['base64'] )
+ $row[$data['binary']] = base64_encode($row[$data['binary']]);
+ elseif ( $db_src->conf['base64'] && !$db_dest->conf['base64'] )
+ $row[$data['binary']] = base64_decode($row[$data['binary']]);
+ }
+
+ // Daten in Zieltabelle einf�gen.
+ $stmt = $db_dest->sql( 'INSERT INTO {t_'.$tabelle.'} ('.join(array_keys($row),',').') VALUES({'.join(array_keys($row),'},{').'})',$dbid_destination);
+ foreach( $row as $key=>$value )
+ {
+ if ( !$sameDB && isset($data['erase']) && in_array($key,$data['erase']) )
+ $stmt->setNull($key);
+ else
+ {
+ if(is_bool($value))
+ $stmt->setBoolean($key,$value);
+ elseif(is_int($value))
+ $stmt->setInt($key,$value);
+ elseif(is_string($value))
+ $stmt->setString($key,$value);
+ }
+ }
+ //$sql = $db->sql( 'INSERT INTO {t_'.$tabelle.'} ('.join(array_keys($row),',').') VALUES('.join($row,',').')',$dbid_destination);
+ $stmt->query();
+ }
+
+ if ( isset($data['self_key']) )
+ {
+ foreach( $mapping[$tabelle] as $oldid=>$newid )
+ {
+ $stmt = $db_dest->sql( 'UPDATE {t_'.$tabelle.'} SET '.$data['self_key'].'='.$newid.' WHERE '.$data['self_key'].'='.($oldid+$maxid),$dbid_destination );
+ $stmt->query();
+ }
+ }
+ }
+
+ \Logger::debug( 'Finished copying project' );
+
+ $db_dest->commit();
+ }
+
+
+
+ /**
+ * Ermittelt die Anzahl aller Objekte in diesem Projekt.
+ * @return int Anzahl
+ */
+ public function countObjects()
+ {
+ $db = db_connection();
+ $sql = $db->sql( 'SELECT COUNT(*) FROM {{object}} '.
+ ' WHERE projectid = {projectid}' );
+ $sql->setInt( 'projectid', $this->projectid );
+
+ return $sql->getOne();
+
+ }
+
+
+
+ /**
+ * Ermittelt die Gr��e aller Dateien in diesem Projekt.
+ * @return int Summe aller Dateigroessen
+ */
+ public function size()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT SUM(size) FROM {{file}}
+ LEFT JOIN {{object}}
+ ON {{file}}.objectid = {{object}}.id
+ WHERE projectid = {projectid}
+SQL
+);
+ $sql->setInt( 'projectid', $this->projectid );
+
+ return $sql->getOne();
+ }
+
+
+
+ /**
+ * Liefert alle verf?gbaren Projekt-Ids
+ */
+ public function info()
+ {
+ $info = array();
+
+ $info['count_objects'] = $this->countObjects();
+ $info['sum_filesize' ] = $this->size();
+
+
+ return $info;
+ }
+
+
+
+
+ /**
+ * Ermittelt projektübergreifend die letzten Änderungen des angemeldeten Benutzers.
+ *
+ * @return array <string, unknown>
+ */
+ public function getMyLastChanges()
+ {
+
+ $db = db_connection();
+
+
+ $sql = $db->sql( <<<SQL
+ SELECT {{object}}.id as objectid,
+ {{object}}.filename as filename,
+ {{object}}.typeid as typeid,
+ {{object}}.lastchange_date as lastchange_date,
+ {{name}}.name as name
+ FROM {{object}}
+ LEFT JOIN {{name}}
+ ON {{name}}.objectid = {{object}}.id
+ AND {{name}}.languageid = {languageid}
+ LEFT JOIN {{project}}
+ ON {{object}}.projectid = {{project}}.id
+ WHERE {{object}}.projectid = {projectid}
+ AND {{object}}.lastchange_userid = {userid}
+ ORDER BY {{object}}.lastchange_date DESC;
+SQL
+ );
+
+ // Variablen setzen.
+ $sql->setInt( 'projectid', $this->projectid );
+
+ $language = Session::getProjectLanguage();
+ $sql->setInt( 'languageid', $language->languageid );
+
+ $user = Session::getUser();
+ $sql->setInt( 'userid', $user->userid );
+
+ return $sql->getAll();
+ }
+
+
+ /**
+ * Ermittelt projektübergreifend die letzten Änderungen.
+ *
+ * @return array
+ */
+ public static function getAllLastChanges()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT {{object}}.id as objectid,
+ {{object}}.lastchange_date as lastchange_date,
+ {{object}}.filename as filename,
+ {{project}}.id as projectid,
+ {{project}}.name as projectname,
+ {{user}}.name as username,
+ {{user}}.id as userid,
+ {{user}}.mail as usermail,
+ {{user}}.fullname as userfullname
+ FROM {{object}}
+ LEFT JOIN {{project}}
+ ON {{object}}.projectid = {{project}}.id
+ LEFT JOIN {{user}}
+ ON {{user}}.id = {{object}}.lastchange_userid
+ ORDER BY {{object}}.lastchange_date DESC
+ LIMIT 50
+SQL
+ );
+
+ return $sql->getAll();
+ }
+
+
+
+ /**
+ * Ermittelt die letzten Änderung im Projekt.
+ * @return array
+ */
+ public function getLastChanges()
+ {
+
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT {{object}}.id as objectid,
+ {{object}}.lastchange_date as lastchange_date,
+ {{object}}.filename as filename,
+ {{object}}.typeid as typeid,
+ {{name}}.name as name,
+ {{user}}.name as username,
+ {{user}}.id as userid,
+ {{user}}.mail as usermail,
+ {{user}}.fullname as userfullname
+ FROM {{object}}
+ LEFT JOIN {{name}}
+ ON {{name}}.objectid = {{object}}.id
+ AND {{name}}.languageid = {languageid}
+ LEFT JOIN {{user}}
+ ON {{user}}.id = {{object}}.lastchange_userid
+ WHERE {{object}}.projectid = {projectid}
+ ORDER BY {{object}}.lastchange_date DESC
+SQL
+ );
+
+ // Variablen setzen.
+ $sql->setInt( 'projectid', $this->projectid );
+
+ $language = Session::getProjectLanguage();
+ $sql->setInt( 'languageid', $language->languageid );
+
+ return $sql->getAll();
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Template.class.php b/modules/cms-core/model/Template.class.php
@@ -0,0 +1,440 @@
+<?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.
+
+
+/**
+ * Logische Darstellung eines Templates
+ *
+ * @author: $Author$
+ * @version: $Revision$
+ * @package openrat.objects
+ */
+class Template
+{
+ /**
+ * ID dieses Templates
+ * @type Integer
+ */
+ var $templateid = 0;
+
+ /**
+ * Projekt-ID des aktuell ausgew?hlten Projektes
+ * @type Integer
+ */
+ var $projectid = 0;
+
+ /**
+ * Logischer Name
+ * @type String
+ */
+ var $name = 'unnamed';
+
+ /**
+ * ID der Projektvariante
+ * @type Integer
+ */
+ var $modelid = 0;
+
+ /**
+ * Dateierweiterung dieses Templates (abh?ngig von der Projektvariante)
+ * @type String
+ */
+ var $extension='';
+
+ /**
+ * Inhalt des Templates (abh?ngig von der Projektvariante)
+ * @type String
+ */
+ var $src='';
+
+ // Konstruktor
+ function __construct( $templateid='' )
+ {
+ $model = \Session::getProjectModel();
+ $project = \Session::getProject();
+
+ if ( is_object($model) )
+ $this->modelid = $model->modelid;
+ if ( is_object($project) )
+ $this->projectid = $project->projectid;
+
+ if ( is_numeric($templateid) )
+ $this->templateid = $templateid;
+ }
+
+
+ /**
+ * Ermitteln aller Templates in dem aktuellen Projekt.
+ * @return Array mit Id:Name
+ */
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{template}}'.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY name ASC ' );
+ if ( isset($this) && isset($this->projectid) )
+ $sql->setInt( 'projectid',$this->projectid );
+ else
+ {
+ $project = \Session::getProject();
+ $sql->setInt( 'projectid',$project->projectid );
+ }
+
+ return $sql->getAssoc();
+ }
+
+
+ /**
+ * Laden des Templates aus der Datenbank und f?llen der Objekteigenschaften
+ */
+ function load()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{template}}'.
+ ' WHERE id={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $row = $sql->getRow();
+
+ if ( empty($row) )
+ throw new \ObjectNotFoundException("Template not found: ".$this->templateid);
+
+ $this->name = $row['name' ];
+ $this->projectid = $row['projectid'];
+
+ $sql = $db->sql( 'SELECT * FROM {{templatemodel}}'.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $sql->setInt( 'modelid' ,$this->modelid );
+ $row = $sql->getRow();
+
+ if ( isset($row['extension']) )
+ {
+ $this->extension = $row['extension'];
+ $this->src = $row['text'];
+ }
+ else
+ {
+ $this->extension = null;
+ $this->src = null;
+ }
+
+ }
+
+
+ /**
+ * Abspeichern des Templates in der Datenbank
+ */
+ function save()
+ {
+ if ( $this->name == "" )
+ $this->name = lang('GLOBAL_TEMPLATE').' #'.$this->templateid;
+
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{template}}'.
+ ' SET name={name}'.
+ ' WHERE id={templateid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setInt ( 'templateid',$this->templateid );
+ $sql->query();
+
+ $sql = $db->sql( 'SELECT COUNT(*) FROM {{templatemodel}}'.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setInt ( 'modelid' ,$this->modelid );
+
+ if ( intval($sql->getOne()) > 0 )
+ {
+ // Vorlagen-Quelltext existiert für diese Varianten schon.
+ $sql = $db->sql( 'UPDATE {{templatemodel}}'.
+ ' SET extension={extension},'.
+ ' text={src} '.
+ ' WHERE templateid={templateid}'.
+ ' AND projectmodelid={modelid}' );
+ }
+ else
+ {
+ // Vorlagen-Quelltext wird für diese Varianten neu angelegt.
+ $sql = $db->sql('SELECT MAX(id) FROM {{templatemodel}}');
+ $nextid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( 'INSERT INTO {{templatemodel}}'.
+ ' (id,templateid,projectmodelid,extension,text) '.
+ ' VALUES ({id},{templateid},{modelid},{extension},{src}) ');
+ $sql->setInt ( 'id',$nextid );
+ }
+
+ $sql->setString( 'extension' ,$this->extension );
+ $sql->setString( 'src' ,$this->src );
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ $sql->setInt ( 'modelid' ,$this->modelid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Es werden Templates mit einem Inhalt gesucht
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Template-IDs
+ */
+ function getTemplateIdsByValue( $text )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT templateid FROM {{templatemodel}}'.
+ ' WHERE text LIKE {text} '.
+ ' AND projectmodelid={modelid}' );
+
+ $sql->setInt ( 'modelid',$this->modelid );
+ $sql->setString( 'text' ,'%'.$text.'%' );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste nur mit den Element-IDs ermittelt und zur?ckgegeben
+ * @return Array
+ */
+ function getElementIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id FROM {{element}}'.
+ ' WHERE templateid={templateid}'.
+ ' ORDER BY name ASC' );
+ $sql->setInt( 'templateid',$this->templateid );
+ return $sql->getCol();
+ }
+
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste mit den kompletten Elementen ermittelt und zurueckgegeben
+ * @return Array
+ */
+ function getElements()
+ {
+ $list = array();
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{element}}'.
+ ' WHERE templateid={templateid}'.
+ ' ORDER BY name ASC' );
+ $sql->setInt( 'templateid',$this->templateid );
+ foreach($sql->getAll() as $row )
+ {
+ $e = new Element( $row['id'] );
+ $e->setDatabaseRow( $row );
+
+ $list[$e->elementid] = $e;
+ unset($e);
+ }
+ return $list;
+ }
+
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste mit den kompletten Elementen ermittelt und zurueckgegeben
+ * @return Array
+ */
+ function getWritableElements()
+ {
+ $list = array();
+ $e = new Element();
+ $readonlyList = "'".implode("','",$e->readonlyElementNames)."'";
+
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+SELECT * FROM {{element}}
+ WHERE templateid={templateid}
+ AND writable=1
+ AND type NOT IN ($readonlyList)
+ ORDER BY name ASC
+SQL
+);
+ $sql->setInt ( 'templateid' ,$this->templateid );
+ foreach($sql->getAll() as $row )
+ {
+ $e = new Element( $row['id'] );
+ $e->setDatabaseRow( $row );
+
+ $list[$e->elementid] = $e;
+ unset($e);
+ }
+ return $list;
+ }
+
+
+
+ /**
+ * Ermitteln aller Elemente zu diesem Template
+ * Es wird eine Liste mit den Element-Namen zur?ckgegeben
+ * @return Array
+ */
+ function getElementNames()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name FROM {{element}}'.
+ ' WHERE templateid={templateid}'.
+ ' ORDER BY name ASC' );
+ $sql->setInt( 'templateid',$this->templateid );
+
+ return $sql->getAssoc();
+ }
+
+
+ /**
+ * Hinzuf?gen eines Elementes
+ * @param String Name des Elementes
+ */
+ function addElement( $name,$description='',$type='text' )
+ {
+ $element = new Element();
+ $element->name = $name;
+ $element->desc = $description;
+ $element->type = $type;
+ $element->templateid = $this->templateid;
+ $element->wiki = true;
+ $element->writable = true;
+ $element->add();
+ }
+
+
+ /**
+ * Hinzufuegen eines Templates
+ * @param String Name des Templates (optional)
+ */
+ function add( $name='' )
+ {
+ if ( !empty($name) )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{template}}');
+ $this->templateid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( 'INSERT INTO {{template}}'.
+ ' (id,name,projectid)'.
+ ' VALUES({templateid},{name},{projectid})' );
+ $sql->setInt ('templateid',$this->templateid );
+ $sql->setString('name' ,$name );
+
+ // Wenn Projektid nicht vorhanden, dann aus Session lesen
+ if ( !isset($this->projectid) || intval($this->projectid) == 0 )
+ {
+ $project = \Session::getProject();
+ $this->projectid = $project->projectid;
+ }
+
+ $sql->setInt ('projectid' ,$this->projectid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Ermitteln alles Objekte (=Seiten), welche auf diesem Template basieren.
+ *
+ * @return Array Liste von Objekt-IDs
+ */
+ function getDependentObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT objectid FROM {{page}}'.
+ ' WHERE templateid={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Loeschen des Templates
+ *
+ * Entfernen alle Templateinhalte und des Templates selber
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ foreach( $this->getElementIds() as $elementid )
+ {
+ $element = new Element( $elementid );
+ $element->delete();
+ }
+
+ $sql = $db->sql( 'DELETE FROM {{templatemodel}}'.
+ ' WHERE templateid={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $sql->query();
+
+ $sql = $db->sql( 'DELETE FROM {{template}}'.
+ ' WHERE id={templateid}' );
+ $sql->setInt( 'templateid',$this->templateid );
+ $sql->query();
+ }
+
+
+ /**
+ * Ermittelt den Mime-Type zu diesem Template.
+ *
+ * Es wird die Extension des Templates betrachtet und dann mit Hilfe der
+ * Konfigurationsdatei 'mime-types.ini' der Mime-Type bestimmt.
+ *
+ * @return String Mime-Type
+ */
+ function mimeType()
+ {
+ global $conf;
+ $mime_types = $conf['mime-types'];
+
+ // Nur den letzten Teil der Extension auswerten:
+ // Aus 'mobile.html' wird nur 'html' verwendet.
+ $parts = explode('.',$this->extension);
+ $extension = strtolower(array_pop($parts));
+
+ if ( !empty($mime_types[$extension]) )
+ $this->mime_type = $mime_types[$extension];
+ else
+ // Wenn kein Mime-Type gefunden, dann Standardwert setzen
+ $this->mime_type = 'application/octet-stream';
+
+ return( $this->mime_type );
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Url.class.php b/modules/cms-core/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/modules/cms-core/model/User.class.php b/modules/cms-core/model/User.class.php
@@ -0,0 +1,1025 @@
+<?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.
+use security\Password;
+
+
+/**
+ * Darstellen eines Benutzers
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class User extends ModelBase
+{
+ var $userid = 0;
+ var $error = '';
+
+ var $name = '';
+ var $fullname = '';
+ var $ldap_dn;
+ var $tel;
+ var $mail;
+ var $desc;
+ var $style;
+ var $isAdmin;
+ var $projects = array();
+ var $rights;
+ var $loginDate = 0;
+
+ var $language;
+ var $timezone;
+ var $passwordExpires;
+ var $passwordAlgo;
+
+ var $lastLogin;
+ var $otpSecret;
+ var $hotp ;
+ var $hotpCount;
+ var $totp ;
+
+
+
+ var $mustChangePassword = false;
+ var $groups = null;
+ var $loginModuleName = null;
+
+ // Konstruktor
+ public function __construct( $userid='' )
+ {
+ if ( is_numeric($userid) )
+ $this->userid = $userid;
+ }
+
+
+ // Lesen Benutzer aus der Datenbank
+ function listAll()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,name '.
+ ' FROM {{user}}'.
+ ' ORDER BY name' );
+
+ return $sql->getAssoc();
+ }
+
+
+ // Lesen Benutzer aus der Datenbank
+ function getAllUsers()
+ {
+ $list = array();
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * '.
+ ' FROM {{user}}'.
+ ' ORDER BY name' );
+
+ foreach($sql->getAll() as $row )
+ {
+ $user = new User();
+ $user->setDatabaseRow( $row );
+
+ $list[] = $user;
+ }
+
+ return $list;
+ }
+
+
+ /**
+ * Benutzer als aktiven Benutzer in die Session schreiben.
+ */
+ public function setCurrent()
+ {
+ $this->loadProjects();
+ $this->loginDate = time();
+
+ \Session::setUser( $this );
+
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ UPDATE {{user}}
+ SET last_login={time}
+ WHERE id={userid}
+SQL
+ );
+ $sql->setInt( 'time' ,time() );
+ $sql->setInt( 'userid',$this->userid );
+
+ // Datenbankabfrage ausfuehren
+ $sql->query();
+
+ }
+
+
+ /**
+ * Erzeugt eine WHERE-Bedingung zur Verwendung in einer SQL-Anfrage.<br>
+ * Es wird eine Oder-Liste mit allen Gruppen-Ids erzeugt.
+ *
+ * @return String SQL-WHERE-Bedingung
+ */
+ function getGroupClause()
+ {
+ $groupIds = $this->getGroupIds();
+
+ if ( count($groupIds) > 0 )
+ $groupclause = ' groupid='.implode(' OR groupid=',$groupIds );
+ else
+ $groupclause = ' 1=0 ';
+
+ return $groupclause;
+ }
+
+
+ // Prueft, ob der Benutzer fuer ein Projekt berechtigt ist
+ function hasProject( $projectid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT COUNT(*)'.
+ ' FROM {{acl}}'.
+ ' LEFT JOIN {{object}} ON {{object}}.id={{acl}}.objectid '.
+ ' WHERE projectid={projectidid} AND '.
+ ' ( userid={userid} OR'.
+ ' '.$this->getGroupClause().' )' );
+ $sql->setInt ( 'userid',$this->userid );
+
+ return $sql->getOne() > 0;
+ }
+
+
+
+ /**
+ * Lesen aller Projekte, fuer die der Benutzer berechtigt ist.
+ *
+ * @return Array [Projekt-Id] = Projekt-Name
+ */
+ public function getReadableProjects()
+ {
+ $db = db_connection();
+
+ if ( $this->isAdmin )
+ {
+ // Administratoren haben Rechte auf alle Projekte.
+ return Project::getAllProjects();
+ }
+ else
+ {
+ $groupClause = $this->getGroupClause();
+ $sql = $db->sql(<<<SQL
+SELECT DISTINCT {{project}}.id,{{project}}.name
+ FROM {{object}}
+ LEFT JOIN {{acl}} ON {{object}}.id = {{acl}}.objectid
+ LEFT JOIN {{project}} ON {{project}}.id = {{object}}.projectid
+ WHERE {{object}}.parentid IS NULL AND
+ {{acl}}.id IS NOT NULL AND
+ ( {{acl}}.userid={userid} OR
+ $groupClause OR
+ ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL))
+ ORDER BY {{project}}.name
+SQL
+);
+ $sql->setInt ( 'userid',$this->userid );
+
+ return $sql->getAssoc();
+ }
+
+ }
+
+
+
+ /**
+ * Ermittelt alls Projekte, fuer die der Benutzer berechtigt ist.
+ * @return Array [0..n] = Projekt-Id
+ */
+ function getReadableProjectIds()
+ {
+ return array_keys( $this->getReadableProjects() );
+ }
+
+
+ /**
+ * Lädt die Liste alle Projekte, fuer die der Benutzer berechtigt ist und
+ * speichert diese in diesem Benutzerobjekt.
+ */
+ function loadProjects()
+ {
+ $this->projects = $this->getReadableProjects();
+ }
+
+
+
+ /**
+ * Ermittelt zu diesem Benutzer den Login-Token.
+ */
+ function loginToken()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT id,mail,name,password_hash FROM {{user}}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$this->userid );
+ $row = $sql->getRow();
+
+ if ( count($row) == 0 )
+ throw new \ObjectNotFoundException();
+
+ // Zusammensetzen des Tokens
+ return sha1( $row['password_hash'].$row['name'].$row['id'].$row['mail'] );
+ }
+
+
+ /**
+ * Lesen Benutzer aus der Datenbank.
+ */
+ public function load()
+ {
+ global $conf;
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT * FROM {{user}}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$this->userid );
+ $row = $sql->getRow();
+
+ if ( count($row) == 0 )
+ throw new \ObjectNotFoundException();
+
+ $this->setDatabaseRow( $row );
+ }
+
+
+ /**
+ * Benutzerobjekt �ber Benutzernamen ermitteln.<br>
+ * Liefert ein neues Benutzerobjekt zur�ck.
+ *
+ * @static
+ * @param name Benutzername
+ */
+ public static function loadWithName( $name )
+ {
+ global $conf;
+ $db = db_connection();
+
+ // Benutzer �ber Namen suchen
+ $sql = $db->sql( 'SELECT id FROM {{user}}'.
+ ' WHERE name={name}' );
+ //Html::debug($sql);
+ $sql->setString( 'name',$name );
+ $userId = $sql->getOne();
+
+ // Benutzer �ber Id instanziieren
+ $neuerUser = new \cms\model\User( $userId );
+
+ $neuerUser->load();
+
+ return $neuerUser;
+ }
+
+
+
+ /**
+ * Stellt fest, ob der Benutzer korrekt geladen ist.
+ */
+ public function isValid()
+ {
+ return intval($this->userid) > 0;
+ }
+
+
+
+ /**
+ * Lesen Benutzer aus der Datenbank
+ */
+ protected function setDatabaseRow( $row )
+ {
+ global $conf;
+
+ $this->userid = $row['id' ];
+ $this->name = $row['name' ];
+ $this->style = $row['style' ];
+ $this->isAdmin = ( $row['is_admin'] == '1');
+ $this->ldap_dn = $row['ldap_dn' ];
+ $this->fullname = $row['fullname'];
+ $this->tel = $row['tel' ];
+ $this->mail = $row['mail' ];
+ $this->desc = $row['descr' ];
+ $this->language = $row['language'];
+ $this->timezone = $row['timezone'];
+ $this->lastLogin = $row['last_login'];
+ $this->otpSecret = $row['otp_secret'];
+ $this->hotp = ($row['hotp']==1);
+ $this->hotpCount = $row['hotp_counter'];
+ $this->totp = ($row['totp']==1);
+ $this->passwordExpires = $row['password_expires'];
+ $this->passwordAlgo = $row['password_algo'];
+
+ if ( $this->fullname == '' )
+ $this->fullname = $this->name;
+
+ if ( $this->style == '' )
+ $this->style = $conf['interface']['style']['default'];
+ }
+
+
+
+ /**
+ * Namen ermitteln.<br>
+ * Wenn "fullname" gefuellt, dann diesen benutzen, sonst den Benutzernamen.
+ */
+ function getName()
+ {
+ if ( empty($this->fullname))
+ return $this->name;
+ else
+ return $this->fullname;
+ }
+
+
+
+ /**
+ * Liest einen Benutzernamen aus der Datenbank.
+ *
+ * @param int Benutzer-Id
+ * @return String Benutzername
+ */
+ function getUserName( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT name FROM {{user}}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$userid );
+
+ $name = $sql->getOne();
+
+ if ( $name == '' )
+ return lang('UNKNOWN');
+ else return $name;
+ }
+
+
+ /**
+ * Speichern Benutzer in der Datenbank.
+ */
+ function save()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ UPDATE {{user}}
+ SET name={name},
+ fullname={fullname},
+ ldap_dn ={ldap_dn} ,
+ tel ={tel} ,
+ descr ={desc} ,
+ mail ={mail} ,
+ style ={style} ,
+ language = {language},
+ timezone = {timezone},
+ is_admin = {isAdmin},
+ totp = {totp},
+ hotp = {hotp}
+ WHERE id={userid}
+SQL
+ );
+ $sql->setString ( 'name' ,$this->name );
+ $sql->setString ( 'fullname',$this->fullname);
+ $sql->setString ( 'ldap_dn' ,$this->ldap_dn );
+ $sql->setString ( 'tel' ,$this->tel );
+ $sql->setString ( 'desc' ,$this->desc );
+ $sql->setString ( 'mail' ,$this->mail );
+ $sql->setString ( 'style' ,$this->style );
+ $sql->setString ( 'language',$this->language);
+ $sql->setString ( 'timezone',$this->timezone);
+ $sql->setBoolean( 'isAdmin' ,$this->isAdmin );
+ $sql->setBoolean( 'totp' ,$this->totp );
+ $sql->setBoolean( 'hotp' ,$this->hotp );
+ $sql->setInt ( 'userid' ,$this->userid );
+
+ // Datenbankabfrage ausfuehren
+ $sql->query();
+ }
+
+
+ /**
+ * Benutzer hinzuf�gen
+ *
+ * @param String $name Benutzername
+ */
+ function add( $name = '' )
+ {
+ if ( $name != '' )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{user}}');
+ $this->userid = intval($sql->getOne())+1;
+
+ $sql = $db->sql('INSERT INTO {{user}}'.
+ ' (id,name,password_hash,ldap_dn,fullname,tel,mail,descr,style,is_admin,password_salt)'.
+ " VALUES( {userid},{name},'','','','','','','default',0,'' )" );
+ $sql->setInt ('userid',$this->userid);
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $sql->query();
+
+ $this->addNewUserGroups(); // Neue Gruppen hinzufuegen.
+
+ $this->renewOTPSecret();
+ }
+
+
+
+ /**
+ * Zu einem neuen Benutzer automatisch Gruppen hinzufuegen.
+ * Diese Methode wird automatisch in "add()" aufgerufen.
+ */
+ function addNewUserGroups()
+ {
+ global $conf;
+ $groupNames = explode(',',@$conf['security']['newuser']['groups']);
+
+ if ( count($groupNames) == 0 )
+ return; // Nichts zu tun.
+
+ $db = db_connection();
+
+ $groupNames = "'".implode("','",$groupNames)."'";
+ $sql = $db->sql("SELECT id FROM {{group}} WHERE name IN($groupNames)");
+ $groupIds = array_unique( $sql->getCol() );
+
+ // Wir brauchen hier nicht weiter pr�fen, ob der Benutzer eine Gruppe schon hat, denn
+ // - passiert dies nur bei der Neuanlage eines Benutzers
+ // - Enth�lt die Group-Id-Liste eine ID nur 1x.
+
+ // Gruppen diesem Benutzer zuordnen.
+ foreach( $groupIds as $groupId )
+ $this->addGroup( $groupId );
+ }
+
+
+ /**
+ * Benutzer entfernen.<br>
+ * Vor dem Entfernen werden alle Referenzen auf diesen Benutzer entfernt:<br>
+ * - "Erzeugt von" f�r diesen Benutzer entfernen.<br>
+ * - "Letzte �nderung von" f�r diesen Benutzer entfernen<br>
+ * - Alle Archivdaten in Dateien mit diesem Benutzer entfernen<br>
+ * - Alle Berechtigungen dieses Benutzers l?schen<br>
+ * - Alle Gruppenzugehoerigkeiten dieses Benutzers l?schen<br>
+ * - Benutzer loeschen<br>
+ */
+ public function delete()
+ {
+ $db = db_connection();
+
+ // "Erzeugt von" f�r diesen Benutzer entfernen.
+ $sql = $db->sql( 'UPDATE {{object}} '.
+ 'SET create_userid=null '.
+ 'WHERE create_userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $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();
+
+ // 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();
+
+ // Alle Berechtigungen dieses Benutzers l?schen
+ $sql = $db->sql( 'DELETE FROM {{acl}} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $sql->query();
+
+ // Alle Gruppenzugehoerigkeiten dieses Benutzers l?schen
+ $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $sql->query();
+
+ // Benutzer loeschen
+ $sql = $db->sql( 'DELETE FROM {{user}} '.
+ 'WHERE id={userid}' );
+ $sql->setInt ('userid',$this->userid );
+ $sql->query();
+ }
+
+
+ /**
+ * Ermitteln der Eigenschaften zu diesem Benutzer
+ *
+ * @return array Liste der Eigenschaften als assoziatives Array
+ */
+ public function getProperties()
+ {
+ return parent::getProperties() + array('id'=>$this->userid,'is_admin'=> $this->isAdmin);
+ }
+
+
+
+ /**
+ * Setzt ein neues Kennwort fuer diesen Benutzer.
+ *
+ * @param password Kennwortt
+ * @param always true, wenn Kennwort dauerhaft.
+ */
+ function setPassword( $password, $always=true )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{user}} SET password_hash={password},password_algo={algo},password_expires={expires} '.
+ 'WHERE id={userid}' );
+
+ if ( $always )
+ {
+ $algo = Password::bestAlgoAvailable();
+ $expire = null;
+ }
+ else
+ {
+ // Klartext-Kennwort, der Benutzer muss das Kennwort beim nä. Login ändern.
+ $algo = OR_PASSWORD_ALGO_PLAIN;
+ $expire = time();
+ }
+
+ // Hashsumme für Kennwort erzeugen
+ if ( $expire == null )
+ $sql->setNull('expires');
+ else
+ $sql->setInt('expires',$expire);
+
+ $sql->setInt ('algo' ,$algo );
+ $sql->setString('password',Password::hash($this->pepperPassword($password),$algo) );
+ $sql->setInt ('userid' ,$this->userid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Gruppen ermitteln, in denen der Benutzer Mitglied ist.
+ *
+ * @return array mit Id:Name
+ */
+ function getGroups()
+ {
+ if ( !is_array($this->groups) )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{group}}.id,{{group}}.name FROM {{group}} '.
+ 'LEFT JOIN {{usergroup}} ON {{usergroup}}.groupid={{group}}.id '.
+ 'WHERE {{usergroup}}.userid={userid}' );
+ $sql->setInt('userid',$this->userid );
+ $this->groups = $sql->getAssoc();
+ }
+
+ return $this->groups;
+ }
+
+
+ // Gruppen ermitteln, in denen der Benutzer Mitglied ist
+ function getGroupIds()
+ {
+ return array_keys( $this->getGroups() );
+
+ /*
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT groupid FROM {{usergroup}} '.
+ 'WHERE userid={userid}' );
+ $sql->setInt('userid',$this->userid );
+
+ return $sql->getCol( $sql );
+ */
+ }
+
+
+ // Gruppen ermitteln, in denen der Benutzer *nicht* Mitglied ist
+ function getOtherGroups()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{group}}.id,{{group}}.name FROM {{group}}'.
+ ' LEFT JOIN {{usergroup}} ON {{usergroup}}.groupid={{group}}.id AND {{usergroup}}.userid={userid}'.
+ ' WHERE {{usergroup}}.userid IS NULL' );
+ $sql->setInt('userid' ,$this->userid );
+
+ return $sql->getAssoc();
+ }
+
+
+
+ /**
+ * Benutzer zu einer Gruppe hinzufuegen.
+ *
+ * @param groupid die Gruppen-Id
+ */
+ function addGroup( $groupid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql('SELECT MAX(id) FROM {{usergroup}}');
+ $usergroupid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( 'INSERT INTO {{usergroup}} '.
+ ' (id,userid,groupid) '.
+ ' VALUES( {usergroupid},{userid},{groupid} )' );
+ $sql->setInt('usergroupid',$usergroupid );
+ $sql->setInt('userid' ,$this->userid );
+ $sql->setInt('groupid' ,$groupid );
+
+ $sql->query();
+
+ }
+
+
+
+ /**
+ * Benutzer aus Gruppe entfernen.
+ *
+ * @param groupid die Gruppen-Id
+ */
+ function delGroup( $groupid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'DELETE FROM {{usergroup}} '.
+ ' WHERE userid={userid} AND groupid={groupid}' );
+ $sql->setInt ('userid' ,$this->userid );
+ $sql->setInt ('groupid' ,$groupid );
+
+ $sql->query();
+ }
+
+
+ /**
+ * Ermitteln aller Rechte des Benutzers im aktuellen Projekt.
+ *
+ * @param Integer $projectid Projekt-Id
+ * @param Integer $languageid Sprache-Id
+ */
+ function loadRights( $projectid,$languageid )
+ {
+ }
+
+
+ /**
+ * Ermitteln aller Berechtigungen des Benutzers.<br>
+ * Diese Daten werden auf der Benutzerseite in der Administration angezeigt.
+ *
+ * @return array
+ */
+ function getAllAcls()
+ {
+
+ $this->delRights();
+
+ $db = db_connection();
+
+ $group_clause = $this->getGroupClause();
+
+ $sql = $db->sql( 'SELECT {{acl}}.*,{{object}}.projectid,{{language}}.name AS languagename FROM {{acl}}'.
+ ' LEFT JOIN {{object}} '.
+ ' ON {{object}}.id={{acl}}.objectid '.
+ ' LEFT JOIN {{language}} '.
+ ' ON {{language}}.id={{acl}}.languageid '.
+ ' WHERE ( {{acl}}.userid={userid} OR '.$group_clause.
+ ' OR ({{acl}}.userid IS NULL AND {{acl}}.groupid IS NULL) )'.
+ ' ORDER BY {{object}}.projectid,{{acl}}.languageid' );
+ $sql->setInt ( 'userid' ,$this->userid );
+
+ $aclList = array();
+
+ foreach($sql->getAll() as $row )
+ {
+ $acl = new Acl();
+ $acl->setDatabaseRow( $row );
+ $acl->projectid = $row['projectid' ];
+ if ( intval($acl->languageid) == 0 )
+ $acl->languagename = lang('GLOBAL_ALL_LANGUAGES');
+ else
+ $acl->languagename = $row['languagename'];
+ $aclList[] = $acl;
+ }
+
+ return $aclList;
+ }
+
+
+ /**
+ * Ermitteln aller Berechtigungen.
+ * @return array Berechtigungen
+ */
+ function getRights()
+ {
+ die('User.class::getRights()');
+
+// $db = db_connection();
+// $var = array();
+//
+// // Alle Projekte lesen
+// $sql = $db->sql( 'SELECT id,name FROM {{project}}' );
+// $projects = $sql->getAssoc( $sql );
+//
+// foreach( $projects as $projectid=>$projectname )
+// {
+// $var[$projectid] = array();
+// $var[$projectid]['name'] = $projectname;
+// $var[$projectid]['folders'] = array();
+// $var[$projectid]['rights'] = array();
+//
+// $sql = $db->sql( 'SELECT {{acl}}.* FROM {{acl}}'.
+// ' LEFT JOIN {{folder}} ON {{acl}}.folderid = {{folder}}.id'.
+// ' WHERE {{folder}}.projectid={projectid}'.
+// ' AND {{acl}}.userid={userid}' );
+// $sql->setInt('projectid',$projectid );
+// $sql->setInt('userid' ,$this->userid );
+//
+// $acls = $sql->getAll( $sql );
+//
+// 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'] = Html::url(array('action'=>'user','subaction'=>'delright','aclid'=>$aclid));
+// }
+//
+// $sql = $db->sql( 'SELECT id FROM {{folder}}'.
+// ' WHERE projectid={projectid}' );
+// $sql->setInt('projectid',$projectid);
+// $folders = $sql->getCol( $sql );
+//
+// $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;
+ }
+
+
+ /**
+ * Entfernt alle Rechte aus diesem Benutzerobjekt.
+ */
+ function delRights()
+ {
+ $this->rights = array();
+ }
+
+
+ /**
+ * Ueberpruft, ob der Benutzer ein bestimmtes Recht hat
+ *
+ * @param $objectid Objekt-Id zu dem Objekt, dessen Rechte untersucht werden sollen
+ * @param $type Typ des Rechts (Lesen,Schreiben,...) als Konstante ACL_*
+ */
+ function hasRight( $objectid,$type )
+ {
+ global $conf;
+ if ( $this->isAdmin && !$conf['security']['readonly'] )
+ return true;
+
+ if ( $this->isAdmin && $type & ACL_READ )
+ return true;
+
+ if ( !isset($this->rights[$objectid]) )
+ return false;
+
+ return $this->rights[$objectid] & $type;
+ }
+
+
+ /**
+ * Berechtigung dem Benutzer hinzufuegen.
+ *
+ * @param objectid Objekt-Id, zu dem eine Berechtigung hinzugefuegt werden soll
+ * @param Art des Rechtes, welches hinzugefuegt werden soll
+ */
+ function addRight( $objectid,$type )
+ {
+ global $conf;
+
+ if ( $conf['security']['readonly'] )
+ if ( $type & ACL_READ )
+ $type = ACL_READ;
+ else
+ $type = 0;
+
+ if ( $type & ACL_PUBLISH && $conf['security']['nopublish'] )
+ $type -= ACL_PUBLISH;
+
+
+ if ( !isset($this->rights[$objectid]) )
+ $this->rights[$objectid] = 0;
+
+ $this->rights[$objectid] = $this->rights[$objectid] | $type;
+ }
+
+
+ /**
+ * Ermitteln aller zur Verfuegung stehenden Stylesheets
+ */
+ public function getAvailableStyles()
+ {
+ global $conf;
+ $styles = array();
+
+ foreach( $conf['style'] as $key=>$values)
+ $styles[$key] = $values['name'];
+
+ return $styles;
+ }
+
+ /**
+ * Ueberpruefen des Kennwortes.
+ *
+ * Es wird festgestellt, ob das Kennwort dem des Benutzers entspricht.
+ * Es wird dabei nur gegen die interne Datenbank geprüft. Weitere
+ * Loginmodule werden nicht aufgerufen!
+ * Diese Methode darf kein Bestandteil des Logins sein, da nur das Kennwort geprüft wird!
+ * Kennwortablauf und Token werden nicht geprüft!
+ */
+ function checkPassword( $password )
+ {
+ $db = db_connection();
+ // Laden des Benutzers aus der Datenbank, um Password-Hash zu ermitteln.
+ $sql = $db->sql( 'SELECT * FROM {{user}}'.
+ ' WHERE id={userid}' );
+ $sql->setInt( 'userid',$this->userid );
+ $row_user = $sql->getRow();
+
+ // Pruefen ob Kennwort mit Datenbank uebereinstimmt.
+ return Password::check($this->pepperPassword($password),$row_user['password_hash'],$row_user['password_algo']);
+ }
+
+
+ /**
+ * Erzeugt ein aussprechbares Kennwort.
+ *
+ * Inspired by http://www.phpbuilder.com/annotate/message.php3?id=1014451
+ *
+ * @return String Zuf�lliges Kennwort
+ */
+ function createPassword()
+ {
+ global $conf;
+
+ $pw = '';
+ $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
+ $v = 'aeiou'; //vowels
+ $a = $c.$v; //both
+
+ //use two syllables...
+ for ( $i=0; $i < intval($conf['security']['password']['min_length'])/3; $i++ )
+ {
+ $pw .= $c[rand(0, strlen($c)-1)];
+ $pw .= $v[rand(0, strlen($v)-1)];
+ $pw .= $a[rand(0, strlen($a)-1)];
+ }
+ //... and add a nice number
+ $pw .= rand(10,99);
+
+ return $pw;
+ }
+
+
+ /**
+ * Das Kennwort "pfeffern".
+ *
+ * Siehe http://de.wikipedia.org/wiki/Salt_%28Kryptologie%29#Pfeffer
+ * für weitere Informationen.
+ *
+ * @param Kennwort
+ * @return Das gepfefferte Kennwort
+ */
+ public function pepperPassword( $pass )
+ {
+ global $conf;
+ return $conf['security']['password']['pepper'].$pass;
+ }
+
+
+ /**
+ * Ermittelt projektübergreifend die letzten Änderungen des Benutzers.
+ *
+ * @return array <string, unknown>
+ */
+ public function getLastChanges()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT {{object}}.id as objectid,
+ {{object}}.filename as filename,
+ {{object}}.lastchange_date as lastchange_date,
+ {{project}}.id as projectid,
+ {{project}}.name as projectname
+ FROM {{object}}
+ LEFT JOIN {{project}}
+ ON {{object}}.projectid = {{project}}.id
+ WHERE {{object}}.lastchange_userid = {userid}
+ ORDER BY {{object}}.lastchange_date DESC
+SQL
+ );
+
+ $sql->setInt( 'userid', $this->userid );
+
+ return $sql->getAll();
+
+ }
+
+
+ /**
+ * Calculate the code, with given secret and point in time.
+ *
+ * @param string $secret
+ * @param int|null $timeSlice
+ *
+ * @return string
+ */
+ public function getTOTPCode()
+ {
+ $codeLength = 6;
+ $timeSlice = floor(time() / 30);
+ $secretkey = @hex2bin($this->otpSecret);
+ // Pack time into binary string
+ $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
+ // Hash it with users secret key
+ $hm = hash_hmac('SHA1', $time, $secretkey, true);
+ // Use last nipple of result as index/offset
+ $offset = ord(substr($hm, -1)) & 0x0F;
+ // grab 4 bytes of the result
+ $hashpart = substr($hm, $offset, 4);
+ // Unpak binary value
+ $value = unpack('N', $hashpart);
+ $value = $value[1];
+ // Only 32 bits
+ $value = $value & 0x7FFFFFFF;
+ $modulo = pow(10, $codeLength);
+ return str_pad($value % $modulo, $codeLength, '0', STR_PAD_LEFT);
+ }
+
+
+ /**
+ * Erzeugt ein neues OTP-Secret.
+ */
+ public function renewOTPSecret() {
+
+ $secret = Password::randomHexString(64);
+
+ $db = db_connection();
+
+ $stmt = $db->sql('UPDATE {{user}} SET otp_secret={secret} WHERE id={id}');
+
+ $stmt->setString( 'secret', $secret );
+ $stmt->setInt ( 'id' , $this->userid );
+
+ $stmt->execute();
+
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-core/model/Value.class.php b/modules/cms-core/model/Value.class.php
@@ -0,0 +1,1688 @@
+<?php
+namespace cms\model;
+use \ObjectNotFoundException;
+use \Logger;
+use \Text;
+use \Html;
+use \Http;
+use \Transformer;
+use \Code;
+
+// 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.
+
+
+
+/**
+ * Darstellen einer Inhaltes
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+
+class Value
+{
+ /**
+ * ID dieser Inhaltes
+ * @type Integer
+ */
+ var $valueid=0;
+
+ /**
+ * Seiten-Objekt der ?bergeordneten Seite
+ * @type Object
+ */
+ var $page;
+
+ /**
+ * Seiten-Id der uebergeordneten Seite
+ * @type Integer
+ */
+ var $pageid;
+
+ /**
+ * Kennzeichen, ob der Inhalt mit dem Inhalt einer anderern Seite verkn�pft wird.
+ * @type Object
+ */
+ var $isLink = false;
+
+ /**
+ * Objekt-ID, auf die verlinkt wird
+ * @type Integer
+ */
+ var $linkToObjectId=0;
+
+ /**
+ * Text-Inhalt
+ * @type String
+ */
+ var $text='';
+
+ /**
+ * Zahl. Auch Flie?kommazahlen werden als Ganzzahl gespeichert
+ * @type Integer
+ */
+ var $number=0;
+
+
+ /**
+ * Datum als Unix-Timestamp
+ * @type Integer
+ */
+ var $date=0;
+
+ /**
+ * Element-Objekt
+ * @type Object
+ */
+ var $element;
+
+ /**
+ * Element-Id
+ * @type Integer
+ */
+ var $elementid;
+
+ /**
+ * Der eigentliche Inhalt des Elementes
+ * @type String
+ */
+ var $value;
+
+ /**
+ * TimeStamp der letzten Aenderung
+ * @type Integer
+ */
+ var $lastchangeTimeStamp;
+
+ /**
+ * Benutzer-ID der letzten Aenderung
+ * @type Integer
+ */
+ var $lastchangeUserId;
+
+ /**
+ * Benutzername der letzten Aenderung
+ * @type Integer
+ */
+ var $lastchangeUserName;
+
+ /**
+ * Schalter, ob dieser Inhalt der aktive Inhalt ist
+ * @type Boolean
+ */
+ var $active;
+
+ /**
+ * Schalter, ob dieser Inhalt der Inhalt ist, der veroeffentlicht
+ * werden soll
+ * @type Boolean
+ */
+ var $publish;
+
+ /**
+ * @type Boolean
+ */
+ public $simple;
+
+ /**
+ * Konstruktor
+ */
+ function __construct()
+ {
+ $this->lastchangeUserId = 0;
+ $this->lastchangeTimeStamp = 0;
+
+ $language = \Session::getProjectLanguage();
+ if ( is_object($language) )
+ $this->languageid = $language->languageid;
+ }
+
+
+
+
+ function path_to_page( $pageid )
+ {
+ return $this->page->path_to_object( $pageid );
+ }
+ function path_to_object( $pageid )
+ {
+ return $this->path_to_page( $pageid );
+ }
+
+
+ /**
+ * Laden des aktuellen Inhaltes aus der Datenbank
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ if ( $this->publish )
+ $sql = $db->sql( 'SELECT * FROM {{value}}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}'.
+ ' AND publish=1' );
+ else
+ $sql = $db->sql( 'SELECT * FROM {{value}}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}'.
+ ' AND active=1' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+ $row = $sql->getRow();
+
+ if ( count($row) > 0 ) // Wenn Inhalt gefunden
+ {
+ $this->text = $row['text'];
+ $this->valueid = intval($row['id'] );
+ $this->linkToObjectId = intval($row['linkobjectid']);
+ $this->number = intval($row['number' ]);
+ $this->date = intval($row['date' ]);
+
+ $this->active = ( $row['active' ]=='1' );
+ $this->publish = ( $row['publish']=='1' );
+
+ $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
+ $this->lastchangeUserId = intval($row['lastchange_userid']);
+ }
+ }
+
+
+ /**
+ * Laden eines bestimmten Inhaltes aus der Datenbank
+ */
+ function loadWithId( $valueid=0 )
+ {
+ if ( $valueid != 0 )
+ $this->valueid = $valueid;
+
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{value}}.*,{{user}}.name as lastchange_username'.
+ ' FROM {{value}}'.
+ ' LEFT JOIN {{user}} ON {{user}}.id={{value}}.lastchange_userid'.
+ ' WHERE {{value}}.id={valueid}' );
+ $sql->setInt( 'valueid',$this->valueid);
+ $row = $sql->getRow();
+
+ $this->text = $row['text' ];
+ $this->pageid = intval($row['pageid' ]);
+ $this->elementid = intval($row['elementid' ]);
+ $this->languageid = intval($row['languageid' ]);
+ $this->valueid = intval($row['id' ]);
+ $this->linkToObjectId = intval($row['linkobjectid']);
+ $this->number = intval($row['number' ]);
+ $this->date = intval($row['date' ]);
+
+ $this->active = ( $row['active' ]=='1' );
+ $this->publish = ( $row['publish']=='1' );
+
+ $this->lastchangeTimeStamp = intval($row['lastchange_date' ]);
+ $this->lastchangeUserId = intval($row['lastchange_userid' ]);
+ $this->lastchangeUserName = $row['lastchange_username'];
+ }
+
+
+ /**
+ * Alle Versionen des aktuellen Inhaltes werden ermittelt
+ * @return Array
+ */
+ function getVersionList()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{value}}.*,{{user}}.name as lastchange_username'.
+ ' FROM {{value}}'.
+ ' LEFT JOIN {{user}} ON {{user}}.id={{value}}.lastchange_userid'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}'.
+ ' ORDER BY lastchange_date' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $list = array();
+ foreach($sql->getAll() as $row )
+ {
+ $val = new Value();
+ $val->valueid = $row['id'];
+
+ $val->text = $row['text'];
+ $val->valueid = intval($row['id'] );
+ $val->linkToObjectId = intval($row['linkobjectid']);
+ $val->number = intval($row['number' ]);
+ $val->date = intval($row['date' ]);
+
+ $val->active = ( $row['active' ]=='1' );
+ $val->publish = ( $row['publish']=='1' );
+
+ $val->lastchangeTimeStamp = intval($row['lastchange_date' ]);
+ $val->lastchangeUserId = intval($row['lastchange_userid' ]);
+ $val->lastchangeUserName = $row['lastchange_username'];
+ $list[] = $val;
+ }
+ return $list;
+ }
+
+
+ /**
+ * Die Anzahl der Versionen des aktuellen Inhaltes wird ermittelt
+ * @return Array
+ */
+ function getCountVersions()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT COUNT(*) FROM {{value}}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ return $sql->getOne();
+ }
+
+
+ function getLastChangeTime()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql(
+<<<SQL
+ SELECT lastchange_date FROM {{value}}
+ WHERE elementid ={elementid}
+ AND pageid ={pageid}
+ AND languageid={languageid}
+ ORDER BY id DESC
+SQL
+ );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ return $sql->getOne();
+ }
+
+
+
+ /**
+ * Inhalt freigeben
+ */
+ function release()
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{value}}'.
+ ' SET publish=0'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $sql->query();
+
+ $sql = $db->sql( 'UPDATE {{value}}'.
+ ' SET publish=1'.
+ ' WHERE active = 1'.
+ ' AND elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $sql->query();
+ }
+
+ /**
+ * Inhalt speichern
+ */
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = $db->sql( 'UPDATE {{value}}'.
+ ' SET active=0'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $sql->query();
+
+ if ( $this->publish )
+ {
+ // Wenn Inhalt sofort veroeffentlicht werden kann, dann
+ // alle anderen Inhalte auf nicht-veroeffentlichen stellen
+ $sql = $db->sql( 'UPDATE {{value}}'.
+ ' SET publish=0'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+
+ $sql->query();
+ }
+
+ // Naechste ID aus Datenbank besorgen
+ $sql = $db->sql('SELECT MAX(id) FROM {{value}}');
+ $this->valueid = intval($sql->getOne())+1;
+
+ $sql = $db->sql( <<<SQL
+INSERT INTO {{value}}
+ (id ,linkobjectid ,text ,number ,date ,elementid ,pageid ,languageid ,active,publish ,lastchange_date ,lastchange_userid )
+ VALUES ({valueid},{linkobjectid},{text},{number},{date},{elementid},{pageid},{languageid},1 ,{publish},{lastchange_date},{lastchange_userid})
+SQL
+ );
+ $sql->setInt( 'valueid' ,$this->valueid );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid );
+
+ if ( intval($this->linkToObjectId)==0)
+ $sql->setNull ( 'linkobjectid' );
+ else $sql->setInt ( 'linkobjectid',$this->linkToObjectId );
+
+ if ( $this->text == '' )
+ $sql->setNull ( 'text' );
+ else $sql->setString( 'text',$this->text );
+
+ if ( intval($this->number)==0)
+ $sql->setNull ( 'number' );
+ else $sql->setInt ( 'number',$this->number );
+
+ if ( intval($this->date)==0)
+ $sql->setNull ( 'date' );
+ else $sql->setInt ( 'date',$this->date );
+
+ $sql->setBoolean( 'publish' ,$this->publish );
+ $sql->setInt ( 'lastchange_date' ,now() );
+ $user = \Session::getUser();
+ $sql->setInt ( 'lastchange_userid',$user->userid );
+
+ $sql->query();
+
+ // Nur ausfuehren, wenn in Konfiguration aktiviert.
+ $limit = config('content','revision-limit');
+ if ( isset($limit['enabled']) && $limit['enabled'] )
+ $this->checkLimit();
+ }
+
+
+ /**
+ * Pruefen, ob maximale Anzahl von Versionen erreicht.
+ * In diesem Fall die zu alten Versionen l�schen.
+ */
+ function checkLimit()
+ {
+ $limit = config('content','revision-limit');
+
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+ SELECT id FROM {{value}}
+ WHERE elementid = {elementid}
+ AND pageid = {pageid}
+ AND languageid = {languageid}
+ AND active = 0
+ AND publish = 0
+ ORDER BY id
+SQL
+ );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid );
+ $values = $sql->getCol();
+
+ if ( count($values) > $limit['min-revisions'] )
+ {
+ $sql = $db->sql( <<<SQL
+ DELETE FROM {{value}}
+ WHERE elementid = {elementid}
+ AND pageid = {pageid}
+ AND languageid = {languageid}
+ AND active = 0
+ AND publish = 0
+ AND lastchange_date < {min_date}
+ AND id < {min_id}
+SQL
+ );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $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();
+ }
+
+ if ( count($values) > $limit['max-revisions'] )
+ {
+ $sql = $db->sql( <<<SQL
+ DELETE FROM {{value}}
+ WHERE elementid = {elementid}
+ AND pageid = {pageid}
+ AND languageid = {languageid}
+ AND active = 0
+ AND publish = 0
+ AND lastchange_date < {min_date}
+ AND id < {min_id}
+SQL
+ );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $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();
+ }
+ }
+
+
+
+ /**
+ * Diesen Inhalt loeschen
+ */
+ function delete()
+ {
+ $db = db_connection();
+ $sql = $db->sql( 'DELETE * FROM {{value}}'.
+ ' WHERE elementid ={elementid}'.
+ ' AND pageid ={pageid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'elementid' ,$this->element->elementid );
+ $sql->setInt( 'pageid' ,$this->pageid );
+ $sql->setInt( 'languageid',$this->languageid);
+ $row = $sql->getRow();
+ }
+
+
+ /**
+ * Hier findet die eigentliche Bereitstellung des Inhaltes statt, zu
+ * jedem Elementtyp wird ein Inhalt ermittelt.
+ *
+ * @return void (aber Eigenschaft 'value' wird gesetzt).
+ */
+ function generate()
+ {
+ global $conf;
+
+ if ( intval($this->valueid)==0 )
+ $this->load();
+
+ $inhalt = '';
+ $raw = false;
+
+ global $conf;
+
+ if ( $conf['cache']['enable_cache'] && is_file( $this->tmpfile() ))
+ {
+ $this->value = implode('',file($this->tmpfile() )); // from cache.
+ return;
+ }
+
+ // Inhalt ist mit anderer Seite verkn�pft.
+ if ( in_array($this->element->type,array('text','longtext','date','number')) && intval($this->linkToObjectId) != 0 && !$this->isLink )
+ {
+ $p = new Page( $this->linkToObjectId );
+ $p->load();
+
+ $v = new Value();
+ $v->isLink = true;
+ $v->pageid = $p->pageid;
+ $v->page = $p;
+ $v->simple = $this->simple;
+ $v->element = $this->element;
+ $v->languageid = $this->languageid;
+ //$v->modelid = $this->modelid;
+ $v->load();
+ $v->generate();
+ $this->value = $v->value;
+ return;
+ }
+
+ switch( $this->element->type )
+ {
+ case 'list' : // nur wg. R�ckw�rtskompabilit�t.
+ case 'insert':
+
+ $objectid = $this->linkToObjectId;
+
+ if ( intval($objectid) == 0 )
+ $objectid = $this->element->defaultObjectId;
+
+ if ( ! Object::available( $objectid) )
+ return;
+
+ $object = new Object( $objectid );
+ $object->objectLoadRaw();
+
+ if ( $object->isFolder )
+ {
+ if ( $this->simple )
+ {
+ $f = new Folder( $objectid );
+ $f->load();
+ $inhalt = $f->name;
+ unset( $f );
+ }
+ else
+ {
+ if ( $objectid != $this->page->objectid ) // Rekursion vermeiden
+ {
+ $f = new Folder( $objectid );
+ foreach( $f->getObjectIds() as $oid )
+ {
+ if ( $oid != $this->page->objectid ) // Rekursion vermeiden
+ {
+ switch( $this->element->subtype )
+ {
+ case '':
+ case 'inline':
+ $o = new Object( $oid );
+ $o->load();
+ switch( $o->getType() )
+ {
+ case OR_TYPE_PAGE:
+ $p = new Page( $oid );
+ $p->enclosingObjectId = $this->page->id;
+ $p->public = $this->page->public;
+ $p->up_path = $this->page->up_path();
+ $p->modelid = $this->page->modelid;
+ $p->languageid = $this->languageid;
+ $p->mime_type = $this->page->mimeType();
+ $p->load();
+ $p->generate();
+ $inhalt .= $p->value;
+ unset( $p );
+ break;
+ case OR_TYPE_LINK:
+ $l = new Link( $oid );
+ $l->load();
+ if ( $l->isLinkToObject )
+ {
+ $op = new Object( $l->linkedObjectId );
+ $op->load();
+ if ( $op->isPage )
+ {
+ $p = new Page( $l->linkedObjectId );
+ $p->enclosingObjectId = $this->page->id;
+ $p->public = $this->page->public;
+ $p->up_path = $this->page->up_path();
+ $p->modelid = $this->page->modelid;
+ $p->languageid = $this->languageid;
+ $p->load();
+ $p->generate();
+ $inhalt .= $p->value;
+ unset( $p );
+ }
+ }
+ break;
+ }
+ break;
+
+ case 'ssi':
+ $inhalt .= '<!--#include virtual="'.$this->page->path_to_object($oid).'" -->';
+ break;
+
+ default:
+ $inhalt = '?'.$this->element->subtype.'?';
+ }
+ }
+ else die('FATAL: recursion detected');
+ }
+ }
+ else die('FATAL: recursion detected');
+ }
+ }
+ elseif ( $object->isPage )
+ {
+ if ( $this->simple )
+ {
+ $p = new Page( $objectid );
+ $p->load();
+ $inhalt = $p->name;
+ unset( $p );
+ }
+ else
+ {
+ if ( $objectid != $this->page->objectid ) // Rekursion vermeiden
+ {
+ switch( $this->element->subtype )
+ {
+ case '':
+ case 'inline':
+ $p = new Page( $objectid );
+ $p->enclosingObjectId = $this->page->id;
+ $p->public = $this->page->public;
+ $p->up_path = $this->page->up_path();
+ $p->modelid = $this->page->modelid;
+ $p->languageid = $this->languageid;
+ $p->mime_type = $this->page->mimeType();
+ $p->load();
+ $p->generate();
+ $inhalt = $p->value;
+ unset( $p );
+ break;
+
+ case 'ssi':
+ $inhalt = '<!--#include virtual="'.$this->page->path_to_object($objectid).'" -->';
+ break;
+
+ default:
+ $inhalt = '?'.$this->element->subtype.'?';
+ break;
+ }
+ }
+ else die('FATAL: recursion detected');
+ }
+ }
+
+ if ( $this->simple )
+ {
+ $inhalt = strip_tags( $inhalt );
+ $inhalt = str_replace( "\n",'',$inhalt );
+ $inhalt = str_replace( "\r",'',$inhalt );
+ }
+
+ break;
+
+
+ case 'link':
+
+ $objectid = $this->linkToObjectId;
+ if ( intval($objectid) == 0 )
+ $objectid = $this->element->defaultObjectId;
+
+ if ( $objectid==0 )
+ {
+ // Link noch nicht gefuellt
+ $inhalt = '';
+ }
+ elseif ( ! Object::available($objectid) )
+ {
+ $inhalt = $this->simple?'-':'';
+ }
+ elseif ( $this->simple )
+ {
+ $o = new Object( $objectid );
+ $o->load();
+ $inhalt = $o->name;
+ }
+ elseif ($this->element->subtype == 'image_data_uri' )
+ {
+ $file = new File($objectid);
+ $file->load();
+ $inhalt = 'data:'.$file->mimeType().';base64,'.base64_encode($file->loadValue());
+ }
+ else
+ {
+ $inhalt = $this->page->path_to_object( $objectid );
+ }
+
+ break;
+
+
+ case 'copy':
+
+ list($linkElementName,$targetElementName) = explode('%',$this->element->name.'%');
+
+ if ( empty($targetElementName) )
+ break;
+
+ $element = new Element();
+ $element->name = $linkElementName;
+ $element->load();
+
+ if ( intval($element->elementid)==0 )
+ break;
+
+ $linkValue = new Value();
+ $linkValue->elementid = $element->elementid;
+ $linkValue->element = $element;
+ $linkValue->pageid = $this->pageid;
+ $linkValue->page = $this->page;
+ $linkValue->simple = $this->simple;
+ $linkValue->languageid = $this->languageid;
+ $linkValue->load();
+
+ if ( !Object::available( $linkValue->linkToObjectId ) )
+ break;
+
+ $linkedPage = new Page( $linkValue->linkToObjectId );
+ $linkedPage->load();
+
+ $linkedPageTemplate = new Template( $linkedPage->templateid );
+ $targetElementId = array_search( $targetElementName, $linkedPageTemplate->getElementNames() );
+
+ if ( intval($targetElementId)==0 )
+ break;
+
+ $targetValue = new Value();
+ $targetValue->elementid = $targetElementId;
+ $targetValue->element = new Element($targetElementId);
+ $targetValue->element->load();
+ $targetValue->pageid = $linkedPage->pageid;
+ $targetValue->page = $linkedPage;
+ $targetValue->simple = $this->simple;
+ $targetValue->generate();
+
+ $inhalt = $targetValue->value;
+
+ break;
+
+
+ case 'linkinfo':
+
+ @list( $linkElementName, $name ) = explode('%',$this->element->name);
+ if ( is_null($name) )
+ break;
+
+ $template = new Template( $this->page->templateid );
+ $elementId = array_search( $linkElementName, $template->getElementNames() );
+
+
+ $element = new Element($elementId);
+ $element->load();
+
+ $linkValue = new Value();
+ $linkValue->elementid = $element->elementid;
+ $linkValue->element = $element;
+ $linkValue->pageid = $this->pageid;
+ $linkValue->languageid = $this->languageid;
+ $linkValue->load();
+
+ $objectid = $linkValue->linkToObjectId;
+
+ if ( intval($objectid) == 0 )
+ $objectid = $linkValue->element->defaultObjectId;
+
+ if ( !Object::available( $objectid ) )
+ break;
+
+ $linkedObject = new Object( $objectid );
+ $linkedObject->languageid = $this->languageid;
+ $linkedObject->load();
+
+ switch( $this->element->subtype )
+ {
+ case 'width':
+ $f = new File( $objectid );
+ $f->load();
+ if ( $f->isImage() )
+ {
+ $f->getImageSize();
+ $inhalt = $f->width;
+ }
+ unset($f);
+ break;
+
+ case 'height':
+ $f = new File( $objectid );
+ $f->load();
+ if ( $f->isImage() )
+ {
+ $f->getImageSize();
+ $inhalt = $f->height;
+ }
+ unset($f);
+ break;
+
+ case 'id':
+ $inhalt = $objectid;
+ break;
+
+ case 'name':
+ $inhalt = $linkedObject->name;
+ break;
+
+ case 'description':
+ $inhalt = $linkedObject->description;
+ break;
+
+ case 'create_user_desc':
+ $user = $linkedObject->createUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->desc;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'create_user_fullname':
+ $user = $linkedObject->createUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->fullname;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'create_user_mail':
+ $user = $linkedObject->createUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->mail;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'create_user_tel':
+ $user = $linkedObject->createUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->tel;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'create_user_username':
+ $user = $linkedObject->createUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->name;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'lastch_user_desc':
+ $user = $linkedObject->lastchangeUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->desc;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'lastch_user_fullname':
+ $user = $linkedObject->lastchangeUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->fullname;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'lastch_user_mail':
+ $user = $linkedObject->lastchangeUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->mail;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'lastch_user_tel':
+ $user = $linkedObject->lastchangeUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->tel;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+
+ break;
+
+ case 'lastch_user_username':
+ $user = $linkedObject->lastchangeUser;
+ try
+ {
+ $user->load();
+ $inhalt = $user->name;
+ }
+ catch( ObjectNotFoundException $e )
+ {
+ }
+ break;
+
+ case 'mime-type':
+ if ( $linkedObject->isFile )
+ {
+ $f = new File( $objectid );
+ $f->load();
+ $inhalt = $f->mimeType();
+ unset($f);
+ }
+ break;
+
+ case 'filename':
+ $inhalt = $linkedObject->filename();
+ break;
+
+ case 'full_filename':
+ $inhalt = $linkedObject->full_filename();
+ break;
+
+ default:
+ $inhalt = '';
+ Logger::error('subtype for linkinfo not implemented:'.$this->element->subtype);
+ }
+
+ break;
+
+ case 'linkdate':
+
+ @list( $linkElementName, $name ) = explode('%',$this->element->name);
+ if ( is_null($name) )
+ break;
+
+ $template = new Template( $this->page->templateid );
+ $elementId = array_search( $linkElementName, $template->getElementNames() );
+
+ $element = new Element($elementId);
+ $element->load();
+
+ $linkValue = new Value();
+ $linkValue->elementid = $element->elementid;
+ $linkValue->element = $element;
+ $linkValue->pageid = $this->pageid;
+ $linkValue->languageid = $this->languageid;
+ $linkValue->load();
+
+ $objectid = $linkValue->linkToObjectId;
+
+ if ( intval($objectid) == 0 )
+ $objectid = $linkValue->element->defaultObjectId;
+
+ if ( !Object::available( $objectid ) )
+ break;
+
+ $linkedObject = new Object( $objectid );
+ $linkedObject->load();
+
+
+ switch( $this->element->subtype )
+ {
+ case 'date_published':
+ // START_TIME wird zu Beginn im Controller gesetzt.
+ // So erh�lt jede Datei das gleiche Ver�ffentlichungsdatum.
+ $date = START_TIME;
+ break;
+
+ case 'date_saved':
+ $date = $linkedObject->lastchangeDate;
+ break;
+
+ case 'date_created':
+ $date = $linkedObject->createDate;
+ break;
+
+ default:
+ Logger::warn('element:'.$this->element->name.', '.
+ 'type:'.$this->element->type.', '.
+ 'unknown subtype:'.$this->element->subtype);
+ $date = START_TIME;
+ }
+
+ if ( strpos($this->element->dateformat,'%')!==FALSE )
+ $inhalt = strftime( $this->element->dateformat,$date );
+ else
+ $inhalt = date ( $this->element->dateformat,$date );
+ break;
+
+ case 'longtext':
+ case 'text':
+ case 'select':
+
+ $inhalt = $this->text;
+
+ // Wenn Inhalt leer, dann versuchen, den Inhalt der Default-Sprache zu laden.
+ if ( $inhalt == '' && $conf['content']['language']['use_default_language'] )
+ {
+ $project = \Session::getProject();
+ $this->languageid = $project->getDefaultLanguageId();
+ $this->load();
+ $inhalt = $this->text;
+ }
+
+ // Wenn Inhalt leer, dann Vorbelegung verwenden
+ if ( $inhalt == '' )
+ $inhalt = $this->element->defaultText;
+
+ // Wenn HTML nicht erlaubt und Wiki-Formatierung aktiv, dann einfache HTML-Tags in Wiki umwandeln
+ if ( !$this->element->html && $this->element->wiki && $conf['editor']['wiki']['convert_html'] && $this->page->mimeType()=='text/html' )
+ $inhalt = Text::html2Wiki( $inhalt );
+
+ // Wenn Wiki-Formatierung aktiv, dann BB-Code umwandeln
+ if ( $this->element->wiki && $conf['editor']['wiki']['convert_bbcode'] )
+ $inhalt = Text::bbCode2Wiki( $inhalt );
+
+ // Wenn HTML nicht erlaubt ist, dann die HTML-Tags ersetzen
+ if ( !$this->element->html && !$this->element->wiki && $this->page->mimeType()=='text/html')
+ $inhalt = Text::encodeHtml( $inhalt );
+
+ // Wenn HTML nicht erlaubt ist, dann Sonderzeichen in HTML �bersetzen
+ if ( !$this->element->wiki && !$this->element->wiki && $this->page->mimeType()=='text/html' )
+ $inhalt = Text::encodeHtmlSpecialChars( $inhalt );
+
+ // Schnellformatierung ('Wiki') durchfuehren
+ if ( $this->element->wiki )
+ {
+ $transformer = new Transformer();
+ $transformer->text = $inhalt;
+ $transformer->page = $this->page;
+ $transformer->element = $this->element;
+
+ $transformer->transform();
+ $inhalt = $transformer->text;
+ }
+
+ if ( $this->page->simple )
+ {
+ $inhalt = strip_tags( $inhalt );
+ $inhalt = str_replace( "\n",'',$inhalt );
+ $inhalt = str_replace( "\r",'',$inhalt );
+ }
+
+ // "__OID__nnn__" ersetzen durch einen richtigen Link
+ foreach( Text::parseOID($inhalt) as $oid=>$t )
+ {
+ $url = $this->page->path_to_object($oid);
+ $inhalt = str_replace($t,'"'.$url.'"',$inhalt);
+ }
+
+ break;
+
+
+ // Zahl
+ //
+ // wird im entsprechenden Format angezeigt.
+ case 'number':
+
+ if ( $this->number == 0 )
+ {
+ // Zahl ist gleich 0, dann Default-Text
+ $inhalt = $this->element->defaultText;
+ break;
+ }
+
+ $number = $this->number / pow(10,$this->element->decimals);
+ $inhalt = number_format( $number,$this->element->decimals,$this->element->decPoint,$this->element->thousandSep );
+
+ break;
+
+
+ // Datum
+ case 'date':
+
+ $date = $this->date;
+
+ if ( intval($date) == 0 )
+ {
+ // Datum wurde noch nicht eingegeben
+ $inhalt = $this->element->defaultText;
+ break;
+ }
+
+ // Datum gemaess Elementeinstellung formatieren
+ if ( strpos($this->element->dateformat,'%')!==FALSE )
+ $inhalt = strftime( $this->element->dateformat,$date );
+ else
+ $inhalt = date ( $this->element->dateformat,$date );
+ break;
+
+
+ // Programmcode (PHP)
+ case 'code':
+
+ if ( $this->page->simple )
+ break;
+
+ // Die Ausführung von benutzer-erzeugtem PHP-Code kann in der
+ // Konfiguration aus Sicherheitsgründen deaktiviert sein.
+ if ( $conf['security']['disable_dynamic_code'] )
+ break;
+
+ $this->page->load();
+
+ // Das Ausführen geschieht über die Klasse "Code".
+ // In dieser wird der Code in eine Datei geschrieben und
+ // von dort eingebunden.
+ $code = new Code();
+ $code->page = &$this->page;
+ $code->setObjectId( $this->page->objectid );
+ $code->delOutput();
+ $code->code = $this->element->code;
+
+ // Jetzt ausfuehren des temporaeren PHP-Codes
+ $code->execute();
+
+ // Ausgabe ermitteln.
+ $inhalt = $code->getOutput();
+
+ break;
+
+
+ // Makros (dynamische Klassen)
+ case 'dynamic':
+
+ if ( $this->page->simple )
+ break;
+
+ $this->page->load();
+ $className = $this->element->subtype;
+ $fileName = OR_DYNAMICCLASSES_DIR.$className.'.class.php';
+ if ( is_file( $fileName ) )
+ {
+ // Fuer den Fall, dass ein Makro mehrmals pro Vorlage auftritt
+ if ( !class_exists($className) )
+ require( $fileName );
+
+ if ( class_exists($className) )
+ {
+ $macro = new $className;
+ $macro->page = &$this->page;
+
+ if ( method_exists( $macro,'execute' ) )
+ {
+ //$$macro->delOutput();
+ $macro->objectid = $this->page->objectid;
+ $macro->page = &$this->page;
+
+ foreach( $this->element->getDynamicParameters() as $param_name=>$param_value )
+ {
+ if ( $param_value[0]=='{')
+ {
+ $elName = substr($param_value,1,strpos($param_value,'}')-1);
+ $template = new Template($this->page->templateid);
+ $elements = $template->getElementNames();
+ $elementid = array_search($elName,$elements);
+
+ $value = new Value();
+ $value->elementid = $elementid;
+ $value->element = new Element( $elementid );
+ $value->element->load();
+ $value->pageid = $this->page->pageid;
+ $value->languageid = $this->page->languageid;
+ $value->load();
+
+ $param_value = $value->getRawValue();
+ }
+ if ( isset( $macro->$param_name ) )
+ {
+ Logger::debug("Setting parameter for Macro-class $className, ".$param_name.':'.$param_value );
+
+ // Die Parameter der Makro-Klasse typisiert setzen.
+ if ( is_int($macro->$param_name) )
+ $macro->$param_name = intval($param_value);
+ elseif ( is_array($macro->$param_name) )
+ $macro->$param_name = explode(',',$param_value);
+ else
+ $macro->$param_name = $param_value;
+
+ }
+ else
+ {
+ if ( !$this->publish )
+ $inhalt .= "WARNING: Unknown parameter $param_name in macro $className\n";
+ }
+ }
+
+ $macro->execute();
+ $inhalt .= $macro->getOutput();
+ }
+ else
+ {
+ Logger::warn('element:'.$this->element->name.', '.
+ 'class:'.$className.', no method: execute()');
+ if ( !$this->publish )
+ $inhalt = lang('ERROR_IN_ELEMENT').' (missing method: execute())';
+ }
+ }
+ else
+ {
+ Logger::warn('element:'.$this->element->name.', '.
+ 'class not found:'.$className);
+ if ( !$this->publish )
+ $inhalt = lang('ERROR_IN_ELEMENT').' (class not found:'.$className.')';
+ }
+ }
+ else
+ {
+ Logger::warn('element:'.$this->element->name.', '.
+ 'file not found:'.$fileName);
+ if ( !$this->publish )
+ $inhalt = lang('ERROR_IN_ELEMENT').' (file not found:'.$fileName.')';
+
+ }
+
+ // Wenn HTML-Ausgabe, dann Sonderzeichen in HTML �bersetzen
+ if ( $this->page->isHtml() )
+ $inhalt = Text::encodeHtmlSpecialChars( $inhalt );
+
+ break;
+
+
+ // Info-Feld als Datum
+ case 'infodate':
+
+ if ( $this->page->simple )
+ break;
+
+ switch( $this->element->subtype )
+ {
+ case 'date_published':
+ // START_TIME wird zu Beginn im Controller gesetzt.
+ // So erh�lt jede Datei das gleiche Ver�ffentlichungsdatum.
+ $date = START_TIME;
+ break;
+
+ case 'date_saved':
+ $date = $this->page->lastchangeDate;
+ break;
+
+ case 'date_created':
+ $date = $this->page->createDate;
+ break;
+
+ default:
+ Logger::warn('element:'.$this->element->name.', '.
+ 'type:'.$this->element->type.', '.
+ 'unknown subtype:'.$this->element->subtype);
+ if ( !$this->publish )
+ $inhalt = lang('ERROR_IN_ELEMENT');
+ }
+
+ if ( strpos($this->element->dateformat,'%')!==FALSE )
+ $inhalt = strftime( $this->element->dateformat,$date );
+ else
+ $inhalt = date ( $this->element->dateformat,$date );
+
+ break;
+
+
+ // Info-Feld
+ case 'info':
+
+ if ( $this->page->simple )
+ break;
+
+ switch( $this->element->subtype )
+ {
+ case 'db_id':
+ $inhalt = $SESS['dbid'];
+ break;
+ case 'db_name':
+ $inhalt = $conf['database_'.$SESS['dbid']]['description'];
+ break;
+ case 'project_id':
+ $inhalt = $this->page->projectid;
+ break;
+ case 'project_name':
+ $project = new Project( $this->page->projectid );
+ $project->load();
+ $inhalt = $project->name;
+ break;
+ case 'language_id':
+ $inhalt = $this->page->languageid;
+ break;
+ case 'language_iso':
+ $language = new Language( $this->page->languageid );
+ $language->load();
+ $inhalt = $language->isoCode;
+ break;
+ case 'language_name':
+ $language = new Language( $this->page->languageid );
+ $language->load();
+ $inhalt = $language->name;
+ break;
+ case 'page_id':
+ $inhalt = $this->page->objectid;
+ break;
+ case 'page_name':
+ $inhalt = $this->page->name;
+ break;
+ case 'page_desc':
+ $inhalt = $this->page->desc;
+ break;
+ case 'page_fullfilename':
+ $inhalt = $this->page->full_filename();
+ break;
+ case 'page_filename':
+ $inhalt = $this->page->filename();
+ break;
+ case 'page_extension':
+ $inhalt = '';
+ break;
+ case 'edit_url':
+ $raw = true;
+ $db = \Session::getDatabase();
+ $inhalt = Html::url('index','object',$this->page->objectid,array('dbid'=>$db->id));
+ break;
+ case 'edit_fullurl':
+ $raw = true;
+ $inhalt = Http::getServer();
+ $db = \Session::getDatabase();
+ $params = array('dbid' =>$db->id,
+ 'objectid' =>$this->page->objectid,
+ 'modelid' =>$this->page->modelid,
+ 'languageid'=>$this->page->languageid,
+ 'elementid' =>$this->element->elementid );
+ $inhalt .= '/'.basename(Html::url('index','object',$this->page->objectid,$params));
+ break;
+ case 'lastch_user_username':
+ $user = $this->page->lastchangeUser;
+ $user->load();
+ $inhalt = $user->name;
+ break;
+ case 'lastch_user_fullname':
+ $user = $this->page->lastchangeUser;
+ $user->load();
+ $inhalt = $user->fullname;
+ break;
+ case 'lastch_user_mail':
+ $user = $this->page->lastchangeUser;
+ $user->load();
+ $inhalt = $user->mail;
+ break;
+ case 'lastch_user_desc':
+ $user = $this->page->lastchangeUser;
+ $user->load();
+ $inhalt = $user->desc;
+ break;
+ case 'lastch_user_tel':
+ $user = $this->page->lastchangeUser;
+ $user->load();
+ $inhalt = $user->tel;
+ break;
+
+ case 'create_user_username':
+ $user = $this->page->createUser;
+ $user->load();
+ $inhalt = $user->name;
+ break;
+ case 'create_user_fullname':
+ $user = $this->page->createUser;
+ $user->load();
+ $inhalt = $user->fullname;
+ break;
+ case 'create_user_mail':
+ $user = $this->page->createUser;
+ $user->load();
+ $inhalt = $user->mail;
+ break;
+ case 'create_user_desc':
+ $user = $this->page->createUser;
+ $user->load();
+ $inhalt = $user->desc;
+ break;
+ case 'create_user_tel':
+ $user = $this->page->createUser;
+ $user->load();
+ $inhalt = $user->tel;
+ break;
+
+ case 'act_user_username':
+ $user = new User($SESS['user']['id']);
+ $user->load();
+ $inhalt = $user->name;
+ break;
+ case 'act_user_fullname':
+ $user = new User($SESS['user']['id']);
+ $user->load();
+ $inhalt = $user->fullname;
+ break;
+ case 'act_user_mail':
+ $user = new User($SESS['user']['id']);
+ $user->load();
+ $inhalt = $user->mail;
+ break;
+ case 'act_user_desc':
+ $user = new User($SESS['user']['id']);
+ $user->load();
+ $inhalt = $user->desc;
+ break;
+ case 'act_user_tel':
+ $user = new User($SESS['user']['id']);
+ $user->load();
+ $inhalt = $user->tel;
+ break;
+ default:
+ Logger::warn('element:'.$this->element->name.', '.
+ 'type:'.$this->element->type.', '.
+ 'unknown subtype:'.$this->element->subtype);
+ // Keine Fehlermeldung in erzeugte Seite schreiben.
+ }
+
+ break;
+
+ default:
+ // Unbekannte Elementtypen darf es nicht geben, daher ERROR loggen.
+ Logger::error('element:'.$this->element->name.', '.
+ 'unknown type:'.$this->element->type);
+
+ if ( !$this->publish )
+ $inhalt = lang('ERROR_IN_ELEMENT').' ('.$this->element->name.':'.
+ 'unknown type:'.$this->element->type.')';
+
+ }
+
+
+ switch( $this->element->type )
+ {
+ case 'longtext':
+ case 'text':
+ case 'select':
+
+ if ( $conf['publish']['encode_utf8_in_html'] )
+ // Wenn HTML-Ausgabe, dann UTF-8-Zeichen als HTML-Code uebersetzen
+ if ( $this->page->isHtml() )
+ $inhalt = translateutf8tohtml($inhalt);
+ break;
+
+ default:
+ }
+
+
+
+ if ( $this->page->icons && $this->element->withIcon && $this->page->isHtml() )
+ {
+ // Anklickbaren Link voranstellen.
+ $iconLink = '<a href="javascript:parent.openNewAction(\''.$this->element->name.'\',\'pageelement\',\''.$this->page->objectid.'_'.$this->element->elementid.'\');" title="'.$this->element->desc.'"><img src="'.OR_THEMES_EXT_DIR.$conf['interface']['theme'].'/images/icon_el_'.$this->element->type.IMG_ICON_EXT.'" border="0" align="left"></a>';
+ $inhalt = $iconLink.$inhalt;
+ }
+
+ $this->value = $inhalt;
+
+
+ // Store in cache.
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->value );
+ fclose( $f );
+ }
+
+
+ /**
+ * Es werden Objekte mit einem Inhalt gesucht.
+ * @param String Suchbegriff
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByValue( $text )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{object}}.id FROM {{value}} '.
+ ' LEFT JOIN {{page}} '.
+ ' ON {{page}}.id={{value}}.pageid '.
+ ' LEFT JOIN {{object}} '.
+ ' ON {{object}}.id={{page}}.objectid '.
+ ' WHERE {{value}}.text LIKE {text}'.
+ ' AND {{value}}.languageid={languageid}'.
+ ' ORDER BY {{object}}.lastchange_date DESC' );
+
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setString( 'text' ,'%'.$text.'%' );
+ return $sql->getCol();
+ }
+
+
+ /**
+ * Es werden Objekte mit einer UserId ermittelt
+ * @param Integer Benutzer-Id der letzten ?nderung
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByLastChangeUserId( $userid )
+ {
+
+ $db = db_connection();
+
+ $sql = $db->sql( 'SELECT {{object}}.id FROM {{value}} '.
+ ' LEFT JOIN {{page}} '.
+ ' ON {{page}}.id={{value}}.pageid '.
+ ' LEFT JOIN {{object}} '.
+ ' ON {{object}}.id={{page}}.objectid '.
+ ' WHERE {{value}}.lastchange_userid={userid}'.
+ ' AND {{value}}.languageid={languageid}'.
+ ' ORDER BY {{object}}.lastchange_date DESC' );
+ $sql->setInt ( 'languageid',$this->languageid );
+ $sql->setInt ( 'userid' ,$userid );
+
+ return $sql->getCol();
+ }
+
+
+
+ /**
+ * Es wird das Objekt ermittelt, welches der Benutzer zuletzt ge�ndert hat.
+ *
+ * @return Integer Objekt-Id
+ */
+ public static function getLastChangedObjectByUserId( $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+SELECT {{object}}.id
+ FROM {{value}}
+ LEFT JOIN {{page}}
+ ON {{page}}.id={{value}}.pageid
+ LEFT JOIN {{object}}
+ ON {{object}}.id={{page}}.objectid
+ WHERE {{value}}.lastchange_userid={userid}
+ ORDER BY {{value}}.lastchange_date DESC
+SQL
+);
+ $sql->setInt ( 'userid' ,$userid );
+ return $sql->getOne();
+ }
+
+
+ /**
+ * Es wird das Objekt ermittelt, welches der Benutzer zuletzt ge�ndert hat.
+ *
+ * @return Integer Objekt-Id
+ */
+ public static function getLastChangedObjectInProjectByUserId( $projectid, $userid )
+ {
+ $db = db_connection();
+
+ $sql = $db->sql( <<<SQL
+SELECT {{object}}.id
+ FROM {{value}}
+ LEFT JOIN {{page}}
+ ON {{page}}.id={{value}}.pageid
+ LEFT JOIN {{object}}
+ ON {{object}}.id={{page}}.objectid
+ WHERE {{value}}.lastchange_userid={userid}
+ AND {{object}}.projectid = {projectid}
+ ORDER BY {{value}}.lastchange_date DESC
+SQL
+);
+ $sql->setInt ( 'userid' ,$userid );
+ $sql->setInt ( 'projectid' ,$projectid );
+ return $sql->getOne();
+ }
+
+
+ /**
+ * Ermittelt einen tempor�ren Dateinamen f�r diesen Inhalt.
+ */
+ function tmpfile()
+ {
+ $db = db_connection();
+ $filename = Object::getTempFileName( array('db'=>$db->id,
+ 'va'=>$this->valueid,
+ 'el'=>$this->element->elementid,
+ 'la'=>$this->languageid,
+ 'm' =>$this->page->modelid,
+ 'pu'=>intval($this->publish),
+ 'si'=>intval($this->page->simple) ) );
+ return $filename;
+ }
+
+
+
+ /**
+ * Ermittelt den unbearbeiteten, "rohen" Inhalt.
+ *
+ * @return Inhalt
+ */
+ public function getRawValue()
+ {
+ switch( $this->element->type )
+ {
+ case 'link':
+ return $this->linkToObjectId;
+
+ case 'date';
+ return $this->date;
+
+ default:
+ return $this->text;
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-core/model/include.inc.php b/modules/cms-core/model/include.inc.php
@@ -0,0 +1,22 @@
+<?php
+namespace cms\model;
+
+// Diese Objekte stehen zeitweise in der Sitzung, daher muessen dieser immer geparst werden.
+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/cms-macros/macro/Album.class.php b/modules/cms-macros/macro/Album.class.php
@@ -0,0 +1,92 @@
+<?php
+// 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.
+use cms\model\File;
+use cms\model\Folder;
+
+
+/**
+ * Erzeugt eine Bilder-Liste.
+ *
+ * Die Ordner-Id kann als Parameter "folderid" übergeben werden.
+ * Falls nicht, wird der aktuelle Ordner, in dem sich die Seite
+ * befindet, benutzt.
+ *
+ * Es wird eine Definitionsliste mit der CSS-Klasse "album" erzeugt, damit
+ * bequem eine Auszeichnung per CSS erfolgen kann.
+ *
+ * Beispiel:
+ * <dl class="album">
+ * <dt><img src="bild.jpg" width=".." .. /></dt>
+ * <dd>Beschreibung</dd>
+ * </dl>
+ *
+ * @author Jan Dankert
+ */
+class Album extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'folderid'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates an album.';
+
+ var $folderid = 0;
+
+ /**
+ */
+ function execute()
+ {
+ if ( intval($this->folderid)!=0 )
+ $folderid = $this->folderid;
+ else
+ $folderid = $this->page->parentid;
+
+ $f = new Folder($folderid);
+
+ $files = $f->getFiles();
+
+ $this->output('<dl class="album">');
+
+ foreach( $files as $fileid )
+ {
+ $file = new File($fileid);
+ $file->load();
+
+ if ( $file->isImage() )
+ {
+ $file->getImageSize();
+ $img = '<img src="'.$this->pathToObject($fileid).'" alt="'.$file->name.'" width="'.$file->width.'" height="'.$file->height.'" />';
+ $this->output('<dt>'.$img.'</dt><dd>'.$file->desc.'</dd>');
+ }
+
+ }
+
+ $this->output('</dl>');
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/Atom.class.php b/modules/cms-macros/macro/Atom.class.php
@@ -0,0 +1,141 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\Page;
+
+
+/**
+ * Erstellen eines ATOM-Feeds
+ * @author Jan Dankert
+ */
+class Atom extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'folderid' =>'Id of the folder whose pages should go into the Atom-Feed, default: the root folder',
+ 'feed_url' =>'Url of the feed, default: blank',
+ 'feed_title' =>'Title of the feed, default: Name of folder',
+ 'feed_description'=>'Description of the feed, default: Description of folder'
+ );
+
+ var $folderid = 0;
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates an Atom-Feed of pages in a folder';
+ var $api;
+
+ var $feed_url = '';
+ var $feed_title = '';
+ var $feed_description = '';
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ $feed = array();
+
+ // Lesen des Root-Ordners
+ if ( intval($this->folderid) == 0 )
+ $folder = new Folder( $this->getRootObjectId() );
+ else
+ $folder = new Folder( intval($this->folderid) );
+
+ $folder->load();
+
+ if ( $this->feed_title == '' )
+ $this->feed_title = $folder->name;
+
+ if ( $this->feed_description == '' )
+ $this->feed_description = $folder->desc;
+
+ $feed['title' ] = $this->feed_title;
+ $feed['description'] = $this->feed_description;
+ $feed['url' ] = $this->feed_url;
+ $feed['items' ] = array();
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjectIds() as $id )
+ {
+ if ( $id == $this->getObjectId() )
+ continue;
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+ if ( $o->isPage ) // Nur wenn Seite
+ {
+ $p = new Page( $id );
+ $p->load();
+
+ $item = array();
+ $item['title' ] = $p->name;
+ $item['description'] = $p->desc;
+ $item['date' ] = $p->lastchangeDate;
+ if ( empty($this->feed_url) )
+ $item['link' ] = $this->pathToObject($id);
+ else
+ $item['link' ] = $this->feed_url;
+
+ $feed['items'][] = $item;
+ }
+ }
+
+ $feed = $this->atomFeed($feed);
+
+ $this->output( $feed );
+ }
+
+
+ function atomFeed($input, $stylesheet='')
+ {
+ $input["encoding"] = (empty($input["encoding"] ))?"UTF-8":$input["encoding"];
+ $input["language"] = (empty($input["language"] ))?"en-us":$input["language"];
+
+ if ( empty($input['title' ])) $input['title' ] = '';
+ if ( empty($input['description'])) $input['description'] = '';
+ if ( empty($input['link' ])) $input['link' ] = '';
+ $feed = '<?xml version="1.0" encoding="'.$input["encoding"].'"?>';
+ $feed .= (!empty($stylesheet))?"\n".'<?xml-stylesheet type="text/xsl" href="'.$stylesheet.'"?>':"";
+ $feed .= <<<__RSS__
+
+ <feed xmlns="http://www.w3.org/2005/Atom">
+ <title>{$input["title"]}</title>
+
+__RSS__;
+ foreach($input["items"] as $item)
+ {
+ if ( empty($item['title' ])) $item['title' ] = '';
+ if ( empty($item['description'])) $item['description'] = '';
+ $feed .= "\n<entry>\n<title>".$item["title"]."</title>";
+ $feed .= "\n<summary><![CDATA[".$item["description"]."]]></summary>";
+ $feed .= "\n<updated>".date('Y-m-d\TH:i:s\Z', $item["date"])."</updated>";
+ $feed .= "\n<link href=\"".$item["link"]."\" />";
+ $feed .= "\n</entry>\n";
+ }
+ $feed .= "\n</feed>";
+ return $feed;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/BlockMenu.class.php b/modules/cms-macros/macro/BlockMenu.class.php
@@ -0,0 +1,137 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2004-12-25 21:05:14 dankert
+// erbt von Klasse Dynamic
+//
+// Revision 1.1 2004/10/14 21:16:12 dankert
+// Erzeugen eines Menues in Bloecken
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Object;
+
+
+/**
+ * Erstellen eines Hauptmenues
+ * @author Jan Dankert
+ */
+class BlockMenu extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between menu entries, default: "·"'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+ var $version = '$Id$';
+ var $api;
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ // Erstellen des Hauptmenues
+
+ // Lesen des Root-Ordners
+ $folder = new Folder( $this->getRootObjectId() );
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+ if ( $o->isFolder ) // Nur wenn Ordner
+ {
+ $f = new Folder( $id );
+
+ // Ermitteln eines Objektes mit dem Dateinamen index
+ $oid = $f->getObjectIdByFileName('index');
+
+ if ( count($f->getLinks())+count($f->getPages()) > 0 )
+ {
+ $this->output( '
+ <!-- sidebox -->
+ <table bgcolor="#000000" border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td>
+ <table border="0" cellpadding="3" cellspacing="1" width="100%">
+ <tr>
+ <td bgcolor="#cccccc"><span class="title"> '.$o->name.'</span></a>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#ffffff">
+ ');
+ // Untermenue
+ // Schleife ber alle Objekte im aktuellen Ordner
+ foreach( $f->getObjectIds() as $xid )
+ {
+ $o = new Object( $xid );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+
+ // Nur Seiten anzeigen
+ if (!$o->isPage && !$o->isLink ) continue;
+
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->getObjectId() == $xid )
+ {
+ // aktuelle Seite
+ $this->output( ' <span class="small">o</span>
+ <strong class="nav">'.$o->name.'</strong>
+ <br />' );
+ }
+ else
+ {
+ $this->output( ' <span class="small">o</span>
+ <a class="nav" href="'.$this->page->path_to_object($xid).'">'.$o->name.'</a>
+ <br />' );
+ }
+ //Api::output( '<br/>' );
+ }
+
+ $this->output( '
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <!-- end sidebox -->
+ <br />
+ ' );
+ }
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/BreadCrumb.class.php b/modules/cms-macros/macro/BreadCrumb.class.php
@@ -0,0 +1,103 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.3 2007-11-30 23:25:25 dankert
+// Das Men? in der Sprache der zu ver?ffentlichenden Seite erzeugen.
+//
+// Revision 1.2 2005/01/04 19:59:55 dankert
+// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+
+
+/**
+ * Erstellen einer sog. Brotkruemel-Navigation
+ * @author Jan Dankert
+ */
+class BreadCrumb extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'beforeEntry'=>'Chars before an active menu entry'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+
+
+ /**
+ * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
+ */
+ var $beforeEntry = '»';
+
+ var $api;
+
+ /**
+ * Erstellen einer BreadCrumb-Navigation.
+ */
+ function execute()
+ {
+ // Erstellen eines Untermenues
+
+ // Ermitteln der aktuellen Seite
+ $f = new Folder($this->page->parentid);
+ $parentIds = $f->parentObjectFileNames(false,true);
+ $lastoid = 0;
+
+ foreach( $parentIds as $oid=>$filename )
+ {
+ $of = new Folder($oid);
+ $of->languageid = $this->page->languageid;
+ $of->load();
+ $pl = $of->getFirstPageOrLink();
+
+ $this->output( $this->beforeEntry );
+
+ if ( is_object($pl) && $pl->objectid != $this->page->objectid )
+ $this->output('<a href="'.$this->pathToObject($pl->objectid).'" class="breadcrumb">'.$of->name.'</a>' );
+ else
+ $this->output('<span class="breadcrumb">'.$of->name.'</span>' );
+
+ if ( is_object($pl) )
+ $lastoid = $pl->objectid;
+ }
+
+ if ( $lastoid != $this->page->objectid )
+ {
+ $this->output( $this->beforeEntry );
+ $this->output('<span class="breadcrumb">'.$this->page->name.'</span>' );
+ }
+
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/CSVTable.class.php b/modules/cms-macros/macro/CSVTable.class.php
@@ -0,0 +1,85 @@
+<?php
+// 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.
+use cms\model\File;
+
+
+/**
+ * Aus einer CSV-Datei wird eine HTML-Tabelle erstellt.
+ *
+ * @author Jan Dankert
+ */
+class CSVList extends Macro
+{
+ /**
+ * Id der Datei, welche die Werte enthält.
+ * @var unknown_type
+ */
+ var $fileid = 0;
+
+ /**
+ * CSS-Klasse der Tabelle.
+ * @var unknown_type
+ */
+ var $css_class = 'table';
+
+ /**
+ * Trennzeichen (Default: Komma).
+ * @var unknown_type
+ */
+ var $seperator = ',';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a HTML-table from a CSV-file';
+
+
+
+ function execute()
+ {
+ $this->output('<table class="'.$this->css_class.'">');
+
+ // Datei lesen
+ $file = new File( $this->fileid );
+ $values = $file->loadValue();
+
+ // In einzelne Zeilen zerlegen.
+ $lines = explode("\n",$values);
+
+ foreach( $lines as $line )
+ {
+ $this->output('<tr>');
+
+ // In einzelne Spalten zerlegen.
+ $columns = explode($seperator,$line);
+ foreach( $columns as $column )
+ {
+ $this->output('<td>' );
+ $this->output($column);
+ $this->output('</td>');
+ }
+ $this->output('</tr>');
+ }
+
+ $this->output('</table>');
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/ClassicMenu.class.php b/modules/cms-macros/macro/ClassicMenu.class.php
@@ -0,0 +1,117 @@
+<?php
+// 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.
+use cms\model\Folder;
+use cms\model\Page;
+
+
+/**
+ * Erstellen eines Menues
+ * @author Jan Dankert
+ */
+class ClassicMenu extends Macro
+{
+ /**
+ * Beschreibung dieser Klasse
+ * @type String
+ */
+ var $description = 'This is a dynamic Menue which contains all pages. Folders are opened when useful. Nice standard menu :-)';
+
+
+ /**
+ * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
+ */
+ var $css_class = 'macro-classicmenu';
+ var $onlySameTemplate = true;
+
+
+ // Erstellen des Hauptmenues
+ public function execute()
+ {
+ $rootId = $this->getRootObjectId();
+ // Erstellen eines Untermenues
+
+ $f = new Folder( $this->page->parentid );
+ $this->parentFolders = $f->parentObjectFileNames(false,true);
+
+ $this->showFolder( $rootId );
+ }
+
+ private function showFolder( $oid )
+ {
+ $this->outputLn('<ul class="'.$this->css_class.'">');
+ $f = new Folder( $oid );
+
+ // Schleife ueber alle Objekte im aktuellen Ordner
+ foreach( $f->getObjects() as $o )
+ {
+ $o->languageid = $this->page->languageid;
+ $o->load();
+
+ // Ordner anzeigen
+ if ($o->isFolder )
+ {
+ $nf = new Folder($o->objectid);
+ $fp = $nf->getFirstPageOrLink();
+
+ if ( is_object($fp) )
+ {
+
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->page->objectid == $fp->objectid )
+ // aktuelle Seite
+ $this->outputLn( '<li class="active">'.$o->name.'' );
+ else
+ // Link erzeugen
+ $this->outputLn( '<li><a href="'.$this->pathToObject($fp->objectid).'">'.$o->name.'</a>' );
+
+ if ( in_array($o->objectid,array_keys($this->parentFolders)) )
+ {
+ $this->showFolder($o->objectid);
+ }
+
+ $this->outputLn( '</li>' );
+ }
+ }
+
+ if ($o->isPage)
+ {
+ $page = new Page($o->objectid);
+ $page->load();
+ if ( $page->templateid != $this->page->templateid && $this->onlySameTemplate )
+ continue;
+ }
+
+ // Seiten und Verknuepfungen anzeigen
+ if ($o->isPage || $o->isLink )
+ {
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->getObjectId() == $o->objectid)
+ // aktuelle Seite
+ $this->output( '<li class="active">'.$o->name.'</li>' );
+ elseif ( $o->isLink )
+ // Link mit HTML-Sonderzeichenumwandlung erzeugen
+ $this->output( '<li><a href="'.htmlspecialchars($this->pathToObject($o->objectid)).'">'.$o->name.'</a></li>' );
+ else
+ // Link erzeugen
+ $this->output( '<li><a href="'.$this->pathToObject($o->objectid).'">'.$o->name.'</a></li>' );
+ }
+ }
+ $this->output('</ul>');
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/CommonMenu.class.php b/modules/cms-macros/macro/CommonMenu.class.php
@@ -0,0 +1,101 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.3 2004-12-19 22:35:23 dankert
+// Parameter -Angabe
+//
+// Revision 1.2 2004/12/19 15:19:29 dankert
+// Klasse erbt von "Dynamic"
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Page;
+
+
+/**
+ * Erstellen eines Menues
+ * @author Jan Dankert
+ */
+class CommonMenu extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'beforeEntry'=>'Chars before an active menu entry',
+ 'afterEntry' =>'Chars after an active menu entry'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+
+
+ /**
+ * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
+ */
+ var $beforeEntry = '<li><strong>';
+ var $afterEntry = '</strong></li>';
+
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ // Erstellen eines Untermenues
+
+ // Ermitteln der aktuellen Seite
+ $thispage = new Page( $this->getObjectId() );
+ $thispage->load(); // Seite laden
+
+ // uebergeordneter Ordner dieser Seite
+ $f = new Folder( $thispage->parentid );
+
+ // Schleife ueber alle Objekte im aktuellen Ordner
+ foreach( $f->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+
+ // Nur Seiten anzeigen
+ if (!$o->isPage && !$o->isLink ) continue;
+
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->getObjectId() == $id )
+ {
+ // aktuelle Seite
+ $this->output( '<li><strong>'.$o->name.'</strong></li>' );
+ }
+ else
+ {
+ // Link erzeugen
+ $this->output( '<li><a href="'.$this->page->path_to_object($id).'">'.$o->name.'</a></li>' );
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/DoiMenu.class.php b/modules/cms-macros/macro/DoiMenu.class.php
@@ -0,0 +1,132 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2005-01-04 20:31:52 dankert
+// Neues Menue
+//
+// Revision 1.1 2005/01/04 20:00:12 dankert
+// Darstellung eines DHTML-Menues
+//
+// Revision 1.2 2004/12/28 22:57:56 dankert
+// Korrektur Vererbung, "api" ausgebaut
+//
+// Revision 1.1 2004/10/14 21:15:29 dankert
+// Erzeugen und Anzeigen einer Sitemap
+//
+// ---------------------------------------------------------------------------
+use cms\model\File;
+use cms\model\Folder;
+use cms\model\Page;
+
+
+/**
+ * Erstellen eines DHTML-Menues (DoiMenu)
+ *
+ * Diese Klasse erzeugt Javascript-Code fuer das DoiMenu
+ *
+ * @see http://doimenu.sf.net for details
+ * @author Jan Dankert
+ */
+class DoiMenu extends Macro
+{
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'You *have to* include doiMenuDOM.js in the page!<br/>Put the code below in head section:<br/><tt><script type="text/javascript" src="{{your-elementname}}.js"></script></tt><br/>The file is distributed with OpenRat';
+
+
+ /**
+ * Parameter mit Objekt-Id
+ * Die Datei mit dieser Id enthaelt Parameter fuer das Menu
+ */
+ var $parameterFileId = 0;
+
+ /**
+ * Ausrichtung des Menues.
+ * available value : 'horizontal','vertical'.
+ */
+ var $direction = 'horizontal';
+
+
+ /**
+ * Erstellen des DHTML-Menues
+ */
+ function execute()
+ {
+ // Erstellen eines Untermenues
+
+ // Ermitteln der aktuellen Seite
+ $thispage = new Page( $this->getObjectId() );
+ $thispage->load(); // Seite laden
+
+ $this->outputLn('<script name="javascript" type="text/javascript">');
+
+ $this->outputLn(" var menu = new TMainMenu('menu','".$this->direction."');");
+
+ $ro = new Folder($this->getRootObjectId());
+ $this->showFolder( $ro );
+
+ if ( intval( $this->parameterFileId ) != 0 )
+ {
+ $f = new File( intval($this->parameterFileId) );
+ $this->outputLn( $f->loadValue() );
+ }
+
+ $this->outputLn( ' menu.Build()' );
+ $this->outputLn( '</script');
+ }
+
+
+ function showFolder( $fo )
+ {
+ if ( $fo->objectid == intval($this->getRootObjectId()) )
+ $parentMenu = 'menu';
+ else
+ $parentMenu = 'menu'.$fo->objectid;
+
+ foreach( $fo->getObjects() as $o )
+ {
+ $menu = 'menu'.$o->objectid;
+
+ if ( $o->isFolder )
+ { $nf = new Folder($o->objectid);
+ $pl = $nf->getFirstPageOrLink();
+ if ( is_object($pl) )
+ {
+ $this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($pl->objectid)."','".$o->desc."');");
+ $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
+ $this->showFolder( $nf );
+ }
+ }
+
+ if ( $o->isPage || $o->isPage )
+ {
+ $this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($o->objectid)."','".$o->desc."');");
+ $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
+ }
+ }
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/GoogleMaps.class.php b/modules/cms-macros/macro/GoogleMaps.class.php
@@ -0,0 +1,63 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+
+
+
+/**
+ * Bindet eine Google-Maps-Karte ein.
+ *
+ * @author Jan Dankert
+ */
+class GoogleMaps extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'lat' => 'Latitude',
+ 'long' => 'Longitude',
+ 'zoom' => 'Zoom'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Includes a Google Map.';
+
+ var $long = 10; // Default: Hamburg
+ var $lat = 53.55; // Default: Hamburg
+ var $zoom = 10;
+ var $width = 425;
+ var $height = 350;
+
+ /**
+ */
+ function execute()
+ {
+ $this->output('<iframe width="'.$this->width.'" height="'.$this->height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.de/?ie=UTF8&ll='.$this->lat.','.$this->long.'&z='.$this->zoom.'&output=embed"></iframe>');
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/LanguageLinksForPage.class.php b/modules/cms-macros/macro/LanguageLinksForPage.class.php
@@ -0,0 +1,72 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2012 Tobias Schöne tobias@schoenesnetz.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$
+// ---------------------------------------------------------------------------
+use cms\model\Language;
+
+/**
+ * Erstellen einer Liste von Language-Links auf die selbe Seite
+ * @author Tobias Schoene
+ */
+class LanguageLinksForPage extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between entries'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates language links to the page.';
+ var $version = '$Id$';
+ var $api;
+
+ // Build the navigation links to other languages
+ function execute()
+ {
+ // current language
+ $languageId = $this->page->languageid;
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( Language::getAll() as $lid=>$lname)
+ {
+
+ $l = new Language( $lid );
+ $l->load();
+ $this->page->languageid = $l->languageid;
+ $filename = $this->page->full_filename();
+ $filename = str_replace($this->page->path(),".",$filename);
+ $this->output( '<li><a href="'.$filename.'">'.strtolower($l->isoCode).'</a></li>' );
+
+ }
+ $this->page->languageid = $languageId;
+ }
+}
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/LastChanges.class.php b/modules/cms-macros/macro/LastChanges.class.php
@@ -0,0 +1,163 @@
+<?php
+// 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.
+use cms\model\Folder;
+use cms\model\Link;
+use cms\model\Page;
+
+
+/**
+ * Erstellen einer Teaser-Liste.
+ *
+ * @author Jan Dankert
+ */
+class LastChanges extends Macro
+{
+ var $title_html_tag = 'h3';
+ var $css_class = 'macro-lastchanges';
+ var $teaserElementId = '';
+ var $teaserMaxLength = 100;
+ var $plaintext = 'true';
+ var $linktitle = 'true';
+ var $linktext = 'true';
+ var $timeelementid = 0;
+ var $folderid = 0;
+ var $showPages = true;
+ var $showLinks = false;
+ var $includeTemplateIds = array();
+ var $excludeTemplateIds = array();
+ var $limit = -1;
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a teaser list of pages in a folder';
+
+ //
+ function execute()
+ {
+ $project = Session::getProject();
+
+ if ( $this->folderid === 'self' )
+ {
+ $page = $this->getPage();
+ $page->load();
+ $folderid = $page->parentid;
+ $f = new Folder( $folderid );
+ $changes = $f->getLastChanges();
+ }
+ elseif ( $this->folderid > 0 )
+ {
+ $f = new Folder( $this->folderid );
+ $changes = $f->getLastChanges();
+ }
+ else
+ $changes = $project->getLastChanges();
+
+ $count = 0;
+
+ foreach( $changes as $o )
+ {
+ if ($o['objectid'] == $this->getObjectId() )
+ continue;
+
+ if ( ($o['typeid']==OR_TYPEID_PAGE && istrue($this->showPages)) ||
+ ($o['typeid']==OR_TYPEID_LINK && istrue($this->showLinks)) ) // Nur wenn gewünschter Typ
+ {
+ if ( $o['typeid']==OR_TYPEID_LINK ) {
+ $l = new Link( $o['objectid'] );
+ $l->load();
+
+ $p = new Page( $l->linkedObjectId );
+ }
+ elseif ( $o['typeid']==OR_TYPEID_PAGE )
+ {
+ $p = new Page( $o['objectid'] );
+ }
+ else
+ continue;
+
+ $p->load();
+
+ // Template zulässig?
+ if ( !empty($this->includeTemplateIds) )
+ if ( !in_array($p->templateid,$this->includeTemplateIds))
+ continue;
+
+ // Template zulässig?
+ if ( !empty($this->excludeTemplateIds) )
+ if ( in_array($p->templateid,$this->excludeTemplateIds))
+ continue;
+
+ $count++;
+ if ( $this->limit >= 0 && $count > $this->limit)
+ break; // Maximale Anzahl erreicht.
+
+ $desc = $p->desc;
+ $p->generate_elements();
+
+ if ( !empty($this->teaserElementId) )
+ {
+ $value = $p->values[$this->teaserElementId];
+ $desc = $value->value;
+ if ( istrue($this->plaintext) )
+ {
+ $desc = strip_tags($desc);
+ // Und nur wenn die Tags raus sind duerfen wir nun den Text kuerzen.
+ // (sonst drohen offene Tags)
+ if ( is_numeric($this->teaserMaxLength) && $this->teaserMaxLength > 0 )
+ $desc = Text::maxLength($desc,$this->teaserMaxLength);
+ }
+ }
+
+ $time = '';
+ if ( !empty($this->timeelementid) )
+ {
+ $value = $p->values[$this->timeelementid];
+ $time = $value->value;
+ }
+
+ $this->output('<div class="'.$this->css_class.'">');
+
+ if ( istrue($this->linktitle) )
+ {
+ $url = $this->pathToObject($o['objectid']);
+ $this->output( '<a href="'.$url.'"><div>' );
+ }
+
+ $this->output('<h6>'.$time.'</h6>');
+
+
+ $this->output( '<h3>');
+ $this->output( $p->name );
+ $this->output( '</h3>' );
+
+ $this->output( '<p>' );
+ $this->output( $desc );
+ $this->output( '</p>' );
+
+ if ( istrue($this->linktitle) )
+ {
+ $this->output( '</div></a>' );
+ }
+
+ $this->output( '</div>' );
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/LastPage.class.php b/modules/cms-macros/macro/LastPage.class.php
@@ -0,0 +1,79 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2005-01-04 19:59:55 dankert
+// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+
+
+/**
+ * Erstellen eines Links zur Seite davor
+ * @author Jan Dankert
+ */
+class LastPage extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between menu entries, default: "·"'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+ var $version = '$Id$';
+
+
+ function execute()
+ {
+ $folder = new Folder( $this->page->parentid );
+
+ $lastObject = null;
+
+ // Schleife ueber alle Inhalte des Ordners
+ foreach( $folder->getObjects() as $o )
+ {
+ if ( $o->isPage || $o->isLink )
+ {
+ if ( is_object($lastObject) && $o->objectid == $this->page->objectid )
+ {
+ $this->output( '<a href="'.$this->pathToObject($lastObject->objectid).' class="next">'.$lastObject->name.'</a>' );
+ break;
+ }
+
+ $lastObject = $o->objectid;
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/Link.class.php b/modules/cms-macros/macro/Link.class.php
@@ -0,0 +1,56 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2005-01-04 19:59:55 dankert
+// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Object;
+
+
+/**
+ * Erstellen eines Links.
+ *
+ * @author Jan Dankert
+ */
+class NextPage extends Macro
+{
+ public $targetid = 0;
+ public $classes = '';
+ public $name = '';
+ public $title = '';
+
+ function execute()
+ {
+ // Lesen des Ordners
+ $o = new Object( $this->targetid );
+ $o->load();
+
+ if ( empty($this->name ) ) $this->name = $o->name;
+ if ( empty($this->title) ) $this->title = $o->description;
+
+ $this->output( '<a href="'.$this->pathToObject($this->targetid).' title="'.$this->title.'" class="'.$this->classes.'">'.$this->name.'</a>' );
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/ListMenu.class.php b/modules/cms-macros/macro/ListMenu.class.php
@@ -0,0 +1,115 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2005-01-28 23:06:10 dankert
+// Neues Menue in Listenform (HTML-Listen), aehnlich "BlockMenu"
+//
+// Revision 1.2 2004/12/25 21:05:14 dankert
+// erbt von Klasse Dynamic
+//
+// Revision 1.1 2004/10/14 21:16:12 dankert
+// Erzeugen eines Menues in Bloecken
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Object;
+
+
+/**
+ * Erstellen eines Hauptmenues
+ * @author Jan Dankert
+ */
+class ListMenu extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between menu entries, default: "·"'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+ var $version = '$Id$';
+ var $api;
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ // Erstellen des Hauptmenues
+
+ // Lesen des Root-Ordners
+ $folder = new Folder( $this->getRootObjectId() );
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+ if ( $o->isFolder ) // Nur wenn Ordner
+ {
+ $f = new Folder( $id );
+ $f->load();
+
+ // Ermitteln eines Objektes mit dem Dateinamen index
+// $oid = $f->getObjectIdByFileName('index');
+
+ if ( count($f->getLinks())+count($f->getPages()) > 0 )
+ {
+ $this->output( '<h1 class="title">'.$o->name.'</h1><ul>');
+ // Untermenue
+ // Schleife ber alle Objekte im aktuellen Ordner
+ foreach( $f->getObjectIds() as $xid )
+ {
+ $o = new Object( $xid );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+
+ // Nur Seiten und Verknuepfungen anzeigen
+ if (!$o->isPage && !$o->isLink && !$o->isUrl ) continue;
+
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->getObjectId() == $xid )
+ {
+ // aktuelle Seite
+ $this->output( '<li class="menu">'.$o->name.'</li>' );
+ }
+ else
+ {
+ $this->output( '<li class="menu"><a class="menu" href="'.$this->page->path_to_object($xid).'">'.$o->name.'</a></li>' );
+ }
+ }
+
+ $this->output( '</ul><br />' );
+ }
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/MainMenu.class.php b/modules/cms-macros/macro/MainMenu.class.php
@@ -0,0 +1,81 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2004-12-19 15:19:16 dankert
+// Klasse erbt von "Dynamic"
+//
+// Revision 1.1 2004/10/14 21:15:57 dankert
+// Erzeugen eines Hauptmenues
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Object;
+
+
+/**
+ * Erstellen eines Hauptmenues
+ * @author Jan Dankert
+ */
+class MainMenu extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between menu entries, default: "·"'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+ var $version = '$Id$';
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ // Lesen des Root-Ordners
+ $folder = new Folder( $this->getRootObjectId() );
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+ if ( $o->isFolder ) // Nur wenn Ordner
+ {
+ $f = new Folder( $id );
+
+ // Ermitteln eines Objektes mit dem Dateinamen index
+ $oid = $f->getObjectIdByFileName('index');
+ if ( is_numeric($oid) && $oid!=0 )
+ $this->output( $this->arrowChar.'<a href="'.$this->page->path_to_object($oid).'" title="'.$o->desc.'">'.$o->name.'</a>' );
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/NextPage.class.php b/modules/cms-macros/macro/NextPage.class.php
@@ -0,0 +1,85 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2005-01-04 19:59:55 dankert
+// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+
+
+/**
+ * Erstellen eines Links zur naechsten Seite
+ * @author Jan Dankert
+ */
+class NextPage extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between menu entries, default: "·"'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+ var $version = '$Id$';
+ var $api;
+
+
+ function execute()
+ {
+ // Lesen des Ordners
+ $folder = new Folder( $this->page->parentid );
+
+ $was = false;
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjects() as $o )
+ {
+ if ( $o->isPage || $o->isLink ) // Nur wenn Ordner
+ {
+ if ( $o->objectid == $this->page->objectid )
+ {
+ $was = true;
+ continue;
+ }
+
+ if ( $was )
+ {
+ $this->output( '<a href="'.$this->pathToObject($o->objectid).' class="next">'.$o->name.'</a>' );
+ break;
+ }
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/OpenStreetMap.class.php b/modules/cms-macros/macro/OpenStreetMap.class.php
@@ -0,0 +1,63 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+
+
+
+/**
+ * Bindet die OpenStreetMap ein.
+ *
+ * @author Jan Dankert
+ */
+class OpenStreetMap extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'box' => 'coordinates',
+ 'layer' => 'mapnik',
+ 'width' => 'Width of iframe',
+ 'height' => 'Height of iframe',
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Includes the OpenStreetMap.';
+
+ var $box = '9.9396,53.4821,10.184,53.643'; // default: Hamburg
+ var $layer = 'mapnik';
+ var $width = 425;
+ var $height = 350;
+
+ /**
+ */
+ function execute()
+ {
+ $this->output('<iframe width="'.$this->width.'" height="'.$this->height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox='.$this->box.'&layer='.$this->layer.'" style="border: 1px solid black"></iframe>');
+ }
+
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/PagesNavigation.class.php b/modules/cms-macros/macro/PagesNavigation.class.php
@@ -0,0 +1,78 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2005-01-04 19:59:55 dankert
+// Allgemeine Korrekturen, Erben von "Dynamic"-klasse
+//
+// Revision 1.1 2004/11/10 22:43:35 dankert
+// Beispiele fuer dynamische Templateelemente
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+
+
+/**
+ * Erstellen eines Hauptmenues
+ * @author Jan Dankert
+ */
+class PagesNavigation extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'arrowChar'=>'String between entries'
+ );
+
+
+ var $arrowChar = ' · ';
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a page navigation.';
+ var $version = '$Id$';
+ var $api;
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ // Lesen des Root-Ordners
+ $folder = new Folder( $this->page->parentid );
+
+ $nr = 0;
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjects() as $o )
+ {
+ $nr++;
+ if ( $o->isPage || $o->isLink )
+ {
+ if ( $o->objectid != $this->page->objectid )
+ $this->output( '<a href="'.$this->page->path_to_object($oid).'" title="'.$o->desc.'" class="pagenav">'.$nr.'</a>' );
+ else
+ $this->output( '<strong>'.$nr.'</strong>' );
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/RSSCreate.class.php b/modules/cms-macros/macro/RSSCreate.class.php
@@ -0,0 +1,170 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.4 2009-03-16 23:30:02 dankert
+// Unnötigen Aufruf von pathToObject entfernt.
+//
+// Revision 1.3 2007-11-17 02:19:29 dankert
+// Erg?nzung der Version (Default: 0.91), Korrektur, Anpassung an neue API.
+//
+// Revision 1.2 2004/12/28 22:57:56 dankert
+// Korrektur Vererbung, "api" ausgebaut
+//
+// Revision 1.1 2004/10/14 21:14:52 dankert
+// Erzeugen eines RSS-Feeds aus einem Ordner
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+
+
+/**
+ * Erstellen eines Hauptmenues
+ * @author Jan Dankert
+ */
+class RSSCreate extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'htmlentities' =>'Escape HTML-Tags in RSS-Feed, default: false',
+ 'folderid' =>'Id of the folder whose pages should go into the RSS-Feed, default: the root folder',
+ 'feed_url' =>'Url of the feed, default: blank',
+ 'feed_title' =>'Title of the feed, default: Name of folder',
+ 'feed_description'=>'Description of the feed, default: Description of folder'
+ );
+
+ var $htmlentities = false;
+ var $folderid = 0;
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates an RSS-Feed of pages in a folder';
+ var $api;
+
+ var $feed_version = '0.91';
+ var $feed_url = '';
+ var $feed_title = '';
+ var $feed_description = '';
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ $feed = array();
+
+ // Lesen des Root-Ordners
+ if ( intval($this->folderid) == 0 )
+ $folder = new Folder( $this->getRootObjectId() );
+ else
+ $folder = new Folder( intval($this->folderid) );
+
+ $folder->load();
+
+ if ( $this->feed_title == '' )
+ $this->feed_title = $folder->name;
+
+ if ( $this->feed_description == '' )
+ $this->feed_description = $folder->desc;
+
+ $feed['title' ] = $this->feed_title;
+ $feed['description'] = $this->feed_description;
+ $feed['url' ] = $this->feed_url;
+ $feed['items' ] = array();
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjectIds() as $id )
+ {
+ if ( $id == $this->getObjectId() )
+ continue;
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+ if ( $o->isPage ) // Nur wenn Seite
+ {
+ $p = new Page( $id );
+ $p->load();
+
+ $item = array();
+ $item['title' ] = $p->name;
+ $item['description'] = $p->desc;
+ $item['pubDate' ] = $p->lastchangeDate;
+ if ( empty($this->feed_url) )
+ $item['link' ] = $this->pathToObject($id);
+ else
+ $item['link' ] = $this->feed_url;
+
+ $feed['items'][] = $item;
+ }
+ }
+
+ $rss = $this->rss($feed);
+
+ if ( $this->htmlentities )
+ $rss = htmlentities( $rss );
+
+ $this->output( $rss );
+ }
+
+
+ function rss($input, $stylesheet='')
+ {
+// print_r($input);
+ // Builds the XML RSS schema using the array
+ $input["encoding"] = (empty($input["encoding"] ))?"UTF-8":$input["encoding"];
+ $input["language"] = (empty($input["language"] ))?"en-us":$input["language"];
+
+ if ( empty($input['title' ])) $input['title' ] = '';
+ if ( empty($input['description'])) $input['description'] = '';
+ if ( empty($input['link' ])) $input['link' ] = '';
+ $rss = '<?xml version="1.0" encoding="'.$input["encoding"].'"?>';
+ $rss .= (!empty($stylesheet))?"\n".'<?xml-stylesheet type="text/xsl" href="'.$stylesheet.'"?>':"";
+ $rss .= <<<__RSS__
+
+ <rss version="{$this->feed_version}">
+ <channel>
+ <title>{$input["title"]}</title>
+ <description>{$input["description"]}</description>
+ <link>{$input["link"]}</link>
+ <language>{$input["language"]}</language>
+ <generator></generator>
+
+__RSS__;
+ foreach($input["items"] as $item)
+ {
+ if ( empty($item['title' ])) $item['title' ] = '';
+ if ( empty($item['description'])) $item['description'] = '';
+ $data = date("r", $item["pubDate"]);
+ $rss .= "\n<item>\n<title>".$item["title"]."</title>";
+ $rss .= "\n<description><![CDATA[".$item["description"]."]]></description>";
+ if (!empty($item["pubDate"]))
+ $rss .= "\n<pubDate>".date("r", $item["pubDate"])."</pubDate>";
+ if (!empty($item["link"]))
+ $rss .= "\n<link>".$item["link"]."</link>";
+ $rss .= "\n</item>\n";
+ }
+ $rss .= "\n</channel>\n</rss>";
+ return $rss;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/RSSReader.class.php b/modules/cms-macros/macro/RSSReader.class.php
@@ -0,0 +1,180 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2004-12-19 15:18:50 dankert
+// Speichern des RSS-Feeds in Session (Performance)
+//
+// Revision 1.1 2004/10/14 21:15:13 dankert
+// Lesen eines RSS-Feeds und erzeugen eines HTML-Abschnittes dafuer
+//
+// ---------------------------------------------------------------------------
+
+
+
+/**
+ * @author Jan Dankert
+ */
+class RSSReader extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'url'=>'URL from which the RSS is fetched'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Reads a RSS-Feed and displays its content as a html list';
+
+ var $url = 'http://www.heise.de/newsticker/heise.rdf';
+
+
+
+ function execute()
+ {
+ // Sessionvariable mit CRC verschluesseln, falls es mehrere RSS-Feeds im Projekt gibt
+ $sessVar = 'RSSReader_'.crc32($this->url);
+ $cache = $this->getSessionVar( $sessVar );
+
+ if ( !empty($cache) )
+ {
+ // Wenn Cache vorhanden, dann diesen ausgeben
+ $this->output( $cache );
+ }
+ else
+ {
+ // Wenn Cache leer, dann RSS erzeugen und in Session speichern
+ $this->create();
+ $this->setSessionVar( $sessVar,$this->getOutput() );
+ }
+ }
+
+
+
+ // Erzeugt den Text des RSS-Feeds
+ function create()
+ {
+ $rss = $this->parse( implode('',file($this->url)) );
+ $out = array();
+
+ $this->output('<ul>');
+
+ // Schleife ueber alle Inhalte des RSS-Feeds
+ foreach( $rss['items'] as $item )
+ {
+ $this->output('<li>');
+ $this->output('<a href="'.$item['link'].'">'.$item['title'].'</a><br/>'.$item['description']);
+ $this->output('</li>');
+ }
+
+ $this->output('</ul>');
+ }
+
+
+
+ function parse( $feed )
+ {
+ // Parses the RSS feed into the array
+ $arr = array();
+ // Determine encoding
+ preg_match('/<\?xml version="1\.0" encoding="(.*)"\?>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["encoding"] = $sarr[1];
+ // Determine title
+ preg_match('/<title>(.*)<\/title>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["title"] = $sarr[1];
+ // Determine title
+ preg_match('/<title>(.*)<\/title>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["title"] = $sarr[1];
+ // Determine description
+ preg_match('/<description>(.*)<\/description>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["description"] = $sarr[1];
+ // Determine link
+ preg_match('/<link>(.*)<\/link>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["link"] = $sarr[1];
+ // Determine language
+ preg_match('/<language>(.*)<\/language>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["language"] = $sarr[1];
+ // Determine generator
+ preg_match('/<generator>(.*)<\/generator>/i', $feed, $sarr);
+ if ( !empty($sarr[1]))
+ $arr["generator"] = $sarr[1];
+ // Strip items
+ $parts = explode("<item>", $feed);
+ foreach($parts as $part)
+ {
+ $item = substr($part, 0, strpos($part, "</item>"));
+ if ( !empty($item) )
+ $items[] = $item;
+ }
+ // Fill the channel array
+ $arr["items"] = array();
+ foreach($items as $item)
+ {
+ $i = array();
+
+ // Determine title
+ preg_match('/<title>(.*)<\/title>/i', $item, $title);
+ if ( !empty($title[1]))
+ $i['title'] = $title[1];
+ else
+ $i['title'] = '';
+
+ // Determine pubdate
+ preg_match('/<pubDate>(.*)<\/pubDate>/i', $item, $pubdate);
+ if ( !empty($pubdate[1]))
+ $i['pubDate'] = strtotime($pubdate[1]);
+ else
+ $i['pubDate'] = '';
+
+ // Determine link
+ preg_match('/<link>(.*)<\/link>/i', $item, $link);
+ if ( !empty($link[1]))
+ $i['link'] = $link[1];
+ else
+ $i['link'] = '';
+
+ // Determine description
+ if(stristr($item, '<![CDATA['))
+ preg_match('/<description><!\[CDATA\[(.*)\]\]><\/description>/is', $item, $description);
+ else
+ preg_match('/<description>(.*)<\/description>/is', $item, $description);
+
+ if ( !empty($description[1]))
+ $i['description'] = $description[1];
+ else
+ $i['description'] = '';
+
+ $arr["items"][] = $i;
+ }
+ return $arr;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/Sitemap.class.php b/modules/cms-macros/macro/Sitemap.class.php
@@ -0,0 +1,119 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.2 2004-12-28 22:57:56 dankert
+// Korrektur Vererbung, "api" ausgebaut
+//
+// Revision 1.1 2004/10/14 21:15:29 dankert
+// Erzeugen und Anzeigen einer Sitemap
+//
+// ---------------------------------------------------------------------------
+use cms\model\Folder;
+use cms\model\Object;
+use cms\model\Page;
+
+
+/**
+ * Erstellen eines Menues
+ * @author Jan Dankert
+ */
+class Sitemap extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'beforeEntry'=>'Chars before an active menu entry'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a main menu.';
+
+
+ /**
+ * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
+ */
+ var $beforeEntry = '<li><strong>';
+ var $afterEntry = '</strong></li>';
+
+ var $api;
+
+ /**
+ * Erstellen einer Sitemap
+ */
+ function execute()
+ {
+ // Erstellen eines Untermenues
+
+ // Ermitteln der aktuellen Seite
+ $thispage = new Page( $this->getObjectId() );
+ $thispage->load(); // Seite laden
+
+ // uebergeordneter Ordner dieser Seite
+ $this->showFolder( $this->getRootObjectId() );
+ }
+
+ function showFolder( $oid )
+ {
+ // uebergeordneter Ordner dieser Seite
+ $f = new Folder( $oid );
+
+ // Schleife ueber alle Objekte im aktuellen Ordner
+ foreach( $f->getObjectIds() as $id )
+ {
+ $o = new Object( $id );
+ $o->languageid = $this->page->languageid;
+ $o->load();
+
+ // Ordner
+ if ($o->isFolder )
+ {
+ $this->output( '<li><strong>'.$o->name.'</strong><br/>' );
+ $this->output( '<ul>' );
+ $this->showFolder( $id ); // Rekursiver Aufruf dieser Methode
+ $this->output( '</ul></li>' );
+ }
+
+ // Seiten und Verkn?fpungen
+ if ($o->isPage || $o->isLink )
+ {
+ // Wenn aktuelle Seite, dann markieren, sonst Link
+ if ( $this->getObjectId() == $id )
+ {
+ // aktuelle Seite
+ $this->output( '<li><strong>'.$o->name.'</strong></li>' );
+ }
+ else
+ {
+ // Link erzeugen
+ $this->output( '<li><a href="'.$this->pathToObject($id).'">'.$o->name.'</a></li>' );
+ }
+ }
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/TableFromFile.class.php b/modules/cms-macros/macro/TableFromFile.class.php
@@ -0,0 +1,89 @@
+<?php
+// 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.
+use cms\model\File;
+
+
+/**
+ * Erstellt eine HTML-Tabelle aus einer CSV-Datei.
+ *
+ * @author Jan Dankert
+ */
+class TagCloud extends Macro
+{
+ /**
+ * Beschreibung dieser Klasse
+ * @type String
+ */
+ var $description = '';
+
+
+ public $fileid = 0;
+ public $separator = ',';
+ public $firstlineheader = 1;
+ public $firstcolumnheader = 1;
+ public $ignorefirstline = 0;
+ public $header = 'A,B,C';
+ public $encodeHtml = 1;
+
+
+ function execute()
+ {
+ $this->output('<table>');
+ $file = new File( $this->fileid );
+ $lines = explode("\n",$file->loadValue() );
+
+ $firstline = true;
+ foreach( $lines as $line )
+ {
+ if ( $firstline)
+ {
+ $firstline = false;
+ if ( $this->ignorefirstline)
+ continue;
+ elseif ( $this->firstlineheader )
+ $lcelltag = 'th';
+ else
+ $lcelltag = 'td';
+ }
+ else
+ $lcelltag = 'td';
+
+ $columns = explode($this->separator,$line);
+
+ $this->output('<tr>');
+ $firstcolumn = true;
+ foreach( $columns as $column )
+ {
+ if ($firstcolumn)
+ {
+ $firstcolumn = false;
+ if ( $this->firstcolumnheader )
+ $celltag = 'th';
+ else
+ $celltag = $lcelltag;
+
+ if ( $this->encodeHtml) $column = encodeHtml($column);
+ $this->output('<'.$celltag.'>'.$column.'</'.$celltag.'>');
+ }
+ }
+ $this->output('</tr>');
+ }
+ $this->output('</table>');
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/TagCloud.class.php b/modules/cms-macros/macro/TagCloud.class.php
@@ -0,0 +1,66 @@
+<?php
+// 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.
+use cms\model\Folder;
+
+
+/**
+ * Erstellt eine Tagcloud.
+ * @author Jan Dankert
+ */
+class TagCloud extends Macro
+{
+ /**
+ * Beschreibung dieser Klasse
+ * @type String
+ */
+ var $description = '';
+
+
+ public $keywordFolderId = 0;
+
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ if ( intval($this->keywordFolderId) == 0 )
+ {
+ $this->output('param keywordfolderid not set');
+ return;
+ }
+
+ $f = new Folder( $this->keywordFolderId );
+
+ foreach( $f->getChildObjectIdsByName() as $fid )
+ {
+ $tf = new Folder($fid);
+ if ( !$tf->isFolder)
+ continue;
+ $tf->load();
+
+ $target = $tf->getFirstPage();
+
+ if ( $target == null)
+ continue;
+ $target->load();
+
+ // Link zum Tag erzeugen
+ $this->output( '<div class="tag" style="font-size:'.(0.5+(sizeof($tf->getObjectIds())*0.1)).'em"><a href="'.$this->pathToObject($target->objectid).'">'.$tf->name.'</a></div>' );
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/TagList.class.php b/modules/cms-macros/macro/TagList.class.php
@@ -0,0 +1,55 @@
+<?php
+// 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.
+use cms\model\Folder;
+use cms\model\Link;
+
+
+/**
+ * Erstellt eine Tagcloud.
+ * @author Jan Dankert
+ */
+class TagList extends Macro
+{
+ /**
+ * Beschreibung dieser Klasse
+ * @type String
+ */
+ var $description = '';
+
+ function execute()
+ {
+ $page = $this->getPage();
+ $linkIds = $page->getLinksToMe();
+
+ foreach( $linkIds as $linkid )
+ {
+ $l = new Link( $linkid );
+ $l->load();
+ $f = new Folder( $l->parentid );
+ $f->load();
+
+ $target = $f->getFirstPage();
+ if ( $target==null) continue;
+ $target->load();
+
+ // Link erzeugen
+ $this->output( '<div class="tag"><a href="'.$this->pathToObject($target->objectid).'">'.$f->name.'</a></div>' );
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/TeaserList.class.php b/modules/cms-macros/macro/TeaserList.class.php
@@ -0,0 +1,114 @@
+<?php
+// 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.
+use cms\model\Folder;
+use cms\model\Page;
+
+
+/**
+ * Erstellen einer Teaser-Liste.
+ *
+ * @author Jan Dankert
+ */
+class TeaserList extends Macro
+{
+ var $folderid = 0;
+ var $title_html_tag = 'h2';
+ var $time_html_tag = 'h6';
+ var $title_css_class = 'teaser';
+ var $description_css_class = 'teaser';
+ var $link_css_class = 'teaser';
+ var $teaserElementId = '';
+ var $teaserMaxLength = 100;
+ var $plaintext = 'true';
+ var $linktitle = 'true';
+ var $linktext = 'true';
+ var $timeelementid = 0;
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a teaser list of pages in a folder';
+
+ // Erstellen des Hauptmenues
+ function execute()
+ {
+ $feed = array();
+
+ // Lesen des Root-Ordners
+ if ( intval($this->folderid) == 0 )
+ $folder = new Folder( $this->getRootObjectId() );
+ else
+ $folder = new Folder( intval($this->folderid) );
+
+ $folder->load();
+
+ // Schleife ueber alle Inhalte des Root-Ordners
+ foreach( $folder->getObjects() as $o )
+ {
+ if ( $o->isPage ) // Nur wenn Ordner
+ {
+ $p = new Page( $o->objectid );
+ $p->load();
+
+ $desc = $p->desc;
+ $p->generate_elements();
+
+ if ( !empty($this->teaserElementId) )
+ {
+ $value = $p->values[$this->teaserElementId];
+ $desc = $value->value;
+ if ( istrue($this->plaintext) )
+ {
+ $desc = strip_tags($desc);
+ // Und nur wenn die Tags raus sind duerfen wir nun den Text kuerzen.
+ // (sonst drohen offene Tags)
+ if ( is_numeric($this->teaserMaxLength) && $this->teaserMaxLength > 0 )
+ $desc = Text::maxLength($desc,$this->teaserMaxLength);
+ }
+ }
+
+ $time = '';
+ if ( !empty($this->timeelementid) )
+ {
+ $value = $p->values[$this->timeelementid];
+ $time = $value->value;
+ }
+
+ $this->output('<'.$this->time_html_tag.'>'.$time.'</'.$this->time_html_tag.'>');
+
+ $url = $this->pathToObject($o->objectid);
+
+ $this->output( '<'.$this->title_html_tag.' class="'.$this->title_css_class.'">');
+ if ( istrue($this->linktitle) )
+ $this->output( '<a href="'.$url.'">'.$p->name.'</a>' );
+ else
+ $this->output( $p->name );
+ $this->output( '</'.$this->title_html_tag.'>' );
+
+ $this->output( '<p class="'.$this->description_css_class.'">' );
+ if ( istrue($this->linktext) )
+ $this->output( '<a href="'.$this->pathToObject($o->objectid).'">'.$desc.'</a>' );
+ else
+ $this->output( $desc );
+
+ $this->output( '</p>' );
+ }
+ }
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms-macros/macro/Youtube.class.php b/modules/cms-macros/macro/Youtube.class.php
@@ -0,0 +1,59 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+
+
+
+/**
+ * Bindet ein Youtube-Video ein.
+ *
+ * @author Jan Dankert
+ */
+class Youtube extends Macro
+{
+ /**
+ * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $parameters = Array(
+ 'id'=>'Video-Id'
+ );
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Includes a youtube video.';
+
+ var $id = "0";
+ var $width = 320;
+ var $height = 265;
+
+ /**
+ */
+ function execute()
+ {
+ $this->output('<object width="'.$this->width.'" height="'.$this->height.'"><param name="movie" value="http://www.youtube.com/v/'.$this->id.'&hl=de&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$this->id.'&hl=de&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$this->width.'" height="'.$this->height.'"></embed></object>');
+ }
+
+}
+
+?>+
\ No newline at end of file