Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -173,5 +173,58 @@ |
174 | 174 | return ''; |
175 | 175 | } |
176 | 176 | } |
| 177 | + |
| 178 | + /** |
| 179 | + * Returns ambassador addiction controls for the course if the |
| 180 | + * current user has the right permissions. |
| 181 | + * |
| 182 | + * @since 0.1 |
| 183 | + * |
| 184 | + * @param EPCourse $course |
| 185 | + * @param string $type |
| 186 | + * |
| 187 | + * @return string |
| 188 | + */ |
| 189 | + protected function getAmbassadorControls( EPCourse $course, $type ) { |
| 190 | + $user = $this->getUser(); |
| 191 | + $links = array(); |
| 192 | + |
| 193 | + if ( ( $user->isAllowed( 'ep-' . $type ) || $user->isAllowed( 'ep-be' . $type ) ) |
| 194 | + && !in_array( $user->getId(), $course->getField( 'instructors' ) ) |
| 195 | + ) { |
| 196 | + $links[] = Html::element( |
| 197 | + 'a', |
| 198 | + array( |
| 199 | + 'href' => '#', |
| 200 | + 'class' => 'ep-add-instructor', |
| 201 | + 'data-courseid' => $course->getId(), |
| 202 | + 'data-coursename' => $course->getField( 'name' ), |
| 203 | + 'data-mode' => 'self', |
| 204 | + ), |
| 205 | + wfMsg( 'ep-course-become-instructor' ) |
| 206 | + ); |
| 207 | + } |
| 208 | + |
| 209 | + if ( $user->isAllowed( 'ep-instructor' ) ) { |
| 210 | + $links[] = Html::element( |
| 211 | + 'a', |
| 212 | + array( |
| 213 | + 'href' => '#', |
| 214 | + 'class' => 'ep-add-instructor', |
| 215 | + 'data-courseid' => $course->getId(), |
| 216 | + 'data-coursename' => $course->getField( 'name' ), |
| 217 | + ), |
| 218 | + wfMsg( 'ep-course-add-instructor' ) |
| 219 | + ); |
| 220 | + } |
| 221 | + |
| 222 | + if ( count( $links ) > 0 ) { |
| 223 | + $this->getOutput()->addModules( 'ep.instructor' ); |
| 224 | + return '<br />' . $this->getLanguage()->pipeList( $links ); |
| 225 | + } |
| 226 | + else { |
| 227 | + return ''; |
| 228 | + } |
| 229 | + } |
177 | 230 | |
178 | 231 | } |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -187,17 +187,19 @@ |
188 | 188 | */ |
189 | 189 | protected function getNewData() { |
190 | 190 | $data = parent::getNewData(); |
191 | | - |
192 | | - $data['org_id'] = $this->getRequest()->getVal( 'neworg' ); |
193 | | - $data['name'] = wfMsgExt( |
194 | | - 'ep-course-edit-name-format', |
195 | | - 'parsemag', |
196 | | - $data['name'], |
197 | | - $this->getRequest()->getVal( 'newterm' ) |
198 | | - ); |
199 | | - $data['term'] = $this->getRequest()->getVal( 'newterm' ); |
200 | | - $data['mc'] = $data['name']; |
201 | | - |
| 191 | + |
| 192 | + if ( $this->isNew() ) { |
| 193 | + $data['org_id'] = $this->getRequest()->getVal( 'neworg' ); |
| 194 | + $data['name'] = wfMsgExt( |
| 195 | + 'ep-course-edit-name-format', |
| 196 | + 'parsemag', |
| 197 | + $data['name'], |
| 198 | + $this->getRequest()->getVal( 'newterm' ) |
| 199 | + ); |
| 200 | + $data['term'] = $this->getRequest()->getVal( 'newterm' ); |
| 201 | + $data['mc'] = $data['name']; |
| 202 | + } |
| 203 | + |
202 | 204 | return $data; |
203 | 205 | } |
204 | 206 | |
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -159,16 +159,18 @@ |
160 | 160 | */ |
161 | 161 | protected function getNewData() { |
162 | 162 | $data = array(); |
163 | | - |
164 | | - if ( $this->isNewPost() ) { |
165 | | - $data['name'] = $this->getRequest()->getVal( 'newname' ); |
| 163 | + |
| 164 | + if ( $this->isNew() ) { |
| 165 | + if ( $this->isNewPost() ) { |
| 166 | + $data['name'] = $this->getRequest()->getVal( 'newname' ); |
| 167 | + } |
| 168 | + else { |
| 169 | + $data['name'] = $this->getTitle()->getText(); |
| 170 | + } |
| 171 | + |
| 172 | + $data['name'] = $this->getLanguage()->ucfirst( $data['name'] ); |
166 | 173 | } |
167 | | - else { |
168 | | - $data['name'] = $this->getTitle()->getText(); |
169 | | - } |
170 | 174 | |
171 | | - $data['name'] = $this->getLanguage()->ucfirst( $data['name'] ); |
172 | | - |
173 | 175 | return $data; |
174 | 176 | } |
175 | 177 | |