openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ProfileAvailableAction.class.php (1856B)


      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 util\ClassName;
      8 use util\exception\SecurityException;
      9 
     10 class ProfileAvailableAction extends ProfileAction implements Method {
     11 
     12     public function view() {
     13 
     14 		$action = $this->request->getText('queryaction');
     15 
     16 		$viewMethods = array_filter( [
     17 			// All UI-related methods (reachable via dropdown menus)
     18 			'pub',
     19 			'info',
     20 			'prop',
     21 			'history',
     22 			'rights',
     23 			'add',
     24 			'pw',
     25 			'memberships',
     26 			'advanced',
     27 			'switch',
     28 			'changetemplate',
     29 			'src',
     30 			'size',
     31 			'settings',
     32 			'rights',
     33 			'remove',
     34 			'preview',
     35 			'order'
     36 			],
     37 			function ($methodName) use ($action) {
     38 
     39 				// Filter existent methods
     40 				while( true ) {
     41 					$actionClassName = new ClassName( ucfirst($action) . ucfirst($methodName) . 'Action');
     42 					$actionClassName->addNamespace( ['cms','action',$action] );
     43 
     44 					if ( $actionClassName->exists() ) {
     45 						$n = $actionClassName->getName();
     46 						/**
     47 						 * @var BaseAction
     48 						 */
     49 						$actionMethod = new $n();
     50 						$actionMethod->request = $this->request;
     51 						try {
     52 							$actionMethod->init();
     53 							$actionMethod->checkAccess();
     54 						} catch( SecurityException $e ) {
     55 							return false;
     56 						}
     57 						return true;
     58 					}
     59 
     60 					$baseActionClassName = new ClassName( ucfirst($action) . 'Action' );
     61 					$baseActionClassName->addNamespace( ['cms','action'] );
     62 
     63 					if ( ! $baseActionClassName->exists() )
     64 						return false;
     65 
     66 					if   ( ! $baseActionClassName->getParent()->exists() )
     67 						return false;
     68 
     69 					$action = strtolower( $baseActionClassName->dropNamespace()->dropSuffix('Action')->get() );
     70 				}
     71 			});
     72 
     73 		$this->setTemplateVar('views', $viewMethods);
     74     }
     75 
     76 
     77     public function post() {
     78     }
     79 
     80 
     81 	public function checkAccess() {
     82 		return true;
     83 	}
     84 }