Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check theme on input and output

  • Loading branch information...
commit 076248941c5d436ee2e7b51fb7b4c8cd1e4f9d39 1 parent abbd8e3
@pudge pudge authored
Showing with 24 additions and 9 deletions.
  1. +24 −9 plugins/Journal/journal.pl
View
33 plugins/Journal/journal.pl
@@ -401,8 +401,7 @@ sub displayArticle {
}
push @sorted_articles, $collection;
- my $theme = $slashdb->getUser($uid, 'journal_theme');
- $theme ||= $constants->{journal_default_theme};
+ my $theme = _checkTheme($slashdb->getUser($uid, 'journal_theme'));
my $show_discussion = $form->{id} && !$constants->{journal_no_comments_item} && $discussion;
my $zoo = getObject('Slash::Zoo');
@@ -425,10 +424,13 @@ sub setPrefs {
my($journal, $constants, $user, $form, $slashdb) = @_;
my %prefs;
- for my $name (qw(journal_discuss journal_theme)) {
- $prefs{$name} = $user->{$name} = $form->{$name}
- if defined $form->{$name};
- }
+ $prefs{journal_discuss} = $user->{journal_discuss} =
+ $form->{journal_discuss}
+ if defined $form->{journal_discuss};
+
+ $prefs{journal_theme} = $user->{journal_theme} =
+ _checkTheme($form->{journal_theme})
+ if defined $form->{journal_theme};
$slashdb->setUser($user->{uid}, \%prefs);
@@ -445,7 +447,7 @@ sub listArticle {
my $list = $journal->list($uid);
my $themes = $journal->themes;
- my $theme = $user->{'journal_theme'} || $constants->{journal_default_theme};
+ my $theme = _checkTheme($user->{'journal_theme'});
my $nickname = $form->{uid}
? $slashdb->getUser($form->{uid}, 'nickname')
: $user->{nickname};
@@ -637,8 +639,7 @@ sub editArticle {
commentcount => $commentcount,
};
- my $theme = $user->{'journal_theme'};
- $theme ||= $constants->{journal_default_theme};
+ my $theme = _checkTheme($user->{'journal_theme'});
my $zoo = getObject('Slash::Zoo');
slashDisplay($theme, {
articles => [{ day => $article->{date}, article => [ $disp_article ] }],
@@ -686,6 +687,20 @@ sub _printHead {
slashDisplay("journalhead", { title => $title });
}
+sub _checkTheme {
+ my($theme) = @_;
+
+ my $constants = getCurrentStatic();
+ return $constants->{journal_default_theme} if !$theme;
+
+ my $journal = getObject('Slash::Journal');
+ my $themes = $journal->themes;
+
+ return $constants->{journal_default_theme}
+ unless grep $_ eq $theme, @$themes;
+ return $theme;
+}
+
createEnvironment();
main();
Please sign in to comment.
Something went wrong with that request. Please try again.