Index: trunk/extensions/EducationProgram/includes/EPTermPager.php |
— | — | @@ -95,19 +95,30 @@ |
96 | 96 | 'end', |
97 | 97 | ); |
98 | 98 | } |
| 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 | + } |
99 | 113 | |
100 | 114 | /** |
101 | 115 | * (non-PHPdoc) |
102 | 116 | * @see EPPager::getFilterOptions() |
103 | 117 | */ |
104 | 118 | 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( |
112 | 123 | 'type' => 'select', |
113 | 124 | 'options' => array_merge( |
114 | 125 | array( '' => '' ), |
— | — | @@ -115,8 +126,9 @@ |
116 | 127 | ), |
117 | 128 | 'value' => '', |
118 | 129 | 'datatype' => 'int', |
119 | | - ), |
120 | | - 'org_id' => array( |
| 130 | + ); |
| 131 | + |
| 132 | + $options['org_id'] = array( |
121 | 133 | 'type' => 'select', |
122 | 134 | 'options' => array_merge( |
123 | 135 | array( '' => '' ), |
— | — | @@ -124,13 +136,21 @@ |
125 | 137 | ), |
126 | 138 | 'value' => '', |
127 | 139 | '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' => '', |
134 | 152 | ); |
| 153 | + |
| 154 | + return $options; |
135 | 155 | } |
136 | 156 | |
137 | 157 | /** |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -95,11 +95,13 @@ |
96 | 96 | $this->setField( 'org_id', $this->getCourse( 'org_id' )->getField( 'org_id' ) ); |
97 | 97 | } |
98 | 98 | |
99 | | - if ( $this->updateSummaries ) { |
| 99 | + $success = parent::insertIntoDB(); |
| 100 | + |
| 101 | + if ( $success && $this->updateSummaries ) { |
100 | 102 | EPOrg::updateSummaryFields( 'terms', array( 'id' => $this->getField( 'org_id' ) ) ); |
101 | 103 | } |
102 | 104 | |
103 | | - return parent::insertIntoDB(); |
| 105 | + return $success; |
104 | 106 | } |
105 | 107 | |
106 | 108 | /** |
— | — | @@ -110,20 +112,22 @@ |
111 | 113 | $id = $this->getId(); |
112 | 114 | |
113 | 115 | 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' ); |
116 | 119 | } |
117 | 120 | |
118 | 121 | $success = parent::removeFromDB(); |
119 | 122 | |
| 123 | + if ( $success && $this->updateSummaries ) { |
| 124 | + EPCourse::updateSummaryFields( 'students', array( 'id' => $courseId ) ); |
| 125 | + EPOrg::updateSummaryFields( array( 'terms', 'students' ), array( 'id' => $orgId ) ); |
| 126 | + } |
| 127 | + |
120 | 128 | if ( $success ) { |
121 | 129 | $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_term', array( 'spt_term_id' => $id ) ) && $success; |
122 | 130 | } |
123 | 131 | |
124 | | - if ( $this->updateSummaries && $orgId !== false ) { |
125 | | - EPOrg::updateSummaryFields( array( 'terms', 'students' ), array( 'id' => $orgId ) ); |
126 | | - } |
127 | | - |
128 | 132 | return $success; |
129 | 133 | } |
130 | 134 | |
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php |
— | — | @@ -889,7 +889,7 @@ |
890 | 890 | |
891 | 891 | $conds[] = $cond; |
892 | 892 | } |
893 | | - //if (count($conds)) {q($conds);} |
| 893 | + |
894 | 894 | return $conds; |
895 | 895 | } |
896 | 896 | |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | wfMsgHtml( 'edit' ) |
128 | 128 | ); |
129 | 129 | |
130 | | - $links[] = $this->getDeletionLink( 'term', $item->getId() ); |
| 130 | + $links[] = $this->getDeletionLink( 'course', $item->getId() ); |
131 | 131 | } |
132 | 132 | |
133 | 133 | return $links; |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | if ( $this->updateSummaries && $orgId !== false ) { |
112 | 112 | EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses' ), array( 'id' => $orgId ) ); |
113 | 113 | } |
114 | | - |
| 114 | + |
115 | 115 | return $success; |
116 | 116 | } |
117 | 117 | |
— | — | @@ -139,8 +139,8 @@ |
140 | 140 | |
141 | 141 | if ( $this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) { |
142 | 142 | $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) ); |
| 143 | + EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) ); |
143 | 144 | EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses' ), $conds ); |
144 | | - EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | return $success; |