diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-06-03 09:40:37 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-06-03 09:40:37 +0200 |
commit | 7582802f033aa6d994691880c1594b590b179c5d (patch) | |
tree | edd3f5ab48dfada99e2b76d718b425c1698f84e8 /Zotlabs | |
parent | f23bdde464ef20ad2ffcb3984cc9481955374809 (diff) | |
parent | f8949ed5d1f277a3246fecf04d3ee4619ba10b51 (diff) | |
download | volse-hubzilla-7582802f033aa6d994691880c1594b590b179c5d.tar.gz volse-hubzilla-7582802f033aa6d994691880c1594b590b179c5d.tar.bz2 volse-hubzilla-7582802f033aa6d994691880c1594b590b179c5d.zip |
Merge branch 'dev' into sabre32
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Apps.php | 60 | ||||
-rw-r--r-- | Zotlabs/Module/React.php | 50 |
2 files changed, 103 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 6d2ef4e45..9dd4bf2d7 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -13,6 +13,8 @@ require_once('include/channel.php'); class Apps { + static public $installed_system_apps = null; + static public function get_system_apps($translate = true) { $ret = array(); @@ -49,22 +51,62 @@ class Apps { static public function import_system_apps() { if(! local_channel()) return; + $apps = self::get_system_apps(false); - // Eventually we want to look at modification dates and update system apps. - $installed = get_pconfig(local_channel(),'system','apps_installed'); - if($installed) - return; - $apps = self::get_system_apps(false); + self::$installed_system_apps = q("select * from app where app_system = 1 and app_channel = %d", + intval(local_channel()) + ); + if($apps) { foreach($apps as $app) { + $id = self::check_install_system_app($app); + // $id will be boolean true or false to install an app, or an integer id to update an existing app + if($id === false) + continue; + if($id !== true) { + // if we already installed this app, but it changed, preserve any categories we created + $s = ''; + $r = q("select * from term where otype = %d and oid = d", + intval(TERM_OBJ_APP), + intval($id) + ); + if($r) { + foreach($r as $t) { + if($s) + $s .= ','; + $s .= $t['term']; + } + $app['categories'] = $s; + } + } $app['uid'] = local_channel(); $app['guid'] = hash('whirlpool',$app['name']); $app['system'] = 1; - self::app_install(local_channel(),$app); + self::app_install(local_channel(),$app); } } - set_pconfig(local_channel(),'system','apps_installed',1); + } + + /** + * Install the system app if no system apps have been installed, or if a new system app + * is discovered, or if the version of a system app changes. + */ + + static public function check_install_system_app($app) { + if((! is_array(self::$installed_system_apps)) || (! count(self::$installed_system_apps))) { + return true; + } + $notfound = true; + foreach(self::$installed_system_apps as $iapp) { + if($iapp['app_id'] == hash('whirlpool',$app['name'])) { + $notfound = false; + if($iapp['app_version'] != $app['version']) { + return intval($iapp['app_id']); + } + } + } + return $notfound; } @@ -111,6 +153,10 @@ class Apps { if(array_key_exists('target',$ret)) $ret['target'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['target']); + if(array_key_exists('version',$ret)) + $ret['version'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['version']); + + if(array_key_exists('requires',$ret)) { $requires = explode(',',$ret['requires']); foreach($requires as $require) { diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php new file mode 100644 index 000000000..85a1e2350 --- /dev/null +++ b/Zotlabs/Module/React.php @@ -0,0 +1,50 @@ +<?php + +namespace Zotlabs\Module; + + +class React extends \Zotlabs\Web\Controller { + + function get() { + if(! local_channel()) + return; + + $postid = $_REQUEST['postid']; + + if(! $postid) + return; + + $emoji = $_REQUEST['emoji']; + if($_REQUEST['emoji']) { + + $i = q("select * from item where id = %d and uid = %d", + intval($postid), + intval(local_channel()) + ); + + if(! $i) + return; + + $channel = \App::get_channel(); + + $n = array(); + $n['aid'] = $channel['channel_account_id']; + $n['uid'] = $channel['channel_id']; + $n['parent'] = $postid; + $n['parent_mid'] = $i[0]['mid']; + $n['mid'] = item_message_id(); + $n['verb'] = ACTIVITY_REACT . '#' . $emoji; + $n['body'] = "\n\n[zmg]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n"; + $n['author_xchan'] = $channel['channel_hash']; + + $x = item_store($n); + if($x['success']) { + $nid = $x['item_id']; + \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$nid)); + } + + } + + } + +}
\ No newline at end of file |