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

View File

@ -2,6 +2,9 @@
namespace Zotlabs\Widget; namespace Zotlabs\Widget;
use App;
use Zotlabs\Lib\Apps;
require_once('include/contact_widgets.php'); require_once('include/contact_widgets.php');
class Categories { class Categories {
@ -10,22 +13,22 @@ class Categories {
$cards = ((array_key_exists('cards',$arr) && $arr['cards']) ? true : false); $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 ''; return '';
$articles = ((array_key_exists('articles',$arr) && $arr['articles']) ? true : false); $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 ''; return '';
if((! \App::$profile['profile_uid']) if((! App::$profile['profile_uid'])
|| (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) { || (! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) {
return ''; return '';
} }
$cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : ''); $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 = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&');
$srchurl = str_replace(array('?f=','&f='),array('',''),$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 url: $baseurl/cards/$nick
name: Cards name: Cards
requires: local_channel, cards requires: local_channel
photo: icon:list photo: icon:list
categories: nav_featured_app, Productivity categories: nav_featured_app, Productivity

View File

@ -118,16 +118,6 @@ function get_features($filtered = true, $level = (-1)) {
feature_level('private_notes',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', 'articles',
t('Articles'), t('Articles'),