app update and ownership issues

This commit is contained in:
zotlabs 2018-07-27 13:59:27 -07:00
parent a94c9d2709
commit e28dab17d6

View file

@ -140,10 +140,15 @@ class Apps {
foreach(self::$available_apps as $iapp) {
if($iapp['app_id'] == hash('whirlpool',$app['name'])) {
$notfound = false;
if(($iapp['app_version'] != $app['version'])
if(($iapp['app_version'] !== $app['version'])
|| ($app['plugin'] && (! $iapp['app_plugin']))) {
return intval($iapp['app_id']);
}
if(($iapp['app_url'] !== $app['url'])
|| ($iapp['app_photo'] !== $app['photo'])) {
return intval($iapp['app_id']);
}
}
}
@ -198,12 +203,11 @@ class Apps {
if($lines) {
foreach($lines as $x) {
if(preg_match('/^([a-zA-Z].*?):(.*?)$/ism',$x,$matches)) {
$ret[$matches[1]] = trim(str_replace(array('$baseurl','$nick'),array($baseurl,$address),$matches[2]));
$ret[$matches[1]] = trim($matches[2]);
}
}
}
if(! $ret['photo'])
$ret['photo'] = $baseurl . '/' . get_default_profile_photo(80);
@ -372,9 +376,24 @@ class Apps {
$papp['papp'] = self::papp_encode($papp);
// This will catch somebody clicking on a system "available" app that hasn't had the path macros replaced
// and they are allowed to see the app
if(strstr($papp['url'],'$baseurl') || strstr($papp['url'],'$nick') || strstr($papp['photo'],'$baseurl') || strstr($pap['photo'],'$nick')) {
$view_channel = local_channel();
if(! $view_channel) {
$sys = get_sys_channel();
$view_channel = $sys['channel_id'];
}
self::app_macros($view_channel,$papp);
}
if(! strstr($papp['url'],'://'))
$papp['url'] = z_root() . ((strpos($papp['url'],'/') === 0) ? '' : '/') . $papp['url'];
foreach($papp as $k => $v) {
if(strpos($v,'http') === 0 && $k != 'papp') {
if(! (local_channel() && strpos($v,z_root()) === 0)) {
@ -811,6 +830,29 @@ class Apps {
}
static public function app_macros($uid,&$arr) {
if(! intval($uid))
return;
$baseurl = z_root();
$channel = channelx_by_n($uid);
$address = (($channel) ? $channel['channel_address'] : '');
//future expansion
$observer = \App::get_observer();
$arr['url'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['url']);
$arr['photo'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['photo']);
}
static public function app_store($arr) {
//logger('app_store: ' . print_r($arr,true));
@ -820,6 +862,7 @@ class Apps {
$sys = get_sys_channel();
self::app_macros($arr['uid'],$arr);
$darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : '');
$darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0);
@ -905,11 +948,14 @@ class Apps {
$darray = array();
$ret = array('success' => false);
self::app_macros($arr['uid'],$arr);
$darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : '');
$darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0);
$darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : 0);
if((! $darray['app_url']) || (! $darray['app_channel']) || (! $darray['app_id']))
if((! $darray['app_url']) || (! $darray['app_id']))
return $ret;
if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
@ -996,9 +1042,6 @@ class Apps {
$ret['type'] = 'personal';
if($app['app_id'])
$ret['guid'] = $app['app_id'];
if($app['app_id'])
$ret['guid'] = $app['app_id'];