https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113382

Revision: 113382
Author:   jeroendedauw
Date:     2012-03-08 19:22:13 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
http://education.wmflabs.org/index.php/Thread:MW_1.18_talk:Community_portal/My_Courses

Modified Paths:
--------------
    trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
    trunk/extensions/EducationProgram/specials/SpecialMyCourses.php

Modified: trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php 
2012-03-08 19:01:49 UTC (rev 113381)
+++ trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php 
2012-03-08 19:22:13 UTC (rev 113382)
@@ -36,6 +36,7 @@
                                        'id',
                                        'course_id',
                                        'page_id',
+                                       'page_title',
                                ),
                                array(
                                        'id' => $req->getInt( 'article-id' ),

Modified: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialMyCourses.php     
2012-03-08 19:01:49 UTC (rev 113381)
+++ trunk/extensions/EducationProgram/specials/SpecialMyCourses.php     
2012-03-08 19:22:13 UTC (rev 113382)
@@ -104,17 +104,11 @@
 
                $this->displayRoleAssociation( 'EPStudent' );
                
-               if ( $this->getUser()->isAllowed( 'ep-instructor' ) ) {
-                       $this->displayRoleAssociation( 'EPInstructor' );
-               }
-               
-               if ( $this->getUser()->isAllowed( 'ep-online' ) ) {
-                       $this->displayRoleAssociation( 'EPOA' );
-               }
-               
-               if ( $this->getUser()->isAllowed( 'ep-campus' ) ) {
-                       $this->displayRoleAssociation( 'EPCA' );
-               }
+               $this->displayRoleAssociation( 'EPInstructor' );
+
+               $this->displayRoleAssociation( 'EPOA' );
+
+               $this->displayRoleAssociation( 'EPCA' );
        }
 
        /**
@@ -142,9 +136,25 @@
         * @param $class The name of the EPIRole implementing class
         */
        protected function displayRoleAssociation( $class ) {
-               $userRole = $class::newFromUser( $this->getUser() );
+               $user = $this->getUser();
+               $userRole = $class::newFromUser( $user );
                $courses = $userRole->getCourses( array( 'id', 'name', 'org_id' 
) );
 
+               switch ( $class ) {
+                       case 'EPStudent':
+                               $isAllowed = true;
+                               break;
+                       case 'EPInstructor':
+                               $isAllowed = $user->isAllowed( 
'ep-beinstructor' ) || $user->isAllowed( 'ep-instructor' );
+                               break;
+                       case 'EPOA':
+                               $isAllowed = $user->isAllowed( 'ep-beonline' ) 
|| $user->isAllowed( 'ep-online' );
+                               break;
+                       case 'EPCA':
+                               $isAllowed = $user->isAllowed( 'ep-becampus' ) 
|| $user->isAllowed( 'ep-campus' );
+                               break;
+               }
+
                if ( count( $courses ) > 0 ) {
                        $message = wfMsgExt( 'ep-mycourses-courses-' . 
strtolower( $class ), 'parsemag', count( $courses ), 
$this->getUser()->getName() );
                        $this->getOutput()->addElement( 'h2', array(), $message 
);
@@ -159,7 +169,7 @@
                                $this->displayCoursePager( $courses, $class );
                        }
                }
-               else {
+               elseif ( $isAllowed ) {
                        $this->getOutput()->addWikiMsg( 
'ep-mycourses-nocourses-' . strtolower( $class ) );
                }
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to