aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2017-11-16 11:11:06 +0100
committerMario Vavti <mario@mariovavti.com>2017-11-16 11:11:06 +0100
commit78c9f752af8db5db290a57224fa1d0239a36a34d (patch)
tree97f75c296cceb5cb248fe7335b3c3b79e41941c0 /Zotlabs
parentd13a6180be310cb184f891fa2b969542691c1863 (diff)
downloadvolse-hubzilla-78c9f752af8db5db290a57224fa1d0239a36a34d.tar.gz
volse-hubzilla-78c9f752af8db5db290a57224fa1d0239a36a34d.tar.bz2
volse-hubzilla-78c9f752af8db5db290a57224fa1d0239a36a34d.zip
provide ability to pin apps to navbar from /apps. this removes the ability to have per custom navbar pinned apps - this can be added later if desired
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Apps.php41
-rw-r--r--Zotlabs/Module/Appman.php6
-rw-r--r--Zotlabs/Widget/Appcategories.php1
3 files changed, 35 insertions, 13 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index f13fbe362..bd271e860 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -401,11 +401,15 @@ class Apps {
'$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''),
'$deleted' => $papp['deleted'],
'$feature' => (($papp['embed']) ? false : true),
+ '$pin' => (($papp['embed']) ? false : true),
'$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true),
+ '$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true),
'$navapps' => (($mode == 'nav') ? true : false),
'$order' => (($mode == 'nav-order') ? true : false),
'$add' => t('Add to app-tray'),
- '$remove' => t('Remove from app-tray')
+ '$remove' => t('Remove from app-tray'),
+ '$add_nav' => t('Add to navbar'),
+ '$remove_nav' => t('Remove from navbar')
));
}
@@ -498,25 +502,27 @@ class Apps {
}
}
- static public function app_feature($uid,$app) {
+ static public function app_feature($uid,$app,$term) {
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($app['guid']),
intval($uid)
);
- $x = q("select * from term where otype = %d and oid = %d and term = 'nav_featured_app' limit 1",
+ $x = q("select * from term where otype = %d and oid = %d and term = '%s' limit 1",
intval(TERM_OBJ_APP),
- intval($r[0]['id'])
+ intval($r[0]['id']),
+ dbesc($term)
);
if($x) {
- q("delete from term where otype = %d and oid = %d and term = 'nav_featured_app'",
+ q("delete from term where otype = %d and oid = %d and term = '%s'",
intval(TERM_OBJ_APP),
- intval($x[0]['oid'])
+ intval($x[0]['oid']),
+ dbesc($term)
);
}
else {
- store_item_tag($uid,$r[0]['id'],TERM_OBJ_APP,TERM_CATEGORY,'nav_featured_app',escape_tags(z_root() . '/apps/?f=&cat=nav_featured_app'));
+ store_item_tag($uid, $r[0]['id'], TERM_OBJ_APP, TERM_CATEGORY, $term, escape_tags(z_root() . '/apps/?f=&cat=' . $term));
}
}
@@ -531,16 +537,27 @@ class Apps {
}
- static public function app_list($uid, $deleted = false, $cat = '') {
+ static public function app_list($uid, $deleted = false, $cats = []) {
if($deleted)
$sql_extra = "";
else
$sql_extra = " and app_deleted = 0 ";
- if($cat) {
- $r = q("select oid from term where otype = %d and term = '%s'",
- intval(TERM_OBJ_APP),
- dbesc($cat)
+ if($cats) {
+
+ $cat_sql_extra = " and ( ";
+
+ foreach($cats as $cat) {
+ if(strpos($cat_sql_extra, 'term'))
+ $cat_sql_extra .= "or ";
+
+ $cat_sql_extra .= "term = '" . dbesc($cat) . "' ";
+ }
+
+ $cat_sql_extra .= ") ";
+
+ $r = q("select oid from term where otype = %d $cat_sql_extra",
+ intval(TERM_OBJ_APP)
);
if(! $r)
return $r;
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index 5c0667357..64d4628ae 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -64,7 +64,11 @@ class Appman extends \Zotlabs\Web\Controller {
}
if($_POST['feature']) {
- Zlib\Apps::app_feature(local_channel(),$papp);
+ Zlib\Apps::app_feature(local_channel(), $papp, $_POST['feature']);
+ }
+
+ if($_POST['pin']) {
+ Zlib\Apps::app_feature(local_channel(), $papp, $_POST['pin']);
}
if($_SESSION['return_url'])
diff --git a/Zotlabs/Widget/Appcategories.php b/Zotlabs/Widget/Appcategories.php
index 490ec1abc..8ff14230f 100644
--- a/Zotlabs/Widget/Appcategories.php
+++ b/Zotlabs/Widget/Appcategories.php
@@ -26,6 +26,7 @@ class Appcategories {
and term.uid = app_channel
and term.otype = %d
and term.term != 'nav_featured_app'
+ and term.term != 'nav_pinned_app'
order by term.term asc",
intval(local_channel()),
intval(TERM_OBJ_APP)