File modules/cms/action/profile/ProfileAvailableAction.class.php
Last commit: Thu Feb 16 22:57:35 2023 +0100 Jan Dankert New: More functions (adding, deleting) for tags.
1 <?php 2 namespace cms\action\profile; 3 use cms\action\Action; 4 use cms\action\BaseAction; 5 use cms\action\Method; 6 use cms\action\ProfileAction; 7 use logger\Logger; 8 use util\ClassName; 9 use util\exception\SecurityException; 10 11 class ProfileAvailableAction extends ProfileAction implements Method { 12 13 public function view() { 14 15 $action = $this->request->getText('queryaction'); 16 17 $viewMethods = array_filter( [ 18 // All UI-related methods (reachable via dropdown menus) 19 'pub', 20 'info', 21 'prop', 22 'history', 23 'rights', 24 'add', 25 'pw', 26 'memberships', 27 'advanced', 28 'switch', 29 'changetemplate', 30 'src', 31 'size', 32 'settings', 33 'rights', 34 'remove', 35 'preview', 36 'order' 37 ], 38 function ($methodName) use ($action) { 39 40 // Filter existent methods 41 while( true ) { 42 $actionClassName = new ClassName( ucfirst($action) . ucfirst($methodName) . 'Action'); 43 $actionClassName->addNamespace( ['cms','action',$action] ); 44 45 Logger::trace("Trying ".$actionClassName->getName() ); 46 if ( $actionClassName->exists() ) { 47 $n = $actionClassName->getName(); 48 /** 49 * @var BaseAction 50 */ 51 $actionMethod = new $n(); 52 $actionMethod->request = $this->request; 53 try { 54 $actionMethod->init(); 55 $actionMethod->checkAccess(); 56 } catch( SecurityException $e ) { 57 Logger::trace("Not allowed to call ".$n); 58 return false; // do not throw anything here. 59 } 60 return true; 61 } 62 63 $baseActionClassName = new ClassName( ucfirst($action) . 'Action' ); 64 $baseActionClassName->addNamespace( ['cms','action'] ); 65 66 if ( ! $baseActionClassName->exists() ) 67 return false; 68 69 if ( ! $baseActionClassName->getParent()->exists() ) 70 return false; 71 72 $action = strtolower( $baseActionClassName->dropNamespace()->dropSuffix('Action')->get() ); 73 } 74 }); 75 76 $this->setTemplateVar('views', $viewMethods); 77 } 78 79 80 public function post() { 81 } 82 83 84 public function checkAccess() { 85 return true; 86 } 87 }
Downloadmodules/cms/action/profile/ProfileAvailableAction.class.php
History Thu, 16 Feb 2023 22:57:35 +0100 Jan Dankert New: More functions (adding, deleting) for tags. Sat, 4 Dec 2021 00:18:39 +0100 dankert Some security enhancements. Fri, 3 Dec 2021 23:27:44 +0100 dankert New: Only allowed methods are shown in the dropdown menu; Some security enhancements. Sun, 14 Mar 2021 22:29:56 +0100 Jan Dankert Refactoring: Clearer access check. Thu, 4 Mar 2021 00:27:41 +0100 Jan Dankert Removed menu entry for 'archive' (it was not used) Wed, 3 Mar 2021 23:48:49 +0100 Jan Dankert Removed menu entry for 'maintenance'. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Tue, 9 Feb 2021 19:37:04 +0100 Jan Dankert Removing sidebar buttons (all related actions are available via a shortcut icon in the title bar) Wed, 18 Nov 2020 20:42:57 +0100 Jan Dankert Getting/Setting cookies with constants, this is more safe. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.