aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-10-06 07:39:10 +0000
committerMario <mario@mariovavti.com>2021-10-06 07:39:10 +0000
commit3b71e115a441cfbe924338d54e064c09a4b15376 (patch)
tree556604bfe151489e87345f65f1ce5d4dba8d9ce7 /Zotlabs
parent16281e0e7fbc4ff691f6190ddc80632b411d2801 (diff)
downloadvolse-hubzilla-3b71e115a441cfbe924338d54e064c09a4b15376.tar.gz
volse-hubzilla-3b71e115a441cfbe924338d54e064c09a4b15376.tar.bz2
volse-hubzilla-3b71e115a441cfbe924338d54e064c09a4b15376.zip
implement sync logic in mod appman
Diffstat (limited to 'Zotlabs')
-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();"');
}