#!/usr/bin/perl -I. use strict; use Pos::Webtop::Web::ContentModule (); use Pos::Policy::LayeredBurrito (); use Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::DesktopWallpaper; use Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::IntranetAccessMethod; use Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::XPRDASettings; package Pos::Webtop::Web::ContentModule::UserPrefs; our @ISA = qw( Pos::Webtop::Web::ContentModule ); sub new { my $this = shift; my $class = ref($this) || $this; my ($self) = @{{@_}}{qw/self/}; if ( not defined $self ) { $self = {}; bless($self,$class); } # setup base class my %args = @_; $args{'self'} = $self; Pos::Webtop::Web::ContentModule->new( %args ); my $tb = $self->getToolBox(); my $pdb = $tb->getPolicyDb(); my $lb = Pos::Policy::LayeredBurrito->new( db=> $pdb ); $self->{'layeredBurrito'} = $lb; $self->{'policyDb'} = $pdb; return $self; } my @prefModules = qw( DesktopWallpaper IntranetAccessMethod XPRDASettings ); # returns undef if fails or invalid class sub createPrefModuleFromClassName { my $self = shift; my ($className) = @{{@_}}{qw/className/}; my $pref = undef; my $toolBox = $self->{'toolBox'}; my $lb = $self->{'layeredBurrito'}; my $pdb = $self->{'policyDb'}; # my $lb = Pos::Policy::LayeredBurrito->new( db=> $pdb ); # make sure className is valid my $cleanClassName = undef; foreach ( @prefModules ) { # this satisifes taint check $cleanClassName = $_ if $className eq $_; } if ( defined $cleanClassName ) { eval '$pref = Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::' . $cleanClassName . '->new( toolBox=> $toolBox, layeredBurrito=> $lb );'; } else { warn ref($self) . "createPrefModuleFromClassName(): className '$className' was not valid"; } return $pref; } # (pure virtual defined in Pos::Webtop::Web::ContentModule) sub main { my $self = shift; my $toolBox = $self->getToolBox(); my $client = $toolBox->getClient(); my $cgi = $toolBox->getCgi(); my $lb = $self->{'layeredBurrito'}; my $db = $toolBox->getWebtopDbReader(); my $userId = $client->getUserId(); my $page = $toolBox->getPage(); my $continueToDefaultPage = 1; my $prefModule = $cgi->param('prefModule'); defined $prefModule and $client->setPersistedValue( name=> 'prefModule', value=> $prefModule ); $prefModule = $client->getPersistedValue( name=> 'prefModule' ); if ( defined $prefModule ) { $client->repersistValues( values=> ['prefModule'] ); my $pref = $self->createPrefModuleFromClassName( className=> $prefModule ); if ( not defined $pref ) { warn ref($self) . "::main(): failed to create PrefModule $prefModule"; } if ( defined $cgi->param('reset') and $cgi->param('reset') ) { $pref->deleteUserPreference(); } else { my $embeddedHtml = $pref->getEmbeddedHtml(); if ( not $pref->isDone() ) { $page->addNavBarElement( description=> $pref->getPreferenceName() ); print $page->getHeaderHtml( title=> "User Preferences" ); #print Pos::Webtop::OcxLauncher::getLauncherHtml(tb => $toolBox); print "
\n"; print $embeddedHtml; print "
\n"; print $page->getFooterHtml(); $continueToDefaultPage = 0; } } } if ( $continueToDefaultPage ) { print $page->getHeaderHtml( title=> "User Preferences" ); #print Pos::Webtop::OcxLauncher::getLauncherHtml(tb => $toolBox); print "
\n "; my $b1 = $toolBox->createBox( title=> "Preferences", width=> "100%" ); print $b1->getHeaderHtml(); print " "; # for now we don't check if it is a policy driven ... so we don't colorize the links... my $rc = 0; foreach my $className (@prefModules) { $rc++; my $pref = $self->createPrefModuleFromClassName( className=> $className ); if ( defined $pref ) { my $text = $pref->getPreviewText(); if ( not ( defined $text and length($text) ) ) { $text = "[Click to assign]"; } my $link = ""; if ( $pref->isLocked() ) { $link = $text; } else { $link = $client->getFormGetCode( text=> $text, values=> [ { name=> "prefModule", value=> $className, } ], tagAttributes=> [ { name=> "CLASS", value=> "BOXLINK" } ] ); } my $preferenceName = $pref->getPreferenceName(); my $cc = ( $rc % 2 ? "BOXTD2" : "BOXTD3" ); print " "; } else { warn ref($self) . "::main(): failed to create PrefModule $className: $@" } } print "
Overview:
Below are a list of preferences which are available to you. Preferences which have the 'reset' link are extensions of policies set by your organization. Clicking the reset link will remove your preference settings and revert back to the value set by your organization. Items that are black instead of blue are read only and may not be changed.
Preference Current Setting Reset
$preferenceName: $link "; if ( defined $pref->getPolicyTypeId() and ( not $pref->isLocked() ) ) { # we make the reset link print $client->getFormGetCode( text=> "Reset", values=> [ { name=> "reset", value=> 1 }, { name=> "prefModule", value=> $className } ], tagAttributes=> [ { name=> "CLASS", value=> "BOXLINK" } ] ); } else { print ' '; } print "
"; print $b1->getFooterHtml(); print "
\n"; my $b2 = $toolBox->createBox( title=> "User Information", width=>"100%" ); print $b2->getHeaderHtml(); $client->setPersistedValue( name=> 'refreshModule', value=> "UserPrefs" ); my $userInfoLink = $client->getFormGetCode( href=> "reg.pl", text=> "Change My User Info", values => [ { name=> "nostep", value => "1" }, { name=> "userInfoPreferences", value=> "1" } ], tagAttributes=> [ { name=> "CLASS", value=> "BOXLINK" } ] ); my $passwdLink = $client->getFormGetCode( href=> "reg.pl", text=> "Change My Password", values => [ { name=> "passwdPreferences", value=> "1" }, { name => "nostep", value => "1" }, { name => "reqoldpass", value => "1" } ], tagAttributes=> [ { name=> "CLASS", value=> "BOXLINK" } ] ); my $secretQuestionAnswerLink = $client->getFormGetCode( href=> "reg.pl", text=> "Change My Secret Question/Answer", values => [ { name => "secretQuestion", value => "1" }, { name => "userPrefsUpdate", value => "1" }, { name => "nostep", value => "1" } ], tagAttributes=> [ { name=> "CLASS", value=> "BOXLINK" } ] ); my $isSupportAccount = $client->isSupportAccount( db=> $db, userId=> $userId ); print " "; if (!$isSupportAccount && $client->canUserChangePassword( db=> $db, userId=>$userId) ) { print " "; } print "
Click below to update any of your personal information, including your email address" . ($isSupportAccount ? " and phone number." : ", phone number, password, and secret question/answer pair." ) . "
Personal Info: $userInfoLink
Password: $passwdLink
Secret Question/Answer: $secretQuestionAnswerLink
"; print $b2->getFooterHtml(); print "
\n "; print $page->getFooterHtml(); } return 1; } # (pure virtual defined in Pos::Webtop::Web::ContentModule) sub getPreviewHtml { my $self = shift; my $ret = undef; my $toolBox = $self->getToolBox(); my $client = $toolBox->getClient(); my $cgi = $toolBox->getCgi(); $ret = $self->getPreviewHeader(); $ret .= "
" . $client->getFormGetCode( values => [ { name => 'module', value => 'UserPrefs' } ], text => "
User Preferences" ) . "
"; $ret .= $self->getPreviewFooter(); return $ret; } 1;