aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/apps.php37
-rw-r--r--mod/appman.php60
-rw-r--r--view/tpl/app.tpl4
-rw-r--r--view/tpl/app_create.tpl6
4 files changed, 78 insertions, 29 deletions
diff --git a/include/apps.php b/include/apps.php
index 536a40f01..910d1c84d 100644
--- a/include/apps.php
+++ b/include/apps.php
@@ -93,7 +93,7 @@ function parse_app_description($f) {
break;
}
- logger('require: ' . print_r($ret,true));
+// logger('require: ' . print_r($ret,true));
}
if($ret) {
translate_system_apps($ret);
@@ -156,9 +156,14 @@ function app_render($papp,$mode = 'view') {
function app_install($uid,$app) {
$app['uid'] = $uid;
if(app_installed($uid,$app))
- app_update($app);
+ $x = app_update($app);
else
- app_store($app);
+ $x = app_store($app);
+
+ if($x['success'])
+ return $x['app_id'];
+
+ return false;
}
function app_destroy($uid,$app) {
@@ -199,14 +204,22 @@ function app_decode($s) {
function app_store($arr) {
+ // logger('app_store: ' . print_r($arr,true));
+
$darray = array();
$ret = array('success' => false);
$darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : '');
$darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0);
- if((! $darray['url']) || (! $darray['app_channel']))
+ if((! $darray['app_url']) || (! $darray['app_channel']))
return $ret;
+ if($arr['photo'] && ! strstr($arr['photo'],z_root())) {
+ $x = import_profile_photo($arr['photo'],get_observer_hash(),true);
+ $arr['photo'] = $x[1];
+ }
+
+
$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());
@@ -232,9 +245,10 @@ function app_store($arr) {
dbesc($darray['app_price']),
dbesc($darray['app_page'])
);
- if($r)
+ if($r) {
$ret['success'] = true;
-
+ $ret['app_id'] = $darray['app_id'];
+ }
return $ret;
}
@@ -247,9 +261,14 @@ function app_update($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['url']) || (! $darray['app_channel']) || (! $darray['app_id']))
+ if((! $darray['app_url']) || (! $darray['app_channel']) || (! $darray['app_id']))
return $ret;
+ if($arr['photo'] && ! strstr($arr['photo'],z_root())) {
+ $x = import_profile_photo($arr['photo'],get_observer_hash(),true);
+ $arr['photo'] = $x[1];
+ }
+
$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'));
@@ -274,8 +293,10 @@ function app_update($arr) {
dbesc($darray['app_id']),
intval($darray['app_channel'])
);
- if($r)
+ if($r) {
$ret['success'] = true;
+ $ret['app_id'] = $darray['app_id'];
+ }
return $ret;
diff --git a/mod/appman.php b/mod/appman.php
index 4fc247a42..6570e2fd9 100644
--- a/mod/appman.php
+++ b/mod/appman.php
@@ -7,6 +7,28 @@ function appman_post(&$a) {
if(! local_user())
return;
+ if($_POST['url']) {
+ $arr = array(
+ 'uid' => intval($_REQUEST['uid']),
+ 'url' => escape_tags($_REQUEST['url']),
+ 'guid' => escape_tags($_REQUEST['guid']),
+ 'author' => escape_tags($_REQUEST['author']),
+ 'addr' => escape_tags($_REQUEST['addr']),
+ 'name' => escape_tags($_REQUEST['name']),
+ 'desc' => escape_tags($_REQUEST['desc']),
+ 'photo' => escape_tags($_REQUEST['photo']),
+ 'version' => escape_tags($_REQUEST['version']),
+ 'price' => escape_tags($_REQUEST['price']),
+ 'sig' => escape_tags($_REQUEST['sig'])
+ );
+
+ $_REQUEST['appid'] = app_install(local_user(),$arr);
+ if(app_installed(local_user(),$app))
+ info( t('App installed.') . EOL);
+ return;
+ }
+
+
$papp = app_decode($_POST['papp']);
if(! is_array($papp)) {
@@ -39,7 +61,7 @@ function appman_content(&$a) {
$channel = $a->get_channel();
$app = null;
-
+ $embed = null;
if($_REQUEST['appid']) {
$r = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($_REQUEST['appid']),
@@ -47,24 +69,26 @@ function appman_content(&$a) {
);
if($r)
$app = $r[0];
+ $embed = array('embed', t('Embed code'), app_encode($app,true),'');
+
}
- return replace_macros(get_markup_template('app_create.tpl'), array(
-
- '$banner' => t('Create App'),
- '$app' => $app,
- '$guid' => (($app) ? $app['app_id'] : ''),
- '$author' => (($app) ? $app['app_author'] : $channel['channel_hash']),
- '$addr' => (($app) ? $app['app_addr'] : $channel['xchan_addr']),
- '$name' => array('name', t('Name of app'),(($app) ? $app['app_name'] : ''), t('Required')),
- '$url' => array('url', t('Location (URL) of app'),(($app) ? $app['app_url'] : ''), t('Required')),
- '$desc' => array('desc', t('Description'),(($app) ? $app['app_desc'] : ''), ''),
- '$photo' => array('photo', t('Photo icon URL'),(($app) ? $app['app_url'] : ''), t('80 x 80 pixels - optional')),
- '$version' => array('version', t('Version ID'),(($app) ? $app['app_version'] : ''), ''),
- '$price' => array('price', t('Price of app'),(($app) ? $app['app_price'] : ''), ''),
- '$page' => array('page', t('Location (URL) to purchase app'),(($app) ? $app['app_page'] : ''), ''),
- '$submit' => t('Submit')
- ));
-
+ return replace_macros(get_markup_template('app_create.tpl'), array(
+
+ '$banner' => t('Create App'),
+ '$app' => $app,
+ '$guid' => (($app) ? $app['app_id'] : ''),
+ '$author' => (($app) ? $app['app_author'] : $channel['channel_hash']),
+ '$addr' => (($app) ? $app['app_addr'] : $channel['xchan_addr']),
+ '$name' => array('name', t('Name of app'),(($app) ? $app['app_name'] : ''), t('Required')),
+ '$url' => array('url', t('Location (URL) of app'),(($app) ? $app['app_url'] : ''), t('Required')),
+ '$desc' => array('desc', t('Description'),(($app) ? $app['app_desc'] : ''), ''),
+ '$photo' => array('photo', t('Photo icon URL'),(($app) ? $app['app_url'] : ''), t('80 x 80 pixels - optional')),
+ '$version' => array('version', t('Version ID'),(($app) ? $app['app_version'] : ''), ''),
+ '$price' => array('price', t('Price of app'),(($app) ? $app['app_price'] : ''), ''),
+ '$page' => array('page', t('Location (URL) to purchase app'),(($app) ? $app['app_page'] : ''), ''),
+ '$embed' => $embed,
+ '$submit' => t('Submit')
+ ));
} \ No newline at end of file
diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl
index 323dfbe63..1d39395d6 100644
--- a/view/tpl/app.tpl
+++ b/view/tpl/app.tpl
@@ -5,8 +5,8 @@
{{if $install || $update || $delete }}
<form action="appman" method="post">
<input type="hidden" name="papp" value="{{$app.papp}}" />
-{{if $install}}<button type="submit" name="install" value="{{$install}}" class="btn btn-default" title="{{$install}}" /><i class="icon-download-alt" ></i></button>{{/if}}
-{{if $delete}}<button type="submit" name="delete" value="{{$delete}}" class="btn btn-default" title="{{$delete}}" /><i class="icon-remove drop-icons"></i></button>{{/if}}
+{{if $install}}<button type="submit" name="install" value="{{$install}}" class="btn btn-default" title="{{$install}}" ><i class="icon-download-alt" ></i></button>{{/if}}
+{{if $delete}}<button type="submit" name="delete" value="{{$delete}}" class="btn btn-default" title="{{$delete}}" ><i class="icon-remove drop-icons"></i></button>{{/if}}
</form>
{{/if}}
</div>
diff --git a/view/tpl/app_create.tpl b/view/tpl/app_create.tpl
index 540effe75..ff28e0598 100644
--- a/view/tpl/app_create.tpl
+++ b/view/tpl/app_create.tpl
@@ -14,12 +14,16 @@
{{include file="field_input.tpl" field=$name}}
{{include file="field_input.tpl" field=$url}}
-{{include file="field_input.tpl" field=$desc}}
+{{include file="field_textarea.tpl" field=$desc}}
{{include file="field_input.tpl" field=$photo}}
{{include file="field_input.tpl" field=$version}}
{{include file="field_input.tpl" field=$price}}
{{include file="field_input.tpl" field=$page}}
+{{if $embed}}
+{{include file="field_textarea.tpl" field=$embed}}
+{{/if}}
+
<input type="submit" name="submit" value="{{$submit}}" />
</form>