/** * Save a user's preferences * * @param array $prefs * @param array $cabins * @param array $motifs * @return bool */ protected function savePreferences(array $prefs = [], array $cabins = [], array $motifs = []) : bool { // Validate the motifs foreach ($prefs['motif'] as $cabin => $selectedMotif) { if (!\in_array($cabin, $cabins)) { unset($prefs['motif'][$cabin]); continue; } if (empty($selectedMotif)) { $prefs['motif'][$cabin] = null; continue; } list($supplier, $motifName) = \explode('/', $selectedMotif); if (!$this->findMotif($motifs[$cabin], $supplier, $motifName)) { $prefs['motif'][$cabin] = null; continue; } } if ($this->acct->updatePreferences($this->getActiveUserId(), $prefs)) { $this->storeLensVar('post_response', ['message' => \__('Preferences saved successfully.'), 'status' => 'success']); return true; } return false; }