WebGUI
      Click here to register.
      
YAPC North America 2008


     Report a Bug > WebGUI Bug Tracker

User profile images disappear after updat

User rene
Date 5/31/2007 8:27 am
Severity Critical (mostly not working)
Version WebGUI 7.3.18
Views 477
Rating 6    Rate [
|
]
Karma Rank 0.000000
Previous · Next
User Message
rene

When adding a picture to a userprofile this picture disappears after updating another field of the profiledata.

the column fielddata in table userprofiledata is set to NULL after update.

Thank you,



Back to Top
Rate [
|
]
 
 
colink
Is the editing of the profile done by the user or by an Admin?


Back to Top
Rate [
|
]
 
 
webrene
The editing is done by the admin but it must be possible to do so for the user

in both ways the picture is gone after editing the profile

we did checked the database to see what happens, after updating the field for the picture is set to NULL



On May 31, 2007, at 7:17 PM, <ckuskie@sterlink.net> wrote:

 
colink has posted to one of your subscriptions
http://www.plainblack.com/bugs/tracker/user-profile-images-disappear-after-updat/1
Is the editing of the profile done by the user or by an Admin?
  

Unsubscribe

<mime-attachment.txt>


Rene Enge
=====================
=====================






Back to Top
Rate [
|
]
 
 
webrene

We tackled this problem by editting the webgui source.

Everything is now working fine



Back to Top
Rate [
|
]
 
 
colink
If you've fixed the bug, do you mind posting the patch so that we can add it to the core?

Back to Top
Rate [
|
]
 
 
webrene

Hello, this is what we did to the following files. This works for us we hope you can add this to the core.

We updated the file User.pm, this file is located in /data/WebGUI/lib/WebGUI

wrintings in bold are new to the file

sub profileField {        my ($self, $fieldName, $value);        $self = shift;        $fieldName = shift;        $value = shift;        if (!exists $self->{_profile}{$fieldName} && !$self->session->db->quickScalar("SELECT COUNT(*) FROM userProfileField WHERE fieldName = ?", [$fieldName]) ) {                $self->session->errorHandler->warn("No such profile field: $fieldName");                return undef;        }        if (defined $value) {                $self->uncache;                $self->{_profile}{$fieldName} = $value;                 my $photo = $self->session->db->read("select fieldData from userProfileData where userId=? and fieldName=?",[$self->{_userId}, 'photo']);                 $self->session->db->write("delete from userProfileData where userId=? and fieldName=?",[$self->{_userId}, $fieldName]);                $self->session->db->write("insert into userProfileData values (?,?,?)", [$self->{_userId}, $fieldName,$value]);                 my $foto = $photo->array;                if ($fieldName eq 'photo' and $value eq ' ' )                {                  if ($foto ne ' ' )                  {                  $self->session->db->write("update userProfileData set fieldData=?  where userId=? and fieldName=?",[$foto, $self->{_userId}, 'photo']);                  }                }                my $time = $self->session->datetime->time();                $self->{_user}{"lastUpdated"} = $time;                $self->session->db->write("update users set lastUpdated=? where userId=?", [$time, $self->{_userId}]);        }        return $self->{_profile}{$fieldName};

}

=====================================================================================

We also updated the file /data/WebGUI/lib/WebGUI/Form/Image.pm

wrintings in bold are new to the file

sub displayForm {        my ($self) = @_;        return $self->toHtml;        #unless $self->get('value');         ##There are files inside here, for each one, display the image        ##and another form control for deleting it.        my $location = WebGUI::Storage::Image->get($self->session, $self->get('value'));        my $i18n = WebGUI::International->new($self->session);        my $fileForm = '';        my $file = shift @{ $location->getFiles };         $fileForm .= sprintf qq!<img src="%s" / width=100><br />!, $location->getUrl($file);        #$fileForm .= sprintf qq!<img src="%s" /><br />!, $location->getUrl($file);        #$fileForm .= $i18n->get(392)        #         .  "&nbsp"x4        #         . WebGUI::Form::YesNo->new($self->session, {-name=>$self->privateName('delete'), -value=>0})->toHtml;        $fileForm .= $self->toHtmlAsHidden();        $fileForm .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml();        return $fileForm;}
==========================================================================================Thank you, 

Back to Top
Rate [
|
]
 
 
Graham
Partial fix checked in.  Editing the images works properly, but displays incorrectly the page displayed after editing using the admin panel.

Back to Top
Rate [
|
]
 
 
Graham
This is fixed now for 7.4

Back to Top
Rate [
|
]