wiki: do not show revert buttons if we do not have write perms and minor cleanup
This commit is contained in:
		| @@ -222,11 +222,7 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 					$html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content)))))); | 					$html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content)))))); | ||||||
| 					$renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName); | 					$renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName); | ||||||
| 				} | 				} | ||||||
| 				$hide_editor = false; |  | ||||||
| 				$showPageControls = $wiki_editor; | 				$showPageControls = $wiki_editor; | ||||||
| 				$showNewWikiButton = $wiki_owner; |  | ||||||
| 				$showNewPageButton = $wiki_editor; |  | ||||||
| 				$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); |  | ||||||
| 				break; | 				break; | ||||||
| 			default:	// Strip the extraneous URL components | 			default:	// Strip the extraneous URL components | ||||||
| 				goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); | 				goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); | ||||||
| @@ -238,7 +234,7 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 		$wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array( | 		$wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array( | ||||||
| 			'$id' => $wikiModalID, | 			'$id' => $wikiModalID, | ||||||
| 			'$title' => t('Revision Comparison'), | 			'$title' => t('Revision Comparison'), | ||||||
| 			'$ok' => t('Revert'), | 			'$ok' => (($showPageControls) ? t('Revert') : ''), | ||||||
| 			'$cancel' => t('Cancel') | 			'$cancel' => t('Cancel') | ||||||
| 		)); | 		)); | ||||||
| 				 | 				 | ||||||
| @@ -246,13 +242,10 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			'$wikiheaderName' => $wikiheaderName, | 			'$wikiheaderName' => $wikiheaderName, | ||||||
| 			'$wikiheaderPage' => $wikiheaderPage, | 			'$wikiheaderPage' => $wikiheaderPage, | ||||||
| 			'$renamePage' => $renamePage, | 			'$renamePage' => $renamePage, | ||||||
| 			'$hideEditor' => $hide_editor, // True will completely hide the content section and is used for the case of no wiki selected |  | ||||||
| 			'$chooseWikiMessage' => t('Choose an available wiki from the list on the left.'), | 			'$chooseWikiMessage' => t('Choose an available wiki from the list on the left.'), | ||||||
| 			'$showPageControls' => $showPageControls, | 			'$showPageControls' => $showPageControls, | ||||||
| 			'$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')), | 			'$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')), | ||||||
| 			'$tools_label' => 'Page Tools', | 			'$tools_label' => 'Page Tools', | ||||||
| 			'$showNewWikiButton'=> $showNewWikiButton, |  | ||||||
| 			'$showNewPageButton'=> $showNewPageButton, |  | ||||||
| 			'$channel' => $owner['channel_address'], | 			'$channel' => $owner['channel_address'], | ||||||
| 			'$resource_id' => $resource_id, | 			'$resource_id' => $resource_id, | ||||||
| 			'$page' => $pageUrlName, | 			'$page' => $pageUrlName, | ||||||
| @@ -268,7 +261,6 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			'$renderedContent' => $renderedContent, | 			'$renderedContent' => $renderedContent, | ||||||
| 			'$pageRename' => array('pageRename', t('New page name'), '', ''), | 			'$pageRename' => array('pageRename', t('New page name'), '', ''), | ||||||
| 			'$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="Short description of your changes (optional)"'), | 			'$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="Short description of your changes (optional)"'), | ||||||
| 			'$pageHistory' => $pageHistory['history'], |  | ||||||
| 			'$wikiModal' => $wikiModal, | 			'$wikiModal' => $wikiModal, | ||||||
| 			'$wikiModalID' => $wikiModalID, | 			'$wikiModalID' => $wikiModalID, | ||||||
| 			'$commit' => 'HEAD', | 			'$commit' => 'HEAD', | ||||||
| @@ -495,8 +487,9 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$historyHTML = widget_wiki_page_history(array( | 			$historyHTML = widget_wiki_page_history(array( | ||||||
| 					'resource_id' => $resource_id, | 				'resource_id' => $resource_id, | ||||||
| 					'pageUrlName' => $pageUrlName | 				'pageUrlName' => $pageUrlName, | ||||||
|  | 				'permsWrite' => $perms['write'] | ||||||
| 			)); | 			)); | ||||||
| 			json_return_and_die(array('historyHTML' => $historyHTML, 'message' => '', 'success' => true)); | 			json_return_and_die(array('historyHTML' => $historyHTML, 'message' => '', 'success' => true)); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -958,7 +958,8 @@ function widget_wiki_page_history($arr) { | |||||||
| 	$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); | 	$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); | ||||||
|  |  | ||||||
| 	return replace_macros(get_markup_template('wiki_page_history.tpl'), array( | 	return replace_macros(get_markup_template('wiki_page_history.tpl'), array( | ||||||
| 			'$pageHistory' => $pageHistory['history'] | 			'$pageHistory' => $pageHistory['history'], | ||||||
|  | 			'$permsWrite' => $arr['permsWrite'] | ||||||
| 	)); | 	)); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,8 +8,10 @@ | |||||||
|       <div class="modal-body" id="generic-modal-body-{{$id}}"></div> |       <div class="modal-body" id="generic-modal-body-{{$id}}"></div> | ||||||
|       <div class="modal-footer"> |       <div class="modal-footer"> | ||||||
|         <button id="generic-modal-cancel-{{$id}}" type="button" class="btn btn-default" data-dismiss="modal">{{$cancel}}</button> |         <button id="generic-modal-cancel-{{$id}}" type="button" class="btn btn-default" data-dismiss="modal">{{$cancel}}</button> | ||||||
|  | 	{{if $ok}} | ||||||
|         <button id="generic-modal-ok-{{$id}}" type="button" class="btn btn-primary">{{$ok}}</button> |         <button id="generic-modal-ok-{{$id}}" type="button" class="btn btn-primary">{{$ok}}</button> | ||||||
|  | 	{{/if}} | ||||||
|       </div> |       </div> | ||||||
|     </div><!-- /.modal-content --> |     </div><!-- /.modal-content --> | ||||||
|   </div><!-- /.modal-dialog --> |   </div><!-- /.modal-dialog --> | ||||||
| </div><!-- /.modal --> | </div><!-- /.modal --> | ||||||
|   | |||||||
| @@ -41,7 +41,7 @@ | |||||||
| 			</div> | 			</div> | ||||||
| 		</form> | 		</form> | ||||||
| 	</div> | 	</div> | ||||||
| 	<div id="wiki-content-container" class="section-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}> | 	<div id="wiki-content-container" class="section-content-wrapper"> | ||||||
| 		<ul class="nav nav-tabs" id="wiki-nav-tabs"> | 		<ul class="nav nav-tabs" id="wiki-nav-tabs"> | ||||||
| 			<li id="edit-pane-tab"><a data-toggle="tab" href="#edit-pane">{{$editOrSourceLabel}}</a></li> | 			<li id="edit-pane-tab"><a data-toggle="tab" href="#edit-pane">{{$editOrSourceLabel}}</a></li> | ||||||
| 			<li class="active"><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">View</a></li> | 			<li class="active"><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">View</a></li> | ||||||
| @@ -225,11 +225,6 @@ | |||||||
| 			if (data.success) { | 			if (data.success) { | ||||||
| 				$('#wiki_page_list_container').html(data.pages); | 				$('#wiki_page_list_container').html(data.pages); | ||||||
| 				$('#wiki_page_list_container').show(); | 				$('#wiki_page_list_container').show(); | ||||||
| 				{{if $showNewPageButton}} |  | ||||||
| 					$('#new-page-button').show(); |  | ||||||
| 				{{else}} |  | ||||||
| 					$('#new-page-button').hide(); |  | ||||||
| 				{{/if}} |  | ||||||
| 			} else { | 			} else { | ||||||
| 				alert('Error fetching page list!'); | 				alert('Error fetching page list!'); | ||||||
| 				window.console.log('Error fetching page list!'); | 				window.console.log('Error fetching page list!'); | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| <style> | <style> | ||||||
|   .diff { |   .diff { | ||||||
|     width:100%; |     width:100%; | ||||||
|  |     word-break: break-all; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   .diff td{ |   .diff td{ | ||||||
| @@ -44,8 +45,10 @@ | |||||||
|       <table id="rev-{{$commit.hash}}" onclick="$('#details-{{$commit.hash}}').show()" width="100%"> |       <table id="rev-{{$commit.hash}}" onclick="$('#details-{{$commit.hash}}').show()" width="100%"> | ||||||
|         <tr><td width="10%">Date</td><td width="70%">{{$commit.date}}</td> |         <tr><td width="10%">Date</td><td width="70%">{{$commit.date}}</td> | ||||||
|             <td rowspan="3" width="20%" align="right"> |             <td rowspan="3" width="20%" align="right"> | ||||||
|  | 		{{if $permsWrite}} | ||||||
|               <button id="revert-{{$commit.hash}}" class="btn btn-danger btn-xs" onclick="wiki_revert_page('{{$commit.hash}}')">Revert</button> |               <button id="revert-{{$commit.hash}}" class="btn btn-danger btn-xs" onclick="wiki_revert_page('{{$commit.hash}}')">Revert</button> | ||||||
|               <br><br> |               <br><br> | ||||||
|  | 		{{/if}} | ||||||
|               <button id="compare-{{$commit.hash}}" class="btn btn-warning btn-xs" onclick="wiki_compare_page('{{$commit.hash}}')">Compare</button> |               <button id="compare-{{$commit.hash}}" class="btn btn-warning btn-xs" onclick="wiki_compare_page('{{$commit.hash}}')">Compare</button> | ||||||
|             </td></tr> |             </td></tr> | ||||||
|         <tr><td>Name</td><td>{{$commit.name}} <{{$commit.email}}></td></tr> |         <tr><td>Name</td><td>{{$commit.name}} <{{$commit.email}}></td></tr> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user