ObjectAction.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.12  2009-03-22 21:13:22  dankert
00024 // Rechte-Seite auch für Nicht-Ordner editierbar, damit Rechte löschbar sind.
00025 //
00026 // Revision 1.11  2009-03-19 04:36:42  dankert
00027 // Neue Methode "inherit()".
00028 //
00029 // Revision 1.10  2009-03-19 02:02:43  dankert
00030 // Keine ererbten Rechte anzeigen.
00031 //
00032 // Revision 1.9  2009-03-06 13:00:40  dankert
00033 // Zeichenketten 'action' und 'subaction' durch Konstanten ersetzt.
00034 //
00035 // Revision 1.8  2007-11-09 20:41:51  dankert
00036 // Hinweismeldungen setzen.
00037 //
00038 // Revision 1.7  2007-10-29 23:29:17  dankert
00039 // Konstanten f?r Request-Variablen.
00040 //
00041 // Revision 1.6  2006/01/29 17:25:07  dankert
00042 // Methode setWindowMenu() entfernt
00043 //
00044 // Revision 1.5  2006/01/23 23:10:46  dankert
00045 // *** empty log message ***
00046 //
00047 // Revision 1.4  2004/12/19 14:56:33  dankert
00048 // Abfrage von Rechten
00049 //
00050 // Revision 1.3  2004/11/28 19:25:38  dankert
00051 // Anpassen an neue Sprachdatei-Konventionen
00052 //
00053 // Revision 1.2  2004/11/28 16:55:20  dankert
00054 // Berechtigungen f?r "alle" hinzufuegen
00055 //
00056 // Revision 1.1  2004/11/27 13:08:22  dankert
00057 // Neu: Beinhaltet objekt?bergreifende Methoden. Die Klassen File,Page,Link und Folder erben nun von dieser Klasse
00058 //
00059 // Revision 1.9  2004/11/10 22:36:16  dankert
00060 // Dateioperationen, Verschieben/Kopieren/Verknuepfen von mehreren Objekten in einem Arbeitsschritt
00061 //
00062 // Revision 1.8  2004/10/14 22:57:44  dankert
00063 // Neue Verknuepfungen mit dem Linknamen als Url vorbelegen
00064 //
00065 // Revision 1.7  2004/10/13 21:18:50  dankert
00066 // Neue Links zum Verschieben nach ganz oben/unten
00067 //
00068 // Revision 1.6  2004/05/07 21:30:59  dankert
00069 // Korrektur up_url
00070 //
00071 // Revision 1.5  2004/05/07 21:29:16  dankert
00072 // Url ?ber Html::url erzeugen
00073 //
00074 // Revision 1.4  2004/05/02 14:49:37  dankert
00075 // Einf?gen package-name (@package)
00076 //
00077 // Revision 1.3  2004/04/28 20:01:52  dankert
00078 // Ordner l?schen erm?glichen
00079 //
00080 // Revision 1.2  2004/04/24 16:57:13  dankert
00081 // Korrektur: pub()
00082 //
00083 // Revision 1.1  2004/04/24 15:14:52  dankert
00084 // Initiale Version
00085 //
00086 // ---------------------------------------------------------------------------
00087 
00088 
00096 class ObjectAction extends Action
00097 {
00098      var $objectid;
00099 
00100 
00106      function addacl()
00107      {
00108           $acl = new Acl();
00109 
00110           $acl->objectid = $this->getRequestId();
00111           
00112           // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
00113           // diesem Objekt die ACLs zu aendern.
00114           $o = new Object( $acl->objectid );
00115 
00116           if   ( !$o->hasRight( ACL_GRANT ) )
00117                die('uh?'); // Scheiss Hacker.
00118           
00119           // Handelt es sich um eine Benutzer- oder Gruppen ACL?
00120           switch( $this->getRequestVar('type') )
00121           {
00122                case 'user':
00123                     $acl->userid  = $this->getRequestVar('userid' );
00124                     
00125                     if   ( $acl->userid <= 0 )
00126                     {
00127                          $this->addValidationError('type'     );
00128                          $this->addValidationError('userid','');
00129                          $this->callSubAction('aclform');
00130                          return;
00131                     }
00132                     break;
00133                case 'group':
00134                     $acl->groupid = $this->getRequestVar('groupid');
00135                     if   ( $acl->groupid <= 0 )
00136                     {
00137                          $this->addValidationError('type'      );
00138                          $this->addValidationError('groupid','');
00139                          $this->callSubAction('aclform');
00140                          return;
00141                     }
00142                     break;
00143                case 'all':
00144                     break;
00145                default:
00146                     $this->addValidationError('type');
00147                     $this->callSubAction('aclform');
00148                     return;
00149           }
00150 
00151           $acl->languageid    = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID);
00152 
00153           $acl->write         = ( $this->hasRequestVar('write'        ) );
00154           $acl->prop          = ( $this->hasRequestVar('prop'         ) );
00155           $acl->delete        = ( $this->hasRequestVar('delete'       ) );
00156           $acl->release       = ( $this->hasRequestVar('release'      ) );
00157           $acl->publish       = ( $this->hasRequestVar('publish'      ) );
00158           $acl->create_folder = ( $this->hasRequestVar('create_folder') );
00159           $acl->create_file   = ( $this->hasRequestVar('create_file'  ) );
00160           $acl->create_link   = ( $this->hasRequestVar('create_link'  ) );
00161           $acl->create_page   = ( $this->hasRequestVar('create_page'  ) );
00162           $acl->grant         = ( $this->hasRequestVar('grant'        ) );
00163           $acl->transmit      = ( $this->hasRequestVar('transmit'     ) );
00164 
00165           $acl->add();
00166           
00167           $this->addNotice('','','ADDED',OR_NOTICE_OK);
00168           
00169           $o->setTimestamp();
00170      }
00171 
00172 
00173 
00177      function rights()
00178      {
00179 //        $this->actionName = 'object';
00180           $o = Session::getObject();
00181           $o->objectLoadRaw();
00182           $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
00183           $this->setTemplateVar( 'type',$o->getType() );
00184           
00185           $acllist = array();
00186 
00187           /*
00188           foreach( $o->getAllInheritedAclIds() as $aclid )
00189           {
00190                $acl = new Acl( $aclid );
00191                $acl->load();
00192                $key = 'au'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
00193                $acllist[$key] = $acl->getProperties();
00194           }
00195           */
00196 
00197           foreach( $o->getAllAclIds() as $aclid )
00198           {
00199                $acl = new Acl( $aclid );
00200                $acl->load();
00201                $key = 'bu'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
00202                $acllist[$key] = $acl->getProperties();
00203                $acllist[$key]['delete_url'] = Html::url($this->actionName,'delacl',$o->objectid,array('aclid'=>$aclid));
00204           }
00205           ksort( $acllist );
00206 
00207           $this->setTemplateVar('acls',$acllist );
00208 
00209           $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
00210      }
00211 
00212      
00213      
00218      function inherit()
00219      {
00220           $log = array();
00221           
00222           if   ( ! $this->hasRequestVar('inherit') )
00223           {
00224                $this->addNotice('folder',$this->name,'NOTHING_DONE',OR_NOTICE_WARN);
00225                return;
00226           }
00227           
00228           
00229           $folder = $this->folder;
00230           $aclids = $folder->getAllAclIds();
00231           
00232           $newAclList = array();
00233           foreach( $aclids as $aclid )
00234           {
00235                $acl = new Acl( $aclid );
00236                $acl->load();
00237                if   ( $acl->transmit )
00238                     $newAclList[] = $acl;
00239           }
00240           $log[] = 'inheriting '.count($newAclList).' acls';
00241           
00242           $oids = $folder->getObjectIds();
00243           
00244           foreach( $folder->getAllSubfolderIds() as $sfid )
00245           {
00246                $subfolder = new Folder( $sfid );
00247                
00248                $oids = array_merge($oids,$subfolder->getObjectIds());
00249           }
00250           
00251           foreach( $oids as $oid )
00252           {
00253                $object = new Object( $oid );
00254           
00255                // Die alten ACLs des Objektes löschen.
00256                foreach( $object->getAllAclIds() as $aclid )
00257                {
00258                     $acl = new Acl( $aclid );
00259                     $acl->objectid = $oid;
00260                     $acl->delete();
00261                     $log[] = 'removing acl '.$aclid.' for object '.$oid;
00262                }
00263                
00264                // Vererbbare ACLs des aktuellen Ordners anwenden.
00265                foreach( $newAclList as $newAcl )
00266                {
00267                     $newAcl->objectid = $oid;
00268                     $newAcl->add();
00269                     $log[] = 'adding new acl '.$newAcl->aclid.' for object '.$oid;
00270                }
00271           }
00272           
00273           $this->addNotice('folder',$this->name,'SAVED',OR_NOTICE_OK,array(),$log);
00274      }
00275 
00276 
00280      function aclform()
00281      {
00282           $o = Session::getObject();
00283           $o->objectLoadRaw();
00284 
00285           $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
00286           $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
00287 
00288           $this->setTemplateVar('users'    ,User::listAll()   );
00289           $this->setTemplateVar('groups'   ,Group::getAll()   );
00290 
00291           $languages = array(0=>lang('GLOBAL_ALL_LANGUAGES'));
00292           $languages += Language::getAll();
00293           $this->setTemplateVar('languages',$languages       );
00294           $this->setTemplateVar('objectid' ,$o->objectid     );
00295           $this->setTemplateVar('action'   ,$this->actionName);
00296      }
00297 
00298 
00299 
00305      function delacl()
00306      {
00307           $acl = new Acl($this->getRequestVar('aclid'));
00308           $acl->objectid = $this->getRequestId();
00309 
00310           // Nachschauen, ob der Benutzer ueberhaupt berechtigt ist, an
00311           // diesem Objekt die ACLs zu aendern.
00312           $o = new Object( $this->getRequestId() );
00313 
00314           if   ( !$o->hasRight( ACL_GRANT ) )
00315                die('ehm?'); // Da wollte uns wohl einer vereimern.
00316 
00317           $acl->delete(); // Weg mit der ACL
00318           
00319           $this->addNotice('','','DELETED',OR_NOTICE_OK);
00320      }
00321 }

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