Allow creation of webpages at channels other than your own.
This commit is contained in:
parent
d8d45dab76
commit
b161d4073d
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function webpages_init(&$a) {
|
function webpages_content(&$a) {
|
||||||
|
|
||||||
if(argc() > 1)
|
if(argc() > 1)
|
||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
@ -20,14 +20,24 @@ function webpages_init(&$a) {
|
|||||||
|
|
||||||
profile_load($a,$which,$profile);
|
profile_load($a,$which,$profile);
|
||||||
|
|
||||||
|
|
||||||
|
$r = q("select channel_id from channel where channel_address = '%s'",
|
||||||
|
dbesc($which)
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
$owner = intval($r[0]['channel_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function webpages_content(&$a) {
|
|
||||||
|
|
||||||
// We can do better, but since editing only works for local users and all posts are webpages, return anyone else for now.
|
// 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
|
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
|
||||||
require_once ('include/conversation.php');
|
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'),
|
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
||||||
'bang' => (($group || $cid) ? '!' : ''),
|
'bang' => (($group || $cid) ? '!' : ''),
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user()
|
'profile_uid' => intval($owner),
|
||||||
);
|
);
|
||||||
|
|
||||||
$o .= status_editor($a,$x);
|
$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?
|
// 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'",
|
$r = q("select * from item_id where uid = %d and service = 'WEBPAGE'",
|
||||||
intval(local_user())
|
intval($owner)
|
||||||
);
|
);
|
||||||
|
|
||||||
$pages = null;
|
$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
|
//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).
|
// 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(
|
return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
|
||||||
'$baseurl' => $url,
|
'$baseurl' => $url,
|
||||||
'$edit' => t('Edit'),
|
'$edit' => t('Edit'),
|
||||||
'$pages' => $pages,
|
'$pages' => $pages,
|
||||||
'$channel' => $a->profile['channel_address'],
|
'$channel' => $which,
|
||||||
'$view' => t('View'),
|
'$view' => t('View'),
|
||||||
|
|
||||||
));
|
));
|
||||||
|
Reference in New Issue
Block a user