https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111909
Revision: 111909
Author: jeroendedauw
Date: 2012-02-20 03:26:42 +0000 (Mon, 20 Feb 2012)
Log Message:
-----------
various small fixes
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/EPCourse.php
trunk/extensions/EducationProgram/includes/EPPageObject.php
trunk/extensions/EducationProgram/includes/EPRoleObject.php
trunk/extensions/EducationProgram/maintenance/importWEPData.php
trunk/extensions/EducationProgram/specials/SpecialStudent.php
Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php 2012-02-20
02:34:49 UTC (rev 111908)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php 2012-02-20
03:26:42 UTC (rev 111909)
@@ -535,6 +535,9 @@
if ( $name === 'instructors' ) {
$this->instructors = false;
}
+ elseif ( $name === 'mc' ) {
+ $value = str_replace( '_', ' ', $value );
+ }
parent::setField( $name, $value );
}
Modified: trunk/extensions/EducationProgram/includes/EPPageObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-02-20
02:34:49 UTC (rev 111908)
+++ trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-02-20
03:26:42 UTC (rev 111909)
@@ -65,5 +65,17 @@
return $this->table->getLogInfoForTitle(
$this->getTitle() );
}
}
+
+ /**
+ * (non-PHPdoc)
+ * @see DBDataObject::setField()
+ */
+ public function setField( $name, $value ) {
+ if ( $name === $this->table->getIdentifierField() ) {
+ $value = str_replace( '_', ' ', $value );
+ }
+
+ parent::setField( $name, $value );
+ }
}
Modified: trunk/extensions/EducationProgram/includes/EPRoleObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRoleObject.php 2012-02-20
02:34:49 UTC (rev 111908)
+++ trunk/extensions/EducationProgram/includes/EPRoleObject.php 2012-02-20
03:26:42 UTC (rev 111909)
@@ -142,7 +142,7 @@
foreach ( $courses as /* EPCourse */ $course ) {
$courseIds[] = $course->getId();
$course->setUpdateSummaries( false );
- $course->enlistUsers( $this->getField( 'user_id' ),
$this->getRoleName() );
+ $success = $course->enlistUsers( $this->getField(
'user_id' ), $this->getRoleName() ) && $success;
$course->setUpdateSummaries( true );
}
Modified: trunk/extensions/EducationProgram/maintenance/importWEPData.php
===================================================================
--- trunk/extensions/EducationProgram/maintenance/importWEPData.php
2012-02-20 02:34:49 UTC (rev 111908)
+++ trunk/extensions/EducationProgram/maintenance/importWEPData.php
2012-02-20 03:26:42 UTC (rev 111909)
@@ -72,9 +72,9 @@
$courseIds = $this->insertCourses( $courses, $orgs );
echo "Inserted courses\n";
-// echo "Inserting students ...\n";
-// $this->insertStudents( $students, $courseIds );
-// echo "Inserted students\n";
+ echo "Inserting students ...\n";
+ $this->insertStudents( $students, $courseIds );
+ echo "Inserted students\n";
echo "Import completed!\n\n";
}
@@ -131,6 +131,8 @@
try{
$course->save();
$courseIds[$name] = $course->getId();
+ $name = str_replace( '_', ' ', $name );
+ echo "Inserted course '$name'.\n";
}
catch ( Exception $ex ) {
echo "Failed to insert course '$name'.\n";
@@ -193,7 +195,7 @@
}
if ( $student->associateWithCourses(
$courses ) ) {
- echo "Imported student $name\n";
+ echo "Inserted student
'$name'\t\t and associated with courses: " . str_replace( '_', ' ', implode( ',
', $courseNames ) ) . "\n";
}
else {
echo "Failed to insert student
'$name'. (failed to associate courses)\n";
Modified: trunk/extensions/EducationProgram/specials/SpecialStudent.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialStudent.php
2012-02-20 02:34:49 UTC (rev 111908)
+++ trunk/extensions/EducationProgram/specials/SpecialStudent.php
2012-02-20 03:26:42 UTC (rev 111909)
@@ -40,7 +40,7 @@
else {
$this->displayNavigation();
- $student = EPStudent::selectRow( null, array( 'id' =>
$this->subPage ) );
+ $student = EPStudents::singleton()->selectRow( null,
array( 'id' => $this->subPage ) );
if ( $student === false ) {
$out->addWikiMsg( 'ep-student-none',
$this->subPage );
@@ -50,8 +50,6 @@
$this->displaySummary( $student );
- $out->addElement( 'h2', array(), wfMsg(
'ep-student-courses' ) );
-
$courseIds = array_map(
function( EPCourse $course ) {
return $course->getId();
@@ -59,7 +57,13 @@
$student->getCourses( 'id' )
);
- EPCourse::displayPager( $this->getContext(),
array( 'id' => $courseIds ) );
+ if ( count( $courseIds ) > 0 ) {
+ $out->addElement( 'h2', array(), wfMsg(
'ep-student-courses' ) );
+ EPCourse::displayPager(
$this->getContext(), array( 'id' => $courseIds ) );
+ }
+ else {
+ // TODO
+ }
}
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs