Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -100,6 +100,7 @@ |
101 | 101 | $wgAutoloadClasses['EPArticle'] = dirname( __FILE__ ) . '/includes/EPArticle.php'; |
102 | 102 | $wgAutoloadClasses['EPArticlePager'] = dirname( __FILE__ ) . '/includes/EPArticlePager.php'; |
103 | 103 | $wgAutoloadClasses['EPArticleTable'] = dirname( __FILE__ ) . '/includes/EPArticleTable.php'; |
| 104 | +$wgAutoloadClasses['EPRevisionAction'] = dirname( __FILE__ ) . '/includes/EPRevisionAction.php'; |
104 | 105 | |
105 | 106 | $wgAutoloadClasses['CoursePage'] = dirname( __FILE__ ) . '/pages/CoursePage.php'; |
106 | 107 | $wgAutoloadClasses['EPPage'] = dirname( __FILE__ ) . '/pages/EPPage.php'; |
Index: trunk/extensions/EducationProgram/includes/EPRevisionAction.php |
— | — | @@ -0,0 +1,58 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class EPRevisionAction { |
| 5 | + |
| 6 | + protected $user; |
| 7 | + protected $isMinor = false; |
| 8 | + protected $isDelete = false; |
| 9 | + protected $comment = ''; |
| 10 | + protected $time = false; |
| 11 | + |
| 12 | + public function __construct() { |
| 13 | + |
| 14 | + } |
| 15 | + |
| 16 | + public function isMinor() { |
| 17 | + return $this->isMinor; |
| 18 | + } |
| 19 | + |
| 20 | + public function isDelete() { |
| 21 | + return $this->isDelete; |
| 22 | + } |
| 23 | + |
| 24 | + public function getComment() { |
| 25 | + return $this->comment; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * @return User |
| 30 | + */ |
| 31 | + public function getUser() { |
| 32 | + return $this->user; |
| 33 | + } |
| 34 | + |
| 35 | + public function getTime() { |
| 36 | + return $this->time === false ? wfTimestampNow() : $this->time; |
| 37 | + } |
| 38 | + |
| 39 | + public function setUser( User $user ) { |
| 40 | + $this->user = $user; |
| 41 | + } |
| 42 | + |
| 43 | + public function setComment( $comment ) { |
| 44 | + $this->comment = $comment; |
| 45 | + } |
| 46 | + |
| 47 | + public function setDelete( $isDelete ) { |
| 48 | + $this->isDelete = $isDelete; |
| 49 | + } |
| 50 | + |
| 51 | + public function setMinor( $isMinor ) { |
| 52 | + $this->isMinor = $isMinor; |
| 53 | + } |
| 54 | + |
| 55 | + public function setTime( $time ) { |
| 56 | + $this->time = $time; |
| 57 | + } |
| 58 | + |
| 59 | +} |
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
— | — | @@ -29,8 +29,26 @@ |
30 | 30 | * @var bool |
31 | 31 | */ |
32 | 32 | protected $storeRevisions = true; |
33 | | - |
| 33 | + |
34 | 34 | /** |
| 35 | + * |
| 36 | + * @since 0.1 |
| 37 | + * @var EPRevisionAction|false |
| 38 | + */ |
| 39 | + protected $revAction = false; |
| 40 | + |
| 41 | + /** |
| 42 | + * |
| 43 | + * |
| 44 | + * @since 0.1 |
| 45 | + * |
| 46 | + * @param EPRevisionAction $revAction |
| 47 | + */ |
| 48 | + protected function setRevisionAction( EPRevisionAction $revAction ) { |
| 49 | + $this->revAction = $revAction; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
35 | 53 | * Sets the value for the @see $storeRevisions field. |
36 | 54 | * |
37 | 55 | * @since 0.1 |
— | — | @@ -79,12 +97,22 @@ |
80 | 98 | * @since 0.1 |
81 | 99 | * |
82 | 100 | * @param EPRevision $revision |
83 | | - * @param bool $isDelete |
84 | 101 | * |
85 | 102 | * @return boolean Success indicator |
86 | 103 | */ |
87 | | - protected function storeRevision( EPRevision $revision, $isDelete = false ) { |
| 104 | + protected function storeRevision( EPRevision $revision ) { |
88 | 105 | if ( $this->storeRevisions ) { |
| 106 | + if ( $this->revAction !== false ) { |
| 107 | + $revision->setFields( array( |
| 108 | + 'minor_edit' => $this->revAction->isMinor(), |
| 109 | + 'deleted' => $this->revAction->deleted(), |
| 110 | + 'time' => $this->revAction->getTime(), |
| 111 | + 'comment' => $this->revAction->getComment(), |
| 112 | + 'user_id' => $this->revAction->getUser()->getId(), |
| 113 | + 'user_text' => $this->revAction->getUser()->getName(), |
| 114 | + ) ); |
| 115 | + } |
| 116 | + |
89 | 117 | return $revision->save(); |
90 | 118 | } |
91 | 119 | |
— | — | @@ -101,8 +129,12 @@ |
102 | 130 | protected function log( $subType ) { |
103 | 131 | if ( $this->log ) { |
104 | 132 | $info = $this->getLogInfo( $subType ); |
105 | | - |
| 133 | + |
106 | 134 | if ( $info !== false ) { |
| 135 | + if ( $this->revAction !== false ) { |
| 136 | + $info['user'] = $this->revAction->getUser(); |
| 137 | + } |
| 138 | + |
107 | 139 | $info['subtype'] = $subType; |
108 | 140 | EPUtils::log( $info ); |
109 | 141 | } |
— | — | @@ -193,72 +225,9 @@ |
194 | 226 | |
195 | 227 | return $success; |
196 | 228 | } |
197 | | - |
198 | | - public static function deleteAndLog( EPRevisionAction $revAction, array $conditions ) { |
199 | | - $success = static::delete( $conditions ); |
200 | | - |
201 | | - if ( $success ) { |
202 | | - $revAction->setDelete( true ); |
203 | | - |
204 | | - // TODO |
205 | | - //static::log(); |
206 | | - } |
207 | | - |
208 | | - return $success; |
209 | | - } |
210 | | - |
211 | | -} |
212 | 229 | |
213 | | -class EPRevisionAction { |
214 | | - |
215 | | - protected $user; |
216 | | - protected $isMinor = false; |
217 | | - protected $isDelete = false; |
218 | | - protected $comment = false; |
219 | | - protected $time = false; |
220 | | - |
221 | | - public function __construct() { |
222 | | - |
| 230 | + public function logRmove() { |
| 231 | + $this->log( 'remove' ); |
223 | 232 | } |
224 | | - |
225 | | - public function isMinor() { |
226 | | - return $this->isMinor; |
227 | | - } |
228 | 233 | |
229 | | - public function isDelete() { |
230 | | - return $this->isDelete; |
231 | | - } |
232 | | - |
233 | | - public function getComment() { |
234 | | - return $this->comment; |
235 | | - } |
236 | | - |
237 | | - public function getUser() { |
238 | | - return $this->user; |
239 | | - } |
240 | | - |
241 | | - public function getTime() { |
242 | | - return $this->time; |
243 | | - } |
244 | | - |
245 | | - public function setUser( User $user ) { |
246 | | - $this->user = $user; |
247 | | - } |
248 | | - |
249 | | - public function setComment( $comment ) { |
250 | | - $this->comment = $comment; |
251 | | - } |
252 | | - |
253 | | - public function setDelete( $isDelete ) { |
254 | | - $this->isDelete = $isDelete; |
255 | | - } |
256 | | - |
257 | | - public function setMinor( $isMinor ) { |
258 | | - $this->isMinor = $isMinor; |
259 | | - } |
260 | | - |
261 | | - public function setTime( $time ) { |
262 | | - $this->time = $time; |
263 | | - } |
264 | | - |
265 | | -} |
| 234 | +} |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php |
— | — | @@ -100,4 +100,37 @@ |
101 | 101 | return self::$info[get_called_class()]['list']; |
102 | 102 | } |
103 | 103 | |
| 104 | + /** |
| 105 | + * |
| 106 | + * |
| 107 | + * @since 0.1 |
| 108 | + * |
| 109 | + * @param EPRevisionAction $revAction |
| 110 | + * @param array $conditions |
| 111 | + * |
| 112 | + * @return boolean |
| 113 | + */ |
| 114 | + public static function deleteAndLog( EPRevisionAction $revAction, array $conditions ) { |
| 115 | + $objects = static::select( |
| 116 | + null, |
| 117 | + $conditions |
| 118 | + ); |
| 119 | + |
| 120 | + $success = true; |
| 121 | + |
| 122 | + if ( count( $objects ) > 0 ) { |
| 123 | + $success = static::delete( $conditions ); |
| 124 | + |
| 125 | + if ( $success ) { |
| 126 | + $revAction->setDelete( true ); |
| 127 | + |
| 128 | + foreach ( $objects as /* EPPageObject */ $object ) { |
| 129 | + $object->logRemove(); |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + return $success; |
| 135 | + } |
| 136 | + |
104 | 137 | } |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $revAction->setUser( $this->getUser() ); |
72 | 72 | $revAction->setComment( $params['comment'] ); |
73 | 73 | |
74 | | - $objects = $class::deleteAndLog( $revAction, array( 'id' => $params['ids'] ) ); |
| 74 | + $class::deleteAndLog( $revAction, array( 'id' => $params['ids'] ) ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $this->getResult()->addValue( |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -175,7 +175,7 @@ |
176 | 176 | */ |
177 | 177 | public static function onPageTabs( SkinTemplate &$sktemplate, array &$links ) { |
178 | 178 | self::displayTabs( $sktemplate, $links, $sktemplate->getTitle() ); |
179 | | - |
| 179 | + |
180 | 180 | return false; |
181 | 181 | } |
182 | 182 | |