In need of some jrCore_download_file advice

SteveX
SteveX
@ultrajam
8 years ago
2,584 posts
In my module, I need to update the item image (pie chart) when specific item fields change.

I am doing that by calling an update_piechart function which then calls a view using jrCore_download_file. The view returns the new image which is then saved to the item.

But (unless I have a browser tab open with the image-making view) the $_user data is not available in that view - I am not logged in.

Should I be able to see the $_user data for the logged in user there?

I tried checking using flags, but they are also not available in that view. Are flags deleted when a new view is called?

I'm coping with that by updating the item before using jrCore_download_file, then checking that the item has just been updated in the view producing the image, but that doesn't feel quite right, so I'm wondering if there is a better way to do this?

Any suggestions would be appreciated!

Thanks :)


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 06/14/16 10:11:00PM
michael
@michael
8 years ago
7,715 posts
if not flags, set/get temp value, eg:
 jrCore_set_temp_value('jrAudio', $zipfile_name, time());

Its like an associative array but gets stored/retrieved via the database instead of cookies or the session.

What I would do to debug is to put a breakpoint where you want to use the $_user, then go looking higher in the stack to see if its there any earlier on. Might be gettable with
global $_user;

--
Why do you need the $_user data to be available, is it causing an issue?
SteveX
SteveX
@ultrajam
8 years ago
2,584 posts
Thanks Michael.

Ideally I'd check that the user can edit the item before generating the image.

If I global and fdebug $_user from the function it's for a not logged in user (unless I have that view open in a separate tab).

I'll try with the temp value.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 02/23/16 01:43:22AM
michael
@michael
8 years ago
7,715 posts
I would expect that on the ajax page the $_user is still logged in, unless its happening behind the scenes where there is no SESSION.

Tags