Index: trunk/extensions/EducationProgram/actions/EPRestoreAction.php |
— | — | @@ -53,27 +53,33 @@ |
54 | 54 | } |
55 | 55 | else { |
56 | 56 | $req = $this->getRequest(); |
57 | | - |
58 | | - if ( $req->wasPosted() && $this->getUser()->matchEditToken( $req->getText( 'restoreToken' ), $this->getSalt() ) ) { |
59 | | - if ( $req->getCheck( 'revid' ) ) { |
60 | | - $success = $this->doRestore( $object, $req->getInt( 'revid' ) ); |
| 57 | + |
| 58 | + $success = false; |
| 59 | + |
| 60 | + if ( $req->getCheck( 'revid' ) ) { |
| 61 | + $revision = EPRevisions::singleton()->selectRow( null, array( 'id' => $req->getInt( 'revid' ) ) ); |
| 62 | + |
| 63 | + if ( $revision !== false ) { |
| 64 | + if ( $req->wasPosted() && $this->getUser()->matchEditToken( $req->getText( 'restoreToken' ), $this->getSalt() ) ) { |
| 65 | + $success = $this->doRestore( $object, $revision ); |
| 66 | + } |
| 67 | + else { |
| 68 | + $this->displayForm( $object, $revision ); |
| 69 | + $success = null; |
| 70 | + } |
61 | 71 | } |
62 | | - else { |
63 | | - $success = false; |
64 | | - } |
65 | | - |
| 72 | + } |
| 73 | + |
| 74 | + if ( !is_null( $success ) ) { |
66 | 75 | if ( $success ) { |
67 | 76 | $query = array( 'restored' => '1' ); // TODO: handle |
68 | 77 | } |
69 | 78 | else { |
70 | 79 | $query = array( 'restorefailed' => '1' ); // TODO: handle |
71 | 80 | } |
72 | | - |
| 81 | + |
73 | 82 | $this->getOutput()->redirect( $object->getTitle()->getLocalURL( $query ) ); |
74 | 83 | } |
75 | | - else { |
76 | | - $this->displayForm( $object ); |
77 | | - } |
78 | 84 | } |
79 | 85 | |
80 | 86 | return ''; |
— | — | @@ -85,12 +91,12 @@ |
86 | 92 | * @since 0.1 |
87 | 93 | * |
88 | 94 | * @param EPPageObject $object |
89 | | - * @param integer $revId |
| 95 | + * @param EPRevision $revision |
90 | 96 | * |
91 | 97 | * @return boolean Success indicator |
92 | 98 | */ |
93 | | - protected function doRestore( EPPageObject $object, $revId ) { |
94 | | - $success = $object->restoreToRevisionId( $revId, $object->getTable()->getRevertableFields() ); |
| 99 | + protected function doRestore( EPPageObject $object, EPRevision $revision ) { |
| 100 | + $success = $object->restoreToRevision( $revision, $object->getTable()->getRevertableFields() ); |
95 | 101 | |
96 | 102 | if ( $success ) { |
97 | 103 | $revAction = new EPRevisionAction(); |
— | — | @@ -99,11 +105,6 @@ |
100 | 106 | $revAction->setComment( $this->getRequest()->getText( 'summary', '' ) ); |
101 | 107 | |
102 | 108 | $success = $object->revisionedSave( $revAction ); |
103 | | - |
104 | | - if ( $success ) { |
105 | | - // TODO: log |
106 | | - // Already logged - just alter message? |
107 | | - } |
108 | 109 | } |
109 | 110 | |
110 | 111 | return $success; |
— | — | @@ -115,8 +116,9 @@ |
116 | 117 | * @since 0.1 |
117 | 118 | * |
118 | 119 | * @param EPPageObject $object |
| 120 | + * @param EPRevision $revision |
119 | 121 | */ |
120 | | - protected function displayForm( EPPageObject $object ) { |
| 122 | + protected function displayForm( EPPageObject $object, EPRevision $revision ) { |
121 | 123 | $out = $this->getOutput(); |
122 | 124 | |
123 | 125 | $out->addModules( 'ep.formpage' ); |
— | — | @@ -136,7 +138,12 @@ |
137 | 139 | 'summary', |
138 | 140 | 'summary', |
139 | 141 | 65, |
140 | | - false, |
| 142 | + wfMsgExt( |
| 143 | + $this->prefixMsg( 'summary-value' ), |
| 144 | + 'parsemag', |
| 145 | + $this->getLanguage()->timeanddate( $revision->getField( 'time' ) ), |
| 146 | + $revision->getUser()->getName() |
| 147 | + ), |
141 | 148 | array( |
142 | 149 | 'maxlength' => 250, |
143 | 150 | 'spellcheck' => true, |
Index: trunk/extensions/EducationProgram/actions/EPUndoAction.php |
— | — | @@ -53,27 +53,33 @@ |
54 | 54 | } |
55 | 55 | else { |
56 | 56 | $req = $this->getRequest(); |
57 | | - |
58 | | - if ( $req->wasPosted() && $this->getUser()->matchEditToken( $req->getText( 'undoToken' ), $this->getSalt() ) ) { |
59 | | - if ( $req->getCheck( 'revid' ) ) { |
60 | | - $success = $this->doUndo( $object, $req->getInt( 'revid' ) ); |
| 57 | + |
| 58 | + $success = false; |
| 59 | + |
| 60 | + if ( $req->getCheck( 'revid' ) ) { |
| 61 | + $revision = EPRevisions::singleton()->selectRow( null, array( 'id' => $req->getInt( 'revid' ) ) ); |
| 62 | + |
| 63 | + if ( $revision !== false ) { |
| 64 | + if ( $req->wasPosted() && $this->getUser()->matchEditToken( $req->getText( 'undoToken' ), $this->getSalt() ) ) { |
| 65 | + $success = $this->doUndo( $object, $revision ); |
| 66 | + } |
| 67 | + else { |
| 68 | + $this->displayForm( $object, $revision ); |
| 69 | + $success = null; |
| 70 | + } |
61 | 71 | } |
62 | | - else { |
63 | | - $success = false; |
64 | | - } |
| 72 | + } |
65 | 73 | |
| 74 | + if ( !is_null( $success ) ) { |
66 | 75 | if ( $success ) { |
67 | 76 | $query = array( 'undid' => '1' ); // TODO: handle |
68 | 77 | } |
69 | 78 | else { |
70 | 79 | $query = array( 'undofailed' => '1' ); // TODO: handle |
71 | 80 | } |
72 | | - |
| 81 | + |
73 | 82 | $this->getOutput()->redirect( $object->getTitle()->getLocalURL( $query ) ); |
74 | 83 | } |
75 | | - else { |
76 | | - $this->displayForm( $object ); |
77 | | - } |
78 | 84 | } |
79 | 85 | |
80 | 86 | return ''; |
— | — | @@ -85,12 +91,12 @@ |
86 | 92 | * @since 0.1 |
87 | 93 | * |
88 | 94 | * @param EPPageObject $object |
89 | | - * @param integer $revId |
| 95 | + * @param EPRevision $revision |
90 | 96 | * |
91 | 97 | * @return boolean Success indicator |
92 | 98 | */ |
93 | | - protected function doUndo( EPPageObject $object, $revId ) { |
94 | | - $success = $object->undoRevisionId( $revId, $object->getTable()->getRevertableFields() ); |
| 99 | + protected function doUndo( EPPageObject $object, EPRevision $revision ) { |
| 100 | + $success = $object->undoRevision( $revision, $object->getTable()->getRevertableFields() ); |
95 | 101 | |
96 | 102 | if ( $success ) { |
97 | 103 | $revAction = new EPRevisionAction(); |
— | — | @@ -99,14 +105,9 @@ |
100 | 106 | $revAction->setComment( $this->getRequest()->getText( 'summary', '' ) ); |
101 | 107 | |
102 | 108 | $success = $object->revisionedSave( $revAction ); |
| 109 | + } |
103 | 110 | |
104 | | - if ( $success ) { |
105 | | - // TODO: log |
106 | | - // Already logged - just alter message? |
107 | | - } |
108 | | - } |
109 | | - |
110 | | - return false; |
| 111 | + return $success; |
111 | 112 | } |
112 | 113 | |
113 | 114 | /** |
— | — | @@ -115,8 +116,9 @@ |
116 | 117 | * @since 0.1 |
117 | 118 | * |
118 | 119 | * @param EPPageObject $object |
| 120 | + * @param EPRevision $revision |
119 | 121 | */ |
120 | | - protected function displayForm( EPPageObject $object ) { |
| 122 | + protected function displayForm( EPPageObject $object, EPRevision $revision ) { |
121 | 123 | $out = $this->getOutput(); |
122 | 124 | |
123 | 125 | $out->addModules( 'ep.formpage' ); |
— | — | @@ -136,7 +138,12 @@ |
137 | 139 | 'summary', |
138 | 140 | 'summary', |
139 | 141 | 65, |
140 | | - false, |
| 142 | + wfMsgExt( |
| 143 | + $this->prefixMsg( 'summary-value' ), |
| 144 | + 'parsemag', |
| 145 | + $this->getLanguage()->timeanddate( $revision->getField( 'time' ) ), |
| 146 | + $revision->getUser()->getName() |
| 147 | + ), |
141 | 148 | array( |
142 | 149 | 'maxlength' => 250, |
143 | 150 | 'spellcheck' => true, |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -500,6 +500,7 @@ |
501 | 501 | 'orgpage-eprestore-summary' => 'Reason for restoration:', |
502 | 502 | 'orgpage-eprestore-restore-button' => 'Restore revision', |
503 | 503 | 'orgpage-eprestore-cancel-button' => 'Cancel', |
| 504 | + 'orgpage-eprestore-summary-value' => 'Restore institution to the revision made on $1 by $2', |
504 | 505 | |
505 | 506 | // Course restoration |
506 | 507 | 'coursepage-eprestore-title' => 'Restore course "$1"', |
— | — | @@ -507,6 +508,7 @@ |
508 | 509 | 'coursepage-eprestore-summary' => 'Reason for restoration:', |
509 | 510 | 'coursepage-eprestore-restore-button' => 'Restore revision', |
510 | 511 | 'coursepage-eprestore-cancel-button' => 'Cancel', |
| 512 | + 'coursepage-eprestore-summary-value' => 'Restore course to the revision made on $1 by $2', |
511 | 513 | |
512 | 514 | // Institution undo revision |
513 | 515 | 'orgpage-epundo-title' => 'Undo revision of institution "$1"', |
— | — | @@ -514,6 +516,7 @@ |
515 | 517 | 'orgpage-epundo-summary' => 'Reason for revert:', |
516 | 518 | 'orgpage-epundo-undo-button' => 'Undo revision', |
517 | 519 | 'orgpage-epundo-cancel-button' => 'Cancel', |
| 520 | + 'orgpage-epundo-summary-value' => 'Undo revision made on $1 by $2', |
518 | 521 | |
519 | 522 | // Course undo revision |
520 | 523 | 'coursepage-epundo-title' => 'Undo revision of course "$1"', |
— | — | @@ -521,6 +524,7 @@ |
522 | 525 | 'coursepage-epundo-summary' => 'Reason for revert:', |
523 | 526 | 'coursepage-epundo-undo-button' => 'Undo revision', |
524 | 527 | 'coursepage-epundo-cancel-button' => 'Cancel', |
| 528 | + 'coursepage-epundo-summary-value' => 'Undo revision made on $1 by $2', |
525 | 529 | |
526 | 530 | // Course undeletion |
527 | 531 | 'coursepage-epundelete-title' => 'Undelete course "$1"', |