aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-05-19 16:49:11 -0700
committerfriendica <info@friendica.com>2014-05-19 16:49:11 -0700
commit6d01707a724504a34b8e84e87c6601a046de9739 (patch)
treef062ebc7ef703402ca74a83b4aca8877f3e86aa0
parentea67b9bda895d30d3115b04ba78db35e6a8b0a74 (diff)
downloadvolse-hubzilla-6d01707a724504a34b8e84e87c6601a046de9739.tar.gz
volse-hubzilla-6d01707a724504a34b8e84e87c6601a046de9739.tar.bz2
volse-hubzilla-6d01707a724504a34b8e84e87c6601a046de9739.zip
more app backend work
-rwxr-xr-xboot.php2
-rw-r--r--include/apps.php45
-rw-r--r--install/database.sql2
-rw-r--r--install/update.php11
-rw-r--r--version.inc2
-rw-r--r--view/tpl/app.tpl6
6 files changed, 59 insertions, 9 deletions
diff --git a/boot.php b/boot.php
index 24f7d5532..2eb55caac 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1109 );
+define ( 'DB_UPDATE_VERSION', 1110 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/include/apps.php b/include/apps.php
index 109da2454..a1469b400 100644
--- a/include/apps.php
+++ b/include/apps.php
@@ -126,9 +126,11 @@ function app_render($app) {
function app_install($uid,$app) {
-
-
-
+ $app['uid'] = $uid;
+ if(app_installed($uid,$app))
+ app_update($app);
+ else
+ app_store($app);
}
@@ -168,7 +170,7 @@ function app_store($arr) {
if((! $darray['url']) || (! $darray['app_channel']))
return $ret;
- $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string());
+ $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname());
$darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash());
$darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown'));
@@ -202,8 +204,43 @@ function app_store($arr) {
function app_update($arr) {
+ $darray = array();
+ $ret = array('success' => false);
+ $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['url']) || (! $darray['app_channel']) || (! $darray['app_id']))
+ return $ret;
+ $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
+ $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash());
+ $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown'));
+ $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : '');
+ $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80));
+ $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : '');
+ $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : '');
+ $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : '');
+ $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : '');
+
+ $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s' where app_id = '%s' and app_channel = %d limit 1",
+ dbesc($darray['app_sig']),
+ dbesc($darray['app_author']),
+ dbesc($darray['app_name']),
+ dbesc($darray['app_desc']),
+ dbesc($darray['app_url']),
+ dbesc($darray['app_photo']),
+ dbesc($darray['app_version']),
+ dbesc($darray['app_addr']),
+ dbesc($darray['app_price']),
+ dbesc($darray['app_page']),
+ dbesc($darray['app_id']),
+ intval($darray['app_channel'])
+ );
+ if($r)
+ $ret['success'] = true;
+
+ return $ret;
}
diff --git a/install/database.sql b/install/database.sql
index 0de5879a2..d03cebd4b 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -85,7 +85,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
CREATE TABLE IF NOT EXISTS `app` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `app_id` char(64) NOT NULL DEFAULT '',
+ `app_id` char(255) NOT NULL DEFAULT '',
`app_sig` char(255) NOT NULL DEFAULT '',
`app_author` char(255) NOT NULL DEFAULT '',
`app_name` char(255) NOT NULL DEFAULT '',
diff --git a/install/update.php b/install/update.php
index 561070ba4..b91589c28 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1109 );
+define( 'UPDATE_VERSION' , 1110 );
/**
*
@@ -1216,7 +1216,7 @@ function update_r1107() {
}
-function update_r11108() {
+function update_r1108() {
$r = q("ALTER TABLE `app` ADD `app_addr` CHAR( 255 ) NOT NULL DEFAULT '',
ADD `app_price` CHAR( 255 ) NOT NULL DEFAULT '',
ADD `app_page` CHAR( 255 ) NOT NULL DEFAULT '',
@@ -1225,3 +1225,10 @@ ADD INDEX ( `app_price` )");
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
+
+function update_r1109() {
+ $r = q("ALTER TABLE `app` CHANGE `app_id` `app_id` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
diff --git a/version.inc b/version.inc
index 934b9cd3c..396a326bd 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-05-18.679
+2014-05-19.680
diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl
new file mode 100644
index 000000000..30287b044
--- /dev/null
+++ b/view/tpl/app.tpl
@@ -0,0 +1,6 @@
+<div class="app-container">
+<a href="{{$ap.url}}" {{if $ap.hover}}title="{{$ap.hover}}"{{/if}}><img src="{{$ap.photo}}" width="80" height="80" />
+<div class="app-name">{{$ap.name}}</div>
+</a>
+</div>
+