/**
  * Saves the settings submitted by the settings form. Redirects the user to the destination
  * of returnto or, if not set, back to this special page
  */
 private function submitSettingsForm()
 {
     $schema = 'MobileOptionsTracking';
     $schemaRevision = 14003392;
     $schemaData = array('action' => 'success', 'images' => "nochange", 'beta' => "nochange");
     $context = MobileContext::singleton();
     $request = $this->getRequest();
     $user = $this->getUser();
     if ($user->isLoggedIn() && !$user->matchEditToken($request->getVal('token'))) {
         $errorText = __METHOD__ . '(): token mismatch';
         wfIncrStats('mobile.options.errors');
         wfDebugLog('mobile', $errorText);
         $this->getOutput()->addHTML('<div class="error">' . $this->msg("mobile-frontend-save-error")->parse() . '</div>');
         $schemaData['action'] = 'error';
         $schemaData['errorText'] = $errorText;
         ExtMobileFrontend::eventLog($schema, $schemaRevision, $schemaData);
         $this->getSettingsForm();
         return;
     }
     wfIncrStats('mobile.options.saves');
     if ($request->getBool('enableBeta')) {
         $group = 'beta';
         if (!$context->isBetaGroupMember()) {
             // The request was to turn on beta
             $schemaData['beta'] = "on";
         }
     } else {
         $group = '';
         if ($context->isBetaGroupMember()) {
             // beta was turned off
             $schemaData['beta'] = "off";
         }
     }
     $context->setMobileMode($group);
     $imagesDisabled = !$request->getBool('enableImages');
     if ($context->imagesDisabled() !== $imagesDisabled) {
         // Only record when the state has changed
         $schemaData['images'] = $imagesDisabled ? "off" : "on";
     }
     $context->setDisableImagesCookie($imagesDisabled);
     $returnToTitle = Title::newFromText($request->getText('returnto'));
     if ($returnToTitle) {
         $url = $returnToTitle->getFullURL();
     } else {
         $url = $this->getPageTitle()->getFullURL('success');
     }
     ExtMobileFrontend::eventLog($schema, $schemaRevision, $schemaData);
     $context->getOutput()->redirect(MobileContext::singleton()->getMobileUrl($url));
 }