app delete issue with base installed apps and app photo being reloaded uneccessarily
This commit is contained in:
parent
e28dab17d6
commit
e25d205a7f
@ -56,12 +56,8 @@ class Apps {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function get_base_apps() {
|
||||||
static public function import_system_apps() {
|
return get_config('system','base_apps',[
|
||||||
if(! local_channel())
|
|
||||||
return;
|
|
||||||
|
|
||||||
self::$base_apps = get_config('system','base_apps',[
|
|
||||||
'Connections',
|
'Connections',
|
||||||
'Suggest Channels',
|
'Suggest Channels',
|
||||||
'Grid',
|
'Grid',
|
||||||
@ -77,6 +73,15 @@ class Apps {
|
|||||||
'Mail',
|
'Mail',
|
||||||
'Profile Photo'
|
'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);
|
$apps = self::get_system_apps(false);
|
||||||
|
|
||||||
@ -537,8 +542,25 @@ class Apps {
|
|||||||
return false;
|
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']) {
|
if($uid && $app['guid']) {
|
||||||
|
|
||||||
@ -549,25 +571,31 @@ class Apps {
|
|||||||
if($x) {
|
if($x) {
|
||||||
if(! intval($x[0]['app_deleted'])) {
|
if(! intval($x[0]['app_deleted'])) {
|
||||||
$x[0]['app_deleted'] = 1;
|
$x[0]['app_deleted'] = 1;
|
||||||
q("delete from term where otype = %d and oid = %d",
|
if(self::can_delete($uid,$app)) {
|
||||||
intval(TERM_OBJ_APP),
|
|
||||||
intval($x[0]['id'])
|
|
||||||
);
|
|
||||||
if ($uid) {
|
|
||||||
$r = q("delete from app where app_id = '%s' and app_channel = %d",
|
$r = q("delete from app where app_id = '%s' and app_channel = %d",
|
||||||
dbesc($app['guid']),
|
dbesc($app['guid']),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
q("delete from term where otype = %d and oid = %d",
|
||||||
// we don't sync system apps - they may be completely different on the other system
|
intval(TERM_OBJ_APP),
|
||||||
build_sync_packet($uid,array('app' => $x));
|
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 {
|
else {
|
||||||
self::app_undestroy($uid,$app);
|
self::app_undestroy($uid,$app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function app_undestroy($uid,$app) {
|
static public function app_undestroy($uid,$app) {
|
||||||
@ -874,8 +902,8 @@ class Apps {
|
|||||||
$arr['author'] = $sys['channel_hash'];
|
$arr['author'] = $sys['channel_hash'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
|
if($arr['photo'] && (strpos($arr['photo'],'icon:') === false) && (! strstr($arr['photo'],z_root()))) {
|
||||||
$x = import_xchan_photo($arr['photo'],get_observer_hash(),true);
|
$x = import_xchan_photo(str_replace('$baseurl',z_root(),$arr['photo']),get_observer_hash(),true);
|
||||||
$arr['photo'] = $x[1];
|
$arr['photo'] = $x[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,8 +986,8 @@ class Apps {
|
|||||||
if((! $darray['app_url']) || (! $darray['app_id']))
|
if((! $darray['app_url']) || (! $darray['app_id']))
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
|
if($arr['photo'] && (strpos($arr['photo'],'icon:') === false) && (! strstr($arr['photo'],z_root()))) {
|
||||||
$x = import_xchan_photo($arr['photo'],get_observer_hash(),true);
|
$x = import_xchan_photo(str_replace('$baseurl',z_root(),$arr['photo']),get_observer_hash(),true);
|
||||||
$arr['photo'] = $x[1];
|
$arr['photo'] = $x[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user