r111812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111811‎ | r111812 | r111813 >
Date:01:53, 18 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on article table
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -213,6 +213,8 @@
214214 $wgAvailableRights[] = 'ep-beonline'; // Add or remove yourself as online ambassador from terms
215215 $wgAvailableRights[] = 'ep-becampus'; // Add or remove yourself as campus ambassador from terms
216216 $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
217219
218220 // User group rights
219221 $wgGroupPermissions['*']['ep-enroll'] = true;
@@ -226,6 +228,8 @@
227229 $wgGroupPermissions['*']['ep-beonline'] = false;
228230 $wgGroupPermissions['*']['ep-becampus'] = false;
229231 $wgGroupPermissions['*']['ep-beinstructor'] = false;
 232+$wgGroupPermissions['*']['ep-bereviewer'] = false;
 233+$wgGroupPermissions['*']['ep-remreviewer'] = false;
230234
231235 $wgGroupPermissions['epstaff']['ep-org'] = true;
232236 $wgGroupPermissions['epstaff']['ep-course'] = true;
@@ -238,6 +242,8 @@
239243 $wgGroupPermissions['epstaff']['ep-beonline'] = true;
240244 $wgGroupPermissions['epstaff']['ep-becampus'] = true;
241245 $wgGroupPermissions['epstaff']['ep-beinstructor'] = true;
 246+$wgGroupPermissions['epstaff']['ep-bereviewer'] = true;
 247+$wgGroupPermissions['epstaff']['ep-remreviewer'] = true;
242248
243249 $wgGroupPermissions['epadmin']['ep-org'] = true;
244250 $wgGroupPermissions['epadmin']['ep-course'] = true;
@@ -250,6 +256,8 @@
251257 $wgGroupPermissions['epadmin']['ep-beonline'] = true;
252258 $wgGroupPermissions['epadmin']['ep-becampus'] = true;
253259 $wgGroupPermissions['epadmin']['ep-beinstructor'] = true;
 260+$wgGroupPermissions['epadmin']['ep-bereviewer'] = true;
 261+$wgGroupPermissions['epadmin']['ep-remreviewer'] = true;
254262
255263 $wgGroupPermissions['eponlineamb']['ep-org'] = true;
256264 $wgGroupPermissions['eponlineamb']['ep-course'] = true;
Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
@@ -49,7 +49,11 @@
5050 if ( count( $studentIds ) > 0 ) {
5151 $out->addElement( 'h2', array(), wfMsg( 'ep-course-articles' ) );
5252
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+ );
5458
5559 if ( $pager->getNumRows() ) {
5660 $out->addHTML(
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -135,17 +135,42 @@
136136 * @return string
137137 */
138138 protected function getUserCell( $userId, $rowSpan ) {
139 - // TODO: add student removal control for instructors
140139 $user = User::newFromId( $userId );
141140 $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
142141
 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+
143168 return html::rawElement(
144169 'td',
145170 array_merge(
146171 $this->getCellAttrs( 'user_id', $userId ),
147172 array( 'rowspan' => $rowSpan )
148173 ),
149 - Linker::userLink( $userId, $name ) . Linker::userToolLinks( $userId, $name )
 174+ $html
150175 );
151176 }
152177
@@ -160,18 +185,30 @@
161186 * @return string
162187 */
163188 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+ );
165193
 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+
166206 return Html::rawElement(
167207 'td',
168208 array_merge(
169209 $this->getCellAttrs( 'articles', $article ),
170210 array( 'rowspan' => $rowSpan )
171211 ),
172 - Linker::link(
173 - $article->getTitle(),
174 - htmlspecialchars( $article->getTitle()->getFullText() )
175 - )
 212+ $html
176213 );
177214 }
178215
@@ -186,21 +223,52 @@
187224 * @return string
188225 */
189226 protected function getReviewerCell( EPArticle $article, $userId ) {
190 - // TODO: add reviewer removal control reviewer and instructors
191227 $user = User::newFromId( $userId );
192228 $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
193229
 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+
194266 return Html::rawElement(
195267 'td',
196268 $this->getCellAttrs( 'reviewers', $userId ),
197 - Linker::userLink( $userId, $name ) . Linker::userToolLinks( $userId, $name )
 269+ $html
198270 );
199271 }
200272
201 - protected function addStudentRemovalControl() {
202 -
203 - }
204 -
205273 protected function addArticleRemovalControl() {
206274
207275 }
@@ -267,8 +335,8 @@
268336 $field = EPStudents::singleton()->getPrefixedField( 'user_id' );
269337 $userIds[] = $student->$field;
270338 $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 ) ) ),
273341 );
274342 }
275343
Index: trunk/extensions/EducationProgram/includes/EPUtils.php
@@ -135,6 +135,16 @@
136136
137137 return ' <span class="mw-usertoollinks">(' . $context->getLanguage()->pipeList( $links ) . ')</span>';
138138 }
 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+ }
139149
140150 /**
141151 * Adds a navigation menu with the provided links.
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -275,6 +275,10 @@
276276 'epstudentpager-header-student' => 'Student',
277277 'epstudentpager-header-articles' => 'Articles',
278278 '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',
279283
280284 // Article pager
281285 'ep-articles-noresults' => 'There are no articles to list.',

Status & tagging log