https://www.mediawiki.org/wiki/Special:Code/MediaWiki/108354
Revision: 108354
Author: jeroendedauw
Date: 2012-01-08 09:22:16 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
more work on the pagers
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/EPCourse.php
trunk/extensions/EducationProgram/includes/EPCoursePager.php
trunk/extensions/EducationProgram/includes/EPDBObject.php
trunk/extensions/EducationProgram/includes/EPTerm.php
trunk/extensions/EducationProgram/includes/EPTermPager.php
Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php 2012-01-08
08:40:00 UTC (rev 108353)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php 2012-01-08
09:22:16 UTC (rev 108354)
@@ -110,7 +110,7 @@
if ( $this->updateSummaries && $orgId !== false ) {
EPOrg::updateSummaryFields( array( 'terms', 'students',
'courses' ), array( 'id' => $orgId ) );
}
-
+
return $success;
}
@@ -139,8 +139,8 @@
if ( $this->updateSummaries && $success && $oldOrgId !== false
&& $oldOrgId !== $this->getField( 'org_id' ) ) {
$conds = array( 'id' => array( $oldOrgId,
$this->getField( 'org_id' ) ) );
+ EPTerm::updateSummaryFields( 'org_id', array(
'course_id' => $this->getId() ) );
EPOrg::updateSummaryFields( array( 'terms', 'students',
'courses' ), $conds );
- EPTerm::updateSummaryFields( 'org_id', array(
'course_id' => $this->getId() ) );
}
return $success;
Modified: trunk/extensions/EducationProgram/includes/EPCoursePager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCoursePager.php
2012-01-08 08:40:00 UTC (rev 108353)
+++ trunk/extensions/EducationProgram/includes/EPCoursePager.php
2012-01-08 09:22:16 UTC (rev 108354)
@@ -126,7 +126,7 @@
wfMsgHtml( 'edit' )
);
- $links[] = $this->getDeletionLink( 'term',
$item->getId() );
+ $links[] = $this->getDeletionLink( 'course',
$item->getId() );
}
return $links;
Modified: trunk/extensions/EducationProgram/includes/EPDBObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPDBObject.php 2012-01-08
08:40:00 UTC (rev 108353)
+++ trunk/extensions/EducationProgram/includes/EPDBObject.php 2012-01-08
09:22:16 UTC (rev 108354)
@@ -889,7 +889,7 @@
$conds[] = $cond;
}
- //if (count($conds)) {q($conds);}
+
return $conds;
}
Modified: trunk/extensions/EducationProgram/includes/EPTerm.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPTerm.php 2012-01-08
08:40:00 UTC (rev 108353)
+++ trunk/extensions/EducationProgram/includes/EPTerm.php 2012-01-08
09:22:16 UTC (rev 108354)
@@ -95,11 +95,13 @@
$this->setField( 'org_id', $this->getCourse( 'org_id'
)->getField( 'org_id' ) );
}
- if ( $this->updateSummaries ) {
+ $success = parent::insertIntoDB();
+
+ if ( $success && $this->updateSummaries ) {
EPOrg::updateSummaryFields( 'terms', array( 'id' =>
$this->getField( 'org_id' ) ) );
}
- return parent::insertIntoDB();
+ return $success;
}
/**
@@ -110,20 +112,22 @@
$id = $this->getId();
if ( $this->updateSummaries ) {
- $this->loadFields( array( 'org_id' ) );
- $orgId = $this->getField( 'org_id', false );
+ $this->loadFields( array( 'org_id', 'course_id' ) );
+ $orgId = $this->getField( 'org_id' );
+ $courseId = $this->getField( 'course_id' );
}
$success = parent::removeFromDB();
+ if ( $success && $this->updateSummaries ) {
+ EPCourse::updateSummaryFields( 'students', array( 'id'
=> $courseId ) );
+ EPOrg::updateSummaryFields( array( 'terms', 'students'
), array( 'id' => $orgId ) );
+ }
+
if ( $success ) {
$success = wfGetDB( DB_MASTER )->delete(
'ep_students_per_term', array( 'spt_term_id' => $id ) ) && $success;
}
- if ( $this->updateSummaries && $orgId !== false ) {
- EPOrg::updateSummaryFields( array( 'terms', 'students'
), array( 'id' => $orgId ) );
- }
-
return $success;
}
Modified: trunk/extensions/EducationProgram/includes/EPTermPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPTermPager.php 2012-01-08
08:40:00 UTC (rev 108353)
+++ trunk/extensions/EducationProgram/includes/EPTermPager.php 2012-01-08
09:22:16 UTC (rev 108354)
@@ -95,19 +95,30 @@
'end',
);
}
+
+ /**
+ * (non-PHPdoc)
+ * @see EPPager::getFieldNames()
+ */
+ public function getFieldNames() {
+ $fields = parent::getFieldNames();
+
+ if ( array_key_exists( 'course_id', $this->conds ) &&
array_key_exists( 'org_id', $fields ) ) {
+ unset( $fields['org_id'] );
+ }
+
+ return $fields;
+ }
/**
* (non-PHPdoc)
* @see EPPager::getFilterOptions()
*/
protected function getFilterOptions() {
- $years = EPTerm::selectFields( 'year', array(), array(
'DISTINCT' ), array(), true );
- asort( $years, SORT_NUMERIC );
- $years = array_merge( array( '' ), $years );
- $years = array_combine( $years, $years );
-
- return array(
- 'course_id' => array(
+ $options = array();
+
+ if ( !array_key_exists( 'course_id', $this->conds ) ) {
+ $options['course_id'] = array(
'type' => 'select',
'options' => array_merge(
array( '' => '' ),
@@ -115,8 +126,9 @@
),
'value' => '',
'datatype' => 'int',
- ),
- 'org_id' => array(
+ );
+
+ $options['org_id'] = array(
'type' => 'select',
'options' => array_merge(
array( '' => '' ),
@@ -124,13 +136,21 @@
),
'value' => '',
'datatype' => 'int',
- ),
- 'year' => array(
- 'type' => 'select',
- 'options' => $years,
- 'value' => '',
- ),
+ );
+ }
+
+ $years = EPTerm::selectFields( 'year', array(), array(
'DISTINCT' ), array(), true );
+ asort( $years, SORT_NUMERIC );
+ $years = array_merge( array( '' ), $years );
+ $years = array_combine( $years, $years );
+
+ $options['year'] = array(
+ 'type' => 'select',
+ 'options' => $years,
+ 'value' => '',
);
+
+ return $options;
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs