Announcement

  •  » Engine
  •  » Handing over variables of the $user array to uploadify.php

#1 2012-03-08 23:14:49

wernerk
Member
2012-01-22
31

Handing over variables of the $user array to uploadify.php

Hi,

I'm experimenting with the admin upload functions - it would take more than one sentence to explain why - and perhaps you can help me. I want to add another (new) index to the $user array in photos_add_direct_process.inc.php, let's call it $user['foo']. So I write $user['foo']="bar";. Now I want to hand it over to the function "add_uploaded_file" in functions_upload.inc.php.

It works fine as long I stay in the normal html upload mode. $user is defined as global in this function and I stay on the same php page - so no problem ...

But if I try the same thing with multiple upload the whole array $user is transfered to "add_uploaded_file" except my recently added ['foo'] index variable. I do know that it is difficult to hand over a variable from one to another php page. And the way from photos_add_direct.php to uploadify.php is very stony because it goes across more than one php page and includes java script as well.

But why then are all the other index entries like ['username'] or ['id'] still there??? And if you add a new index to $user in uploadify.php itself it is also handed over correctly to add_uploaded_file.

And now I am searching for hours and days and I don't find the point where the $user contents is changed or reloaded by uploadify or where and how it's handed over. Is it perhaps done by JQuery/uploadify itself?

Greetings
Werner

Last edited by wernerk (2012-03-08 23:23:29)

Offline

 

#2 2012-03-09 00:27:43

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Handing over variables of the $user array to uploadify.php

Hi wernerk,

It's interesting to see how you investigate Piwigo source code, you're a future Piwigo expert :-)

$user is loaded in include/user.inc.php which is itself loaded in include/common.inc.php. The variables you find in $user come from database tables USERS_TABLE and USER_INFOS_TABLE.

Instead of trying to save your variable in $user, you'd better save them in session:

Code:

$_SESSION['foo'] = 'bar';

and then in add_uploaded_file, you can write (with no "global"):

Code:

echo $_SESSION['foo'];

By the way: modifying Piwigo core is not a great idea, your changes will be lost on next upgrade.

Offline

 

#3 2012-03-09 03:16:25

wernerk
Member
2012-01-22
31

Re: Handing over variables of the $user array to uploadify.php

Hi,

plg wrote:

It's interesting to see how you investigate Piwigo source code, you're a future Piwigo expert

Perhaps I'm gonna become it some day. ;-)

plg wrote:

$user is loaded in include/user.inc.php which is itself loaded in include/common.inc.php. The variables you find in $user come from database tables USERS_TABLE and USER_INFOS_TABLE.

I already thought of common.inc being involved, but I only looked at the empty $user array at the beginning. ;-)

plg wrote:

Instead of trying to save your variable in $user, you'd better save them in session:

Yep! That's exactly what I've been looking for! 8-) Thank you!

plg wrote:

By the way: modifying Piwigo core is not a great idea, your changes will be lost on next upgrade.

I know - and I do not either like to do such evil things ;-). The whole thing is born out of necessity because I had to install a rather large project for me and some friends within a few weeks and I liked piwigo best. But there were some things to be tweaked and some bugs to be found. For example I want to improve multi-user administration, which seems to be a weak point although there are some nice things like the "community" plugin. I've done a lot of stuff with theme.css and the templates and even succeeded in writing a little plugin. But for some problems there is no other short term solution but little modifications in the core. But even the plugins and templates are not upgrade-proof, maybe they have also to be adapted as soon as a new version is released.

And the spin-off is that I am learning php ;-)

First of all I do the modification for myself. But when the last problems are solved, I shall release a documentation - and if you are interested you can perhaps implement some of my modifications into the official code.

Greetings
Werner

Offline

 

#4 2012-03-09 10:20:52

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Handing over variables of the $user array to uploadify.php

wernerk wrote:

First of all I do the modification for myself. But when the last problems are solved, I shall release a documentation - and if you are interested you can perhaps implement some of my modifications into the official code.

OK, you'll send your modified version and I'll be able to compare it to the official Piwigo code.

Offline

 

#5 2012-03-17 20:07:55

wernerk
Member
2012-01-22
31

Re: Handing over variables of the $user array to uploadify.php

Hello Pierrick,

I'm ready and I have sent it to your gmail address. Have you received it?

Greetings
Werner

Offline

 
  •  » Engine
  •  » Handing over variables of the $user array to uploadify.php

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact