Forums / Cotonti / Development / Ajax part in plugins

Suggestion for some improvments

Macik
#1 2010-07-29 20:36
Now (in cotonti 0.6.9) when you exec some ajax part of you plugin you can not use usual enviroment.
I talk aboun automatic loading you plugin LANG files and full initing $usr variable.
(I mean $usr['auth_read'], $usr['auth_write'], $usr['isadmin']);

So, now I must include some part of code that duplicate 'plug.inc.php' in each of my plugin that uses AJAX (plug.php?r=plug) and need to be ajax-result localized.

I think it done for some speed optimizing for AJAX part in simple plugins. But some times developer needs full power of CMS to use in AJAX responce part.

My suggestion to make it configurable: when user use additional parameter (for example 'plug.php?e=plug&h=fullajax') it loads all variables and had done all init as in usual plugin part (plug.php?e=plug).
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
ez
#2 2010-07-29 21:40
I think Ajax should be as clean as possible... Why do you ask.. :/

Because ajax responses needs to be FAST
It is usually an action that the user is waiting for (so an UserInterface thing)

If you need rights:
just do: $plug_admin = sed_auth('plug', 'Yourplug', 'A');

Language file:
require_once(sed_langfile('Yourplug'));

I think $cfg is available, not sure about $usr..
maybe try: global $usr
==- I say: Keep it EZ -==