| Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
| — | — | @@ -194,4 +194,71 @@ |
| 195 | 195 | return $success; |
| 196 | 196 | } |
| 197 | 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 | + |
| 198 | 211 | } |
| | 212 | + |
| | 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 | + |
| | 223 | + } |
| | 224 | + |
| | 225 | + public function isMinor() { |
| | 226 | + return $this->isMinor; |
| | 227 | + } |
| | 228 | + |
| | 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 | +} |
| Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
| — | — | @@ -24,23 +24,21 @@ |
| 25 | 25 | public static function log( array $info ) { |
| 26 | 26 | $user = array_key_exists( 'user', $info ) ? $info['user'] : $GLOBALS['wgUser']; |
| 27 | 27 | |
| 28 | | - if ( $info !== false ) { |
| 29 | | - $logEntry = new ManualLogEntry( $info['type'], $info['subtype'] ); |
| | 28 | + $logEntry = new ManualLogEntry( $info['type'], $info['subtype'] ); |
| 30 | 29 | |
| 31 | | - $logEntry->setPerformer( $user ); |
| 32 | | - $logEntry->setTarget( $info['title'] ); |
| 33 | | - |
| 34 | | - if ( array_key_exists( 'comment', $info ) ) { |
| 35 | | - $logEntry->setComment( $info['comment'] ); |
| 36 | | - } |
| 37 | | - |
| 38 | | - if ( array_key_exists( 'parameters', $info ) ) { |
| 39 | | - $logEntry->setParameters( $info['parameters'] ); |
| 40 | | - } |
| 41 | | - |
| 42 | | - $logid = $logEntry->insert(); |
| 43 | | - $logEntry->publish( $logid ); |
| | 30 | + $logEntry->setPerformer( $user ); |
| | 31 | + $logEntry->setTarget( $info['title'] ); |
| | 32 | + |
| | 33 | + if ( array_key_exists( 'comment', $info ) ) { |
| | 34 | + $logEntry->setComment( $info['comment'] ); |
| 44 | 35 | } |
| | 36 | + |
| | 37 | + if ( array_key_exists( 'parameters', $info ) ) { |
| | 38 | + $logEntry->setParameters( $info['parameters'] ); |
| | 39 | + } |
| | 40 | + |
| | 41 | + $logid = $logEntry->insert(); |
| | 42 | + $logEntry->publish( $logid ); |
| 45 | 43 | } |
| 46 | 44 | |
| 47 | 45 | /** |
| Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php |
| — | — | @@ -54,12 +54,23 @@ |
| 55 | 55 | |
| 56 | 56 | $everythingOk = true; |
| 57 | 57 | |
| 58 | | - foreach ( $params['ids'] as $id ) { |
| 59 | | - // $instance->remove is used instead of Class::delete, |
| 60 | | - // so that linked data also gets deleted. |
| 61 | | - $c = self::$typeMap[$params['type']]; |
| 62 | | - $object = new $c( array( 'id' => $id ) ); |
| 63 | | - $everythingOk = $object->remove() && $everythingOk; |
| | 58 | +// foreach ( $params['ids'] as $id ) { |
| | 59 | +// // $instance->remove is used instead of Class::delete, |
| | 60 | +// // so that linked data also gets deleted. |
| | 61 | +// $c = self::$typeMap[$params['type']]; |
| | 62 | +// $object = new $c( array( 'id' => $id ) ); |
| | 63 | +// $everythingOk = $object->remove() && $everythingOk; |
| | 64 | +// } |
| | 65 | + |
| | 66 | + $class = self::$typeMap[$params['type']]; |
| | 67 | + |
| | 68 | + if ( count( $params['ids'] ) > 0 ) { |
| | 69 | + $revAction = new EPRevisionAction(); |
| | 70 | + |
| | 71 | + $revAction->setUser( $this->getUser() ); |
| | 72 | + $revAction->setComment( $params['comment'] ); |
| | 73 | + |
| | 74 | + $objects = $class::deleteAndLog( $revAction, array( 'id' => $params['ids'] ) ); |
| 64 | 75 | } |
| 65 | 76 | |
| 66 | 77 | $this->getResult()->addValue( |
| — | — | @@ -115,6 +126,11 @@ |
| 116 | 127 | ApiBase::PARAM_REQUIRED => true, |
| 117 | 128 | ApiBase::PARAM_ISMULTI => false, |
| 118 | 129 | ), |
| | 130 | + 'comment' => array( |
| | 131 | + ApiBase::PARAM_TYPE => 'string', |
| | 132 | + ApiBase::PARAM_REQUIRED => false, |
| | 133 | + ApiBase::PARAM_DFLT => '', |
| | 134 | + ), |
| 119 | 135 | 'token' => null, |
| 120 | 136 | ); |
| 121 | 137 | } |
| — | — | @@ -124,6 +140,7 @@ |
| 125 | 141 | 'ids' => 'The IDs of the reviews to delete', |
| 126 | 142 | 'token' => 'Edit token. You can get one of these through prop=info.', |
| 127 | 143 | 'type' => 'Type of object to delete.', |
| | 144 | + 'comment' => 'Message with the reason for this change for the log', |
| 128 | 145 | ); |
| 129 | 146 | } |
| 130 | 147 | |
| Index: trunk/extensions/EducationProgram/resources/ep.pager.js |
| — | — | @@ -20,7 +20,8 @@ |
| 21 | 21 | } ); |
| 22 | 22 | |
| 23 | 23 | var $dialog = undefined, |
| 24 | | - $remove = undefined; |
| | 24 | + $remove = undefined, |
| | 25 | + $summaryInput = undefined; |
| 25 | 26 | |
| 26 | 27 | var showConfirmDialog = function( args, onConfirm ) { |
| 27 | 28 | var args = $.extend( { |
| — | — | @@ -71,7 +72,7 @@ |
| 72 | 73 | 'for': 'epsummaryinput' |
| 73 | 74 | } ).msg( 'ep-pager-summary-message-' + args.type ).append( ' ' ); |
| 74 | 75 | |
| 75 | | - var summaryInput = $( '<input>' ).attr( { |
| | 76 | + summaryInput = $( '<input>' ).attr( { |
| 76 | 77 | 'type': 'text', |
| 77 | 78 | 'size': 60, |
| 78 | 79 | 'maxlength': 250, |
| — | — | @@ -102,7 +103,8 @@ |
| 103 | 104 | args = { |
| 104 | 105 | 'type': $this.attr( 'data-type' ), |
| 105 | 106 | 'ids': [ $this.attr( 'data-id' ) ], |
| 106 | | - 'names': [ $this.attr( 'data-name' ) ] |
| | 107 | + 'names': [ $this.attr( 'data-name' ) ], |
| | 108 | + 'comment': $summaryInput |
| 107 | 109 | }; |
| 108 | 110 | |
| 109 | 111 | showConfirmDialog( |
| — | — | @@ -156,7 +158,8 @@ |
| 157 | 159 | args = { |
| 158 | 160 | 'type': $( this ).attr( 'data-type' ), |
| 159 | 161 | 'ids': ids, |
| 160 | | - 'names': names |
| | 162 | + 'names': names, |
| | 163 | + 'comment': $summaryInput |
| 161 | 164 | }; |
| 162 | 165 | |
| 163 | 166 | showConfirmDialog( |