move cards from features to apps

This commit is contained in:
Mario Vavti 2018-09-10 13:34:05 +02:00
parent 4bb16b18ed
commit c6abe87ec2
4 changed files with 33 additions and 34 deletions

View File

@ -1,12 +1,16 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\PermissionDescription;
require_once('include/channel.php');
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
class Cards extends \Zotlabs\Web\Controller {
class Cards extends Controller {
function init() {
@ -29,22 +33,24 @@ class Cards extends \Zotlabs\Web\Controller {
return login();
}
if(! \App::$profile) {
if(! App::$profile) {
notice( t('Requested profile is not available.') . EOL );
\App::$error = 404;
App::$error = 404;
return;
}
if(! feature_enabled(\App::$profile_uid, 'cards')) {
return;
if(! Apps::system_app_installed(App::$profile_uid, 'Cards')) {
$o = '<b>Cards App - Not Installed:</b><br>';
$o .= 'Create personal planning cards';
return $o;
}
nav_set_selected(t('Cards'));
nav_set_selected('Cards');
head_add_link([
'rel' => 'alternate',
'type' => 'application/json+oembed',
'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string),
'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$query_string),
'title' => 'oembed'
]);
@ -52,7 +58,7 @@ class Cards extends \Zotlabs\Web\Controller {
$category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : '');
if($category) {
$sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'], 'item', $category, TERM_CATEGORY));
$sql_extra2 .= protect_sprintf(term_item_parent_query(App::$profile['profile_uid'], 'item', $category, TERM_CATEGORY));
}
@ -60,11 +66,11 @@ class Cards extends \Zotlabs\Web\Controller {
$selected_card = ((argc() > 2) ? argv(2) : '');
$_SESSION['return_url'] = \App::$query_string;
$_SESSION['return_url'] = App::$query_string;
$uid = local_channel();
$owner = \App::$profile_uid;
$observer = \App::get_observer();
$owner = App::$profile_uid;
$observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
@ -101,8 +107,8 @@ class Cards extends \Zotlabs\Web\Controller {
'nickname' => $channel['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => (($is_owner) ? populate_acl($channel_acl, false,
\Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''),
'acl' => (($is_owner) ? populate_acl($channel_acl, false,
PermissionDescription::fromGlobalPermission('view_pages')) : ''),
'permissions' => $channel_acl,
'showacl' => (($is_owner) ? true : false),
'visitor' => true,
@ -132,8 +138,8 @@ class Cards extends \Zotlabs\Web\Controller {
$itemspage = get_pconfig(local_channel(),'system','itemspage');
\App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
$sql_extra = item_permissions_sql($owner);
@ -171,7 +177,7 @@ class Cards extends \Zotlabs\Web\Controller {
WHERE item.uid = %d $item_normal
AND item.parent IN ( %s )
$sql_extra $sql_extra2 ",
intval(\App::$profile['profile_uid']),
intval(App::$profile['profile_uid']),
dbesc($parents_str)
);
if($items) {

View File

@ -2,6 +2,9 @@
namespace Zotlabs\Widget;
use App;
use Zotlabs\Lib\Apps;
require_once('include/contact_widgets.php');
class Categories {
@ -10,22 +13,22 @@ class Categories {
$cards = ((array_key_exists('cards',$arr) && $arr['cards']) ? true : false);
if(($cards) && (! feature_enabled(\App::$profile['profile_uid'],'cards')))
if(($cards) && (! Apps::system_app_installed(App::$profile['profile_uid'], 'Cards')))
return '';
$articles = ((array_key_exists('articles',$arr) && $arr['articles']) ? true : false);
if(($articles) && (! feature_enabled(\App::$profile['profile_uid'],'articles')))
if(($articles) && (! feature_enabled(App::$profile['profile_uid'],'articles')))
return '';
if((! \App::$profile['profile_uid'])
|| (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) {
if((! App::$profile['profile_uid'])
|| (! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) {
return '';
}
$cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : '');
$srchurl = (($cards) ? \App::$argv[0] . '/' . \App::$argv[1] : \App::$query_string);
$srchurl = (($cards) ? App::$argv[0] . '/' . App::$argv[1] : App::$query_string);
$srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&');
$srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl);

View File

@ -1,6 +1,6 @@
version: 1.1
version: 1.2
url: $baseurl/cards/$nick
name: Cards
requires: local_channel, cards
requires: local_channel
photo: icon:list
categories: nav_featured_app, Productivity

View File

@ -118,16 +118,6 @@ function get_features($filtered = true, $level = (-1)) {
feature_level('private_notes',1),
],
[
'cards',
t('Cards'),
t('Create personal planning cards'),
false,
get_config('feature_lock','cards'),
feature_level('cards',1),
],
[
'articles',
t('Articles'),