Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -213,6 +213,8 @@ |
214 | 214 | $wgAvailableRights[] = 'ep-beonline'; // Add or remove yourself as online ambassador from terms |
215 | 215 | $wgAvailableRights[] = 'ep-becampus'; // Add or remove yourself as campus ambassador from terms |
216 | 216 | $wgAvailableRights[] = 'ep-beinstructor'; // Add or remove yourself as instructor from courses |
| 217 | +$wgAvailableRights[] = 'ep-bereviewer'; // Add or remove yourself as reviewer from articles |
| 218 | +$wgAvailableRights[] = 'ep-remreviewer'; // Remove reviewers from articles |
217 | 219 | |
218 | 220 | // User group rights |
219 | 221 | $wgGroupPermissions['*']['ep-enroll'] = true; |
— | — | @@ -226,6 +228,8 @@ |
227 | 229 | $wgGroupPermissions['*']['ep-beonline'] = false; |
228 | 230 | $wgGroupPermissions['*']['ep-becampus'] = false; |
229 | 231 | $wgGroupPermissions['*']['ep-beinstructor'] = false; |
| 232 | +$wgGroupPermissions['*']['ep-bereviewer'] = false; |
| 233 | +$wgGroupPermissions['*']['ep-remreviewer'] = false; |
230 | 234 | |
231 | 235 | $wgGroupPermissions['epstaff']['ep-org'] = true; |
232 | 236 | $wgGroupPermissions['epstaff']['ep-course'] = true; |
— | — | @@ -238,6 +242,8 @@ |
239 | 243 | $wgGroupPermissions['epstaff']['ep-beonline'] = true; |
240 | 244 | $wgGroupPermissions['epstaff']['ep-becampus'] = true; |
241 | 245 | $wgGroupPermissions['epstaff']['ep-beinstructor'] = true; |
| 246 | +$wgGroupPermissions['epstaff']['ep-bereviewer'] = true; |
| 247 | +$wgGroupPermissions['epstaff']['ep-remreviewer'] = true; |
242 | 248 | |
243 | 249 | $wgGroupPermissions['epadmin']['ep-org'] = true; |
244 | 250 | $wgGroupPermissions['epadmin']['ep-course'] = true; |
— | — | @@ -250,6 +256,8 @@ |
251 | 257 | $wgGroupPermissions['epadmin']['ep-beonline'] = true; |
252 | 258 | $wgGroupPermissions['epadmin']['ep-becampus'] = true; |
253 | 259 | $wgGroupPermissions['epadmin']['ep-beinstructor'] = true; |
| 260 | +$wgGroupPermissions['epadmin']['ep-bereviewer'] = true; |
| 261 | +$wgGroupPermissions['epadmin']['ep-remreviewer'] = true; |
254 | 262 | |
255 | 263 | $wgGroupPermissions['eponlineamb']['ep-org'] = true; |
256 | 264 | $wgGroupPermissions['eponlineamb']['ep-course'] = true; |
Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -49,7 +49,11 @@ |
50 | 50 | if ( count( $studentIds ) > 0 ) { |
51 | 51 | $out->addElement( 'h2', array(), wfMsg( 'ep-course-articles' ) ); |
52 | 52 | |
53 | | - $pager = new EPArticleTable( $this->getContext(), array( 'id' => $studentIds ) ); |
| 53 | + $pager = new EPArticleTable( |
| 54 | + $this->getContext(), |
| 55 | + array( 'id' => $studentIds ), |
| 56 | + array( 'course_id' => $course->getId() ) |
| 57 | + ); |
54 | 58 | |
55 | 59 | if ( $pager->getNumRows() ) { |
56 | 60 | $out->addHTML( |
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -135,17 +135,42 @@ |
136 | 136 | * @return string |
137 | 137 | */ |
138 | 138 | protected function getUserCell( $userId, $rowSpan ) { |
139 | | - // TODO: add student removal control for instructors |
140 | 139 | $user = User::newFromId( $userId ); |
141 | 140 | $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
142 | 141 | |
| 142 | + $html = Linker::userLink( $userId, $name ); |
| 143 | + |
| 144 | + if ( $this->getUser()->isAllowed( 'ep-remstudent' ) |
| 145 | + && array_key_exists( 'course_id', $this->articleConds ) |
| 146 | + && is_integer( $this->articleConds['course_id'] ) ) { |
| 147 | + |
| 148 | + $html .= EPUtils::getToolLinks( |
| 149 | + $userId, |
| 150 | + $name, |
| 151 | + $this->getContext(), |
| 152 | + array( Html::element( |
| 153 | + 'a', |
| 154 | + array( |
| 155 | + 'href' => '#', |
| 156 | + 'data-user-id' => $userId, |
| 157 | + 'data-course-id' => $this->articleConds['course_id'], |
| 158 | + 'class' => 'ep-rem-student', |
| 159 | + ), |
| 160 | + wfMsg( 'ep-artciles-remstudent' ) |
| 161 | + ) ) |
| 162 | + ); |
| 163 | + } |
| 164 | + else { |
| 165 | + $html .= Linker::userToolLinks( $userId, $name ); |
| 166 | + } |
| 167 | + |
143 | 168 | return html::rawElement( |
144 | 169 | 'td', |
145 | 170 | array_merge( |
146 | 171 | $this->getCellAttrs( 'user_id', $userId ), |
147 | 172 | array( 'rowspan' => $rowSpan ) |
148 | 173 | ), |
149 | | - Linker::userLink( $userId, $name ) . Linker::userToolLinks( $userId, $name ) |
| 174 | + $html |
150 | 175 | ); |
151 | 176 | } |
152 | 177 | |
— | — | @@ -160,18 +185,30 @@ |
161 | 186 | * @return string |
162 | 187 | */ |
163 | 188 | protected function getArticleCell( EPArticle $article, $rowSpan ) { |
164 | | - // TODO: add article removal control for student |
| 189 | + $html = Linker::link( |
| 190 | + $article->getTitle(), |
| 191 | + htmlspecialchars( $article->getTitle()->getFullText() ) |
| 192 | + ); |
165 | 193 | |
| 194 | + if ( $this->getUser()->getId() === $article->getField( 'user_id' ) ) { |
| 195 | + $html .= ' (' . Html::element( |
| 196 | + 'a', |
| 197 | + array( |
| 198 | + 'href' => '#', |
| 199 | + 'data-article-id' => $article->getId(), |
| 200 | + 'class' => 'ep-rem-article', |
| 201 | + ), |
| 202 | + wfMsg( 'ep-artciles-remarticle' ) |
| 203 | + ) . ')'; |
| 204 | + } |
| 205 | + |
166 | 206 | return Html::rawElement( |
167 | 207 | 'td', |
168 | 208 | array_merge( |
169 | 209 | $this->getCellAttrs( 'articles', $article ), |
170 | 210 | array( 'rowspan' => $rowSpan ) |
171 | 211 | ), |
172 | | - Linker::link( |
173 | | - $article->getTitle(), |
174 | | - htmlspecialchars( $article->getTitle()->getFullText() ) |
175 | | - ) |
| 212 | + $html |
176 | 213 | ); |
177 | 214 | } |
178 | 215 | |
— | — | @@ -186,21 +223,52 @@ |
187 | 224 | * @return string |
188 | 225 | */ |
189 | 226 | protected function getReviewerCell( EPArticle $article, $userId ) { |
190 | | - // TODO: add reviewer removal control reviewer and instructors |
191 | 227 | $user = User::newFromId( $userId ); |
192 | 228 | $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
193 | 229 | |
| 230 | + $html = Linker::userLink( $userId, $name ); |
| 231 | + |
| 232 | + if ( $this->getUser()->isAllowed( 'ep-remreviewer' ) ) { |
| 233 | + $html .= EPUtils::getToolLinks( |
| 234 | + $userId, |
| 235 | + $name, |
| 236 | + $this->getContext(), |
| 237 | + array( Html::element( |
| 238 | + 'a', |
| 239 | + array( |
| 240 | + 'href' => '#', |
| 241 | + 'data-user-id' => $userId, |
| 242 | + 'data-article-id' => $article->getId(), |
| 243 | + 'class' => 'ep-rem-reviewer', |
| 244 | + ), |
| 245 | + wfMsg( 'ep-artciles-remreviewer' ) |
| 246 | + ) ) |
| 247 | + ); |
| 248 | + } |
| 249 | + elseif ( $this->getUser()->getId() === $userId ) { |
| 250 | + $html .= Linker::userToolLinks( $userId, $name ); |
| 251 | + $html .= '<br />'; |
| 252 | + $html .= Html::element( |
| 253 | + 'button', |
| 254 | + array( |
| 255 | + 'class' => 'ep-rem-reviewer-self', |
| 256 | + 'disabled' => 'disabled', |
| 257 | + 'data-article-id' => $article->getId(), |
| 258 | + ), |
| 259 | + wfMsg( 'ep-artciles-remreviewer-self' ) |
| 260 | + ); |
| 261 | + } |
| 262 | + else { |
| 263 | + $html .= Linker::userToolLinks( $userId, $name ); |
| 264 | + } |
| 265 | + |
194 | 266 | return Html::rawElement( |
195 | 267 | 'td', |
196 | 268 | $this->getCellAttrs( 'reviewers', $userId ), |
197 | | - Linker::userLink( $userId, $name ) . Linker::userToolLinks( $userId, $name ) |
| 269 | + $html |
198 | 270 | ); |
199 | 271 | } |
200 | 272 | |
201 | | - protected function addStudentRemovalControl() { |
202 | | - |
203 | | - } |
204 | | - |
205 | 273 | protected function addArticleRemovalControl() { |
206 | 274 | |
207 | 275 | } |
— | — | @@ -267,8 +335,8 @@ |
268 | 336 | $field = EPStudents::singleton()->getPrefixedField( 'user_id' ); |
269 | 337 | $userIds[] = $student->$field; |
270 | 338 | $this->articles[$student->$field] = array( // TODO |
271 | | - EPArticles::singleton()->newFromArray( array( 'page_id' => 1, 'reviewers' => array( 1, 1 ) ) ), |
272 | | - EPArticles::singleton()->newFromArray( array( 'page_id' => 2, 'reviewers' => array( 1, 1 ) ) ), |
| 339 | + EPArticles::singleton()->newFromArray( array( 'page_id' => 1, 'user_id' => 1, 'reviewers' => array( 1, 1 ) ) ), |
| 340 | + EPArticles::singleton()->newFromArray( array( 'page_id' => 2, 'user_id' => 1, 'reviewers' => array( 1, 1 ) ) ), |
273 | 341 | ); |
274 | 342 | } |
275 | 343 | |
Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
— | — | @@ -135,6 +135,16 @@ |
136 | 136 | |
137 | 137 | return ' <span class="mw-usertoollinks">(' . $context->getLanguage()->pipeList( $links ) . ')</span>'; |
138 | 138 | } |
| 139 | + |
| 140 | + public static function getToolLinks( $userId, $userName, IContextSource $context, array $extraLinks = array() ) { |
| 141 | + $links = array(); |
| 142 | + |
| 143 | + $links[] = Linker::userTalkLink( $userId, $userName ); |
| 144 | + |
| 145 | + $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $userName ), wfMsgHtml( 'contribslink' ) ); |
| 146 | + |
| 147 | + return ' <span class="mw-usertoollinks">(' . $context->getLanguage()->pipeList( array_merge( $links, $extraLinks ) ) . ')</span>'; |
| 148 | + } |
139 | 149 | |
140 | 150 | /** |
141 | 151 | * Adds a navigation menu with the provided links. |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -275,6 +275,10 @@ |
276 | 276 | 'epstudentpager-header-student' => 'Student', |
277 | 277 | 'epstudentpager-header-articles' => 'Articles', |
278 | 278 | 'epstudentpager-header-reviewers' => 'Reviewers', |
| 279 | + 'ep-artciles-remstudent' => 'remove from course', |
| 280 | + 'ep-artciles-remreviewer-self' => 'Remove myself as reviewer', |
| 281 | + 'ep-artciles-remreviewer' => 'remove as reviewer', |
| 282 | + 'ep-artciles-remarticle' => 'remove article', |
279 | 283 | |
280 | 284 | // Article pager |
281 | 285 | 'ep-articles-noresults' => 'There are no articles to list.', |