diff options
author | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-22 17:45:43 +0100 |
---|---|---|
committer | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-22 17:52:30 +0100 |
commit | bd2be2b10cc132f29b2bfba7996400684405c86a (patch) | |
tree | 706c8a14a9fb5f0a0ded5b3503db7df04b30a1a1 /include/apps.php | |
parent | d3830aea9661dac0610eef72cad35b188832b7f2 (diff) | |
download | volse-hubzilla-bd2be2b10cc132f29b2bfba7996400684405c86a.tar.gz volse-hubzilla-bd2be2b10cc132f29b2bfba7996400684405c86a.tar.bz2 volse-hubzilla-bd2be2b10cc132f29b2bfba7996400684405c86a.zip |
Fix feature check in apps (missing parenthesis), allow multiple requires (comma separated)
Diffstat (limited to 'include/apps.php')
-rw-r--r-- | include/apps.php | 113 |
1 files changed, 59 insertions, 54 deletions
diff --git a/include/apps.php b/include/apps.php index 9c4fe826a..e08e6a6f5 100644 --- a/include/apps.php +++ b/include/apps.php @@ -83,35 +83,37 @@ function parse_app_description($f) { $ret['target'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['target']); if(array_key_exists('requires',$ret)) { - $require = trim(strtolower($ret['requires'])); - switch($require) { - case 'nologin': - if(local_user()) - unset($ret); - break; - case 'admin': - if(! is_site_admin()) - unset($ret); - break; - case 'local_user': - if(! local_user()) - unset($ret); - break; - case 'public_profile': - if(! is_public_profile()) - unset($ret); - break; - case 'observer': - if(! $observer) - unset($ret); - break; - default: - if(! local_user() && feature_enabled(local_user(),$require)) - unset($ret); - break; + $requires = explode(',',$ret['requires']); + foreach($requires as $require) { + $require = trim(strtolower($require)); + switch($require) { + case 'nologin': + if(local_user()) + unset($ret); + break; + case 'admin': + if(! is_site_admin()) + unset($ret); + break; + case 'local_user': + if(! local_user()) + unset($ret); + break; + case 'public_profile': + if(! is_public_profile()) + unset($ret); + break; + case 'observer': + if(! $observer) + unset($ret); + break; + default: + if(! (local_user() && feature_enabled(local_user(),$require))) + unset($ret); + break; + } } -// logger('require: ' . print_r($ret,true)); } if($ret) { translate_system_apps($ret); @@ -189,34 +191,37 @@ function app_render($papp,$mode = 'view') { $papp['desc'] = str_replace(array('\'','"'),array(''','&dquot;'),$papp['desc']); if($k === 'requires') { - $require = trim(strtolower($v)); - switch($require) { - case 'nologin': - if(local_user()) - return ''; - break; - case 'admin': - if(! is_site_admin()) - return ''; - break; - case 'local_user': - if(! local_user()) - return ''; - break; - case 'public_profile': - if(! is_public_profile()) - return ''; - break; - case 'observer': - $observer = get_app()->get_observer(); - if(! $observer) - return ''; - break; - default: - if(! local_user() && feature_enabled(local_user(),$require)) - return ''; - break; + $requires = explode(',',$v); + foreach($requires as $require) { + $require = trim(strtolower($require)); + switch($require) { + case 'nologin': + if(local_user()) + return ''; + break; + case 'admin': + if(! is_site_admin()) + return ''; + break; + case 'local_user': + if(! local_user()) + return ''; + break; + case 'public_profile': + if(! is_public_profile()) + return ''; + break; + case 'observer': + $observer = get_app()->get_observer(); + if(! $observer) + return ''; + break; + default: + if(! (local_user() && feature_enabled(local_user(),$require))) + return ''; + break; + } } } |