File modules/cms/action/object/ObjectInheritAction.class.php
Last commit: Wed Mar 9 13:28:52 2022 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()'
1 <?php 2 namespace cms\action\object; 3 use cms\action\Action; 4 use cms\action\Method; 5 use cms\action\ObjectAction; 6 use cms\model\Permission; 7 use cms\model\BaseObject; 8 use cms\model\Folder; 9 use language\Messages; 10 use logger\Logger; 11 use util\Session; 12 13 class ObjectInheritAction extends ObjectAction implements Method { 14 15 public function getRequiredPermission() 16 { 17 return Permission::ACL_GRANT; 18 } 19 20 public function view() { 21 $o = new BaseObject( $this->request->getId() ); 22 $o->objectLoadRaw(); 23 $this->setTemplateVar( 'type',$o->getType() ); 24 25 $acllist = array(); 26 $this->setTemplateVar('acls',$acllist ); 27 } 28 29 30 public function post() { 31 32 Session::close(); 33 34 $baseObject = new Folder( $this->request->getId() ); 35 $baseObject->load(); 36 37 if ( ! $this->request->isTrue('inherit') ) 38 { 39 $this->addWarningFor( $baseObject,Messages::NOTHING_DONE); 40 return; 41 } 42 43 $aclids = $baseObject->getAllAclIds(); 44 45 $newAclList = array(); 46 foreach( $aclids as $aclid ) 47 { 48 $permission = new Permission( $aclid ); 49 $permission->load(); 50 if ( $permission->transmit ) 51 $newAclList[] = $permission; 52 } 53 Logger::debug('inheriting '.count($newAclList).' acls'); 54 55 $oids = $baseObject->getObjectIds(); 56 57 foreach( $baseObject->getAllSubfolderIds() as $sfid ) 58 { 59 $subfolder = new Folder( $sfid ); 60 61 $oids = array_merge($oids,$subfolder->getObjectIds()); 62 } 63 64 foreach( $oids as $oid ) 65 { 66 $object = new BaseObject( $oid ); 67 68 // Die alten ACLs des Objektes löschen. 69 foreach( $object->getAllAclIds() as $aclid ) 70 { 71 $permission = new Permission( $aclid ); 72 $permission->objectid = $oid; 73 $permission->delete(); 74 Logger::debug('removing acl '.$aclid.' for object '.$oid); 75 } 76 77 // Vererbbare ACLs des aktuellen Ordners anwenden. 78 foreach( $newAclList as $newAcl ) 79 { 80 $newAcl->aclid = null; 81 $newAcl->objectid = $oid; 82 $newAcl->persist(); 83 Logger::debug('adding new acl '.$newAcl->aclid.' for object '.$oid); 84 } 85 } 86 87 $this->addNoticeFor($baseObject,Messages::SAVED); 88 } 89 }
Downloadmodules/cms/action/object/ObjectInheritAction.class.php
History Wed, 9 Mar 2022 13:28:52 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()' Sun, 5 Dec 2021 22:36:40 +0100 dankert Fixed deleting and inheriting of permissions. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Mon, 4 Jan 2021 19:03:18 +0100 Jan Dankert Refactoring: ACL class is renamed to Permission, because most RBAC/DMAC concepts are calling it a permission. Thu, 19 Nov 2020 14:49:58 +0100 Jan Dankert Fix: Action::addNotice() is replaced by Action::addNoticeFor() Wed, 18 Nov 2020 01:46:36 +0100 Jan Dankert Refactoring of model classes: New method persist() and some other cleanups. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.