diff options
Diffstat (limited to 'mod/editblock.php')
-rw-r--r-- | mod/editblock.php | 91 |
1 files changed, 41 insertions, 50 deletions
diff --git a/mod/editblock.php b/mod/editblock.php index dcb4b42a7..8ccccc24b 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -1,74 +1,68 @@ <?php -// What is this here for? I think it's cruft, but comment out for now in case it's here for a reason -// require_once('acl_selectors.php'); function editblock_content(&$a) { -// We first need to figure out who owns the webpage, grab it from an argument - $which = argv(1); -// $a->get_channel() and stuff don't work here, so we've got to find the owner for ourselves. - $r = q("select channel_id from channel where channel_address = '%s'", - dbesc($which) - ); - if($r) { - $owner = intval($r[0]['channel_id']); - //logger('owner: ' . print_r($owner,true)); - } + if(argc() < 2) { + notice( t('Item not found') . EOL); + return; + } + $channel = get_channel_by_nick(argv(1)); - - - if((local_user()) && (argc() > 2) && (argv(2) === 'view')) { - $which = $channel['channel_address']; - } + if($c) { + $owner = intval($channel['channel_id']); + } $o = ''; -// Figure out which post we're editing + // Figure out which post we're editing $post_id = ((argc() > 2) ? intval(argv(2)) : 0); - if(! $post_id) { + if(! ($post_id && $channel)) { notice( t('Item not found') . EOL); return; } -// Now we've got a post and an owner, let's find out if we're allowed to edit it - - $observer = $a->get_observer(); - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + // Now we've got a post and an owner, let's find out if we're allowed to edit it - $perms = get_all_perms($owner,$ob_hash); - - if(! $perms['write_pages']) { - notice( t('Permission denied.') . EOL); - return; - } + if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'write_pages')) { + notice( t('Permission denied.') . EOL); + return; + } -// We've already figured out which item we want and whose copy we need, so we don't need anything fancy here - $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", - intval($post_id), - intval($owner) - ); - $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", - $itm[0]['id'] + // We've already figured out which item we want and whose copy we need, so we don't need anything fancy here + $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", + intval($post_id), + intval($channel['channel_id']) ); - if($item_id) - $block_title = $item_id[0]['sid']; + if($itm) { + $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", + $itm[0]['id'] + ); + if($item_id) + $block_title = $item_id[0]['sid']; + } + else { + notice( t('Item not found') . EOL); + return; + } $plaintext = true; -// You may or may not be a local user. This won't work, - if(feature_enabled(local_user(),'richtext')) + + // You may or may not be a local user. + if(local_user() && feature_enabled(local_user(),'richtext')) $plaintext = false; $mimeselect = ''; + $mimetype = $itm[0]['mimetype']; if($mimetype != 'text/bbcode') $plaintext = true; @@ -79,9 +73,6 @@ function editblock_content(&$a) { $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - - - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Block') )); @@ -91,8 +82,8 @@ function editblock_content(&$a) { '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'), - '$geotag' => $geotag, - '$nickname' => $a->user['nickname'], + '$geotag' => '', + '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete block?') )); @@ -105,13 +96,13 @@ function editblock_content(&$a) { call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); - $channel = $a->get_channel(); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); -//FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. So, send folk to the webpage list. + // FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. + //So, send folk to the webpage list. - $rp = '/blocks/' . $which; + $rp = 'blocks/' . $channel['channel_address']; $o .= replace_macros($tpl,array( '$return_path' => $rp, @@ -147,10 +138,10 @@ function editblock_content(&$a) { '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', - '$profile_uid' => (intval($owner)), + '$profile_uid' => (intval($channel['channel_id'])), '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), '$jotplugins' => $jotplugins, - '$sourceapp' => t($a->sourcename), + '$sourceapp' => $itm[0]['app'], '$defexpire' => '', '$feature_expire' => 'none', '$expires' => t('Set expiration date'), |