diff options
author | zotlabs <mike@macgirvin.com> | 2017-08-23 17:46:20 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-08-23 17:46:20 -0700 |
commit | 3b68df1be6173cbcc50386efc0161ece2015112d (patch) | |
tree | e075614cc9faa7a3cf1f93cff8c91cf0da34e663 /Zotlabs | |
parent | 9518dc0e4ee40c9672e533afbb1a506c3a85c598 (diff) | |
download | volse-hubzilla-3b68df1be6173cbcc50386efc0161ece2015112d.tar.gz volse-hubzilla-3b68df1be6173cbcc50386efc0161ece2015112d.tar.bz2 volse-hubzilla-3b68df1be6173cbcc50386efc0161ece2015112d.zip |
several card enhancements
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 5 | ||||
-rw-r--r-- | Zotlabs/Module/Card_edit.php | 135 | ||||
-rw-r--r-- | Zotlabs/Module/Cards.php | 54 |
3 files changed, 161 insertions, 33 deletions
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index ad944203c..526169e1b 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -101,10 +101,13 @@ class ThreadItem { if($item['author']['xchan_network'] === 'rss') $shareable = true; + $mode = $conv->get_mode(); + $edlink = (($item['item_type'] == ITEM_TYPE_CARD) ? 'card_edit' : 'editpost'); + if(local_channel() && $observer['xchan_hash'] === $item['author_xchan']) - $edpost = array(z_root()."/editpost/".$item['id'], t("Edit")); + $edpost = array(z_root() . '/' . $edlink . '/' . $item['id'], t('Edit')); else $edpost = false; diff --git a/Zotlabs/Module/Card_edit.php b/Zotlabs/Module/Card_edit.php new file mode 100644 index 000000000..216d2cf63 --- /dev/null +++ b/Zotlabs/Module/Card_edit.php @@ -0,0 +1,135 @@ +<?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, + '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'), + '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); + + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit Block'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$id' => $itm[0]['id'], + '$editor' => $editor + )); + + return $o; + + } + +} diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 1fdd3b63f..1c37ca13d 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -47,24 +47,14 @@ class Cards extends \Zotlabs\Web\Controller { $which = argv(1); + $selected_card = ((argc() > 2) ? argv(2) : ''); + $_SESSION['return_url'] = \App::$query_string; - $uid = \App::$profile_uid; - $owner = 0; + $uid = local_channel(); + $owner = \App::$profile_uid; $observer = \App::get_observer(); - $channel = \App::$profile; - - if(! $owner) { - // Figure out who the page owner is. - $r = q("select channel_id from channel where channel_address = '%s'", - dbesc($which) - ); - if($r) { - $owner = intval($r[0]['channel_id']); - } - } - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { @@ -76,13 +66,10 @@ class Cards extends \Zotlabs\Web\Controller { $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); - // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages - // Nickname is set to the observers xchan, and profile_uid to the owner's. - // This lets you post pages at other people's channels. + $is_owner = ($uid && $uid == $owner); - if((! $channel) && ($uid) && ($uid == \App::$profile_uid)) { - $channel = \App::get_channel(); - } + $channel = channelx_by_n($owner); + if($channel) { $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], @@ -95,28 +82,25 @@ class Cards extends \Zotlabs\Web\Controller { $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } - - $is_owner = ($uid && $uid == $owner); - if(perm_is_allowed($owner,$ob_hash,'write_pages')) { $x = array( 'webpage' => ITEM_TYPE_CARD, 'is_owner' => true, - 'nickname' => \App::$profile['channel_address'], + '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')) : ''), 'permissions' => $channel_acl, 'showacl' => (($is_owner) ? true : false), 'visitor' => true, - 'hide_location' => true, - 'hide_voting' => true, + 'hide_location' => false, + 'hide_voting' => false, 'profile_uid' => intval($owner), 'mimetype' => $mimetype, 'mimeselect' => false, 'layoutselect' => false, 'expanded' => false, - 'novoting'=> true, + 'novoting'=> false, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true ); @@ -130,12 +114,18 @@ class Cards extends \Zotlabs\Web\Controller { if($_REQUEST['body']) $x['body'] = $_REQUEST['body']; - // Get a list of webpages. We can't display all them because endless scroll makes that unusable, - // so just list titles and an edit link. - - + $sql_extra = item_permissions_sql($owner); - + + 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_extra .= "and item.id = " . intval($r[0]['iid']) . " "; + } + } + $r = q("select * from item where item.uid = %d and item_type = %d $sql_extra order by item.created desc", |