Parley
view release on metacpan or search on metacpan
lib/Parley/Controller/My.pm view on Meta::CPAN
$c->session->{show_pref_tab} = 'tab_' . $c->request->param('tab');
$c->log->warn( $c->session->{show_pref_tab} );
}
# formfill/stash data
if ('UTC' eq $c->_authed_user()->preference()->timezone()) {
$c->stash->{formdata}{use_utc} = 1;
}
else {
$c->stash->{formdata}{selectZone}
= $c->_authed_user()->preference()->timezone();
}
# time format
if (defined $c->_authed_user()->preference()->time_format()) {
$c->stash->{formdata}{time_format} =
$c->_authed_user()->preference()->time_format()->id();
}
# show tz?
$c->stash->{formdata}{show_tz}
= $c->_authed_user()->preference()->show_tz();
# watched threads
my $watches = $c->model('ParleyDB')->resultset('ThreadView')->search(
{
person_id => $c->_authed_user()->id(),
watched => 1,
},
{
order_by => [\'last_post.created DESC'],
join => {
'thread' => 'last_post',
},
}
);
$c->stash->{thread_watches} = $watches;
# skin
$c->stash->{formdata}{skin}
= (
$c->_authed_user()->preference()->skin()
or
$c->config->{site_skin}
or
q{base}
)
;
$c->log->debug('pref-site-skin: ' . $c->stash->{formdata}{skin});
return;
}
sub update :Path('/my/preferences/update') {
my ($self, $c) = @_;
my $form_name = $c->request->param('form_name');
# use the my/preferences template
$c->stash->{template} = 'my/preferences';
# make sure the form name matches something we have a DFV profile for
if (not exists $dfv_profile_for{ $form_name }) {
# if there's no form, detach back to prefs
if ($form_name =~ m{\A\s*\z}xms) {
$c->response->redirect( $c->uri_for('/my/preferences') );
return;
}
# otherwise notify user about the unknown form
parley_warn(
$c,
$c->localize(qq{No Such Form})
. qq{: $form_name}
);
return;
}
# validate the specified form
$c->form(
$dfv_profile_for{ $form_name }
);
# are we updating TZ preferences?
my $ok_update;
if ('time_format' eq $form_name) {
# return to the right tab
# use session flash, or we lose the info with the redirect
$c->session->{show_pref_tab} = 'tab_time';
$ok_update = $self->_process_form_time_format( $c );
}
# are we updating notification preferences?
elsif ('notifications' eq $form_name) {
# return to the right tab
# use session flash, or we lose the info with the redirect
$c->session->{show_pref_tab} = 'tab_notifications';
$ok_update = $self->_process_form_notifications( $c );
}
# are we updating the skin
elsif ('skin' eq $form_name) {
# return to the right tab
# use session flash, or we lose the info with the redirect
$c->session->{show_pref_tab} = 'tab_skin';
$ok_update = $self->_process_form_skin( $c );
}
# are we updating the avatar
elsif ('user_avatar' eq $form_name) {
# return to the right tab
# use session flash, or we lose the info with the redirect
$c->session->{show_pref_tab} = 'tab_avatar';
$ok_update = $self->_process_form_avatar( $c );
}
# otherwise we haven't decided how to handle the specified form ...
else {
$c->stash->{error}{message} = "don't know how to handle: $form_name";
return;
}
if ($ok_update) {
( run in 2.157 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )