Fork me on GitHub

Profile module - new field type  Bottom

  • Is any way to add a new field type to Profile module. I would like to add image upload field, similar to that one in Pagesetter. That users can easily add their own photo.

    --
    rgfdgafgaf
  • Please add a feature request (or if you code it yourself, a patch) to the tracker on noc.postnuke.com/projects/postnuke.

    I'm afraid that what's in the module at the moment is all that's available, but that can change in the future.

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • There are several modules to do that - pnAvatar, Avatar (1.1 for .764, 2.0 for .800) and pnUserPictures.

    Try them and see which work for you.

    pnAvatar and Avatar both use the standard avatar field, just allow users to upload personal avatars. Avatar allows you to set the upload directory, so that if you disable the editing of the avatar field in the user profile, users can then just upload their own and not accidentally (or intentionally) use someone else's.
  • Yes, I know about Avatar module but unfortunately version 2.0 for .8 not support personal avatar's... maybe only don't want for me :(

    Anyway I want to have avatars and user pictures. I thought about copy and rename all avatar module to User Pictures module :) and install as User Pictures but since personal avatars are not personal any more it's not a good solution.

    I have already add, a image upload type to select option and add, a template to view it but I have problem to do the upload... I don't know how to execute upload function inside a Profile form and pass back uploaded image path into input field so it can be saved... I have tried use Ajax but it seems I'm not enough smart icon_razz

    I'm still thinking about that avatar module I have to look into it...
    I want to make a friends page where instead of avatars in last seen or on-line block will be picture and other stuff it's going to be some kind of dating service icon_biggrin
    Spring is coming... love is in the air icon_razz

    --
    rgfdgafgaf
  • Take a look at the Avatar 2.0 upload, it uses a few PN classes to perform it, do some checks, and such.

    So you want to have an avatar AND a picture?

    I have Avatar 2.0 working on a few .8 sites, but I had to adjust 1 thing in the code (I'll have to look up what I did), and make sure it pointed to a writable folder.

    NCM
  • uheweb

    I have Avatar 2.0 working on a few .8 sites, but I had to adjust 1 thing in the code (I'll have to look up what I did)


    Please add this to the tracker at the NOC project if it is a general problem with Avatar 2.0.

    Kaik

    Yes, I know about Avatar module but unfortunately version 2.0 for .8 not support personal avatar's...


    Can you explain this please? If it is a bug, it should be fixed.




    --
    "He is not dangerous, he just wants to play...."
  • uheweb


    So you want to have an avatar AND a picture?

    I have Avatar 2.0 working on a few .8 sites, but I had to adjust 1 thing in the code (I'll have to look up what I did), and make sure it pointed to a writable folder.


    Yes, a want to have avatar AND picture.

    Landseer

    Can you explain this please? If it is a bug, it should be fixed.


    User's are able to load their own avatar and it is saved correctly with pers_uid so folder is writeable. Problem is because in the main view user's can see all avatars including private also they can choose other users avatars.
    I think this problem have been reported already...



    --
    rgfdgafgaf
  • Sorry for double posting
    Ok I found it and make a fix it's a simple fix but is working...

    old avatars pnuserapi.php functions with bug's

    Code

    ...
    function Avatar_userapi_getAvatars($args)
    {
        if (isset($args['uid'])) {
            $uid = $args['uid'];
        } else {
            // no user ID is passed, so assume the current user
            $uid = pnUserGetVar('uid');
        }
     
        $avatardir = pnModGetVar('Avatar', 'avatardir');
       
        $allavatars = FileUtil::getFiles($avatardir, true, true, null, false);
        $avatars = array();
        foreach ($allavatars as $avatar) {
            $parts = explode($avatar, '_'); //Kaik: no way to work...
            if(is_array($parts)) {
                if(!isset($parts[1])) {
                    // normal aatar, so it's OK
                    $avatars[] = $avatar;
                } else {
    // check for permission; Kaik: even if somehow $parts[1]
    // will exist then for sure uid.fileextension will not be same as any uid in pn
    //...no way to get personal avatar
                    if(SecurityUtil::checkPermission('Avatar::', $parts[0] . ':'
     . $parts[1] . ':', ACCESS_READ) || $parts[1] == $uid) {
                        $avatars[] = $avatar;
                    }
                }
            }
        }
        asort($avatars);
       
        return $avatars;
    }
    ...
    function Avatar_userapi_checkAvatar($args)
    {
        // check if the avatar is allowed for the user
        $avatar_ok = false;
        $parts = explode($args['avatar'], '_');
        if(is_array($parts)) {
            if(!isset($parts[1])) {
                // normal avatar, so it's OK
                $avatar_ok = true;
            } else {
                // check for permission
    //
                if(SecurityUtil::checkPermission('Avatar::', $parts[0] . ':'
     . $parts[1] . ':', ACCESS_READ, $args['uid']) || $parts[1] == $args['uid']) {
                    $avatar_ok = true;
                }
            }
        }
        return $avatar_ok;
    }



    My bug's fix

    Code

    ...
    function Avatar_userapi_getAvatars($args)
    {
        if (isset($args['uid'])) {
            $uid = $args['uid'];
        } else {
            // no user ID is passed, so assume the current user
            $uid = pnUserGetVar('uid');
        }
     
        $avatardir = pnModGetVar('Avatar', 'avatardir');
       
        $allavatars = FileUtil::getFiles($avatardir, true, true, null, false);
        $avatars = array();
        foreach ($allavatars as $avatar) {
            $parts = explode('_', $avatar);
            if(is_array($parts)) {
                if(!isset($parts[1])) {
                    // normal aatar, so it's OK
                    $avatars[] = $avatar;
                } else {
                    // check for permission
                    $uidpart = explode('.', $parts[1]);
                    if( $uidpart[0] == $uid) {
                        $avatars[] = $avatar;
                    }
                }
            }
        }
        asort($avatars);
       
        return $avatars;
    }

    ...

    function Avatar_userapi_checkAvatar($args)
    {
        // check if the avatar is allowed for the user
        $avatar_ok = false;
        $parts = explode('_', $args['avatar']);
        if(is_array($parts)) {
            if(!isset($parts[1])) {
                // normal avatar, so it's OK
                $avatar_ok = true;
            } else {
                // check for permission
                $uidpart = explode('.', $parts[1]);
                    if( $uidpart[0] == $args['uid']) {
                    $avatar_ok = true;
                }
            }
        }
        return $avatar_ok;
    }


    hmm...



    edited by: Kaik, Mar 18, 2008 - 03:35 PM

    --
    rgfdgafgaf
  • Landseer,

    the forumdir gave me trouble, so I changed it to:
    Avatar_admin_modifyconfighandler.class.php line 74 in 2.0 RC1:

    Code

    if ($data['forumdir']) pnModSetVar('Avatar', 'forumdir',           $data['forumdir']);


    So, if no forumdir was set, the lang. define wouldn't need to be set either and possible throw an error on null. I didn't investigate further.

    Also, on my system I kept getting the type returned as "jpeg" . I followed the code, and at no point could I see where it would return jpeg instead of jpg as the filetype.

    I fiddled for a while, but finally just added jpeg to the end of the allowed filetypes.

    Seems image_type_to_extension function would return jpg:

    Code

    case IMAGETYPE_JPEG    : return $dot . 'jpg';


    But I would always get back jpeg....how, I have no idea! It boggled me as its just a simple switch and jpeg cannot be returned anywhere. The night grew late, so I just gave up and added jpeg in the admin settings and all worked fine.

    NCM
    UHEweb / SwitchBit
  • As for being able to choose other's avatars, I just disable the field in the User admin.

    Then, they are forced to use the avatar module to manage their avatar.

    Don't delete the field, just disable it. The Avatar will still add to the DB correctly, and as far as I've seen, PN will still fetch and display the avatar correctly everywhere.

    NCM
  • Same thing happens on this site - you can hijack another's personal avatar...

    Admins - just disable the avatar field in the main profile page icon_wink
  • I have found another small bug in Users/pnuser.pnp line 337
    is

    Code

    if (empty($dynadata['YOURAVATAR'])) $dynadata['YOURAVATAR'] = 'blank.gif';

    should be

    Code

    if (empty($dynadata['_YOURAVATAR'])) $dynadata['_YOURAVATAR'] = 'blank.gif';


    I will add this to the tracker at the NOC project I'm waiting for registration email

    The other thing is that when you add/edit dud field in Profile should be option to add default value for that field, which is set during registration.
    Similar to blank.gif like in avatar but not hardcoded as it's above.




    --
    rgfdgafgaf
  • @Kaik: Thanks, the code fixed a bug I was chasing for a longer time. This avoids avatar images being hijacked by others in 2.0, I am not sure if I will fix this in the code used here.
    @uheweb: image_type_to_extension() in PHP5 returns jpeg in case of a .jpg file, I changed the upgrade function in Avatar to add jpeg to the extension list if jpg is found.

    Both changes will be committed to the Avatar-SVN today. Please do not post bugs here at all as we do not look into the forums to find them, please always use the bug tracker on NOC.



    --
    "He is not dangerous, he just wants to play...."

This list is based on users active over the last 60 minutes.