lots of changes.

This commit is contained in:
Matthew Wilson 2005-12-08 03:17:48 +00:00
parent 2825a11907
commit a8c99a2b9c
11 changed files with 209 additions and 164 deletions

View file

@ -11,9 +11,13 @@ package WebGUI::Asset::Shortcut;
#------------------------------------------------------------------- #-------------------------------------------------------------------
use strict; use strict;
use Tie::IxHash;
use WebGUI::Asset; use WebGUI::Asset;
use WebGUI::Icon; use WebGUI::Icon;
use WebGUI::International; use WebGUI::International;
use WebGUI::Operation::Profile;
use WebGUI::ProfileField;
use WebGUI::ProfileCategory;
use WebGUI::Macro; use WebGUI::Macro;
use WebGUI::Privilege; use WebGUI::Privilege;
use WebGUI::Session; use WebGUI::Session;
@ -123,19 +127,6 @@ sub _drawQueryBuilder {
return $output; 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 { sub _submenu {
my $self = shift; my $self = shift;
@ -147,14 +138,13 @@ sub _submenu {
$ac->setIcon($self->getIcon); $ac->setIcon($self->getIcon);
$ac->addSubmenuItem($self->getUrl('func=edit'), WebGUI::International::get("Back to Edit Shortcut","Asset_Shortcut")); $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=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); return $ac->render($workarea, $title);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub canEdit { sub canEdit {
my $self = shift; 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; return 0;
} }
@ -166,69 +156,61 @@ sub canManage {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub definition { sub definition {
my $class = shift; my $class = shift;
my $definition = shift; my $definition = shift;
push(@{$definition}, { push(@{$definition}, {
assetName=>WebGUI::International::get('assetName',"Asset_Shortcut"), assetName=>WebGUI::International::get('assetName',"Asset_Shortcut"),
icon=>'shortcut.gif', icon=>'shortcut.gif',
tableName=>'Shortcut', tableName=>'Shortcut',
className=>'WebGUI::Asset::Shortcut', className=>'WebGUI::Asset::Shortcut',
properties=>{ properties=>{
shortcutToAssetId=>{ shortcutToAssetId=>{
noFormPost=>1, noFormPost=>1,
fieldType=>"hidden", fieldType=>"hidden",
defaultValue=>undef 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=>{ shortcutByCriteria=>{
fieldType=>"yesNo", fieldType=>"yesNo",
defaultValue=>0, defaultValue=>0,
}, },
disableContentLock=>{ disableContentLock=>{
fieldType=>"yesNo", fieldType=>"yesNo",
defaultValue=>0 defaultValue=>0
}, },
resolveMultiples=>{ resolveMultiples=>{
fieldType=>"selectBox", fieldType=>"selectBox",
defaultValue=>"mostRecent", defaultValue=>"mostRecent",
}, },
shortcutCriteria=>{ shortcutCriteria=>{
fieldType=>"textarea", fieldType=>"textarea",
defaultValue=>"", defaultValue=>"",
}, },
templateId=>{ templateId=>{
fieldType=>"template", fieldType=>"template",
defaultValue=>"PBtmpl0000000000000140" defaultValue=>"PBtmpl0000000000000140"
}, },
description=>{ description=>{
fieldType=>"HTMLArea", fieldType=>"HTMLArea",
defaultValue=>undef defaultValue=>undef
}, },
prefFieldsToShow=>{
fieldType=>"checkList",
defaultValue=>undef
},
prefFieldsToImport=>{
fieldType=>"checkList",
defaultValue=>undef
}
} }
}); });
return $class->SUPER::definition($definition); return $class->SUPER::definition($definition);
} }
#-------------------------------------------------------------------
sub discernUserId {
my $self = shift;
return ($self->canManage && WebGUI::Session::isAdminOn()) ? '1' : $session{user}{userId};
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub getEditForm { sub getEditForm {
@ -291,6 +273,10 @@ sub getEditForm {
} }
$tabform->addTab('overrides',$i18n->get('Overrides')); $tabform->addTab('overrides',$i18n->get('Overrides'));
$tabform->getTab('overrides')->raw($self->getOverridesList); $tabform->getTab('overrides')->raw($self->getOverridesList);
if ($self->isDashlet) {
$tabform->addTab('preferences',$i18n->get('Preferences'));
$tabform->getTab('preferences')->raw($self->getFieldsList);
}
return $tabform; return $tabform;
} }
@ -312,22 +298,37 @@ sub getExtraHeadTags {
sub getFieldsList { sub getFieldsList {
my $self = shift; my $self = shift;
my $i18n = WebGUI::International->new("Asset_Shortcut"); my $i18n = WebGUI::International->new("Asset_Shortcut");
my $output = '<a href="'.$self->getUrl('func=add;class=WebGUI::Asset::Field').'" class="formLink">'.$i18n->get('Add Preference Field').'</a><br /><br />'; my $output = '<a href="'.$self->getUrl('op=editProfileSettings').'" class="formLink">'.$i18n->get('Manage Profile Fields').'</a><br /><br />';
my @fielden; my %fieldNames;
@fielden = $self->getUserPrefs; tie %fieldNames, 'Tie::IxHash';
return $output unless scalar @fielden > 0; foreach my $field (@{WebGUI::ProfileField->getFields}) {
$output .= '<table cellspacing="0" cellpadding="3" border="1">'; my $fieldId = $field->getId;
$output .= '<tr class="tableHeader"><td>'.$i18n->get('fieldName').'</td><td>'.$i18n->get('edit delete fieldname').'</td></tr>'; next if $fieldId =~ /contentPositions/;
foreach my $field (@fielden) { $fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']';
$output .= '<tr>';
$output .= '<td class="tableData"><a href="'.$field->getUrl('func=edit').'">'.$field->get("fieldName").'</a></td>';
$output .= '<td class="tableData">';
$output .= editIcon('func=edit',$field->getUrl());
$output .= deleteIcon('func=delete',$field->getUrl());
$output .= '</td>';
$output .= '</tr>';
} }
$output .= '</table>'; $output .= '<table cellspacing="0" cellpadding="3" border="1"><tr><td><table cellspacing="0" cellpadding="3" border="0">';
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 .= '</table></td><td><table cellspacing="0" cellpadding="3" border="0">';
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 .= '</table></td></tr></table>';
return $output; return $output;
} }
@ -387,16 +388,20 @@ sub getOverrides {
$overrides{overrides}{$fieldName}{parsedValue} = $newValue; $overrides{overrides}{$fieldName}{parsedValue} = $newValue;
} }
$sth->finish; $sth->finish;
my @userPrefs = $self->getUserPrefs; if ($self->isDashlet) {
foreach my $field (@userPrefs) { my $u = WebGUI::User->new($self->discernUserId);
my $id = $field->getId; my @userPrefs = $self->getPrefFieldsToImport;
my $fieldName = $field->getFieldName; foreach my $fieldId (@userPrefs) {
my $fieldValue = $field->getUserPref($id); my $field = WebGUI::ProfileField->new($fieldId);
$overrides{userPrefs}{$fieldName}{value} = $fieldValue; next unless $field;
$overrides{overrides}{$fieldName}{parsedValue} = $fieldValue; my $fieldName = $field->getId;
# 'myTemplateId is ##userPref:myTemplateId##', for example. my $fieldValue = $u->profileField($field->getId);
foreach my $overr (keys %{$overrides{overrides}}) { $overrides{userPrefs}{$fieldName}{value} = $fieldValue;
$overrides{overrides}{$overr}{parsedValue} =~ s/\#\#userPref\:${fieldName}\#\#/$fieldValue/gm; $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); $cache->set(\%overrides, 60*60);
@ -411,7 +416,7 @@ sub getShortcut {
unless ($self->{_shortcut}) { unless ($self->{_shortcut}) {
$self->{_shortcut} = $self->getShortcutOriginal; $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 # 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. # to display it. But it's being shown in the dragheader by default.
my %overhash = $self->getOverrides; my %overhash = $self->getOverrides;
@ -420,9 +425,6 @@ sub getShortcut {
foreach my $override (keys %overrides) { foreach my $override (keys %overrides) {
$self->{_shortcut}{_properties}{$override} = $overrides{$override}{parsedValue}; $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}; return $self->{_shortcut};
} }
@ -553,10 +555,22 @@ sub getShortcutOriginal {
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub getUserPrefs { sub getPrefFieldsToShow {
my $self = shift; my $self = shift;
my $bibibib = $self->getLineage(["children"],{includeOnlyClasses=>["WebGUI::Asset::Field"],returnObjects=>1}); return split("\n",$self->getValue("prefFieldsToShow"));
return @$bibibib; }
#-------------------------------------------------------------------
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 { sub uncacheOverrides {
my $self = shift; my $self = shift;
WebGUI::Cache->new(["shortcutOverrides",$self->getId])->delete; WebGUI::Cache->new(["shortcutOverrides",$self->getId])->delete;
@ -614,7 +613,6 @@ sub www_edit {
return WebGUI::Privilege::insufficient() unless $self->canEdit; return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->getAdminConsole->setHelp("shortcut add/edit","Asset_Shortcut"); $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=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")); return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get(2,"Asset_Shortcut"));
} }
@ -622,41 +620,41 @@ sub www_edit {
sub www_getUserPrefsForm { sub www_getUserPrefsForm {
#This is a form retrieved by "ajax". #This is a form retrieved by "ajax".
my $self = shift; my $self = shift;
return 'nuhuh' unless $self->getParent->canPersonalize; return 'You are no longer logged in' if $session{user}{userId} eq '1';
my @fielden = $self->getUserPrefs; 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;"'); my $f = WebGUI::HTMLForm->new(extras=>' onSubmit="submitForm(this,\''.$self->getId.'\',\''.$self->getUrl.'\');return false;"');
$f->raw('<table cellspacing="0" cellpadding="3" border="0">');
$f->hidden( $f->hidden(
-name => 'func', -name => 'func',
-value => 'saveUserPrefs' -value => 'saveUserPrefs'
); );
foreach my $field (@fielden) { foreach my $fieldId (@fielden) {
my $fieldType = $field->get("fieldType") || "text"; my $field = WebGUI::ProfileField->new($fieldId);
my $options; next unless $field;
my $params = {name=>$field->getId, my $params = {};
label=>$field->get("fieldName"), if (lc($field->get("fieldType")) eq 'textarea') {
uiLevel=>5,
value=>$field->getUserPref($field->getId),
extras=>'',
possibleValues=>$field->get("possibleValues"),
options=>$options,
fieldType=>$fieldType
};
if (lc($fieldType) eq 'textarea') {
$params->{rows} = 4; $params->{rows} = 4;
$params->{columns} = 20; $params->{columns} = 20;
} }
$f->dynamicField(%$params); if (lc($field->get("fieldType")) eq 'text') {
$params->{size} = 20;
}
$f->raw($field->formField($params,1));
} }
$f->submit; $f->submit({extras=>'className="nothing"'});
return $f->print; $f->raw('</table>');
} my $tags;
foreach my $tag (@{$session{page}{head}{javascript}}) {
#------------------------------------------------------------------- $tags .= '<script';
sub www_manageUserPrefs { foreach my $name (keys %{$tag}) {
my $self = shift; $tags .= ' '.$name.'="'.$tag->{$name}.'"';
return WebGUI::Privilege::insufficient() unless $self->canEdit; }
my $output = $self->getFieldsList; $tags .= '></script>'."\n";
return $self->_submenu($output,WebGUI::International::get("Manage User Preferences","Asset_Shortcut")); }
$output .= $tags.$f->print;
return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -687,11 +685,21 @@ sub www_deleteOverride {
sub www_saveUserPrefs { sub www_saveUserPrefs {
my $self = shift; my $self = shift;
return '' unless $self->getParent->canPersonalize; 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}}) { foreach my $fieldId (keys %{$session{form}}) {
my $field = WebGUI::Asset->newByDynamicClass($fieldId); my $field = WebGUI::ProfileField->new($fieldId);
next unless $field; 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 '<li>'.WebGUI::International::get(1072).'</li>';
}
if ($field->isRequired && !$data{$field->getId}) {
return '<li>'.$field->getLabel.' '.WebGUI::International::get(451).'</li>';
}
$u->profileField($field->getId,$data{$field->getId});
} }
return $self->view; return $self->view;
} }
@ -739,7 +747,7 @@ sub www_editOverride {
-value=>$overrides{overrides}{$fieldName}{newValue}, -value=>$overrides{overrides}{$fieldName}{newValue},
-hoverHelp=>$i18n->get("Place something in this box if you dont want to use the automatically generated field") -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; $f->submit;
$output .= $f->print; $output .= $f->print;
return $self->_submenu($output,$i18n->get('Edit Override')); return $self->_submenu($output,$i18n->get('Edit Override'));
@ -768,7 +776,7 @@ sub www_saveOverride {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_view { sub www_view {
my $self = shift; my $self = shift;
if (ref($self->getParent) eq 'WebGUI::Asset::Wobject::Dashboard') { if ($self->isDashlet) {
return WebGUI::Privilege::noAccess() unless $self->canView; return WebGUI::Privilege::noAccess() unless $self->canView;
$session{asset} = $self->getParent; $session{asset} = $self->getParent;
return $session{asset}->www_view; return $session{asset}->www_view;

View file

@ -17,6 +17,7 @@ use WebGUI::Utility;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::Grouping; use WebGUI::Grouping;
use WebGUI::Privilege; use WebGUI::Privilege;
use WebGUI::ProfileField;
use WebGUI::ErrorHandler; use WebGUI::ErrorHandler;
use Time::HiRes; use Time::HiRes;
use WebGUI::Style; use WebGUI::Style;
@ -28,12 +29,14 @@ our @ISA = qw(WebGUI::Asset::Wobject);
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub canManage { sub canManage {
my $self = shift; my $self = shift;
return 0 if $session{user}{userId} == 1;
return WebGUI::Grouping::isInGroup($self->get("adminsGroupId")); return WebGUI::Grouping::isInGroup($self->get("adminsGroupId"));
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub canPersonalize { sub canPersonalize {
my $self = shift; my $self = shift;
return 0 if $session{user}{userId} == 1;
return WebGUI::Grouping::isInGroup($self->get("usersGroupId")); return WebGUI::Grouping::isInGroup($self->get("usersGroupId"));
} }
@ -65,7 +68,8 @@ sub definition {
assetsToHide => { assetsToHide => {
defaultValue=>undef, defaultValue=>undef,
fieldType=>"checkList" fieldType=>"checkList"
} },
); );
push(@{$definition}, { push(@{$definition}, {
assetName=>WebGUI::International::get('assetName',"Asset_Dashboard"), assetName=>WebGUI::International::get('assetName',"Asset_Dashboard"),
@ -138,13 +142,13 @@ sub getEditForm {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub initialize { sub initialize {
my $self = shift; my $self = shift;
my $userPrefField = WebGUI::ProfileField::addProfileField({ my $userPrefField = WebGUI::ProfileField->create($self->getId.'contentPositions',{
label=>'\'Dashboard User Preference - Content Positions\'', label=>'\'Dashboard User Preference - Content Positions\'',
visible=>1, visible=>0,
isProtected=>1, protected=>1,
editable=>0, editable=>0,
dataType=>'text', required=>0,
fieldName=>$self->getId.'contentPositions' fieldType=>'text'
}); });
$self->update({isInitialized=>1}); $self->update({isInitialized=>1});
} }
@ -181,7 +185,7 @@ sub view {
my @hidden = split("\n",$self->get("assetsToHide")); my @hidden = split("\n",$self->get("assetsToHide"));
foreach my $child (@{$children}) { foreach my $child (@{$children}) {
push(@hidden,$child->get('shortcutToAssetId')) if ref $child eq 'WebGUI::Asset::Shortcut'; 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++) { for (my $i = 0; $i < scalar(@positions); $i++) {
next unless isIn($child->get('shortcutToAssetId'),@hidden); next unless isIn($child->get('shortcutToAssetId'),@hidden);
my $newChildId = $child->getId; my $newChildId = $child->getId;
@ -216,7 +220,7 @@ sub view {
dashletTitle=>$child->{_properties}{title}, dashletTitle=>$child->{_properties}{title},
shortcutUrl=>$child->getUrl, shortcutUrl=>$child->getUrl,
canPersonalize=>$self->canPersonalize, 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.'\';'; $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';';
@ -227,7 +231,7 @@ sub view {
dashletTitle=>$child->{_properties}{title}, dashletTitle=>$child->{_properties}{title},
shortcutUrl=>$child->getUrl, shortcutUrl=>$child->getUrl,
canPersonalize=>$self->canPersonalize, 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.'\';'; $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';';
} }
@ -249,7 +253,7 @@ sub view {
dashletTitle=>$child->getTitle, dashletTitle=>$child->getTitle,
shortcutUrl=>$child->getUrl, shortcutUrl=>$child->getUrl,
canPersonalize=>$self->canPersonalize, 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.'\';'; $newStuff .= 'available_dashlets["'.$child->getId.'"]=\''.$child->getUrl.'\';';
} }

View file

@ -174,25 +174,26 @@ Adds a FATAL type message to the log, outputs an error message to the user, and
sub fatal { sub fatal {
my $message = shift; my $message = shift;
WebGUI::HTTP::setStatus("500","Server Error");
my $logger = getLogger(); my $logger = getLogger();
Apache2::RequestUtil->request->content_type('text/html') if ($WebGUI::Session::session{req}); Apache2::RequestUtil->request->content_type('text/html') if ($WebGUI::Session::session{req});
$logger->fatal($message); $logger->fatal($message);
$logger->debug("Stack trace for FATAL ".$message."\n".getStackTrace()); $logger->debug("Stack trace for FATAL ".$message."\n".getStackTrace());
unless (canShowDebug()) { unless (canShowDebug()) {
#NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop. #NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop.
print "<h1>Problem With Request</h1> print "<h1>Problem With Request</h1>
We have encountered a problem with your request. Please use your back button and try again. 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."; If this problem persists, please contact us with what you were trying to do and the time and date of the problem.";
print '<br />'.$WebGUI::Session::session{setting}{companyName}; print '<br />'.$WebGUI::Session::session{setting}{companyName};
print '<br />'.$WebGUI::Session::session{setting}{companyEmail}; print '<br />'.$WebGUI::Session::session{setting}{companyEmail};
print '<br />'.$WebGUI::Session::session{setting}{companyURL}; print '<br />'.$WebGUI::Session::session{setting}{companyURL};
} else { } else {
print "<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n"; print "<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n";
print "<p>".$message."</p>\n"; print "<p>".$message."</p>\n";
print showDebug(); print showDebug();
} }
WebGUI::Session::close(); 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 { sub security {
my $message = shift; my $message = shift;
$Log::Log4perl::caller_depth++; $Log::Log4perl::caller_depth++;
WebGUI::ErrorHandler::warn($WebGUI::Session::session{user}{username}." (".$WebGUI::Session::session{user}{userId}.") connecting from " WebGUI::ErrorHandler::warn($WebGUI::Session::session{user}{username}." (".$WebGUI::Session::session{user}{userId}.") connecting from "
.$WebGUI::Session::session{env}{REMOTE_ADDR}." attempted to ".$message); .$WebGUI::Session::session{env}{REMOTE_ADDR}." attempted to ".$message);
$Log::Log4perl::caller_depth--; $log::Log4perl::caller_depth--;
} }

View file

@ -75,7 +75,7 @@ Generates an HTTP header.
=cut =cut
sub getHeader { sub getHeader {
return undef if ($session{http}{noHeader}); return undef if ($session{http}{noHeader});
my %params; my %params;
if (isRedirect()) { if (isRedirect()) {
$session{req}->headers_out->set(Location => $session{http}{location}); $session{req}->headers_out->set(Location => $session{http}{location});
@ -83,16 +83,14 @@ sub getHeader {
} else { } else {
$session{req}->content_type($session{http}{mimetype} || "text/html"); $session{req}->content_type($session{http}{mimetype} || "text/html");
if ($session{setting}{preventProxyCache}) { if ($session{setting}{preventProxyCache}) {
$params{"-expires"} = "-1d"; $params{"-expires"} = "-1d";
} }
if ($session{http}{filename}) { if ($session{http}{filename}) {
$params{"-attachment"} = $session{http}{filename}; $params{"-attachment"} = $session{http}{filename};
} }
} }
$params{"-cookie"} = $session{http}{cookie}; $params{"-cookie"} = $session{http}{cookie};
my $status = getStatus(); $session{req}->status_line(getStatus().' '.$session{http}{statusDescription}) if $session{req};
# $session{req}->custom_response($status, '<!-- '.$session{http}{statusDescription}.' -->' );
$session{req}->status($status);
return; return;
} }
@ -119,6 +117,7 @@ Returns the current HTTP status code, if one has been set.
=cut =cut
sub getStatus { sub getStatus {
$session{http}{statusDescription} = $session{http}{statusDescription} || "OK";
return $session{http}{status} || "200"; return $session{http}{status} || "200";
} }

View file

@ -62,7 +62,7 @@ sub execute {
$output = eval($cmd); $output = eval($cmd);
WebGUI::ErrorHandler::error("Couldn't execute operation : ".$cmd.". Root cause: ".$@) if ($@); WebGUI::ErrorHandler::error("Couldn't execute operation : ".$cmd.". Root cause: ".$@) if ($@);
} else { } else {
WebGUI::ErrorHandler::security("execute an invalid operation: ".$op); WebGUI::ErrorHandler::security("execute an invalid operation: ".$op);
} }
return $output; return $output;
} }

View file

@ -103,6 +103,7 @@ sub www_editProfile {
my @temp = (); my @temp = ();
foreach my $field (@{$category->getFields}) { foreach my $field (@{$category->getFields}) {
next unless ($field->isEditable); next unless ($field->isEditable);
next if $field->getId =~ /contentPositions/;
push(@temp, { push(@temp, {
'profile.form.element' => $field->formField, 'profile.form.element' => $field->formField,
'profile.form.element.label' => $field->getLabel, 'profile.form.element.label' => $field->getLabel,

View file

@ -265,6 +265,7 @@ sub www_editProfileSettings {
$output .= moveDownIcon('op=moveProfileCategoryDown;cid='.$category->getId); $output .= moveDownIcon('op=moveProfileCategoryDown;cid='.$category->getId);
$output .= ' <b>'.$category->getLabel.'</b><br />'; $output .= ' <b>'.$category->getLabel.'</b><br />';
foreach my $field (@{$category->getFields}) { foreach my $field (@{$category->getFields}) {
next if $field->getId =~ /contentPositions/;
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; $output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
$output .= deleteIcon('op=deleteProfileFieldConfirm;fid='.$field->getId,'',WebGUI::International::get(467,"WebGUIProfile")); $output .= deleteIcon('op=deleteProfileFieldConfirm;fid='.$field->getId,'',WebGUI::International::get(467,"WebGUIProfile"));
$output .= editIcon('op=editProfileField;fid='.$field->getId); $output .= editIcon('op=editProfileField;fid='.$field->getId);

View file

@ -278,6 +278,7 @@ sub www_editUser {
foreach my $category (@{WebGUI::ProfileCategory->getCategories}) { foreach my $category (@{WebGUI::ProfileCategory->getCategories}) {
$tabform->getTab("profile")->raw('<tr><td colspan="2" class="tableHeader">'.$category->getLabel.'</td></tr>'); $tabform->getTab("profile")->raw('<tr><td colspan="2" class="tableHeader">'.$category->getLabel.'</td></tr>');
foreach my $field (@{$category->getFields}) { foreach my $field (@{$category->getFields}) {
next if $field->getId =~ /contentPositions/;
$tabform->getTab("profile")->raw($field->formField(undef,1)); $tabform->getTab("profile")->raw($field->formField(undef,1));
} }
} }
@ -337,6 +338,7 @@ sub www_editUserSave {
$authInstance->editUserFormSave; $authInstance->editUserFormSave;
} }
foreach my $field (@{WebGUI::ProfileField->getFields}) { foreach my $field (@{WebGUI::ProfileField->getFields}) {
next if $field->getId =~ /contentPositions/;
$u->profileField($field->getId,$field->formProcess); $u->profileField($field->getId,$field->formProcess);
} }
my @groups = WebGUI::FormProcessor::group("groupsToAdd"); my @groups = WebGUI::FormProcessor::group("groupsToAdd");

View file

@ -23,6 +23,7 @@ use WebGUI::Form;
use WebGUI::FormProcessor; use WebGUI::FormProcessor;
use WebGUI::Operation::Shared; use WebGUI::Operation::Shared;
use WebGUI::HTML; use WebGUI::HTML;
use WebGUI::User;
=head1 NAME =head1 NAME
@ -226,7 +227,7 @@ Returns an array reference of WebGUI::ProfileField objects. This is a class meth
sub getFields { sub getFields {
my $self = shift; my $self = shift;
my @fields = (); 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)); push(@fields,WebGUI::ProfileField->new($fieldName));
} }
return \@fields; return \@fields;

View file

@ -263,10 +263,10 @@ sub new {
my %profile = WebGUI::SQL->buildHash("select userProfileField.fieldName, userProfileData.fieldData my %profile = WebGUI::SQL->buildHash("select userProfileField.fieldName, userProfileData.fieldData
from userProfileField, userProfileData where userProfileField.fieldName=userProfileData.fieldName and from userProfileField, userProfileData where userProfileField.fieldName=userProfileData.fieldName and
userProfileData.userId=".quote($user{userId})); 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) { foreach my $key (keys %default) {
my $value; my $value;
if ($profile{$key} eq "") { if ($profile{$key} eq "" && $default{$key}) {
$value = eval($default{$key}); $value = eval($default{$key});
if (ref $value eq "ARRAY") { if (ref $value eq "ARRAY") {
$profile{$key} = $$value[0]; $profile{$key} = $$value[0];

View file

@ -280,8 +280,8 @@ The word "Shortcut".</p>
lastUpdated => 1133619940, lastUpdated => 1133619940,
}, },
'Add Preference Field' => { 'Manage Profile Fields' => {
message => q|Add Preference Field|, message => q|Manage Profile Fields|,
lastUpdated => 1133619940, lastUpdated => 1133619940,
}, },
@ -370,6 +370,34 @@ The word "Shortcut".</p>
lastUpdated => 1133619940, 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; 1;