diff options
Diffstat (limited to 'include/apps.php')
-rw-r--r-- | include/apps.php | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/include/apps.php b/include/apps.php index 9eb54af00..37deb0bbc 100644 --- a/include/apps.php +++ b/include/apps.php @@ -126,7 +126,9 @@ function translate_system_apps(&$arr) { 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), - 'Help' => t('Help') + 'Help' => t('Help'), + 'Mail' => t('Mail'), + 'Mood' => t('Mood'), ); if(array_key_exists($arr['name'],$apps)) @@ -153,6 +155,9 @@ function app_render($papp,$mode = 'view') { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + if(! $papp) + return; + $papp['papp'] = papp_encode($papp); foreach($papp as $k => $v) { @@ -161,6 +166,34 @@ function app_render($papp,$mode = 'view') { if($k === 'desc') $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 'observer': + $observer = get_app()->get_observer(); + if(! $observer) + return ''; + break; + default: + if(! local_user() && feature_enabled(local_user(),$require)) + return ''; + break; + + } + + } } if(local_user()) { @@ -256,8 +289,9 @@ function app_store($arr) { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); - $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s' )", + $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )", dbesc($darray['app_id']), dbesc($darray['app_sig']), dbesc($darray['app_author']), @@ -269,7 +303,8 @@ function app_store($arr) { intval($darray['app_channel']), dbesc($darray['app_addr']), dbesc($darray['app_price']), - dbesc($darray['app_page']) + dbesc($darray['app_page']), + dbesc($darray['app_requires']) ); if($r) { $ret['success'] = true; @@ -304,8 +339,9 @@ function app_update($arr) { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); - $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s' where app_id = '%s' and app_channel = %d limit 1", + $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s' where app_id = '%s' and app_channel = %d limit 1", dbesc($darray['app_sig']), dbesc($darray['app_author']), dbesc($darray['app_name']), @@ -316,6 +352,7 @@ function app_update($arr) { dbesc($darray['app_addr']), dbesc($darray['app_price']), dbesc($darray['app_page']), + dbesc($darray['app_requires']), dbesc($darray['app_id']), intval($darray['app_channel']) ); @@ -369,8 +406,8 @@ function app_encode($app,$embed = false) { if($app['app_page']) $ret['page'] = $app['app_page']; -// if($app['alt_url']) -// $ret['alt_url'] = $app['alt_url']; + if($app['app_requires']) + $ret['requires'] = $app['app_requires']; if(! $embed) return $ret; |