Merge "Add PreferencesFormPreSave hook"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 3 Feb 2014 03:00:44 +0000 (03:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 3 Feb 2014 03:00:44 +0000 (03:00 +0000)
1  2 
docs/hooks.txt
includes/Preferences.php

diff --combined docs/hooks.txt
@@@ -847,15 -847,6 +847,15 @@@ content model name, but no entry for th
  $modeName: the requested content model name
  &$handler: set this to a ContentHandler object, if desired.
  
 +'ContentModelCanBeUsedOn': Called to determine whether that content model can
 +be used on a given page. This is especially useful to prevent some content models
 +to be used in some special location.
 +$contentModel: ID of the content model in question
 +$title: the Title in question.
 +&$ok: Output parameter, whether it is OK to use $contentModel on $title.
 +Handler functions that modify $ok should generally return false to prevent further
 +hooks from further modifying $ok.
 +
  'ConvertContent': Called by AbstractContent::convert when a conversion to another
  content model is requested.
  $content: The Content object to be converted.
@@@ -908,9 -899,8 +908,9 @@@ $new: the ?new= param value from the ur
  
  'DiffRevisionTools': Override or extend the revision tools available from the
  diff view, i.e. undo, etc.
 -$rev: Revision object
 +$newRev: Revision object of the "new" revision
  &$links: Array of HTML links
 +$oldRev: Revision object of the "old" revision (may be null)
  
  'DiffViewHeader': Called before diff display
  $diff: DifferenceEngine object that's calling
@@@ -1967,6 -1957,12 +1967,12 @@@ $form: the PreferencesForm object. Thi
  $key: the section name
  &$legend: the legend text. Defaults to wfMessage( "prefs-$key" )->text() but may be overridden
  
+ 'PreferencesFormPreSave': Override preferences being saved
+  $formData: array of user submitted data
+  $form: PreferencesForm object, also a ContextSource
+  $user: User object with preferences to be saved set
+  &$result: boolean indicating success
  'PrefixSearchBackend': Override the title prefix search used for OpenSearch and
  AJAX search suggestions. Put results into &$results outparam and return false.
  $ns : array of int namespace keys to search in
diff --combined includes/Preferences.php
@@@ -755,12 -755,27 +755,12 @@@ class Preferences 
                        'label-raw' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay?
                );
  
 -              if ( $wgAllowUserCssPrefs ) {
 -                      $defaultPreferences['showtoc'] = array(
 -                              'type' => 'toggle',
 -                              'section' => 'rendering/advancedrendering',
 -                              'label-message' => 'tog-showtoc',
 -                      );
 -              }
                $defaultPreferences['showhiddencats'] = array(
                        'type' => 'toggle',
                        'section' => 'rendering/advancedrendering',
                        'label-message' => 'tog-showhiddencats'
                );
  
 -              if ( $wgAllowUserCssPrefs ) {
 -                      $defaultPreferences['justify'] = array(
 -                              'type' => 'toggle',
 -                              'section' => 'rendering/advancedrendering',
 -                              'label-message' => 'tog-justify',
 -                      );
 -              }
 -
                $defaultPreferences['numberheadings'] = array(
                        'type' => 'toggle',
                        'section' => 'rendering/advancedrendering',
                global $wgAllowUserCssPrefs;
  
                ## Editing #####################################
 -              if ( $wgAllowUserCssPrefs ) {
 -                      $defaultPreferences['editsection'] = array(
 -                              'type' => 'toggle',
 -                              'section' => 'editing/advancedediting',
 -                              'label-message' => 'tog-editsection',
 -                      );
 -              }
                $defaultPreferences['editsectiononrightclick'] = array(
                        'type' => 'toggle',
                        'section' => 'editing/advancedediting',
                                $user->setOption( $key, $value );
                        }
  
+                       wfRunHooks( 'PreferencesFormPreSave', array( $formData, $form, $user, &$result ) );
                        $user->saveSettings();
                }