List of wikis populates with links according to observer permissions.
This commit is contained in:
parent
049147a9d7
commit
a36bef7979
@ -48,7 +48,22 @@ class Wiki extends \Zotlabs\Web\Controller {
|
|||||||
'acl' => populate_acl($channel_acl),
|
'acl' => populate_acl($channel_acl),
|
||||||
'bang' => ''
|
'bang' => ''
|
||||||
);
|
);
|
||||||
|
// $wikiheader = t('Wiki Sandbox');
|
||||||
|
// $hide_editor = false;
|
||||||
|
if(argc()<3) {
|
||||||
|
$wikiheader = t('Wiki Sandbox');
|
||||||
|
$hide_editor = false;
|
||||||
|
} elseif (argc()<4) {
|
||||||
|
$wikiheader = 'Empty wiki: ' . rawurldecode(argv(2)); // show wiki name
|
||||||
|
$hide_editor = true;
|
||||||
|
} elseif (argc()<5) {
|
||||||
|
$wikiheader = rawurldecode(argv(2)) . ': ' . rawurldecode(argv(3)); // show wiki name and page
|
||||||
|
$hide_editor = false;
|
||||||
|
}
|
||||||
|
|
||||||
$o .= replace_macros(get_markup_template('wiki.tpl'),array(
|
$o .= replace_macros(get_markup_template('wiki.tpl'),array(
|
||||||
|
'$wikiheader' => $wikiheader,
|
||||||
|
'$hideEditor' => $hide_editor,
|
||||||
'$channel' => $channel['channel_address'],
|
'$channel' => $channel['channel_address'],
|
||||||
'$lockstate' => $x['lockstate'],
|
'$lockstate' => $x['lockstate'],
|
||||||
'$acl' => $x['acl'],
|
'$acl' => $x['acl'],
|
||||||
|
@ -860,13 +860,19 @@ function widget_chatroom_members() {
|
|||||||
function widget_wiki_list($arr) {
|
function widget_wiki_list($arr) {
|
||||||
|
|
||||||
require_once("include/wiki.php");
|
require_once("include/wiki.php");
|
||||||
$r = wiki_list(App::$profile['channel_hash']);
|
if(argc()>1) {
|
||||||
|
$nick = argv(1);
|
||||||
|
} else {
|
||||||
|
$channel = \App::get_channel();
|
||||||
|
$nick = $channel['channel_address'];
|
||||||
|
}
|
||||||
|
$wikis = wiki_list($nick, get_observer_hash());
|
||||||
|
|
||||||
if($r) {
|
if($wikis) {
|
||||||
return replace_macros(get_markup_template('wikilist.tpl'), array(
|
return replace_macros(get_markup_template('wikilist.tpl'), array(
|
||||||
'$header' => t('Wiki List'),
|
'$header' => t('Wiki List'),
|
||||||
'$read' => $r['read'],
|
'$channel' => $nick,
|
||||||
'$write' => $r['write']
|
'$wikis' => $wikis['wikis']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,17 @@ function wiki_delete() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wiki_list($observer_hash) {
|
function wiki_list($nick, $observer_hash) {
|
||||||
|
if (local_channel() || remote_channel()) {
|
||||||
|
$sql_extra = item_permissions_sql(get_channel_by_nick($nick)['channel_id'], $observer_hash);
|
||||||
|
} else {
|
||||||
|
$sql_extra = " AND item_private = 0 ";
|
||||||
|
}
|
||||||
|
$wikis = q("SELECT * FROM item WHERE resource_type = '%s' AND mid = parent_mid AND item_deleted = 0 $sql_extra",
|
||||||
|
dbesc(WIKI_ITEM_RESOURCE_TYPE)
|
||||||
|
);
|
||||||
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access
|
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access
|
||||||
return array('write' => array('wiki1'), 'read' => array('wiki1', 'wiki2'));
|
return array('wikis' => $wikis);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wiki_pages() {
|
function wiki_pages() {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);
|
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);
|
||||||
adjustInlineTopBarHeight();"><i class="fa fa-compress"></i></button>
|
adjustInlineTopBarHeight();"><i class="fa fa-compress"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<h2>Wiki</h2>
|
<h2>{{$wikiheader}}</h2>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="new-wiki-form-wrapper" class="section-content-tools-wrapper" style="display:none;">
|
<div id="new-wiki-form-wrapper" class="section-content-tools-wrapper" style="display:none;">
|
||||||
@ -46,7 +46,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wiki-content-container" class="section-content-wrapper">
|
<div id="wiki-content-container" class="section-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}>
|
||||||
<ul class="nav nav-tabs" id="wiki-nav-tabs">
|
<ul class="nav nav-tabs" id="wiki-nav-tabs">
|
||||||
<li class="active"><a data-toggle="tab" href="#edit-pane">Edit</a></li>
|
<li class="active"><a data-toggle="tab" href="#edit-pane">Edit</a></li>
|
||||||
<li><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">Preview</a></li>
|
<li><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">Preview</a></li>
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
<div id="wiki_list" class="widget">
|
<div id="wiki_list" class="widget">
|
||||||
<h3>{{$header}}</h3>
|
<h3>{{$header}}</h3>
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
{{foreach $read as $r}}
|
{{foreach $wikis as $wiki}}
|
||||||
<li><a href="">{{$r}}</a></li>
|
<li><a href="/wiki/{{$channel}}/{{$wiki.title}}">{{$wiki.title}}</a></li>
|
||||||
{{/foreach}}
|
|
||||||
{{foreach $write as $r}}
|
|
||||||
<li><a href="">{{$r}}</a></li>
|
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user