diff options
-rw-r--r-- | include/page_widgets.php | 12 | ||||
-rw-r--r-- | mod/page.php | 15 | ||||
-rw-r--r-- | mod/webpages.php | 30 | ||||
-rw-r--r-- | view/tpl/write_pages.tpl | 3 |
4 files changed, 49 insertions, 11 deletions
diff --git a/include/page_widgets.php b/include/page_widgets.php new file mode 100644 index 000000000..21d5e5382 --- /dev/null +++ b/include/page_widgets.php @@ -0,0 +1,12 @@ +<?php + +// A toolbar for observers with write_pages permissions +function writepages_widget ($who,$which){ +return replace_macros(get_markup_template('write_pages.tpl'), array( + '$new' => t('New Page'), + '$newurl' => "webpages/$who", + '$edit' => t('edit'), + '$editurl' => "editwebpage/$who/$which" + )); +} + diff --git a/mod/page.php b/mod/page.php index 51b292f37..1bdc3027a 100644 --- a/mod/page.php +++ b/mod/page.php @@ -2,6 +2,8 @@ require_once('include/items.php'); require_once('include/conversation.php'); +require_once('include/page_widgets.php'); + function page_init(&$a) { // We need this to make sure the channel theme is always loaded. $which = argv(1); @@ -32,7 +34,6 @@ function page_content(&$a) { return; } - if(argc() < 3) { notice( t('Invalid item.') . EOL); return; @@ -57,12 +58,24 @@ function page_content(&$a) { dbesc($page_id), intval(ITEM_WEBPAGE) ); + logger('r: ' . print_r($r,true)); if(! $r) { notice( t('Item not found.') . EOL); return; } +// Use of widgets should be determined by Comanchie, but we don't have it yet, so... + + + if ($perms['write_pages']) { + $who = $channel_address; + $which = $r[0]['id']; + $o .= writepages_widget($who,$which); + } + + + xchan_query($r); $r = fetch_post_tags($r,true); $a->profile = array('profile_uid' => $u[0]['channel_id']); diff --git a/mod/webpages.php b/mod/webpages.php index f2026ea0b..8e3901d90 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); @@ -46,8 +56,8 @@ require_once ('include/conversation.php'); //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. // 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()) +$r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by sid asc", + 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'), )); diff --git a/view/tpl/write_pages.tpl b/view/tpl/write_pages.tpl new file mode 100644 index 000000000..f6668ceb1 --- /dev/null +++ b/view/tpl/write_pages.tpl @@ -0,0 +1,3 @@ +<div id="write-pages" class="bigwidget"> +<center><span id="wp-new"><a href="{{$newurl}}">{{$new}}</a></span> <span id="wp-edit"><a href="{{$editurl}}">{{$edit}}</a></span></center> +</div> |