aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-12-14 19:11:01 -0800
committerzotlabs <mike@macgirvin.com>2016-12-14 19:11:01 -0800
commitbae28965abb179948ccd50eabdc2c038a58b9b03 (patch)
treedfb9503bec536f0a8a03a92bbc4cd883e278e864
parent63efbdffe6ef653e1556a7b34ea59b75b234e759 (diff)
downloadvolse-hubzilla-bae28965abb179948ccd50eabdc2c038a58b9b03.tar.gz
volse-hubzilla-bae28965abb179948ccd50eabdc2c038a58b9b03.tar.bz2
volse-hubzilla-bae28965abb179948ccd50eabdc2c038a58b9b03.zip
issue #446 apps usability - disable app if attached to a plugin that is uninstalled, allow system apps to be soft deleted and undeleted from the edit pane.
-rw-r--r--Zotlabs/Lib/Apps.php87
-rw-r--r--Zotlabs/Module/Appman.php1
-rw-r--r--Zotlabs/Module/Apps.php2
-rwxr-xr-xboot.php2
-rw-r--r--install/schema_mysql.sql3
-rw-r--r--install/schema_postgres.sql4
-rw-r--r--install/update.php11
-rw-r--r--view/theme/redbasic/css/style.css3
-rw-r--r--view/tpl/app.tpl4
9 files changed, 87 insertions, 30 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index a2f253299..46486bb5a 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -38,6 +38,7 @@ class Apps {
if(plugin_is_installed($plugin)) {
$x = self::parse_app_description($f,$translate);
if($x) {
+ $x['plugin'] = $plugin;
$ret[] = $x;
}
}
@@ -54,7 +55,6 @@ class Apps {
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())
);
@@ -68,7 +68,7 @@ class Apps {
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",
+ $r = q("select * from term where otype = %d and oid = %d",
intval(TERM_OBJ_APP),
intval($id)
);
@@ -100,6 +100,8 @@ class Apps {
}
$notfound = true;
foreach(self::$installed_system_apps as $iapp) {
+ if($app['plugin'] && (! $iapp['app_plugin']))
+ return(1);
if($iapp['app_id'] == hash('whirlpool',$app['name'])) {
$notfound = false;
if($iapp['app_version'] != $app['version']) {
@@ -238,9 +240,9 @@ class Apps {
'Profile Photo' => t('Profile Photo')
);
- if(array_key_exists($arr['name'],$apps))
+ if(array_key_exists($arr['name'],$apps)) {
$arr['name'] = $apps[$arr['name']];
-
+ }
}
@@ -267,6 +269,9 @@ class Apps {
self::translate_system_apps($papp);
+ if(($papp['plugin']) && (! plugin_is_installed($papp['plugin'])))
+ return '';
+
$papp['papp'] = self::papp_encode($papp);
if(! strstr($papp['url'],'://'))
@@ -339,7 +344,9 @@ class Apps {
'$purchase' => (($papp['page'] && (! $installed)) ? t('Purchase') : ''),
'$install' => (($hosturl && $mode == 'view') ? $install_action : ''),
'$edit' => ((local_channel() && $installed && $mode == 'edit') ? t('Edit') : ''),
- '$delete' => ((local_channel() && $installed && $mode == 'edit') ? t('Delete') : '')
+ '$delete' => ((local_channel() && $installed && $mode == 'edit') ? t('Delete') : ''),
+ '$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''),
+ '$deleted' => $papp['deleted']
));
}
@@ -359,7 +366,7 @@ class Apps {
if($r) {
if(! $r[0]['app_system']) {
if($app['categories'] && (! $app['term'])) {
- $r[0]['term'] = q("select * from term where otype = %d and oid = d",
+ $r[0]['term'] = q("select * from term where otype = %d and oid = %d",
intval(TERM_OBJ_APP),
intval($r[0]['id'])
);
@@ -382,31 +389,60 @@ class Apps {
intval($uid)
);
if($x) {
- $x[0]['app_deleted'] = 1;
- q("delete from term where otype = %d and oid = %d",
- intval(TERM_OBJ_APP),
- intval($x[0]['id'])
- );
- if($x[0]['app_system']) {
- $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
- dbesc($app['guid']),
- intval($uid)
+ if(! intval($x[0]['app_deleted'])) {
+ $x[0]['app_deleted'] = 1;
+ q("delete from term where otype = %d and oid = %d",
+ intval(TERM_OBJ_APP),
+ intval($x[0]['id'])
);
+ if($x[0]['app_system']) {
+ $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
+ dbesc($app['guid']),
+ intval($uid)
+ );
+ }
+ else {
+ $r = q("delete from app where app_id = '%s' and app_channel = %d",
+ dbesc($app['guid']),
+ intval($uid)
+ );
+
+ // we don't sync system apps - they may be completely different on the other system
+ build_sync_packet($uid,array('app' => $x));
+ }
}
else {
- $r = q("delete from app where app_id = '%s' and app_channel = %d",
+ self::app_undestroy($uid,$app);
+ }
+ }
+ }
+ }
+
+
+ static public function app_undestroy($uid,$app) {
+
+ // undelete a system app
+
+ if($uid && $app['guid']) {
+
+ $x = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
+ dbesc($app['guid']),
+ intval($uid)
+ );
+ if($x) {
+ if($x[0]['app_system']) {
+ $r = q("update app set app_deleted = 0 where app_id = '%s' and app_channel = %d",
dbesc($app['guid']),
intval($uid)
);
-
- // we don't sync system apps - they may be completely different on the other system
- build_sync_packet($uid,array('app' => $x));
}
}
}
}
+
+
static public function app_installed($uid,$app) {
$r = q("select id from app where app_id = '%s' and app_version = '%s' and app_channel = %d limit 1",
@@ -421,7 +457,7 @@ class Apps {
static public function app_list($uid, $deleted = false, $cat = '') {
if($deleted)
- $sql_extra = " and app_deleted = 1 ";
+ $sql_extra = "";
else
$sql_extra = " and app_deleted = 0 ";
@@ -494,13 +530,14 @@ class Apps {
$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']) : '');
+ $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : '');
$darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : '');
$darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0);
$darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0);
$created = datetime_convert();
- $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires, app_created, app_edited, app_system, app_deleted ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
+ $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires, app_created, app_edited, app_system, app_plugin, app_deleted ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', %d )",
dbesc($darray['app_id']),
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
@@ -517,6 +554,7 @@ class Apps {
dbesc($created),
dbesc($created),
intval($darray['app_system']),
+ dbesc($darray['app_plugin']),
intval($darray['app_deleted'])
);
if($r) {
@@ -569,13 +607,14 @@ class Apps {
$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']) : '');
+ $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : '');
$darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : '');
$darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0);
$darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0);
$edited = datetime_convert();
- $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', app_requires = '%s', app_edited = '%s', app_system = %d, app_deleted = %d where app_id = '%s' and app_channel = %d",
+ $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', app_requires = '%s', app_edited = '%s', app_system = %d, app_plugin = '%s', app_deleted = %d where app_id = '%s' and app_channel = %d",
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
dbesc($darray['app_name']),
@@ -589,6 +628,7 @@ class Apps {
dbesc($darray['app_requires']),
dbesc($edited),
intval($darray['app_system']),
+ dbesc($darray['app_plugin']),
intval($darray['app_deleted']),
dbesc($darray['app_id']),
intval($darray['app_channel'])
@@ -673,6 +713,9 @@ class Apps {
if($app['app_system'])
$ret['system'] = $app['app_system'];
+ if($app['app_plugin'])
+ $ret['plugin'] = $app['app_plugin'];
+
if($app['app_deleted'])
$ret['deleted'] = $app['app_deleted'];
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index a200e986a..425b2d539 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -56,6 +56,7 @@ class Appman extends \Zotlabs\Web\Controller {
if($_POST['delete']) {
Zlib\Apps::app_destroy(local_channel(),$papp);
}
+
if($_POST['edit']) {
return;
diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php
index 4dab621b2..5583f1757 100644
--- a/Zotlabs/Module/Apps.php
+++ b/Zotlabs/Module/Apps.php
@@ -21,7 +21,7 @@ class Apps extends \Zotlabs\Web\Controller {
if(local_channel()) {
Zlib\Apps::import_system_apps();
$syslist = array();
- $list = Zlib\Apps::app_list(local_channel(), false, $_GET['cat']);
+ $list = Zlib\Apps::app_list(local_channel(), (($mode == 'edit') ? true : false), $_GET['cat']);
if($list) {
foreach($list as $x) {
$syslist[] = Zlib\Apps::app_encode($x);
diff --git a/boot.php b/boot.php
index ab7f75095..7531a45b2 100755
--- a/boot.php
+++ b/boot.php
@@ -51,7 +51,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '2.1' );
define ( 'ZOT_REVISION', '1.2' );
-define ( 'DB_UPDATE_VERSION', 1185 );
+define ( 'DB_UPDATE_VERSION', 1186 );
/**
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index e143e252a..3f53ea907 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -114,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `app` (
`app_sig` char(255) NOT NULL DEFAULT '',
`app_author` char(255) NOT NULL DEFAULT '',
`app_name` char(255) NOT NULL DEFAULT '',
- `app_desc` text NOT NULL,
+ `app_desc` text NOT NULL DEFAULT '',
`app_url` char(255) NOT NULL DEFAULT '',
`app_photo` char(255) NOT NULL DEFAULT '',
`app_version` char(255) NOT NULL DEFAULT '',
@@ -125,6 +125,7 @@ CREATE TABLE IF NOT EXISTS `app` (
`app_requires` char(255) NOT NULL DEFAULT '',
`app_deleted` int(11) NOT NULL DEFAULT '0',
`app_system` int(11) NOT NULL DEFAULT '0',
+ `app_plugin` char(255) NOT NULL DEFAULT '',
`app_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`app_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY (`id`),
diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql
index b1b1c8474..1a51ff718 100644
--- a/install/schema_postgres.sql
+++ b/install/schema_postgres.sql
@@ -111,7 +111,7 @@ CREATE TABLE "app" (
"app_sig" text NOT NULL DEFAULT '',
"app_author" text NOT NULL DEFAULT '',
"app_name" text NOT NULL DEFAULT '',
- "app_desc" text NOT NULL,
+ "app_desc" text NOT NULL DEFAULT '',
"app_url" text NOT NULL DEFAULT '',
"app_photo" text NOT NULL DEFAULT '',
"app_version" text NOT NULL DEFAULT '',
@@ -122,6 +122,7 @@ CREATE TABLE "app" (
"app_requires" text NOT NULL DEFAULT '',
"app_deleted" smallint NOT NULL DEFAULT '0',
"app_system" smallint NOT NULL DEFAULT '0',
+ "app_plugin" text NOT NULL DEFAULT '',
"app_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"app_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id")
@@ -138,6 +139,7 @@ create index "app_edited" on app ("app_edited");
create index "app_deleted" on app ("app_deleted");
create index "app_system" on app ("app_system");
+
CREATE TABLE "atoken" (
"atoken_id" serial NOT NULL,
"atoken_aid" bigint NOT NULL DEFAULT 0,
diff --git a/install/update.php b/install/update.php
index dbf3a08ca..eca7011a8 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1185 );
+define( 'UPDATE_VERSION' , 1186 );
/**
*
@@ -2472,3 +2472,12 @@ function update_r1184() {
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
+
+function update_r1185() {
+
+ $r1 = q("alter table app add app_plugin char(255) not null default '' ");
+
+ if($r1)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index b5f25073d..3ae52d5cc 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -1067,11 +1067,12 @@ a.rconnect:hover, a.rateme:hover, div.rateme:hover {
.contact-block-content {
margin-top: 10px;
}
-.contact-block-img.archived {
+.contact-block-img.archived, .app-deleted {
opacity: 0.3;
filter:alpha(opacity=30);
}
+
.profile-match-connect { margin-top: 5px; }
.reshared-content { margin-left: 20px; }
diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl
index 3e6b71b29..cfb652913 100644
--- a/view/tpl/app.tpl
+++ b/view/tpl/app.tpl
@@ -1,5 +1,5 @@
<div class="app-container">
- <div class="app-detail">
+ <div class="app-detail{{if $deleted}} app-deleted{{/if}}">
<a href="{{$app.url}}" {{if $ap.target}}target="{{$ap.target}}" {{/if}}{{if $app.desc}}title="{{$app.desc}}{{if $app.price}} ({{$app.price}}){{/if}}"{{else}}title="{{$app.name}}"{{/if}}><img src="{{$app.photo}}" width="80" height="80" />
<div class="app-name" style="text-align:center;">{{$app.name}}</div>
</a>
@@ -16,7 +16,7 @@
<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="fa fa-arrow-circle-o-down" ></i></button>{{/if}}
{{if $edit}}<input type="hidden" name="appid" value="{{$app.guid}}" /><button type="submit" name="edit" value="{{$edit}}" class="btn btn-default" title="{{$edit}}" ><i class="fa fa-pencil" ></i></button>{{/if}}
- {{if $delete}}<button type="submit" name="delete" value="{{$delete}}" class="btn btn-default" title="{{$delete}}" ><i class="fa fa-trash-o drop-icons"></i></button>{{/if}}
+ {{if $delete}}<button type="submit" name="delete" value="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" class="btn btn-default" title="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" ><i class="fa fa-trash-o drop-icons"></i></button>{{/if}}
</form>
</div>
{{/if}}