diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/NativeWiki.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Wiki.php | 42 |
2 files changed, 48 insertions, 0 deletions
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 0c1894625..39952ed5f 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -18,6 +18,12 @@ class NativeWiki { if($wikis) { foreach($wikis as &$w) { + + $w['allow_cid'] = acl2json($w['allow_cid']); + $w['allow_gid'] = acl2json($w['allow_gid']); + $w['deny_cid'] = acl2json($w['deny_cid']); + $w['deny_gid'] = acl2json($w['deny_gid']); + $w['rawName'] = get_iconfig($w, 'wiki', 'rawName'); $w['htmlName'] = escape_tags($w['rawName']); $w['urlName'] = urlencode(urlencode($w['rawName'])); diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index adea3f515..013ffef70 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -463,6 +463,48 @@ class Wiki extends \Zotlabs\Web\Controller { } } + // Update a wiki + // /wiki/channel/update/wiki + if ((argc() > 3) && (argv(2) === 'update') && (argv(3) === 'wiki')) { + // Only the channel owner can update a wiki, at least until we create a + // more detail permissions framework + + if (local_channel() !== intval($owner['channel_id'])) { + goaway('/' . argv(0) . '/' . $nick . '/'); + } + + if($wiki['urlName'] === '') { + notice( t('Error updating wiki. Invalid name.') . EOL); + goaway('/wiki'); + return; //not reached + } + + $exists = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $wiki['urlName']); + if($exists['id']) { + + // Get ACL for permissions + $acl = new \Zotlabs\Access\AccessList($owner); + $acl->set_from_array($_POST); + $r = Zlib\NativeWiki::create_wiki($owner, $observer_hash, $wiki, $acl); + if($r['success']) { + Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$r['item_id'],$r['item']['resource_id']); + $homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id'], $wiki['mimeType']); + if(! $homePage['success']) { + notice( t('Wiki created, but error creating Home page.')); + goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName']); + } + Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$homePage['item_id'],$r['item']['resource_id']); + goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName'] . '/' . $homePage['page']['urlName']); + } + else { + notice( t('Error creating wiki')); + goaway(z_root() . '/wiki'); + } + + } + + } + // Delete a wiki if ((argc() > 3) && (argv(2) === 'delete') && (argv(3) === 'wiki')) { |