ModelAction.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 // ---------------------------------------------------------------------------
00003 // $Id$
00004 // ---------------------------------------------------------------------------
00005 // OpenRat Content Management System
00006 // Copyright (C) 2002-2004 Jan Dankert, cms@jandankert.de
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 // ---------------------------------------------------------------------------
00022 // $Log$
00023 // Revision 1.10  2007-05-08 20:25:58  dankert
00024 // Erweiterung der Methode "checkmenu()"
00025 //
00026 // Revision 1.9  2007-05-08 20:21:03  dankert
00027 // ?berschreiben der Methode "checkmenu()"
00028 //
00029 // Revision 1.8  2007-04-08 21:18:16  dankert
00030 // Korrektur URL in listing()
00031 //
00032 // Revision 1.7  2007/01/21 22:27:49  dankert
00033 // Direkt Punkt "Bearbeiten" ?ffnen.
00034 //
00035 // Revision 1.6  2006/01/29 17:18:58  dankert
00036 // Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden
00037 //
00038 // Revision 1.5  2004/12/19 14:55:27  dankert
00039 // Anpassung von urls
00040 //
00041 // Revision 1.4  2004/12/13 22:17:51  dankert
00042 // URL-Korrektur
00043 //
00044 // Revision 1.3  2004/05/07 21:37:31  dankert
00045 // Url ?ber Html::url erzeugen
00046 //
00047 // Revision 1.2  2004/05/02 14:49:37  dankert
00048 // Einf?gen package-name (@package)
00049 //
00050 // Revision 1.1  2004/04/24 15:14:52  dankert
00051 // Initiale Version
00052 //
00053 // ---------------------------------------------------------------------------
00054 
00055 
00062 class ModelAction extends Action
00063 {
00064      var $defaultSubAction = 'listing';
00065      var $model;
00066 
00067 
00068      function ModelAction()
00069      {
00070           if   ( $this->getRequestId() != 0 )
00071           {
00072                $this->model = new Model( $this->getRequestId() );
00073                $this->model->load();
00074           }
00075           
00076           $this->project = Session::getProject();
00077      }
00078 
00079 
00080      function add()
00081      {
00082      }
00083 
00084 
00085      function addmodel()
00086      {
00087           $model = new Model();
00088           $model->projectid = $this->project->projectid;
00089           $model->name      = $this->getRequestVar('name');
00090           $model->add();
00091           
00092           // Wenn kein Namen eingegeben, dann einen setzen.
00093           if   ( empty($model->name) )
00094           {
00095                // Name ist "Variante <id>"
00096                $model->name = lang('GLOBAL_MODEL').' '.$model->modelid;
00097                $model->save();
00098           }
00099      }
00100 
00101 
00102 
00107      function remove()
00108      {
00109           $this->model->load();
00110 
00111           $this->setTemplateVar( 'name',$this->model->name );
00112      }
00113      
00114      
00115      function delete() 
00116      {
00117           if   ( $this->getRequestVar('confirm') == '1' )
00118           {
00119                $this->model->delete();
00120           }
00121      }
00122      
00123      
00124      
00125      // Speichern eines Modells
00126      function save()
00127      {
00128           if   ( $this->getRequestVar('name') != '' )
00129           {
00130                $this->model->name = $this->getRequestVar('name');
00131                $this->model->save();
00132                $this->addNotice('model',$this->model->name,'SAVED','ok');
00133           }
00134           else
00135           {
00136                $this->addNotice('model',$this->model->name,'NOT_SAVED','error');
00137           }
00138      
00139           // Baum aktualisieren
00140 //        $this->setTemplateVar('tree_refresh',true);
00141      }
00142 
00143 
00144      function setdefault()
00145      {
00146           if   ( !$this->userIsAdmin() ) exit();
00147 
00148           $this->model->setDefault();
00149      
00150           $this->callSubAction('listing');
00151      }
00152 
00153 
00154      function listing()
00155      {
00156           global $conf_php;
00157           $actModel = Session::getProjectModel();
00158 
00159 //        $var['act_modelid'] = $this->getSessionVar('modelid');
00160      
00161           $list = array();
00162           foreach( $this->project->getModelIds() as $id )
00163           {
00164                $m = new Model( $id );
00165                $m->load();
00166 
00167                $list[$id]['name'] = $m->name;
00168                
00169                if   ( $this->userIsAdmin() )
00170                     $list[$id]['url' ] = Html::url('main','model',$id,
00171                                                    array(REQ_PARAM_TARGETSUBACTION=>'edit') );
00172 
00173                if   ( ! $m->isDefault && $this->userIsAdmin() )
00174                     $list[$id]['default_url'] = Html::url('model','setdefault',$id);
00175 
00176                if   ( $actModel->modelid != $m->modelid )
00177                     $list[$id]['select_url' ] = Html::url('index','model',$id);
00178           }
00179           $this->setTemplateVar( 'el',$list );
00180           $this->setTemplateVar( 'add',$this->userIsAdmin() );
00181      
00182           $this->forward('model_list');
00183      }
00184 
00185 
00190      function edit()
00191      {
00192           $this->model->load();
00193      
00194           $this->setTemplateVars( $this->model->getProperties() );
00195      }
00196 
00197 
00198      function checkmenu( $menu )
00199      {
00200           switch( $menu )
00201           {
00202                case 'remove':
00203                     $actModel = Session::getProjectModel();
00204                     return
00205                          $this->userIsAdmin()                 &&
00206                          count( $this->model->getAll() ) >= 2 &&
00207                          $actModel->modelid != $this->model->modelid;
00208                     
00209                case 'add':
00210                     return
00211                          $this->userIsAdmin();
00212                
00213                default:
00214                     return true;
00215           }
00216      }
00217 }

Erzeugt am Thu May 14 00:55:48 2009 für OpenRat von  doxygen 1.5.8