Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: bobdole2281 - syyskuu 10, 2013, 01:50:03 IP

Otsikko: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 10, 2013, 01:50:03 IP
How do I use the function function profileSaveAvatarData(&$value)?

I am trying to make a custom way to edit an avatar. I can't figure out what the $value is supposed to be.
Is it $value supposed to = "filepath from user's computer"?

What if the wan't to select "No avatar", then is value just null or ""? I've been trying to call this function for a while now and could really use some advice. What do I need to call before it? Subs? Profile-modify.php?
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: Shambles - syyskuu 10, 2013, 02:30:06 IP
A quick check shows the function source to be in Profile-Modify.php.

The $value parameter seems to be validated to be one of 'external', 'none', 'server_stored' or 'upload'.

Have a ganders at the function source to see further...
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 10, 2013, 02:44:09 IP
Gotta be careful with whatever you're trying to do, SMF's code for store/get avatar is pretty complex since it offers multiple options, external, attachment and selecting one from the avatars folder.

Before getting into the actual function, what exactly do you want to achieve?
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 10, 2013, 03:01:18 IP
Lainaus käyttäjältä: Shambles - syyskuu 10, 2013, 02:30:06 IP
The $value parameter seems to be validated to be one of 'external', 'none', 'server_stored' or 'upload'.

Thanks, that narrows it down quite a lot.


LainaaGotta be careful with whatever you're trying to do, SMF's code for store/get avatar is pretty complex since it offers multiple options, external, attachment and selecting one from the avatars folder.

Before getting into the actual function, what exactly do you want to achieve

Thanks for the reply. I'm not using server_stored or external for this. (At least from my understanding). I want to either upload an image from the users computer or select none. Then change it to their permanent avatar.

What would a typical call of this function look like? Also, you are right. I need to be very careful to know what I am doing before screwing around with this one.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 10, 2013, 03:09:59 IP
A typical call to that function isn't different from any other call to any other function... that is:

function_name($params);

or $var = function_name($params);  // If your function returns any value.


Is this a private customization for you and you only or do you try to build a mod?

Most of the SMF functions are not really designed to be used independently, specially the profile ones, thats why I'm asking what exactly are you trying to do... depending on what you're doing it might be easier to build a custom function.

Why would you want to select an image from an users computer?  where does that image would go? does it will be encrypted on your server or it will be saved "as is"? whats the purpose of that uploaded image?  under what context does that image will appear?
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 10, 2013, 03:23:54 IP
Alright, so this function might not be for me. It seems like I might need create a custom one. This is for all users, not just me.

Here is a brief description. I am about 99% done with a custom profile program I made that ties into another website I have and shows a bunch of non-smf related things. One of the only things I am missing is a way to "Edit Avatar."

I would be happy to go into much more description if needed, just ask. I don't want to bog the thread down with unneeded descriptions, but if it will help in any way I'll definitely share.

So, I need a way for a user to pick their avatar. I was only going to allow the options "Choose file" or "No avatar." I was not going to include server avatars or url link (unless someone persuades me too). So the "No avatar" option is probably fairly simple. I'm wondering more about the "Choose file" portion. What type of data would I need to gather and what type of files would I need to include.

Do you have a rough idea of what this function would look like? Thanks for all the help.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 10, 2013, 05:32:50 IP
I still don't know if you will need a custom function or not as you still haven't answer my questions.

So far I only know you have a custom profile program, dunno what that means or how it relates to uploading an image to your server.

Why don't you just use the avatar system in SMF?  why having two totally equal features?

Oh please, don't mind bogging the topic... be as descriptive as possible otherwise I simply won't be able to help, at all.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 10, 2013, 05:40:38 IP
Okay.

What I am trying to achieve: I am trying to get an upload avatar feature on a page it isn't normally on. If possible I'd like just php include the old one. If not possible, perhaps use the same function smf already uses. If still not possible create my own function. I am removing the old feature all together, so their won't be a duplicate.

I definitely don't mind using the old avatar feature if their is away to include it. I just need it on this custom page.  Hopefully I better described what I am looking for. Are there any other questions you can think of? I'd be happy to answer them.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 10, 2013, 05:52:57 IP
Where do you want to include it?
Why do you want to re-build something thats already built?

Like I said, the stuff that handles the profile page and all options over there is nothing but complicated, too many functions relies on each other, take one and you will have to take em all.

I'm still don't know for what exactly do you want to do this... seems so... redundant... not to mention messing with profile options isn't exactly easy, there is no modularity, all possible user options are so tightly integrated with each other and are saved with an extremely complicated system that taking a single one of them and using it independently is just impossible.

Thats why I wanted to know what exactly are you trying to do and whats your final purpose but it is futile to keep asking you if you're only providing half-empty answers :(

I have no idea why you want to build yet another page where users can save settings... it seems better to just include whatever settings you want to include in the already built page for user settings.

Theres a nice hook and you can create as much user options as you need, I did exactly the same with a mod I'm building.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 10, 2013, 06:06:22 IP
Lainaus käyttäjältä: Suki - syyskuu 10, 2013, 05:52:57 IP
Where do you want to include it?
Why do you want to re-build something thats already built?

Like I said, the stuff that handles the profile page and all options over there is nothing but complicated, too many functions relies on each other, take one and you will have to take em all.

I'm still don't know for what exactly do you want to do this... seems so... redundant... not to mention messing with profile options isn't exactly easy, there is no modularity, all possible user options are so tightly integrated with each other and are saved with an extremely complicated system that taking a single one of them and using it independently is just impossible.

Hmmm, I was unaware how tightly integrated the functions were. I seemed to have messed up. I'm not trying to give you half empty answers, I apologize. Our web team and I basically spent the last 4 grueling weeks non-stop programming and created a custom profile page from scratch. We completely got rid of the old one. We are literally finished with it except the 'edit avatar'. It's far too late to go back and change the old profile page. In hindsight I definitely should have. And I wish I would have.


You've answered a lot of questions. Thank you. I'm kind of stuck now because I don't want to re-do the entire process. It looks like if I'm not going that route I have to custom make a function to "Edit Avatar." So I'm under the assumption I can't call any of the smf functions for avatars like profileSaveAvatarData(&$value) correct?
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 10, 2013, 06:17:09 IP
You can, sure, but chances are you will get more errors than solutions.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 12, 2013, 02:05:17 IP
How would I start approaching this without calling the function profileSaveAvatarData()?
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 12, 2013, 02:44:58 IP
You start by having all the HTML you are going to use.

I have no idea where are you gonna put this so I cannot tell you how to build the form, the form must target an action or a file or whatever you want to use in the server side to handle the data.

I also don't have any idea what are you trying to accomplish with uploading an image, dunno what you're suppose to do after the user uploads an image either.

Like I said before, if you don't give full details it is impossible for me to help you out.

If you just want a generic way to upload an image to your server then just do google it, there are millions of examples on how to do it.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 12, 2013, 03:17:58 IP
I'm NOT trying to just upload an image. I think you misunderstand me. (I actually already do that on my site and no how to do it).

I'm trying to have a user select his avatar. If the only way they can select an image from their desktop and use it as their avatar is to upload it. Then so be it.

The only thing I am trying to achieve is mocking the "Edit Avatar" feature already in smf. (That is since I won't be able to include it without getting errors.)
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: bobdole2281 - syyskuu 12, 2013, 03:23:19 IP
What table stores the Avatars? Is it smf_members storing all Avatar data? Because I can only see Avatar url in that table.
Otsikko: Re: function profileSaveAvatarData(&$value)??
Kirjoitti: All Colours Sam - syyskuu 12, 2013, 03:31:45 IP
Then mock it, find out the which template renders it and which source file manages, then start copying code to whatever file are you using for your users to select an avatar.


And nope, I haven't misunderstood you, it just seem so silly to me to try to replicate something so complicated as the avatar stuff for no real reason or benefit other than having it somewhere else.

Thats why I cannot keep helping you, I have no idea if you're using the members table or using your own, no idea what other data are you collecting, how and for what.

If I were you I just point out your users to their real settings page inside their profile  or just extend the already built and working profile settings page and add whatever I want to add.

I still have no idea how this magical new place looks like or how is it coded, I don't know how you retrieve and save the users data neither. I don't know if this file is a standalone file or is it an inner SMF action or even a subaction inside an action.

I don't know how many times I already said this but if you keep posting half ideas and don't provide the FULL context of whatever you are trying to do is gonna be utterly difficult for both you and me. At some point I'm simply gonna be fed up of asking.

Lainaus käyttäjältä: bobdole2281 - syyskuu 12, 2013, 03:23:19 IP
What table stores the Avatars? Is it smf_members storing all Avatar data? Because I can only see Avatar url in that table.


It is a lot more complicated that just storing a file name...  thats the whole point...  quoting some random direct-to-TV movie I saw a few days ago: "You're dealing with forces you cannot understand".


Can you please post your entire code here, all of it, everything.