aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-07-27 14:36:06 -0700
committerzotlabs <mike@macgirvin.com>2018-07-27 14:36:06 -0700
commite25d205a7f1428588edd431002a2e10833c8f76e (patch)
tree86d4baa509baa14e5aad234604c847676bbdd08e
parente28dab17d6b958d6ef76181d23f784d17bc70b5e (diff)
downloadvolse-hubzilla-e25d205a7f1428588edd431002a2e10833c8f76e.tar.gz
volse-hubzilla-e25d205a7f1428588edd431002a2e10833c8f76e.tar.bz2
volse-hubzilla-e25d205a7f1428588edd431002a2e10833c8f76e.zip
app delete issue with base installed apps and app photo being reloaded uneccessarily
-rw-r--r--Zotlabs/Lib/Apps.php66
1 files changed, 47 insertions, 19 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index b337a3bcd..841fffd39 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -56,12 +56,8 @@ class Apps {
}
-
- static public function import_system_apps() {
- if(! local_channel())
- return;
-
- self::$base_apps = get_config('system','base_apps',[
+ static public function get_base_apps() {
+ return get_config('system','base_apps',[
'Connections',
'Suggest Channels',
'Grid',
@@ -77,7 +73,16 @@ class Apps {
'Mail',
'Profile Photo'
]);
+ }
+
+
+ static public function import_system_apps() {
+ if(! local_channel())
+ return;
+
+ self::$base_apps = self::get_base_apps();
+
$apps = self::get_system_apps(false);
self::$available_apps = q("select * from app where app_channel = 0");
@@ -537,9 +542,26 @@ class Apps {
return false;
}
- static public function app_destroy($uid,$app) {
+
+ static public function can_delete($uid,$app) {
+ if(! $uid) {
+ return false;
+ }
+
+ $base_apps = self::get_base_apps();
+ if($base_apps) {
+ foreach($base_apps as $b) {
+ if($app['guid'] === hash('whirlpool',$b)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ static public function app_destroy($uid,$app) {
+
if($uid && $app['guid']) {
$x = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
@@ -549,25 +571,31 @@ class Apps {
if($x) {
if(! intval($x[0]['app_deleted'])) {
$x[0]['app_deleted'] = 1;
- q("delete from term where otype = %d and oid = %d",
- intval(TERM_OBJ_APP),
- intval($x[0]['id'])
- );
- if ($uid) {
+ if(self::can_delete($uid,$app)) {
$r = q("delete from app where app_id = '%s' and app_channel = %d",
dbesc($app['guid']),
intval($uid)
);
-
- // we don't sync system apps - they may be completely different on the other system
- build_sync_packet($uid,array('app' => $x));
+ q("delete from term where otype = %d and oid = %d",
+ intval(TERM_OBJ_APP),
+ intval($x[0]['id'])
+ );
+ }
+ else {
+ $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
+ dbesc($app['guid']),
+ intval($uid)
+ );
}
+
+ build_sync_packet($uid,array('app' => $x));
}
else {
self::app_undestroy($uid,$app);
}
}
}
+
}
static public function app_undestroy($uid,$app) {
@@ -874,8 +902,8 @@ class Apps {
$arr['author'] = $sys['channel_hash'];
}
- if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
- $x = import_xchan_photo($arr['photo'],get_observer_hash(),true);
+ if($arr['photo'] && (strpos($arr['photo'],'icon:') === false) && (! strstr($arr['photo'],z_root()))) {
+ $x = import_xchan_photo(str_replace('$baseurl',z_root(),$arr['photo']),get_observer_hash(),true);
$arr['photo'] = $x[1];
}
@@ -958,8 +986,8 @@ class Apps {
if((! $darray['app_url']) || (! $darray['app_id']))
return $ret;
- if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
- $x = import_xchan_photo($arr['photo'],get_observer_hash(),true);
+ if($arr['photo'] && (strpos($arr['photo'],'icon:') === false) && (! strstr($arr['photo'],z_root()))) {
+ $x = import_xchan_photo(str_replace('$baseurl',z_root(),$arr['photo']),get_observer_hash(),true);
$arr['photo'] = $x[1];
}