From a8c99a2b9c25e8af104c2f0e06bdc286ea3b2ac3 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Thu, 8 Dec 2005 03:17:48 +0000 Subject: [PATCH] lots of changes. --- lib/WebGUI/Asset/Shortcut.pm | 264 +++++++++++----------- lib/WebGUI/Asset/Wobject/Dashboard.pm | 24 +- lib/WebGUI/ErrorHandler.pm | 29 +-- lib/WebGUI/HTTP.pm | 11 +- lib/WebGUI/Operation.pm | 2 +- lib/WebGUI/Operation/Profile.pm | 1 + lib/WebGUI/Operation/ProfileSettings.pm | 1 + lib/WebGUI/Operation/User.pm | 2 + lib/WebGUI/ProfileField.pm | 3 +- lib/WebGUI/User.pm | 4 +- lib/WebGUI/i18n/English/Asset_Shortcut.pm | 32 ++- 11 files changed, 209 insertions(+), 164 deletions(-) diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index e0114d320..59350e25a 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -11,9 +11,13 @@ package WebGUI::Asset::Shortcut; #------------------------------------------------------------------- use strict; +use Tie::IxHash; use WebGUI::Asset; use WebGUI::Icon; use WebGUI::International; +use WebGUI::Operation::Profile; +use WebGUI::ProfileField; +use WebGUI::ProfileCategory; use WebGUI::Macro; use WebGUI::Privilege; use WebGUI::Session; @@ -123,19 +127,6 @@ sub _drawQueryBuilder { return $output; } -sub parseOverride { - my $self = shift; - my $value = shift; - my @userPrefs = $self->getUserPrefs; - foreach my $field (@userPrefs) { - my $id = $field->getId; - my $fieldName = $field->getFieldName; - use WebGUI::Asset::Field; - my $fieldValue = WebGUI::Asset::Field->getUserPref($id); - $value =~ s/\#\#userPref\:${fieldName}\#\#/$fieldValue/g; - } -} - #------------------------------------------------------------------- sub _submenu { my $self = shift; @@ -147,14 +138,13 @@ sub _submenu { $ac->setIcon($self->getIcon); $ac->addSubmenuItem($self->getUrl('func=edit'), WebGUI::International::get("Back to Edit Shortcut","Asset_Shortcut")); $ac->addSubmenuItem($self->getUrl("func=manageOverrides"),WebGUI::International::get("Manage Shortcut Overrides","Asset_Shortcut")); - $ac->addSubmenuItem($self->getUrl("func=manageUserPrefs"),WebGUI::International::get("Manage User Preferences","Asset_Shortcut")); return $ac->render($workarea, $title); } #------------------------------------------------------------------- sub canEdit { my $self = shift; -return 1 if ($self->SUPER::canEdit || (ref $self->getParent eq 'WebGUI::Asset::Wobject::Dashboard' && $self->getParent->canManage)); +return 1 if ($self->SUPER::canEdit || ($self->isDashlet && $self->getParent->canManage)); return 0; } @@ -166,69 +156,61 @@ sub canManage { #------------------------------------------------------------------- sub definition { - my $class = shift; - my $definition = shift; - push(@{$definition}, { + my $class = shift; + my $definition = shift; + push(@{$definition}, { assetName=>WebGUI::International::get('assetName',"Asset_Shortcut"), icon=>'shortcut.gif', - tableName=>'Shortcut', - className=>'WebGUI::Asset::Shortcut', - properties=>{ - shortcutToAssetId=>{ + tableName=>'Shortcut', + className=>'WebGUI::Asset::Shortcut', + properties=>{ + shortcutToAssetId=>{ noFormPost=>1, fieldType=>"hidden", defaultValue=>undef - }, -# overrideTitle=>{ -# fieldType=>"yesNo", -# defaultValue=>0 -# }, -# overrideTemplate=>{ -# fieldType=>"yesNo", -# defaultValue=>0 -# }, -# overrideDisplayTitle=>{ -# fieldType=>"yesNo", -# defaultValue=>0 -# }, -# overrideDescription=>{ -# fieldType=>"yesNo", -# defaultValue=>0 -# }, -# overrideTemplateId=>{ -# fieldType=>"template", -# defaultValue=>undef -# }, + }, shortcutByCriteria=>{ fieldType=>"yesNo", defaultValue=>0, - }, + }, disableContentLock=>{ fieldType=>"yesNo", defaultValue=>0 - }, + }, resolveMultiples=>{ fieldType=>"selectBox", defaultValue=>"mostRecent", - }, + }, shortcutCriteria=>{ fieldType=>"textarea", defaultValue=>"", - }, + }, templateId=>{ fieldType=>"template", defaultValue=>"PBtmpl0000000000000140" - }, + }, description=>{ fieldType=>"HTMLArea", defaultValue=>undef }, + prefFieldsToShow=>{ + fieldType=>"checkList", + defaultValue=>undef + }, + prefFieldsToImport=>{ + fieldType=>"checkList", + defaultValue=>undef + } } }); return $class->SUPER::definition($definition); } - +#------------------------------------------------------------------- +sub discernUserId { + my $self = shift; + return ($self->canManage && WebGUI::Session::isAdminOn()) ? '1' : $session{user}{userId}; +} #------------------------------------------------------------------- sub getEditForm { @@ -291,6 +273,10 @@ sub getEditForm { } $tabform->addTab('overrides',$i18n->get('Overrides')); $tabform->getTab('overrides')->raw($self->getOverridesList); + if ($self->isDashlet) { + $tabform->addTab('preferences',$i18n->get('Preferences')); + $tabform->getTab('preferences')->raw($self->getFieldsList); + } return $tabform; } @@ -312,22 +298,37 @@ sub getExtraHeadTags { sub getFieldsList { my $self = shift; my $i18n = WebGUI::International->new("Asset_Shortcut"); - my $output = ''.$i18n->get('Add Preference Field').'

'; - my @fielden; - @fielden = $self->getUserPrefs; - return $output unless scalar @fielden > 0; - $output .= ''; - $output .= ''; - foreach my $field (@fielden) { - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; + my $output = ''.$i18n->get('Manage Profile Fields').'

'; + my %fieldNames; + tie %fieldNames, 'Tie::IxHash'; + foreach my $field (@{WebGUI::ProfileField->getFields}) { + my $fieldId = $field->getId; + next if $fieldId =~ /contentPositions/; + $fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']'; } - $output .= '
'.$i18n->get('fieldName').''.$i18n->get('edit delete fieldname').'
'.$field->get("fieldName").''; - $output .= editIcon('func=edit',$field->getUrl()); - $output .= deleteIcon('func=delete',$field->getUrl()); - $output .= '
'; + $output .= '
'; + my @prefFieldsToShow = split("\n",$self->getValue("prefFieldsToShow")); + $output .= WebGUI::Form::CheckList->new( + -name=>"prefFieldsToShow", + -value=>\@prefFieldsToShow, + -options=>\%fieldNames, + -label=>$i18n->get('pref fields to show'), + -hoverHelp=>$i18n->get('pref fields to show description'), + -vertical=>1, + -uiLevel=>9 + )->toHtmlWithWrapper; + $output .= '
'; + my @prefFieldsToImport = split("\n",$self->getValue("prefFieldsToImport")); + $output .= WebGUI::Form::CheckList->new( + -name=>"prefFieldsToImport", + -value=>\@prefFieldsToImport, + -options=>\%fieldNames, + -label=>$i18n->get('pref fields to import'), + -hoverHelp=>$i18n->get('pref fields to import description'), + -vertical=>1, + -uiLevel=>9 + )->toHtmlWithWrapper; + $output .= '
'; return $output; } @@ -387,16 +388,20 @@ sub getOverrides { $overrides{overrides}{$fieldName}{parsedValue} = $newValue; } $sth->finish; - my @userPrefs = $self->getUserPrefs; - foreach my $field (@userPrefs) { - my $id = $field->getId; - my $fieldName = $field->getFieldName; - my $fieldValue = $field->getUserPref($id); - $overrides{userPrefs}{$fieldName}{value} = $fieldValue; - $overrides{overrides}{$fieldName}{parsedValue} = $fieldValue; - # 'myTemplateId is ##userPref:myTemplateId##', for example. - foreach my $overr (keys %{$overrides{overrides}}) { - $overrides{overrides}{$overr}{parsedValue} =~ s/\#\#userPref\:${fieldName}\#\#/$fieldValue/gm; + if ($self->isDashlet) { + my $u = WebGUI::User->new($self->discernUserId); + my @userPrefs = $self->getPrefFieldsToImport; + foreach my $fieldId (@userPrefs) { + my $field = WebGUI::ProfileField->new($fieldId); + next unless $field; + my $fieldName = $field->getId; + my $fieldValue = $u->profileField($field->getId); + $overrides{userPrefs}{$fieldName}{value} = $fieldValue; + $overrides{overrides}{$fieldName}{parsedValue} = $fieldValue; + # 'myTemplateId is ##userPref:myTemplateId##', for example. + foreach my $overr (keys %{$overrides{overrides}}) { + $overrides{overrides}{$overr}{parsedValue} =~ s/\#\#userPref\:${fieldName}\#\#/$fieldValue/gm; + } } } $cache->set(\%overrides, 60*60); @@ -411,7 +416,7 @@ sub getShortcut { unless ($self->{_shortcut}) { $self->{_shortcut} = $self->getShortcutOriginal; } - $self->{_shortcut}{_properties}{displayTitle} = undef if (ref $self->getParent eq 'WebGUI::Asset::Wobject::Dashboard'); + $self->{_shortcut}{_properties}{displayTitle} = undef if ($self->isDashlet); # Hide title by default. If you want, you can create an override # to display it. But it's being shown in the dragheader by default. my %overhash = $self->getOverrides; @@ -420,9 +425,6 @@ sub getShortcut { foreach my $override (keys %overrides) { $self->{_shortcut}{_properties}{$override} = $overrides{$override}{parsedValue}; } - foreach my $userPref ($self->getUserPrefs) { - $self->{_shortcut}{_properties}{$userPref->getFieldName} = $userPref->getUserPref($userPref->getId) unless (exists $overrides{$userPref->getFieldName}); - } } return $self->{_shortcut}; } @@ -553,10 +555,22 @@ sub getShortcutOriginal { } #------------------------------------------------------------------- -sub getUserPrefs { +sub getPrefFieldsToShow { my $self = shift; - my $bibibib = $self->getLineage(["children"],{includeOnlyClasses=>["WebGUI::Asset::Field"],returnObjects=>1}); - return @$bibibib; + return split("\n",$self->getValue("prefFieldsToShow")); +} + +#------------------------------------------------------------------- +sub getPrefFieldsToImport { + my $self = shift; + return split("\n",$self->getValue("prefFieldsToImport")); +} + +#------------------------------------------------------------------- +sub isDashlet { + my $self = shift; + return 1 if ref $self->getParent eq 'WebGUI::Asset::Wobject::Dashboard'; + return 0; } #------------------------------------------------------------------- @@ -569,21 +583,6 @@ sub processPropertiesFromFormPost { #------------------------------------------------------------------- -sub purge { - my $self = shift; - # delete and purge all associated FieldIds and their preferences. - return $self->SUPER::purge; -} - -#------------------------------------------------------------------- - -sub purgeRevision { - my $self = shift; - return $self->SUPER::purgeRevision; -} - -#------------------------------------------------------------------- - sub uncacheOverrides { my $self = shift; WebGUI::Cache->new(["shortcutOverrides",$self->getId])->delete; @@ -614,7 +613,6 @@ sub www_edit { return WebGUI::Privilege::insufficient() unless $self->canEdit; $self->getAdminConsole->setHelp("shortcut add/edit","Asset_Shortcut"); $self->getAdminConsole->addSubmenuItem($self->getUrl("func=manageOverrides"),WebGUI::International::get("Manage Shortcut Overrides","Asset_Shortcut")); - $self->getAdminConsole->addSubmenuItem($self->getUrl("func=manageUserPrefs"),WebGUI::International::get("Manage User Preferences","Asset_Shortcut")); return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get(2,"Asset_Shortcut")); } @@ -622,41 +620,41 @@ sub www_edit { sub www_getUserPrefsForm { #This is a form retrieved by "ajax". my $self = shift; - return 'nuhuh' unless $self->getParent->canPersonalize; - my @fielden = $self->getUserPrefs; + return 'You are no longer logged in' if $session{user}{userId} eq '1'; + return 'You are not allowed to personalize this Dashboard.' unless $self->getParent->canPersonalize; + my $output; + my @fielden = $self->getPrefFieldsToShow; my $f = WebGUI::HTMLForm->new(extras=>' onSubmit="submitForm(this,\''.$self->getId.'\',\''.$self->getUrl.'\');return false;"'); + $f->raw(''); $f->hidden( -name => 'func', -value => 'saveUserPrefs' ); - foreach my $field (@fielden) { - my $fieldType = $field->get("fieldType") || "text"; - my $options; - my $params = {name=>$field->getId, - label=>$field->get("fieldName"), - uiLevel=>5, - value=>$field->getUserPref($field->getId), - extras=>'', - possibleValues=>$field->get("possibleValues"), - options=>$options, - fieldType=>$fieldType - }; - if (lc($fieldType) eq 'textarea') { + foreach my $fieldId (@fielden) { + my $field = WebGUI::ProfileField->new($fieldId); + next unless $field; + my $params = {}; + if (lc($field->get("fieldType")) eq 'textarea') { $params->{rows} = 4; $params->{columns} = 20; } - $f->dynamicField(%$params); + if (lc($field->get("fieldType")) eq 'text') { + $params->{size} = 20; + } + $f->raw($field->formField($params,1)); } - $f->submit; - return $f->print; -} - -#------------------------------------------------------------------- -sub www_manageUserPrefs { - my $self = shift; - return WebGUI::Privilege::insufficient() unless $self->canEdit; - my $output = $self->getFieldsList; - return $self->_submenu($output,WebGUI::International::get("Manage User Preferences","Asset_Shortcut")); + $f->submit({extras=>'className="nothing"'}); + $f->raw('
'); + my $tags; + foreach my $tag (@{$session{page}{head}{javascript}}) { + $tags .= 'print; + return $output; } #------------------------------------------------------------------- @@ -687,11 +685,21 @@ sub www_deleteOverride { sub www_saveUserPrefs { my $self = shift; return '' unless $self->getParent->canPersonalize; - my @fellowFields = $self->getUserPrefs; + my @fellowFields = $self->getPrefFieldsToShow; + my %data = (); + $self->uncacheOverrides; + my $u = WebGUI::User->new($self->discernUserId); foreach my $fieldId (keys %{$session{form}}) { - my $field = WebGUI::Asset->newByDynamicClass($fieldId); + my $field = WebGUI::ProfileField->new($fieldId); next unless $field; - $field->setUserPref($fieldId,$session{form}{$fieldId}); + $data{$field->getId} = $field->formProcess; + if ($field->getId eq 'email' && WebGUI::Operation::Profile::isDuplicateEmail($data{$field->getId})) { + return '
  • '.WebGUI::International::get(1072).'
  • '; + } + if ($field->isRequired && !$data{$field->getId}) { + return '
  • '.$field->getLabel.' '.WebGUI::International::get(451).'
  • '; + } + $u->profileField($field->getId,$data{$field->getId}); } return $self->view; } @@ -739,7 +747,7 @@ sub www_editOverride { -value=>$overrides{overrides}{$fieldName}{newValue}, -hoverHelp=>$i18n->get("Place something in this box if you dont want to use the automatically generated field") ); - $f->readOnly(-label=>$i18n->get("Replacement Value"),-value=>$overrides{overrides}{$fieldName}{parsedValue},-hoverHelp=>$i18n->get("This is the example output of the field when parsed for user preference macros")); + $f->readOnly(-label=>$i18n->get("Replacement Value"),-value=>$overrides{overrides}{$fieldName}{parsedValue},-hoverHelp=>$i18n->get("This is the example output of the field when parsed for user preference macros")) if $self->isDashlet; $f->submit; $output .= $f->print; return $self->_submenu($output,$i18n->get('Edit Override')); @@ -768,7 +776,7 @@ sub www_saveOverride { #------------------------------------------------------------------- sub www_view { my $self = shift; - if (ref($self->getParent) eq 'WebGUI::Asset::Wobject::Dashboard') { + if ($self->isDashlet) { return WebGUI::Privilege::noAccess() unless $self->canView; $session{asset} = $self->getParent; return $session{asset}->www_view; diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index 631a0cf39..ad778801f 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -17,6 +17,7 @@ use WebGUI::Utility; use WebGUI::Session; use WebGUI::Grouping; use WebGUI::Privilege; +use WebGUI::ProfileField; use WebGUI::ErrorHandler; use Time::HiRes; use WebGUI::Style; @@ -28,12 +29,14 @@ our @ISA = qw(WebGUI::Asset::Wobject); #------------------------------------------------------------------- sub canManage { my $self = shift; + return 0 if $session{user}{userId} == 1; return WebGUI::Grouping::isInGroup($self->get("adminsGroupId")); } #------------------------------------------------------------------- sub canPersonalize { my $self = shift; + return 0 if $session{user}{userId} == 1; return WebGUI::Grouping::isInGroup($self->get("usersGroupId")); } @@ -65,7 +68,8 @@ sub definition { assetsToHide => { defaultValue=>undef, fieldType=>"checkList" - } + }, + ); push(@{$definition}, { assetName=>WebGUI::International::get('assetName',"Asset_Dashboard"), @@ -138,13 +142,13 @@ sub getEditForm { #------------------------------------------------------------------- sub initialize { my $self = shift; - my $userPrefField = WebGUI::ProfileField::addProfileField({ + my $userPrefField = WebGUI::ProfileField->create($self->getId.'contentPositions',{ label=>'\'Dashboard User Preference - Content Positions\'', - visible=>1, - isProtected=>1, + visible=>0, + protected=>1, editable=>0, - dataType=>'text', - fieldName=>$self->getId.'contentPositions' + required=>0, + fieldType=>'text' }); $self->update({isInitialized=>1}); } @@ -181,7 +185,7 @@ sub view { my @hidden = split("\n",$self->get("assetsToHide")); foreach my $child (@{$children}) { push(@hidden,$child->get('shortcutToAssetId')) if ref $child eq 'WebGUI::Asset::Shortcut'; - #the following loop will initially place just-shortcutted assets. + #the following loop will initially place just-dashletted assets. for (my $i = 0; $i < scalar(@positions); $i++) { next unless isIn($child->get('shortcutToAssetId'),@hidden); my $newChildId = $child->getId; @@ -216,7 +220,7 @@ sub view { dashletTitle=>$child->{_properties}{title}, shortcutUrl=>$child->getUrl, canPersonalize=>$self->canPersonalize, - canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0)) + canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getPrefFieldsToShow) > 0)) }); $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';'; @@ -227,7 +231,7 @@ sub view { dashletTitle=>$child->{_properties}{title}, shortcutUrl=>$child->getUrl, canPersonalize=>$self->canPersonalize, - canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0)) + canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getPrefFieldsToShow) > 0)) }); $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';'; } @@ -249,7 +253,7 @@ sub view { dashletTitle=>$child->getTitle, shortcutUrl=>$child->getUrl, canPersonalize=>$self->canPersonalize, - canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0)) + canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getPrefFieldsToShow) > 0)) }); $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';'; } diff --git a/lib/WebGUI/ErrorHandler.pm b/lib/WebGUI/ErrorHandler.pm index 3279f9043..8da3e5988 100644 --- a/lib/WebGUI/ErrorHandler.pm +++ b/lib/WebGUI/ErrorHandler.pm @@ -174,25 +174,26 @@ Adds a FATAL type message to the log, outputs an error message to the user, and sub fatal { my $message = shift; + WebGUI::HTTP::setStatus("500","Server Error"); my $logger = getLogger(); Apache2::RequestUtil->request->content_type('text/html') if ($WebGUI::Session::session{req}); $logger->fatal($message); $logger->debug("Stack trace for FATAL ".$message."\n".getStackTrace()); - unless (canShowDebug()) { - #NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop. - print "

    Problem With Request

    - We have encountered a problem with your request. Please use your back button and try again. - If this problem persists, please contact us with what you were trying to do and the time and date of the problem."; - print '
    '.$WebGUI::Session::session{setting}{companyName}; - print '
    '.$WebGUI::Session::session{setting}{companyEmail}; - print '
    '.$WebGUI::Session::session{setting}{companyURL}; - } else { - print "

    WebGUI Fatal Error

    Something unexpected happened that caused this system to fault.

    \n"; + unless (canShowDebug()) { + #NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop. + print "

    Problem With Request

    + We have encountered a problem with your request. Please use your back button and try again. + If this problem persists, please contact us with what you were trying to do and the time and date of the problem."; + print '
    '.$WebGUI::Session::session{setting}{companyName}; + print '
    '.$WebGUI::Session::session{setting}{companyEmail}; + print '
    '.$WebGUI::Session::session{setting}{companyURL}; + } else { + print "

    WebGUI Fatal Error

    Something unexpected happened that caused this system to fault.

    \n"; print "

    ".$message."

    \n"; print showDebug(); } WebGUI::Session::close(); - exit; + exit; #this is bad under mod_perl. restarts that httpd instance. } @@ -303,9 +304,9 @@ The message you wish to add to the log. sub security { my $message = shift; $Log::Log4perl::caller_depth++; - WebGUI::ErrorHandler::warn($WebGUI::Session::session{user}{username}." (".$WebGUI::Session::session{user}{userId}.") connecting from " - .$WebGUI::Session::session{env}{REMOTE_ADDR}." attempted to ".$message); - $Log::Log4perl::caller_depth--; + WebGUI::ErrorHandler::warn($WebGUI::Session::session{user}{username}." (".$WebGUI::Session::session{user}{userId}.") connecting from " + .$WebGUI::Session::session{env}{REMOTE_ADDR}." attempted to ".$message); + $log::Log4perl::caller_depth--; } diff --git a/lib/WebGUI/HTTP.pm b/lib/WebGUI/HTTP.pm index 14f63ee6e..f53385f2d 100644 --- a/lib/WebGUI/HTTP.pm +++ b/lib/WebGUI/HTTP.pm @@ -75,7 +75,7 @@ Generates an HTTP header. =cut sub getHeader { - return undef if ($session{http}{noHeader}); + return undef if ($session{http}{noHeader}); my %params; if (isRedirect()) { $session{req}->headers_out->set(Location => $session{http}{location}); @@ -83,16 +83,14 @@ sub getHeader { } else { $session{req}->content_type($session{http}{mimetype} || "text/html"); if ($session{setting}{preventProxyCache}) { - $params{"-expires"} = "-1d"; - } + $params{"-expires"} = "-1d"; + } if ($session{http}{filename}) { $params{"-attachment"} = $session{http}{filename}; } } $params{"-cookie"} = $session{http}{cookie}; - my $status = getStatus(); - # $session{req}->custom_response($status, '' ); - $session{req}->status($status); + $session{req}->status_line(getStatus().' '.$session{http}{statusDescription}) if $session{req}; return; } @@ -119,6 +117,7 @@ Returns the current HTTP status code, if one has been set. =cut sub getStatus { + $session{http}{statusDescription} = $session{http}{statusDescription} || "OK"; return $session{http}{status} || "200"; } diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index f51fe27b6..fe25cc7d8 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -62,7 +62,7 @@ sub execute { $output = eval($cmd); WebGUI::ErrorHandler::error("Couldn't execute operation : ".$cmd.". Root cause: ".$@) if ($@); } else { - WebGUI::ErrorHandler::security("execute an invalid operation: ".$op); + WebGUI::ErrorHandler::security("execute an invalid operation: ".$op); } return $output; } diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index d558724e4..765c6276f 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -103,6 +103,7 @@ sub www_editProfile { my @temp = (); foreach my $field (@{$category->getFields}) { next unless ($field->isEditable); + next if $field->getId =~ /contentPositions/; push(@temp, { 'profile.form.element' => $field->formField, 'profile.form.element.label' => $field->getLabel, diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 34829a3ab..b4c2f6d0c 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -265,6 +265,7 @@ sub www_editProfileSettings { $output .= moveDownIcon('op=moveProfileCategoryDown;cid='.$category->getId); $output .= ' '.$category->getLabel.'
    '; foreach my $field (@{$category->getFields}) { + next if $field->getId =~ /contentPositions/; $output .= '     '; $output .= deleteIcon('op=deleteProfileFieldConfirm;fid='.$field->getId,'',WebGUI::International::get(467,"WebGUIProfile")); $output .= editIcon('op=editProfileField;fid='.$field->getId); diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 783381169..2efab3de9 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -278,6 +278,7 @@ sub www_editUser { foreach my $category (@{WebGUI::ProfileCategory->getCategories}) { $tabform->getTab("profile")->raw(''.$category->getLabel.''); foreach my $field (@{$category->getFields}) { + next if $field->getId =~ /contentPositions/; $tabform->getTab("profile")->raw($field->formField(undef,1)); } } @@ -337,6 +338,7 @@ sub www_editUserSave { $authInstance->editUserFormSave; } foreach my $field (@{WebGUI::ProfileField->getFields}) { + next if $field->getId =~ /contentPositions/; $u->profileField($field->getId,$field->formProcess); } my @groups = WebGUI::FormProcessor::group("groupsToAdd"); diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index 6d0e65cdf..f2e36d891 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -23,6 +23,7 @@ use WebGUI::Form; use WebGUI::FormProcessor; use WebGUI::Operation::Shared; use WebGUI::HTML; +use WebGUI::User; =head1 NAME @@ -226,7 +227,7 @@ Returns an array reference of WebGUI::ProfileField objects. This is a class meth sub getFields { my $self = shift; my @fields = (); - foreach my $fieldName (WebGUI::SQL->buildArray("select fieldName from userProfileField order by sequenceNumber")) { + foreach my $fieldName (WebGUI::SQL->buildArray("select fieldName from userProfileField order by profileCategoryId, sequenceNumber")) { push(@fields,WebGUI::ProfileField->new($fieldName)); } return \@fields; diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index f5efe32de..9d113f52f 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -263,10 +263,10 @@ sub new { my %profile = WebGUI::SQL->buildHash("select userProfileField.fieldName, userProfileData.fieldData from userProfileField, userProfileData where userProfileField.fieldName=userProfileData.fieldName and userProfileData.userId=".quote($user{userId})); - my %default = WebGUI::SQL->buildHash("select fieldName, dataDefault from userProfileField where profileCategoryId=4"); + my %default = WebGUI::SQL->buildHash("select fieldName, dataDefault from userProfileField"); foreach my $key (keys %default) { my $value; - if ($profile{$key} eq "") { + if ($profile{$key} eq "" && $default{$key}) { $value = eval($default{$key}); if (ref $value eq "ARRAY") { $profile{$key} = $$value[0]; diff --git a/lib/WebGUI/i18n/English/Asset_Shortcut.pm b/lib/WebGUI/i18n/English/Asset_Shortcut.pm index e2b65077e..40cf458b6 100644 --- a/lib/WebGUI/i18n/English/Asset_Shortcut.pm +++ b/lib/WebGUI/i18n/English/Asset_Shortcut.pm @@ -280,8 +280,8 @@ The word "Shortcut".

    lastUpdated => 1133619940, }, - 'Add Preference Field' => { - message => q|Add Preference Field|, + 'Manage Profile Fields' => { + message => q|Manage Profile Fields|, lastUpdated => 1133619940, }, @@ -370,6 +370,34 @@ The word "Shortcut".

    lastUpdated => 1133619940, }, + 'pref fields to show' => { + message => q|Preference Fields to Show|, + lastUpdated => 1133619940, + }, + + 'pref fields to show description' => { + message => q|These are the user profile fields you want to expose as user preferences to the users who can personalize this dashboard.|, + lastUpdated => 1133619940, + }, + + 'pref fields to import' => { + message => q|Preference Fields to Import|, + lastUpdated => 1133619940, + }, + + 'pref fields to import description' => { + message => q|These are the user profile fields you want exposed to your override fields (in the form ##userPref:nameOfProfileField##). Check these if you want to expose profile fields from other areas of the site or the general user profile fields.|, + lastUpdated => 1133619940, + }, + + 'Preferences' => { + message => q|Preferences|, + lastUpdated => 1133619940, + }, + + + + }; 1;