Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php |
— | — | @@ -40,8 +40,13 @@ |
41 | 41 | else { |
42 | 42 | $this->displayNavigation(); |
43 | 43 | |
44 | | - $student = EPStudents::singleton()->selectRow( null, array( 'id' => $this->subPage ) ); |
| 44 | + $student = false; |
| 45 | + $user = User::newFromName( $subPage ); |
45 | 46 | |
| 47 | + if ( $user !== false && $user->getId() !== 0 ) { |
| 48 | + $student = EPStudents::singleton()->selectRow( null, array( 'user_id' => $user->getId() ) ); |
| 49 | + } |
| 50 | + |
46 | 51 | if ( $student === false ) { |
47 | 52 | $out->addWikiMsg( 'ep-student-none', $this->subPage ); |
48 | 53 | } |
Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
— | — | @@ -108,13 +108,11 @@ |
109 | 109 | public static function getRoleToolLinks( EPIRole $role, IContextSource $context, EPCourse $course = null ) { |
110 | 110 | $roleName = $role->getRoleName(); |
111 | 111 | $links = array(); |
112 | | - |
113 | | - $links[] = Linker::userTalkLink( $role->getUser()->getId(), $role->getUser()->getName() ); |
114 | | - |
115 | | - $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $role->getUser()->getName() ), wfMsgHtml( 'contribslink' ) ); |
116 | | - |
| 112 | + |
| 113 | + $user = $role->getUser(); |
| 114 | + |
117 | 115 | if ( !is_null( $course ) && |
118 | | - ( $context->getUser()->isAllowed( 'ep-' . $roleName ) || $role->getUser()->getId() == $context->getUser()->getId() ) ) { |
| 116 | + ( $context->getUser()->isAllowed( 'ep-' . $roleName ) || $user->getId() == $context->getUser()->getId() ) ) { |
119 | 117 | $links[] = Html::element( |
120 | 118 | 'a', |
121 | 119 | array( |
— | — | @@ -123,8 +121,8 @@ |
124 | 122 | 'data-role' => $roleName, |
125 | 123 | 'data-courseid' => $course->getId(), |
126 | 124 | 'data-coursename' => $course->getField( 'name' ), |
127 | | - 'data-userid' => $role->getUser()->getId(), |
128 | | - 'data-username' => $role->getUser()->getName(), |
| 125 | + 'data-userid' => $user->getId(), |
| 126 | + 'data-username' => $user->getName(), |
129 | 127 | 'data-bestname' => $role->getName(), |
130 | 128 | ), |
131 | 129 | wfMsg( 'ep-' . $roleName . '-remove' ) |
— | — | @@ -133,9 +131,21 @@ |
134 | 132 | $context->getOutput()->addModules( 'ep.enlist' ); |
135 | 133 | } |
136 | 134 | |
137 | | - return ' <span class="mw-usertoollinks">(' . $context->getLanguage()->pipeList( $links ) . ')</span>'; |
| 135 | + return self::getToolLinks( $user->getId(), $user->getName(), $context, $links ); |
138 | 136 | } |
139 | 137 | |
| 138 | + /** |
| 139 | + * Returns tool links for the provided user details plus any adittional links. |
| 140 | + * |
| 141 | + * @since 0.1 |
| 142 | + * |
| 143 | + * @param integer $userId |
| 144 | + * @param string $userName |
| 145 | + * @param IContextSource $context |
| 146 | + * @param array $extraLinks |
| 147 | + * |
| 148 | + * @return string |
| 149 | + */ |
140 | 150 | public static function getToolLinks( $userId, $userName, IContextSource $context, array $extraLinks = array() ) { |
141 | 151 | $links = array(); |
142 | 152 | |
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
— | — | @@ -81,16 +81,11 @@ |
82 | 82 | */ |
83 | 83 | protected function getFormattedValue( $name, $value ) { |
84 | 84 | switch ( $name ) { |
85 | | - case 'id': |
86 | | - $value = Linker::linkKnown( |
87 | | - SpecialPage::getTitleFor( 'Student', $value ), |
88 | | - htmlspecialchars( $this->getLanguage()->formatNum( $value, true ) ) |
89 | | - ); |
90 | | - break; |
91 | 85 | case 'user_id': |
92 | 86 | if ( array_key_exists( $value, $this->userNames ) ) { |
93 | 87 | list( $userName, $realName ) = $this->userNames[$value]; |
94 | | - $value = Linker::userLink( $value, $userName, $realName ) . Linker::userToolLinks( $value, $userName ); |
| 88 | + $value = Linker::userLink( $value, $userName, $realName ) |
| 89 | + . EPStudent::getViewLinksFor( $this->getContext(), $value, $userName ); |
95 | 90 | } |
96 | 91 | else { |
97 | 92 | wfWarn( 'User id not in $this->userNames in ' . __METHOD__ ); |
— | — | @@ -147,6 +142,8 @@ |
148 | 143 | public function getFieldNames() { |
149 | 144 | $fields = parent::getFieldNames(); |
150 | 145 | |
| 146 | + unset( $fields['id'] ); |
| 147 | + |
151 | 148 | $fields['_courses_current'] = 'current-courses'; |
152 | 149 | |
153 | 150 | return $fields; |
Index: trunk/extensions/EducationProgram/includes/EPStudentActivityPager.php |
— | — | @@ -99,7 +99,8 @@ |
100 | 100 | case 'user_id': |
101 | 101 | if ( array_key_exists( $value, $this->userNames ) ) { |
102 | 102 | list( $userName, $realName ) = $this->userNames[$value]; |
103 | | - $value = Linker::userLink( $value, $userName, $realName ) . Linker::userToolLinks( $value, $userName ); |
| 103 | + $value = Linker::userLink( $value, $userName, $realName ) |
| 104 | + . EPStudent::getViewLinksFor( $this->getContext(), $value, $userName ); |
104 | 105 | } |
105 | 106 | else { |
106 | 107 | wfWarn( 'User id not in $this->userNames in ' . __METHOD__ ); |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -92,4 +92,46 @@ |
93 | 93 | $this->getUser()->saveSettings(); |
94 | 94 | } |
95 | 95 | |
| 96 | + /** |
| 97 | + * Returns the view link for the student. |
| 98 | + * These are the user page, contribs and student profile. |
| 99 | + * |
| 100 | + * @since 0.1 |
| 101 | + * |
| 102 | + * @param IContextSource $context |
| 103 | + * |
| 104 | + * @return string |
| 105 | + */ |
| 106 | + public function getViewLinks( IContextSource $context ) { |
| 107 | + return self::getViewLinksFor( |
| 108 | + $context, |
| 109 | + $this->getUser()->getId(), |
| 110 | + $this->getUser()->getName() |
| 111 | + ); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Returns the view links for the student with provided user id and name. |
| 116 | + * These are the user page, contribs and student profile. |
| 117 | + * |
| 118 | + * @since 0.1 |
| 119 | + * |
| 120 | + * @param IContextSource $context |
| 121 | + * @param integer $userId |
| 122 | + * @param string $userName |
| 123 | + * |
| 124 | + * @return string |
| 125 | + */ |
| 126 | + public static function getViewLinksFor( IContextSource $context, $userId, $userName ) { |
| 127 | + return EPUtils::getToolLinks( |
| 128 | + $userId, |
| 129 | + $userName, |
| 130 | + $context, |
| 131 | + array( Linker::link( |
| 132 | + SpecialPage::getTitleFor( 'Student', $userName ), |
| 133 | + $context->msg( 'ep-student-view-profile' )->escaped() |
| 134 | + ) ) |
| 135 | + ); |
| 136 | + } |
| 137 | + |
96 | 138 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | 'ep-form-summary' => 'Summary:', |
30 | 30 | 'ep-form-minor' => 'This is a minor edit', |
31 | 31 | 'ep-move-error' => 'You are not allowed to move articles in or out of the education namespaces.', |
| 32 | + 'ep-student-view-profile' => 'student profile', |
32 | 33 | |
33 | 34 | // Tabs |
34 | 35 | 'ep-tab-view' => 'Read', |
— | — | @@ -582,7 +583,7 @@ |
583 | 584 | 'ep-ambassador-title' => 'Ambassador: $1', |
584 | 585 | |
585 | 586 | // Special:Student |
586 | | - 'ep-student-none' => 'There is no student with id "$1". See [[Special:Students|here]] for a list of students.', |
| 587 | + 'ep-student-none' => 'There is no student with user name "$1". See [[Special:Students|here]] for a list of all students.', |
587 | 588 | 'ep-student-title' => 'Student: $1', |
588 | 589 | 'ep-student-actively-enrolled' => 'Currently enrolled', |
589 | 590 | 'ep-student-no-active-enroll' => 'Not currently enrolled', |