aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-05-04 18:46:45 +0000
committerMario <mario@mariovavti.com>2022-05-04 18:46:45 +0000
commitf0c09b374c6577f8c3785b2dfe6c3cbba2bf2041 (patch)
tree1717cc7f8da3aa22cd6220313cfcf0b3554bc70d /Zotlabs
parent38fda98b6da4d97cf8049adc7acc139b28ccd8a2 (diff)
downloadvolse-hubzilla-f0c09b374c6577f8c3785b2dfe6c3cbba2bf2041.tar.gz
volse-hubzilla-f0c09b374c6577f8c3785b2dfe6c3cbba2bf2041.tar.bz2
volse-hubzilla-f0c09b374c6577f8c3785b2dfe6c3cbba2bf2041.zip
move cards to addon
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Card_edit.php140
-rw-r--r--Zotlabs/Module/Cards.php214
-rw-r--r--Zotlabs/Widget/Notes.php4
-rw-r--r--Zotlabs/Widget/Tasklist.php9
4 files changed, 11 insertions, 356 deletions
diff --git a/Zotlabs/Module/Card_edit.php b/Zotlabs/Module/Card_edit.php
deleted file mode 100644
index c57a0f043..000000000
--- a/Zotlabs/Module/Card_edit.php
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-require_once('include/channel.php');
-require_once('include/acl_selectors.php');
-require_once('include/conversation.php');
-
-class Card_edit extends \Zotlabs\Web\Controller {
-
-
- function get() {
-
- // Figure out which post we're editing
- $post_id = ((argc() > 1) ? intval(argv(1)) : 0);
-
- if(! $post_id) {
- notice( t('Item not found') . EOL);
- return;
- }
-
- $itm = q("SELECT * FROM item WHERE id = %d and item_type = %d LIMIT 1",
- intval($post_id),
- intval(ITEM_TYPE_CARD)
- );
- if($itm) {
- $item_id = q("select * from iconfig where cat = 'system' and k = 'CARD' and iid = %d limit 1",
- intval($itm[0]['id'])
- );
- if($item_id)
- $card_title = $item_id[0]['v'];
- }
- else {
- notice( t('Item not found') . EOL);
- return;
- }
-
- $owner = $itm[0]['uid'];
- $uid = local_channel();
-
- $observer = \App::get_observer();
-
- $channel = channelx_by_n($owner);
- if(! $channel) {
- notice( t('Channel not found.') . EOL);
- return;
- }
-
- $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
-
- if(! perm_is_allowed($owner,$ob_hash,'write_pages')) {
- notice( t('Permission denied.') . EOL);
- return;
- }
-
- $is_owner = (($uid && $uid == $owner) ? true : false);
-
- $o = '';
-
-
-
- $category = '';
- $catsenabled = ((feature_enabled($owner,'categories')) ? 'categories' : '');
-
- if ($catsenabled){
- $itm = fetch_post_tags($itm);
-
- $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
-
- foreach ($cats as $cat) {
- if (strlen($category))
- $category .= ', ';
- $category .= $cat['term'];
- }
- }
-
- if($itm[0]['attach']) {
- $j = json_decode($itm[0]['attach'],true);
- if($j) {
- foreach($j as $jj) {
- $itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
- }
- }
- }
-
-
- $mimetype = $itm[0]['mimetype'];
-
- $content = $itm[0]['body'];
-
-
-
- $rp = 'cards/' . $channel['channel_address'];
-
- $x = array(
- 'nickname' => $channel['channel_address'],
- 'bbco_autocomplete'=> 'bbcode',
- 'return_path' => $rp,
- 'webpage' => ITEM_TYPE_CARD,
- 'button' => t('Edit'),
- 'writefiles' => perm_is_allowed($owner, get_observer_hash(), 'write_pages'),
- 'weblink' => t('Insert web link'),
- 'hide_voting' => false,
- 'hide_future' => false,
- 'hide_location' => false,
- 'hide_expire' => false,
- 'showacl' => true,
- 'acl' => populate_acl($itm[0],false,\Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')),
- 'permissions' => $itm[0],
- 'lockstate' => (($itm[0]['allow_cid'] || $itm[0]['allow_gid'] || $itm[0]['deny_cid'] || $itm[0]['deny_gid']) ? 'lock' : 'unlock'),
- 'ptyp' => $itm[0]['type'],
- 'mimeselect' => false,
- 'mimetype' => $itm[0]['mimetype'],
- 'body' => undo_post_tagging($content),
- 'post_id' => $post_id,
- 'visitor' => true,
- 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
- 'summary' => htmlspecialchars($itm[0]['summary'],ENT_COMPAT,'UTF-8'),
- 'placeholdertitle' => t('Title (optional)'),
- 'pagetitle' => $card_title,
- 'profile_uid' => (intval($channel['channel_id'])),
- 'catsenabled' => $catsenabled,
- 'category' => $category,
- 'bbcode' => (($mimetype == 'text/bbcode') ? true : false)
- );
-
- $editor = status_editor($a, $x, false, 'Card_edit');
-
- $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
- '$title' => t('Edit Card'),
- '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false),
- '$id' => $itm[0]['id'],
- '$cancel' => t('Cancel'),
- '$editor' => $editor
- ));
-
- return $o;
-
- }
-
-}
diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php
deleted file mode 100644
index b71af6044..000000000
--- a/Zotlabs/Module/Cards.php
+++ /dev/null
@@ -1,214 +0,0 @@
-<?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');
-
-/**
- * @brief Provides the Cards module.
- *
- */
-class Cards extends Controller {
-
- public function init() {
-
- if(argc() > 1)
- $which = argv(1);
- else
- return;
-
- profile_load($which);
- }
-
- /**
- * {@inheritDoc}
- * @see \\Zotlabs\\Web\\Controller::get()
- *
- * @return string Parsed HTML from template 'cards.tpl'
- */
- public function get($update = 0, $load = false) {
-
- if(observer_prohibited(true)) {
- return login();
- }
-
- if(! App::$profile) {
- notice( t('Requested profile is not available.') . EOL );
- App::$error = 404;
- return;
- }
-
- if(! Apps::system_app_installed(App::$profile_uid, 'Cards')) {
- //Do not display any associated widgets at this point
- App::$pdl = '';
- $papp = Apps::get_papp('Cards');
- return Apps::app_render($papp, 'module');
- }
-
- 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),
- 'title' => 'oembed'
- ]);
-
-
- $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));
- }
-
-
- $which = argv(1);
-
- $selected_card = ((argc() > 2) ? argv(2) : '');
-
- $_SESSION['return_url'] = App::$query_string;
-
- $uid = local_channel();
- $owner = App::$profile_uid;
- $observer = App::get_observer();
-
- $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
-
- if(! perm_is_allowed($owner, $ob_hash, 'view_pages')) {
- notice( t('Permission denied.') . EOL);
- return;
- }
-
- $is_owner = ($uid && $uid == $owner);
-
- $channel = channelx_by_n($owner);
-
- if($channel) {
- $channel_acl = [
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
- 'deny_gid' => $channel['channel_deny_gid']
- ];
- }
- else {
- $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ];
- }
-
-
- if(perm_is_allowed($owner, $ob_hash, 'write_pages')) {
-
- $x = [
- 'webpage' => ITEM_TYPE_CARD,
- 'is_owner' => true,
- 'content_label' => t('Add Card'),
- 'button' => t('Save'),
- '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,
- PermissionDescription::fromGlobalPermission('view_pages')) : ''),
- 'permissions' => $channel_acl,
- 'showacl' => (($is_owner) ? true : false),
- 'visitor' => true,
- 'hide_location' => false,
- 'hide_voting' => false,
- 'profile_uid' => intval($owner),
- 'mimetype' => 'text/bbcode',
- 'mimeselect' => false,
- 'layoutselect' => false,
- 'expanded' => false,
- 'novoting' => false,
- 'catsenabled' => feature_enabled($owner, 'categories'),
- 'bbco_autocomplete' => 'bbcode',
- 'bbcode' => true
- ];
-
- if($_REQUEST['title'])
- $x['title'] = $_REQUEST['title'];
- if($_REQUEST['body'])
- $x['body'] = $_REQUEST['body'];
-
- $editor = status_editor($a, $x, false, 'Cards');
- }
- else {
- $editor = '';
- }
-
-
- $itemspage = get_pconfig(local_channel(),'system','itemspage');
- App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
-
-
- $sql_extra = item_permissions_sql($owner);
- $sql_item = '';
-
- if($selected_card) {
- $r = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = 'CARD' and iconfig.v = '%s' limit 1",
- dbesc($selected_card)
- );
- if($r) {
- $sql_item = "and item.id = " . intval($r[0]['iid']) . " ";
- }
- }
-
- $r = q("select * from item
- where uid = %d and item_type = %d
- $sql_extra $sql_item order by item.created desc $pager_sql",
- intval($owner),
- intval(ITEM_TYPE_CARD)
- );
-
- $item_normal = " and item.item_hidden = 0 and item.item_type in (0,6) and item.item_deleted = 0
- and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
- and item.item_blocked = 0 ";
-
- $items_result = [];
- if($r) {
-
- $pager_total = count($r);
-
- $parents_str = ids_to_querystr($r, 'id');
-
- $items = q("SELECT item.*, item.id AS item_id
- FROM item
- WHERE item.uid = %d $item_normal
- AND item.parent IN ( %s )
- $sql_extra $sql_extra2 ",
- intval(App::$profile['profile_uid']),
- dbesc($parents_str)
- );
- if($items) {
- xchan_query($items);
- $items = fetch_post_tags($items, true);
- $items_result = conv_sort($items, 'updated');
- }
- }
-
- $mode = 'cards';
-
- if(get_pconfig(local_channel(),'system','articles_list_mode') && (! $selected_card))
- $page_mode = 'pager_list';
- else
- $page_mode = 'traditional';
-
- $content = conversation($items_result, $mode, false, $page_mode);
-
- $o = replace_macros(get_markup_template('cards.tpl'), [
- '$title' => t('Cards'),
- '$editor' => $editor,
- '$content' => $content,
- '$pager' => alt_pager($pager_total)
- ]);
-
- return $o;
- }
-
-}
diff --git a/Zotlabs/Widget/Notes.php b/Zotlabs/Widget/Notes.php
index 2e8e04e93..c9d08c6b7 100644
--- a/Zotlabs/Widget/Notes.php
+++ b/Zotlabs/Widget/Notes.php
@@ -10,6 +10,7 @@
namespace Zotlabs\Widget;
+use App;
use Zotlabs\Lib\Apps;
class Notes {
@@ -18,6 +19,9 @@ class Notes {
if(! local_channel())
return EMPTY_STR;
+ if(App::$profile_uid !== local_channel())
+ return EMPTY_STR;
+
if(! Apps::system_app_installed(local_channel(), 'Notes'))
return EMPTY_STR;
diff --git a/Zotlabs/Widget/Tasklist.php b/Zotlabs/Widget/Tasklist.php
index 5ecfd5a27..96b70af15 100644
--- a/Zotlabs/Widget/Tasklist.php
+++ b/Zotlabs/Widget/Tasklist.php
@@ -7,12 +7,17 @@
namespace Zotlabs\Widget;
+use App;
+
class Tasklist {
function widget($arr) {
- if (! local_channel())
- return;
+ if(! local_channel())
+ return EMPTY_STR;
+
+ if(App::$profile_uid !== local_channel())
+ return EMPTY_STR;
$o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';
$o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id, function(data) { tasksFetch();}); }