ProjectAction.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.19  2008-03-06 21:10:21  dankert
00024 // Ausgabe von PHPINFO erm?glichen (es wird phpinfo(); aufgerufen).
00025 //
00026 // Revision 1.18  2007-12-22 00:21:41  dankert
00027 // Funktion f?r Projektbeispiel entfernt.
00028 //
00029 // Revision 1.17  2007-12-21 23:27:53  dankert
00030 // Felder mit Namen versehen. Beim Anlegen von Projekten Beispiel-Projekte ausw?hlen.
00031 //
00032 // Revision 1.16  2007-11-17 20:55:41  dankert
00033 // Fehlerhandling verbessert wenn Projektname nicht eingegeben.
00034 //
00035 // Revision 1.15  2007-11-05 20:51:03  dankert
00036 // Aufruf von "addValidationError(...)" bei Eingabefehlern.
00037 //
00038 // Revision 1.14  2007-10-04 21:50:37  dankert
00039 // Notiz, wenn Projekt gespeichert.
00040 //
00041 // Revision 1.13  2007-04-21 11:50:50  dankert
00042 // Umbenennung von Im- in Export.
00043 //
00044 // Revision 1.12  2007-04-16 21:25:41  dankert
00045 // Neuer Men?punkt im Projektmen?: Import.
00046 //
00047 // Revision 1.11  2007/01/21 15:00:03  dankert
00048 // Parameter TARGETSUBACTION verwenden.
00049 //
00050 // Revision 1.10  2006/06/01 20:59:27  dankert
00051 // Projektwartung: Suche nach verlorenen Dateien.
00052 //
00053 // Revision 1.9  2006/06/01 20:07:01  dankert
00054 // Neue Methode "maintenance"
00055 //
00056 // Revision 1.8  2006/01/23 23:10:46  dankert
00057 // *** empty log message ***
00058 //
00059 // Revision 1.7  2004/12/26 20:24:16  dankert
00060 // Korrektur Abfrage Berechtigungen
00061 //
00062 // Revision 1.6  2004/12/19 15:16:02  dankert
00063 // div. Korrekturen
00064 //
00065 // Revision 1.5  2004/12/15 23:25:32  dankert
00066 // Anpassung an Session-Funktionen
00067 //
00068 // Revision 1.4  2004/11/10 22:40:14  dankert
00069 // Neue Funktion zur Projektauswahl nach dem Login
00070 //
00071 // Revision 1.3  2004/05/19 21:12:49  dankert
00072 // Korrektur listing()
00073 //
00074 // Revision 1.2  2004/05/02 14:49:37  dankert
00075 // Einf?gen package-name (@package)
00076 //
00077 // Revision 1.1  2004/04/24 15:14:52  dankert
00078 // Initiale Version
00079 //
00080 // ---------------------------------------------------------------------------
00081 
00082 
00089 class ProjectAction extends Action
00090 {
00091      var $project;
00092      var $defaultSubAction = 'listing';
00093 
00094 
00095      function ProjectAction()
00096      {
00097           if   ( $this->getRequestId()!=0 )
00098           {
00099                $this->project = new Project( $this->getRequestId() );
00100                $this->project->load();
00101           }
00102           
00103           
00104      }
00105 
00106 
00107      function save()
00108      {
00109           if   ( $this->getRequestVar('name') != '')
00110           {
00111                $this->project->name                = $this->getRequestVar('name'               );
00112                $this->project->target_dir          = $this->getRequestVar('target_dir'         );
00113                $this->project->ftp_url             = $this->getRequestVar('ftp_url'            );
00114                $this->project->ftp_passive         = $this->getRequestVar('ftp_passive'        );
00115                $this->project->cmd_after_publish   = $this->getRequestVar('cmd_after_publish'  );
00116                $this->project->content_negotiation = $this->getRequestVar('content_negotiation');
00117                $this->project->cut_index           = $this->getRequestVar('cut_index'          );
00118      
00119                $this->addNotice('project',$this->project->name,'SAVED','ok');
00120                $this->project->save(); // speichern
00121           }
00122           else
00123           {
00124                $this->addValidationError('name');
00125                $this->callSubAction('edit');
00126           }
00127      }
00128 
00129 
00130 
00131      function add()
00132      {
00133           $this->setTemplateVar( 'projects',Project::getAll() );
00134      }
00135      
00136 
00141      function addproject()
00142      {
00143           if   ( !$this->hasRequestVar('type') )
00144           {
00145                $this->addValidationError('type');
00146                $this->callSubAction('add');
00147                return;
00148           }
00149           else
00150           {
00151                switch( $this->getRequestVar('type') )
00152                {
00153                     case 'empty':
00154                          if   ( !$this->hasRequestVar('name') )
00155                          {
00156                               $this->addValidationError('name');
00157                               $this->callSubAction('add');
00158                               return;
00159                          }
00160                          $this->project = new Project();
00161                          $this->project->name = $this->getRequestVar('name');
00162                          $this->project->add();
00163                          break;
00164                     case 'copy':
00165                          $db = db_connection();
00166                          $project = new Project($this->getRequestVar('projectid'));
00167                          $project->load();
00168                          $project->export($db->id);
00169                          break;
00170                     default:
00171                          Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') );
00172                }
00173                
00174                $this->addNotice('project',$this->project->name,'ADDED'); 
00175           }
00176      }
00177 
00178 
00183      function listing()
00184      {
00185           global $conf_php;
00186 
00187           // Projekte ermitteln
00188           $list = array();
00189 
00190           foreach( Project::getAll() as $id=>$name )
00191           {
00192                $list[$id]             = array();
00193                $list[$id]['url'     ] = Html::url('main' ,'project',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit'));
00194                $list[$id]['use_url' ] = Html::url('index','project',$id);
00195                $list[$id]['name'    ] = $name;
00196           }
00197           $this->setTemplateVar('el',$list);
00198      
00199           $this->forward('project_list');
00200      }
00201 
00202 
00203      function select()
00204      {
00205           $user     = Session::getUser();
00206           $projects = $user->projects;
00207 
00208           // Administrator sieht Administrationsbereich
00209           if   ( $user->isAdmin )
00210                $projects = array_merge( array("-1"=>lang('ADMINISTRATION')),$projects );
00211 
00212           // Projekte ermitteln
00213           $list = array();
00214 
00215           foreach( $projects as $id=>$name )
00216           {
00217                $list[$id]         = array();
00218                $list[$id]['url' ] = Html::url('index','project',$id);
00219                $list[$id]['name'] = $name;
00220           }
00221           $this->setTemplateVar('el',$list);
00222      
00223           $this->forward('project_select');
00224      }
00225 
00226 
00227      function edit()
00228      {
00229           // Projekt laden
00230           $this->setTemplateVars( $this->project->getProperties() );
00231 
00232           $this->forward('project_edit');
00233 
00234      }
00235      
00236      
00237      function remove()
00238      {
00239           $this->setTemplateVar( 'name',$this->project->name );
00240      }
00241      
00242      
00243      function delete()
00244      {
00245           if   ( $this->getRequestVar('delete') != '' )
00246           {
00247                // Gesamtes Projekt loeschen
00248                $this->project->delete();
00249 
00250                $this->setTemplateVar('tree_refresh',true);
00251                $this->addNotice('project',$this->project->name,'DELETED'); 
00252           }
00253           else
00254           {
00255                $this->addValidationError('delete');
00256                $this->callSubAction('remove');
00257           }
00258      }
00259      
00260      
00261 
00262      function maintenance()
00263      {
00264           if   ( $this->hasRequestVar('ok') )
00265           {
00266                $this->project->checkLostFiles();
00267                $this->addNotice('project',$this->project->name,'DONE');
00268                $this->setTemplateVar('done',true);
00269           }
00270      }
00271 
00272 
00273 
00277      function export()
00278      {
00279           $db = db_connection();
00280           $this->setTemplateVar( 'dbid',$db->id );
00281 
00282           global $conf;
00283           $dbids = array();
00284           
00285           foreach( $conf['database'] as $dbname=>$dbconf )
00286           {
00287                if   ( is_array($dbconf) && $dbconf['enabled'])
00288                     $dbids[$dbname] = $dbconf['comment'];
00289           }
00290           $this->setTemplateVar( 'dbids',$dbids );
00291           
00292           
00293           if   ( $this->hasRequestVar('ok') )
00294           {
00295                $this->project->export( $this->getRequestVar('dbid') );
00296                
00297                $this->addNotice('project',$this->project->name,'DONE');
00298                $this->setTemplateVar('done',true);
00299           }
00300      }
00301      
00302      
00303      
00308      function phpinfo()
00309      {
00310           phpinfo();
00311      }
00312 }

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