Exemple #1
0
 protected function create_edit_html(WikiPage $page)
 {
     $h_title = html_escape($page->title);
     $i_revision = int_escape($page->revision) + 1;
     global $user;
     if ($user->is_admin()) {
         $val = $page->is_locked() ? " checked" : "";
         $lock = "<br>Lock page: <input type='checkbox' name='lock'{$val}>";
     } else {
         $lock = "";
     }
     return "\n\t\t\t" . make_form(make_link("wiki_admin/save")) . "\n\t\t\t\t<input type='hidden' name='title' value='{$h_title}'>\n\t\t\t\t<input type='hidden' name='revision' value='{$i_revision}'>\n\t\t\t\t<textarea name='body' style='width: 100%' rows='20'>" . html_escape($page->body) . "</textarea>\n\t\t\t\t{$lock}\n\t\t\t\t<br><input type='submit' value='Save'>\n\t\t\t</form>\n\t\t";
 }
Exemple #2
0
 /**
  * See if the given user is allowed to edit the given page.
  *
  * @param User $user
  * @param WikiPage $page
  * @return bool
  */
 public static function can_edit(User $user, WikiPage $page)
 {
     // admins can edit everything
     if ($user->is_admin()) {
         return true;
     }
     // anon / user can't ever edit locked pages
     if ($page->is_locked()) {
         return false;
     }
     // anon / user can edit if allowed by config
     if ($user->can("edit_wiki_page")) {
         return true;
     }
     return false;
 }
Exemple #3
0
 /**
  * See if the given user is allowed to edit the given page
  *
  * @retval boolean
  */
 public static function can_edit(User $user, WikiPage $page)
 {
     global $config;
     // admins can edit everything
     if ($user->is_admin()) {
         return true;
     }
     // anon / user can't ever edit locked pages
     if ($page->is_locked()) {
         return false;
     }
     // anon / user can edit if allowed by config
     if ($config->get_bool("wiki_edit_anon", false) && $user->is_anonymous()) {
         return true;
     }
     if ($config->get_bool("wiki_edit_user", false) && !$user->is_anonymous()) {
         return true;
     }
     return false;
 }