Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -95,9 +95,6 @@ |
96 | 96 | |
97 | 97 | $wgCollectionPortletForLoggedInUsersOnly = false; |
98 | 98 | |
99 | | -$wgCollectionSaveAsUserPageRight = null; |
100 | | -$wgCollectionSaveAsCommunityPageRight = 'autoconfirmed'; |
101 | | - |
102 | 99 | $wgCollectionNavPopups = false; |
103 | 100 | |
104 | 101 | # ============================================================================== |
Index: trunk/extensions/Collection/README.txt |
— | — | @@ -217,8 +217,21 @@ |
218 | 218 | |
219 | 219 | $wgEnableWriteAPI = true; |
220 | 220 | |
221 | | - (This is the default for MediaWiki >= 1.14.) |
| 221 | + (This is the default for MediaWiki >= 1.14.). |
222 | 222 | |
| 223 | + There are two MediaWiki rights that are checked, before users are allowed |
| 224 | + to save collections: To be able to save collection pages under the User |
| 225 | + namespace, users must have the right 'collectionsaveasuserpage'; to be able |
| 226 | + to save collection pages under the community namespace |
| 227 | + (see $wgCommunityCollectionNamespace), users must have the right |
| 228 | + 'collectionsaveascommunitypage'. For example, if all logged-in users shall |
| 229 | + be allowed to save collection pages under the User namespace, but only |
| 230 | + autoconfirmed users, shall be allowed to save collection pages under the |
| 231 | + community namespace, add this to your LocalSettings.php:: |
| 232 | + |
| 233 | + $wgGroupPermissions['user']['collectionsaveasuserpage'] = true; |
| 234 | + $wgGroupPermissions['autoconfirmed']['collectionsaveascommunitypage'] = true; |
| 235 | + |
223 | 236 | * As the current collection of articles is stored in the session, the session |
224 | 237 | timeout should be set to some sensible value (at least a few hours, maybe |
225 | 238 | one day). Adjust session.cookie_lifetime and session.gc_maxlifetime in your |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -148,39 +148,42 @@ |
149 | 149 | $partner = $wgRequest->getVal( 'partner', 'pediapress' ); |
150 | 150 | return $this->postZIP( $collection, $partner ); |
151 | 151 | case 'save_collection/': |
152 | | - $collTitle = $wgRequest->getVal( 'colltitle' ); |
153 | | - if ( $wgRequest->getVal( 'overwrite' ) && !empty( $collTitle ) ) {; |
154 | | - $title = Title::newFromText( $collTitle ); |
155 | | - $this->saveCollection( $title, $overwrite=true ); |
156 | | - $wgOut->redirect( $title->getFullURL() ); |
| 152 | + if ( $wgRequest->getVal( 'abort' ) ) { |
| 153 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
157 | 154 | return; |
158 | 155 | } |
159 | | - $collType = $wgRequest->getVal( 'colltype' ); |
160 | | - $overwrite = $wgRequest->getBool( 'overwrite' ); |
161 | | - $saveCalled = false; |
162 | | - if ( $collType == 'personal' ) { |
| 156 | + $colltype = $wgRequest->getVal( 'colltype' ); |
| 157 | + if ( $colltype == 'personal' ) { |
| 158 | + $collname = $wgRequest->getVal( 'pcollname' ); |
| 159 | + if ( !$wgUser->isAllowed( 'collectionsaveasuserpage' ) || empty( $collname ) ) { |
| 160 | + return; |
| 161 | + } |
163 | 162 | $userPageTitle = $wgUser->getUserPage()->getPrefixedText(); |
164 | | - $name = $wgRequest->getVal( 'pcollname', '' ); |
165 | | - if ( !empty( $name ) ) { |
166 | | - $title = Title::newFromText( $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
167 | | - $saveCalled = true; |
168 | | - $saved = $this->saveCollection( $title, $overwrite ); |
| 163 | + $title = Title::newFromText( |
| 164 | + $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $collname |
| 165 | + ); |
| 166 | + } else if ( $colltype == 'community' ) { |
| 167 | + $collname = $wgRequest->getVal( 'ccollname' ); |
| 168 | + if ( !$wgUser->isAllowed( 'collectionsaveascommunitypage' ) || empty( $collname ) ) { |
| 169 | + return; |
169 | 170 | } |
170 | | - } else if ( $collType == 'community' ) { |
171 | | - $name = $wgRequest->getVal( 'ccollname', '' ); |
172 | | - if ( !empty( $name ) ) { |
173 | | - $title = Title::makeTitle( $wgCommunityCollectionNamespace, wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
174 | | - $saveCalled = true; |
175 | | - $saved = $this->saveCollection( $title, $overwrite ); |
176 | | - } |
| 171 | + $title = Title::makeTitle( |
| 172 | + $wgCommunityCollectionNamespace, |
| 173 | + wfMsgForContent( 'coll-collections' ) . '/' . $collname |
| 174 | + ); |
177 | 175 | } |
178 | | - |
179 | | - if ( !$saveCalled) { |
180 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
181 | | - } else if ( $saved ) { |
| 176 | + if ( !isset( $title ) ) { |
| 177 | + return; |
| 178 | + } |
| 179 | + if ( $this->saveCollection( $title, $wgRequest->getBool( 'overwrite' ) ) ) { |
182 | 180 | $wgOut->redirect( $title->getFullURL() ); |
183 | 181 | } else { |
184 | | - $this->renderSaveOverwritePage( $title ); |
| 182 | + $this->renderSaveOverwritePage( |
| 183 | + $colltype, |
| 184 | + $title, |
| 185 | + $wgRequest->getVal( 'pcollname' ), |
| 186 | + $wgRequest->getVal( 'ccollname' ) |
| 187 | + ); |
185 | 188 | } |
186 | 189 | return; |
187 | 190 | case 'render/': |
— | — | @@ -892,7 +895,7 @@ |
893 | 896 | $wgOut->redirect( $response['redirect_url'] ); |
894 | 897 | } |
895 | 898 | |
896 | | - private function renderSaveOverwritePage( $title ) { |
| 899 | + private function renderSaveOverwritePage( $colltype, $title, $pcollname, $ccollname ) { |
897 | 900 | global $wgOut; |
898 | 901 | |
899 | 902 | $this->setHeaders(); |
— | — | @@ -900,6 +903,9 @@ |
901 | 904 | |
902 | 905 | $template = new CollectionSaveOverwriteTemplate(); |
903 | 906 | $template->set( 'title', $title ); |
| 907 | + $template->set( 'pcollname', $pcollname ); |
| 908 | + $template->set( 'ccollname', $ccollname ); |
| 909 | + $template->set( 'colltype', $colltype ); |
904 | 910 | $wgOut->addTemplate( $template ); |
905 | 911 | } |
906 | 912 | |
Index: trunk/extensions/Collection/Collection.templates.php |
— | — | @@ -132,10 +132,10 @@ |
133 | 133 | <?php |
134 | 134 | if ($GLOBALS['wgUser']->isLoggedIn()) { |
135 | 135 | $showLoginInfo = false; |
136 | | - $canSaveUserPage = (empty($GLOBALS['wgCollectionSaveAsUserPageRight']) || $GLOBALS['wgUser']->isAllowed($GLOBALS['wgCollectionSaveAsUserPageRight'])); |
137 | | - $canSaveCommunityPage = (empty($GLOBALS['wgCollectionSaveAsCommunityPageRight']) || $GLOBALS['wgUser']->isAllowed($GLOBALS['wgCollectionSaveAsCommunityPageRight'])); |
| 136 | + $canSaveUserPage = $GLOBALS['wgUser']->isAllowed('collectionsaveasuserpage'); |
| 137 | + $canSaveCommunityPage = $GLOBALS['wgUser']->isAllowed('collectionsaveascommunitypage'); |
138 | 138 | } else { |
139 | | - $showLoginInfo = (empty($GLOBALS['wgCollectionSaveAsCommunityPageRight']) || empty($GLOBALS['wgCollectionSaveAsUserPageRight'])); |
| 139 | + $showLoginInfo = true; |
140 | 140 | } |
141 | 141 | if ($GLOBALS['wgEnableWriteAPI'] && ($showLoginInfo || $canSaveUserPage || $canSaveCommunityPage)) { |
142 | 142 | ?> |
— | — | @@ -326,7 +326,9 @@ |
327 | 327 | <form action="<?php echo htmlspecialchars(SkinTemplate::makeSpecialUrlSubpage('Book', 'save_collection/')) ?>" method="post"> |
328 | 328 | <input name="overwrite" type="submit" value="<?php $this->msg('coll-yes') ?>" /> |
329 | 329 | <input name="abort" type="submit" value="<?php $this->msg('coll-no') ?>" /> |
330 | | - <input name="colltitle" type="hidden" value="<?php echo htmlspecialchars($this->data['title']->getPrefixedText()) ?>" /> |
| 330 | + <input name="pcollname" type="hidden" value="<?php echo htmlspecialchars($this->data['pcollname']) ?>" /> |
| 331 | + <input name="ccollname" type="hidden" value="<?php echo htmlspecialchars($this->data['ccollname']) ?>" /> |
| 332 | + <input name="colltype" type="hidden" value="<?php echo htmlspecialchars($this->data['colltype']) ?>" /> |
331 | 333 | </form> |
332 | 334 | |
333 | 335 | <?php |