1
wishcraft
SmartProfile - edituser.php & /admin/user.php

Hi all how have you been, I am just trying to debug something with smartprofile module for a client that has been a pleasure doing business with.

Quote:

When I try to edit the profile from smart profile here /modules/smartprofile/edituser.php After saving I get the following errors.

Errors Returned While Uploading
Filename Is Empty
Errors Returned While Uploading
Filename Is Empty


I have checked where the error is coming from which is the uploader.php class as part of xoops, this is the source wrap that handles uploads for some reason the media name is coming through blank and it is erroring at line 198 of /class/uploader.php

if ($this->mediaName == '') {
            
$this->setErrors('Filename Is Empty');
            return 
false;
        }


I would say there is nothing wrong with the uploader class something ether to do with magic quotes and uploading on his service or a bug in smartprofile, just wondering if anyone knowns of a fix for this.

The other bug is a repeat of the last with the following error occurring when:

Quote:

When I try to edit from /modules/smartprofile/admin/user.php I get the following errors

ERROR: Displayname taken.
ERROR: Email address already registered.


But i will have a look and see if I can see what is doing that.. admin panel stuff is easier
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

2
wishcraft
Re: SmartProfile - edituser.php & /admin/user.php

Ok the second bug i have a quick fix for it...

from line 53 to line 81 of /smartprofile/include/functions.php should be as follows:

global $op_buffer;
    
$member_handler =& xoops_gethandler('member');
    
$display_criteria = new Criteria('uname'$user->getVar('uname'));
    if (
$user->getVar('uid') > 0) {
        
//existing user, so let's keep the user's own row out of this
        
$display_criteria = new CriteriaCompo($display_criteria);

        
$useriddisplay_criteria = new Criteria('uid'$user->getVar('uid'), '!=');

        
$display_criteria->add($useriddisplay_criteria);
    }
    
$display_count $member_handler->getUserCount($display_criteria);
    unset(
$display_criteria);
    if (
$display_count 0&&$op_buffer!='edit') {
        
$stop .= _PROFILE_MA_DISPLAYNAMETAKEN."";
    }
    if ( 
$user->getVar('email')) {
        
$count_criteria = new Criteria('email'$user->getVar('email'));
        if (
$user->getVar('uid') > 0) {
            
//existing user, so let's keep the user's own row out of this
            
$count_criteria = new CriteriaCompo($count_criteria);
            
$count_criteria->add(new Criteria('uid'$user->getVar('uid'), '!='));
        }
        
$count $member_handler->getUserCount($count_criteria);
        unset(
$count_criteria);
        if ( 
$count &&$op_buffer!='edit') {
            
$stop .= _PROFILE_MA_EMAILTAKEN."";
        }
    }


and you will need to add these to lines to /smartprofile/admin/user.php at line 42

global $op_buffer;
$op_buffer $op;


that will fix the second bug... but is wrong with the first problem and uploading??
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

3
jimmyx
Re: SmartProfile - edituser.php & /admin/user.php
  • 2008/2/2 13:34

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


there are many unofficial smartprofile fixed version..check it out ..compare with software such as winmerge

- herve (instant-zero.com)
http://www.herve-thouzard.com/smartprofile/smartprofile.zip

- SmartProfile CVS 1.0.3
http://smartfactory.ca/modules/newbb/dl_attachment.php?attachid=1181910860&post_id=8259

- (mboyden)
http://mark.boyden.name/smartsection.item.32/profiles.html

4
jimmyx
Re: SmartProfile - edituser.php & /admin/user.php
  • 2008/2/2 13:37

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


the next XOOPS release 2.3 hope to see this integrated..

5
wishcraft
Re: SmartProfile - edituser.php & /admin/user.php

Starting at Line 144 (/admin/user.php) you need to alter it to read

foreach (array_keys($fields) as $i) {
            
$fieldname $fields[$i]->getVar('field_name');
            if (
in_array($fields[$i]->getVar('fieldid'), $editable_fields) && ($fields[$i]->getvar('field_type') != "image" || isset($_REQUEST[$fieldname]))) {
                if (
in_array($fieldname$profile_handler->getUserVars())) {
                    
$value $fields[$i]->getValueForSave($_REQUEST[$fieldname], $user->getVar($fieldname'n'));
                    
$user->setVar($fieldname$value);
                }
                else {
                    
$value $fields[$i]->getValueForSave((isset($_REQUEST[$fieldname]) ? $_REQUEST[$fieldname] : ""), $profile->getVar($fieldname'n'));
                    
$profile->setVar($fieldname$value);
                }
            } elseif (
$fields[$i]->getvar('field_type') == "image"){
               
$value $fields[$i]->getValueForSave($fieldname$profile->getVar($fieldname'n'),$imageindex);
               
$profile->setVar($fieldname$value);
            }

        }


And starting line 78 you need to alter the foreach also to read

foreach (array_keys($fields) as $i) {
        
$fieldname $fields[$i]->getVar('field_name');
        if (
in_array($fields[$i]->getVar('fieldid'), $editable_fields) && ($fields[$i]->getvar('field_type') != "image" || isset($_REQUEST[$fieldname]))) {
            if (
in_array($fieldname$profile_handler->getUserVars())) {
                
$value $fields[$i]->getValueForSave($_REQUEST[$fieldname], $edituser->getVar($fieldname'n'));
                
$edituser->setVar($fieldname$value);
            }
            else {
                
$value $fields[$i]->getValueForSave((isset($_REQUEST[$fieldname]) ? $_REQUEST[$fieldname] : ""), $profile->getVar($fieldname'n'));
                
$profile->setVar($fieldname$value);
            }
        } elseif (
$fields[$i]->getvar('field_type') == "image"){
                
$value $fields[$i]->getValueForSave($fieldname$profile->getVar($fieldname'n'),$imageindex);
               
$profile->setVar($fieldname$value);

            
        }
    }


The changes to /class/field.php need to be changed as you can't do an isset on a $_FILES object it will always read true.

Starting at line 363 of the select case you need to make the following changes through to the fetchmedia call, the case statement should read

case "image":
                foreach (
$_POST['xoops_upload_file'] as $result){
                    
$count++;
                    if (
$result==$this->getVar('field_name')){
                        
$index $count-1;
                        break;
                    }
                }
                
                if (!isset(
$_FILES[$_POST['xoops_upload_file'][$index]])||$_FILES[$_POST['xoops_upload_file'][$index]]['error']==4) {
                    return 
$oldvalue;
                } else {
                    
//print_r($_FILES[$_POST['xoops_upload_file'][$index]]);
                
}
                
/*if (!isset($_FILES[$this->getVar('field_name')])) {
                    return $oldvalue;
                }*/
                
$options $this->getVar('field_options');
                
$dirname XOOPS_UPLOAD_PATH."/smartprofile";
                if (!
is_dir($dirname)) {
                    
mkdir($dirname);
                }
                include_once 
XOOPS_ROOT_PATH.'/class/uploader.php';
                
$uploader = new XoopsMediaUploader($dirname, array('image/gif''image/jpeg''image/pjpeg''image/x-png''image/png'), $options['maxsize']*1024$options['maxwidth'], $options['maxheight']);
                if (
$uploader->fetchMedia($_POST['xoops_upload_file'][$index])) {
                  
                    
$uploader->setPrefix('image');
                    if (
$uploader->upload()) {
                        @
unlink($dirname."/".$oldvalue);
                        return 
$uploader->getSavedFileName();
                    }
                    else {
                        echo 
$uploader->getErrors();
                        return 
$oldvalue;
                    }
                }
                else {
                    echo 
$uploader->getErrors();
                    return 
$oldvalue;
                }
                break;
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

Login

Who's Online

303 user(s) are online (248 user(s) are browsing Support Forums)


Members: 0


Guests: 303


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits