r108925 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108924‎ | r108925 | r108926 >
Date:17:30, 14 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix permission issues
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/api/ApiDeleteEducation.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMentorPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudentPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTermPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php
@@ -108,14 +108,6 @@
109109
110110 /**
111111 * (non-PHPdoc)
112 - * @see EPPager::getMultipleItemActions()
113 - */
114 - protected function getMultipleItemActions() {
115 - return array();
116 - }
117 -
118 - /**
119 - * (non-PHPdoc)
120112 * @see EPPager::hasActionsColumn()
121113 */
122114 protected function hasActionsColumn() {
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -162,5 +162,22 @@
163163
164164 return $links;
165165 }
 166+
 167+ /**
 168+ * (non-PHPdoc)
 169+ * @see EPPager::getMultipleItemActions()
 170+ */
 171+ protected function getMultipleItemActions() {
 172+ $actions = parent::getMultipleItemActions();
166173
 174+ if ( $this->getUser()->isAllowed( 'ep-org' ) ) {
 175+ $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
 176+ 'class' => 'ep-pager-delete-selected',
 177+ 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
 178+ );
 179+ }
 180+
 181+ return $actions;
 182+ }
 183+
167184 }
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php
@@ -198,6 +198,13 @@
199199 protected function getMultipleItemActions() {
200200 $actions = parent::getMultipleItemActions();
201201
 202+ if ( $this->getUser()->isAllowed( 'ep-term' ) ) {
 203+ $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
 204+ 'class' => 'ep-pager-delete-selected',
 205+ 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
 206+ );
 207+ }
 208+
202209 return $actions;
203210 }
204211
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -246,14 +246,6 @@
247247 */
248248 protected function getMultipleItemActions() {
249249 $actions = array();
250 -
251 - if ( false ) { // TODO: $this->getUser()->isAllowed( 'epadmin' )
252 - $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
253 - 'class' => 'ep-pager-delete-selected',
254 - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
255 - );
256 - }
257 -
258250 return $actions;
259251 }
260252
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -212,7 +212,7 @@
213213 * @return boolean
214214 */
215215 public static function displayAddNewControl( IContextSource $context, array $args = array() ) {
216 - if ( !$context->getUser()->isAllowed( 'epmentor' ) ) {
 216+ if ( !$context->getUser()->isAllowed( 'ep-course' ) ) {
217217 return false;
218218 }
219219
@@ -327,5 +327,22 @@
328328 htmlspecialchars( $this->getField( 'name' ) )
329329 );
330330 }
 331+
 332+ /**
 333+ * (non-PHPdoc)
 334+ * @see EPPager::getMultipleItemActions()
 335+ */
 336+ protected function getMultipleItemActions() {
 337+ $actions = parent::getMultipleItemActions();
331338
 339+ if ( $this->getUser()->isAllowed( 'ep-course' ) ) {
 340+ $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
 341+ 'class' => 'ep-pager-delete-selected',
 342+ 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
 343+ );
 344+ }
 345+
 346+ return $actions;
 347+ }
 348+
332349 }
Index: trunk/extensions/EducationProgram/includes/EPMentorPager.php
@@ -84,14 +84,6 @@
8585
8686 /**
8787 * (non-PHPdoc)
88 - * @see EPPager::getMultipleItemActions()
89 - */
90 - protected function getMultipleItemActions() {
91 - return array();
92 - }
93 -
94 - /**
95 - * (non-PHPdoc)
9688 * @see EPPager::hasActionsColumn()
9789 */
9890 protected function hasActionsColumn() {
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -353,13 +353,9 @@
354354 * @author Jeroen De Dauw
355355 */
356356 $messages['qqq'] = array(
357 - 'right-epadmin' => '{{doc-right|epadmin}}',
358 - 'right-epstudent' => '{{doc-right|epstudent}}',
359 - 'right-epmentor' => '{{doc-right|epmentor}}',
 357+ 'right-' => '{{doc-right|}}',
360358
361 - 'action-epadmin' => '{{doc-action|epadmin}}',
362 - 'action-epstudent' => '{{doc-action|epstudent}}',
363 - 'action-epmentor' => '{{doc-action|epmentor}}',
 359+ 'action-' => '{{doc-action|}}',
364360
365361 'specialpages-group-education' => 'Special pages group, h2',
366362 'special-mycourses' => '{{doc-special|mycourses}}',
Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php
@@ -25,8 +25,6 @@
2626 'org' => 'EPOrg',
2727 'course' => 'EPCourse',
2828 'term' => 'EPTerm',
29 - 'student' => 'EPStudent',
30 - 'mentor' => 'EPMentor',
3129 );
3230
3331 /**
@@ -83,34 +81,7 @@
8482 * @return boolean
8583 */
8684 protected function userIsAllowed( $type, array $params ) {
87 - $user = $this->getUser();
88 -
89 - if ( $type === 'student' ) {
90 - return EPStudent::selectField( 'id', array( 'user_id' => $user->getId() ) ) === $params['id'];
91 - }
92 -
93 - if ( $type === 'mentor' ) {
94 - return EPMentor::selectField( 'id', array( 'user_id' => $user->getId() ) ) === $params['id'];
95 - }
96 -
97 - if ( $user->isAllowed( 'epadmin' ) ) {
98 - return true;
99 - }
100 -
101 - if ( $user->isAllowed( 'epmentor' ) ) {
102 - $mentor = new EPMentor( array( 'user_id' => $user->getId() ) );
103 -
104 - if ( $mentor !== false ) {
105 - if ( $type === 'course' ) {
106 - return $mentor->hasCourse( array( 'id' => $params['id'] ) );
107 - }
108 - elseif ( $type === 'term' ) {
109 - return $mentor->hasTerm( array( 'id' => $params['id'] ) );
110 - }
111 - }
112 - }
113 -
114 - return false;
 85+ return $this->getUser()->isAllowed( 'ep-' . $type );
11586 }
11687
11788 /**

Status & tagging log