Allow a lonely "-" as positional argument
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
index 14d97eb..c672817 100644 (file)
@@ -105,7 +105,7 @@ class SpecialBlock extends FormSpecialPage {
 
                # Don't need to do anything if the form has been posted
                if ( !$this->getRequest()->wasPosted() && $this->preErrors ) {
-                       $s = HTMLForm::formatErrors( $this->preErrors );
+                       $s = $form->formatErrors( $this->preErrors );
                        if ( $s ) {
                                $form->addHeaderText( Html::rawElement(
                                        'div',
@@ -236,6 +236,14 @@ class SpecialBlock extends FormSpecialPage {
                # This will be overwritten by request data
                $fields['Target']['default'] = (string)$this->target;
 
+               if ( $this->target ) {
+                       $status = self::validateTarget( $this->target, $this->getUser() );
+                       if ( !$status->isOK() ) {
+                               $errors = $status->getErrorsArray();
+                               $this->preErrors = array_merge( $this->preErrors, $errors );
+                       }
+               }
+
                # This won't be
                $fields['PreviousTarget']['default'] = (string)$this->target;
 
@@ -784,22 +792,21 @@ class SpecialBlock extends FormSpecialPage {
 
                # Prepare log parameters
                $logParams = array();
-               $logParams[] = $data['Expiry'];
-               $logParams[] = self::blockLogFlags( $data, $type );
+               $logParams['5::duration'] = $data['Expiry'];
+               $logParams['6::flags'] = self::blockLogFlags( $data, $type );
 
                # Make log entry, if the name is hidden, put it in the oversight log
                $log_type = $data['HideUser'] ? 'suppress' : 'block';
-               $log = new LogPage( $log_type );
-               $log_id = $log->addEntry(
-                       $logaction,
-                       Title::makeTitle( NS_USER, $target ),
-                       $data['Reason'][0],
-                       $logParams,
-                       $performer
-               );
+               $logEntry = new ManualLogEntry( $log_type, $logaction );
+               $logEntry->setTarget( Title::makeTitle( NS_USER, $target ) );
+               $logEntry->setComment( $data['Reason'][0] );
+               $logEntry->setPerformer( $performer );
+               $logEntry->setParameters( $logParams );
                # Relate log ID to block IDs (bug 25763)
                $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
-               $log->addRelations( 'ipb_id', $blockIds, $log_id );
+               $logEntry->setRelations( array( 'ipb_id' => $blockIds ) );
+               $logId = $logEntry->insert();
+               $logEntry->publish( $logId );
 
                # Report to the user
                return true;
@@ -829,7 +836,7 @@ class SpecialBlock extends FormSpecialPage {
                        }
 
                        list( $show, $value ) = explode( ':', $option );
-                       $a[htmlspecialchars( $show )] = htmlspecialchars( $value );
+                       $a[$show] = $value;
                }
 
                return $a;