r108354 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108353‎ | r108354 | r108355 >
Date:09:22, 8 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
more work on the pagers
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPDBObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTermPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPTermPager.php
@@ -95,19 +95,30 @@
9696 'end',
9797 );
9898 }
 99+
 100+ /**
 101+ * (non-PHPdoc)
 102+ * @see EPPager::getFieldNames()
 103+ */
 104+ public function getFieldNames() {
 105+ $fields = parent::getFieldNames();
 106+
 107+ if ( array_key_exists( 'course_id', $this->conds ) && array_key_exists( 'org_id', $fields ) ) {
 108+ unset( $fields['org_id'] );
 109+ }
 110+
 111+ return $fields;
 112+ }
99113
100114 /**
101115 * (non-PHPdoc)
102116 * @see EPPager::getFilterOptions()
103117 */
104118 protected function getFilterOptions() {
105 - $years = EPTerm::selectFields( 'year', array(), array( 'DISTINCT' ), array(), true );
106 - asort( $years, SORT_NUMERIC );
107 - $years = array_merge( array( '' ), $years );
108 - $years = array_combine( $years, $years );
109 -
110 - return array(
111 - 'course_id' => array(
 119+ $options = array();
 120+
 121+ if ( !array_key_exists( 'course_id', $this->conds ) ) {
 122+ $options['course_id'] = array(
112123 'type' => 'select',
113124 'options' => array_merge(
114125 array( '' => '' ),
@@ -115,8 +126,9 @@
116127 ),
117128 'value' => '',
118129 'datatype' => 'int',
119 - ),
120 - 'org_id' => array(
 130+ );
 131+
 132+ $options['org_id'] = array(
121133 'type' => 'select',
122134 'options' => array_merge(
123135 array( '' => '' ),
@@ -124,13 +136,21 @@
125137 ),
126138 'value' => '',
127139 'datatype' => 'int',
128 - ),
129 - 'year' => array(
130 - 'type' => 'select',
131 - 'options' => $years,
132 - 'value' => '',
133 - ),
 140+ );
 141+ }
 142+
 143+ $years = EPTerm::selectFields( 'year', array(), array( 'DISTINCT' ), array(), true );
 144+ asort( $years, SORT_NUMERIC );
 145+ $years = array_merge( array( '' ), $years );
 146+ $years = array_combine( $years, $years );
 147+
 148+ $options['year'] = array(
 149+ 'type' => 'select',
 150+ 'options' => $years,
 151+ 'value' => '',
134152 );
 153+
 154+ return $options;
135155 }
136156
137157 /**
Index: trunk/extensions/EducationProgram/includes/EPTerm.php
@@ -95,11 +95,13 @@
9696 $this->setField( 'org_id', $this->getCourse( 'org_id' )->getField( 'org_id' ) );
9797 }
9898
99 - if ( $this->updateSummaries ) {
 99+ $success = parent::insertIntoDB();
 100+
 101+ if ( $success && $this->updateSummaries ) {
100102 EPOrg::updateSummaryFields( 'terms', array( 'id' => $this->getField( 'org_id' ) ) );
101103 }
102104
103 - return parent::insertIntoDB();
 105+ return $success;
104106 }
105107
106108 /**
@@ -110,20 +112,22 @@
111113 $id = $this->getId();
112114
113115 if ( $this->updateSummaries ) {
114 - $this->loadFields( array( 'org_id' ) );
115 - $orgId = $this->getField( 'org_id', false );
 116+ $this->loadFields( array( 'org_id', 'course_id' ) );
 117+ $orgId = $this->getField( 'org_id' );
 118+ $courseId = $this->getField( 'course_id' );
116119 }
117120
118121 $success = parent::removeFromDB();
119122
 123+ if ( $success && $this->updateSummaries ) {
 124+ EPCourse::updateSummaryFields( 'students', array( 'id' => $courseId ) );
 125+ EPOrg::updateSummaryFields( array( 'terms', 'students' ), array( 'id' => $orgId ) );
 126+ }
 127+
120128 if ( $success ) {
121129 $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_term', array( 'spt_term_id' => $id ) ) && $success;
122130 }
123131
124 - if ( $this->updateSummaries && $orgId !== false ) {
125 - EPOrg::updateSummaryFields( array( 'terms', 'students' ), array( 'id' => $orgId ) );
126 - }
127 -
128132 return $success;
129133 }
130134
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php
@@ -889,7 +889,7 @@
890890
891891 $conds[] = $cond;
892892 }
893 - //if (count($conds)) {q($conds);}
 893+
894894 return $conds;
895895 }
896896
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -126,7 +126,7 @@
127127 wfMsgHtml( 'edit' )
128128 );
129129
130 - $links[] = $this->getDeletionLink( 'term', $item->getId() );
 130+ $links[] = $this->getDeletionLink( 'course', $item->getId() );
131131 }
132132
133133 return $links;
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -110,7 +110,7 @@
111111 if ( $this->updateSummaries && $orgId !== false ) {
112112 EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses' ), array( 'id' => $orgId ) );
113113 }
114 -
 114+
115115 return $success;
116116 }
117117
@@ -139,8 +139,8 @@
140140
141141 if ( $this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) {
142142 $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) );
 143+ EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) );
143144 EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses' ), $conds );
144 - EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) );
145145 }
146146
147147 return $success;

Status & tagging log