aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Apps.php41
-rw-r--r--Zotlabs/Module/Appman.php6
-rw-r--r--Zotlabs/Widget/Appcategories.php1
-rw-r--r--include/nav.php14
-rw-r--r--view/tpl/app.tpl9
5 files changed, 49 insertions, 22 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)
diff --git a/include/nav.php b/include/nav.php
index 9df50c9fe..8d39d492a 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -253,7 +253,7 @@ EOT;
}
$syslist = array();
- $list = Zlib\Apps::app_list(local_channel(), false, 'nav_featured_app');
+ $list = Zlib\Apps::app_list(local_channel(), false, ['nav_featured_app', 'nav_pinned_app']);
if($list) {
foreach($list as $li) {
$syslist[] = Zlib\Apps::app_encode($li);
@@ -274,16 +274,20 @@ EOT;
$app['active'] = true;
if($is_owner) {
- $nav_apps[] = Zlib\Apps::app_render($app,'nav');
- if(strpos($app['categories'],'navbar_' . $template)) {
+ if(strpos($app['categories'],'nav_pinned_app')) {
$navbar_apps[] = Zlib\Apps::app_render($app,'navbar');
}
+ else {
+ $nav_apps[] = Zlib\Apps::app_render($app,'nav');
+ }
}
elseif(! $is_owner && strpos($app['requires'], 'local_channel') === false) {
- $nav_apps[] = Zlib\Apps::app_render($app,'nav');
- if(strpos($app['categories'],'navbar_' . $template)) {
+ if(strpos($app['categories'],'nav_pinned_app')) {
$navbar_apps[] = Zlib\Apps::app_render($app,'navbar');
}
+ else {
+ $nav_apps[] = Zlib\Apps::app_render($app,'nav');
+ }
}
}
diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl
index ac5c18deb..c8bbc4ce1 100644
--- a/view/tpl/app.tpl
+++ b/view/tpl/app.tpl
@@ -15,10 +15,11 @@
<div class="app-tools">
<form action="{{$hosturl}}appman" method="post">
<input type="hidden" name="papp" value="{{$app.papp}}" />
- {{if $install}}<button type="submit" name="install" value="{{$install}}" class="btn btn-outline-secondary btn-sm" 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-outline-secondary btn-sm" title="{{$edit}}" ><i class="fa fa-pencil" ></i></button>{{/if}}
- {{if $delete}}<button type="submit" name="delete" value="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" class="btn btn-outline-secondary btn-sm" title="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" ><i class="fa fa-trash-o drop-icons"></i></button>{{/if}}
- {{if $feature}}<button type="submit" name="feature" value="feature" class="btn btn-outline-secondary btn-sm" title="{{if $featured}}{{$remove}}{{else}}{{$add}}{{/if}}"><i class="fa fa-star"{{if $featured}} style="color: gold"{{/if}}></i></button>{{/if}}
+ {{if $install}}<button type="submit" name="install" value="{{$install}}" class="btn btn-outline-secondary btn-sm" title="{{$install}}" ><i class="fa fa-fw 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-outline-secondary btn-sm" title="{{$edit}}" ><i class="fa fa-fw fa-pencil" ></i></button>{{/if}}
+ {{if $delete}}<button type="submit" name="delete" value="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" class="btn btn-outline-secondary btn-sm" title="{{if $deleted}}{{$undelete}}{{else}}{{$delete}}{{/if}}" ><i class="fa fa-fw fa-trash-o drop-icons"></i></button>{{/if}}
+ {{if $feature}}<button type="submit" name="feature" value="nav_featured_app" class="btn btn-outline-secondary btn-sm" title="{{if $featured}}{{$remove}}{{else}}{{$add}}{{/if}}"><i class="fa fa-fw fa-star{{if $featured}} text-warning{{/if}}"></i></button>{{/if}}
+ {{if $pin}}<button type="submit" name="pin" value="nav_pinned_app" class="btn btn-outline-secondary btn-sm" title="{{if $pinned}}{{$remove_nav}}{{else}}{{$add_nav}}{{/if}}"><i class="fa fa-fw fa-thumb-tack{{if $pinned}} text-success{{/if}}"></i></button>{{/if}}
</form>
</div>
{{/if}}