r110477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110476‎ | r110477 | r110478 >
Date:13:58, 1 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix course edit issue
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EPEditAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EditCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewCourseAction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
@@ -173,5 +173,58 @@
174174 return '';
175175 }
176176 }
 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+ }
177230
178231 }
\ No newline at end of file
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php
@@ -187,17 +187,19 @@
188188 */
189189 protected function getNewData() {
190190 $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+
202204 return $data;
203205 }
204206
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -159,16 +159,18 @@
160160 */
161161 protected function getNewData() {
162162 $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'] );
166173 }
167 - else {
168 - $data['name'] = $this->getTitle()->getText();
169 - }
170174
171 - $data['name'] = $this->getLanguage()->ucfirst( $data['name'] );
172 -
173175 return $data;
174176 }
175177

Status & tagging log