MainmenuAction.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 // $Id$
00003 //
00004 // OpenRat Content Management System
00005 // Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 
00029 class MainmenuAction extends Action
00030 {
00031      var $defaultSubAction = 'login';
00032 
00033      var $subActionList = array();
00034      var $path          = array();
00035      var $search        = false;
00036      var $obj;
00037 
00038      
00039      function MainmenuAction()
00040      {
00041           $this->setTemplateVar('type',$this->getRequestVar(REQ_PARAM_SUBACTION) );
00042           
00043           
00044           switch( $this->getRequestVar( REQ_PARAM_SUBACTION) )
00045           {
00046                case 'page':
00047                case 'pageelement':
00048                case 'file':
00049                case 'link':
00050                case 'folder':
00051                case 'language':
00052                case 'model':
00053                case 'template':
00054                case 'element':
00055                     $this->addSubAction( 'show'  ,-1 );
00056                     $this->addSubAction( 'create',-1 );
00057                     $this->addSubAction( 'edit'  ,-1 );
00058                     $this->addSubAction( 'el'    ,-1 );
00059                     $this->addSubAction( 'pub'   ,-1 );
00060                     $this->addSubAction( 'prop'  ,-1 );
00061                     $this->addSubAction( 'src'   ,-1 );
00062                     $this->addSubAction( 'rights',-1 );
00063                     $this->search = true;
00064                     break;
00065 
00066                case 'project':
00067                case 'user':
00068                case 'group':
00069                     $this->addSubAction( 'listing'    ,-1 );
00070                     $this->addSubAction( 'add'        ,-1 );
00071                     $this->addSubAction( 'edit'       ,-1 );
00072                     $this->addSubAction( 'memberships',-1 );
00073                     $this->addSubAction( 'pw'         ,-1 );
00074                     $this->addSubAction( 'rights'     ,-1 );
00075                     $this->addSubAction( 'phpinfo'    ,-1 );
00076                     break;
00077 
00078                case 'blank':
00079                default:
00080                     $this->setTemplateVar('windowMenu',array() );
00081                     $this->setTemplateVar('text'      ,''      );
00082           }
00083      }
00084      
00085      
00086      function addSubAction( $name,$aclbit=0 )
00087      {
00088           // Wenn $aclbit nicht vorhanden oder die entsprechende Berechtigung vorhanden ist,
00089           // dann Men�punkt erg�nzen.
00090           if   ( $aclbit==-1 )
00091                $url = '';
00092           elseif   ( $aclbit==0 || $this->obj->hasRight($aclbit) )
00093                $url = Html::url($this->subActionName,$name,$this->getRequestId() );
00094           else
00095                $url = '';
00096           $this->subActionList[ $name ] = array( 'text' =>'MENU_'.strtoupper($name),
00097                                                  'title'=>'MENU_'.strtoupper($name).'_DESC',
00098                                                  'key'  =>strtoupper(lang('ACCESSKEY_MAIN_'.strtoupper($name))),
00099                                                  'url'  =>$url );
00100      }
00101      
00102      
00103      function element()
00104      {
00105           $this->subActionName = 'element';
00106           $this->setTemplateVar('type','element' );
00107 
00108           $element = new Element( $this->getRequestId() );
00109           $element->load();
00110 
00111           //global $REQ;
00112           //$REQ['id'] = $element->templateid;
00113           
00114           $template = new Template( $element->templateid );
00115           $template->load();
00116 
00117           $this->addPath( lang('templates'),lang('templates'),Html::url('main','template',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'');
00118           $this->addPath( $template->name,lang('TEMPLATE'),Html::url('main','template',$template->templateid),'');
00119           $this->setTemplateVar('text',$element->name );
00120           
00121           //$this->addSubaction('listing');
00122           //$this->addSubaction('show' );
00123           //$this->addSubaction('edit' );
00124           //$this->addSubaction('el'   );
00125           //if ( $this->writable )
00126           //   $this->addSubaction('src'  );
00127           //$this->addSubaction('prop' );
00128 
00129           $this->setTemplateVar('windowMenu',$this->subActionList);
00130      }
00131 
00132 
00133      function addPath( $name,$title,$url,$type )
00134      {
00135           $this->path[$name] = array('name' =>$name ,
00136                                      'title'=>$title,
00137                                      'url'  =>$url  ,
00138                                      'type' =>$type  ); 
00139      }
00140 
00141 
00142      function template()
00143      {
00144           //$this->addSubaction('listing');
00145      
00146           if   ( $this->getRequestId() != 0 )
00147           {
00148                $template = new Template( $this->getRequestId() );
00149                $template->load();
00150                $this->setTemplateVar('text',$template->name );
00151                $this->addPath( lang('templates'),lang('templates'),Html::url('main','template',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'');
00152                
00153                $this->addSubaction('show' );
00154 //             $this->addSubaction('edit' );
00155                $this->addSubaction('src'  );
00156                $this->addSubaction('el'   );
00157                $this->addSubaction('prop' );
00158           }
00159           else
00160           {
00161                $this->setTemplateVar('text',lang('templates') );
00162           }
00163 
00164           $this->setTemplateVar('param' ,'templateid');
00165           $this->setTemplateVar('windowMenu',$this->subActionList);
00166      }
00167 
00168 
00169 
00170      function pageelement()
00171      {
00172           //$this->subActionName = 'page';
00173           //$this->callSubAction('page');
00174           
00175           
00176           $page = Session::getObject();
00177           if   ( $page->objectid != $this->getRequestId() )
00178           {
00179                $page = new Page( $this->getRequestId() );
00180                Session::setObject( $page );
00181                $page->load();
00182           }
00183           
00184           $folder = new Folder( $page->parentid );
00185           $folder->filenames = false;
00186           $folder->load();
00187 
00188           foreach( $folder->parentObjectNames(true,true) as $id=>$name )
00189                $this->addPath($name,$name,Html::url('main','folder',$id),'folder');
00190 
00191           $this->addPath($page->name,$page->name,Html::url('main','page',$page->id),'page');
00192           
00193           // Ermitteln Namen des Elementes
00194           $element = new Element( $this->getRequestVar('elementid'));
00195           $element->load();
00196           $this->setTemplateVar('text',$element->name);
00197      
00198 //        $this->obj = &$page;
00199 //        $this->addSubAction('show'  ,ACL_READ    );
00200 //        $this->addSubAction('edit'  ,ACL_WRITE   );
00201 //        $this->addSubAction('el'    ,ACL_WRITE   );
00202 //        $this->addSubAction('form'  ,ACL_WRITE   );
00203 
00204 //        $this->addSubAction('pub'   ,ACL_PUBLISH );
00205 //        $this->addSubAction('prop'  ,ACL_PROP    );
00206 //        $this->addSubAction('src'   ,ACL_PROP    );
00207 //        $this->addSubAction('rights',ACL_GRANT   );
00208 
00209           $this->setTemplateVar('windowMenu',$this->subActionList);
00210      }
00211 
00212 
00213 
00214      function page()
00215      {
00216           $page = Session::getObject();
00217           if   ( $page->objectid != $this->getRequestId() )
00218           {
00219                $page = new Page( $this->getRequestId() );
00220                Session::setObject( $page );
00221           }
00222           $page->load();
00223           $this->lastModified( $page->lastchangeDate );
00224           
00225           $this->setTemplateVar('nr'      ,$page->objectid);
00226           $this->setTemplateVar('actionid',$page->objectid);
00227      
00228           $folder = new Folder( $page->parentid );
00229           $folder->filenames = false;
00230           $folder->load();
00231 
00232           foreach( $folder->parentObjectNames(true,true) as $id=>$name )
00233                $this->addPath($name,$name,Html::url('main','folder',$id),'folder');
00234 
00235 //        $others = $folder->getObjects();
00236 //        $o2 = array();
00237 //        foreach( $others as $o )
00238 //             if   ( $o->isPage )
00239 //                  $o2[$o->objectid] = Text::maxLength($o->name,25);
00240 //             
00241 //        $this->setTemplateVar('otherObjects',$o2);
00242      
00243           // Ermitteln Namen der Seite
00244           $this->setTemplateVar('text',$page->name);
00245      
00246           $this->obj = &$page;
00247           $this->addSubAction('show'  ,ACL_READ    );
00248           $this->addSubAction('edit'  ,ACL_WRITE   );
00249           $this->addSubAction('el'    ,ACL_WRITE   );
00250 //        $this->addSubAction('form'  ,ACL_WRITE   );
00251 
00252           $this->addSubAction('pub'   ,ACL_PUBLISH );
00253           $this->addSubAction('prop'  ,ACL_PROP    );
00254           $this->addSubAction('src'   ,ACL_PROP    );
00255           $this->addSubAction('rights',ACL_GRANT   );
00256 
00257           $this->setTemplateVar('windowMenu',$this->subActionList);
00258      }
00259 
00260 
00261 
00262      function user()
00263      {
00264           global $conf;
00265           
00266           //$this->addSubaction('listing');
00267           $this->addSubaction('add'    );
00268 
00269           if   ( $this->getRequestId() != 0 )
00270           {
00271                $this->addPath( lang('USER'),lang('USER'),Html::url('main','user',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'user');
00272                $user = new User( $this->getRequestId() );
00273                $user->load();
00274                     
00275                $this->setTemplateVar('text',$user->name);
00276           
00277                $this->addSubaction('edit'   );
00278                $this->addSubaction('memberships' );
00279                
00280                // Kennwortaenderung ist nur sinnvoll, wenn kein LDAP verwendet wird
00281                if   ( @$conf['security']['auth']['type'] == 'database' && 
00282                          ( empty($user->ldap_dn) ||
00283                            !@$conf['security']['auth']['userdn'])  )
00284                $this->addSubaction('pw'     );
00285 
00286                $this->addSubaction('rights' );
00287           }
00288           else
00289           {
00290                $this->setTemplateVar('text',lang('USERS'));           
00291           }
00292           
00293           $this->setTemplateVar('windowMenu',$this->subActionList);
00294           $this->setTemplateVar('param'    ,'userid'            );
00295      }
00296 
00297 
00298 
00299      function group()
00300      {
00301 
00302           $this->addSubaction('listing'    );
00303           $this->addSubaction('add'        );
00304 
00305           if   ( $this->getRequestId() != 0 )
00306           {
00307                $group = new Group( $this->getRequestId() );
00308                $group->load();
00309                $this->setTemplateVar('text',$group->name);
00310                
00311                $this->addPath( lang('GROUPS'),lang('GROUPS'),Html::url('main','group',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'group');
00312                $this->addSubaction('memberships');
00313                $this->addSubaction('edit'   );
00314                $this->addSubaction('rights' );
00315           }
00316           else
00317           {
00318                $this->setTemplateVar('text',lang('GROUPS'));               
00319           }
00320           
00321           $this->setTemplateVar('windowMenu',$this->subActionList);
00322 
00323           $this->setTemplateVar('param'    ,'groupid'           );
00324      }
00325 
00326 
00327      function file()
00328      {
00329           $file = new File( $this->getRequestId() );
00330           $file->load();
00331           $this->lastModified( $file->lastchangeDate );
00332           
00333           $folder = new Folder( $file->parentid );
00334           $folder->filenames = false;
00335           $folder->load();
00336 
00337           $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
00338 
00339           foreach( $folder->parentObjectNames(true,true) as $id=>$name )
00340           {
00341                $this->addPath($name,$name,Html::url('main','folder',$id),'folder');
00342           }
00343 
00344           $this->setTemplateVar('text'  ,$file->name);
00345 
00346           $this->setTemplateVar('id','o'.$file->objectid);
00347      
00348           $this->obj = &$file;
00349           $this->addSubAction('show'  ,ACL_READ    );
00350 
00351           $this->addSubAction('edit'  ,ACL_WRITE   );
00352 
00353           $this->addSubAction('pub'   ,ACL_PUBLISH );
00354           $this->addSubAction('prop'  ,ACL_PROP    );
00355           $this->addSubAction('rights',ACL_GRANT   );
00356 
00357           $this->setTemplateVar('windowMenu',$this->subActionList);
00358 
00359           $this->setTemplateVar('param','objectid');
00360      }
00361 
00362 
00363 
00364      function prefs()
00365      {
00366           $this->addSubaction('show');
00367 
00368           $this->setTemplateVar('windowMenu',$this->subActionList);
00369           $this->setTemplateVar('param','conf');
00370      }
00371      
00372      
00373      
00374      function link()
00375      {
00376           // Ermitteln Sprache
00377           $link = new Link( $this->getRequestId() );
00378           $link->load();
00379           
00380           $folder = new Folder( $link->parentid );
00381           $folder->filenames = false;
00382           $folder->load();
00383 
00384           $this->setTemplateVar('nr',$this->getSessionVar('objectid'));
00385 
00386           foreach( $folder->parentObjectNames(true,true) as $id=>$name )
00387                $this->addPath($name,$name,Html::url('main','folder',$id),'folder');
00388 
00389           $this->setTemplateVar('text'  ,$link->name);
00390 
00391           $this->setTemplateVar('id','o'.$link->objectid);
00392 
00393           $this->obj = &$link;
00394           $this->addSubAction('edit'  ,ACL_WRITE);
00395           $this->addSubAction('prop'  ,ACL_PROP );
00396           $this->addSubAction('rights',ACL_GRANT);
00397 
00398           $this->setTemplateVar('windowMenu',$this->subActionList);
00399           $this->setTemplateVar('param','objectid');
00400      }
00401 
00402 
00403 
00404      function folder()
00405      {
00406           $folder = Session::getObject();
00407           if   ( $folder->objectid != $this->getRequestId() )
00408           {
00409                $folder = new Folder( $this->getRequestId() );
00410                Session::setObject( $folder );
00411           }
00412           $folder = new Folder( $folder->objectid );
00413           $folder->load();
00414           $this->obj = &$folder;
00415           $this->setTemplateVar('nr',$folder->objectid);
00416 
00417           $this->lastModified( $folder->lastchangeDate );
00418 
00419           foreach( $folder->parentObjectNames(true,false) as $id=>$name )
00420                $this->addPath($name,$name,Html::url('main','folder',$id),'folder');
00421           
00422           $this->setTemplateVar('text',$folder->name);
00423      
00424           $this->addSubAction('show',ACL_READ    );
00425 
00426           $this->addSubAction('create',ACL_CREATE_FOLDER );
00427           $this->addSubAction('create',ACL_CREATE_FILE   );
00428           $this->addSubAction('create',ACL_CREATE_PAGE   );
00429           $this->addSubAction('create',ACL_CREATE_LINK   );
00430           $this->addSubaction('el',-1 );
00431 
00432           $this->addSubAction('pub'   ,ACL_PUBLISH );
00433 
00434           if   ( !$folder->isRoot )
00435                $this->addSubAction('prop',ACL_PROP    );
00436 
00437           $this->addSubAction('rights',ACL_GRANT);
00438 
00439           $this->setTemplateVar('windowMenu',$this->subActionList);
00440           $this->setTemplateVar('param','objectid');
00441      }
00442 
00443 
00444      function project()
00445      {
00446           $this->setTemplateVar('path',array() );
00447 
00448           //$this->addSubaction('listing');
00449           $this->addSubaction('add'    );
00450           $this->addSubaction('phpinfo');
00451           
00452           if   ( $this->getRequestId() > 0 )
00453           {
00454                $this->addSubaction('edit');
00455 
00456                $project = new Project( $this->getRequestId() );
00457                $project->load();
00458                $this->setTemplateVar('text',$project->name );
00459                $this->addPath( lang('PROJECTS'),lang('PROJECTS'),Html::url('main','project',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'user');
00460           }
00461           else
00462           {
00463                $this->setTemplateVar('text',lang('GLOBAL_PROJECTS') );
00464           }
00465 
00466           $this->setTemplateVar('windowMenu',$this->subActionList);
00467           $this->setTemplateVar('param','projectid');
00468      }
00469 
00470 
00471      function language()
00472      {
00473           //$this->addSubaction('listing');
00474 
00475           if   ( $this->userIsAdmin() && $this->getRequestId()>0 )
00476           {
00477                $language = new Language($this->getRequestId());
00478                $language->load();
00479                $this->addPath( lang('LANGUAGES'),lang('LANGUAGES'),Html::url('main','language',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'');
00480                $this->addSubaction('edit');
00481                $this->setTemplateVar('text',$language->name);
00482           }
00483           else
00484           {
00485                $this->setTemplateVar('text',lang('LANGUAGES'));
00486           }
00487 
00488           $this->setTemplateVar('windowMenu',$this->subActionList);
00489           $this->setTemplateVar('param',REQ_PARAM_LANGUAGE_ID);
00490      }
00491 
00492 
00493 
00494      function model()
00495      {
00496           //$this->addSubaction('listing');
00497 
00498           if   ( $this->userIsAdmin() && $this->getRequestId()>0 )
00499           {
00500                $model = new Model( $this->getRequestId() );
00501                $model->load();
00502                $this->addPath( lang('MODELS'),lang('MODELS'),Html::url('main','model',0,array(REQ_PARAM_TARGETSUBACTION=>'listing')),'');
00503                $this->addSubaction('edit');
00504                $this->setTemplateVar('text',$model->name);
00505           }
00506           else
00507           {
00508                $this->setTemplateVar('text',lang('MODELS'));
00509           }
00510                
00511           $this->setTemplateVar('param','modelid');
00512           $this->setTemplateVar('windowMenu',$this->subActionList);
00513      }
00514 
00515 
00516      function search()
00517      {
00518           $this->addSubaction('prop'   );
00519           $this->addSubaction('content');
00520           $this->setTemplateVar('text',lang('GLOBAL_SEARCH'));
00521           $this->setTemplateVar('windowMenu',$this->subActionList);
00522           $this->setTemplateVar('param','objectid');
00523      }
00524 
00525 
00526      function transfer()
00527      {
00528           $this->addSubaction('import');
00529           $this->setTemplateVar('windowMenu',$this->subActionList);
00530      }
00531 
00532 
00533      function show()
00534      {
00535           $this->setTemplateVar('windowIcons',array( array('url'   =>Html::url('index','projectmenu'),
00536                                                            'target'=>'_top',
00537                                                            'type'  =>'min'),
00538                                                      array('url'   =>Html::url('index','logout'),
00539                                                            'target'=>'_top',
00540                                                            'type'  =>'close')
00541                                                                                       ) );
00542           $this->setTemplateVar('actionid',$this->getRequestId() );
00543 
00544           if   ( $this->subActionName == 'pageelement')
00545                $this->setTemplateVar('action','page');
00546           else
00547                $this->setTemplateVar('action',$this->subActionName  );
00548           
00549           $this->setTemplateVar('name'          ,$this->subActionName);
00550           $this->setTemplateVar('css_body_class','menu'              );
00551           
00552           $this->setTemplateVar('path'          ,$this->path         );
00553      }
00554      
00555      
00556      
00557      function blank()
00558      {
00559      }
00560 }
00561 
00562 ?>

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