aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-05-22 19:19:04 -0700
committerfriendica <info@friendica.com>2014-05-22 19:19:04 -0700
commitbcac633085d9383ad32f3608f07f83df31cc7635 (patch)
tree723f257ff66d432c892cb92455ca4e872d12e222
parentceb64bdb24259cc5e4491fc185fdec348feca95c (diff)
downloadvolse-hubzilla-bcac633085d9383ad32f3608f07f83df31cc7635.tar.gz
volse-hubzilla-bcac633085d9383ad32f3608f07f83df31cc7635.tar.bz2
volse-hubzilla-bcac633085d9383ad32f3608f07f83df31cc7635.zip
implement 'requires' on personal apps
-rwxr-xr-xboot.php2
-rw-r--r--include/apps.php49
-rw-r--r--install/database.sql1
-rw-r--r--install/update.php9
4 files changed, 53 insertions, 8 deletions
diff --git a/boot.php b/boot.php
index 14a3d8770..768b703e9 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1111 );
+define ( 'DB_UPDATE_VERSION', 1112 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
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('&#39;','&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;
diff --git a/install/database.sql b/install/database.sql
index d03cebd4b..82c96019e 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -97,6 +97,7 @@ CREATE TABLE IF NOT EXISTS `app` (
`app_addr` char(255) NOT NULL DEFAULT '',
`app_price` char(255) NOT NULL DEFAULT '',
`app_page` char(255) NOT NULL DEFAULT '',
+ `app_requires` char(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `app_id` (`app_id`),
KEY `app_name` (`app_name`),
diff --git a/install/update.php b/install/update.php
index cc755c8c2..0d5d26237 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1111 );
+define( 'UPDATE_VERSION' , 1112 );
/**
*
@@ -1244,3 +1244,10 @@ ADD INDEX ( `app_price` )");
return UPDATE_SUCCESS;
}
+
+function update_r1111() {
+ $r = q("ALTER TABLE `app` ADD `app_requires` CHAR( 255 ) NOT NULL DEFAULT '' ");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}