https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111885
Revision: 111885
Author: jeroendedauw
Date: 2012-02-19 19:59:18 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
finishing up article table functionality
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.php
trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
trunk/extensions/EducationProgram/actions/EPAddReviewerAction.php
trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
trunk/extensions/EducationProgram/actions/EPRemoveReviewerAction.php
trunk/extensions/EducationProgram/actions/EPRemoveStudentAction.php
trunk/extensions/EducationProgram/includes/EPArticle.php
trunk/extensions/EducationProgram/includes/EPArticleTable.php
trunk/extensions/EducationProgram/resources/ep.articletable.js
Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php 2012-02-19
19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/EducationProgram.php 2012-02-19
19:59:18 UTC (rev 111885)
@@ -240,7 +240,7 @@
$wgGroupPermissions['*']['ep-beonline'] = false;
$wgGroupPermissions['*']['ep-becampus'] = false;
$wgGroupPermissions['*']['ep-beinstructor'] = false;
-$wgGroupPermissions['*']['ep-bereviewer'] = false;
+$wgGroupPermissions['*']['ep-bereviewer'] = true;
$wgGroupPermissions['*']['ep-remreviewer'] = false;
$wgGroupPermissions['epstaff']['ep-org'] = true;
Modified: trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/actions/EPAddArticleAction.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -57,7 +57,7 @@
}
}
- Action::factory( 'view', $this->page, $this->context )->show();
+ $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
return '';
}
Modified: trunk/extensions/EducationProgram/actions/EPAddReviewerAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPAddReviewerAction.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/actions/EPAddReviewerAction.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -33,16 +33,15 @@
$salt = 'addreviewer' . $req->getInt( 'article-id' );
- if ( $user->matchEditToken( $req->getText( 'token' ), $salt )
- && $user->isAllowed( 'ep-bereviewer' ) ) {
+ if ( $user->matchEditToken( $req->getText( 'token' ), $salt ) )
{
$article = EPArticles::singleton()->selectRow(
array( 'id', 'reviewers' ),
array( 'id' => $req->getInt( 'article-id' ) )
);
- if ( $article !== false ) {
- $addedReviewers = $article->addReviewers(
array( $req->getInt( 'user-id' ) ) );
+ if ( $article !== false && $article->canBecomeReviewer(
$user ) ) {
+ $addedReviewers = $article->addReviewers(
array( $user->getId() ) );
if ( !empty( $addedReviewers ) ) {
if ( $article->save() ) {
@@ -52,7 +51,7 @@
}
}
- Action::factory( 'view', $this->page, $this->context )->show();
+ $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
return '';
}
Modified: trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -41,7 +41,7 @@
}
}
- Action::factory( 'view', $this->page, $this->context )->show();
+ $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
return '';
}
Modified: trunk/extensions/EducationProgram/actions/EPRemoveReviewerAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRemoveReviewerAction.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/actions/EPRemoveReviewerAction.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -29,11 +29,12 @@
public function onView() {
$req = $this->getRequest();
$user = $this->getUser();
+ $userIdToRemove = $req->getCheck( 'user-id' ) ? $req->getInt(
'user-id' ) : $user->getId();
- $salt = $req->getInt( 'user-id' ) .'remarticle' . $req->getInt(
'article-id' );
+ $salt = $userIdToRemove .'remreviewer' . $req->getInt(
'article-id' );
if ( $user->matchEditToken( $req->getText( 'token' ), $salt )
- && ( $user->getId() === $req->getInt( 'user-id' ) ||
$user->isAllowed( 'ep-remreviewer' ) ) ) {
+ && ( $user->getId() === $userIdToRemove ||
$user->isAllowed( 'ep-remreviewer' ) ) ) {
$article = EPArticles::singleton()->selectRow(
array( 'id', 'reviewers' ),
@@ -41,7 +42,7 @@
);
if ( $article !== false ) {
- $removedReviewers = $article->removeReviewers(
array( $req->getInt( 'user-id' ) ) );
+ $removedReviewers = $article->removeReviewers(
array( $userIdToRemove ) );
if ( !empty( $removedReviewers ) ) {
if ( $article->save() ) {
@@ -51,7 +52,7 @@
}
}
- Action::factory( 'view', $this->page, $this->context )->show();
+ $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
return '';
}
Modified: trunk/extensions/EducationProgram/actions/EPRemoveStudentAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRemoveStudentAction.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/actions/EPRemoveStudentAction.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -39,7 +39,7 @@
try { $api->execute(); } catch ( Exception $exception ) {}
- Action::factory( 'view', $this->page, $this->context )->show();
+ $this->getOutput()->redirect( $this->getTitle()->getLocalURL()
);
return '';
}
Modified: trunk/extensions/EducationProgram/includes/EPArticle.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticle.php 2012-02-19
19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/includes/EPArticle.php 2012-02-19
19:59:18 UTC (rev 111885)
@@ -90,9 +90,11 @@
public function canBecomeReviewer( User $user ) {
if ( !array_key_exists( $user->getId(), $this->canBecomeReviwer
) ) {
- $this->canBecomeReviwer[$user->getId()] =
$this->getUser()->isAllowed( 'ep-bereviewer' )
+ $this->canBecomeReviwer[$user->getId()] =
+ $user->isLoggedIn()
+ && $user->isAllowed( 'ep-bereviewer' )
&& $this->getUser()->getId() !== $user->getId()
- && !in_array( $this->getUser()->getId(),
$this->getField( 'reviewers' ) );
+ && !in_array( $user->getId(), $this->getField(
'reviewers' ) );
}
return $this->canBecomeReviwer[$user->getId()];
@@ -102,7 +104,7 @@
$addedIds = array_diff( $userIds, $this->getField( 'reviewers'
) );
if ( !empty( $addedIds ) ) {
- $this->setField( 'reviewers', array_merge( $userIds,
$addedIds ) );
+ $this->setField( 'reviewers', array_merge(
$this->getField( 'reviewers' ), $addedIds ) );
}
return $addedIds;
Modified: trunk/extensions/EducationProgram/includes/EPArticleTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-19 19:59:18 UTC (rev 111885)
@@ -119,7 +119,7 @@
$rowCount++;
}
- $html .= $this->getUserCell( $student->getField( 'user_id' ),
$rowCount );
+ $html .= $this->getUserCell( $student->getField( 'user_id' ),
max( 1, $rowCount ) );
$this->addNonStudentHTML( $html, $articles,
$showArticleAdittion );
@@ -185,7 +185,10 @@
}
$html .= $this->getArticleAdittionControl(
$this->articleConds['course_id'] );
- }
+ }
+ elseif ( $isFirst ) {
+ $html .= '<td></td><td></td>';
+ }
}
/**
@@ -350,7 +353,7 @@
'class' => 'ep-rem-reviewer-self',
'disabled' => 'disabled',
'data-article-id' => $article->getId(),
- 'data-article-name' =>
$article->getField( 'name' ),
+ 'data-article-name' =>
$article->getTitle()->getFullText(),
'data-student-name' =>
$article->getUser()->getName(),
'data-token' =>
$this->getUser()->getEditToken( $userId . 'remreviewer' . $article->getId() ),
),
Modified: trunk/extensions/EducationProgram/resources/ep.articletable.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.articletable.js
2012-02-19 19:56:56 UTC (rev 111884)
+++ trunk/extensions/EducationProgram/resources/ep.articletable.js
2012-02-19 19:59:18 UTC (rev 111885)
@@ -214,11 +214,13 @@
'value': $this.attr( 'data-article-id' )
} ) );
- $form.append( $( '<input>' ).attr( {
- 'type': 'hidden',
- 'name': 'user-id',
- 'value': isSelf ? mw.user.id : $this.attr(
'data-reviewer-id' )
- } ) );
+ if ( !isSelf ) {
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'user-id',
+ 'value': $this.attr( 'data-reviewer-id' )
+ } ) );
+ }
var $dialog = $( '<div>' ).html( '' ).dialog( {
'title': ep.msg('ep-articletable-remreviwer-title' +
selfSuffix, reviewerName ),
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs