Skip to content

Commit b580191

Browse files
committed
Add a warning to the top of the edit page if one is a super admin but not an author
1 parent 288f92a commit b580191

File tree

1 file changed

+16
-0
lines changed
  • system/application/views/melons/cantaloupe

1 file changed

+16
-0
lines changed

system/application/views/melons/cantaloupe/edit.php

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
article > *:not(span) {display:none !important;}
4646
.ci-template-html {font-family:Georgia,Times,serif !important; padding-left:7.2rem; padding-right:7.2rem;}
4747
.body_copy {max-width:100% !important;}
48+
.error {margin-bottom:-20px; margin-top:0px;}
4849
label {padding-right:8px;}
4950
label, .sortable li, .ui-sortable-handle {cursor:pointer;}
5051
.ui-sortable-helper {background-color:#dddddd; font-family:"Lato",Arial,sans-serif; font-size:16px;}
@@ -842,6 +843,21 @@ function badges() {
842843
</div>
843844
</div>
844845
</div>
846+
<?php
847+
// A super admin is editing a page for a book they're not an author of
848+
if ($login->is_super) {
849+
$super_is_author = false;
850+
foreach ($book->contributors as $contrib) {
851+
if ($contrib->user_id == $login->user_id && ($contrib->relationship == 'author' || $contrib->relationship == 'editor')) {
852+
$super_is_author= true;
853+
break;
854+
}
855+
}
856+
if (!$super_is_author) {
857+
echo '<div class="error notice-super-not-author"><p>You are a super admin, however, you are not connected to this book as an Author. This means that you can view the edit page but you can not save the page. <a href="'.confirm_slash(base_url()).'system/dashboard?book_id='.$book->book_id.'&zone=users#tabs-users">Add yourself as an author in the Dashboard</a></p></div>'."\n";
858+
}
859+
}
860+
?>
845861
<form id="edit_form" class="caption_font" method="post" action="<?=base_url().$book->slug.'/'?>" onsubmit="<?= (isset($book->editorial_is_on) && $book->editorial_is_on === '1')?'confirm_editorial_state_then_save':'validate_edit_form' ?>($(this));return false;" autocomplete="off">
846862
<input type="hidden" name="action" value="<?=(isset($page->version_index))?'update':'add'?>" />
847863
<input type="hidden" name="native" value="1" />

0 commit comments

Comments
 (0)