diff --git a/README.md b/README.md index 27a5324..1aba3cb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A wiki for phpBB with version history, side-by-side compare, and a moderation qu - Start an article from the overview page's **New article title** box, or by linking to `/wiki/` and following the link. - Link to another article by writing `[[Article name]]`, in articles and in forum posts; links to articles that don't exist yet are shown in red and open the editor. Each article lists the articles that link to it under **What links here**. See [Linking between articles](#linking-between-articles). - Every edit is saved as a new version; compare any two versions. The compare page opens in a **Readable** view: the newer version as readers see it, with added text in green and underlined, removed text in red and struck through, and the changed words marked inside a line, list item or table row that changed. **Source** shows the BBCode diff. A `Template:` page is compared as written. -- **Protect article**, under **Moderator controls** in the version history, names the phpBB groups whose members may edit an article. It narrows the board-wide edit permission for that one article and never widens it: everyone else can no longer edit it, restore an older version, upload files to it or move it, and a note under the article names the groups. Edits by those members still wait for approval as before. Tick no group to lift it. It needs the **Can protect an article** permission, which moderators get when the extension is updated, and whose holders may always edit. Protection moves with the article and is removed with it. +- **Protect article** (the padlock button on an article, or **Moderator controls** in the version history) names the phpBB groups whose members may edit an article. It narrows the board-wide edit permission for that one article and never widens it: everyone else can no longer edit it, restore an older version, upload files to it or move it, and a note under the article names the groups. Edits by those members still wait for approval as before. Tick no group to lift it. It needs the **Can protect an article** permission, which moderators get when the extension is updated, and whose holders may always edit. Protection moves with the article and is removed with it. In the overview, Recent changes, search results and category pages, a lock beside the title marks a protected article; hovering it names the groups. - **Two people editing at once.** The ACP setting **When two people edit an article** (under **Extensions > Wiki > Settings**) chooses what happens. **Notice** (the default) names on the edit form whoever else has the article open, and since when. **Lock** lets only the first to open the edit form edit the article: the others see who holds it and until when, a moderator (with "Can set an article version active") can break the lock, and the moderators are notified once when a lock keeps someone out. If the lock changes hands while someone's form is open, their save is refused and their text kept. **Nothing** keeps the old behaviour. An editor is held for **Minutes an editor holds an article** (30 by default, 5 to 240) after their last sign of work; the open edit form extends it every few minutes, and so does Preview. - **Restore** in the version history brings back an older version by saving its text, title, description, sources and redirect as a new version, so no version is lost. Members who may edit can restore; the restored version goes live straight away for members who may set versions active, and otherwise waits for approval like any edit. - **Move article**, under **Moderator controls** in the version history, gives an article a new name (its address) and, if wanted, a new title. Every version, its uploaded files and its watchers move with it, and a redirect is left at the old name unless that box is cleared; an article can be moved back over its own redirect. Links in other articles are not rewritten, so the redirect keeps them working, and articles that use a moved template keep showing it through the redirect. Moving a template that articles use shows how many and asks for a second confirmation. It needs the **Can move an article to a new name** permission, which moderators get when the extension is updated. diff --git a/config/services.yml b/config/services.yml index be10d4b..5f263b6 100644 --- a/config/services.yml +++ b/config/services.yml @@ -29,6 +29,7 @@ services: - '%core.root_path%' - '%core.php_ext%' - '%tables.wiki.article%' + - '@phpbbmodders.wiki.protection' phpbbmodders.wiki.recent_changes: class: phpbbmodders\wiki\controller\recent_changes @@ -44,6 +45,7 @@ services: - '%tables.wiki.article%' - '%core.root_path%' - '%core.php_ext%' + - '@phpbbmodders.wiki.protection' phpbbmodders.wiki.categories: class: phpbbmodders\wiki\wiki\categories @@ -66,6 +68,7 @@ services: - '@phpbbmodders.wiki.categories' - '@phpbbmodders.wiki.main' - '%tables.wiki.article%' + - '@phpbbmodders.wiki.protection' phpbbmodders.wiki.template_list: class: phpbbmodders\wiki\controller\template_list @@ -445,6 +448,7 @@ services: - '%tables.wiki.search_text%' - '%core.root_path%' - '%core.php_ext%' + - '@phpbbmodders.wiki.protection' phpbbmodders.wiki.search: class: phpbbmodders\wiki\controller\search diff --git a/controller/category.php b/controller/category.php index 5a2d9ee..29cf769 100644 --- a/controller/category.php +++ b/controller/category.php @@ -23,6 +23,9 @@ class category /** How many of a category's articles the list of categories shows under it */ const PREVIEW_MEMBERS = 5; + /** @var \phpbbmodders\wiki\wiki\protection */ + protected $protection; + /** @var \phpbb\auth\auth */ protected $auth; @@ -69,8 +72,9 @@ class category * @param \phpbbmodders\wiki\controller\main $main * @param string $article_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, categories $categories, \phpbbmodders\wiki\controller\main $main, $article_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, categories $categories, \phpbbmodders\wiki\controller\main $main, $article_table, \phpbbmodders\wiki\wiki\protection $protection) { + $this->protection = $protection; $this->auth = $auth; $this->config = $config; $this->db = $db; @@ -101,6 +105,7 @@ protected function assign_members($name) { $this->template->assign_block_vars('category_members', array( 'TITLE' => $row['article_title'], + 'PROTECTED' => $this->protection->list_label($row['article_url']), 'DESCRIPTION' => $row['article_description'], 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $row['article_url'])), )); @@ -217,6 +222,7 @@ public function index() { $this->template->assign_block_vars('categories.members', array( 'TITLE' => $member['article_title'], + 'PROTECTED' => $this->protection->list_label($member['article_url']), 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $member['article_url'])), )); } diff --git a/controller/overview.php b/controller/overview.php index fe36b63..17eb2a8 100644 --- a/controller/overview.php +++ b/controller/overview.php @@ -12,6 +12,9 @@ class overview { + /** @var \phpbbmodders\wiki\wiki\protection */ + protected $protection; + /** @var \phpbb\auth\auth */ protected $auth; @@ -64,8 +67,9 @@ class overview * @param string $php_ext * @param string $article_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $helper, \phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbbmodders\wiki\wiki\edit $edit, \phpbbmodders\wiki\wiki\compare $compare, \phpbbmodders\wiki\wiki\view $view, $phpbb_root_path, $php_ext, $article_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $helper, \phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbbmodders\wiki\wiki\edit $edit, \phpbbmodders\wiki\wiki\compare $compare, \phpbbmodders\wiki\wiki\view $view, $phpbb_root_path, $php_ext, $article_table, \phpbbmodders\wiki\wiki\protection $protection) { + $this->protection = $protection; $this->auth = $auth; $this->helper = $helper; $this->db = $db; @@ -106,6 +110,7 @@ public function base() { $this->template->assign_block_vars('all_wiki_article', array( 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $all_wiki_article['article_url'])), + 'PROTECTED' => $this->protection->list_label($all_wiki_article['article_url']), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], @@ -128,6 +133,7 @@ public function base() { $this->template->assign_block_vars('latest_wiki_article', array( 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $all_wiki_article['article_url'])), + 'PROTECTED' => $this->protection->list_label($all_wiki_article['article_url']), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], @@ -150,6 +156,7 @@ public function base() { $this->template->assign_block_vars('hot_wiki_article', array( 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $all_wiki_article['article_url'])), + 'PROTECTED' => $this->protection->list_label($all_wiki_article['article_url']), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], @@ -173,6 +180,7 @@ public function base() { $this->template->assign_block_vars('sticky_wiki_article', array( 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $all_wiki_article['article_url'])), + 'PROTECTED' => $this->protection->list_label($all_wiki_article['article_url']), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], @@ -220,6 +228,7 @@ public function base() $this->template->assign_block_vars('pending_wiki_article', array( 'U_ARTICLE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $pending_wiki_article['article_url'])), + 'PROTECTED' => $this->protection->list_label($pending_wiki_article['article_url']), 'ARTICLE_NAME' => $pending_wiki_article['article_title'], 'ARTICLE_LASTEDIT' => $this->user->format_date($pending_wiki_article['article_last_edit']), 'S_STALE' => $is_stale, diff --git a/controller/recent_changes.php b/controller/recent_changes.php index a0fa5dd..0d5683e 100644 --- a/controller/recent_changes.php +++ b/controller/recent_changes.php @@ -22,6 +22,9 @@ */ class recent_changes { + /** @var \phpbbmodders\wiki\wiki\protection */ + protected $protection; + /** @var \phpbb\auth\auth */ protected $auth; @@ -68,8 +71,9 @@ class recent_changes * @param string $phpbb_root_path * @param string $php_ext */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, $article_table, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, $article_table, $phpbb_root_path, $php_ext, \phpbbmodders\wiki\wiki\protection $protection) { + $this->protection = $protection; $this->auth = $auth; $this->config = $config; $this->db = $db; @@ -165,6 +169,7 @@ public function page() $this->template->assign_block_vars('changes', array( 'ARTICLE_TITLE' => $row['article_title'], + 'PROTECTED' => $this->protection->list_label($row['article_url']), 'EDIT_REASON' => $row['article_edit_reason'], 'EDIT_TIME' => $this->user->format_date($row['article_last_edit']), 'USER' => \phpbbmodders\wiki\wiki\author::link($this->helper, $row['user_id'], $row['username'], $row['user_colour']), diff --git a/docs/images/wiki-protected-article.png b/docs/images/wiki-protected-article.png index 1e9e559..4c19ecf 100644 Binary files a/docs/images/wiki-protected-article.png and b/docs/images/wiki-protected-article.png differ diff --git a/docs/images/wiki-protected-list.png b/docs/images/wiki-protected-list.png new file mode 100644 index 0000000..b9f377d Binary files /dev/null and b/docs/images/wiki-protected-list.png differ diff --git a/language/en/common.php b/language/en/common.php index 79b9f21..1650757 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -65,12 +65,12 @@ 'WIKI_EDIT_LOCK_BROKEN' => 'The lock was broken. The article can be edited again.', 'WIKI_EDIT_LOCK_EDIT_NOW' => 'Edit the article', 'WIKI_PROTECT_ARTICLE' => 'Protect article', + 'WIKI_PROTECT_CHANGE' => 'Protected: change who may edit', 'WIKI_PROTECT_EXPLAIN' => 'Choose the groups whose members may edit this article. Only they, and members who may protect articles, can then edit it, restore an older version, upload files to it or move it. Members still need the permission to edit articles, and their edits still wait for approval as before. Tick no group to let everyone who may edit articles edit this one again.', 'WIKI_PROTECT_GROUPS' => 'Groups that may edit', 'WIKI_PROTECT_GROUPS_EXPLAIN' => 'Members of any ticked group may edit.', 'WIKI_PROTECT_SAVED' => 'The article is protected. Only members of these groups may edit it: %s.', 'WIKI_PROTECT_LIFTED' => 'The article is no longer protected. Everyone who may edit articles may edit it.', - 'WIKI_PROTECTED_NOTE' => 'Only members of %s can edit this article.', 'WIKI_PROTECTED_NO_EDIT' => 'This article is protected. Only members of %s can edit it.', 'VERSIONS_OF_ARTICLE' => 'Version history', 'VERSION_COMPARE_HEADLINE' => 'Changes from version %1$d to %2$d', diff --git a/language/en/link.php b/language/en/link.php index 3b6506b..4b5aeb8 100644 --- a/language/en/link.php +++ b/language/en/link.php @@ -46,6 +46,8 @@ 'WIKI_NOTIFICATION_STARTER_TEMPLATES_OPTION' => 'The wiki’s starter templates repository has new or changed templates', 'WIKI_EDIT_LOCK_BLOCKED' => '%1$s could not edit the wiki article %2$s, because %3$s holds it.', 'WIKI_EDIT_LOCK_BLOCKED_OPTION' => 'An edit lock keeps someone out of a wiki article', + // Under a protected article, and beside it in lists on any page (the board search too) + 'WIKI_PROTECTED_NOTE' => 'Only members of %s can edit this article.', 'WIKI_TOC' => 'Contents', 'WIKI_LINK_BUTTON' => 'Wiki link: [[Article name]] or [[Article name|link text]]', 'WIKI_LINK_NEW_ARTICLE' => 'This article doesn’t exist yet. Follow the link to create it.', diff --git a/styles/prosilver/template/article_body.html b/styles/prosilver/template/article_body.html index 4e09c76..af3f0a5 100644 --- a/styles/prosilver/template/article_body.html +++ b/styles/prosilver/template/article_body.html @@ -9,7 +9,7 @@

{ARTICLE_TITLE} - {L_VER {L_ARTICLE_HAS_NEW} {L_SET_ACTIVE}

- +