aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Apps.php7
-rw-r--r--include/apps.php73
-rw-r--r--include/widgets.php4
-rw-r--r--view/tpl/app_select.tpl4
4 files changed, 70 insertions, 18 deletions
diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php
index 4066966ca..ea6ab1913 100644
--- a/Zotlabs/Module/Apps.php
+++ b/Zotlabs/Module/Apps.php
@@ -17,16 +17,21 @@ class Apps extends \Zotlabs\Web\Controller {
$apps = array();
- $syslist = get_system_apps();
if(local_channel()) {
+ import_system_apps();
+ $syslist = array();
$list = app_list(local_channel());
if($list) {
foreach($list as $x) {
$syslist[] = app_encode($x);
}
}
+ translate_system_apps($syslist);
}
+ else
+ $syslist = get_system_apps(true);
+
usort($syslist,'app_name_compare');
// logger('apps: ' . print_r($syslist,true));
diff --git a/include/apps.php b/include/apps.php
index dca49a3c6..cab851b66 100644
--- a/include/apps.php
+++ b/include/apps.php
@@ -8,7 +8,7 @@
require_once('include/plugin.php');
require_once('include/identity.php');
-function get_system_apps() {
+function get_system_apps($translate = true) {
$ret = array();
if(is_dir('apps'))
@@ -17,7 +17,7 @@ function get_system_apps() {
$files = glob('app/*.apd');
if($files) {
foreach($files as $f) {
- $x = parse_app_description($f);
+ $x = parse_app_description($f,$translate);
if($x) {
$ret[] = $x;
}
@@ -28,7 +28,7 @@ function get_system_apps() {
foreach($files as $f) {
$n = basename($f,'.apd');
if(plugin_is_installed($n)) {
- $x = parse_app_description($f);
+ $x = parse_app_description($f,$translate);
if($x) {
$ret[] = $x;
}
@@ -40,11 +40,36 @@ function get_system_apps() {
}
+
+function import_system_apps() {
+ if(! local_channel())
+ return;
+
+ // Eventually we want to look at modification dates and update system apps.
+
+ $installed = get_pconfig(local_channel(),'system','apps_installed');
+ if($installed)
+ return;
+ $apps = get_system_apps(false);
+ if($apps) {
+ foreach($apps as $app) {
+ $app['uid'] = local_channel();
+ $app['guid'] = hash('whirlpool',$app['name']);
+ $app['system'] = 1;
+ app_install(local_channel(),$app);
+ }
+ }
+ set_pconfig(local_channel(),'system','apps_installed',1);
+}
+
+
+
+
function app_name_compare($a,$b) {
return strcmp($a['name'],$b['name']);
}
-function parse_app_description($f) {
+function parse_app_description($f,$translate = true) {
$ret = array();
$baseurl = z_root();
@@ -116,7 +141,8 @@ function parse_app_description($f) {
}
}
if($ret) {
- translate_system_apps($ret);
+ if($translate)
+ translate_system_apps($ret);
return $ret;
}
return false;
@@ -293,11 +319,18 @@ function app_destroy($uid,$app) {
);
$x[0]['app_deleted'] = 1;
-
- $r = q("delete from app where app_id = '%s' and app_channel = %d",
- dbesc($app['guid']),
- intval($uid)
- );
+ if($x[0]['app_system']) {
+ $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
+ dbesc($app['guid']),
+ intval($uid)
+ );
+ }
+ else {
+ $r = q("delete from app where app_id = '%s' and app_channel = %d",
+ dbesc($app['guid']),
+ intval($uid)
+ );
+ }
build_sync_packet($uid,array('app' => $x));
}
@@ -370,10 +403,12 @@ function app_store($arr) {
$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']) : '');
+ $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0);
+ $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0);
$created = datetime_convert();
- $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, app_created, app_edited ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%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, app_created, app_edited, app_system, app_deleted ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
dbesc($darray['app_id']),
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
@@ -388,7 +423,9 @@ function app_store($arr) {
dbesc($darray['app_page']),
dbesc($darray['app_requires']),
dbesc($created),
- dbesc($created)
+ dbesc($created),
+ intval($darray['app_system']),
+ intval($darray['app_deleted'])
);
if($r) {
$ret['success'] = true;
@@ -425,10 +462,12 @@ function app_update($arr) {
$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']) : '');
+ $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0);
+ $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0);
$edited = datetime_convert();
- $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', app_edited = '%s' where app_id = '%s' and app_channel = %d",
+ $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', app_edited = '%s', app_system = %d, app_deleted = %d where app_id = '%s' and app_channel = %d",
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
dbesc($darray['app_name']),
@@ -441,6 +480,8 @@ function app_update($arr) {
dbesc($darray['app_page']),
dbesc($darray['app_requires']),
dbesc($edited),
+ intval($darray['app_system']),
+ intval($darray['app_deleted']),
dbesc($darray['app_id']),
intval($darray['app_channel'])
);
@@ -499,6 +540,12 @@ function app_encode($app,$embed = false) {
if($app['app_requires'])
$ret['requires'] = $app['app_requires'];
+ if($app['app_system'])
+ $ret['system'] = $app['app_system'];
+
+ if($app['app_deleted'])
+ $ret['deleted'] = $app['app_deleted'];
+
if(! $embed)
return $ret;
diff --git a/include/widgets.php b/include/widgets.php
index fa92901ae..1b9d3c07a 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -103,8 +103,8 @@ function widget_appselect($arr) {
'$system' => t('System'),
'$authed' => ((local_channel()) ? true : false),
'$personal' => t('Personal'),
- '$new' => t('Create Personal App'),
- '$edit' => t('Edit Personal App')
+ '$new' => t('New App'),
+ '$edit' => t('Edit App')
));
}
diff --git a/view/tpl/app_select.tpl b/view/tpl/app_select.tpl
index 527d01eae..93049d522 100644
--- a/view/tpl/app_select.tpl
+++ b/view/tpl/app_select.tpl
@@ -2,8 +2,8 @@
<div class="widget">
<h3>{{$title}}</h3>
<ul class="nav nav-pills nav-stacked">
-<li><a href="appman">{{$new}}</a></li>
-<li><a href="apps/edit">{{$edit}}</a></li>
+<li><a href="appman"><i class="fa fa-plus"></i>&nbsp;&nbsp;{{$new}}</a></li>
+<li><a href="apps/edit"><i class="fa fa-pencil"></i>&nbsp;&nbsp;{{$edit}}</a></li>
</ul>
</div>
{{/if}}