aboutsummaryrefslogtreecommitdiffstats
path: root/mod/appman.php
blob: 4fc247a422f95d01a0c8aed7ddb5cb6da86bec74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php /** @file */

require_once('include/apps.php');

function appman_post(&$a) {

	if(! local_user())
		return;

	$papp = app_decode($_POST['papp']);

	if(! is_array($papp)) {
		notice( t('Malformed app.') . EOL);
		return;
	}

	if($_POST['install']) {
		app_install(local_user(),$papp);
	}

	if($_POST['delete']) {
		app_destroy(local_user(),$papp);
	}

	if($_SESSION['return_url']) 
		goaway(z_root() . '/' . $_SESSION['return_url']);
	goaway(z_root() . '/apps/personal');


}


function appman_content(&$a) {

	if(! local_user()) {
		notice( t('Permission denied.') . EOL);
		return;
	}

	$channel = $a->get_channel();
	$app = null;

	if($_REQUEST['appid']) {
		$r = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
			dbesc($_REQUEST['appid']),
			dbesc(local_user())
		);
		if($r)
			$app = $r[0];
	}
			
		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')
		));


}