tidy (perltidy), simplify and optimise

This commit is contained in:
John W. Krahn 2003-02-05 04:19:28 +00:00
parent a1304593e6
commit 1f305caee0

View file

@ -22,308 +22,298 @@ use WebGUI::Privilege;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::SQL; 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); 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 { sub _reorderCategories {
my ($sth, $i, $id); my $sth = WebGUI::SQL->read( 'select profileCategoryId from userProfileCategory order by sequenceNumber' );
$sth = WebGUI::SQL->read("select profileCategoryId from userProfileCategory order by sequenceNumber"); my $i = 1;
while (($id) = $sth->array) { while ( my ( $id ) = $sth->array ) {
$i++; WebGUI::SQL->write( q[update userProfileCategory set sequenceNumber='] . $i++ . q[' where profileCategoryId=] . $id );
WebGUI::SQL->write("update userProfileCategory set sequenceNumber='$i' where profileCategoryId=$id"); }
} $sth->finish;
$sth->finish;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _reorderFields { sub _reorderFields {
my ($sth, $i, $id); my ( $sth, $i, $id );
$sth = WebGUI::SQL->read("select fieldName from userProfileField where profileCategoryId=".quote($_[0])." order by sequenceNumber"); my $sth = WebGUI::SQL->read( 'select fieldName from userProfileField where profileCategoryId=' . quote( $_[ 0 ] ) . ' order by sequenceNumber' );
while (($id) = $sth->array) { my $i = 1;
$i++; while ( my ( $id ) = $sth->array ) {
WebGUI::SQL->write("update userProfileField set sequenceNumber='$i' where fieldName=".quote($id)); WebGUI::SQL->write( q[update userProfileField set sequenceNumber='] . $i++ . q[' where fieldName=] . quote( $id ) );
} }
$sth->finish; $sth->finish;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _submenu { sub _submenu {
my (%menu); tie my %menu, 'Tie::IxHash';
tie %menu, 'Tie::IxHash'; $menu{ WebGUI::URL::page( 'op=editProfileCategory' ) } = WebGUI::International::get( 490 );
$menu{WebGUI::URL::page("op=editProfileCategory")} = WebGUI::International::get(490); $menu{ WebGUI::URL::page( 'op=editProfileField' ) } = WebGUI::International::get( 491 );
$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' ) {
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=editProfileField&fid='.$session{form}{fid})} = WebGUI::International::get(787); $menu{ WebGUI::URL::page( 'op=deleteProfileField&fid=' . $session{ form }{ fid } ) } = WebGUI::International::get( 788 );
$menu{WebGUI::URL::page('op=deleteProfileField&fid='.$session{form}{fid})} = WebGUI::International::get(788);
} }
if (($session{form}{op} eq "editProfileCategory" && $session{form}{cid} ne "new") || $session{form}{op} eq "deleteProfileCategory") { 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=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=deleteProfileCategory&cid=' . $session{ form }{ cid } ) } = WebGUI::International::get( 790 );
} }
$menu{WebGUI::URL::page("op=editProfileSettings")} = WebGUI::International::get(492); $menu{ WebGUI::URL::page( 'op=editProfileSettings' ) } = WebGUI::International::get( 492 );
$menu{WebGUI::URL::page('op=manageSettings')} = WebGUI::International::get(4); $menu{ WebGUI::URL::page( 'op=manageSettings' ) } = WebGUI::International::get( 4 );
return menuWrapper($_[0],\%menu); return menuWrapper( $_[ 0 ], \%menu );
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteProfileCategory { sub www_deleteProfileCategory {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($output); return WebGUI::Privilege::vitalComponent() if $session{ form }{ cid } < 1000;
return WebGUI::Privilege::vitalComponent() if ($session{form}{cid} < 1000); my $output = '<h1>' . WebGUI::International::get( 42 ) . '</h1>'
$output = '<h1>'.WebGUI::International::get(42).'</h1>'; . WebGUI::International::get( 466 ) . '<p>'
$output .= WebGUI::International::get(466).'<p>'; . '<div align="center"><a href="' . WebGUI::URL::page( 'op=deleteProfileCategoryConfirm&cid='
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=deleteProfileCategoryConfirm&cid='.$session{form}{cid}). . $session{ form }{ cid } ) . '">' . WebGUI::International::get( 44 ) . '</a>'
'">'.WebGUI::International::get(44).'</a>'; . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . WebGUI::URL::page( 'op=editProfileSettings' ) . '">'
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.WebGUI::URL::page('op=editProfileSettings').'">'. . WebGUI::International::get( 45 ) . '</a></div>';
WebGUI::International::get(45).'</a></div>'; return _submenu( $output );
return _submenu($output);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteProfileCategoryConfirm { sub www_deleteProfileCategoryConfirm {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
return WebGUI::Privilege::vitalComponent() if ($session{form}{cid} < 1000); return WebGUI::Privilege::vitalComponent() if $session{ form }{ cid } < 1000;
WebGUI::SQL->write("delete from userProfileCategory where profileCategoryId=$session{form}{cid}"); WebGUI::SQL->write( "delete from userProfileCategory where profileCategoryId=$session{form}{cid}" );
WebGUI::SQL->write("update userProfileField set profileCategoryId=1 where profileCategoryId=$session{form}{cid}"); WebGUI::SQL->write( "update userProfileField set profileCategoryId=1 where profileCategoryId=$session{form}{cid}" );
return www_editProfileSettings(); return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteProfileField { sub www_deleteProfileField {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($output,$protected); my ( $protected ) = WebGUI::SQL->quickArray( 'select protected from userProfileField where fieldname=' . quote( $session{ form }{ fid } ) );
($protected) = WebGUI::SQL->quickArray("select protected from userProfileField where fieldname=".quote($session{form}{fid})); return WebGUI::Privilege::vitalComponent() if $protected;
return WebGUI::Privilege::vitalComponent() if ($protected); my $output = '<h1>' . WebGUI::International::get( 42 ) . '</h1>'
$output = '<h1>'.WebGUI::International::get(42).'</h1>'; . WebGUI::International::get( 467 ) . '<p>'
$output .= WebGUI::International::get(467).'<p>'; . '<div align="center"><a href="' . WebGUI::URL::page( 'op=deleteProfileFieldConfirm&fid=' . $session{ form }{ fid } )
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=deleteProfileFieldConfirm&fid='.$session{form}{fid}). . '">' . WebGUI::International::get( 44 ) . '</a>'
'">'.WebGUI::International::get(44).'</a>'; . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . WebGUI::URL::page( 'op=editProfileSettings' ) . '">'
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.WebGUI::URL::page('op=editProfileSettings').'">'. . WebGUI::International::get( 45 ) . '</a></div>';
WebGUI::International::get(45).'</a></div>'; return _submenu( $output );
return _submenu($output);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteProfileFieldConfirm { sub www_deleteProfileFieldConfirm {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($protected); my ( $protected ) = WebGUI::SQL->quickArray( 'select protected from userProfileField where fieldname=' . quote( $session{ form }{ fid } ) );
($protected) = WebGUI::SQL->quickArray("select protected from userProfileField where fieldname=".quote($session{form}{fid})); return WebGUI::Privilege::vitalComponent() if $protected;
return WebGUI::Privilege::vitalComponent() if ($protected); WebGUI::SQL->write( 'delete from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) );
WebGUI::SQL->write("delete from userProfileField where fieldName=".quote($session{form}{fid})); WebGUI::SQL->write( 'delete from userProfileData where fieldName=' . quote( $session{ form }{ fid } ) );
WebGUI::SQL->write("delete from userProfileData where fieldName=".quote($session{form}{fid})); return www_editProfileSettings();
return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editProfileCategory { sub www_editProfileCategory {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($output, $f, %data);
tie %data, 'Tie::CPHash'; tie my %data, 'Tie::CPHash';
$output = '<h1>'.WebGUI::International::get(468).'</h1>'; my $f = WebGUI::HTMLForm->new;
$f = WebGUI::HTMLForm->new; $f->hidden( 'op', 'editProfileCategorySave' );
$f->hidden("op","editProfileCategorySave"); if ( $session{ form }{ cid } ) {
if ($session{form}{cid}) { $f->hidden( 'cid', $session{ form }{ cid } );
$f->hidden("cid",$session{form}{cid}); $f->readOnly( $session{ form }{ cid }, WebGUI::International::get( 469 ) );
$f->readOnly($session{form}{cid},WebGUI::International::get(469)); %data = WebGUI::SQL->quickHash( "select * from userProfileCategory where profileCategoryId=$session{form}{cid}" );
%data = WebGUI::SQL->quickHash("select * from userProfileCategory where profileCategoryId=$session{form}{cid}");
} else {
$f->hidden("cid","new");
} }
$f->text("categoryName",WebGUI::International::get(470),$data{categoryName}); else {
$f->hidden( 'cid', 'new' );
}
$f->text( 'categoryName', WebGUI::International::get( 470 ), $data{ categoryName } );
$f->submit; $f->submit;
$output .= $f->print;
return _submenu($output); return _submenu( '<h1>' . WebGUI::International::get( 468 ) . '</h1>' . $f->print );
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editProfileCategorySave { sub www_editProfileCategorySave {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); 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 "''"); $session{ form }{ categoryName } = 'Unamed' if $session{ form }{ categoryName } eq '' or $session{ form }{ categoryName } eq q[''];
$test = eval($session{form}{categoryName}); my $test = eval $session{ form }{ categoryName };
$session{form}{categoryName} = "'".$session{form}{categoryName}."'" if ($test eq ""); $session{ form }{ categoryName } = "'$session{form}{categoryName}'" if $test eq '';
if ($session{form}{cid} eq "new") { if ( $session{ form }{ cid } eq 'new' ) {
$categoryId = getNextId("profileCategoryId"); my $categoryId = getNextId( 'profileCategoryId' );
($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) from userProfileCategory"); my ( $sequenceNumber ) = WebGUI::SQL->quickArray( 'select max(sequenceNumber) from userProfileCategory' );
WebGUI::SQL->write("insert into userProfileCategory values ($categoryId, ".quote($session{form}{categoryName}).", WebGUI::SQL->write( "insert into userProfileCategory values ($categoryId, " . quote( $session{ form }{ categoryName } )
".($sequenceNumber+1).")"); . ', ' . $sequenceNumber + 1 . ')' );
} else { }
WebGUI::SQL->write("update userProfileCategory set categoryName=".quote($session{form}{categoryName})." where else {
profileCategoryId=$session{form}{cid}"); WebGUI::SQL->write( 'update userProfileCategory set categoryName=' . quote( $session{ form }{ categoryName } )
. " where profileCategoryId=$session{form}{cid}" );
} }
return www_editProfileSettings(); return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editProfileField { sub www_editProfileField {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($output, $f, %data, %hash, $key);
tie %data, 'Tie::CPHash'; tie my %data, 'Tie::CPHash';
$output = '<h1>'.WebGUI::International::get(471).'</h1>'; my $f = WebGUI::HTMLForm->new;
$f = WebGUI::HTMLForm->new; $f->hidden( 'op', 'editProfileFieldSave' );
$f->hidden("op","editProfileFieldSave"); if ( $session{ form }{ fid } ) {
if ($session{form}{fid}) { $f->hidden( 'fid', $session{ form }{ fid } );
$f->hidden("fid",$session{form}{fid}); $f->readOnly( $session{ form }{ fid }, WebGUI::International::get( 470 ) );
$f->readOnly($session{form}{fid},WebGUI::International::get(470)); %data = WebGUI::SQL->quickHash( 'select * from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) );
%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));
} }
$f->text("fieldLabel",WebGUI::International::get(472),$data{fieldLabel}); else {
$f->yesNo("visible",WebGUI::International::get(473),$data{visible}); $f->hidden( 'new', 1 );
$f->yesNo("required",WebGUI::International::get(474),$data{required}); $f->text( 'fid', WebGUI::International::get( 470 ) );
tie %hash, 'Tie::IxHash'; }
%hash = ( 'text'=>WebGUI::International::get(475), $f->text( 'fieldLabel', WebGUI::International::get( 472 ), $data{ fieldLabel } );
'textarea'=>WebGUI::International::get(476), $f->yesNo( 'visible', WebGUI::International::get( 473 ), $data{ visible } );
'HTMLArea'=>WebGUI::International::get(477), $f->yesNo( 'required', WebGUI::International::get( 474 ), $data{ required } );
'url'=>WebGUI::International::get(478), tie my %hash, 'Tie::IxHash';
'date'=>WebGUI::International::get(479), my %hash = (
'email'=>WebGUI::International::get(480), 'text' => WebGUI::International::get( 475 ),
'phone'=>WebGUI::International::get(481), 'textarea' => WebGUI::International::get( 476 ),
'integer'=>WebGUI::International::get(482), 'HTMLArea' => WebGUI::International::get( 477 ),
'yesNo'=>WebGUI::International::get(483), 'url' => WebGUI::International::get( 478 ),
'select'=>WebGUI::International::get(484) 'date' => WebGUI::International::get( 479 ),
); 'email' => WebGUI::International::get( 480 ),
$f->select("dataType",\%hash,WebGUI::International::get(486),[$data{dataType}]); 'phone' => WebGUI::International::get( 481 ),
$f->textarea("dataValues",WebGUI::International::get(487),$data{dataValues}); 'integer' => WebGUI::International::get( 482 ),
$f->textarea("dataDefault",WebGUI::International::get(488),$data{dataDefault}); '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 } );
tie %hash, 'Tie::CPHash'; tie %hash, 'Tie::CPHash';
%hash = WebGUI::SQL->buildHash("select profileCategoryId,categoryName from userProfileCategory order by categoryName"); %hash = WebGUI::SQL->buildHash( 'select profileCategoryId,categoryName from userProfileCategory order by categoryName' );
foreach $key (keys %hash) { for my $key ( keys %hash ) {
$hash{$key} = eval $hash{$key}; $hash{ $key } = eval $hash{ $key };
} }
$f->select("profileCategoryId",\%hash,WebGUI::International::get(489),[$data{profileCategoryId}]); $f->select( 'profileCategoryId', \%hash, WebGUI::International::get( 489 ), [ $data{ profileCategoryId } ] );
$f->submit; $f->submit;
$output .= $f->print;
return _submenu($output); return _submenu( '<h1>' . WebGUI::International::get( 471 ) . '</h1>' . $f->print );
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editProfileFieldSave { sub www_editProfileFieldSave {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); 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 "''"); $session{ form }{ fieldLabel } = 'Unamed' if $session{ form }{ fieldLabel } eq '' or $session{ form }{ fieldLabel } eq q[''];
$test = eval($session{form}{fieldLabel}); my $test = eval $session{ form }{ fieldLabel };
$session{form}{fieldLabel} = "'".$session{form}{fieldLabel}."'" if ($test eq ""); $session{ form }{ fieldLabel } = "'$session{form}{fieldLabel}'" if $test eq '';
if ($session{form}{new}) { if ( $session{ form }{ new } ) {
($fieldName) = WebGUI::SQL->quickArray("select count(*) from userProfileField my ( $fieldName ) = WebGUI::SQL->quickArray( 'select count(*) from userProfileField where fieldName='
where fieldName=".quote($session{form}{fid})); . quote( $session{ form }{ fid } ) );
if ($fieldName) { $session{ form }{ fid } .= '2' if $fieldName;
$session{form}{fid} .= '2'; my ( $sequenceNumber ) = WebGUI::SQL->quickArray( "select max(sequenceNumber)
} from userProfileField where profileCategoryId=$session{form}{profileCategoryId}" );
($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) WebGUI::SQL->write( 'insert into userProfileField (fieldName, sequenceNumber, protected) values ('
from userProfileField where profileCategoryId=$session{form}{profileCategoryId}"); . quote( $session{ form }{ fid } ) . ', ' . $sequenceNumber + 1 . ', 0)' );
WebGUI::SQL->write("insert into userProfileField (fieldName, sequenceNumber, protected)
values (".quote($session{form}{fid}).", ".($sequenceNumber+1).", 0)");
} }
WebGUI::SQL->write("update userProfileField set WebGUI::SQL->write( 'update userProfileField set
fieldLabel=".quote($session{form}{fieldLabel}).", fieldLabel=' . quote( $session{ form }{ fieldLabel } ) . ",
visible='$session{form}{visible}', visible='$session{form}{visible}',
required='$session{form}{required}', required='$session{form}{required}',
dataType=".quote($session{form}{dataType}).", dataType=" . quote( $session{ form }{ dataType } ) . ',
dataValues=".quote($session{form}{dataValues}).", dataValues=' . quote( $session{ form }{ dataValues } ) . ',
dataDefault=".quote($session{form}{dataDefault}).", dataDefault=' . quote( $session{ form }{ dataDefault } ) . ',
profileCategoryId=".quote($session{form}{profileCategoryId})." profileCategoryId=' . quote( $session{ form } {profileCategoryId } ) . '
where fieldName=".quote($session{form}{fid})); where fieldName=' . quote( $session{ form }{ fid } ) );
return www_editProfileSettings(); return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editProfileSettings { sub www_editProfileSettings {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless ( WebGUI::Privilege::isInGroup( 3 ) );
my ($output, $a, %category, %field, $b);
tie %category, 'Tie::CPHash'; my $output = helpIcon( 22 )
tie %field, 'Tie::CPHash'; . '<h1>' . WebGUI::International::get( 308 ) . '</h1>';
$output = helpIcon(22); my $a = WebGUI::SQL->read( 'select * from userProfileCategory order by sequenceNumber' );
$output .= '<h1>'.WebGUI::International::get(308).'</h1>';
$a = WebGUI::SQL->read("select * from userProfileCategory order by sequenceNumber"); tie my %category, 'Tie::CPHash';
while (%category = $a->hash) { while ( %category = $a->hash ) {
$output .= deleteIcon('op=deleteProfileCategory&cid='.$category{profileCategoryId}); $output .= deleteIcon( 'op=deleteProfileCategory&cid=' . $category{ profileCategoryId } )
$output .= editIcon('op=editProfileCategory&cid='.$category{profileCategoryId}); . editIcon( 'op=editProfileCategory&cid=' . $category{ profileCategoryId } )
$output .= moveUpIcon('op=moveProfileCategoryUp&cid='.$category{profileCategoryId}); . moveUpIcon( 'op=moveProfileCategoryUp&cid=' . $category{ profileCategoryId } )
$output .= moveDownIcon('op=moveProfileCategoryDown&cid='.$category{profileCategoryId}); . moveDownIcon( 'op=moveProfileCategoryDown&cid=' . $category{ profileCategoryId } )
$output .= ' <b>'; . ' <b>'
$output .= eval $category{categoryName}; . eval $category{ categoryName }
$output .= '</b><br>'; . '</b><br>';
$b = WebGUI::SQL->read("select * from userProfileField where my $b = WebGUI::SQL->read( "select * from userProfileField where
profileCategoryId=$category{profileCategoryId} order by sequenceNumber"); profileCategoryId=$category{profileCategoryId} order by sequenceNumber" );
while (%field = $b->hash) { tie my %field, 'Tie::CPHash';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; while ( %field = $b->hash ) {
$output .= deleteIcon('op=deleteProfileField&fid='.$field{fieldName}); $output .= '&nbsp;' x 5
$output .= editIcon('op=editProfileField&fid='.$field{fieldName}); . deleteIcon( 'op=deleteProfileField&fid=' . $field{ fieldName } )
$output .= moveUpIcon('op=moveProfileFieldUp&fid='.$field{fieldName}); . editIcon( 'op=editProfileField&fid=' . $field{ fieldName } )
$output .= moveDownIcon('op=moveProfileFieldDown&fid='.$field{fieldName}); . moveUpIcon( 'op=moveProfileFieldUp&fid=' . $field{ fieldName } )
$output .= ' '; . moveDownIcon( 'op=moveProfileFieldDown&fid=' . $field{ fieldName } )
$output .= eval $field{fieldLabel}; . ' '
$output .= '<br>'; . eval $field{ fieldLabel }
. '<br>';
} }
$b->finish; $b->finish;
} }
$a->finish; $a->finish;
return _submenu($output); return _submenu( $output );
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_moveProfileCategoryDown { sub www_moveProfileCategoryDown {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($id, $thisSeq); my ( $thisSeq ) = WebGUI::SQL->quickArray( "select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}" );
($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" );
($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq+1"); if ( $id ne '' ) {
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=$session{form}{cid}"); WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$id" );
WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber-1 where profileCategoryId=$id"); _reorderCategories();
_reorderCategories(); }
} return www_editProfileSettings();
return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_moveProfileCategoryUp { sub www_moveProfileCategoryUp {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($id, $thisSeq); my ( $thisSeq ) = WebGUI::SQL->quickArray( "select sequenceNumber from userProfileCategory where profileCategoryId=$session{form}{cid}" );
($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" );
($id) = WebGUI::SQL->quickArray("select profileCategoryId from userProfileCategory where sequenceNumber=$thisSeq-1"); if ( $id ne '' ) {
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=$session{form}{cid}"); WebGUI::SQL->write( "update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$id" );
WebGUI::SQL->write("update userProfileCategory set sequenceNumber=sequenceNumber+1 where profileCategoryId=$id"); _reorderCategories();
_reorderCategories(); }
} return www_editProfileSettings();
return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_moveProfileFieldDown { sub www_moveProfileFieldDown {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($id, $thisSeq, $profileCategoryId); my ( $thisSeq, $profileCategoryId ) = WebGUI::SQL->quickArray( 'select sequenceNumber,profileCategoryId from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) );
($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" );
($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq+1"); if ( $id ne '' ) {
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($session{form}{fid})); WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=' . quote( $id ) );
WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber-1 where fieldName=".quote($id)); _reorderFields( $profileCategoryId );
_reorderFields($profileCategoryId); }
} return www_editProfileSettings();
return www_editProfileSettings();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_moveProfileFieldUp { sub www_moveProfileFieldUp {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3)); return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup( 3 );
my ($id, $thisSeq, $profileCategoryId); my ( $thisSeq, $profileCategoryId ) = WebGUI::SQL->quickArray( 'select sequenceNumber,profileCategoryId from userProfileField where fieldName=' . quote( $session{ form }{ fid } ) );
($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" );
($id) = WebGUI::SQL->quickArray("select fieldName from userProfileField where profileCategoryId=$profileCategoryId and sequenceNumber=$thisSeq-1"); if ( $id ne '' ) {
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($session{form}{fid})); WebGUI::SQL->write( 'update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=' . quote( $id ) );
WebGUI::SQL->write("update userProfileField set sequenceNumber=sequenceNumber+1 where fieldName=".quote($id)); _reorderFields( $profileCategoryId );
_reorderFields($profileCategoryId); }
} return www_editProfileSettings();
return www_editProfileSettings();
} }
1; 1;