mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 06:35:15 +00:00
some work on wiki acl
This commit is contained in:
parent
46b6415f5f
commit
4c5722c766
3 changed files with 65 additions and 2 deletions
|
@ -18,11 +18,18 @@ 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']));
|
||||
$w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType');
|
||||
$w['lock'] = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access
|
||||
|
|
|
@ -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')) {
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{{$acl}}
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
@ -50,10 +49,25 @@
|
|||
<td><i class="fa fa-trash-o drop-icons" onclick="wiki_delete_wiki('{{$wiki.title}}', '{{$wiki.resource_id}}'); return false;"></i></td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<form id="edit-wiki-form-{{$wiki.id}}" method="post" action="wiki/{{$channel}}/update/wiki" class="acl-form" data-form_id="edit-wiki-form-{{$wiki.id}}" data-allow_cid='{{$wiki.allow_cid}}' data-allow_gid='{{$wiki.allow_gid}}' data-deny_cid='{{$wiki.deny_cid}}' data-deny_gid='{{$wiki.deny_gid}}'>
|
||||
<div class="btn-group float-right">
|
||||
{{if $lockstate}}
|
||||
<button class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#aclModal" type="button">
|
||||
<i class="jot-perms-icon fa fa-{{$lockstate}}"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
<button class="btn btn-primary btn-sm" type="submit" value="edit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{$acl}}
|
||||
<script>
|
||||
{{if $owner}}
|
||||
function wiki_delete_wiki(wikiHtmlName, resource_id) {
|
||||
|
|
Loading…
Reference in a new issue