From 3c0d65ac10c3a73e4195038015c8179174f81f9b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 6 Feb 2003 01:36:40 +0000 Subject: [PATCH] Fixed a the perltidy problem. --- lib/WebGUI/Operation/Group.pm | 398 ++++++++++---------- lib/WebGUI/Operation/International.pm | 476 +++++++++++++----------- lib/WebGUI/Operation/ProfileSettings.pm | 431 ++++++++++----------- 3 files changed, 670 insertions(+), 635 deletions(-) diff --git a/lib/WebGUI/Operation/Group.pm b/lib/WebGUI/Operation/Group.pm index 7a8d99b8d..150f28927 100644 --- a/lib/WebGUI/Operation/Group.pm +++ b/lib/WebGUI/Operation/Group.pm @@ -28,267 +28,271 @@ use WebGUI::SQL; use WebGUI::URL; use WebGUI::Utility; -our @ISA = qw(Exporter); -our @EXPORT = qw(&www_manageUsersInGroup &www_deleteGroup &www_deleteGroupConfirm &www_editGroup -&www_editGroupSave &www_listGroups &www_emailGroup &www_emailGroupSend &www_manageGroupsInGroup -&www_addGroupsToGroupSave &www_deleteGroupGrouping); +our @ISA = qw(Exporter); +our @EXPORT = qw(&www_manageUsersInGroup &www_deleteGroup &www_deleteGroupConfirm &www_editGroup + &www_editGroupSave &www_listGroups &www_emailGroup &www_emailGroupSend &www_manageGroupsInGroup + &www_addGroupsToGroupSave &www_deleteGroupGrouping); #------------------------------------------------------------------- sub _submenu { - tie my %menu, 'Tie::IxHash'; - $menu{ WebGUI::URL::page( 'op=editGroup&gid=new' ) } = WebGUI::International::get( 90 ); - unless ( $session{ form }{ op } eq 'listGroups' - or $session{ form }{ gid } eq 'new' - or $session{ form }{ op } eq 'deleteGroupConfirm' ) - { - $menu{ WebGUI::URL::page( 'op=editGroup&gid=' . $session{ form }{ gid } ) } = WebGUI::International::get( 753 ); - $menu{ WebGUI::URL::page( 'op=manageUsersInGroup&gid=' . $session{ form }{ gid } ) } = WebGUI::International::get( 754 ); - $menu{ WebGUI::URL::page( 'op=manageGroupsInGroup&gid=' . $session{ form }{ gid } ) } = WebGUI::International::get( 807 ); - $menu{ WebGUI::URL::page( 'op=emailGroup&gid=' . $session{ form }{ gid } ) } = WebGUI::International::get( 808 ); - $menu{ WebGUI::URL::page( 'op=deleteGroup&gid=' . $session{ form }{ gid } ) } = WebGUI::International::get( 806 ); - } - $menu{ WebGUI::URL::page( 'op=listGroups' ) } = WebGUI::International::get( 756 ); - return menuWrapper( $_[ 0 ], \%menu ); + my ($output, %menu); + tie %menu, 'Tie::IxHash'; + $menu{WebGUI::URL::page('op=editGroup&gid=new')} = WebGUI::International::get(90); + unless ($session{form}{op} eq "listGroups" + || $session{form}{gid} eq "new" + || $session{form}{op} eq "deleteGroupConfirm") { + $menu{WebGUI::URL::page("op=editGroup&gid=".$session{form}{gid})} = WebGUI::International::get(753); + $menu{WebGUI::URL::page("op=manageUsersInGroup&gid=".$session{form}{gid})} = WebGUI::International::get(754); + $menu{WebGUI::URL::page("op=manageGroupsInGroup&gid=".$session{form}{gid})} = WebGUI::International::get(807); + $menu{WebGUI::URL::page("op=emailGroup&gid=".$session{form}{gid})} = WebGUI::International::get(808); + $menu{WebGUI::URL::page("op=deleteGroup&gid=".$session{form}{gid})} = WebGUI::International::get(806); + } + $menu{WebGUI::URL::page("op=listGroups")} = WebGUI::International::get(756); + return menuWrapper($_[0],\%menu); } #------------------------------------------------------------------- sub www_addGroupsToGroupSave { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my @groups = $session{ cgi }->param( 'groups' ); - WebGUI::Grouping::addGroupsToGroups( \@groups, [ $session{ form }{ gid } ] ); - return www_manageGroupsInGroup(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my (@groups, $group); + @groups = $session{cgi}->param('groups'); + WebGUI::Grouping::addGroupsToGroups(\@groups,[$session{form}{gid}]); + return www_manageGroupsInGroup(); } #------------------------------------------------------------------- sub www_deleteGroup { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ gid } < 26; - my $output = helpIcon( 15 ) - . '

' . WebGUI::International::get( 42 ) . '

' - . WebGUI::International::get( 86 ) . '

' - . '

' . WebGUI::International::get( 44 ) . '' - . '    ' - . WebGUI::International::get( 45 ) . '
'; - return _submenu( $output ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output); + return WebGUI::Privilege::vitalComponent() if ($session{form}{gid} < 26); + $output .= helpIcon(15); + $output .= '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(86).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '    ' + .WebGUI::International::get(45).'
'; + return _submenu($output); } #------------------------------------------------------------------- sub www_deleteGroupConfirm { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ gid } < 26; - my $g = WebGUI::Group->new( $session{ form }{ gid } ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + return WebGUI::Privilege::vitalComponent() if ($session{form}{gid} < 26); + my $g = WebGUI::Group->new($session{form}{gid}); $g->delete; - return www_listGroups(); + return www_listGroups(); } #------------------------------------------------------------------- sub www_deleteGroupGrouping { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - WebGUI::Grouping::deleteGroupsFromGroups( [ $session{ form }{ delete } ], [ $session{ form }{ gid } ] ); - return www_manageGroupsInGroup(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + WebGUI::Grouping::deleteGroupsFromGroups([$session{form}{delete}],[$session{form}{gid}]); + return www_manageGroupsInGroup(); } #------------------------------------------------------------------- sub www_editGroup { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $g = ( $session{ form }{ gid } eq 'new' ) - ? WebGUI::Group->new( '' ) - : WebGUI::Group->new( $session{ form }{ gid } ); - - my $f = WebGUI::HTMLForm->new; - $f->hidden( 'op', 'editGroupSave' ); - $f->hidden( 'gid', $session{ form }{ gid } ); - $f->readOnly( $g->groupId, WebGUI::International::get( 379 ) ); - $f->text( 'groupName', WebGUI::International::get( 84 ), $g->name ); - $f->textarea( 'description', WebGUI::International::get( 85 ), $g->description ); - $f->interval( 'expireOffset', WebGUI::International::get( 367 ), WebGUI::DateTime::secondsToInterval( $g->expireOffset ) ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $f, $g); + if ($session{form}{gid} eq "new") { + $g = WebGUI::Group->new(""); + } else { + $g = WebGUI::Group->new($session{form}{gid}); + } + $output .= helpIcon(17); + $output .= '

'.WebGUI::International::get(87).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","editGroupSave"); + $f->hidden("gid",$session{form}{gid}); + $f->readOnly($g->groupId,WebGUI::International::get(379)); + $f->text("groupName",WebGUI::International::get(84),$g->name); + $f->textarea("description",WebGUI::International::get(85),$g->description); + $f->interval("expireOffset",WebGUI::International::get(367), WebGUI::DateTime::secondsToInterval($g->expireOffset)); $f->yesNo( - -name => 'expireNotify', - -value => $g->expireNotify, - -label => WebGUI::International::get( 865 ) - ); + -name=>"expireNotify", + -value=>$g->expireNotify, + -label=>WebGUI::International::get(865) + ); $f->integer( - -name => 'expireNotifyOffset', - -value => $g->expireNotifyOffset, - -label => WebGUI::International::get( 864 ) - ); - $f->textarea( - -name => 'expireNotifyMessage', - -value => $g->expireNotifyMessage, - -label => WebGUI::International::get( 866 ) - ); - $f->integer( - -name => 'deleteOffset', - -value => $g->deleteOffset, - -label => WebGUI::International::get( 863 ) - ); - $f->integer( 'karmaThreshold', WebGUI::International::get( 538 ), $g->karmaThreshold ) if $session{ setting }{ useKarma }; + -name=>"expireNotifyOffset", + -value=>$g->expireNotifyOffset, + -label=>WebGUI::International::get(864) + ); + $f->textarea( + -name=>"expireNotifyMessage", + -value=>$g->expireNotifyMessage, + -label=>WebGUI::International::get(866) + ); + $f->integer( + -name=>"deleteOffset", + -value=>$g->deleteOffset, + -label=>WebGUI::International::get(863) + ); + if ($session{setting}{useKarma}) { + $f->integer("karmaThreshold",WebGUI::International::get(538),$g->karmaThreshold); + } $f->text( - -name => 'ipFilter', - -value => $g->ipFilter, - -label => WebGUI::International::get( 857 ) - ); + -name=>"ipFilter", + -value=>$g->ipFilter, + -label=>WebGUI::International::get(857) + ); $f->submit; - - return _submenu( helpIcon( 17 ) . '

' . WebGUI::International::get( 87 ) . '

' . $f->print ); + $output .= $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_editGroupSave { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my $g = WebGUI::Group->new( $session{ form }{ gid } ); - $g->description( $session{ form }{ description } ); - $g->name( $session{ form }{ groupName } ); - $g->expireOffset( WebGUI::DateTime::intervalToSeconds( $session{ form }{ expireOffset_interval }, $session{ form }{ expireOffset_units } ) ); - $g->karmaThreshold( $session{ form }{ karmaThreshold } ); - $g->ipFilter( $session{ form }{ ipFilter } ); - $g->expireNotify( $session{ form }{ expireNotify } ); - $g->expireNotifyOffset( $session{ form }{ expireNotifyOffset } ); - $g->expireNotifyMessage( $session{ form }{ expireNotifyMessage } ); - $g->deleteOffset( $session{ form }{ deleteOffset } ); - return www_listGroups(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my $g = WebGUI::Group->new($session{form}{gid}); + $g->description($session{form}{description}); + $g->name($session{form}{groupName}); + $g->expireOffset(WebGUI::DateTime::intervalToSeconds($session{form}{expireOffset_interval},$session{form}{expireOffset_units})); + $g->karmaThreshold($session{form}{karmaThreshold}); + $g->ipFilter($session{form}{ipFilter}); + $g->expireNotify($session{form}{expireNotify}); + $g->expireNotifyOffset($session{form}{expireNotifyOffset}); + $g->expireNotifyMessage($session{form}{expireNotifyMessage}); + $g->deleteOffset($session{form}{deleteOffset}); + return www_listGroups(); } #------------------------------------------------------------------- sub www_emailGroup { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $f = WebGUI::HTMLForm->new; - $f->hidden( 'op', 'emailGroupSend' ); - $f->hidden( 'gid', $session{ form }{ gid } ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output,$f); + $output = '

'.WebGUI::International::get(809).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","emailGroupSend"); + $f->hidden("gid",$session{form}{gid}); $f->email( - -name => 'from', - -value => $session{ setting }{ companyEmail }, - -label => WebGUI::International::get( 811 ) - ); + -name=>"from", + -value=>$session{setting}{companyEmail}, + -label=>WebGUI::International::get(811) + ); $f->text( - -name => 'subject', - -label => WebGUI::International::get( 229 ) - ); + -name=>"subject", + -label=>WebGUI::International::get(229) + ); $f->textarea( - -name => 'message', - -label => WebGUI::International::get( 230 ), - -rows => ( 5 + $session{ setting }{ textAreaRows } ) - ); - $f->submit( WebGUI::International::get( 810 ) ); - - return _submenu( '

' . WebGUI::International::get( 809 ) . '

' . $f->print ); + -name=>"message", + -label=>WebGUI::International::get(230), + -rows=>(5+$session{setting}{textAreaRows}) + ); + $f->submit(WebGUI::International::get(810)); + $output = $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_emailGroupSend { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $sth = WebGUI::SQL->read( "select b.fieldData from groupings a left join userProfileData b - on a.userId=b.userId and b.fieldName='email' where a.groupId=$session{form}{gid}" ); - while ( my ( $email ) = $sth->array ) { - next if $email eq ''; - WebGUI::Mail::send( $email, $session{ form }{ subject }, $session{ form }{ message }, '', $session{ form }{ from } ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($sth, $email); + $sth = WebGUI::SQL->read("select b.fieldData from groupings a left join userProfileData b + on a.userId=b.userId and b.fieldName='email' where a.groupId=$session{form}{gid}"); + while (($email) = $sth->array) { + if ($email ne "") { + WebGUI::Mail::send($email,$session{form}{subject},$session{form}{message},'',$session{form}{from}); + } } $sth->finish; - return _submenu( WebGUI::International::get( 812 ) ); + return _submenu(WebGUI::International::get(812)); } #------------------------------------------------------------------- sub www_listGroups { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $sth = WebGUI::SQL->read( 'select groupId,groupName,description from groups - where groupId<>1 and groupId<>2 and groupId<>7 order by groupName' ); - - my @row; - while ( my @data = $sth->array ) { - my ( $userCount ) = WebGUI::SQL->quickArray( "select count(*) from groupings where groupId=$data[0]" ); - push @row, '' - . '' . $data[ 1 ] . '' - . '' . $data[ 2 ] . '' - . '' . $userCount . '' - . ''; - } + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $p, $sth, @data, @row, $i, $userCount); + $output = helpIcon(10); + $output .= '

'.WebGUI::International::get(89).'

'; + $sth = WebGUI::SQL->read("select groupId,groupName,description from groups + where groupId<>1 and groupId<>2 and groupId<>7 order by groupName"); + while (@data = $sth->array) { + $row[$i] = ''; + $row[$i] .= '
'.$data[1].''; + $row[$i] .= ''.$data[2].''; + ($userCount) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId=$data[0]"); + $row[$i] .= ''.$userCount.''; + $row[$i] .= ''; + $i++; + } $sth->finish; - - my $p = WebGUI::Paginator->new( WebGUI::URL::page( 'op=listGroups' ), \@row ); - - my $output = helpIcon( 10 ) - . '

' . WebGUI::International::get( 89 ) . '

' - . '' - . '' - . $p->getPage( $session{ form }{ pn } ) - . '
' . WebGUI::International::get( 84 ) . '' - . WebGUI::International::get( 85 ) . '' - . WebGUI::International::get( 748 ) . '
' - . $p->getBarTraditional( $session{ form }{ pn } ); - return _submenu( $output ); + $p = WebGUI::Paginator->new(WebGUI::URL::page('op=listGroups'),\@row); + $output .= ''; + $output .= ''; + $output .= $p->getPage($session{form}{pn}); + $output .= '
'.WebGUI::International::get(84).'' + .WebGUI::International::get(85).'' + .WebGUI::International::get(748).'
'; + $output .= $p->getBarTraditional($session{form}{pn}); + return _submenu($output); } #------------------------------------------------------------------- sub www_manageGroupsInGroup { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $f = WebGUI::HTMLForm->new; - $f->hidden( 'op', 'addGroupsToGroupSave' ); - $f->hidden( 'gid', $session{ form }{ gid } ); - my $groups = WebGUI::Grouping::getGroupsInGroup( $session{ form }{ gid } ); - push @$groups, $session{ form }{ gid }; - $f->group( - -name => 'groups', - -excludeGroups => $groups, - -label => WebGUI::International::get( 605 ), - -size => 5, - -multiple => 1 - ); - $f->submit; - - my $output = '

' . WebGUI::International::get( 813 ) . '

' - . $f->print . '

' - . ''; - - my $p = WebGUI::Paginator->new( WebGUI::URL::page( 'op=manageGroupsInGroup' ) ); - $p->setDataByQuery( "select a.groupName as name,a.groupId as id from groups a + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $p, $group, $groups, $f); + $output = '

'.WebGUI::International::get(813).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","addGroupsToGroupSave"); + $f->hidden("gid",$session{form}{gid}); + $groups = WebGUI::Grouping::getGroupsInGroup($session{form}{gid}); + push(@$groups,$session{form}{gid}); + $f->group( + -name=>"groups", + -excludeGroups=>$groups, + -label=>WebGUI::International::get(605), + -size=>5, + -multiple=>1 + ); + $f->submit; + $output .= $f->print; + $output .= '

' . WebGUI::International::get( 84 ) . '
'; + $output .= ''; + $p = WebGUI::Paginator->new(WebGUI::URL::page('op=manageGroupsInGroup')); + $p->setDataByQuery("select a.groupName as name,a.groupId as id from groups a left join groupGroupings b on a.groupId=b.groupId - where b.inGroup=$session{form}{gid} order by a.groupName" ); + where b.inGroup=$session{form}{gid} order by a.groupName"); $groups = $p->getPageData; - for my $group ( @$groups ) { + foreach $group (@$groups) { $output .= ''; + .deleteIcon('op=deleteGroupGrouping&gid='.$session{form}{gid}.'&delete='.$group->{id}) + .''; } - $output .= '
'.WebGUI::International::get(84).'
' - . deleteIcon( 'op=deleteGroupGrouping&gid=' . $session{ form }{ gid } . '&delete=' . $group->{ id } ) - . '' . $group->{ name } . '
' + .$group->{name}.'
' . $p->getBarTraditional; - return _submenu( $output ); + $output .= ''; + $output .= $p->getBarTraditional; + return _submenu($output); } #------------------------------------------------------------------- sub www_manageUsersInGroup { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $output = '

' . WebGUI::International::get( 88 ) . '

'; - . ''; - - my $sth = WebGUI::SQL->read( "select users.username,users.userId,groupings.expireDate + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $sth, %hash); + tie %hash, 'Tie::CPHash'; + $output = '

'.WebGUI::International::get(88).'

'; + $output .= '
 ' - . WebGUI::International::get( 50 ) . '' - . WebGUI::International::get( 369 ) . '
+ + '; + $sth = WebGUI::SQL->read("select users.username,users.userId,groupings.expireDate from groupings,users where groupings.groupId=$session{form}{gid} and groupings.userId=users.userId - order by users.username" ); - - tie my %hash, 'Tie::CPHash'; - while ( %hash = $sth->hash ) { - $output .= '' - . '' - . ''; - } - $sth->finish; - $output .= '
 '.WebGUI::International::get(50).''.WebGUI::International::get(369).'
' - . deleteIcon( 'op=deleteGrouping&uid=' . $hash{ userId } . '&gid=' . $session{ form }{ gid } ) - . editIcon( 'op=editGrouping&uid=' . $hash{ userId } . '&gid=' . $session{ form }{ gid } ) - . '' - . $hash{ username } . '' . epochToHuman( $hash{ expireDate }, '%z' ) . '
'; - return _submenu( $output ); + order by users.username"); + while (%hash = $sth->hash) { + $output .= '' + .deleteIcon('op=deleteGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid}) + .editIcon('op=editGrouping&uid='.$hash{userId}.'&gid='.$session{form}{gid}) + .''; + $output .= '
' + .$hash{username}.''; + $output .= ''.epochToHuman($hash{expireDate},"%z").''; + } + $sth->finish; + $output .= ''; + return _submenu($output); } -1; +1; diff --git a/lib/WebGUI/Operation/International.pm b/lib/WebGUI/Operation/International.pm index 3b75a6d03..3453dc898 100644 --- a/lib/WebGUI/Operation/International.pm +++ b/lib/WebGUI/Operation/International.pm @@ -24,313 +24,335 @@ use WebGUI::Session; use WebGUI::SQL; use WebGUI::URL; -our @ISA = qw(Exporter); -our @EXPORT = qw(&www_listLanguages &www_editLanguage &www_submitTranslation &www_submitTranslationConfirm -&www_deleteLanguage &www_deleteLanguageConfirm &www_addInternationalMessage &www_addInternationalMessageSave -&www_listInternationalMessages &www_editLanguageSave &www_editInternationalMessage -&www_exportTranslation &www_editInternationalMessageSave ); +our @ISA = qw(Exporter); +our @EXPORT = qw(&www_listLanguages &www_editLanguage &www_submitTranslation &www_submitTranslationConfirm + &www_deleteLanguage &www_deleteLanguageConfirm &www_addInternationalMessage &www_addInternationalMessageSave + &www_listInternationalMessages &www_editLanguageSave &www_editInternationalMessage + &www_exportTranslation &www_editInternationalMessageSave ); #------------------------------------------------------------------- sub _export { - tie my %data, 'Tie::CPHash'; - %data = WebGUI::SQL->quickHash( 'select * from language where languageId=' . $_[ 0 ] ); - my $export = '#Exported from ' . $session{ setting }{ companyName } . ' (http://' . $session{ env }{ SERVER_NAME } . ') by ' - . $session{ user }{ username } . ' (' . $session{ user }{ email } . ")\n" - . '#' . $data{ language } . ' translation export for WebGUI ' . $WebGUI::VERSION . ".\n\n" - . "#language\n\n" - . 'delete from language where languageId=' . $_[ 0 ] . ";\n" - . 'insert into language (languageId,language,characterSet,toolbar) values (' - . $data{ languageId } . ', ' . quote( $data{ language } ) . ', ' . quote( $data{ characterSet } ) . ', ' - . quote( $data{ toolbar } ) . ");\n" - . "\n#international messages\n\n"; - my $sth = WebGUI::SQL->read( 'select * from international where languageId=' . $_[ 0 ] . ' order by lastUpdated desc' ); - - while ( %data = $sth->hash ) { - $export .= 'delete from international where languageId=' . $_[ 0 ] . ' and namespace=' - . quote( $data{ namespace } ) . ' and internationalId=' . $data{ internationalId } . ";\n" - . 'insert into international (internationalId,languageId,namespace,message,lastUpdated) values (' - . $data{ internationalId } . ',' . $data{ languageId } . ',' . quote( $data{ namespace } ) - . ',' . quote( $data{ message } ) . ', ' . $data{ lastUpdated } . ");\n"; - } - $sth->finish; + my ($sth, %data, $export); + tie %data, 'Tie::CPHash'; + %data = WebGUI::SQL->quickHash("select * from language where languageId=".$_[0]); + $export = "#Exported from ".$session{setting}{companyName}." (http://".$session{env}{SERVER_NAME}.") by " + .$session{user}{username}." (".$session{user}{email}.")\n"; + $export .= "#".$data{language}." translation export for WebGUI ".$WebGUI::VERSION.".\n\n"; + $export .= "#language\n\n"; + $export .= "delete from language where languageId=".$_[0].";\n"; + $export .= "insert into language (languageId,language,characterSet,toolbar) values (" + .$data{languageId}.", ".quote($data{language}).", ".quote($data{characterSet}).", " + .quote($data{toolbar}).");\n"; + $export .= "\n#international messages\n\n"; + $sth = WebGUI::SQL->read("select * from international where languageId=".$_[0]." order by lastUpdated desc"); + while (%data = $sth->hash) { + $export .= "delete from international where languageId=".$_[0]." and namespace=" + .quote($data{namespace})." and internationalId=".$data{internationalId}.";\n"; + $export .= "insert into international (internationalId,languageId,namespace,message,lastUpdated) values (" + .$data{internationalId}.",".$data{languageId}.",".quote($data{namespace}) + .",".quote($data{message}).", ".$data{lastUpdated}.");\n"; + } + $sth->finish; return $export; } #------------------------------------------------------------------- sub _submenu { - tie my %menu, 'Tie::IxHash'; - $menu{ WebGUI::URL::page( 'op=editLanguage&lid=new' ) } = WebGUI::International::get( 584 ); - if ( $session{ form }{ lid } == 1 ) { - $menu{ WebGUI::URL::page( 'op=addInternationalMessage&lid=1' ) } = 'Add a new message.'; + my (%menu); + tie %menu, 'Tie::IxHash'; + $menu{WebGUI::URL::page('op=editLanguage&lid=new')} = WebGUI::International::get(584); + if ($session{form}{lid} == 1) { + $menu{WebGUI::URL::page('op=addInternationalMessage&lid=1')} = "Add a new message."; } - if ( $session{ form }{ lid } ne 'new' && $session{ form }{ lid } ne '' ) { - $menu{ WebGUI::URL::page( 'op=listInternationalMessages&lid=' . $session{ form }{ lid } ) } = - WebGUI::International::get( 594 ); - $menu{ WebGUI::URL::page( 'op=exportTranslation&lid=' . $session{ form }{ lid } ) } = WebGUI::International::get( 718 ); - $menu{ WebGUI::URL::page( 'op=submitTranslation&lid=' . $session{ form }{ lid } ) } = WebGUI::International::get( 593 ); - $menu{ WebGUI::URL::page( 'op=editLanguage&lid=' . $session{ form }{ lid } ) } = WebGUI::International::get( 598 ); - $menu{ WebGUI::URL::page( 'op=deleteLanguage&lid=' . $session{ form }{ lid } ) } = WebGUI::International::get( 791 ); - } - $menu{ WebGUI::URL::page( 'op=listLanguages' ) } = WebGUI::International::get( 585 ); - return menuWrapper( $_[ 0 ], \%menu ); + if ($session{form}{lid} ne "new" && $session{form}{lid} ne "") { + $menu{WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid})} = + WebGUI::International::get(594); + $menu{WebGUI::URL::page('op=exportTranslation&lid='.$session{form}{lid})} = WebGUI::International::get(718); + $menu{WebGUI::URL::page('op=submitTranslation&lid='.$session{form}{lid})} = WebGUI::International::get(593); + $menu{WebGUI::URL::page('op=editLanguage&lid='.$session{form}{lid})} = WebGUI::International::get(598); + $menu{WebGUI::URL::page("op=deleteLanguage&lid=".$session{form}{lid})} = WebGUI::International::get(791); + } + $menu{WebGUI::URL::page('op=listLanguages')} = WebGUI::International::get(585); + return menuWrapper($_[0],\%menu); } #------------------------------------------------------------------- sub www_addInternationalMessage { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my $output = '

Add English Message

'; - my $namespace = $session{ wobject }; - $namespace->{ WebGUI } = 'WebGUI'; - $namespace = { %{ $namespace }, map { 'Auth/' . $_ => 'Authentication: ' . $session{ authentication }->{ $_ } } keys %{ $session{ authentication } } }; - my $f = WebGUI::HTMLForm->new(); - $f->hidden( 'lid', 1 ); - $f->hidden( 'op', 'addInternationalMessageSave' ); - $f->select( 'namespace', $namespace, 'Namespace', [ 'WebGUI' ] ); - $f->textarea( 'message', 'Message' ); + my ($output,$f,$namespace); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + $output = '

Add English Message

'; + $namespace = $session{wobject}; + $namespace->{WebGUI} = 'WebGUI'; + $namespace = {%{$namespace}, map {'Auth/'.$_ => 'Authentication: '.$session{authentication}->{$_}} keys(%{$session{authentication}})}; + $f = WebGUI::HTMLForm->new(); + $f->hidden("lid",1); + $f->hidden("op","addInternationalMessageSave"); + $f->select("namespace",$namespace,"Namespace",['WebGUI']); + $f->textarea("message","Message"); $f->submit; $output .= $f->print; - return _submenu( $output ); + return _submenu($output); } #------------------------------------------------------------------- sub www_addInternationalMessageSave { - my ( $nextId ) = WebGUI::SQL->quickArray( 'select max(internationalId) from international where languageId=1 - and namespace=' . quote( $session{ form }{ namespace } ) ); + my ($nextId); + ($nextId) = WebGUI::SQL->quickArray("select max(internationalId) from international where languageId=1 + and namespace=".quote($session{form}{namespace})); $nextId++; - WebGUI::SQL->write( "insert into international (languageId, internationalId, namespace, message, lastUpdated) values - (1,$nextId," . quote( $session{ form }{ namespace } ) . ',' . quote( $session{ form }{ message } ) . ',' . time() . ')' ); - return "Message was added with id $nextId." . www_listInternationalMessages(); + WebGUI::SQL->write("insert into international (languageId, internationalId, namespace, message, lastUpdated) values + (1,$nextId,".quote($session{form}{namespace}).",".quote($session{form}{message}).",".time().")"); + return "Message was added with id $nextId.".www_listInternationalMessages(); } #------------------------------------------------------------------- sub www_deleteLanguage { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ lid } < 1000 and $session{ form }{ lid } > 0; - my $output = '

' . WebGUI::International::get( 42 ) . '

' - . WebGUI::International::get( 587 ) . '

' - . '

' . WebGUI::International::get( 44 ) . '' - . '    ' . WebGUI::International::get( 45 ) . '
'; - return _submenu( $output ); + my ($output); + return WebGUI::Privilege::vitalComponent() if ($session{form}{lid} < 1000 && $session{form}{lid} > 0); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + $output .= '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(587).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '    '.WebGUI::International::get(45).'
'; + return _submenu($output); } #------------------------------------------------------------------- sub www_deleteLanguageConfirm { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ lid } < 1000 and $session{ form }{ lid } > 0; - WebGUI::SQL->write( 'delete from language where languageId=' . $session{ form }{ lid } ); - WebGUI::SQL->write( 'delete from international where languageId=' . $session{ form }{ lid } ); - WebGUI::SQL->write( q[delete from userProfileData where fieldName='language' and fieldData=] . $session{ form }{ lid } ); - $session{ form }{ lid } = ''; - return www_listLanguages(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + return WebGUI::Privilege::vitalComponent() if ($session{form}{lid} < 1000 && $session{form}{lid} > 0); + WebGUI::SQL->write("delete from language where languageId=".$session{form}{lid}); + WebGUI::SQL->write("delete from international where languageId=".$session{form}{lid}); + WebGUI::SQL->write("delete from userProfileData where fieldName='language' and fieldData=".$session{form}{lid}); + $session{form}{lid} = ""; + return www_listLanguages(); } #------------------------------------------------------------------- sub www_editInternationalMessage { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $language ) = WebGUI::SQL->quickArray( 'select language from language where languageId=' . $session{ form }{ lid } ); - my $output = '

' . WebGUI::International::get( 597 ) . '

'; - my $f = WebGUI::HTMLForm->new; - $f->readOnly( $session{ form }{ iid }, WebGUI::International::get( 601 ) ); - $f->hidden( 'lid', $session{ form }{ lid } ); - $f->hidden( 'status', $session{ form }{ status } ); - $f->hidden( 'iid', $session{ form }{ iid } ); - $f->hidden( 'pn', $session{ form }{ pn } ); - $f->hidden( 'namespace', $session{ form }{ namespace } ); - $f->hidden( 'op', 'editInternationalMessageSave' ); - my ( $message ) = WebGUI::SQL->quickArray( 'select message from international where internationalId=' . $session{ form }{ iid } - . q[ and namespace='] . $session{ form }{ namespace } . q[' and languageId=] . $session{ form }{ lid } ); - $f->textarea( 'message', $language, $message ); - $f->submit; - ( $message ) = WebGUI::SQL->quickArray( 'select message from international where internationalId=' . $session{ form }{ iid } - . q[ and namespace='] . $session{ form }{ namespace } . q[' and languageId=1] ); - $f->readOnly( $message, 'English' ); - $output .= $f->print; - return _submenu( $output ); + my ($output, $message, $f, $language); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + ($language) = WebGUI::SQL->quickArray("select language from language where languageId=".$session{form}{lid}); + $output = '

'.WebGUI::International::get(597).'

'; + $f = WebGUI::HTMLForm->new; + $f->readOnly($session{form}{iid},WebGUI::International::get(601)); + $f->hidden("lid",$session{form}{lid}); + $f->hidden("status",$session{form}{status}); + $f->hidden("iid",$session{form}{iid}); + $f->hidden("pn",$session{form}{pn}); + $f->hidden("namespace",$session{form}{namespace}); + $f->hidden("op","editInternationalMessageSave"); + ($message) = WebGUI::SQL->quickArray("select message from international where internationalId=".$session{form}{iid}." + and namespace='".$session{form}{namespace}."' and languageId=".$session{form}{lid}); + $f->textarea("message",$language,$message); + $f->submit; + ($message) = WebGUI::SQL->quickArray("select message from international where internationalId=".$session{form}{iid}." + and namespace='".$session{form}{namespace}."' and languageId=1"); + $f->readOnly($message,"English"); + $output .= $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_editInternationalMessageSave { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - if ( $session{ form }{ status } eq 'missing' ) { - WebGUI::SQL->write( 'insert into international (message,namespace,languageId,internationalId,lastUpdated) values (' - . quote( $session{ form }{ message } ) . ',' . quote( $session{ form }{ namespace } ) - . ',' . $session{ form }{ lid } . ',' . $session{ form }{ iid } . ', ' . time() . ')' ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + if ($session{form}{status} eq "missing") { + WebGUI::SQL->write("insert into international (message,namespace,languageId,internationalId,lastUpdated) + values (".quote($session{form}{message}).",".quote($session{form}{namespace}) + .",".$session{form}{lid}.",".$session{form}{iid}.", ".time().")"); + } else { + WebGUI::SQL->write("update international set message=".quote($session{form}{message}).", lastUpdated=" + .time()." where namespace=".quote($session{form}{namespace})." + and languageId=".$session{form}{lid}." and internationalId=".$session{form}{iid}); } - else { - WebGUI::SQL->write( 'update international set message=' . quote( $session{ form }{ message } ) - . ', lastUpdated=' . time() . ' where namespace=' . quote( $session{ form }{ namespace } ) - . ' and languageId=' . $session{ form }{ lid } . ' and internationalId=' . $session{ form }{ iid } ); - } - return www_listInternationalMessages(); + return www_listInternationalMessages(); } #------------------------------------------------------------------- sub www_editLanguage { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - my $dir = $session{ config }{ extrasPath } . $session{ os }{ slash } . 'toolbar'; - opendir my $dh, $dir or WebGUI::ErrorHandler::warn( "Can't open toolbar directory $dir: $!" ); - my @files = grep !/^\.\.?$/, readdir $dh; - closedir $dh; - - my %options; - @options{ @files } = @files; - - tie my %data, 'Tie::CPHash'; - if ( $session{ form }{ lid } eq 'new' ) { - $data{ characterSet } = 'ISO-8859-1'; - $data{ toolbar } = 'default'; + my ($output, $dir, @files, $file, %data, $f, %options); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + tie %data, 'Tie::CPHash'; + $dir = $session{config}{extrasPath}.$session{os}{slash}."toolbar"; + opendir (DIR,$dir) or WebGUI::ErrorHandler::warn("Can't open toolbar directory!"); + @files = readdir(DIR); + foreach $file (@files) { + if ($file ne ".." && $file ne ".") { + $options{$file} = $file; + } + } + closedir(DIR); + if ($session{form}{lid} eq "new") { + $data{characterSet} = "ISO-8859-1"; + $data{toolbar} = "default"; + } else { + %data = WebGUI::SQL->quickHash("select * from language where languageId=".$session{form}{lid}); } - else { - %data = WebGUI::SQL->quickHash( 'select * from language where languageId=' . $session{ form }{ lid } ); - } - my $f = WebGUI::HTMLForm->new; - $f->readOnly( $session{ form }{ lid }, WebGUI::International::get( 590 ) ); - $f->hidden( 'lid', $session{ form }{ lid } ); - $f->hidden( 'op', 'editLanguageSave' ); - $f->text( 'language', WebGUI::International::get( 591 ), $data{ language } ); - $f->text( 'characterSet', WebGUI::International::get( 592 ), $data{ characterSet } ); - $f->select( 'toolbar', \%options, WebGUI::International::get( 746 ), [ $data{ toolbar } ] ); + $output = '

'.WebGUI::International::get(589).'

'; + $f = WebGUI::HTMLForm->new; + $f->readOnly($session{form}{lid},WebGUI::International::get(590)); + $f->hidden("lid",$session{form}{lid}); + $f->hidden("op","editLanguageSave"); + $f->text("language",WebGUI::International::get(591),$data{language}); + $f->text("characterSet",WebGUI::International::get(592),$data{characterSet}); + $f->select("toolbar",\%options,WebGUI::International::get(746),[$data{toolbar}]); $f->submit; - return _submenu( '

' . WebGUI::International::get( 589 ) . '

' . $f->print ); + $output .= $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_editLanguageSave { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - if ( $session{ form }{ lid } eq 'new' ) { - $session{ form }{ lid } = getNextId( 'languageId' ); - WebGUI::SQL->write( "insert into language (languageId) values ($session{form}{lid})" ); - } - WebGUI::SQL->write( 'update language set language=' . quote( $session{ form }{ language } ) - . ', characterSet=' . quote( $session{ form }{ characterSet } ) . ', toolbar=' . quote( $session{ form }{ toolbar } ) - . ' where languageId=' . $session{ form }{ lid } ); - return www_editLanguage(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + if ($session{form}{lid} eq "new") { + $session{form}{lid} = getNextId("languageId"); + WebGUI::SQL->write("insert into language (languageId) values ($session{form}{lid})"); + } + WebGUI::SQL->write("update language set language=".quote($session{form}{language}).", + characterSet=".quote($session{form}{characterSet}).", toolbar=".quote($session{form}{toolbar})." + where languageId=".$session{form}{lid}); + return www_editLanguage(); } #------------------------------------------------------------------- sub www_exportTranslation { - $session{ header }{ mimetype } = 'text/plain'; - return _export( $session{ form }{ lid } ); + $session{header}{mimetype} = 'text/plain'; + return _export($session{form}{lid}); } #------------------------------------------------------------------- sub www_listInternationalMessages { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - tie my %data, 'Tie::CPHash'; - %data = WebGUI::SQL->quickHash( 'select language from language where languageId=' . $session{ form }{ lid } ); - - my $missing = '' . WebGUI::International::get( 596 ) . ''; - my $outOfDate = '' . WebGUI::International::get( 719 ) . ''; - my $ok = WebGUI::International::get( 720 ); - my $deprecated = WebGUI::International::get( 723 ); - my $output = '

' . WebGUI::International::get( 595 ) . ' (' . $data{ language } . ')

'; - my $f = WebGUI::HTMLForm->new( 1 ); - $f->hidden( 'op', 'listInternationalMessages' ); - $f->hidden( 'lid', $session{ form }{ lid } ); - $f->text( 'search', '', $session{ form }{ search } ); - $f->submit( 'search' ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $sth, $key, $p, $search, $status,%data, %list, $deprecated, $i, $missing, @row, $f, $outOfDate, $ok); + tie %data, 'Tie::CPHash'; + %data = WebGUI::SQL->quickHash("select language from language where languageId=".$session{form}{lid}); + $missing = ''.WebGUI::International::get(596).''; + $outOfDate = ''.WebGUI::International::get(719).''; + $ok = WebGUI::International::get(720); + $deprecated = WebGUI::International::get(723); + $output = '

'.WebGUI::International::get(595).' ('.$data{language}.')

'; + $f = WebGUI::HTMLForm->new(1); + $f->hidden("op","listInternationalMessages"); + $f->hidden("lid",$session{form}{lid}); + $f->text("search","",$session{form}{search}); + $f->submit("search"); $output .= $f->print; - - my $search = ' and message like ' . quote( '%' . $session{ form }{ search } . '%' ) - if $session{ form }{ search } ne ''; - my $sth = WebGUI::SQL->read( 'select * from international where languageId=' . $session{ form }{ lid } . $search ); - my %list; - while ( %data = $sth->hash ) { - @{ $list{ "z-$data{namespace}-$data{internationalId}" } }{ qw[id namespace message lastUpdated status] } - = ( @data{ qw[internationalId namespace message lastUpdated] }, 'deleted' ); + if ($session{form}{search} ne "") { + $search = " and message like ".quote("%".$session{form}{search}."%"); } - $sth->finish; - - $sth = WebGUI::SQL->read( 'select * from international where languageId=1' ); - while ( %data = $sth->hash ) { - my $key = $data{ namespace } . '-' . $data{ internationalId }; - if ( $list{ 'z-' . $key } ) { - if ( $list{ 'z-' . $key }{ lastUpdated } < $data{ lastUpdated } ) { - $list{ 'o-' . $key } = delete $list{ 'z-' . $key }; - $list{ 'o-' . $key }{ status } = 'updated'; - } - else { - $list{ 'q-' . $key } = delete $list{ 'z-' . $key }; - $list{ 'q-' . $key }{ status } = 'ok'; + $sth = WebGUI::SQL->read("select * from international where languageId=".$session{form}{lid}.$search); + while (%data = $sth->hash) { + $list{"z-".$data{namespace}."-".$data{internationalId}}{id} = $data{internationalId}; + $list{"z-".$data{namespace}."-".$data{internationalId}}{namespace} = $data{namespace}; + $list{"z-".$data{namespace}."-".$data{internationalId}}{message} = $data{message}; + $list{"z-".$data{namespace}."-".$data{internationalId}}{lastUpdated} = $data{lastUpdated}; + $list{"z-".$data{namespace}."-".$data{internationalId}}{status} = "deleted"; + } + $sth->finish; + $sth = WebGUI::SQL->read("select * from international where languageId=1"); + while (%data = $sth->hash) { + $key = $data{namespace}."-".$data{internationalId}; + if ($session{form}{search} ne "") { + if ($list{"z-".$key}) { + if ($list{"z-".$key}{lastUpdated} < $data{lastUpdated}) { + $list{"o-".$key} = $list{"z-".$key}; + delete($list{"z-".$key}); + $list{"o-".$key}{status} = "updated"; + } else { + $list{"q-".$key} = $list{"z-".$key}; + delete($list{"z-".$key}); + $list{"q-".$key}{status} = "ok"; + } + } + } else { + unless ($list{"z-".$key}) { + $list{"a-".$key}{namespace} = $data{namespace}; + $list{"a-".$key}{id} = $data{internationalId}; + $list{"a-".$key}{status} = "missing"; + } else { + if ($list{"z-".$key}{lastUpdated} < $data{lastUpdated}) { + $list{"o-".$key} = $list{"z-".$key}; + delete($list{"z-".$key}); + $list{"o-".$key}{status} = "updated"; + } else { + $list{"q-".$key} = $list{"z-".$key}; + delete($list{"z-".$key}); + $list{"q-".$key}{status} = "ok"; + } } } - elsif ( $session{ form }{ search } eq '' ) { - @{ $list{ 'a-' . $key } }{ qw[namespace id status] } - = ( @data{ qw[namespace internationalId] }, 'missing' ); - } - } - $sth->finish; - - my @row; - for my $key ( sort keys %list ) { - my $status = $ok; - if ( $list{ $key }{ status } eq 'updated' ) { + } + $sth->finish; + foreach $key (sort {$a cmp $b} keys %list) { + if ($list{$key}{status} eq "updated") { $status = $outOfDate; - } - elsif ( $list{ $key }{ status } eq 'missing' ) { + } elsif ($list{$key}{status} eq "missing") { $status = $missing; - } - elsif ( $list{ $key }{ status } eq 'deleted' ) { + } elsif ($list{$key}{status} eq "deleted") { $status = $deprecated; + } else { + $status = $ok; } - push @row, '' . $status . '' - . editIcon( 'op=editInternationalMessage&lid=' . $session{ form }{ lid } - . '&iid=' . $list{ $key }{ id } . '&namespace=' . $list{ $key }{ namespace } . '&pn=' . $session{ form }{ pn } - . '&status=' . $list{ $key }{ status } ) . '' . $list{ $key }{ namespace } . '' - . $list{ $key }{ id } . '' . $list{ $key }{ message } . "\n"; - } - my $p = WebGUI::Paginator->new( WebGUI::URL::page( 'op=listInternationalMessages&lid=' . $session{ form }{ lid } ), \@row, 100 ); - - $output .= $p->getBarTraditional( $session{ form }{ pn } ) - . '' - . '' - . $p->getPage( $session{ form }{ pn } ) - . '
' . WebGUI::International::get( 434 ) . '' - . WebGUI::International::get( 575 ) . '' . WebGUI::International::get( 721 ) - . '' . WebGUI::International::get( 722 ) - . '' . WebGUI::International::get( 230 ) . '
' - . $p->getBarTraditional( $session{ form }{ pn } ); - return _submenu( $output ); + $row[$i] = ''.$status."" + .editIcon('op=editInternationalMessage&lid='.$session{form}{lid} + .'&iid='.$list{$key}{id}.'&namespace='.$list{$key}{namespace}.'&pn='.$session{form}{pn} + ."&status=".$list{$key}{status})."".$list{$key}{namespace}."" + .$list{$key}{id}."".$list{$key}{message}."\n"; + $i++; + } + $p = WebGUI::Paginator->new(WebGUI::URL::page('op=listInternationalMessages&lid='.$session{form}{lid}),\@row,100); + $output .= $p->getBarTraditional($session{form}{pn}); + $output .= ''; + $output .= ''; + $output .= $p->getPage($session{form}{pn}); + $output .= '
'.WebGUI::International::get(434).''. + WebGUI::International::get(575).''.WebGUI::International::get(721) + .''.WebGUI::International::get(722) + .''.WebGUI::International::get(230).'
'; + $output .= $p->getBarTraditional($session{form}{pn}); + return _submenu($output); } #------------------------------------------------------------------- sub www_listLanguages { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - tie my %data, 'Tie::CPHash'; - my $output = '

' . WebGUI::International::get( 586 ) . '

'; - my $sth = WebGUI::SQL->read( 'select languageId,language from language where languageId<>1 order by language' ); - while ( %data = $sth->hash ) { - $output .= '' . $data{ language } . '
'; + my ($output, $sth, %data); + tie %data, 'Tie::CPHash'; + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + $output = '

'.WebGUI::International::get(586).'

'; + $sth = WebGUI::SQL->read("select languageId,language from language where languageId<>1 order by language"); + while (%data = $sth->hash) { + $output .= '
'.$data{language}.'
'; } $sth->finish; - return _submenu( $output ); + return _submenu($output); } #------------------------------------------------------------------- sub www_submitTranslation { - my $output = '

' . WebGUI::International::get( 42 ) . '

' - . WebGUI::International::get( 588 ) . '

' - . '

' . WebGUI::International::get( 44 ) . '' - . '    ' . WebGUI::International::get( 45 ) . '
'; - return _submenu( $output ); + my ($output); + $output .= '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(588).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '    '.WebGUI::International::get(45).'
'; + return _submenu($output); } #------------------------------------------------------------------- sub www_submitTranslationConfirm { - WebGUI::Mail::send( 'info@plainblack.com', 'International Message Submission', _export( $session{ form }{ lid } ) ); + WebGUI::Mail::send("info\@plainblack.com","International Message Submission",_export($session{form}{lid})); return www_editLanguage(); } + + + + 1; - - diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 1d411f491..bbf9e4863 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -22,298 +22,307 @@ use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; -our @ISA = qw(Exporter); +our @ISA = qw(Exporter); our @EXPORT = qw(&www_deleteProfileCategoryConfirm &www_deleteProfileFieldConfirm &www_editProfileCategorySave &www_editProfileFieldSave &www_deleteProfileCategory &www_deleteProfileField &www_editProfileCategory &www_editProfileField &www_moveProfileCategoryDown &www_moveProfileCategoryUp &www_moveProfileFieldDown &www_moveProfileFieldUp &www_editProfileSettings); #------------------------------------------------------------------- sub _reorderCategories { - my $sth = WebGUI::SQL->read( 'select profileCategoryId from userProfileCategory order by sequenceNumber' ); - my $i = 1; - while ( my ( $id ) = $sth->array ) { - WebGUI::SQL->write( q[update userProfileCategory set sequenceNumber='] . $i++ . q[' where profileCategoryId=] . $id ); - } - $sth->finish; + my ($sth, $i, $id); + $sth = WebGUI::SQL->read("select profileCategoryId from userProfileCategory order by sequenceNumber"); + while (($id) = $sth->array) { + $i++; + WebGUI::SQL->write("update userProfileCategory set sequenceNumber='$i' where profileCategoryId=$id"); + } + $sth->finish; } #------------------------------------------------------------------- sub _reorderFields { - my ( $sth, $i, $id ); - my $sth = WebGUI::SQL->read( 'select fieldName from userProfileField where profileCategoryId=' . quote( $_[ 0 ] ) . ' order by sequenceNumber' ); - my $i = 1; - while ( my ( $id ) = $sth->array ) { - WebGUI::SQL->write( q[update userProfileField set sequenceNumber='] . $i++ . q[' where fieldName=] . quote( $id ) ); - } - $sth->finish; + my ($sth, $i, $id); + $sth = WebGUI::SQL->read("select fieldName from userProfileField where profileCategoryId=".quote($_[0])." order by sequenceNumber"); + while (($id) = $sth->array) { + $i++; + WebGUI::SQL->write("update userProfileField set sequenceNumber='$i' where fieldName=".quote($id)); + } + $sth->finish; } #------------------------------------------------------------------- sub _submenu { - tie my %menu, 'Tie::IxHash'; - $menu{ WebGUI::URL::page( 'op=editProfileCategory' ) } = WebGUI::International::get( 490 ); - $menu{ WebGUI::URL::page( 'op=editProfileField' ) } = WebGUI::International::get( 491 ); - if ( ( $session{ form }{ op } eq 'editProfileField' and $session{ form }{ fid } ne 'new' ) or $session{ form }{ op } eq 'deleteProfileField' ) { - $menu{ WebGUI::URL::page( 'op=editProfileField&fid=' . $session{ form }{ fid } ) } = WebGUI::International::get( 787 ); - $menu{ WebGUI::URL::page( 'op=deleteProfileField&fid=' . $session{ form }{ fid } ) } = WebGUI::International::get( 788 ); + my (%menu); + tie %menu, 'Tie::IxHash'; + $menu{WebGUI::URL::page("op=editProfileCategory")} = WebGUI::International::get(490); + $menu{WebGUI::URL::page("op=editProfileField")} = WebGUI::International::get(491); + if (($session{form}{op} eq "editProfileField" && $session{form}{fid} ne "new") || $session{form}{op} eq "deleteProfileField") { + $menu{WebGUI::URL::page('op=editProfileField&fid='.$session{form}{fid})} = WebGUI::International::get(787); + $menu{WebGUI::URL::page('op=deleteProfileField&fid='.$session{form}{fid})} = WebGUI::International::get(788); } - if ( ( $session{ form }{ op } eq 'editProfileCategory' and $session{ form }{ cid } ne 'new' ) or $session{ form }{ op } eq 'deleteProfileCategory' ) { - $menu{ WebGUI::URL::page( 'op=editProfileCategory&cid=' . $session{ form }{ cid } ) } = WebGUI::International::get( 789 ); - $menu{ WebGUI::URL::page( 'op=deleteProfileCategory&cid=' . $session{ form }{ cid } ) } = WebGUI::International::get( 790 ); - } - $menu{ WebGUI::URL::page( 'op=editProfileSettings' ) } = WebGUI::International::get( 492 ); - $menu{ WebGUI::URL::page( 'op=manageSettings' ) } = WebGUI::International::get( 4 ); - return menuWrapper( $_[ 0 ], \%menu ); + if (($session{form}{op} eq "editProfileCategory" && $session{form}{cid} ne "new") || $session{form}{op} eq "deleteProfileCategory") { + $menu{WebGUI::URL::page('op=editProfileCategory&cid='.$session{form}{cid})} = WebGUI::International::get(789); + $menu{WebGUI::URL::page('op=deleteProfileCategory&cid='.$session{form}{cid})} = WebGUI::International::get(790); + } + $menu{WebGUI::URL::page("op=editProfileSettings")} = WebGUI::International::get(492); + $menu{WebGUI::URL::page('op=manageSettings')} = WebGUI::International::get(4); + return menuWrapper($_[0],\%menu); } #------------------------------------------------------------------- sub www_deleteProfileCategory { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ cid } < 1000; - my $output = '

' . WebGUI::International::get( 42 ) . '

' - . WebGUI::International::get( 466 ) . '

' - . '

' . WebGUI::International::get( 44 ) . '' - . '    ' - . WebGUI::International::get( 45 ) . '
'; - return _submenu( $output ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output); + return WebGUI::Privilege::vitalComponent() if ($session{form}{cid} < 1000); + $output = '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(466).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '    '. + WebGUI::International::get(45).'
'; + return _submenu($output); } #------------------------------------------------------------------- sub www_deleteProfileCategoryConfirm { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - return WebGUI::Privilege::vitalComponent() if $session{ form }{ cid } < 1000; - WebGUI::SQL->write( "delete from userProfileCategory where profileCategoryId=$session{form}{cid}" ); - WebGUI::SQL->write( "update userProfileField set profileCategoryId=1 where profileCategoryId=$session{form}{cid}" ); - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + return WebGUI::Privilege::vitalComponent() if ($session{form}{cid} < 1000); + WebGUI::SQL->write("delete from userProfileCategory where profileCategoryId=$session{form}{cid}"); + WebGUI::SQL->write("update userProfileField set profileCategoryId=1 where profileCategoryId=$session{form}{cid}"); + return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_deleteProfileField { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $protected ) = WebGUI::SQL->quickArray( 'select protected from userProfileField where fieldname=' . quote( $session{ form }{ fid } ) ); - return WebGUI::Privilege::vitalComponent() if $protected; - my $output = '

' . WebGUI::International::get( 42 ) . '

' - . WebGUI::International::get( 467 ) . '

' - . '

' . WebGUI::International::get( 44 ) . '' - . '    ' - . WebGUI::International::get( 45 ) . '
'; - return _submenu( $output ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output,$protected); + ($protected) = WebGUI::SQL->quickArray("select protected from userProfileField where fieldname=".quote($session{form}{fid})); + return WebGUI::Privilege::vitalComponent() if ($protected); + $output = '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(467).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '    '. + WebGUI::International::get(45).'
'; + return _submenu($output); } #------------------------------------------------------------------- sub www_deleteProfileFieldConfirm { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $protected ) = WebGUI::SQL->quickArray( 'select protected from userProfileField where fieldname=' . quote( $session{ form }{ fid } ) ); - return WebGUI::Privilege::vitalComponent() if $protected; - WebGUI::SQL->write( 'delete from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) ); - WebGUI::SQL->write( 'delete from userProfileData where fieldName=' . quote( $session{ form }{ fid } ) ); - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($protected); + ($protected) = WebGUI::SQL->quickArray("select protected from userProfileField where fieldname=".quote($session{form}{fid})); + return WebGUI::Privilege::vitalComponent() if ($protected); + WebGUI::SQL->write("delete from userProfileField where fieldName=".quote($session{form}{fid})); + WebGUI::SQL->write("delete from userProfileData where fieldName=".quote($session{form}{fid})); + return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_editProfileCategory { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - tie my %data, 'Tie::CPHash'; - my $f = WebGUI::HTMLForm->new; - $f->hidden( 'op', 'editProfileCategorySave' ); - if ( $session{ form }{ cid } ) { - $f->hidden( 'cid', $session{ form }{ cid } ); - $f->readOnly( $session{ form }{ cid }, WebGUI::International::get( 469 ) ); - %data = WebGUI::SQL->quickHash( "select * from userProfileCategory where profileCategoryId=$session{form}{cid}" ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $f, %data); + tie %data, 'Tie::CPHash'; + $output = '

'.WebGUI::International::get(468).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","editProfileCategorySave"); + if ($session{form}{cid}) { + $f->hidden("cid",$session{form}{cid}); + $f->readOnly($session{form}{cid},WebGUI::International::get(469)); + %data = WebGUI::SQL->quickHash("select * from userProfileCategory where profileCategoryId=$session{form}{cid}"); + } else { + $f->hidden("cid","new"); } - else { - $f->hidden( 'cid', 'new' ); - } - $f->text( 'categoryName', WebGUI::International::get( 470 ), $data{ categoryName } ); + $f->text("categoryName",WebGUI::International::get(470),$data{categoryName}); $f->submit; - - return _submenu( '

' . WebGUI::International::get( 468 ) . '

' . $f->print ); + $output .= $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_editProfileCategorySave { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - $session{ form }{ categoryName } = 'Unamed' if $session{ form }{ categoryName } eq '' or $session{ form }{ categoryName } eq q['']; - my $test = eval $session{ form }{ categoryName }; - $session{ form }{ categoryName } = "'$session{form}{categoryName}'" if $test eq ''; - if ( $session{ form }{ cid } eq 'new' ) { - my $categoryId = getNextId( 'profileCategoryId' ); - my ( $sequenceNumber ) = WebGUI::SQL->quickArray( 'select max(sequenceNumber) from userProfileCategory' ); - WebGUI::SQL->write( "insert into userProfileCategory values ($categoryId, " . quote( $session{ form }{ categoryName } ) - . ', ' . $sequenceNumber + 1 . ')' ); - } - else { - WebGUI::SQL->write( 'update userProfileCategory set categoryName=' . quote( $session{ form }{ categoryName } ) - . " where profileCategoryId=$session{form}{cid}" ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($categoryId, $sequenceNumber, $test); + $session{form}{categoryName} = 'Unamed' if ($session{form}{categoryName} eq "" || $session{form}{categoryName} eq "''"); + $test = eval($session{form}{categoryName}); + $session{form}{categoryName} = "'".$session{form}{categoryName}."'" if ($test eq ""); + if ($session{form}{cid} eq "new") { + $categoryId = getNextId("profileCategoryId"); + ($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) from userProfileCategory"); + WebGUI::SQL->write("insert into userProfileCategory values ($categoryId, ".quote($session{form}{categoryName}).", + ".($sequenceNumber+1).")"); + } else { + WebGUI::SQL->write("update userProfileCategory set categoryName=".quote($session{form}{categoryName})." where + profileCategoryId=$session{form}{cid}"); } return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_editProfileField { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - - tie my %data, 'Tie::CPHash'; - my $f = WebGUI::HTMLForm->new; - $f->hidden( 'op', 'editProfileFieldSave' ); - if ( $session{ form }{ fid } ) { - $f->hidden( 'fid', $session{ form }{ fid } ); - $f->readOnly( $session{ form }{ fid }, WebGUI::International::get( 470 ) ); - %data = WebGUI::SQL->quickHash( 'select * from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $f, %data, %hash, $key); + tie %data, 'Tie::CPHash'; + $output = '

'.WebGUI::International::get(471).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","editProfileFieldSave"); + if ($session{form}{fid}) { + $f->hidden("fid",$session{form}{fid}); + $f->readOnly($session{form}{fid},WebGUI::International::get(470)); + %data = WebGUI::SQL->quickHash("select * from userProfileField where fieldName=".quote($session{form}{fid})); + } else { + $f->hidden("new",1); + $f->text("fid",WebGUI::International::get(470)); } - else { - $f->hidden( 'new', 1 ); - $f->text( 'fid', WebGUI::International::get( 470 ) ); - } - $f->text( 'fieldLabel', WebGUI::International::get( 472 ), $data{ fieldLabel } ); - $f->yesNo( 'visible', WebGUI::International::get( 473 ), $data{ visible } ); - $f->yesNo( 'required', WebGUI::International::get( 474 ), $data{ required } ); - tie my %hash, 'Tie::IxHash'; - my %hash = ( - 'text' => WebGUI::International::get( 475 ), - 'textarea' => WebGUI::International::get( 476 ), - 'HTMLArea' => WebGUI::International::get( 477 ), - 'url' => WebGUI::International::get( 478 ), - 'date' => WebGUI::International::get( 479 ), - 'email' => WebGUI::International::get( 480 ), - 'phone' => WebGUI::International::get( 481 ), - 'integer' => WebGUI::International::get( 482 ), - 'yesNo' => WebGUI::International::get( 483 ), - 'select' => WebGUI::International::get( 484 ) - ); - $f->selectList( 'dataType', \%hash, WebGUI::International::get( 486 ), [ $data{ dataType } ] ); - untie %hash; - $f->textarea( 'dataValues', WebGUI::International::get( 487 ), $data{ dataValues } ); - $f->textarea( 'dataDefault', WebGUI::International::get( 488 ), $data{ dataDefault } ); + $f->text("fieldLabel",WebGUI::International::get(472),$data{fieldLabel}); + $f->yesNo("visible",WebGUI::International::get(473),$data{visible}); + $f->yesNo("required",WebGUI::International::get(474),$data{required}); + tie %hash, 'Tie::IxHash'; + %hash = ( 'text'=>WebGUI::International::get(475), + 'textarea'=>WebGUI::International::get(476), + 'HTMLArea'=>WebGUI::International::get(477), + 'url'=>WebGUI::International::get(478), + 'date'=>WebGUI::International::get(479), + 'email'=>WebGUI::International::get(480), + 'phone'=>WebGUI::International::get(481), + 'integer'=>WebGUI::International::get(482), + 'yesNo'=>WebGUI::International::get(483), + 'select'=>WebGUI::International::get(484) + ); + $f->select("dataType",\%hash,WebGUI::International::get(486),[$data{dataType}]); + $f->textarea("dataValues",WebGUI::International::get(487),$data{dataValues}); + $f->textarea("dataDefault",WebGUI::International::get(488),$data{dataDefault}); tie %hash, 'Tie::CPHash'; - %hash = WebGUI::SQL->buildHash( 'select profileCategoryId,categoryName from userProfileCategory order by categoryName' ); - for my $key ( keys %hash ) { - $hash{ $key } = eval $hash{ $key }; + %hash = WebGUI::SQL->buildHash("select profileCategoryId,categoryName from userProfileCategory order by categoryName"); + foreach $key (keys %hash) { + $hash{$key} = eval $hash{$key}; } - $f->select( 'profileCategoryId', \%hash, WebGUI::International::get( 489 ), [ $data{ profileCategoryId } ] ); - $f->submit; - - return _submenu( '

' . WebGUI::International::get( 471 ) . '

' . $f->print ); + $f->select("profileCategoryId",\%hash,WebGUI::International::get(489),[$data{profileCategoryId}]); + $f->submit; + $output .= $f->print; + return _submenu($output); } #------------------------------------------------------------------- sub www_editProfileFieldSave { - return WebGUI::Privilege::adminOnly() unless ( WebGUI::Privilege::isInGroup( 3 ) ); - - $session{ form }{ fieldLabel } = 'Unamed' if $session{ form }{ fieldLabel } eq '' or $session{ form }{ fieldLabel } eq q['']; - my $test = eval $session{ form }{ fieldLabel }; - $session{ form }{ fieldLabel } = "'$session{form}{fieldLabel}'" if $test eq ''; - if ( $session{ form }{ new } ) { - my ( $fieldName ) = WebGUI::SQL->quickArray( 'select count(*) from userProfileField where fieldName=' - . quote( $session{ form }{ fid } ) ); - $session{ form }{ fid } .= '2' if $fieldName; - my ( $sequenceNumber ) = WebGUI::SQL->quickArray( "select max(sequenceNumber) - from userProfileField where profileCategoryId=$session{form}{profileCategoryId}" ); - WebGUI::SQL->write( 'insert into userProfileField (fieldName, sequenceNumber, protected) values (' - . quote( $session{ form }{ fid } ) . ', ' . $sequenceNumber + 1 . ', 0)' ); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($sequenceNumber, $fieldName, $test); + $session{form}{fieldLabel} = 'Unamed' if ($session{form}{fieldLabel} eq "" || $session{form}{fieldLabel} eq "''"); + $test = eval($session{form}{fieldLabel}); + $session{form}{fieldLabel} = "'".$session{form}{fieldLabel}."'" if ($test eq ""); + if ($session{form}{new}) { + ($fieldName) = WebGUI::SQL->quickArray("select count(*) from userProfileField + where fieldName=".quote($session{form}{fid})); + if ($fieldName) { + $session{form}{fid} .= '2'; + } + ($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) + from userProfileField where profileCategoryId=$session{form}{profileCategoryId}"); + WebGUI::SQL->write("insert into userProfileField (fieldName, sequenceNumber, protected) + values (".quote($session{form}{fid}).", ".($sequenceNumber+1).", 0)"); } - WebGUI::SQL->write( 'update userProfileField set - fieldLabel=' . quote( $session{ form }{ fieldLabel } ) . ", + WebGUI::SQL->write("update userProfileField set + fieldLabel=".quote($session{form}{fieldLabel}).", visible='$session{form}{visible}', required='$session{form}{required}', - dataType=" . quote( $session{ form }{ dataType } ) . ', - dataValues=' . quote( $session{ form }{ dataValues } ) . ', - dataDefault=' . quote( $session{ form }{ dataDefault } ) . ', - profileCategoryId=' . quote( $session{ form } {profileCategoryId } ) . ' - where fieldName=' . quote( $session{ form }{ fid } ) ); + dataType=".quote($session{form}{dataType}).", + dataValues=".quote($session{form}{dataValues}).", + dataDefault=".quote($session{form}{dataDefault}).", + profileCategoryId=".quote($session{form}{profileCategoryId})." + where fieldName=".quote($session{form}{fid})); return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_editProfileSettings { - return WebGUI::Privilege::adminOnly() unless ( WebGUI::Privilege::isInGroup( 3 ) ); - - my $output = helpIcon( 22 ) - . '

' . WebGUI::International::get( 308 ) . '

'; - my $a = WebGUI::SQL->read( 'select * from userProfileCategory order by sequenceNumber' ); - - tie my %category, 'Tie::CPHash'; - while ( %category = $a->hash ) { - $output .= deleteIcon( 'op=deleteProfileCategory&cid=' . $category{ profileCategoryId } ) - . editIcon( 'op=editProfileCategory&cid=' . $category{ profileCategoryId } ) - . moveUpIcon( 'op=moveProfileCategoryUp&cid=' . $category{ profileCategoryId } ) - . moveDownIcon( 'op=moveProfileCategoryDown&cid=' . $category{ profileCategoryId } ) - . ' ' - . eval $category{ categoryName } - . '
'; - my $b = WebGUI::SQL->read( "select * from userProfileField where - profileCategoryId=$category{profileCategoryId} order by sequenceNumber" ); - tie my %field, 'Tie::CPHash'; - while ( %field = $b->hash ) { - $output .= ' ' x 5 - . deleteIcon( 'op=deleteProfileField&fid=' . $field{ fieldName } ) - . editIcon( 'op=editProfileField&fid=' . $field{ fieldName } ) - . moveUpIcon( 'op=moveProfileFieldUp&fid=' . $field{ fieldName } ) - . moveDownIcon( 'op=moveProfileFieldDown&fid=' . $field{ fieldName } ) - . ' ' - . eval $field{ fieldLabel } - . '
'; + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($output, $a, %category, %field, $b); + tie %category, 'Tie::CPHash'; + tie %field, 'Tie::CPHash'; + $output = helpIcon(22); + $output .= '

'.WebGUI::International::get(308).'

'; + $a = WebGUI::SQL->read("select * from userProfileCategory order by sequenceNumber"); + while (%category = $a->hash) { + $output .= deleteIcon('op=deleteProfileCategory&cid='.$category{profileCategoryId}); + $output .= editIcon('op=editProfileCategory&cid='.$category{profileCategoryId}); + $output .= moveUpIcon('op=moveProfileCategoryUp&cid='.$category{profileCategoryId}); + $output .= moveDownIcon('op=moveProfileCategoryDown&cid='.$category{profileCategoryId}); + $output .= ' '; + $output .= eval $category{categoryName}; + $output .= '
'; + $b = WebGUI::SQL->read("select * from userProfileField where + profileCategoryId=$category{profileCategoryId} order by sequenceNumber"); + while (%field = $b->hash) { + $output .= '     '; + $output .= deleteIcon('op=deleteProfileField&fid='.$field{fieldName}); + $output .= editIcon('op=editProfileField&fid='.$field{fieldName}); + $output .= moveUpIcon('op=moveProfileFieldUp&fid='.$field{fieldName}); + $output .= moveDownIcon('op=moveProfileFieldDown&fid='.$field{fieldName}); + $output .= ' '; + $output .= eval $field{fieldLabel}; + $output .= '
'; } $b->finish; } $a->finish; - return _submenu( $output ); + return _submenu($output); } #------------------------------------------------------------------- sub www_moveProfileCategoryDown { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $thisSeq ) = WebGUI::SQL->quickArray( "select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}" ); - my ( $id ) = WebGUI::SQL->quickArray( "select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq+1" ); - if ( $id ne '' ) { - WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$session{form}{cid}" ); - WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$id" ); - _reorderCategories(); - } - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($id, $thisSeq); + ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}"); + ($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq+1"); + if ($id ne "") { + WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$session{form}{cid}"); + WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$id"); + _reorderCategories(); + } + return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_moveProfileCategoryUp { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $thisSeq ) = WebGUI::SQL->quickArray( "select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}" ); - my ( $id ) = WebGUI::SQL->quickArray( "select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq-1" ); - if ( $id ne '' ) { - WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$session{form}{cid}" ); - WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$id" ); - _reorderCategories(); - } - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($id, $thisSeq); + ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}"); + ($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq-1"); + if ($id ne "") { + WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$session{form}{cid}"); + WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$id"); + _reorderCategories(); + } + return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_moveProfileFieldDown { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $thisSeq, $profileCategoryId ) = WebGUI::SQL->quickArray( 'select sequenceNumber,profileCategoryId from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) ); - my ( $id ) = WebGUI::SQL->quickArray( "select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq+1" ); - if ( $id ne '' ) { - WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=' . quote( $session{ form }{ fid } ) ); - WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=' . quote( $id ) ); - _reorderFields( $profileCategoryId ); - } - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($id, $thisSeq, $profileCategoryId); + ($thisSeq,$profileCategoryId) = WebGUI::SQL->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".quote($session{form}{fid})); + ($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq+1"); + if ($id ne "") { + WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".quote($session{form}{fid})); + WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".quote($id)); + _reorderFields($profileCategoryId); + } + return www_editProfileSettings(); } #------------------------------------------------------------------- sub www_moveProfileFieldUp { - return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 ); - my ( $thisSeq, $profileCategoryId ) = WebGUI::SQL->quickArray( 'select sequenceNumber,profileCategoryId from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) ); - my ( $id ) = WebGUI::SQL->quickArray( "select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq-1" ); - if ( $id ne '' ) { - WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=' . quote( $session{ form }{ fid } ) ); - WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=' . quote( $id ) ); - _reorderFields( $profileCategoryId ); - } - return www_editProfileSettings(); + return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); + my ($id, $thisSeq, $profileCategoryId); + ($thisSeq,$profileCategoryId) = WebGUI::SQL->quickArray("select sequenceNumber,profileCategoryId from userProfileField where fieldName=".quote($session{form}{fid})); + ($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq-1"); + if ($id ne "") { + WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".quote($session{form}{fid})); + WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".quote($id)); + _reorderFields($profileCategoryId); + } + return www_editProfileSettings(); } -1; + + +1;