Multiple changes:
- Shift ProfileField API so that new returns undef on invalid fields.
This makes it possible for Shortcut::www_saveUserPrefs to execute.
The class methods in ProfileField are now also actually class methods.
+ Also fix up other modules that created dummy ProfileFields so that
they don't need to do that anymore, because it's now invalid.
- Merge contradictory-looking code from Shortcut's view and www_view
into a reasonable compromise in view, and then have www_view call
$self->view in a manner similar to that of the default Asset::view.
+ The profile field overrides still don't work, because there's no
obvious mechanism for "transclude asset in context". This may
require some fiddling to get right...
This commit is contained in:
parent
84e8d8f689
commit
565119fa1a
5 changed files with 57 additions and 36 deletions
|
|
@ -28,6 +28,10 @@
|
|||
- fix: dashlet user preference setting causing nested dashboard to appear
|
||||
- fix: saving edits to dashlet shortcuts kicks you out of your version tag
|
||||
- fix: Discussion tmpl variables in Article asset
|
||||
- fix: dashlet www_saveUserPrefs refusing to execute
|
||||
- API change: ProfileField::new now returns undef for invalid fields
|
||||
- API change: in ProfileField, the get*Fields family of methods are now class methods
|
||||
- API change: 'func' and 'op' are now reserved and not usable as profile fields
|
||||
|
||||
7.0.6
|
||||
- fix: Error in DateTime.pm
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ sub getFieldsList {
|
|||
my $output = '<a href="'.$self->getUrl('op=editProfileSettings').'" class="formLink">'.$i18n->get('Manage Profile Fields').'</a><br /><br />';
|
||||
my %fieldNames;
|
||||
tie %fieldNames, 'Tie::IxHash';
|
||||
foreach my $field (@{WebGUI::ProfileField->new($self->session,'dummy')->getFields}) {
|
||||
foreach my $field (@{WebGUI::ProfileField->getFields($self->session)}) {
|
||||
my $fieldId = $field->getId;
|
||||
next if $fieldId =~ /contentPositions/;
|
||||
$fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']';
|
||||
|
|
@ -616,11 +616,7 @@ sub prepareView {
|
|||
$template->prepare;
|
||||
$self->{_viewTemplate} = $template;
|
||||
my $shortcut = $self->getShortcut;
|
||||
if (defined $shortcut) {
|
||||
$shortcut->prepareView;
|
||||
} else {
|
||||
$self->notLinked;
|
||||
}
|
||||
$shortcut->prepareView if defined $shortcut;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -645,18 +641,21 @@ sub view {
|
|||
my $content;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Shortcut");
|
||||
my $shortcut = $self->getShortcut;
|
||||
if (defined $shortcut) {
|
||||
# continue
|
||||
} elsif ($self->canEdit) {
|
||||
return '<a href="'.$self->getUrl("func=delete").'">'.$self->notLinked.'</a>';
|
||||
} else {
|
||||
return undef;
|
||||
|
||||
unless (defined $shortcut) {
|
||||
if ($self->canEdit) {
|
||||
return $self->session->style->userStyle('<a href="'.$self->getUrl("func=delete").'">'.$self->notLinked.'</a>');
|
||||
} else {
|
||||
return $self->notLinked;
|
||||
}
|
||||
}
|
||||
|
||||
if ($self->get("shortcutToAssetId") eq $self->get("parentId")) {
|
||||
$content = $i18n->get("Displaying this shortcut would cause a feedback loop");
|
||||
} else {
|
||||
$content = $shortcut->view;
|
||||
}
|
||||
|
||||
my %var = (
|
||||
isShortcut => 1,
|
||||
'shortcut.content' => $content,
|
||||
|
|
@ -866,16 +865,12 @@ sub www_saveOverride {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
# Hrrrm. Why doesn't the default www_view work here?
|
||||
my $self = shift;
|
||||
my $shortcut = $self->getShortcut;
|
||||
|
||||
if (defined $shortcut) {
|
||||
return $shortcut->www_view;
|
||||
} elsif ($self->canEdit) {
|
||||
return $self->session->style->userStyle('<a href="'.$self->getUrl("func=delete").'">'.$self->notLinked.'</a>');
|
||||
} else {
|
||||
return $self->notLinked;
|
||||
}
|
||||
my $check = $self->checkView;
|
||||
return $check if defined $check;
|
||||
$self->prepareView;
|
||||
return $self->view;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ The current WebGUI session object.
|
|||
sub getRequiredProfileFields {
|
||||
my $session = shift;
|
||||
my @array;
|
||||
foreach my $field (@{WebGUI::ProfileField->new($session,'dummy')->getRequiredFields}) {
|
||||
foreach my $field (@{WebGUI::ProfileField->getRequiredFields($session)}) {
|
||||
push(@array, {
|
||||
'profile.formElement' => $field->formField,
|
||||
'profile.formElement.label' => $field->getLabel
|
||||
|
|
@ -146,7 +146,7 @@ sub validateProfileData {
|
|||
my $error = "";
|
||||
my $warning = "";
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
foreach my $field (@{WebGUI::ProfileField->new($session,'dummy')->getEditableFields}) {
|
||||
foreach my $field (@{WebGUI::ProfileField->getEditableFields($session)}) {
|
||||
my $fieldValue = $field->formProcess;
|
||||
if (ref $fieldValue eq "ARRAY") {
|
||||
$data{$field->getId} = $$fieldValue[0];
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ sub www_editUserSave {
|
|||
}
|
||||
|
||||
# Loop through all profile fields, and update them with new values.
|
||||
foreach my $field (@{WebGUI::ProfileField->new($session,'dummy')->getFields}) {
|
||||
foreach my $field (@{WebGUI::ProfileField->getFields($session)}) {
|
||||
next if $field->getId =~ /contentPositions/;
|
||||
$u->profileField($field->getId,$field->formProcess);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use WebGUI::Form::DynamicField;
|
|||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -54,6 +55,19 @@ sub _reorderFields {
|
|||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 isReservedFieldName ( fieldName )
|
||||
|
||||
Return true iff fieldName is reserved and therefore not usable as a profile field name.
|
||||
|
||||
=cut
|
||||
|
||||
sub isReservedFieldName {
|
||||
my $class = shift;
|
||||
my $fieldName = shift;
|
||||
return isIn($fieldName, ('func', 'op'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 create ( session, fieldName [, properties, categoryId] )
|
||||
|
|
@ -86,6 +100,8 @@ sub create {
|
|||
my $categoryId = shift || "1";
|
||||
my ($fieldNameExists) = $session->db->quickArray("select count(*) from userProfileField where fieldName=".$session->db->quote($fieldName));
|
||||
return undef if ($fieldNameExists);
|
||||
return undef if $class->isReservedFieldName($fieldName);
|
||||
|
||||
my $id = $session->db->setRow("userProfileField","fieldName",{fieldName=>"new"},$fieldName);
|
||||
my $self = $class->new($session,$id);
|
||||
$self->setCategory($categoryId);
|
||||
|
|
@ -225,34 +241,36 @@ sub getCategory {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditableFields ( )
|
||||
=head2 getEditableFields ( session )
|
||||
|
||||
Returns an array reference of WebGUI::ProfileField objects that are marked "editable" or "required". This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditableFields {
|
||||
my $self = shift;
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my @fields = ();
|
||||
foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField where required=1 or editable=1 order by sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($self->session,$fieldName));
|
||||
foreach my $fieldName ($session->db->buildArray("select fieldName from userProfileField where required=1 or editable=1 order by sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($session,$fieldName));
|
||||
}
|
||||
return \@fields;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFields ( )
|
||||
=head2 getFields ( session )
|
||||
|
||||
Returns an array reference of WebGUI::ProfileField objects. This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFields {
|
||||
my $self = shift;
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my @fields = ();
|
||||
foreach my $fieldName ($self->session->db->buildArray("select fieldName from userProfileField order by profileCategoryId, sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($self->session,$fieldName));
|
||||
foreach my $fieldName ($session->db->buildArray("select fieldName from userProfileField order by profileCategoryId, sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($session,$fieldName));
|
||||
}
|
||||
return \@fields;
|
||||
}
|
||||
|
|
@ -287,17 +305,18 @@ sub getLabel {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getRequiredFields ( )
|
||||
=head2 getRequiredFields ( session )
|
||||
|
||||
Returns an array reference of WebGUI::ProfileField objects that are marked "required". This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub getRequiredFields {
|
||||
my $self = shift;
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my @fields = ();
|
||||
foreach my $fieldName ($self->session->db->buildArray("select userProfileField.fieldName from userProfileField LEFT JOIN userProfileCategory ON userProfileField.profileCategoryId = userProfileCategory.profileCategoryId where userProfileField.required=1 order by userProfileCategory.sequenceNumber, userProfileField.sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($self->session,$fieldName));
|
||||
foreach my $fieldName ($session->db->buildArray("select userProfileField.fieldName from userProfileField LEFT JOIN userProfileCategory ON userProfileField.profileCategoryId = userProfileCategory.profileCategoryId where userProfileField.required=1 order by userProfileCategory.sequenceNumber, userProfileField.sequenceNumber")) {
|
||||
push(@fields,WebGUI::ProfileField->new($session,$fieldName));
|
||||
}
|
||||
return \@fields;
|
||||
}
|
||||
|
|
@ -417,7 +436,10 @@ sub new {
|
|||
my $session = shift;
|
||||
my $id = shift;
|
||||
return undef unless ($id);
|
||||
return undef if $class->isReservedFieldName($id);
|
||||
my $properties = $session->db->getRow("userProfileField","fieldName",$id);
|
||||
# Reject properties that don't exist.
|
||||
return undef unless scalar keys %$properties;
|
||||
bless {_session=>$session, _properties=>$properties}, $class;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue