openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 7487c4ef7c13f987b80d511aeded01e24b117d5b
parent 5cb05b61011414d92da0459a1a26064cfeeb0240
Author: Jan Dankert <develop@jandankert.de>
Date:   Wed, 18 Nov 2020 00:18:10 +0100

Refactoring Part 2: Removing all unnecessary methods in the action base classes.

Diffstat:
Mmodules/cms/action/AliasAction.class.php | 4----
Mmodules/cms/action/BaseAction.class.php | 17-----------------
Mmodules/cms/action/ConfigurationAction.class.php | 59-----------------------------------------------------------
Mmodules/cms/action/ElementAction.class.php | 561-------------------------------------------------------------------------------
Mmodules/cms/action/FileAction.class.php | 500+------------------------------------------------------------------------------
Mmodules/cms/action/FolderAction.class.php | 1144+------------------------------------------------------------------------------
Mmodules/cms/action/GroupAction.class.php | 241-------------------------------------------------------------------------------
Mmodules/cms/action/GrouplistAction.class.php | 50--------------------------------------------------
Mmodules/cms/action/ImageAction.class.php | 111+------------------------------------------------------------------------------
Mmodules/cms/action/LanguageAction.class.php | 76----------------------------------------------------------------------------
Mmodules/cms/action/LanguagelistAction.class.php | 84-------------------------------------------------------------------------------
Mmodules/cms/action/LinkAction.class.php | 73-------------------------------------------------------------------------
Mmodules/cms/action/LoginAction.class.php | 725+------------------------------------------------------------------------------
Mmodules/cms/action/ModelAction.class.php | 77-----------------------------------------------------------------------------
Mmodules/cms/action/ModellistAction.class.php | 53-----------------------------------------------------
Mmodules/cms/action/ObjectAction.class.php | 612-------------------------------------------------------------------------------
Mmodules/cms/action/PageAction.class.php | 726-------------------------------------------------------------------------------
Mmodules/cms/action/PageelementAction.class.php | 611+++----------------------------------------------------------------------------
Mmodules/cms/action/ProfileAction.class.php | 293+------------------------------------------------------------------------------
Mmodules/cms/action/ProjectAction.class.php | 218-------------------------------------------------------------------------------
Mmodules/cms/action/ProjectlistAction.class.php | 89-------------------------------------------------------------------------------
Mmodules/cms/action/README.md | 11++++++-----
Mmodules/cms/action/SearchAction.class.php | 66++----------------------------------------------------------------
Mmodules/cms/action/TemplateAction.class.php | 507-------------------------------------------------------------------------------
Mmodules/cms/action/TemplatelistAction.class.php | 156-------------------------------------------------------------------------------
Mmodules/cms/action/TextAction.class.php | 40----------------------------------------
Mmodules/cms/action/UrlAction.class.php | 103-------------------------------------------------------------------------------
Mmodules/cms/action/UserAction.class.php | 401+------------------------------------------------------------------------------
Mmodules/cms/action/userlist/UserlistAddAction.class.php | 5+++++
Mmodules/cms/action/userlist/UserlistEditAction.class.php | 3+++
30 files changed, 47 insertions(+), 7569 deletions(-)

diff --git a/modules/cms/action/AliasAction.class.php b/modules/cms/action/AliasAction.class.php @@ -62,8 +62,4 @@ class AliasAction extends ObjectAction parent::init(); } - - - - } diff --git a/modules/cms/action/BaseAction.class.php b/modules/cms/action/BaseAction.class.php @@ -12,21 +12,4 @@ class BaseAction extends Action { parent::__construct(); } - - - /** - * Gets all available View-Methods in this Action. - */ - public function availableView() - { - $viewMethods = array_map( function($methodName){ - // Removing the 'View' from the end of the method name - return substr($methodName,0,strlen($methodName)-4); - }, array_filter(get_class_methods($this), function ($methodName) { - // Filter only View methods - return substr($methodName, -4, 4) == 'View'; - })); - - $this->setTemplateVar('views', $viewMethods); - } } \ No newline at end of file diff --git a/modules/cms/action/ConfigurationAction.class.php b/modules/cms/action/ConfigurationAction.class.php @@ -40,66 +40,7 @@ class ConfigurationAction extends BaseAction } - public function editView() - { - $this->nextSubAction('show'); - - } - - /** - * Anzeigen des Elementes - */ - public function showView() - { - $defaultConfig = DefaultConfig::get();; - $currentConfig = Session::getConfig(); - - $currentConfig['system'] = $this->getSystemConfiguration(); - - // Language are to much entries - unset($currentConfig['language']); - - $pad = str_repeat("\xC2\xA0",10); // Hard spaces - - $flatDefaultConfig = \util\ArrayUtils::dryFlattenArray( $defaultConfig , $pad ); - $flatCMSConfig = \util\ArrayUtils::dryFlattenArray( Session::getConfig(), $pad ); - $flatConfig = \util\ArrayUtils::dryFlattenArray( $currentConfig , $pad ); - - $config = array_map( function($key,$value) use ($flatConfig,$flatCMSConfig,$flatDefaultConfig) { - - if ( strpos($key,'password') !== false ) - $value = '*'; - - return ['key'=>$key,'value'=>$value,'class'=>(empty($flatCMSConfig[$key])?'readonly':(isset($flatDefaultConfig[$key]) && $flatDefaultConfig[$key]==$flatConfig[$key]?'default':'changed'))]; - - },array_keys($flatConfig),$flatConfig); - - $this->setTemplateVar('config',$config ); - } - - - /** - * Die Konfiguration als YAML-String anzeigen. - */ - public function srcView() - { - $conf = Session::getConfig(); - unset( $conf['language']); - - // Mask passwords. - array_walk_recursive($conf,function(&$item,$key) - { - if($key=='password'){ - $item='*************'; - } - }); - - $this->setTemplateVar('source', \util\YAML::dump($conf,4,0,true)); - } - - - /** * Reads system configuration. * @return array diff --git a/modules/cms/action/ElementAction.class.php b/modules/cms/action/ElementAction.class.php @@ -50,566 +50,5 @@ class ElementAction extends BaseAction $this->setTemplateVar( 'elementid' ,$this->element->elementid ); } - - - - /** - * Umbenennen des Elementes - */ - public function removeView() - { - $this->setTemplateVar( 'name' ,$this->element->name ); - } - - - /** - * Entfernen des Elementes - */ - public function removePost() - { - if ( !$this->hasRequestVar('confirm') ) - throw new \util\exception\ValidationException('confirm'); - - $type = $this->getRequestVar('type','abc'); - - if ( $type == 'value' ) - { - // Nur Inhalte löschen - $this->element->deleteValues(); - $this->addNotice('element', 0, $this->element->name, 'DELETED', Action::NOTICE_OK); - } - elseif ( $type == 'all' ) - { - // Element löschen - $this->element->delete(); - $this->addNotice('element', 0, $this->element->name, 'DELETED', Action::NOTICE_OK); - } - } - - - - /** - * Aendern des Element-Typs - */ - public function advancedPost() - { - $ini_date_format = Configuration::subset('date')->get('format',[] ); - - if ( $this->hasRequestVar('format')) - $this->element->format = $this->getRequestId('format'); - - - if ( $this->hasRequestVar('dateformat')) - $this->element->dateformat = @$ini_date_format[$this->getRequestVar('dateformat')]; - - - if ( $this->hasRequestVar('default_longtext')) - $this->element->defaultText = $this->getRequestVar('default_longtext',RequestParams::FILTER_TEXT); - else - $this->element->defaultText = $this->getRequestVar('default_text',RequestParams::FILTER_TEXT); - - $this->element->subtype = $this->getRequestVar('subtype'); - - $this->element->html = $this->hasRequestVar('html'); - $this->element->withIcon = $this->hasRequestVar('with_icon'); - $this->element->allLanguages = $this->hasRequestVar('all_languages'); - $this->element->writable = $this->hasRequestVar('writable'); - $this->element->inherit = $this->hasRequestVar('inherit'); - - $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' ,RequestParams::FILTER_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',RequestParams::FILTER_RAW); - - $this->element->save(); - $this->addNotice('element', 0, $this->element->name, 'SAVED'); - - } - - - public function advancedView() - { - $this->setTemplateVar('type',$this->element->getTypeName() ); - - // 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 'inherit': - $this->setTemplateVar('inherit' ,$this->element->inherit ); - break; - - case 'html': - $this->setTemplateVar('html' ,$this->element->html ); - break; - - case 'subtype': - - $convertToLang = false; - switch( $this->element->typeid ) - { - case Element::ELEMENT_TYPE_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 Element::ELEMENT_TYPE_INFODATE: - case Element::ELEMENT_TYPE_LINKDATE: - $subtypes = Array('date_published', - 'date_saved', - 'date_created' ); - $convertToLang = true; - break; - - case Element::ELEMENT_TYPE_LINK: - $subtypes = Array( - 'file', - 'image', - 'image_data_uri', - 'page', - 'folder', - 'link' ); - $convertToLang = true; - break; - - case Element::ELEMENT_TYPE_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 Element::ELEMENT_TYPE_INSERT: - $subtypes = Array('inline', - 'ssi' ); - $convertToLang = true; - break; - - case Element::ELEMENT_TYPE_DYNAMIC: - - $files = Array(); - $macroFiles = \util\FileUtils::readDir(__DIR__ . '/../../cms/macros/macro'); - foreach( $macroFiles as $macroFile ) - { - $file = substr($macroFile,0,strlen($macroFile)-10); - if ( $file != '' ) - $files[$file] = $file; - } - - $subtypes = $files; - break; - - default: - $subtypes = array(); - break; - } - - if ( $convertToLang ) - { - foreach( $subtypes as $t=>$v ) - { - unset($subtypes[$t]); - $subtypes[$v] = \cms\base\Language::lang('EL_'.$this->element->getTypeName().'_'.$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 = Configuration::subset('date')->get('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->typeid ) - { - case Element::ELEMENT_TYPE_LONGTEXT: - $this->setTemplateVar('default_longtext',$this->element->defaultText ); - break; - - case Element::ELEMENT_TYPE_SELECT: - case Element::ELEMENT_TYPE_TEXT: - $this->setTemplateVar('default_text' ,$this->element->defaultText ); - break; - } - break; - - - case 'format': - $this->setTemplateVar('format', $this->element->format ); - - $formats = Element::getAvailableFormats(); - - // Für einfache Textelemente gibt es keinen HTML-Editor - if ( $this->element->typeid != Element::ELEMENT_TYPE_LONGTEXT ) - unset( $formats[ Element::ELEMENT_FORMAT_HTML ] ); - - //foreach( $formats as $t=>$v ) - // $formats[$t] = array('lang'=>'EL_PROP_FORMAT_'.$v); - - $this->setTemplateVar('formatlist', $formats); - 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(); - - $template = new Template( $this->element->templateid ); - $template->load(); - $project = new Project( $template->projectid ); - - foreach( $project->getTemplates() 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.' ('.\cms\base\Language::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->typeid ) - { - - case Element::ELEMENT_TYPE_SELECT: - $this->setTemplateVar('select_items',$this->element->code ); - break; - - case Element::ELEMENT_TYPE_DYNAMIC: - - $className = '\\cms\\macros\\macro\\'.ucfirst($this->element->subtype); - - $description = ''; - $paramList = array(); - $parameters = array(); - - if ( class_exists($className) ) - { - $dynEl = new $className; - - $description = $dynEl->description; - - $old = $this->element->getDynamicParameters(); - - $reflect = new ReflectionClass($dynEl); - $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED); - foreach( get_object_vars($dynEl) as $paramName=>$paramValue ) - { - $paramList[$paramName] = print_r( $paramValue, true); - - if ( @$old[$paramName] ) - $parameters[$paramName] = $old[$paramName]; - else - $parameters[$paramName] = $paramValue; - } - - } - - $this->setTemplateVar('dynamic_class_description',$description ); - $this->setTemplateVar('dynamic_class_parameters' ,$paramList ); - $this->setTemplateVar('parameters' , \util\YAML::dump($parameters) ); - - - break; - - case Element::ELEMENT_TYPE_CODE: - if ( Configuration::subset('security')->is('disable_dynamic_code',true ) ) - $this->addNotice('element', 0, $this->element->name, 'CODE_DISABLED', Action::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(); - - $template = new Template( $this->element->templateid ); - $template->load(); - $project = new Project( $template->projectid ); - - // Ermitteln aller verfuegbaren Objekt-IDs - foreach( $project->getAllObjectIds() as $id ) - { - $o = new BaseObject( $id ); - $o->load(); - - switch( $this->element->typeid ) - { - case Element::ELEMENT_TYPE_LINK: - if ( ! in_array( $o->typeid, array(BaseObject::TYPEID_PAGE,BaseObject::TYPEID_IMAGE,BaseObject::TYPEID_FILE,BaseObject::TYPEID_LINK,BaseObject::TYPEID_URL,BaseObject::TYPEID_TEXT ) ) ) - continue 2; - break; - //Change tobias - case Element::ELEMENT_TYPE_INSERT: - if ( ! in_array( $o->typeid, array(BaseObject::TYPEID_FOLDER,BaseObject::TYPEID_PAGE,BaseObject::TYPEID_IMAGE,BaseObject::TYPEID_FILE,BaseObject::TYPEID_LINK,BaseObject::TYPEID_URL,BaseObject::TYPEID_TEXT ) ) ) - continue 2; - break; - //Change tobias end - default: - continue 2; - } - - $objects[ $id ] = \cms\base\Language::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( \util\Text::FILE_SEP,$names ); - } - - $objects[ $id ] .= \util\Text::FILE_SEP.$o->getName(); - } - - asort( $objects ); // Sortieren - - $this->setTemplateVar('objects',$objects); - - $this->setTemplateVar('default_objectid',$this->element->defaultObjectId); - - break; - - - case 'folderObjectId': - - - // Ermitteln aller verf?gbaren Objekt-IDs - $template = new Template( $this->element->templateid ); - $template->load(); - $project = new Project( $template->projectid ); - - $folders = $project->getAllFlatFolders(); - $this->setTemplateVar('folders',$folders); - - $this->setTemplateVar('folderobjectid' ,$this->element->folderObjectId ); - - break; - - default: - throw new \LogicException('Unknown element property: '.$propertyName ); - } - } - } - - - - /** - * Auswahlmaske f�r weitere Einstellungen zum Template-Element. - * - */ - function infoView() - { - $this->setTemplateVar('id' ,$this->element->elementid ); - $this->setTemplateVar('name',$this->element->name ); - $this->setTemplateVar('type',$this->element->getTypeName() ); - } - - /** - * Auswahlmaske f�r weitere Einstellungen zum Template-Element. - * - */ - function propView() - { - // Name und Beschreibung - $this->setTemplateVar('name' ,$this->element->name); - $this->setTemplateVar('label' ,$this->element->label); - - $this->setTemplateVar('description',$this->element->desc); - - // Die verschiedenen Element-Typen - $types = array(); - - foreach( Element::getAvailableTypes() as $typeId=>$typeKey ) - $types[ $typeId ] = 'EL_'.$typeKey; - - // 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('typeid',$this->element->typeid); - } - - - - /** - * Speichern der Element-Eigenschaften. - */ - public function propPost() - { - if ( !$this->userIsAdmin() && $this->getRequestVar('type') == 'code' ) - // Code-Elemente fuer Nicht-Administratoren nicht benutzbar - throw new \util\exception\ValidationException('type'); - - $this->element->typeid = $this->getRequestId('typeid'); - - $this->element->name = $this->getRequestVar('name' ,RequestParams::FILTER_ALPHANUM); - $this->element->label= $this->getRequestVar('label' ,RequestParams::FILTER_TEXT); - $this->element->desc = $this->getRequestVar('description',RequestParams::FILTER_TEXT); - - $this->element->save(); - - $this->addNotice('element', 0, $this->element->name, 'SAVED', Action::NOTICE_OK); - } } diff --git a/modules/cms/action/FileAction.class.php b/modules/cms/action/FileAction.class.php @@ -73,477 +73,7 @@ class FileAction extends ObjectAction } - /** - * Ersetzt den Inhalt der Datei. - */ - public function editPost() - { - $upload = new Upload(); - - if ( $upload->isAvailable() ) - { - // File received as attachement. - try - { - $upload->processUpload(); - } - catch( \Exception $e ) - { - throw $e; - } - - $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(); - } - elseif( $this->hasRequestVar('value') ) - { - // File value received - $this->file->value = $this->getRequestVar('value'); - - if ( strtolower($this->getRequestVar('encoding')) == 'base64') - // file value is base64-encoded - $this->file->value = base64_decode($this->file->value); - - $this->file->saveValue(); - } - else - { - // No file received. - throw new ValidationException('value'); - } - - $this->file->setTimestamp(); - - $this->addNotice($this->file->getType(), 0, $this->file->filename, 'VALUE_SAVED', 'ok'); - } - - - /** - * Abspeichern der Eigenschaften zu dieser Datei. - * - */ - function advancedPost() - { - $this->file->extension = $this->getRequestVar('extension' ,RequestParams::FILTER_FILENAME); - - $typeid = $this->getRequestVar('type',RequestParams::FILTER_NUMBER ); - - if ( ! in_array($typeid,[BaseObject::TYPEID_FILE,BaseObject::TYPEID_IMAGE,BaseObject::TYPEID_TEXT])) - throw new ValidationException('type'); - - $this->file->typeid = $typeid; - $this->file->updateType(); - $this->file->save(); - - $this->addNotice($this->file->getType(), 0, $this->file->filename, 'PROP_SAVED', 'ok'); - } - - - - /** - * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt - * auf die Standardausgabe geschrieben - */ - function previewView() - { - $url = Html::url($this->file->getType(),'show',$this->file->objectid ); - $this->setTemplateVar('preview_url',$url ); - } - - - /** - * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt - * auf die Standardausgabe geschrieben - */ - function showView() - { - $fileContext = new FileContext($this->file->objectid, Producer::SCHEME_PREVIEW ); - - $generator = new FileGenerator( $fileContext); - - $this->lastModified( $this->file->lastchangeDate ); - - if ( $this->file->extension == 'gz' ) - { - $pos = strrpos($this->file->filename,'.'); - if ( $pos === false ) - $ext = ''; - else - $ext = substr($this->file->filename,$pos+1); - - $ext = strtolower($ext); - - $mime_type = File:: $mime_types[$ext]; - - 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->filename() ); - header('Content-Transfer-Encoding: binary' ); - header('Content-Description: '.$this->file->filename() ); - - //$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: '.$this->file->size ); - - - if ( $this->request->getRequestVar('encoding') == 'base64') - { - $encodingFunction = function($value) { - return base64_encode($value); - }; - $this->setTemplateVar('encoding', 'base64'); - } - else { - $encodingFunction = function($value) { - return $value; - }; - $this->setTemplateVar('encoding', 'none'); - } - - - // Unterscheidung, ob PHP-Code in der Datei ausgefuehrt werden soll. - $publishConfig = Configuration::subset('publish'); - $phpActive = ( $publishConfig->get('enable_php_in_file_content')=='auto' && $this->file->getRealExtension()=='php') || - $publishConfig->get('enable_php_in_file_content' )===true; - - if ( $phpActive ) { - - // PHP-Code ausfuehren - ob_start(); - require( $generator->getCache()->load()->getFilename() ); - $this->setTemplateVar('value',$encodingFunction(ob_get_contents()) ); - ob_end_clean(); - } - else - $this->setTemplateVar('value',$encodingFunction( $generator->getCache()->get() ) ); - // Maybe we want some gzip-encoding? - } - - - - - public function advancedView() - { - // Eigenschaften der Datei uebertragen - $this->setTemplateVar( 'extension',$this->file->extension ); - $this->setTemplateVar( 'type' ,$this->file->type ); - $this->setTemplateVar( 'types' ,[ - BaseObject::TYPEID_FILE => \cms\base\Language::lang('file' ), - BaseObject::TYPEID_IMAGE => \cms\base\Language::lang('image'), - BaseObject::TYPEID_TEXT => \cms\base\Language::lang('text' ) - ] ); - } - - - - - /** - * Anzeigen des Inhaltes - */ - function editView() - { - // MIME-Types aus Datei lesen - $this->setTemplateVars( $this->file->getProperties() ); - } - - - /** - * Anzeigen des Inhaltes - */ - function upload() - { - } - - - /** - * Anzeigen des Inhaltes - */ - function valueView() - { - // 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() ); - } - - - /** - * 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")) - { - throw new \LogicException("Not GZIP format (See RFC 1952)"); - } - $method = ord(substr($this->file->loadValue(),2,1)); - if ( $method != 8 ) - { - throw new \LogicException("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: - throw new \util\exception\UIException('','cannot uncompress file with extension: ' . $this->file->extension ); - } - - $this->addNotice('file', 0, $this->file->name, 'DONE', Action::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', 0, $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', 0, $newFile->name, 'ADDED'); - unset($newFile); - } - - $zip->close(); - unset($zip); - - break; - - default: - throw new \util\exception\UIException('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] = \cms\base\Language::lang('compression_'.$t); - - $this->setTemplateVar('formats' ,$formats ); - } - - - - /** - * Anzeigen des Inhaltes - */ - function compressPost() - { - $format = $this->getRequestVar('format',RequestParams::FILTER_ALPHANUM); - - switch( $format ) - { - case 'gz': - if ( $this->getRequestVar('replace',RequestParams::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: - throw new \util\exception\UIException('unknown compress type: ' . $format ); - } - - $this->addNotice('file', 0, $this->file->name, 'DONE', Action::NOTICE_OK); - $this->callSubAction('edit'); - } - - - /** - * Datei veroeffentlichen - */ - function pubView() - { - } - - - /** - * Datei veroeffentlichen - */ - function pubPost() - { - $fileGenerator = new FileGenerator( new FileContext( $this->file->objectid, Producer::SCHEME_PUBLIC)); - - $publisher = new Publisher( $this->file->projectid ); - $publisher->addOrderForPublishing( new PublishOrder( $fileGenerator->getCache()->load()->getFilename(),$fileGenerator->getPublicFilename(),$this->file->lastchangeDate) ); - $publisher->publish(); - - $this->addNoticeFor($this->file,'PUBLISHED',[],'Published items:'."\n".implode("\n",$publisher->getDestinationFilenames()) ); - } - - - - function getCompressionTypes() + protected function getCompressionTypes() { $compressionTypes = array(); if ( function_exists('gzencode' ) ) $compressionTypes[] = 'gz'; @@ -552,7 +82,7 @@ class FileAction extends ObjectAction return $compressionTypes; } - function getArchiveTypes() + protected function getArchiveTypes() { $archiveTypes = array(); $archiveTypes[] = 'tar'; @@ -560,26 +90,4 @@ class FileAction extends ObjectAction return $archiveTypes; } - - - public function removeView() - { - $this->setTemplateVar( 'name',$this->file->filename ); - } - - - public function removePost() - { - if ( $this->getRequestVar('delete') != '' ) - { - $this->file->delete(); - $this->addNotice('template', 0, $this->file->filename, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice('template', 0, $this->file->filename, 'CANCELED', Action::NOTICE_WARN); - } - } -} - -?>- \ No newline at end of file +}+ \ No newline at end of file diff --git a/modules/cms/action/FolderAction.class.php b/modules/cms/action/FolderAction.class.php @@ -70,662 +70,6 @@ class FolderAction extends ObjectAction } - public function createfolderPost( $name ) - { - $description = $this->getRequestVar('description'); - - $f = new Folder(); - $f->projectid = $this->folder->projectid; - $f->languageid = $this->folder->languageid; - $f->name = $name; - $f->filename = BaseObject::urlify( $name ); - $f->desc = $description; - $f->parentid = $this->folder->objectid; - - $f->add(); - $f->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor($f, Messages::ADDED); - // Die neue Folder-Id (wichtig für API-Aufrufe). - $this->setTemplateVar('objectid',$f->objectid); - - $this->folder->setTimestamp(); // Zeitstempel setzen. - } - - - - 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); - return; - } - - $file->desc = $description; - $file->filename = BaseObject::urlify( $name ); - $file->name = !empty($name)?$name:basename($url); - $file->size = strlen($http->body); - $file->value = $http->body; - $file->parentid = $this->folder->objectid; - $file->projectid = $this->folder->projectid; - } - elseif ( $this->hasRequestVar('value') ) - { - // New file is inserted. - $file->filename = BaseObject::urlify( $filename ); - $file->value = $this->getRequestVar('value'); - $file->size = strlen($file->value); - $file->parentid = $this->folder->objectid; - $file->projectid = $this->folder->projectid; - } - else - { - // File was uploaded. - $upload = new Upload('file'); - - try - { - $upload->processUpload(); - } - catch( \Exception $e ) - { - // technical error. - throw new \RuntimeException('Exception while processing the upload: '.$e->getMessage(), 0, $e); - - //throw new \ValidationException( $upload->parameterName ); - } - - $file->desc = $description; - $file->filename = BaseObject::urlify( $upload->filename ); - $file->name = !empty($name)?$name:$upload->filename; - $file->extension = $upload->extension; - $file->size = $upload->size; - $file->parentid = $this->folder->objectid; - $file->projectid = $this->folder->projectid; - - $file->value = $upload->value; - } - - $file->add(); // Datei hinzufuegen - $file->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor( $file, Messages::ADDED ); - $this->setTemplateVar('objectid',$file->objectid); - - $this->folder->setTimestamp(); - } - - - - public function createimagePost() - { - $type = $this->getRequestVar('type' ); - $name = $this->getRequestVar('name' ); - $filename = $this->getRequestVar('filename' ); - $description = $this->getRequestVar('description'); - - $image = new Image(); - - // 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); - return; - } - - $image->desc = $description; - $image->filename = BaseObject::urlify( basename($url) ); - $image->name = !empty($name)?$name:basename($url); - $image->size = strlen($http->body); - $image->value = $http->body; - $image->parentid = $this->folder->objectid; - } - else - { - $upload = new Upload(); - - try - { - $upload->processUpload(); - } - catch( \Exception $e ) - { - // technical error. - throw new \RuntimeException('Exception while processing the upload: '.$e->getMessage(), 0, $e); - - //throw new \ValidationException( $upload->parameterName ); - } - - $image->desc = $description; - $image->filename = BaseObject::urlify( $upload->filename ); - $image->name = !empty($name)?$name:$upload->filename; - $image->extension = $upload->extension; - $image->size = $upload->size; - $image->parentid = $this->folder->objectid; - $image->projectid = $this->folder->projectid; - - $image->value = $upload->value; - } - - $image->add(); // Datei hinzufuegen - $this->addNoticeFor( $image, Messages::ADDED ); - $image->setNameForAllLanguages( $name,$description ); - $this->setTemplateVar('objectid',$image->objectid); - - $this->folder->setTimestamp(); - } - - - - public function createtextPost() - { - $name = $this->getRequestVar('name' ); - $description = $this->getRequestVar('description'); - - $text = new Text(); - $text->parentid = $this->folder->objectid; - $text->projectid = $this->folder->projectid; - - // 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->addNotice($http->error); - // TODO: What to do with $http->error ? - throw new ValidationException('url',Messages::COMMON_VALIDATION_ERROR); - } - - $text->filename = BaseObject::urlify( basename($url) ); - $text->size = strlen($http->body); - $text->value = $http->body; - } - else - { - $upload = new Upload(); - - if ( $upload->isAvailable() ) { - - try - { - $upload->processUpload(); - } - catch( \Exception $e ) - { - // TODO: make a UIException? - throw $e; - } - - $text->filename = BaseObject::urlify( $upload->filename ); - $text->extension = $upload->extension; - $text->size = $upload->size; - - $text->value = $upload->value; - } - else { - $text->filename = $this->getRequestVar('filename'); - $text->extension = $this->getRequestVar('extension'); - $text->value = $this->getRequestVar('text'); - $text->size = strlen( $text->value ); - } - } - - $text->add(); // Datei hinzufuegen - $text->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor($text, Messages::ADDED); - $this->setTemplateVar('objectid',$text->objectid); - - $this->folder->setTimestamp(); - } - - - - public function createlinkPost( $name ) - { - $description = $this->getRequestVar('description'); - - $link = new Link(); - $link->filename = BaseObject::urlify( $name ); - $link->parentid = $this->folder->objectid; - - $link->linkedObjectId = $this->getRequestVar('targetobjectid'); - $link->projectid = $this->folder->projectid; - - $link->add(); - $link->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor( $link, Messages::ADDED); - $this->setTemplateVar('objectid',$link->objectid); - - $this->folder->setTimestamp(); - } - - public function createurlPost( $name ) - { - $description = $this->getRequestVar('description'); - $filename = $this->getRequestVar('filename' ); - - $url = new Url(); - $url->filename = BaseObject::urlify( $name ); - $url->parentid = $this->folder->objectid; - $url->projectid = $this->folder->projectid; - - $url->url = $this->getRequestVar('url'); - - $url->add(); - $url->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor( $url, Messages::ADDED ); - $this->setTemplateVar('objectid',$url->objectid); - - $this->folder->setTimestamp(); - } - - - - public function createpagePost( $name ) - { - $filename = $this->getRequestVar('filename' ); - $description = $this->getRequestVar('description'); - - $page = new Page(); - $page->filename = BaseObject::urlify( $name ); - $page->templateid = $this->getRequestVar('templateid'); - $page->parentid = $this->folder->objectid; - $page->projectid = $this->folder->projectid; - - - $page->add(); - $page->setNameForAllLanguages( $name,$description ); - - $this->addNoticeFor( $page, Messages::ADDED ); - $this->setTemplateVar('objectid',$page->objectid); - - $this->folder->setTimestamp(); - } - - - - /** - * Reihenfolge von Objekten aendern. - */ - public function orderPost() - { - $ids = $this->folder->getObjectIds(); - $seq = 0; - - $order = explode(',',$this->getRequestVar('order') ); - - foreach( $order as $objectid ) - { - if ( ! is_numeric($objectid) || ! in_array($objectid,$ids) ) - { - throw new \LogicException('Object-Id '.$objectid.' is not in this folder any more'); - } - $seq++; // Sequenz um 1 erhoehen - - $o = new BaseObject( $objectid ); - $o->setOrderId( $seq ); - - unset( $o ); // Selfmade Garbage Collection :-) - } - - $this->addNoticeFor($this->folder, Messages::SEQUENCE_CHANGED); - $this->folder->setTimestamp(); - } - - - - /** - * Verschieben/Kopieren/Loeschen/Verknuepfen von mehreren Dateien in diesem Ordner - */ - public function advancedPost() - { - $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::ACL_CREATE_LINK ) ) || - ( ( $type=='move' || $type == 'copy' ) && - ( $f->hasRight(Acl::ACL_CREATE_FOLDER) || $f->hasRight(Acl::ACL_CREATE_FILE) || $f->hasRight(Acl::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 BaseObject( $id ); - $o->load(); - - // Fuer die gewuenschte Aktion muessen pro Objekt die entsprechenden Rechte - // vorhanden sein. - if ( $type == 'copy' && $o->hasRight( Acl::ACL_READ ) || - $type == 'move' && $o->hasRight( Acl::ACL_WRITE ) || - $type == 'link' && $o->hasRight( Acl::ACL_READ ) || - $type == 'archive' && $o->hasRight( Acl::ACL_READ ) || - $type == 'delete' && $o->hasRight( Acl::ACL_DELETE ) ) - $objectList[ $id ] = $o->getProperties(); - else - $this->addNotice($o->getType(), 0, $o->name, 'no_rights', Action::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 BaseObject( $id ); - $o->load(); - - if ( $o->isFile ) - { - $file = new File($id); - $file->load(); - - // Datei dem Archiv hinzufügen. - $info = array(); - $info['name'] = $file->filename(); - $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(), 0, $o->name, 'NOTHING_DONE', Action::NOTICE_WARN); - } - - } - - // TAR speichern. - $tarFile = new File(); - $tarFile->name = \cms\base\Language::lang('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 BaseObject( $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(), 0, $o->name, 'MOVED', 'ok'); - $o->setParentId( $targetObjectId ); - } - else - { - $this->addNotice($o->getType(), 0, $o->name, 'ERROR', 'error'); - } - } - else - { - $o->setParentId( $targetObjectId ); - $this->addNotice($o->getType(), 0, $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(), 0, $o->name, 'CANNOT_COPY_FOLDER', 'error'); - break; - - case 'file': - $f = new File( $id ); - $f->load(); - $f->filename = ''; - $f->name = \cms\base\Language::lang('COPY_OF').' '.$f->name; - $f->parentid = $targetObjectId; - $f->add(); - $f->copyValueFromFile( $id ); - - $this->addNotice($o->getType(), 0, $o->name, 'COPIED', 'ok'); - break; - - case 'page': - $p = new Page( $id ); - $p->load(); - $p->filename = ''; - $p->name = \cms\base\Language::lang('COPY_OF').' '.$p->name; - $p->parentid = $targetObjectId; - $p->add(); - $p->copyValuesFromPage( $id ); - $this->addNotice($o->getType(), 0, $o->name, 'COPIED', 'ok'); - break; - - case 'link': - $l = new Link( $id ); - $l->load(); - $l->filename = ''; - $l->name = \cms\base\Language::lang('COPY_OF').' '.$l->name; - $l->parentid = $targetObjectId; - $l->add(); - $this->addNotice($o->getType(), 0, $o->name, 'COPIED', 'ok'); - break; - - default: - throw new \LogicException('fatal: what type to delete?'); - } - $notices[] = \cms\base\Language::lang('COPIED'); - break; - - case 'link': - - if ( $o->isFile || - $o->isImage || - $o->isText || - $o->isPage ) // Nur Seiten oder Dateien sind verknuepfbar - { - $link = new Link(); - $link->parentid = $targetObjectId; - - $link->linkedObjectId = $id; - $link->isLinkToObject = true; - $link->name = \cms\base\Language::lang('LINK_TO').' '.$o->name; - $link->add(); - $this->addNotice($o->getType(), 0, $o->name, 'LINKED', 'ok'); - } - else - { - $this->addNotice($o->getType(), 0, $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(), 0, $o->name, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice($o->getType(), 0, $o->name, 'NOTHING_DONE', Action::NOTICE_WARN); - } - - break; - - default: - $this->addNotice($o->getType(), 0, $o->name, 'ERROR', 'error'); - } - - } - } - - $this->folder->setTimestamp(); - } - - - - - /** - * Alias für Methode 'create'. - */ - public function addView() - { - $this->nextSubAction('create'); - } - - - /** - * Alias für Methode 'create'. - */ - public function addPost() - { - $this->nextSubAction('create'); - } - - - public function createView() - { - $this->setTemplateVar('mayCreateFolder',$this->folder->hasRight( Acl::ACL_CREATE_FOLDER ) ); - $this->setTemplateVar('mayCreateFile' ,$this->folder->hasRight( Acl::ACL_CREATE_FILE ) ); - $this->setTemplateVar('mayCreateText' ,$this->folder->hasRight( Acl::ACL_CREATE_FILE ) ); - $this->setTemplateVar('mayCreateImage' ,$this->folder->hasRight( Acl::ACL_CREATE_FILE ) ); - $this->setTemplateVar('mayCreatePage' ,$this->folder->hasRight( Acl::ACL_CREATE_PAGE ) ); - $this->setTemplateVar('mayCreateUrl' ,$this->folder->hasRight( Acl::ACL_CREATE_LINK ) ); - $this->setTemplateVar('mayCreateLink' ,$this->folder->hasRight( Acl::ACL_CREATE_LINK ) ); - - } - - - - public function createfolderView() - { - $this->setTemplateVar('objectid' ,$this->folder->objectid ); - $this->setTemplateVar('languageid',$this->folder->languageid ); - } @@ -762,52 +106,6 @@ class FolderAction extends ObjectAction return min($sizes); // Using the minimum of all 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 ); - } - - - /** - * Hochladen einer Datei. - * - */ - public function createimageView() - { - // Maximale Dateigroesse. - $maxSizeBytes = $this->maxFileSize(); - $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' ); - $this->setTemplateVar('maxlength',$maxSizeBytes ); - - $this->setTemplateVar('objectid',$this->folder->objectid ); - } - - - /** - * Hochladen einer Datei. - * - */ - public function createtextView() - { - // 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> @@ -817,7 +115,7 @@ class FolderAction extends ObjectAction * @param String Abgek�rzter Bytewert * @return Integer Byteanzahl */ - private function stringToBytes($val) + protected function stringToBytes($val) { $val = trim($val); $last = strtolower($val[strlen($val)-1]); @@ -836,444 +134,4 @@ class FolderAction extends ObjectAction return intval($val); } - - - public function createlinkView() - { - $this->setTemplateVar('objectid' ,$this->folder->objectid ); - } - - - public function createurlView() - { - } - - - public function createpageView() - { - $project = new Project( $this->folder->projectid ); - - $all_templates = $project->getTemplates(); - $this->setTemplateVar('templates' ,$all_templates ); - $this->setTemplateVar('objectid' ,$this->folder->objectid ); - - if ( count($all_templates) == 0 ) - $this->addNotice('folder', 0, $this->folder->name, 'NO_TEMPLATES_AVAILABLE', Action::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 editView() - { - if ( ! $this->folder->isRoot ) - $this->setTemplateVar('parentid',$this->folder->parentid); - - $list = array(); - - // Schleife ueber alle Objekte in diesem Ordner - foreach( $this->folder->getObjects() as $o ) - { - /* @var $o BaseObject */ - - $id = $o->objectid; - - if ( $o->hasRight(Acl::ACL_READ) ) - { - $list[$id]['name'] = \util\Text::maxLength($o->name, 30); - $list[$id]['filename'] = \util\Text::maxLength($o->filename, 20); - $list[$id]['desc'] = \util\Text::maxLength($o->desc, 30); - if ( $list[$id]['desc'] == '' ) - $list[$id]['desc'] = \cms\base\Language::lang('NO_DESCRIPTION_AVAILABLE'); - $list[$id]['desc'] = $list[$id]['desc'].' - '.\cms\base\Language::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() - { - if ( ! $this->folder->isRoot ) - $this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid)); - - $this->setTemplateVar('writable',$this->folder->hasRight(Acl::ACL_WRITE) ); - - $list = array(); - - // Schleife ueber alle Objekte in diesem Ordner - foreach( $this->folder->getObjects() as $o ) - { - /* @var $o BaseObject */ - $id = $o->objectid; - - if ( $o->hasRight(Acl::ACL_READ) ) - { - $list[$id]['name'] = \util\Text::maxLength($o->name, 30); - $list[$id]['filename'] = \util\Text::maxLength($o->filename, 20); - $list[$id]['desc'] = \util\Text::maxLength($o->desc, 30); - if ( $list[$id]['desc'] == '' ) - $list[$id]['desc'] = \cms\base\Language::lang('NO_DESCRIPTION_AVAILABLE'); - $list[$id]['desc'] = $list[$id]['desc'].' - '.\cms\base\Language::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 advancedView() - { - $this->setTemplateVar('writable',$this->folder->hasRight(Acl::ACL_WRITE) ); - - $list = array(); - - // Schleife ueber alle Objekte in diesem Ordner - foreach( $this->folder->getObjects() as $o ) - { - /* @var $o BaseObject */ - $id = $o->objectid; - - if ( $o->hasRight(Acl::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'] = \cms\base\Language::lang('NO_DESCRIPTION_AVAILABLE'); - $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc']; - - $list[$id]['type'] = $o->getType(); - - $list[$id]['icon'] = $o->getType(); - - $list[$id]['url' ] = Html::url($o->getType(),'',$id); - $list[$id]['date'] = date( \cms\base\Language::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::ACL_WRITE) ) - { - // Alle anderen Ordner ermitteln - $otherfolder = array(); - $project = new Project( $this->folder->projectid ); - foreach( $project->getAllFolders() as $id ) - { - $f = new Folder( $id ); - if ( $f->hasRight( Acl::ACL_WRITE ) ) - $otherfolder[$id] = Startup::FILE_SEP.implode( Startup::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::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); - - $project = new Project($this->folder->projectid); - $rootFolder = new Folder( $project->getRootObjectId() ); - $rootFolder->load(); - - $this->setTemplateVar('properties' ,$this->folder->getProperties() ); - $this->setTemplateVar('rootfolderid' ,$rootFolder->id ); - $this->setTemplateVar('rootfoldername',$rootFolder->name); - } - - - - - public function rootView() - { - $project = new Project($this->folder->projectid); - $rootFolder = new Folder( $project->getRootObjectId() ); - $rootFolder->load(); - - $this->setTemplateVar('rootfolderid' ,$rootFolder->id ); - $this->setTemplateVar('rootfoldername',$rootFolder->name); - } - - - - /** - * Reihenfolge bearbeiten. - */ - public function orderView() - { - $list = array(); - - // Schleife ueber alle Objekte in diesem Ordner - foreach( $this->folder->getObjects() as $o ) - { - /* @var $o BaseObject */ - $id = $o->objectid; - $name = $o->getDefaultName(); - - if ( $o->hasRight(Acl::ACL_READ) ) - { - $list[$id]['id' ] = $id; - $list[$id]['name'] = $name->name; - $list[$id]['filename'] = $o->filename; - $list[$id]['desc'] = 'ID '.$id.' - '.$name->description; - - $list[$id]['type'] = $o->getType(); - $list[$id]['icon'] = $o->getType(); - - $list[$id]['date'] = $o->lastchangeDate; - $list[$id]['user'] = $o->lastchangeUser; - - $last_objectid = $id; - } - } - - $this->setTemplateVar('object' ,$list ); - $this->setTemplateVar('act_objectid',$this->folder->id); - } - - - - - public function pubView() - { - // Schalter nur anzeigen, wenn sinnvoll - - // TODO texts, urls.... - $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::ACL_PUBLISH ) ) - throw new \util\exception\SecurityException('no rights for publish'); - - $project = $this->folder->getProject(); - $project->load(); - - // Nothing is written to the session from this point. so we should free the session. - Session::close(); - - $publisher = new Publisher( $project->projectid ); - - // Create a list of all folders. - $folderList = [ $this->folder->objectid ]; - - // Add all subfolders to the list - if ( $this->request->hasRequestVar('subdirs') ) - $folderList = array_merge( $folderList, $this->folder->getAllSubFolderIds() ); - - foreach( $folderList as $folderId ) { - - $folder = new Folder( $folderId ); - $folder->load(); - - // Publish all pages - if ( $this->request->hasRequestVar('pages' ) ) { - - foreach( $folder->getPages() as $pageObjectId ) { - - foreach( $project->getModelIds() as $modelId ) { - - foreach( $project->getLanguageIds() as $languageId ) { - - $pageContext = new PageContext( $pageObjectId, Producer::SCHEME_PUBLIC ); - $pageContext->modelId = $modelId; - $pageContext->languageId = $languageId; - - $pageGenerator = new PageGenerator( $pageContext ); - - $publisher->addOrderForPublishing( new PublishOrder( $pageGenerator->getCache()->load()->getFilename(),$pageGenerator->getPublicFilename(), 0 ) ); - } - } - } - } - - // Publish all files - if ( $this->hasRequestVar('files' ) ) { - - foreach( $folder->getFiles() as $fileid ) { - - $fileGenerator = new FileGenerator( new FileContext( $fileid, Producer::SCHEME_PUBLIC)); - $publisher->addOrderForPublishing( new PublishOrder( $fileGenerator->getCache()->load()->getFilename(),$fileGenerator->getPublicFilename(),0 ) ); - - } - } - - $publisher->publish(); - } - - - - - // Cleanup the target directory (if supported by the underlying target) - if ( $this->hasRequestVar('clean') ) - $publisher->cleanOlderThan( Startup::getStartTime() ); - - - $this->addNoticeFor( $this->folder, - 'PUBLISHED', - array(), - implode("\n",$publisher->getDestinationFilenames() ) - ); - } - - - - /** - * Shows the folder content as html. - */ - public function showView() { - - // Angabe Content-Type - header('Content-Type: text/html' ); - - header('X-Folder-Id: ' .$this->folder->folderid ); - header('X-Id: ' .$this->folder->id ); - header('Content-Description: '.$this->folder->filename() ); - - echo '<html><body>'; - echo '<h1>'.$this->folder->filename.'</h1>'; - echo '<ul>'; - - // Schleife ueber alle Objekte in diesem Ordner - foreach( $this->folder->getObjects() as $o ) - { - /* @var $o BaseObject */ - $id = $o->objectid; - - if ( $o->hasRight(Acl::ACL_READ) ) - { - echo '<li><a href="'. Html::url($o->getType(),'',$id).'">'.$o->filename.'</a></li>'; - - //echo date( \cms\base\Language::lang('DATE_FORMAT'),$o->lastchangeDate ); - //echo $o->lastchangeUser; - } - } - - echo '</ul>'; - echo '</body></html>'; - - exit; - } - - - - public function removeView() - { - $this->setTemplateVar( 'name',$this->folder->filename ); - $this->setTemplateVar( 'hasChildren', $this->folder->hasChildren() ); - } - - - public function removePost() - { - if ( $this->hasRequestVar( 'withChildren')) - $this->folder->deleteAll(); // Delete with children - else - if ( $this->folder->hasChildren() ) - throw new \util\exception\ValidationException("withChildren",Messages::CONTAINS_CHILDREN); - else - $this->folder->delete(); // Only delete current folder. - - $this->addNoticeFor($this->folder, Messages::DELETED); - } - } \ No newline at end of file diff --git a/modules/cms/action/GroupAction.class.php b/modules/cms/action/GroupAction.class.php @@ -57,245 +57,4 @@ class GroupAction extends BaseAction $this->setTemplateVar( 'groupid',$this->group->groupid ); } - - - function removePost() - { - if ( $this->hasRequestVar('confirm') ) - { - $this->group->delete(); - - $this->addNotice('group', 0, $this->group->name, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice('group', 0, $this->group->name, 'NOTHING_DONE', Action::NOTICE_WARN); - } - } - - - - function removeView() - { - $this->setTemplateVars( $this->group->getProperties() ); - } - - - - public function propPost() - { - if ( ! $this->getRequestVar('name') ) - throw new \util\exception\ValidationException('name'); - - $this->group->name = $this->getRequestVar('name'); - $this->group->save(); - - $this->addNotice('group', 0, $this->group->name, 'SAVED', 'ok'); - } - - - 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', 0, $this->group->name, 'USER_ADDED_TO_GROUP', Action::NOTICE_OK, array('count' => count($userid))); - } - elseif( intval($userid) > 0 ) - { - // Nur 1 Benutzer hinzuf�gen. - $this->group->addUser( intval($userid) ); - $this->addNotice('group', 0, $this->group->name, 'USER_ADDED_TO_GROUP', OK_NOTICE_OK, array('count' => '1')); - } - else - { - // Es wurde kein Benutzer ausgew�hlt. - $this->addNotice('group', 0, $this->group->name, 'NOTHING_DONE', Action::NOTICE_WARN); - } - } - - - - /** - * Einen Benutzer aus der Gruppe entfernen. - */ - function deluser() - { - $this->group->delUser( intval($this->getRequestVar('userid')) ); - - $this->addNotice('group', 0, $this->group->name, 'DELETED', Action::NOTICE_OK); - } - - - - /** - * Liste aller Gruppen. - */ - function listingView() - { - $list = array(); - - foreach( Group::getAll() as $id=>$name ) - { - $list[$id] = array(); - $list[$id]['name'] = $name; - } - - $this->setTemplateVar('el', $list); - } - - - function infoView() - { - $this->setTemplateVars( $this->group->getProperties() ); - $this->setTemplateVar( 'users',$this->group->getUsers() ); - } - - - - function propView() - { - $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); - } - - - 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', 0, $name, 'ADDED'); - } - - if ( $hasUser && !$this->hasRequestVar('user'.$id) ) - { - $this->group->delUser($id); - $this->addNotice('user', 0, $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'] = \cms\base\Language::lang('ALL_LANGUAGES'); - } - - - $o = new BaseObject($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() ); - } - - - } \ No newline at end of file diff --git a/modules/cms/action/GrouplistAction.class.php b/modules/cms/action/GrouplistAction.class.php @@ -40,54 +40,4 @@ class GrouplistAction extends BaseAction } - /** - * 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', 0, $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/action/ImageAction.class.php b/modules/cms/action/ImageAction.class.php @@ -44,106 +44,6 @@ class ImageAction extends FileAction parent::setBaseObject($image); } - - /** - * Anzeigen des Inhaltes - */ - public function sizeView() - { - $this->setTemplateVars( $this->image->getProperties() ); - - $format = $this->imageFormat(); - - if ( $format == 0 ) - { - $this->addNotice('image', 0, '', 'IMAGE_RESIZING_UNKNOWN_TYPE', Action::NOTICE_WARN); - } - - $formats = $this->imageFormats(); - - if ( empty($formats) ) - $this->addNotice('image', 0, '', 'IMAGE_RESIZING_NOT_AVAILABLE', Action::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->image->getImageSize(); - $this->setTemplateVar('width' ,$this->image->width ); - $this->setTemplateVar('height',$this->image->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 Image($this->image->objectid); - $imageFile->load(); - $imageFile->name = \cms\base\Language::lang('copy_of').' '.$imageFile->name; - $imageFile->desription = \cms\base\Language::lang('copy_of').' '.$imageFile->description; - $imageFile->filename = $imageFile->filename.'_resized_'.time(); - $imageFile->add(); - $imageFile->copyValueFromFile( $this->image->objectid ); - } - else - { - $imageFile = $this->image; - } - - 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(), 0, $imageFile->name, 'IMAGE_RESIZED', 'ok'); - } - protected function imageFormat() @@ -169,7 +69,7 @@ class ImageAction extends FileAction - private function imageExt() + protected function imageExt() { switch( $this->imageFormat() ) { @@ -203,14 +103,5 @@ class ImageAction extends FileAction } - /** - */ - public function previewView() - { - $this->setTemplateVar('url', Html::url('image','show',$this->image->objectid ) ); - - parent::previewView(); - } - } diff --git a/modules/cms/action/LanguageAction.class.php b/modules/cms/action/LanguageAction.class.php @@ -57,81 +57,5 @@ class LanguageAction extends BaseAction } - /** - * Setzen der Sprache als Standardsprache. - * Diese Sprache wird benutzt beim Ausw?hlen des Projektes sowie - * als Default-Sprache bei mehrsprachigen Webseiten ("content-negotiation") - */ - public function setdefaultPost() - { - $this->language->setDefault(); - - $this->addNotice('language', 0, $this->language->name, 'DONE', Action::NOTICE_OK); - } - - - - /** - * Anzeigen der L�schbest�tigungs-Maske. - */ - public function removeView() - { - $this->setTemplateVar('name' ,$this->language->name ); - } - - - /** - * L�schen der Sprache. - */ - public function removePost() - { - if ( $this->getRequestVar('confirm') == '1' ) - $this->language->delete(); - } - - - /** - * Speichern der Sprache - */ - function propPost() - { - if ( $this->hasRequestVar('name') ) - { - $this->language->name = $this->getRequestVar('name' ); - $this->language->isoCode = $this->getRequestVar('isocode'); - } - else - { - $countries = Configuration::subset('countries'); - $iso = $this->getRequestVar('isocode'); - $this->language->name = $countries->get($iso,$iso); - $this->language->isoCode = strtolower( $iso ); - } - - if ( $this->hasRequestVar('is_default') ) - $this->language->setDefault(); - - $this->language->save(); - $this->addNotice('language', 0, $this->language->name, 'DONE', Action::NOTICE_OK); - } - - - - public function infoView() - { - $this->setTemplateVars( $this->language->getProperties() ); - } - - - function propView() - { - $this->setTemplateVar('isocode' ,$this->language->isoCode ); - $this->setTemplateVar('name' ,$this->language->name ); - $this->setTemplateVar('is_default',$this->language->isDefault ); - } - - - - } \ No newline at end of file diff --git a/modules/cms/action/LanguagelistAction.class.php b/modules/cms/action/LanguagelistAction.class.php @@ -58,88 +58,4 @@ class LanguagelistAction extends BaseAction $this->project = new Project( $this->request->getRequestId()); } - - - - public function showView() - { - $countryList = Configuration::Conf()->get('countries',[]); - - $list = array(); - - $this->setTemplateVar('act_languageid',0 ); - - - - 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; - $list[$id]['id' ] = $id; - - $list[$id]['is_default'] = $l->isDefault; - - $list[$id]['select_url'] = Html::url( 'index','language',$id ); - } - - $this->setTemplateVar('el',$list); - } - - - - function editView() - { - $this->nextSubAction('show'); - } - - - - - /** - * Sprache hinzufuegen - */ - function addView() - { - $countryList = Configuration::subset('countries')->getConfig(); - - foreach( $this->project->getLanguageIds() as $id ) - { - - $l = new Language( $id ); - $l->load(); - - unset( $countryList[$l->isoCode] ); - } - - asort( $countryList ); - - $this->setTemplateVar('isocodes' ,$countryList ); - $this->setTemplateVar('isocode' ,'' ); - } - - - /** - * Adding a language. - */ - public function addPost() - { - $countryList = Configuration::Conf()->get('countries',[]); - - $iso = $this->getRequestVar('isocode'); - $language = new Language(); - $language->projectid = $this->project->projectid; - $language->isoCode = $iso; - $language->name = @$countryList[$iso]; - $language->add(); - - $this->addNoticeFor($language, Messages::ADDED); - } - - } \ No newline at end of file diff --git a/modules/cms/action/LinkAction.class.php b/modules/cms/action/LinkAction.class.php @@ -65,77 +65,4 @@ class LinkAction extends ObjectAction parent::setBaseObject( $link ); } - - - - /** - * Abspeichern der Eigenschaften - */ - function editPost() - { - $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); - $this->link->save(); - - $this->addNotice('link', 0, $this->link->name, 'SAVED', Action::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 ); - } - - - - - - public function removeView() - { - $this->setTemplateVar( 'name',$this->link->filename ); - } - - - public function removePost() - { - if ($this->getRequestVar('delete') != '') { - $this->link->delete(); - $this->addNotice('link', 0, $this->link->filename, 'DELETED', Action::NOTICE_OK); - } else { - $this->addNotice('link', 0, $this->link->filename, 'CANCELED', Action::NOTICE_WARN); - } - } - - - public function showView() - { - header('Content-Type: text/html' ); - - header('X-Link-Id: ' .$this->link->linkid ); - header('X-Id: ' .$this->link->id ); - header('Content-Description: '.$this->link->filename() ); - - echo '<html><body>'; - echo '<h1>'.$this->link->filename.'</h1>'; - echo '<hr />'; - - try { - $o = new BaseObject( $this->link->linkedObjectId ); - $o->load(); - echo '<a href="'.Html::url($o->getType(),'show',$o->objectid).'">'.$o->filename.'</a>'; - } - catch( \util\exception\ObjectNotFoundException $e ) { - echo '-'; - } - - echo '</body></html>'; - - exit; - } - } diff --git a/modules/cms/action/LoginAction.class.php b/modules/cms/action/LoginAction.class.php @@ -70,7 +70,7 @@ class LoginAction extends BaseAction * @return bool * @throws ObjectNotFoundException */ - private function checkLogin($name, $pw, $pw1, $pw2 ) + protected function checkLogin($name, $pw, $pw1, $pw2 ) { Logger::debug( "Login user: '$name'.'" ); @@ -166,123 +166,6 @@ class LoginAction extends BaseAction } - public function oidcView() { - - if ( $this->hasRequestVar("id")) { - $providerName = $this->request->getRequestVar('id',RequestParams::FILTER_ALPHANUM); - Session::set(Session::KEY_OIDC_PROVIDER,$providerName); - }else { - $providerName = Session::get( Session::KEY_OIDC_PROVIDER); - } - - - $providerConfig = Configuration::subset(['security','oidc','provider',$providerName]); - - $oidc = new OpenIDConnectClient(); - $oidc->setProviderURL ( $providerConfig->get('url' )); - $oidc->setIssuer ( $providerConfig->get('url' )); - $oidc->setClientID ( $providerConfig->get('client_id' )); - $oidc->setClientSecret( $providerConfig->get('client_secret')); - - try { - $oidc->authenticate(); - $subjectIdentifier = $oidc->requestUserInfo('sub'); - - $user = User::loadWithName( $subjectIdentifier,User::AUTH_TYPE_OIDC,$providerName ); - - if ( ! $user ) { - // Create user - $user = new User(); - $user->name = $subjectIdentifier; - $user->type = User::AUTH_TYPE_OIDC; - $user->issuer = $providerName; - $user->add(); - - } - - Session::setUser( $user ); - - } catch( Exception $e) { - throw new \RuntimeException('OpenId-Connect authentication failed',0,$e); - } - - header( 'Location: ./'); - } - - - - /** - * Anzeigen der Loginmaske. - * - * Es wird nur die Loginmaske angezeigt. - * @throws UIException - */ - function loginView() - { - $loginConfig = Configuration::subset('security'); - $securityConfig = Configuration::subset('security'); - $authenticateConfig = Configuration::subset('authenticate'); - - $authenticateEnabled = $authenticateConfig->is('enable',true); - $oidcList = []; - - $oidcConfig = Configuration::subset(['security','oidc']); - - if ( $oidcConfig->is('enabled',true) ) { - foreach ( $oidcConfig->subset('provider')->subsets() as $name=>$providerConfig ) { - if ( $providerConfig->is('enabled',true)) { - $oidcList[ $name ] = $providerConfig->get('label',$name ); - } - } - } - - $this->setTemplateVar('enableUserPasswordLogin',$authenticateEnabled); - $this->setTemplateVar('enableOpenIdConnect' ,(boolean)$oidcList ); - $this->setTemplateVar('provider' ,$oidcList ); - - $databases = Configuration::subset('database')->subsets(); - - // Filter all enabled databases - $databases = array_filter( $databases, function($dbConfig) { - $dbConfig->is('enabled',true); - }); - - $dbids = []; - foreach( $databases as $dbid => $dbconf ) - { - // Getting the first not-null information about the connection. - $dbids[ $dbid ] = array_filter( array( - $dbconf->get('description'), - $dbconf->get('name'), - $dbconf->get('host'), - $dbconf->get('driver'), - $dbid))[0]; - } - - - if ( empty($dbids) ) - $this->addNotice('', 0, '', 'no_database_configuration', Action::NOTICE_WARN); - - $this->setTemplateVar( 'dbids',$dbids ); - - // Database was already connected in the Dispatcher. So we MUST have a db connection here. - $db = Session::getDatabase(); - $this->setTemplateVar('dbid',$db->id); - - $this->setTemplateVar('register' ,$loginConfig->get('register' )); - $this->setTemplateVar('send_password',$loginConfig->get('send_password')); - - // Versuchen, einen Benutzernamen zu ermitteln, der im Eingabeformular vorausgewählt wird. - $username = AuthRunner::getUsername('preselect'); - - $this->setTemplateVar('login_name',$username); - - // If the preselected user is the default user, we have a password. - if ( $username == $securityConfig->subset('default')->get('username') ) - $this->setTemplateVar('login_password', $securityConfig->subset('default')->get('password') ); - } - - /** * get all enabled databases. * @return Config[] @@ -363,618 +246,14 @@ class LoginAction extends BaseAction } - - /** - * Login. - * Zuerst wird die Datenbankverbindung aufgebaut und falls notwendig, aktualisiert. - */ - function loginPost() - { - Session::setUser(null); // Altes Login entfernen. - - if ( Configuration::subset('login')->is('nologin',false ) ) - throw new SecurityException('login disabled'); - - $loginName = $this->getRequestVar('login_name' ,RequestParams::FILTER_ALPHANUM); - $loginPassword = $this->getRequestVar('login_password',RequestParams::FILTER_ALPHANUM); - $newPassword1 = $this->getRequestVar('password1' ,RequestParams::FILTER_ALPHANUM); - $newPassword2 = $this->getRequestVar('password2' ,RequestParams::FILTER_ALPHANUM); - $token = $this->getRequestVar('user_token' ,RequestParams::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(); - - $passwordConfig = Configuration::subset(['security','password']); - - if ( $auth->login($loginName, $loginPassword,$token) || $auth->mustChangePassword ) - { - if ( $newPassword1 != $newPassword2 ) - { - $this->addValidationError('password1',Messages::PASSWORDS_DO_NOT_MATCH); - $this->addValidationError('password2',''); - return; - } - elseif ( strlen($newPassword1) < $passwordConfig->get('min_length',10) ) - { - $this->addValidationError('password1',Messages::PASSWORD_MINLENGTH,array('minlength'=>$passwordConfig->get('min_length',10))); - $this->addValidationError('password2',''); - return; - } - else - { - // Kennwoerter identisch und lang genug. - $user = User::loadWithName($loginName,User::AUTH_TYPE_INTERNAL); - $user->setPassword( $newPassword1,true ); - - // Das neue gesetzte Kennwort für die weitere Authentifizierung benutzen. - $loginPassword = $newPassword1; - } - } - else - { - // Anmeldung gescheitert. - $this->addNotice('user', 0, $loginName, 'LOGIN_FAILED', 'error', array('name' => $loginName)); - $this->addValidationError('login_name' ,''); - $this->addValidationError('login_password',''); - return; - } - } - - // Cookie setzen - $this->setCookie('or_username',$loginName ); - $this->setCookie('or_dbid' ,$this->getRequestVar('dbid')); - - // Jedes Authentifizierungsmodul durchlaufen, bis ein Login erfolgreich ist. - $result = AuthRunner::checkLogin('authenticate',$loginName,$loginPassword, $token ); - - $mustChangePassword = ( $result === Auth::STATUS_PW_EXPIRED ); - $tokenFailed = ( $result === Auth::STATUS_TOKEN_NEEDED ); - $loginOk = ( $result === Auth::STATUS_SUCCESS ); - - if ( $loginOk ) - { - Logger::info('Login successful for '.$loginName); - - try - { - // Benutzer über den Benutzernamen laden. - $user = User::loadWithName($loginName,User::AUTH_TYPE_INTERNAL,null); - $user->setCurrent(); - $user->updateLoginTimestamp(); - - 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 ( Configuration::subset(['security','newuser'])->is('autoadd',true ) ) - { - // 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( TextMessage::create('login failed for user ${name} from IP ${ip}', - [ - 'name' => $loginName, - 'ip' => $ip - ] - ) ); - - if ( $tokenFailed ) - { - // Token falsch. - $this->addNotice('user', 0, $loginName, 'LOGIN_FAILED_TOKEN_FAILED', 'error'); - $this->addValidationError('user_token',''); - } - elseif ( $mustChangePassword ) - { - // Anmeldung gescheitert, Benutzer muss Kennwort ?ndern. - $this->addNotice('user', 0, $loginName, 'LOGIN_FAILED_MUSTCHANGEPASSWORD', 'error'); - $this->addValidationError('password1',''); - $this->addValidationError('password2',''); - } - else - { - // Anmeldung gescheitert. - $this->addNotice('user', 0, $loginName, 'LOGIN_FAILED', 'error', array('name' => $loginName)); - $this->addValidationError('login_name' ,''); - $this->addValidationError('login_password',''); - } - - return; - } - else - { - - Logger::debug("Login successful for user '$loginName' from IP $ip"); - - if ( $this->hasRequestVar('remember') ) - { - // Cookie setzen - $this->setCookie('or_username',$user->name ); - $this->setCookie('or_token' ,$user->createNewLoginToken() ); - } - - // Anmeldung erfolgreich. - if ( Configuration::subset('security')->is('renew_session_login',false) ) - $this->recreateSession(); - - $this->addNoticeFor( $user,Messages::LOGIN_OK, array('name' => $user->getName() )); - - $config = Session::getConfig(); - $language = new \language\Language(); - $config['language'] = $language->getLanguage($user->language); - $config['language']['language_code'] = $user->language; - Session::setConfig( $config ); - } - - } - - - /** - * Logout current user. - */ - public function logoutPost() - { - if ( Configuration::subset('security')->is('renew_session_logout',false) ) - $this->recreateSession(); - - // Reading the login token cookie - list( $selector,$token ) = array_pad( explode('.',@$_COOKIE['or_token']),2,''); - - // Logout forces the removal of all login tokens - if ( $selector ) - $this->currentUser->deleteLoginToken( $selector ); - - // Cookie mit Logintoken löschen. - $this->setCookie('or_token' ,null ); - - Session::setUser(null); - - $this->addNoticeFor( $this->currentUser, Messages::LOGOUT_OK ); - } - - - - /** - * Benutzer meldet sich ab. - */ - function logoutView() - { - // There is no view for this action. - } - - - /** - * 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 userinfoView() - { - $user = Session::getUser(); - - $info = array('username' => $user->name, - 'fullname' => $user->fullname, - 'mail' => $user->mail, - 'telephone' => $user->tel, - 'style' => $user->style, - 'admin' => $user->isAdmin, - 'groups' => implode(',',$user->getGroups()), - 'description'=> $user->desc - ); - - $this->setTemplateVar('userinfo',$info); - } - - - function switchuser() - { - $user = Session::getUser(); - - if ( ! $user->isAdmin ) - throw new SecurityException("Switching the user is only possible for admins."); - - $this->recreateSession(); - - $newUser = new User( $this->getRequestId() ); - $newUser->load(); - - $newUser->setCurrent(); - } - - - /** - * @throws ObjectNotFoundException - * @deprecated not in use - */ - function show() - { - $conf = Configuration::rawConfig(); - - $user = Session::getUser(); - // Gast-Login - if ( ! is_object($user) ) - { - if ( $conf['security']['guest']['enable'] ) - { - $username = $conf['security']['guest']['user']; - $user = User::loadWithName($username,User::AUTH_TYPE_INTERNAL); - if ( $user->userid > 0 ) - $user->setCurrent(); - else - { - Logger::warn('Guest login failed, user not found: '.$username); - $this->addNotice('user', 0, $username, 'LOGIN_FAILED', Action::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']) ) - { - $ok = $this->checkLogin( $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] ); - } - - if ( ! $ok ) - { - header( 'WWW-Authenticate: Basic realm="'.Startup::TITLE.' - '.\cms\base\Language::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: - throw new \LogicException('Unknown auth-type: '.$conf['security']['login']['type'].'. Please check the configuration setting /security/login/type' ); - } - } - - if ( $user->mustChangePassword ) - { - $this->addNotice('user', 0, $user->name, 'PASSWORD_TIMEOUT', 'warn'); - $this->callSubAction( 'changepassword' ); // Zwang, das Kennwort zu ?ndern. - } - - // Seite ?ndert sich nur 1x pro Session - $this->lastModified( $user->loginDate ); - - } - - - - /** - * 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() - { - $conf = Configuration::rawConfig(); - - $this->setTemplateVar( 'dbids',$this->getSelectableDatabases() ); - - $db = DB::get(); - if ( $db ) - $this->setTemplateVar('actdbid',$db->id); - else - $this->setTemplateVar('actdbid',$conf['database-defaults']['default-id']); - - - - } - - - - public function registerPost() - { - $email_address = $this->getRequestVar('mail',RequestParams::FILTER_MAIL); - - if ( ! Mail::checkAddress($email_address) ) - { - $this->addValidationError('mail'); - return; - } - - Session::set( Session::KEY_REGISTER_MAIL,$email_address ); - - srand ((double)microtime()*1000003); - $registerCode = rand(); - - Session::set( Session::KEY_REGISTER_CODE,$registerCode ); - - - // E-Mail and die eingegebene Adresse verschicken - $mail = new Mail($email_address, - 'register_commit_code'); - $mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable - - if ( $mail->send() ) - { - $this->addNoticeFor( new User(), Messages::MAIL_SENT); - } - else - { - $this->addErrorFor( new User(),Messages::MAIL_NOT_SENT, [], $mail->error); - } - } - - - /** - * Benutzerregistierung. - * Benutzer hat Best?tigungscode erhalten und eingegeben. - */ - function registercodePost() - { - $conf = Configuration::rawConfig(); - - $origRegisterCode = Session::get( Session::KEY_REGISTER_CODE ); - $inputRegisterCode = $this->getRequestVar('code'); - - if ( $origRegisterCode != $inputRegisterCode ) - throw new ValidationException('code', Messages::CODE_NOT_MATCH ); // Validation code does not match. - - // Best?tigungscode stimmt ?berein. - // Neuen Benutzer anlegen. - - if ( !$this->hasRequestVar('username') ) - { - $this->addValidationError('username'); - return; - } - - $user = User::loadWithName( $this->getRequestVar('username'),User::AUTH_TYPE_INTERNAL ); - if ( $user ) - throw new ValidationException('username',Messages::USER_ALREADY_IN_DATABASE ); - - if ( strlen($this->getRequestVar('password')) < $conf['security']['password']['min_length'] ) - throw new ValidationException('password', Messages::PASSWORD_MINLENGTH/*,[ - 'minlength'=>$conf['security']['password']['min_length'] - ]*/); - - $newUser = new User(); - $newUser->name = $this->getRequestVar('username'); - $newUser->fullname = $newUser->name; - $newUser->add(); - - $newUser->mail = Session::get( Session::KEY_REGISTER_MAIL ); - $newUser->save(); - - $newUser->setPassword( $this->getRequestVar('password'),true ); - - $this->addNotice('user', 0, $newUser->name, 'user_added', 'ok'); - } - - - - /** - * Vergessenes Kennwort zusenden lassen. - */ - function passwordView() - { - // TODO: Attribut "Password" abfragen - - $this->setTemplateVar( 'dbids',$this->getSelectableDatabases() ); - - $db = DB::get(); - - if ( is_object($db) ) - $this->setTemplateVar('actdbid',$db->id); - else - $this->setTemplateVar('actdbid', Configuration::subset('database-default')->get('default-id','')); - } - - - - /** - * Einen Kennwort-Anforderungscode an den Benutzer senden. - */ - function passwordPost() - { - $username = $this->getRequestVar('username'); - if ( ! $username ) - throw new ValidationException('username'); - - $user = User::loadWithName( $username,User::AUTH_TYPE_INTERNAL ); - - Password::delay(); // Crypto-Wait - - if ( $user ) - { - srand ((double)microtime()*1000003); - $code = rand(); - $this->setSessionVar(Session::KEY_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->addNoticeFor( new User(), Messages::MAIL_SENT); - else - // Yes, the mail is not sent but we are faking a sent mail. - // so no one is able to check if the username exists (if the mail system is down) - $this->addNoticeFor( new User(), Messages::MAIL_SENT); - - $this->setSessionVar(Session::KEY_PASSWORD_COMMIT_NAME,$user->name); - } - else - { - // There is no user with this name. - // We are faking a sending mail, so no one is able to check if this username exists. - sleep(1); - $this->addNoticeFor( new User(), Messages::MAIL_SENT); - } - } - - - - /** - * Anzeige Formular zum Eingeben des Kennwort-Codes. - * - */ - function passwordcodeView() - { - - } - - - /** - * Neues Kennwort erzeugen und dem Benutzer zusenden. - */ - function passwordcodePost() - { - $username = $this->getSessionVar(Session::KEY_PASSWORD_COMMIT_NAME); - - if ( $this->getRequestVar("code")=='' || - $this->getSessionVar(Session::KEY_PASSWORD_COMMIT_CODE) != $this->getRequestVar("code") ) - { - $this->addValidationError('code','PASSWORDCODE_NOT_MATCH'); - return; - } - - $user = User::loadWithName( $username,User::AUTH_TYPE_INTERNAL ); - - if ( !$user->isValid() ) - { - // Benutzer konnte nicht geladen werden. - $this->addNotice('user', 0, $username, 'error', Action::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', 0, $username, 'mail_sent', Action::NOTICE_OK); - } - else - { - // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den - // Code per E-Mail erhalten hat. - $this->addNotice('user', 0, $username, 'error', Action::NOTICE_ERROR, array(), $eMail->error); - } - } - - /** * Erzeugt eine neue Sitzung. */ - function recreateSession() + protected function recreateSession() { session_regenerate_id(true); } - - - 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' =>'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); - - - - $this->setTemplateVar('time' ,date('r') ); - $this->setTemplateVar('os' ,php_uname('s') ); - $this->setTemplateVar('release' ,php_uname('r') ); - $this->setTemplateVar('machine' ,php_uname('m') ); - $this->setTemplateVar('version' , phpversion() ); - - $this->setTemplateVar('cms_name' , Configuration::Conf()->subset('application')->get('name' ) ); - $this->setTemplateVar('cms_version' , Configuration::Conf()->subset('application')->get('version' ) ); - $this->setTemplateVar('cms_operator', Configuration::Conf()->subset('application')->get('operator') ); - - $user = Session::getUser(); - if ( !empty($user) ) - { - $this->setTemplateVar('user_login' , $user->loginDate ); - $this->setTemplateVar('user_name' , $user->name ); - $this->setTemplateVar('user_fullname', $user->fullname ); - } - - } } diff --git a/modules/cms/action/ModelAction.class.php b/modules/cms/action/ModelAction.class.php @@ -53,81 +53,4 @@ class ModelAction extends BaseAction $this->model->load(); } - - - public function propView() - { - $this->setTemplateVar('name' ,$this->model->name ); - $this->setTemplateVar('is_default',$this->model->isDefault ); - } - - - - /** - * Speichern der Sprache - */ - public function propPost() - { - if ( $this->hasRequestVar('name') ) { - $this->model->name = $this->getRequestVar('name'); - $this->model->save(); - } - - if ( $this->hasRequestVar('is_default') ) - $this->model->setDefault(); - - $this->addNoticeFor( $this->model, Messages::DONE ); - } - - - /** - * 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->addNoticeFor( $this->model, Messages::DONE ); - } - else - { - $this->addWarningFor( $this->model, Messages::NOTHING_DONE); - } - } - - - - function setdefaultPost() - { - if ( !$this->userIsAdmin() ) exit(); - - $this->model->setDefault(); - - $this->addNoticeFor( $this->model, Messages::DONE ); - } - - - /** - * Bearbeiten der Variante. - * Ermitteln aller Eigenschaften der Variante. - */ - public function infoView() - { - $this->model->load(); - - $this->setTemplateVars( $this->model->getProperties() ); - } } \ No newline at end of file diff --git a/modules/cms/action/ModellistAction.class.php b/modules/cms/action/ModellistAction.class.php @@ -53,58 +53,5 @@ class ModellistAction extends BaseAction } - function showView() - { - $project = new Project( $this->project->projectid ); - - $list = array(); - foreach( $project->getModelIds() as $id ) - { - $m = new Model( $id ); - $m->load(); - - $list[$id]['id' ] = $id; - $list[$id]['name'] = $m->name; - - $list[$id]['is_default'] = $m->isDefault; - $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->getRequestVar('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 = \cms\base\Language::lang('MODEL').' '.$model->modelid; - $model->save(); - } - } - } \ No newline at end of file diff --git a/modules/cms/action/ObjectAction.class.php b/modules/cms/action/ObjectAction.class.php @@ -58,555 +58,6 @@ class ObjectAction extends BaseAction } - public function copyView() - { - $sourceObject = new BaseObject( $this->getRequestId()); - $sourceObject->load(); - - $targetFolder = new BaseObject( $this->getRequestVar('targetFolderId',RequestParams::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::ACL_WRITE) ) - { - $this->addNotice('folder', 0, $targetFolder->name, 'NOT_WRITABLE', Action::NOTICE_ERROR); - } - } - - - /** - * Ein Fileobjekt wird in einen neuen Ordner kopiert oder verschoben. - */ - public function copyPost() - { - $type = $this->getRequestVar('type'); - $targetObjectId = $this->getRequestVar('targetid',RequestParams::FILTER_NUMBER); - $sourceObjectId = $this->getRequestVar('sourceid',RequestParams::FILTER_NUMBER); - - $sourceObject = new BaseObject( $sourceObjectId ); - $sourceObject->load(); - - $targetFolder = new BaseObject( $targetObjectId ); - $targetFolder->load(); - - // Prüfen, ob Schreibrechte im Zielordner bestehen. - if ( ! $targetFolder->hasRight(Acl::ACL_WRITE) ) - { - $this->addNotice('folder', 0, $targetFolder->name, 'NOT_WRITABLE', Action::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', 0, $sourceObject->name, 'ERROR', Action::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, 0, $sourceObject->name, 'moved'); - break; - - case 'moveandlink': - - $oldParentId = $sourceObject->parentid; - - $sourceObject->setParentId( $targetObjectId ); - $this->addNotice($sourceObject->type, 0, $sourceObject->name, 'moved'); - - $link = new Link(); - $link->parentid = $oldParentId; - $link->name = \cms\base\Language::lang('LINK_TO').' '.$sourceObject->name; - $link->filename = $sourceObject->filename; - $link->linkedObjectId = $sourceObjectId; - $link->add(); - $this->addNotice('link', 0, $link->name, 'added'); - - break; - - case 'copy': - - switch( $sourceObject->getType() ) - { - case 'folder': - // Ordner zur Zeit nicht kopieren - // Funktion waere zu verwirrend - $this->addNotice($sourceObject->getType(), 0, $sourceObject->name, 'CANNOT_COPY_FOLDER', 'error'); - break; - - case 'file': - $f = new File( $sourceObjectId ); - $f->load(); - $f->filename = ''; - $f->name = \cms\base\Language::lang('COPY_OF').' '.$f->name; - $f->parentid = $targetObjectId; - $f->add(); - $f->copyValueFromFile( $sourceObjectId ); - - $this->addNotice($sourceObject->getType(), 0, $sourceObject->name, 'COPIED', 'ok'); - break; - - case 'page': - $p = new Page( $sourceObjectId ); - $p->load(); - $p->filename = ''; - $p->name = \cms\base\Language::lang('COPY_OF').' '.$p->name; - $p->parentid = $targetObjectId; - $p->add(); - $p->copyValuesFromPage( $sourceObjectId ); - $this->addNotice($sourceObject->getType(), 0, $sourceObject->name, 'COPIED', 'ok'); - break; - - case 'link': - $l = new Link( $sourceObjectId ); - $l->load(); - $l->filename = ''; - $l->name = \cms\base\Language::lang('COPY_OF').' '.$l->name; - $l->parentid = $targetObjectId; - $l->add(); - $this->addNotice($sourceObject->getType(), 0, $sourceObject->name, 'COPIED', 'ok'); - break; - - default: - throw new \LogicException('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::ACL_CREATE_LINK) ) - { - $this->addNotice('folder', 0, $targetFolder->name, 'NOT_WRITABLE', Action::NOTICE_ERROR); - return; - } - - $link = new Link(); - $link->parentid = $targetObjectId; - $link->name = \cms\base\Language::lang('LINK_TO').' '.$sourceObject->name; - $link->filename = $sourceObject->filename; - $link->linkedObjectId = $sourceObjectId; - $link->isLinkToObject = true; - $link->add(); - $this->addNotice('link', 0, $link->name, 'added'); - // OK - break; - - default: - throw new \LogicException('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 BaseObject( $acl->objectid ); - - if ( !$o->hasRight( Acl::ACL_GRANT ) ) - throw new \util\exception\SecurityException('Not allowed to insert permissions.'); // 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(RequestParams::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('', 0, '', 'ADDED', Action::NOTICE_OK); - - $o->setTimestamp(); - } - - - - /** - * Alle Rechte anzeigen - */ - function rightsView() - { - $o = new BaseObject( $this->getRequestId() ); - $o->objectLoadRaw(); - $this->setTemplateVar( 'show',$o->getRelatedAclTypes() ); - $this->setTemplateVar( 'type',$o->getType() ); - - $acllist = array(); - - - 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() - { - $o = new BaseObject( $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', 0, $folder->name, 'NOTHING_DONE', Action::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 BaseObject( $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', 0, $folder->name, 'SAVED', Action::NOTICE_OK); - } - - - /** - * Formular anzeigen, um Rechte hinzufuegen - */ - function aclformView() - { - $o = new BaseObject( $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=>\cms\base\Language::lang('ALL_LANGUAGES')); - - $project = new Project( $this->baseObject->projectid ); - - $languages += $project->getLanguages(); - $this->setTemplateVar('languages',$languages ); - $this->setTemplateVar('objectid' ,$o->objectid ); - $this->setTemplateVar('action' ,$this->request->action); - } - - - - /** - * Entfernen einer ACL - * - * @access protected - */ - function delaclPost() - { - $acl = new Acl($this->getRequestVar('aclid')); - $acl->load(); - - // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an - // diesem Objekt die ACLs zu aendern. - $o = new BaseObject( $acl->objectid ); - - if ( !$o->hasRight( Acl::ACL_GRANT ) ) - Http::notAuthorized('no grant rights'); // Da wollte uns wohl einer vereimern. - - $acl->delete(); // Weg mit der ACL - - $this->addNotice('', 0, '', 'DELETED', Action::NOTICE_OK); - } - - - /** - * Abspeichern der Ordner-Eigenschaften. - */ - public function propPost() - { - if ( ! $this->hasRequestVar('filename' ) ) - throw new ValidationException('filename'); - - $this->baseObject->filename = BaseObject::urlify( $this->getRequestVar('filename') ); - $this->baseObject->save(); - - $alias = $this->baseObject->getAliasForLanguage(null); - $alias->filename = BaseObject::urlify( $this->getRequestVar( 'alias_filename') ); - $alias->parentid = $this->getRequestId('alias_folderid'); - - // If no alias, remove the alias - if ( ! $alias->filename ) - $alias->delete(); - else - $alias->save(); - - - // Should we do this? - if ( $this->hasRequestVar('creationTimestamp') && $this->userIsAdmin() ) - $this->baseObject->createDate = $this->getRequestVar('creationTimestamp',RequestParams::FILTER_NUMBER); - $this->baseObject->setCreationTimestamp(); - - - $this->addNotice($this->baseObject->getType(), 0, $this->baseObject->filename, 'PROP_SAVED', 'ok'); - } - - - /** - * Abspeichern der Ordner-Eigenschaften. - */ - public function namePost() - { - if ( ! $this->hasRequestVar('name' ) ) - throw new ValidationException('name'); - - $name = $this->baseObject->getNameForLanguage( $this->getRequestId('languageid')); - - $name->name = $this->getRequestVar( 'name' ); - $name->description = $this->getRequestVar( 'description' ); - - $name->save(); - - $this->addNoticeFor($this->baseObject, Messages::SAVED); - } - - - - - - - /** - * Eigenschaften anzeigen. - */ - public function propView() - { - $this->setTemplateVar( 'filename', $this->baseObject->filename ); - $alias = $this->baseObject->getAliasForLanguage(null ); - $this->setTemplateVar( 'alias_filename', $alias->filename ); - $this->setTemplateVar( 'alias_folderid', $alias->parentid ); - - $project = Project::create( $this->baseObject->projectid ); - $this->setTemplateVar( 'folders' , $project->getAllFlatFolders() ); - } - - - /** - * Eigenschaften anzeigen. - */ - public function nameView() - { - $name = $this->baseObject->getNameForLanguage( $this->getRequestId('languageid') ); - - $nameProps = $name->getProperties(); - - $language = new Language( $name->languageid ); - $language->load(); - $nameProps[ 'languageName' ] = $language->name; - $this->setTemplateVars( $nameProps ); - } - - - public function settingsView() - { - $this->setTemplateVar('settings',$this->baseObject->settings); - - $this->setTemplateVar( 'valid_from_date' ,$this->baseObject->validFromDate==null?'':date('Y-m-d',$this->baseObject->validFromDate) ); - $this->setTemplateVar( 'valid_from_time' ,$this->baseObject->validFromDate==null?'':date('H:i' ,$this->baseObject->validFromDate) ); - $this->setTemplateVar( 'valid_until_date',$this->baseObject->validToDate ==null?'':date('Y-m-d',$this->baseObject->validToDate ) ); - $this->setTemplateVar( 'valid_until_time',$this->baseObject->validToDate ==null?'':date('H:i' ,$this->baseObject->validToDate ) ); - } - - public function settingsPost() - { - $this->baseObject->settings = $this->getRequestVar( 'settings'); - - // Validate YAML-Settings - try { - \util\YAML::parse( $this->baseObject->settings); - } - catch( \Exception $e ) - { - throw new ValidationException( 'settings' ); - } - - // Gültigkeitszeiträume speichern. - if ($this->hasRequestVar( 'valid_from_date' )) - $this->baseObject->validFromDate = strtotime( $this->getRequestVar( 'valid_from_date' ).' '.$this->getRequestVar( 'valid_from_time' ) ); - else - $this->baseObject->validFromDate = null; - - if ($this->hasRequestVar( 'valid_until_date')) - $this->baseObject->validToDate = strtotime( $this->getRequestVar( 'valid_until_date').' '.$this->getRequestVar( 'valid_until_time') ); - else - $this->baseObject->validToDate = null; - - - $this->baseObject->save(); - - $this->addNotice($this->baseObject->getType(), 0, $this->baseObject->filename, 'SAVED', Action::NOTICE_OK); - } - - /** * Stellt fest, ob der angemeldete Benutzer Projekt-Admin ist. * Dies ist der Fall, wenn der Benutzer PROP-Rechte im Root-Folder hat. @@ -619,67 +70,4 @@ class ObjectAction extends BaseAction return $rootFolder->hasRight(Acl::ACL_PROP); } - - - /** - * Show infos. - */ - public function infoView() - { - $this->setTemplateVars( $this->baseObject->getProperties() ); - - $this->setTemplateVar( 'is_valid' ,$this->baseObject->isValid() ); - $this->setTemplateVar( 'full_filename',$this->baseObject->full_filename() ); - $this->setTemplateVar( 'extension' , '' ); - $this->setTemplateVar( 'mimetype' , $this->baseObject->mimeType() ); - - $this->setTemplateVar( 'name' , $this->baseObject->getDefaultName()->name ); - $this->setTemplateVar( 'description' , $this->baseObject->getDefaultName()->description ); - - $languages = $this->baseObject->getProject()->getLanguages(); - $languagesVars = array(); - - foreach( $languages as $languageId => $languageName ) - { - $name = $this->baseObject->getNameForLanguage( $languageId ); - - - $languagesVar = [ - 'name' => $name->name, - 'description' => $name->description, - 'languagename' => $languageName, - 'languageid' => $languageId, - ]; - - $languagesVars[] = $languagesVar; - } - - $this->setTemplateVar('languages',$languagesVars ); - - // Read all objects linking to us. - $pages = $this->baseObject->getDependentObjectIds(); - - $list = array(); - foreach( $pages as $languageid ) - { - $o = new BaseObject( $languageid ); - $o->load(); - $list[$languageid] = array(); - $list[$languageid]['name'] = $o->filename; - $list[$languageid]['type'] = $o->getType(); - } - - asort( $list ); - - $this->setTemplateVar('pages',$list); - - $this->setTemplateVar('size',number_format($this->baseObject->getSize()/1000,0,',','.').' kB' ); - - $pad = str_repeat("\xC2\xA0",5); // Hard spaces - $totalSettings = $this->baseObject->getTotalSettings(); - $this->setTemplateVar('total_settings', $totalSettings,$pad ); - $this->setTemplateVar('settings', ArrayUtils::dryFlattenArray( $totalSettings,$pad ) ); - } - - } \ No newline at end of file diff --git a/modules/cms/action/PageAction.class.php b/modules/cms/action/PageAction.class.php @@ -90,732 +90,6 @@ class PageAction extends ObjectAction } - /** - * Alle Daten aus dem Formular speichern - */ - function formPost() - { - 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->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::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->getRequestVar(RequestParams::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(); - $value->languageid = $this->page->languageid; - $value->objectid = $this->page->objectid; - $value->pageid = Page::getPageIdFromObjectId( $this->page->objectid ); - - if ( ! $this->hasRequestVar('elementid') ) - $this->addValidationError('elementid' ); - - $value->element = new Element( $this->getRequestVar('elementid') ); - - $value->element->load(); - $value->load(); - - $value->number = $this->getRequestVar('number') * pow(10,$value->element->decimals); - $value->linkToObjectId = intval($this->getRequestVar('linkobjectid')); - $value->text = $this->getRequestVar('text'); - - // 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 BaseObject( $id ); - $o->load(); - - if ( $o->getType() != 'folder' ) - { - $f = new Folder( $o->parentid ); - $objects[ $id ] = \cms\base\Language::lang( ''.$o->getType() ).': '; - $objects[ $id ] .= implode( \util\Text::FILE_SEP,$f->parentObjectNames(false,true) ); - $objects[ $id ] .= \util\Text::FILE_SEP.$o->name; - } - } - asort($objects); - $this->setTemplateVar( 'objects' ,$objects ); - - $this->setTemplateVar( 'release' ,$this->page->hasRight(Acl::ACL_RELEASE) ); - $this->setTemplateVar( 'publish' ,$this->page->hasRight(Acl::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::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 = new Project( $this->page->projectid ); - 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 - } - - - - /** - * Die Eigenschaften der Seite anzeigen - */ - function infoView() - { - $this->setTemplateVar('id',$this->page->objectid); - - parent::infoView(); - $this->page->load(); - - $this->setTemplateVars( $this->page->getProperties() ); - - $alias = $this->page->getAliasForLanguage(null); - $this->setTemplateVar( 'alias', $alias->full_filename() ); - - $languages = $this->page->getProject()->getLanguages(); - $languagesVars = array(); - - foreach( $languages as $id => $name ) - { - $this->page->languageid = $id; - $this->page->load(); - - $languagesVar = $this->page->getProperties(); - $languagesVar['languagename'] = $name; - $languagesVar['languageid' ] = $id; - $alias = $this->page->getAliasForLanguage( $id ); - $languagesVar['alias' ] = $alias->full_filename(); - - $languagesVars[] = $languagesVar; - } - - $this->setTemplateVar('languages',$languagesVars ); - - if ( $this->userIsProjectAdmin() ) - { - $this->setTemplateVar('templateid',$this->page->templateid); - } - - $template = new Template( $this->page->templateid ); - $template->load(); - $this->setTemplateVar('template_name',$template->name ); - - $generator = new PageGenerator( $this->createPageContext( Producer::SCHEME_PUBLIC) ); - - $this->setTemplateVar('tmp_filename' ,$generator->getPublicFilename() ); - } - - - - - /** - * Die Eigenschaften der Seite anzeigen - */ - function nameView() - { - $languageId = $this->getRequestVar('languageid'); - - $name = $this->page->getNameForLanguage($languageId); - - $this->setTemplateVars( $name->getProperties() ); - - $alias = $this->page->getAliasForLanguage( $languageId ); - - $this->setTemplateVar( 'alias_filename', $alias->filename ); - $this->setTemplateVar( 'alias_folderid', $alias->parentid ); - - $project = Project::create( $this->page->projectid ); - $this->setTemplateVar( 'folders' , $project->getAllFlatFolders() ); - } - - - - - function namePost() { - - parent::namePost(); // Save name and description - - $alias = $this->page->getAliasForLanguage( $this->getRequestId('languageid')); - - $alias->filename = BaseObject::urlify( $this->getRequestVar( 'alias_filename') ); - $alias->parentid = $this->getRequestId('alias_folderid'); - - // If no alias, remove the alias - if ( ! $alias->filename ) { - - $alias->delete(); - $this->addNotice($alias->getType(), 0, '', 'DELETED', 'ok'); - } - else - { - $alias->save(); - $this->addNotice($alias->getType(), 0, $alias->filename, 'SAVED', 'ok'); - } - - } - - - /** - * Austauschen der Vorlage vorbereiten - * - * Es wird ein Formualar 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.' - '.\cms\base\Language::lang('EL_'.$e->type ); - $oldElement['id' ] = $e->elementid; - - $newElements = Array(); - $newElements[0] = \cms\base\Language::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] = \cms\base\Language::lang('ELEMENT').': '.$ne->name.' - '.\cms\base\Language::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', 0, $this->page->name, 'SAVED', Action::NOTICE_OK); - } - else - $this->addNotice('page', 0, $this->page->name, 'NOT_SAVED', Action::NOTICE_WARN); - } - - - - - /** - * Alle Elemente der Seite anzeigen - */ - function editView() - { - $template = new Template( $this->page->templateid ); - $template->load(); - - /** @var Element[] $elements */ - $elements = $template->getElements(); - - $elements = array_filter(/** - * @param $element Element - * @return Element - */ $elements, function($element ) { - return $element->isWritable(); - } ); - - $elements = array_map( function( $element ) { - return get_object_vars( $element ) + array('pageelementid'=>$this->page->id.'_'.$element->elementid,'typename'=>$element->getTypeName() ); - }, $elements); - - $this->setTemplateVar('elements',$elements); - } - - - /** - * Alle editierbaren Felder in einem Formular bereitstellen - */ - function formView() - { - $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 BaseObject( $oid ); - $o->load(); - - if ( $o->getType() != 'folder' ) - { - $f = new Folder( $o->parentid ); - $f->load(); - - $objects[ $oid ] = \cms\base\Language::lang( $o->getType() ).': '; - $objects[ $oid ] .= implode( ' &raquo; ',$f->parentObjectNames(false,true) ); - $objects[ $oid ] .= ' &raquo; '.$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 ] = \cms\base\Language::lang( $f->getType() ).': '; - $objects[ $oid ] .= implode( ' &raquo; ',$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::ACL_RELEASE) ); - $this->setTemplateVar( 'publish',$this->page->hasRight(Acl::ACL_PUBLISH) ); - - $this->setTemplateVar('el',$list); - } - - - - /** - * Seite anzeigen - */ - public function previewView() - { - $this->setModelAndLanguage(); - - $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array(RequestParams::PARAM_LANGUAGE_ID=>$this->page->getProject()->getDefaultLanguageId(),RequestParams::PARAM_MODEL_ID=>$this->page->getProject()->getDefaultModelId()) ) ); - } - - - - /** - * Seite anzeigen - */ - function showView() - { - // We must overwrite the CSP here. - // The output is only shown in an iframe, so there is no security impact to the CMS. - // But if the template is using inline JS or CSS, we would break this with a CSP-header. - $pageSettingsConfig = new Config( $this->page->getTotalSettings() ); - header('Content-Security-Policy: '.$pageSettingsConfig->get('content-security-policy','') ); - - $this->page->load(); - - $project = $this->page->getProject(); - - header('Content-Type: '.$this->page->mimeType().'; charset=UTF-8' ); - - // HTTP-Header mit Sprachinformation setzen. - $language = new Language( $this->page->languageid); - $language->load(); - header('Content-Language: '.$language->isoCode); - - Logger::debug("Preview page: ".$this->page->__toString() ); - - $pageContext = $this->createPageContext( Producer::SCHEME_PREVIEW); - $generator = new PageGenerator( $pageContext ); - - $template = new Template( $this->page->templateid ); - $templateModel = $template->loadTemplateModelFor( $pageContext->modelId ); - $templateModel->load(); - - // Executing PHP in Pages. - $enablePHP = Configuration::subset('publish')->get('enable_php_in_page_content'); - if ( ( $enablePHP=='auto' && $templateModel->extension == 'php') || - $enablePHP===true ) - { - ob_start(); - require( $generator->getCache()->load()->getFilename() ); - $this->setTemplateVar('output',ob_get_contents() ); - ob_end_clean(); - } - else - $this->setTemplateVar('output',$generator->getCache()->get()); - } - - - - /** - * Den Quellcode der Seite anzeigen - * - * Alle HTML-Sonderzeichen werden maskiert - */ - public function srcView() - { - $project = new Project( $this->page->projectid ); - $this->setModelAndLanguage(); - - $pageContext = new PageContext( $this->page->objectid,Producer::SCHEME_PUBLIC); - $pageContext->languageId = $project->getDefaultLanguageId(); - $pageContext->modelId = $project->getDefaultModelId(); - - $generator = new PageGenerator( $pageContext ); - - $this->setTemplateVar('src',$generator->getCache()->get() ); - } - - - - - /** - * Die Eigenschaften der Seite anzeigen - */ - function changetemplateView() - { - $this->page->load(); - - - $this->setTemplateVars( $this->page->getProperties() ); - - if ( $this->userIsAdmin() ) - { - $this->setTemplateVar('template_url',Html::url('template','show',$this->page->templateid)); - } - - $template = new Template( $this->page->templateid ); - $template->load(); - $this->setTemplateVar('template_name',$template->name); - - $templates = Array(); - $project = new Project( $this->page->projectid ); - foreach( $project->getTemplates() 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::ACL_PUBLISH ) ) - throw new \util\exception\SecurityException( 'no right for publish' ); - - $project = $this->page->getProject(); - - // Nothing is written to the session from this point. so we should free the session. - Session::close(); - - $publisher = new Publisher( $project->projectid ); - - foreach( $project->getModelIds() as $modelId ) { - - foreach( $project->getLanguageIds() as $languageId ) { - - $pageContext = new PageContext( $this->page->objectid, Producer::SCHEME_PUBLIC ); - $pageContext->modelId = $modelId; - $pageContext->languageId = $languageId; - - $pageGenerator = new PageGenerator( $pageContext ); - - $publisher->addOrderForPublishing( new PublishOrder( $pageGenerator->getCache()->load()->getFilename(),$pageGenerator->getPublicFilename(), $this->page->lastchangeDate ) ); - } - } - - $publisher->publish(); - - $this->addNoticeFor( $this->page, - 'PUBLISHED', - array(), - implode("\n",$publisher->getDestinationFilenames() ) - ); - } - - - - - public function removeView() - { - $this->setTemplateVar( 'name',$this->page->filename ); - } - - - public function removePost() - { - if ( $this->getRequestVar('delete') != '' ) - { - $this->page->delete(); - $this->addNotice('page', 0, $this->page->filename, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice('page', 0, $this->page->filename, 'CANCELED', Action::NOTICE_WARN); - } - } protected function setModelAndLanguage() { diff --git a/modules/cms/action/PageelementAction.class.php b/modules/cms/action/PageelementAction.class.php @@ -148,248 +148,12 @@ class PageelementAction extends BaseAction } - /** - * Anzeigen des Element-Inhaltes. - * @deprecated - */ - public function propView_Unused() - { - $this->value->languageid = $this->page->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->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_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() - { - $this->value->languageid = $this->page->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->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_id' ,$this->value->element->elementid ); - $this->setTemplateVar('element_name' ,$this->value->element->name ); - $this->setTemplateVar('element_type' ,$this->value->element->getTypeName() ); - $this->setTemplateVar('element_format',Element::getAvailableFormats()[ $this->value->element->format] ); - $this->setTemplateVar('format' ,@Element::getAvailableFormats()[ $this->value->format ] ); - - $user = new User( $this->value->lastchangeUserId ); - - try{ - $user->load(); - }catch (\util\exception\ObjectNotFoundException $e) { - $user = new User(); // Empty User. - } - - $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 ); - - - } - - - /** - * Normaler Editiermodus. - * - * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. - */ - public function editView() - { - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->page = $this->page; - $this->value->element = &$this->element; - $this->value->elementid = $this->element->elementid; - $this->value->element->load(); - - $this->setTemplateVar('name' ,$this->value->element->label ); - $this->setTemplateVar('description',$this->value->element->desc ); - $this->setTemplateVar('elementid' ,$this->value->element->elementid); - $this->setTemplateVar('type' ,$this->value->element->getTypeName() ); - - $languages = array(); - - foreach ( $this->page->getProject()->getLanguages() as $languageId=>$languageName ) - { - $value = clone $this->value; // do not overwrite the value - $value->languageid = $languageId; - $value->load(); - - $languages[$languageId] = array( - 'languageid' => $languageId, - 'languagename' => $languageName, - 'text' => $this->calculateValue( $value ), - 'number' => $value->number, - 'date' => $value->date, - 'linkObjectId' => $value->linkToObjectId, - ); - } - - $this->setTemplateVar('languages',$languages); - } - - - - - - - /** - * Erweiterter Modus. - */ - public function advancedView() - { - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->page = $this->page; - $this->value->element = &$this->element; - $this->value->elementid = $this->element->elementid; - $this->value->element->load(); - - $this->setTemplateVar('name' ,$this->value->element->label ); - $this->setTemplateVar('description',$this->value->element->desc ); - $this->setTemplateVar('elementid' ,$this->value->element->elementid); - $this->setTemplateVar('type' ,$this->value->element->getTypeName() ); - - $languages = array(); - - foreach ( $this->page->getProject()->getLanguages() as $languageId=>$languageName ) - { - $this->value->languageid = $languageId; - $this->value->load(); - - $languages[$languageId] = array( - 'languageid' => $languageId, - 'languagename' => $languageName, - 'text' => $this->calculateValue( $this->value ), - 'number' => $this->value->number, - 'date' => $this->value->date, - 'linkObjectId' => $this->value->linkToObjectId, - 'editors' => Element::getAvailableFormats() - ); - } - - $this->setTemplateVar('languages',$languages); - } - - - - public function valueView() - { - $this->value->languageid = $this->page->languageid; - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->element = &$this->element; - $this->value->elementid = &$this->element->elementid; - $this->value->element->load(); - $this->value->publish = false; - - - $valueId =$this->getRequestId('valueid'); - if ( $valueId ) { - $this->value->valueid = $valueId; - $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('languageid',$this->value->languageid ); - $this->setTemplateVar('type' ,$this->value->element->getTypeName() ); - $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::ACL_RELEASE) ) - $this->setTemplateVar( 'release',true ); - if ( $this->value->page->hasRight(Acl::ACL_PUBLISH) ) - $this->setTemplateVar( 'publish',false ); - - $funktionName = 'edit'.$this->value->element->type; - - if ( ! method_exists($this,$funktionName) ) - throw new \LogicException('Method does not exist: PageElementAction#'.$funktionName ); - - $this->$funktionName(); // Aufruf der Funktion "edit<Elementtyp>()". - } - - - - /** - * Vorschau. - */ - public function previewView() - { - $valueGenerator = new ValueGenerator( $this->createValueContext( Producer::SCHEME_PREVIEW) ); - $this->setTemplateVar('preview' ,$valueGenerator->getCache()->get() ); - } - - - - /** - * Datum bearbeiten. - * - */ - private function editdate() - { - $this->setTemplateVar( 'date' ,$this->value->date==null?'':date('Y-m-d',$this->value->date) ); - $this->setTemplateVar( 'time' ,$this->value->date==null?'':date('H:i' ,$this->value->date) ); - } - - /** * Verkn�pfung bearbeiten. * */ - private function editlink() + protected function editlink() { $project = new Project($this->page->projectid); $this->setTemplateVar('rootfolderid',$project->getRootObjectId() ); @@ -422,73 +186,11 @@ class PageelementAction extends BaseAction } - - function linkView() - { - $this->value->languageid = $this->page->languageid; - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->element = &$this->element; - $this->value->element->load(); - $this->value->load(); - - $this->setTemplateVar('name' ,$this->value->element->name ); - $this->setTemplateVar('desc' ,$this->value->element->desc ); - - $project = new Project($this->page->projectid); - $this->setTemplateVar('rootfolderid' ,$project->getRootObjectId() ); - - // 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 ] = \cms\base\Language::lang('LIST_ENTRY_EMPTY'); // Wert "nicht ausgewählt" - - - $t = new Template( $this->page->templateid ); - - foreach( $t->getDependentObjectIds() as $id ) - { - $o = new BaseObject( $id ); - $o->load(); - - // if ( in_array( $o->getType(),$types )) - // { - $f = new Folder( $o->parentid ); - // $f->load(); - - $objects[ $id ] = \cms\base\Language::lang( $o->getType() ).': '; - $objects[ $id ] .= implode( \util\Text::FILE_SEP,$f->parentObjectNames(false,true) ); - $objects[ $id ] .= \util\Text::FILE_SEP.$o->name; - // } - } - - asort( $objects ); // Sortieren - - $this->setTemplateVar('objects' ,$objects); - $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId); - - $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::ACL_RELEASE) ); - $this->setTemplateVar( 'publish',$this->value->page->hasRight(Acl::ACL_PUBLISH) ); - - $this->setTemplateVar( 'objectid',$this->value->page->objectid ); - } - - - /** * Auswahlbox. * */ - private function editselect() + protected function editselect() { $this->setTemplateVar( 'items',$this->value->element->getSelectItems() ); $this->setTemplateVar( 'text' ,$this->value->text ); @@ -501,7 +203,7 @@ class PageelementAction extends BaseAction * Einf�gen-Element. * */ - private function editlist() + protected function editlist() { $this->editinsert(); } @@ -512,7 +214,7 @@ class PageelementAction extends BaseAction * Einf�gen-Element. * */ - private function editinsert() + protected function editinsert() { // Auswahl ueber alle Elementtypen $objects = array(); @@ -560,7 +262,7 @@ class PageelementAction extends BaseAction * Zahl bearbeiten. * */ - private function editnumber() + protected function editnumber() { $this->setTemplateVar('number',$this->value->number / pow(10,$this->value->element->decimals) ); } @@ -571,7 +273,7 @@ class PageelementAction extends BaseAction * * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. */ - private function editlongtext() + protected function editlongtext() { if ( $this->hasRequestVar('format') ) // Individual format from request. @@ -595,195 +297,17 @@ class PageelementAction extends BaseAction * * Es wird ein Formular erzeugt, mit dem der Benutzer den Inhalt bearbeiten kann. */ - private function edittext() + protected function edittext() { $this->setTemplateVar( 'text',$this->value->text ); } - - - /** - * Wiederherstellung eines alten Inhaltes. - */ - public function restorePost() - { - $this->value->valueid = $this->getRequestVar('valueid'); - $this->value->loadWithId(); - $this->value->element = new Element( $this->value->elementid ); - - if ( $this->value->pageid != $this->page->pageid ) - throw new \LogicException( 'Cannot find value','page-id does not match' ); - - // Pruefen, ob Berechtigung zum Freigeben besteht - //$this->value->release = $this->page->hasRight(Acl::ACL_RELEASE); - $this->value->release = false; - - // Inhalt wieder herstellen, in dem er neu gespeichert wird. - $this->value->save(); - - $this->addNotice('pageelement', 0, $this->value->element->name, 'PAGEELEMENT_USE_FROM_ARCHIVE', Action::NOTICE_OK); - } - - - - /** - * Freigeben eines Inhaltes - */ - public function releasePost() - { - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->page = $this->page; - $this->value->element = &$this->element; - $this->value->elementid = $this->element->elementid; - $this->value->element->load(); - - $this->value->valueid = intval($this->getRequestVar('valueid')); - $this->value->loadWithId(); - - if ( $this->value->pageid != $this->page->pageid ) - throw new LogicException( 'cannot release, bad page' ); - - // Pruefen, ob Berechtigung zum Freigeben besteht - if ( !$this->page->hasRight(Acl::ACL_RELEASE) ) - throw new SecurityException( 'Cannot release','no right' ); - - // Inhalt freigeben - $this->value->release(); - - $this->addNoticeFor($this->value, Messages::PAGEELEMENT_RELEASED ); - } - - - /** - * Erzeugt eine Liste aller Versionsst?nde zu diesem Inhalt - */ - public function historyView() - { - $this->page->load(); - - $this->value->objectid = $this->page->objectid; - $this->value->pageid = $this->page->pageid; - $this->value->page = $this->page; - $this->value->element = &$this->element; - $this->value->elementid = $this->element->elementid; - $this->value->element->load(); - - $languages = array(); - - foreach ( $this->page->getProject()->getLanguages() as $languageId=>$languageName ) - { - $language = [ - 'id' => $languageId, - 'name' => $languageName, - 'values' => [], - ]; - - $value = clone $this->value; // do not overwrite the value - $value->languageid = $languageId; - - /** @var Value $value */ - foreach($value->getVersionList() as $value) { - - $language['values'][] = [ - 'text' => $this->calculateValue( $value ), - 'active' => $value->active, - 'publish' => $value->publish, - 'user' => $value->lastchangeUserName, - 'date' => $value->lastchangeTimeStamp, - 'id' => $value->getId(), - 'usable' => ! $value->active, - 'releasable' => $value->active && ! $value->publish, - 'comparable' => in_array($this->element->typeid,[Element::ELEMENT_TYPE_LONGTEXT]), - ]; - } - - $languages[$languageId] = $language; - } - - $this->setTemplateVar('name' ,$this->element->label ); - $this->setTemplateVar('languages',$languages ); - } - - - /** - * 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. - $diffResult = Text::diff($text1,$text2); - - $outputResult = array_map( function( $left,$right) { - return [ - 'left' => $left, - 'right'=> $right - ]; - },$diffResult[0],$diffResult[1] ); - - $this->setTemplateVar('diff',$outputResult ); - } - - - - /** - * Ein Element der Seite speichern. - */ - public function valuePost() - { - $this->element->load(); - $type = $this->element->type; - - if ( empty($type)) - throw new \InvalidArgumentException('No element type available'); - - $funktionName = 'save'.$type; - - if ( !method_exists($this,$funktionName)) - throw new \InvalidArgumentException('Function not available: '.$funktionName); - - $this->$funktionName(); // Aufruf Methode "save<ElementTyp>()" - } - - - /** * Element speichern * * Der Inhalt eines Elementes wird abgespeichert */ - private function savetext() + protected function savetext() { $value = new Value(); $value->publisher = $this->page->publisher; @@ -819,7 +343,7 @@ class PageelementAction extends BaseAction * @param $value Value * @throws \util\exception\ObjectNotFoundException */ - private function afterSave( $value ) + protected function afterSave( $value ) { $value->page = new Page( $value->objectid ); $value->page->load(); @@ -873,7 +397,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function savelongtext() + protected function savelongtext() { $value = new Value(); $value->languageid = $this->page->languageid; @@ -907,7 +431,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function savedate() + protected function savedate() { $value = new Value(); $value->languageid = $this->page->languageid; @@ -939,7 +463,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function saveselect() + protected function saveselect() { $value = new Value(); $value->languageid = $this->page->languageid; @@ -966,7 +490,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function savelink() + protected function savelink() { $value = new Value(); $value->publisher = $this->page->publisher; @@ -996,7 +520,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function savelist() + protected function savelist() { $this->saveinsert(); } @@ -1008,7 +532,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function saveinsert() + protected function saveinsert() { $value = new Value(); $value->publisher = $this->page->publisher; @@ -1035,7 +559,7 @@ class PageelementAction extends BaseAction * * Der Inhalt eines Elementes wird abgespeichert */ - private function savenumber() + protected function savenumber() { $value = new Value(); $value->publisher = $this->page->publisher; @@ -1059,77 +583,8 @@ class PageelementAction extends BaseAction } - function exportlongtext() - { - $types = array(); - - foreach( array('odf','plaintext') as $type ) - { - $types[$type] = \cms\base\Language::lang('FILETYPE_'.$type); - } - - $this->setTemplateVar('types',$types); - } - - - function importlongtext() - { - $types = array(); - - foreach( array('odf','plaintext') as $type ) - { - $types[$type] = \cms\base\Language::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; - } - - - - - private function linkifyOIDs( $text ) + protected function linkifyOIDs( $text ) { $pageContext = new PageContext( $this->page->objectid, Producer::SCHEME_PREVIEW ); $pageContext->modelId = 0; @@ -1148,7 +603,7 @@ class PageelementAction extends BaseAction } - private function compactOIDs( $text ) + protected function compactOIDs( $text ) { foreach( Text::parseOID($text) as $oid=>$t ) { @@ -1166,7 +621,7 @@ class PageelementAction extends BaseAction * @param $text * @return int */ - private function parseSimpleOID($text ) + protected function parseSimpleOID($text ) { $treffer = Text::parseOID( $text ); @@ -1177,31 +632,6 @@ class PageelementAction extends BaseAction 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::ACL_PUBLISH ) ) - throw new SecurityException( 'no right for publish' ); - - $this->publishPage(); - } - protected function publishPage() { @@ -1274,5 +704,3 @@ class PageelementAction extends BaseAction } } } - -?>- \ No newline at end of file diff --git a/modules/cms/action/ProfileAction.class.php b/modules/cms/action/ProfileAction.class.php @@ -43,7 +43,7 @@ use util\UIUtils; class ProfileAction extends BaseAction { public $security = Action::SECURITY_USER; - + protected $user; var $defaultSubAction = 'edit'; @@ -59,231 +59,12 @@ class ProfileAction extends BaseAction } - /** - * 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' ); - - - Session::setUser( $this->user ); - - if ( !empty($this->user->fullname) ) - { - $this->user->save(); - $this->addNoticeFor( $this->user,Messages::SAVED); - } - else - { - $this->addValidationError('fullname'); - } - - - // Ausgewählte Sprache sofort verwenden. - $l = $this->getRequestVar('language'); - - if ( $l ) - $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 = $user->type == User::AUTH_TYPE_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. - throw new ValidationException('mail'); - } - else - { - // Der Freischaltcode wird in der Sitzung gespeichert. - Session::set( Session::KEY_MAIL_CHANGE_CODE,$code ); - Session::set( Session::KEY_MAIL_CHANGE_MAIL,$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->addNoticeFor( $this->user, Messages::MAIL_SENT); - } - else - { - Logger::warn('Mail could not be sent: '.$mail->error); - $this->addNoticeFor($this->user, Messages::MAIL_NOT_SENT,[],$mail->error); // Meldung - } - } - } - - - - /** - * 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( Session::KEY_MAIL_CHANGE_CODE ); - $newMail = Session::get( Session::KEY_MAIL_CHANGE_MAIL ); - $inputRegisterCode = $this->getRequestVar('code'); - - if ( $sessionCode == $inputRegisterCode ) - { - // Best�tigungscode stimmt �berein. - // E-Mail-Adresse �ndern. - $this->user->mail = $newMail; - $this->user->save(); - - $this->addNoticeFor( $this->user,Messages::SAVED ); - } - else - { - // Validation code does not match - throw new ValidationException('code',Messages::CODE_NOT_MATCH ); - } - - } - - - - public function pwPost() - { - $pwMinLength = Configuration::subset(['security','password'])->get('min_length',10); - - 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'))<$pwMinLength ) - { - $this->addValidationError('password1','PASSWORD_MINLENGTH',array('minlength'=> $pwMinLength)); - } - else - { - $this->user->setPassword( $this->getRequestVar('password1') ); - $this->addNotice('user', 0, $this->user->name, 'SAVED', 'ok'); - } - } - - - - /** - * Anzeige aller Benutzer-Eigenschaften. - */ - function editView() - { - $issuer = urlencode(Configuration::subset('application')->get('operator',Startup::TITLE)); - $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() ); - - $languageList = []; - - foreach( Messages::$AVAILABLE_LANGUAGES as $languageIsoCode) - { - $language = (new Language)->getLanguage($languageIsoCode); - $label = $language[ Messages::SELF_NAME ]; - $languageList[ $languageIsoCode ] = $label; - } - $this->setTemplateVar('language_list',$languageList ); - - $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() ); - } - - - /** * Setzt eine Sprache für den Benutzer. * * @param $l string Sprache */ - public function setLanguage($l) + protected function setLanguage($l) { $conf = Session::getConfig(); $language = new Language(); @@ -294,76 +75,6 @@ class ProfileAction extends BaseAction } - - /** - * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer in allen Projekten gemacht worden sind. - */ - public function historyView() - { - $lastChanges = $this->user->getLastChanges(); - - $timeline = array(); - - foreach( $lastChanges as $entry ) - { - $timeline[ $entry['objectid'] ] = $entry; - $baseObject = new BaseObject( $entry['objectid']); - $baseObject->objectLoad(); - $timeline[ $entry['objectid'] ]['type'] = $baseObject->getType(); - } - $this->setTemplateVar('timeline', $timeline); - } - - - - public function userinfoView() - { - - $user = Session::getUser(); - - $currentStyle = $this->getUserStyle($user); - $this->setTemplateVar('style',$currentStyle); - - - $defaultStyleConfig = Configuration::Conf()->get('style-default',[]); // default style config - $userStyleConfig = Configuration::subset('style')->get($currentStyle,[]); // user style config - - if ( $userStyleConfig ) - $defaultStyleConfig = array_merge($defaultStyleConfig, $userStyleConfig ); // Merging user style into default style - else - ; // Unknown style name, we are ignoring this. - - // Theme base color for smartphones colorizing their status bar. - $this->setTemplateVar('theme-color', UIUtils::getColorHexCode($defaultStyleConfig['title_background_color'])); - } - - - /** - * All UI settings. - */ - public function uisettingsView() { - - $this->setTemplateVar('settings',Configuration::Conf()->get('ui') ); - } - - - /** - * The user-dependent language codes. - */ - public function languageView() { - - $this->setTemplateVar('language',Configuration::Conf()->get('language') ); - } - - - - public function pingView() - { - $this->setTemplateVar('pong',1); - } - - - /** * @param User $user * @return string diff --git a/modules/cms/action/ProjectAction.class.php b/modules/cms/action/ProjectAction.class.php @@ -56,48 +56,6 @@ class ProjectAction extends BaseAction } - function propPost() - { - if ( $this->getRequestVar('name') != '') - { - $this->project->name = $this->getRequestVar('name' ,RequestParams::FILTER_ALPHANUM); - $this->project->url = $this->getRequestVar('url' ,RequestParams::FILTER_ALPHANUM); - $this->project->target_dir = $this->getRequestVar('target_dir' ,RequestParams::FILTER_RAW ); - $this->project->ftp_url = $this->getRequestVar('ftp_url' ,RequestParams::FILTER_RAW ); - $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,RequestParams::FILTER_RAW ); - $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,RequestParams::FILTER_RAW ); - $this->project->content_negotiation = $this->getRequestVar('content_negotiation',RequestParams::FILTER_NUMBER ); - $this->project->cut_index = $this->getRequestVar('cut_index' ,RequestParams::FILTER_NUMBER ); - $this->project->publishFileExtension = $this->getRequestVar('publishFileExtension',RequestParams::FILTER_NUMBER ); - $this->project->publishPageExtension = $this->getRequestVar('publishPageExtension',RequestParams::FILTER_NUMBER ); - $this->project->linkAbsolute = $this->getRequestVar('linksAbsolute' ,RequestParams::FILTER_NUMBER ) == '1'; - - $this->addNoticeFor($this->project,Messages::SAVED); - $this->project->save(); // speichern - - $root = new Folder( $this->project->getRootObjectId() ); - $root->setTimestamp(); - } - else - { - $this->addValidationError('name'); - $this->callSubAction('edit'); - } - } - - - - - public function editView() { - - - $this->setTemplateVar('projectid' ,$this->project->projectid); - $this->setTemplateVar('rootobjectid' ,$this->project->getRootObjectId()); - $this->setTemplateVar('is_project_admin',$this->userIsProjectAdmin()); - } - - - /** * Stellt fest, ob der angemeldete Benutzer Projekt-Admin ist. * Dies ist der Fall, wenn der Benutzer PROP-Rechte im Root-Folder hat. @@ -110,172 +68,9 @@ class ProjectAction extends BaseAction return $rootFolder->hasRight(Acl::ACL_PROP); } - /** - * Liste aller Projekte anzeigen. - * - */ - function listingView() - { - // 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"=>\cms\base\Language::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 propView() - { - $extraProperties = array( - 'rootobjectid' => $this->project->getRootObjectId(), - 'linksAbsolute' => $this->project->linkAbsolute?'1':'0' - ); - - $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', 0, $this->project->name, 'DELETED'); - } - - - - /** - * Anzeige View fuer Wartung. - */ - function maintenanceView() - { - } - - - - /** - * Wartung durchfuehren. - */ - function maintenancePost() - { - switch( $this->getRequestVar('type') ) - { - case 'check_files': - // Konsistenzprüfungen - $log = $this->project->checkLostFiles(); - - $this->addNoticeFor($this->project,Messages::DONE, [], implode("\n",$log) ); - break; - - case 'check_limit': - // Alte Versionen löschen. - $this->project->checkLimit(); - $this->addNoticeFor($this->project,Messages::DONE); - break; - - default: - $this->addValidationError('type'); - } - } - - - - /** - * Projekt exportieren. - */ - public function copyView() - { - - } - - - /** - * Projekt exportieren. - */ - public function copyPost() - { - $db = \cms\base\DB::get(); - $this->setTemplateVar( 'dbid',$db->id ); - - $conf = Configuration::rawConfig(); - $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', 0, $this->project->name, 'DONE'); - $this->setTemplateVar('done',true); - } - } - - - - public function infoView() - { - $this->setTemplateVar( 'info', $this->project->info() ); - $this->setTemplateVar( 'name', $this->project->name ); - $this->setTemplateVar( 'url' , $this->makeAbsoluteHostnameLink($this->project->url) ); - } - - /** * Make a linkable hostname * * @param $hostname @@ -286,18 +81,5 @@ class ProjectAction extends BaseAction return 'http://'.$hostname; return $hostname; } - - - /** - * 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/action/ProjectlistAction.class.php b/modules/cms/action/ProjectlistAction.class.php @@ -41,93 +41,4 @@ class ProjectlistAction extends BaseAction parent::__construct(); } - - /** - * Liste aller Projekte anzeigen. - * - */ - public function editView() - { - // Projekte ermitteln - $list = array(); - - foreach(Project::getAllProjects() as $id=> $name ) - { - - // Schleife ueber alle Projekte - foreach (Project::getAllProjects() as $id => $name) { - - $project = new Project($id); - $rootFolder = new Folder($project->getRootObjectId()); - $rootFolder->load(); - - // Berechtigt für das Projekt? - if ($rootFolder->hasRight(Acl::ACL_READ)) { - $list[$id] = array(); - $list[$id]['id' ] = $id; - $list[$id]['name' ] = $name; - } - } - } - - $this->setTemplateVar('projects',$list); - $this->setTemplateVar('add',$this->userIsAdmin()); - } - - - - function addView() - { - if( ! $this->userIsAdmin() ) - throw new SecurityException('user is not allowed to add a project'); - - $this->setTemplateVar( 'projects',Project::getAllProjects() ); - } - - - /** - * Projekt hinzufuegen. - * - */ - function addPost() - { - if( !$this->userIsAdmin()) - throw new SecurityException(); - - $projectid = $this->getRequestVar('projectid'); - - if ( $projectid ) { - - $db = \cms\base\DB::get(); - $project = Project::create($projectid); - $project->load(); - $project->export($db->id); - $this->addNoticeFor($project,Messages::DONE); - - } else { - $name = $this->hasRequestVar('name'); - - if ( !$name ) - throw new \util\exception\ValidationException('name'); - - $project = new Project(); - $project->name = $name; - $project->add(); - $this->addNoticeFor($project,Messages::ADDED); - - } - - } - - - /** - * 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/action/README.md b/modules/cms/action/README.md @@ -10,17 +10,18 @@ Their mission is to ### View and Post -Every HTTP-Request contains 2 parameters: -- `action`: The action class is instantiated with this value. Example: The action "example" will instantiate a class "ExampleAction". -- `method`: The method which should be called in this action (see above) +Every HTTP-Request contains 3 parameters: +- `action`: The action pointing to an model object +- `method`: The method +- `id` : The id of the model object. This is optional in some cases ### View and Post The parameter `method` and the HTTP method are deciding, which method is called. Example: -`GET /?action=example&method=foo` will call _ExampleAction::fooView()_. -`POST /?action=example&method=foo` will call _ExampleAction::fooPost()_. +`GET /?action=example&method=foo` will call _ExampleFooAction::view()_. +`POST /?action=example&method=foo` will call _ExampleFooAction::post()_. ### Contracts: - **no database requests are done here!** Database requests are only done by the model classes. \ No newline at end of file diff --git a/modules/cms/action/SearchAction.class.php b/modules/cms/action/SearchAction.class.php @@ -68,66 +68,6 @@ class SearchAction extends BaseAction } /** - * Durchf?hren der Suche - * und Anzeige der Ergebnisse - */ - public function resultView() - { - $suchText = $this->getRequestVar('text'); - $searchFlags = 0; - - if ( $this->hasRequestVar('id' ) ) $searchFlags |= self::FLAG_ID; - if ( $this->hasRequestVar('filename' ) ) $searchFlags |= self::FLAG_FILENAME; - if ( $this->hasRequestVar('name' ) ) $searchFlags |= self::FLAG_NAME; - if ( $this->hasRequestVar('description') ) $searchFlags |= self::FLAG_DESCRIPTION; - if ( $this->hasRequestVar('content' ) ) $searchFlags |= self::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() - { - $searchConfig = C::subset('search')->subset('quicksearch'); - - $text = $this->getRequestVar('search'); - - $flag = $searchConfig->subset('flag'); - - $searchFlags = 0; - - // Always search for the id without a max length - if ( $flag->is('id' ) ) $searchFlags |= self::FLAG_ID; - - if ( strlen($text) >= $searchConfig->get('maxlength',3 ) ) { - - if ( $flag->is('name' ) ) $searchFlags |= self::FLAG_NAME; - if ( $flag->is('filename' ) ) $searchFlags |= self::FLAG_FILENAME; - if ( $flag->is('description') ) $searchFlags |= self::FLAG_DESCRIPTION; - if ( $flag->is('content' ) ) $searchFlags |= self::FLAG_VALUE; - } - - $this->performSearch($text, $searchFlags); - } - - - /** * Query the search * * @param $searchText string search query text @@ -253,6 +193,4 @@ class SearchAction extends BaseAction return $resultList; } -} - -?>- \ No newline at end of file +}+ \ No newline at end of file diff --git a/modules/cms/action/TemplateAction.class.php b/modules/cms/action/TemplateAction.class.php @@ -44,8 +44,6 @@ class TemplateAction extends BaseAction { public $security = Action::SECURITY_USER; - var $defaultSubAction = 'show'; - /** * @var Template */ @@ -76,509 +74,4 @@ class TemplateAction extends BaseAction } } - - /** - * Save the new template source into the database. - */ - public function srcPost() - { - $modelId = $this->getRequestId('modelid'); - - $templatemodel = new TemplateModel($this->template->templateid, $modelId); - $templatemodel->load(); - - $newSource = $this->request->getRequestVar('source',RequestParams::FILTER_RAW); - - /* - // Not useful any more. Technical name of a element should not be changed. - foreach ($this->template->getElementNames() as $elid => $elname) { - $newSource = str_replace('{{' . $elname . '}}', '{{' . $elid . '}}', $newSource); - $newSource = str_replace('{{->' . $elname . '}}', '{{->' . $elid . '}}', $newSource); - $newSource = str_replace('{{' . \cms\base\Language::lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . \cms\base\Language::lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFEMPTY:' . $elid . ':BEGIN}}', $newSource); - $newSource = str_replace('{{' . \cms\base\Language::lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . \cms\base\Language::lang('TEMPLATE_SRC_END') . '}}', '{{IFEMPTY:' . $elid . ':END}}', $newSource); - $newSource = str_replace('{{' . \cms\base\Language::lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . \cms\base\Language::lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFNOTEMPTY:' . $elid . ':BEGIN}}', $newSource); - $newSource = str_replace('{{' . \cms\base\Language::lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . \cms\base\Language::lang('TEMPLATE_SRC_END') . '}}', '{{IFNOTEMPTY:' . $elid . ':END}}', $newSource); - } - */ - - $templatemodel->src = $newSource; - $templatemodel->extension = $this->getRequestVar('extension'); - $templatemodel->save(); - - $this->addNotice('template', 0, $this->template->name, 'SAVED', Action::NOTICE_OK); - } - - - - - function srcelementPost() - { - $tplModel = $this->template->loadTemplateModelFor( $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID)); - - $elementToAdd = new Element( $this->getRequestVar('elementid') ); - $elementToAdd->load(); - - switch( $this->getRequestVar('type') ) - { - case 'addelement': - $tplModel->src .= "\n".'{{'.$elementToAdd->name.'}}'; - break; - - default: - throw new ValidationException('type'); - } - - $tplModel->save(); - - $this->addNoticeFor($this->template,Messages::SAVED); - } - - - // 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', 0, $this->template->name, 'SAVED', Action::NOTICE_OK); - } - } - - - // Speichern der Template-Eigenschaftens - // - function removePost() - { - if ( $this->getRequestVar('delete') != '' ) - { - $this->template->delete(); - $this->addNotice('template', 0, $this->template->name, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice('template', 0, $this->template->name, 'CANCELED', Action::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->filename; - } - - $this->setTemplateVar('pages',$pages); - $this->setTemplateVar('id' ,$this->template->getId() ); - $this->setTemplateVar('name' ,$this->template->getName() ); - } - - - /** - * Speichern der Dateiendung - */ - public function extensionPost() - { - $project = new Project( $this->template->projectid ); - $models = $project->getModels(); - - $extensions = array(); - foreach( $models as $modelId => $modelName ) { - - $input = $this->getRequestVar( $modelName ); - - // Validierung: Werte dürfen nicht doppelt vorkommen. - if ( in_array($input, $extensions) ) - { - $this->addNotice('template', 0, $this->template->name, 'DUPLICATE_INPUT', 'error'); - throw new \util\exception\ValidationException( $modelName ); - } - - $extensions[ $modelId ] = $input; - } - - foreach( $models as $modelId => $modelName ) { - - $templatemodel = new TemplateModel($this->template->templateid, $modelId); - $templatemodel->load(); - - $templatemodel->extension = $extensions[ $modelId ]; - - $templatemodel->save(); - } - - $this->addNotice('template', 0, $this->template->name, 'SAVED', 'ok'); - } - - - - function addelView() - { - // Die verschiedenen Element-Typen - $types = array(); - - foreach( Element::getAvailableTypes() as $typeid => $t ) - { - $types[ $typeid ] = 'EL_'.$t; - } - - // Code-Element nur fuer Administratoren (da voller Systemzugriff!) - if ( !$this->userIsAdmin() ) - unset( $types[Element::ELEMENT_TYPE_CODE] ); - - // Auswahlmoeglichkeiten: - $this->setTemplateVar('types',$types); - - // Vorbelegung: - $this->setTemplateVar('typeid',Element::ELEMENT_TYPE_TEXT); - } - - - - /* - * Neues Element hinzufuegen. - */ - function addelPost() - { - - $name = $this->getRequestVar('name',RequestParams::FILTER_ALPHANUM); - - if ( empty($name) ) - throw new \util\exception\ValidationException('name'); - - $newElement = $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('typeid') ); - - if ( $this->hasRequestVar('addtotemplate') ) - { - $project = new Project( $this->template->projectid); - $modelIds = $project->getModelIds(); - - foreach( $modelIds as $modelId ) - { - $template = new Template( $this->template->templateid ); - $templateModel = $template->loadTemplateModelFor( $modelId ); - $templateModel->load(); - $templateModel->src .= "\n".'{{'.$newElement->name.'}}'; - $templateModel->save(); - } - - } - - $this->addNotice('template', 0, $this->template->name, 'SAVED', Action::NOTICE_OK); - } - - - - /** - * Eigenschaften einer Vorlage anzeigen - */ - function propView() - { - $this->setTemplateVar('name' , $this->template->name ); - $this->setTemplateVar('extension','' ); - $this->setTemplateVar('mime_type','' ); - } - - - - - /** - * Anzeigen des Inhaltes, der Inhalt wird samt Header direkt - * auf die Standardausgabe geschrieben - */ - function previewView() - { - $project = new Project( $this->template->projectid); - - $this->setTemplateVar('models',$project->getModels() ); - - $modelId = $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID); - if ( ! $modelId ) - $modelId = Project::create( $this->template->projectid )->getDefaultModelId(); - - $this->setTemplateVar('modelid' ,$modelId); - - $this->setTemplateVar('preview_url',Html::url('template','show',$this->template->templateid,array('target'=>'none','modelid'=>$modelId ) ) ); - } - - - - - /** - * Voransicht einer Vorlage - */ - function showView() - { - $modelId = $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID); - if ( ! $modelId ) - $modelId = Project::create( $this->template->projectid )->getDefaultModelId(); - - $templatemodel = new TemplateModel($this->template->templateid, $modelId); - $templatemodel->load(); - - header('Content-Type: '.$templatemodel->mimeType().'; charset=UTF-8' ); - $text = $templatemodel->src; - - foreach( $this->template->getElementIds() as $elid ) - { - $element = new Element( $elid ); - $element->load(); - - $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 ); - } - - $this->setTemplateVar('text',$text); - } - - - /** - * 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->getTypeName(); - $list[$elid]['typeid' ] = $element->typeid; - - unset( $element ); - } - $this->setTemplateVar('elements',$list); - - - $project = new Project( $this->template->projectid ); - - - $models = array(); - - foreach( $project->getModels() as $modelId => $modelName ) - { - $templatemodel = new TemplateModel( $this->template->templateid, $modelId ); - $templatemodel->load(); - - $text = $templatemodel->src; - - foreach( $this->template->getElementIds() as $elid ) - { - $element = new Element( $elid ); - $element->load(); - - // Fix old stuff: - $text = str_replace('{{'.$elid.'}}', - '{{'.$element->name.'}}', - $text ); - $text = str_replace('{{->'.$elid.'}}', - '{{goto.'.$element->name.'}}', - $text ); - $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}', - '{{^'.$element->name.'}}', - $text ); - $text = str_replace('{{IFEMPTY:'.$elid.':END}}', - '{{/'.$element->name.'}}', - $text ); - $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}', - '{{#'.$element->name.'}}', - $text ); - $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}', - '{{/'.$element->name.'}}', - $text ); - } - - $models[ $modelId ] = array( - 'name' => $modelName, - 'source' => $text, - 'modelid' => $modelId - ); - } - - $this->setTemplateVar( 'models',$models ); - - - } - - - 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() - { - $project = new Project( $this->template->projectid ); - $modelId = $this->getRequestId('modelid'); - - $modelSrc = array(); - - $templatemodel = new TemplateModel( $this->template->templateid, $modelId ); - $templatemodel->load(); - - $text = $templatemodel->src; - - foreach( $this->template->getElementIds() as $elid ) - { - $element = new Element( $elid ); - $element->load(); - - // Fix old stuff: - $text = str_replace('{{'.$elid.'}}', - '{{'.$element->name.'}}', - $text ); - $text = str_replace('{{->'.$elid.'}}', - '{{goto.'.$element->name.'}}', - $text ); - $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}', - '{{^'.$element->name.'}}', - $text ); - $text = str_replace('{{IFEMPTY:'.$elid.':END}}', - '{{/'.$element->name.'}}', - $text ); - $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}', - '{{#'.$element->name.'}}', - $text ); - $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}', - '{{/'.$element->name.'}}', - $text ); - } - - $this->setTemplateVar( 'modelid',$modelId ); - $this->setTemplateVar( 'source' ,$text ); - $this->setTemplateVar( 'extension',$templatemodel->extension ); - } - - - // Anzeigen aller Templates - // - function listingView() - { - $list = array(); - - $project = new Project( $this->template->projectid ); - - foreach( $project->getTemplates() 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(); - - $publisher = new PublishPublic( $this->template->projectid ); - - foreach( $objectIds as $objectid ) - { - $page = new Page( $objectid ); - $page->load(); - - if ( !$page->hasRight( Acl::ACL_PUBLISH ) ) - continue; - - $page->publisher = $publisher; - $page->publish(); - } - - $this->addNotice('template', 0, $this->template->name, 'PUBLISHED', Action::NOTICE_OK, array(), array_map(function ($obj) { - return $obj['full_filename']; - }, $publisher->publishedObjects)); - - $publisher->close(); - } - - - } \ No newline at end of file diff --git a/modules/cms/action/TemplatelistAction.class.php b/modules/cms/action/TemplatelistAction.class.php @@ -53,160 +53,4 @@ class TemplatelistAction extends BaseAction $this->project = new Project( $this->request->getRequestId()); } - - - /** - * Bearbeiten einer Vorlage - */ - function editView() - { - $this->nextSubAction('show'); - } - - - - // Anzeigen aller Templates - // - function showView() - { - $list = array(); - - foreach( $this->project->getTemplates() as $id=>$name ) - { - $list[$id] = array(); - $list[$id]['name'] = $name; - $list[$id]['id' ] = $id; - } - - $this->setTemplateVar('templates',$list); - } - - - - /** - * Add a template. - */ - public function addView() - { - $this->setTemplateVar( 'templates',$this->project->getTemplates() ); - $this->setTemplateVar( 'copytemplateid','' ); - - /* - $examples = array(); - $dir = opendir( 'examples/templates'); - while( $file = readdir($dir) ) - { - if ( substr($file,0,1) != '.') - { - $examples[$file] = $file; - } - } - - $this->setTemplateVar( 'examples',$examples ); - $this->setTemplateVar( 'example','' ); - */ - - } - - - - public function addPost( $name ) - { - // create a new template. - $template = new Template(); - $template->projectid = $this->project->projectid; - $template->name = $name; - $template->add(); - - $this->addNoticeFor($template, Messages::ADDED); - - $copytemplateid = $this->getRequestId('copytemplateid'); - if ( $copytemplateid ) { - - // Template kopieren. - $copyTemplate = new Template( $copytemplateid ); - $copyTemplate->load(); - - // Copy all elements - foreach( $copyTemplate->getElements() as $element ) - { - /* @type $element Element */ - $element->load(); - $element->templateid = $template->templateid; - $element->add(); - $element->save(); - } - - // copy all template models - foreach( $this->project->getModelIds() as $modelid ) - { - // Template laden - $copyTemplate->load(); - - $copyTemplateModel = $copyTemplate->loadTemplateModelFor( $modelid ); - - $newTemplateModel = $template->loadTemplateModelFor( $modelid ); - $newTemplateModel->src = $copyTemplateModel->src; - $newTemplateModel->extension = $copyTemplateModel->extension; - $newTemplateModel->save(); - } - - $this->addNoticeFor( $copyTemplate, Messages::COPIED); - - /* - case 'example': - - // Neues Template anlegen. - $template = new Template(); - $template->projectid = $this->project->projectid; - - $template->add( $this->getRequestVar('name') ); - - $templateModel = $template->loadTemplateModelFor( $this->project->getDefaultModelId() ); - - // FIXME - $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(); - } - } - $template->name = $this->getRequestVar('name'); - $templateModel->src = str_replace(';',"\n",$templateModel->src); - - foreach( $template->getElementNames() as $elid=>$elname ) - { - $templateModel->src = str_replace('{{'.$elname.'}}' ,'{{'.$elid.'}}' ,$templateModel->src ); - $templateModel->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$templateModel->src ); - } - - $template->save(); - $templateModel->save(); - - $this->addNotice('template', 0, $template->name, 'ADDED', 'ok'); - - break; -*/ - } - - } - - } \ No newline at end of file diff --git a/modules/cms/action/TextAction.class.php b/modules/cms/action/TextAction.class.php @@ -63,44 +63,4 @@ class TextAction extends FileAction parent::setBaseObject( $text ); } - - - public function valuePost() - { - $this->text->value = $this->getRequestVar('text', RequestParams::FILTER_RAW); - $this->text->saveValue(); - - $this->addNoticeFor($this->text,Messages::VALUE_SAVED); - $this->text->setTimestamp(); - } - - - /** - * Only needed because there is a special template for text nodes. - */ - public function valueView() - { - $this->setTemplateVar( 'text', $this->text->loadValue() ); - - parent::valueView(); - } - - - /** - * Only needed because there is a special template for text nodes. - */ - public function showView() { - - parent::showView(); - } - - /** - * Displaying the text content. - */ - public function previewView() - { - $this->setTemplateVar( 'text', $this->text->loadValue() ); - - parent::previewView(); - } } diff --git a/modules/cms/action/UrlAction.class.php b/modules/cms/action/UrlAction.class.php @@ -63,107 +63,4 @@ class UrlAction extends ObjectAction parent::setBaseObject( $url ); } - - - function remove() - { - $this->setTemplateVars( $this->url->getProperties() ); - } - - - - function delete() - { - if ( $this->hasRequestVar("delete") ) - { - $this->url->delete(); - $this->addNotice('url', 0, $this->url->name, 'DELETED'); - } - } - - - - public function removeView() - { - $this->setTemplateVar( 'name',$this->url->filename ); - } - - - public function removePost() - { - if ( $this->getRequestVar('delete') != '' ) - { - $this->url->delete(); - $this->addNotice('url', 0, $this->url->filename, 'DELETED', Action::NOTICE_OK); - } - else - { - $this->addNotice('url', 0, $this->url->filename, 'CANCELED', Action::NOTICE_WARN); - } - } - - - /** - * Abspeichern der Eigenschaften - */ - public function valuePost() - { - $this->url->url = $this->getRequestVar('url'); - $this->url->save(); - - $this->addNoticeFor( $this->url,Messages::SAVED ); - } - - - - public function valueView() - { - $this->setTemplateVars( $this->url->getProperties() ); - - // Typ der Verknuepfung - $this->setTemplateVar('type' ,$this->url->getType() ); - $this->setTemplateVar('url' ,$this->url->url ); - } - - - public function editView() - { - $this->setTemplateVars( $this->url->getProperties() ); - - // Typ der Verknuepfung - $this->setTemplateVar('type' ,$this->url->getType() ); - $this->setTemplateVar('url' ,$this->url->url ); - } - - - public function showView() - { - // Angabe Content-Type - header('Content-Type: text/html' ); - - header('X-Url-Id: ' .$this->url->urlid ); - header('X-Id: ' .$this->url->id ); - header('Content-Description: '.$this->url->filename() ); - - echo '<html><body>'; - echo '<h1>'.$this->url->filename.'</h1>'; - echo '<hr />'; - echo '<a href="'.$this->url->url.'">'.$this->url->url.'</a>'; - echo '</body></html>'; - - exit; - - } - - - - /** - * Vorschau anzeigen - */ - function previewView() - { - $this->setTemplateVar('preview_url',$this->url->url ); - } - - } \ No newline at end of file diff --git a/modules/cms/action/UserAction.class.php b/modules/cms/action/UserAction.class.php @@ -56,411 +56,14 @@ class UserAction extends BaseAction * UserAction constructor. * @throws \util\exception\ObjectNotFoundException */ - function __construct() - { + function __construct() { parent::__construct(); - } - public function init() - { + public function init() { $this->user = new User( $this->getRequestId() ); $this->user->load(); $this->setTemplateVar('userid',$this->user->userid); } - - - public function propPost() - { - if ( ! $this->getRequestVar('name') ) - throw new \util\exception\ValidationException( 'name'); - - // Benutzer speichern - $this->user->name = $this->getRequestVar('name' ); - $this->user->fullname = $this->getRequestVar('fullname'); - $this->user->isAdmin = $this->hasRequestVar('is_admin'); - $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' ); - - if ( Configuration::get(['security','user','show_admin_mail']) ) - $this->user->mail = $this->getRequestVar('mail' ); - - $this->user->style = $this->getRequestVar('style' ); - - $this->user->save(); - $this->addNotice('user', 0, $this->user->name, 'SAVED', 'ok'); - } - - - - function removeView() - { - $this->setTemplateVars( $this->user->getProperties() ); - } - - - - public function removePost() - { - $this->user->delete(); - $this->addNoticeFor( $this->user ,Messages::DELETED); - } - - - public function addgrouptouserPost() - { - $group = new Group( $this->request->getRequiredRequestId('groupid' ) ); - $group->load(); - - $this->user->addGroup( $group->groupid ); - - $this->addNoticeFor( $this->user, Messages::ADDED); - } - - - function addgroup() - { - // Alle hinzufuegbaren Gruppen ermitteln - $this->setTemplateVar('groups',$this->user->getOtherGroups()); - } - - - function delgroup() - { - $this->user->delGroup( $this->getRequestVar('groupid') ); - - $this->addNotice('user', 0, $this->user->name, 'DELETED', 'ok'); - } - - - /** - * Das Kennwort wird an den Benutzer geschickt - * - * @access private - */ - protected 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(); - } - - - /** - * Change password for user. - */ - public function pwPost() - { - $password = $this->getRequestVar('password'); - - if ( !$password ) - $password = $this->getRequestVar('password_proposal'); - - if ( strlen($password) < Configuration::subset(['security','password'])->get('min_length',8) ) - throw new ValidationException('password',Messages::PASSWORD_MINLENGTH ); - - $this->user->setPassword($password,!$this->hasRequestVar('timeout') ); // Kennwort setzen - - // E-Mail mit dem neuen Kennwort an Benutzer senden - if ( $this->hasRequestVar('email') && - $this->user->mail && // user has an e-mail. - Configuration::subset('mail')->is('enabled',true) - ) { - $this->mailPw( $password ); - $this->addNoticeFor( $this->user, Messages::MAIL_SENT); - } - - $this->addNoticeFor($this->user, Messages::SAVED); - - } - - - - function listingView() - { - $list = array(); - - foreach( User::getAllUsers() as $user ) - { - /* @var $user User */ - $list[$user->userid] = $user->getProperties(); - } - $this->setTemplateVar('el',$list); - } - - - /** - * Eigenschaften des Benutzers ermitteln. - */ - public function propView() - { - $issuer = urlencode(Configuration::subset('application')->get('operator',Startup::TITLE)); - $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 = Messages::$AVAILABLE_LANGUAGES; - 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 = Configuration::subset(['interface','gravatar'] ); - - - if ( $gravatarConfig->is('enabled',true) && $this->user->mail ) - { - $url = 'http://www.gravatar.com/avatar/'.md5($this->user->mail).'?'; - - $url .= '&s='.$gravatarConfig->get('size' ,80 ); - $url .= '&d='.$gravatarConfig->get('default',404); - $url .= '&r='.$gravatarConfig->get('rating' ,'g'); - - $this->setTemplateVar( 'image', $url ); - } else { - $this->setTemplateVar( 'image', 'about:blank' ); - } - - - - - $issuer = urlencode(Configuration::subset('application')->get('operator',Startup::TITLE)); - $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)) - ); - - } - - - 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); - } - - - 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', 0, $name, 'ADDED'); - $aenderung = true; - } - - if ( $hasGroup && !$this->hasRequestVar('group'.$id) ) - { - $this->user->delGroup($id); - $this->addNotice('group', 0, $name, 'DELETED'); - $aenderung = true; - } - } - - if ( ! $aenderung ) - $this->addNotice('group', 0, $name, 'NOTHING_DONE'); - } - - - /** - * Aendern des Kennwortes - */ - function pwView() - { - $this->setTemplateVar('enabled',$this->user->type == User::AUTH_TYPE_INTERNAL ); - - $this->setTemplateVar('password_proposal', $this->user->createPassword() ); - } - - - /** - * Anzeigen der Benutzerrechte - * @throws \util\exception\ObjectNotFoundException - */ - function rightsView() - { - $rights = $this->user->getAllAcls(); - - $projects = array(); - - foreach( $rights as $acl ) - { - /* @var $acl Acl */ - if ( !isset($projects[$acl->projectid])) - { - $p = Project::create( $acl->projectid ); - - $projects[$acl->projectid] = array(); - $projects[$acl->projectid]['projectname'] = $p->load()->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'] = \cms\base\Language::lang('ALL_LANGUAGES'); - } - - - $o = new BaseObject($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', 0, $this->user->name, 'ADMIN_NEEDS_NO_RIGHTS', Action::NOTICE_WARN); - } - - - /** - * Switch to this user - */ - public function switchPost() - { - $this->addNoticeFor( $this->user,Messages::USER_LOGIN ); - - // Und in der Sitzung speichern. - Session::setUser( $this->user ); - } - - - - public function switchView() { - $this->setTemplateVar('username',$this->user->getName() ); - } - - - /** - * Ermittelt die letzten Änderungen, die durch den aktuellen Benutzer in allen Projekten gemacht worden sind. - */ - public function historyView() - { - $lastChanges = $this->user->getLastChanges(); - - $timeline = array(); - - foreach( $lastChanges as $entry ) - { - $timeline[ $entry['objectid'] ] = $entry; - $baseObject = new BaseObject( $entry['objectid']); - $baseObject->objectLoad(); - $timeline[ $entry['objectid'] ]['type'] = $baseObject->getType(); - } - $this->setTemplateVar('timeline', $timeline); - } - - } \ No newline at end of file diff --git a/modules/cms/action/userlist/UserlistAddAction.class.php b/modules/cms/action/userlist/UserlistAddAction.class.php @@ -7,6 +7,11 @@ use cms\model\User; use language\Messages; use util\exception\ValidationException; +/** + * Adding a new user. + * + * @package cms\action\userlist + */ class UserlistAddAction extends UserlistAction implements Method { public function view() { } diff --git a/modules/cms/action/userlist/UserlistEditAction.class.php b/modules/cms/action/userlist/UserlistEditAction.class.php @@ -4,6 +4,9 @@ use cms\action\Method; use cms\action\UserlistAction; use cms\model\User; +/** + * Shows all users. + */ class UserlistEditAction extends UserlistAction implements Method { public function view() {