diff options
author | git-marijus <mario@mariovavti.com> | 2017-09-15 16:27:30 +0200 |
---|---|---|
committer | git-marijus <mario@mariovavti.com> | 2017-09-15 16:27:30 +0200 |
commit | 4c5722c766643af368f600abb93a44fc72d27c11 (patch) | |
tree | c2fd1c049b180d8c00ad96a085e1627411261954 /Zotlabs/Module/Wiki.php | |
parent | 46b6415f5fddcea5aa7c4c55842405b68a7ccd6a (diff) | |
download | volse-hubzilla-4c5722c766643af368f600abb93a44fc72d27c11.tar.gz volse-hubzilla-4c5722c766643af368f600abb93a44fc72d27c11.tar.bz2 volse-hubzilla-4c5722c766643af368f600abb93a44fc72d27c11.zip |
some work on wiki acl
Diffstat (limited to 'Zotlabs/Module/Wiki.php')
-rw-r--r-- | Zotlabs/Module/Wiki.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 1eb600f51..2b1322122 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -428,6 +428,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')) { |