/** * Allows users to select which Motif to use * * @route my/preferences */ public function preferences() { if (!$this->isLoggedIn()) { \Airship\redirect($this->airship_cabin_prefix); } $prefs = $this->acct->getUserPreferences($this->getActiveUserId()); $cabins = []; $motifs = []; foreach ($this->getCabinNamespaces() as $cabin) { $cabins[] = $cabin; $filename = ROOT . '/tmp/cache/' . $cabin . '.motifs.json'; if (\file_exists($filename)) { $motifs[$cabin] = \Airship\loadJSON($filename); } else { $motifs[$cabin] = []; } } $post = $this->post(PreferencesFilter::fromConfig($cabins, $motifs)); if (!empty($post)) { if ($this->savePreferences($post['prefs'], $cabins, $motifs)) { \Airship\redirect($this->airship_cabin_prefix . '/my/preferences'); } } $this->lens('preferences', ['prefs' => $prefs, 'motifs' => $motifs]); }