Index: trunk/extensions/EducationProgram/includes/DBDataObject.php |
— | — | @@ -610,13 +610,21 @@ |
611 | 611 | * @since 1.20 |
612 | 612 | * |
613 | 613 | * @param DBDataObject $object |
614 | | - * @param boolean $excludeSummaryFields When set to true, summary field changes are ignored. |
| 614 | + * @param boolean|array $excludeSummaryFields |
| 615 | + * When set to true, summary field changes are ignored. |
| 616 | + * Can also be an array of fields to ignore. |
615 | 617 | * |
616 | 618 | * @return boolean |
617 | 619 | */ |
618 | 620 | protected function fieldsChanged( DBDataObject $object, $excludeSummaryFields = false ) { |
| 621 | + $exclusionFields = array(); |
| 622 | + |
| 623 | + if ( $excludeSummaryFields !== false ) { |
| 624 | + $exclusionFields = is_array( $excludeSummaryFields ) ? $excludeSummaryFields : $this->table->getSummaryFields(); |
| 625 | + } |
| 626 | + |
619 | 627 | foreach ( $this->fields as $name => $value ) { |
620 | | - $excluded = $excludeSummaryFields && in_array( $name, $this->table->getSummaryFields() ); |
| 628 | + $excluded = $excludeSummaryFields && in_array( $name, $exclusionFields ); |
621 | 629 | |
622 | 630 | if ( !$excluded && $object->getField( $name ) !== $value ) { |
623 | 631 | return true; |
Index: trunk/extensions/EducationProgram/includes/EPRevisionPager.php |
— | — | @@ -118,14 +118,16 @@ |
119 | 119 | array( 'revid' => $revision->getId() ) |
120 | 120 | ); |
121 | 121 | } |
122 | | - |
123 | | - $actionLinks[] = $object->getLink( |
124 | | - 'eprestore', |
125 | | - wfMsgHtml( 'ep-revision-restore' ), |
126 | | - array(), |
127 | | - array( 'revid' => $revision->getId() ) |
128 | | - ); |
129 | | - |
| 122 | + |
| 123 | + if ( $this->mOffset !== '' || $this->rowNr != 0 ) { |
| 124 | + $actionLinks[] = $object->getLink( |
| 125 | + 'eprestore', |
| 126 | + wfMsgHtml( 'ep-revision-restore' ), |
| 127 | + array(), |
| 128 | + array( 'revid' => $revision->getId() ) |
| 129 | + ); |
| 130 | + } |
| 131 | + |
130 | 132 | $html .= ' . . '; |
131 | 133 | $html .= '(' . $this->getLanguage()->pipeList( $actionLinks ) . ')'; |
132 | 134 | } |
Index: trunk/extensions/EducationProgram/includes/EPCourses.php |
— | — | @@ -132,11 +132,16 @@ |
133 | 133 | */ |
134 | 134 | public function getRevertableFields() { |
135 | 135 | return array( |
| 136 | + 'org_id', |
136 | 137 | 'name', |
| 138 | + 'mc', |
137 | 139 | 'start', |
138 | 140 | 'end', |
139 | 141 | 'description', |
140 | 142 | 'token', |
| 143 | + 'field', |
| 144 | + 'level', |
| 145 | + 'term' |
141 | 146 | ); |
142 | 147 | } |
143 | 148 | |
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
— | — | @@ -320,15 +320,19 @@ |
321 | 321 | * @return boolean Success indicator |
322 | 322 | */ |
323 | 323 | public function restoreToRevision( EPRevision $revison, array $fields = null ) { |
324 | | - $obejct = $revison->getObject(); |
325 | | - $fields = is_null( $fields ) ? $obejct->getFieldNames() : $fields; |
| 324 | + $object = $revison->getObject(); |
| 325 | + $fields = is_null( $fields ) ? $object->getFieldNames() : $fields; |
326 | 326 | |
327 | 327 | foreach ( $fields as $fieldName ) { |
328 | | - $this->setField( $fieldName, $obejct->getField( $fieldName ) ); |
| 328 | + $this->restoreField( $fieldName, $object ); |
329 | 329 | } |
330 | 330 | |
331 | 331 | return true; |
332 | 332 | } |
| 333 | + |
| 334 | + protected function restoreField( $fieldName, EPRevisionedObject $object ) { |
| 335 | + $this->setField( $fieldName, $object->getField( $fieldName ) ); |
| 336 | + } |
333 | 337 | |
334 | 338 | /** |
335 | 339 | * Retore the object to a revision with the provided id. |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -705,5 +705,12 @@ |
706 | 706 | |
707 | 707 | EPUtils::log( $info ); |
708 | 708 | } |
709 | | - |
| 709 | + |
| 710 | + protected function restoreField( $fieldName, EPRevisionedObject $object ) { |
| 711 | + if ( $fieldName !== 'org_id' |
| 712 | + || EPOrgs::singleton()->has( array( 'id' => $object->getField( 'org_id' ) ) ) ) { |
| 713 | + parent::restoreField( $fieldName, $object ); |
| 714 | + } |
| 715 | + } |
| 716 | + |
710 | 717 | } |