aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Appman.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Appman.php')
-rw-r--r--Zotlabs/Module/Appman.php94
1 files changed, 79 insertions, 15 deletions
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index 9d065768e..26e564aa5 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -2,9 +2,9 @@
namespace Zotlabs\Module;
-//require_once('include/apps.php');
-
-use \Zotlabs\Lib as Zlib;
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
class Appman extends \Zotlabs\Web\Controller {
@@ -33,9 +33,9 @@ class Appman extends \Zotlabs\Web\Controller {
'categories' => escape_tags($_REQUEST['categories'])
);
- $_REQUEST['appid'] = Zlib\Apps::app_install(local_channel(),$arr);
+ $_REQUEST['appid'] = Apps::app_install(local_channel(),$arr);
- if(Zlib\Apps::app_installed(local_channel(),$arr))
+ if(Apps::app_installed(local_channel(),$arr))
info( t('App installed.') . EOL);
goaway(z_root() . '/apps');
@@ -43,7 +43,7 @@ class Appman extends \Zotlabs\Web\Controller {
}
- $papp = Zlib\Apps::app_decode($_POST['papp']);
+ $papp = Apps::app_decode($_POST['papp']);
if(! is_array($papp)) {
notice( t('Malformed app.') . EOL);
@@ -51,13 +51,53 @@ class Appman extends \Zotlabs\Web\Controller {
}
if($_POST['install']) {
- Zlib\Apps::app_install(local_channel(),$papp);
- if(Zlib\Apps::app_installed(local_channel(),$papp))
+ Apps::app_install(local_channel(),$papp);
+ if(Apps::app_installed(local_channel(),$papp))
info( t('App installed.') . EOL);
+
+hz_syslog('install: ' . print_r($papp,true));
+
+ $sync = q("SELECT * FROM app WHERE app_channel = %d AND app_id = '%s' LIMIT 1",
+ intval(local_channel()),
+ dbesc($papp['guid'])
+ );
+
+ if (!$sync) {
+ return;
+ }
+
+ if (intval($sync[0]['app_system'])) {
+ Libsync::build_sync_packet($uid, ['sysapp' => $sync]);
+ }
+ else {
+ Libsync::build_sync_packet($uid, ['app' => $sync]);
+ }
+
}
if($_POST['delete']) {
- Zlib\Apps::app_destroy(local_channel(),$papp);
+
+ // Fetch the app for sync before it is deleted (if it is deletable))
+ $sync = q("SELECT * FROM app WHERE app_channel = %d AND app_id = '%s' LIMIT 1",
+ intval(local_channel()),
+ dbesc($papp['guid'])
+ );
+
+ if (!$sync) {
+ return;
+ }
+
+ Apps::app_destroy(local_channel(), $papp);
+
+ // Now flag it deleted
+ $sync[0]['app_deleted'] = 1;
+
+ if (intval($sync[0]['app_system'])) {
+ Libsync::build_sync_packet($uid, ['sysapp' => $sync]);
+ }
+ else {
+ Libsync::build_sync_packet($uid, ['app' => $sync]);
+ }
}
if($_POST['edit']) {
@@ -65,11 +105,35 @@ class Appman extends \Zotlabs\Web\Controller {
}
if($_POST['feature']) {
- Zlib\Apps::app_feature(local_channel(), $papp, $_POST['feature']);
+ Apps::app_feature(local_channel(), $papp, $_POST['feature']);
+
+ $sync = q("SELECT * FROM app WHERE app_channel = %d AND app_id = '%s' LIMIT 1",
+ intval(local_channel()),
+ dbesc($papp['guid'])
+ );
+
+ if (intval($sync[0]['app_system'])) {
+ Libsync::build_sync_packet($uid, ['sysapp' => $sync]);
+ }
+ else {
+ Libsync::build_sync_packet($uid, ['app' => $sync]);
+ }
}
if($_POST['pin']) {
- Zlib\Apps::app_feature(local_channel(), $papp, $_POST['pin']);
+ Apps::app_feature(local_channel(), $papp, $_POST['pin']);
+
+ $sync = q("SELECT * FROM app WHERE app_channel = %d AND app_id = '%s' LIMIT 1",
+ intval(local_channel()),
+ dbesc($papp['guid'])
+ );
+
+ if (intval($sync[0]['app_system'])) {
+ Libsync::build_sync_packet($uid, ['sysapp' => $sync]);
+ }
+ else {
+ Libsync::build_sync_packet($uid, ['app' => $sync]);
+ }
}
if($_POST['aj']) {
@@ -92,14 +156,14 @@ class Appman extends \Zotlabs\Web\Controller {
return;
}
- $channel = \App::get_channel();
+ $channel = App::get_channel();
if(argc() > 3) {
if(argv(2) === 'moveup') {
- Zlib\Apps::moveup(local_channel(),argv(1),argv(3));
+ Apps::moveup(local_channel(),argv(1),argv(3));
}
if(argv(2) === 'movedown') {
- Zlib\Apps::movedown(local_channel(),argv(1),argv(3));
+ Apps::movedown(local_channel(),argv(1),argv(3));
}
goaway(z_root() . '/apporder');
}
@@ -133,7 +197,7 @@ class Appman extends \Zotlabs\Web\Controller {
}
}
- $embed = array('embed', t('Embed code'), Zlib\Apps::app_encode($app,true),'', 'onclick="this.select();"');
+ $embed = array('embed', t('Embed code'), Apps::app_encode($app,true),'', 'onclick="this.select();"');
}