/** * @todo document */ protected function saveOptions() { global $wgAllowPrefChange; $extuser = ExternalUser::newFromUser($this); $this->loadOptions(); $dbw = wfGetDB(DB_MASTER); $insert_rows = array(); $saveOptions = $this->mOptions; // Allow hooks to abort, for instance to save to a global profile. // Reset options to default state before saving. if (!wfRunHooks('UserSaveOptions', array($this, &$saveOptions))) { return; } foreach ($saveOptions as $key => $value) { # Don't bother storing default values if (is_null(self::getDefaultOption($key)) && !($value === false || is_null($value)) || $value != self::getDefaultOption($key)) { $insert_rows[] = array('up_user' => $this->getId(), 'up_property' => $key, 'up_value' => $value); } if ($extuser && isset($wgAllowPrefChange[$key])) { switch ($wgAllowPrefChange[$key]) { case 'local': case 'message': break; case 'semiglobal': case 'global': $extuser->setPref($key, $value); } } } $dbw->delete('user_properties', array('up_user' => $this->getId()), __METHOD__); $dbw->insert('user_properties', $insert_rows, __METHOD__); }
/** * @todo document */ protected function saveOptions() { global $wgAllowPrefChange; $extuser = ExternalUser::newFromUser($this); $this->loadOptions(); // wikia change global $wgExternalSharedDB, $wgSharedDB, $wgGlobalUserProperties; if (isset($wgSharedDB)) { $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); } else { $dbw = wfGetDB(DB_MASTER); } $insert_rows = array(); $saveOptions = $this->mOptions; // Allow hooks to abort, for instance to save to a global profile. // Reset options to default state before saving. if (!wfRunHooks('UserSaveOptions', array($this, &$saveOptions))) { return; } foreach ($saveOptions as $key => $value) { # Don't bother storing default values # <Wikia> if ($this->shouldOptionBeStored($key, $value)) { $insert_rows[] = array('up_user' => $this->getId(), 'up_property' => $key, 'up_value' => $value); } # </Wikia> if ($extuser && isset($wgAllowPrefChange[$key])) { switch ($wgAllowPrefChange[$key]) { case 'local': case 'message': break; case 'semiglobal': case 'global': $extuser->setPref($key, $value); } } } $dbw->delete('user_properties', array('up_user' => $this->getId()), __METHOD__); $dbw->insert('user_properties', $insert_rows, __METHOD__); if ($extuser) { $extuser->updateUser(); } }