diff options
author | Thomas Willingham <founder@kakste.com> | 2013-08-09 18:30:30 +0100 |
---|---|---|
committer | Thomas Willingham <founder@kakste.com> | 2013-08-09 18:30:30 +0100 |
commit | b161d4073def64abf0b2c8d61a19f5f7a6673380 (patch) | |
tree | ba31f8d0197f44b598e30e90aa2488ebbe32a593 | |
parent | d8d45dab76fa96df9f57e9d5975daaf5a5322026 (diff) | |
download | volse-hubzilla-b161d4073def64abf0b2c8d61a19f5f7a6673380.tar.gz volse-hubzilla-b161d4073def64abf0b2c8d61a19f5f7a6673380.tar.bz2 volse-hubzilla-b161d4073def64abf0b2c8d61a19f5f7a6673380.zip |
Allow creation of webpages at channels other than your own.
-rw-r--r-- | mod/webpages.php | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/mod/webpages.php b/mod/webpages.php index f2026ea0b..9e885c14b 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -1,6 +1,6 @@ <?php -function webpages_init(&$a) { +function webpages_content(&$a) { if(argc() > 1) $which = argv(1); @@ -20,14 +20,24 @@ function webpages_init(&$a) { profile_load($a,$which,$profile); -} - -function webpages_content(&$a) { + $r = q("select channel_id from channel where channel_address = '%s'", + dbesc($which) + ); + if($r) { + $owner = intval($r[0]['channel_id']); + } // We can do better, but since editing only works for local users and all posts are webpages, return anyone else for now. -if (!local_user()) return; + $observer = $a->get_observer(); + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + $perms = get_all_perms($owner,$ob_hash); + if(! $perms['write_pages']) { + notice( t('Permission denied.') . EOL); + return; + } // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages require_once ('include/conversation.php'); @@ -38,7 +48,7 @@ require_once ('include/conversation.php'); 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'bang' => (($group || $cid) ? '!' : ''), 'visitor' => 'block', - 'profile_uid' => local_user() + 'profile_uid' => intval($owner), ); $o .= status_editor($a,$x); @@ -47,7 +57,7 @@ require_once ('include/conversation.php'); // FIXME - we should sort these results, but it's not obvious what order yet. Alphabetical? Created order? $r = q("select * from item_id where uid = %d and service = 'WEBPAGE'", - intval(local_user()) + intval($owner) ); $pages = null; @@ -61,13 +71,13 @@ $r = q("select * from item_id where uid = %d and service = 'WEBPAGE'", //Build the base URL for edit links - $url = z_root() . "/editwebpage/" . $a->profile['channel_address']; + $url = z_root() . "/editwebpage/" . $which; // This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM). return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( '$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, - '$channel' => $a->profile['channel_address'], + '$channel' => $which, '$view' => t('View'), )); |