Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com_ajax #30208

Open
fvlasenko opened this issue Jul 28, 2020 · 8 comments
Open

com_ajax #30208

fvlasenko opened this issue Jul 28, 2020 · 8 comments

Comments

@fvlasenko
Copy link

fvlasenko commented Jul 28, 2020

What needs to be fixed

com_ajax

Why this should be fixed

Add functional ajax in admin module

How would you fix it

replace
$helperFile = JPATH_BASE . '/modules/mod_' . $module . '/helper.php';
to
$basePath = ($table->client_id) ? JPATH_ADMINISTRATOR : JPATH_SITE; $helperFile = $basePath . '/modules/mod_' . $module . '/helper.php';
remove
// Load language file for module $basePath = JPATH_BASE;

Side Effects expected

No

@Fedik
Copy link
Member

Fedik commented Jul 28, 2020

JPATH_BASE already holds a correct path, for an administrator and for a site.
If you need access to administrator module then do request to /administrator.

@SharkyKZ
Copy link
Contributor

Duplicate #25684.

Using client ID would be fine except that we can't determine it based on module name. Modules with the same name can be installed to both backend and frontend, e.g. like core mod_feed or mod_custom modules.

@Fedik
Copy link
Member

Fedik commented Jul 28, 2020

I do not think it is an issue, you just have to do a correct request:

for site modules: /index.php?option=com_ajax&module=foobar&format=json
for admin modules: /administrator/index.php?option=com_ajax&module=foobar&format=json

Same as with any component.

@SharkyKZ
Copy link
Contributor

This is no good if you want to use Ajax in module form.

@Fedik
Copy link
Member

Fedik commented Jul 29, 2020

why you ever need that? :)

It the same as for components, you cannot execute Site component by doing request to Backend, and vice versa. The same applies to the modules.

@SharkyKZ
Copy link
Contributor

To update form fields using AJAX. It's a reasonable use case.

@Fedik
Copy link
Member

Fedik commented Jul 30, 2020

Ah okay, I finally get it, it for a module configuration form, not for a module itself 😄

Well, then, just add &client=0 to query, and update com_ajax to use it.
So you can call site module from backend. Eg:
/administrator/index.php?option=com_ajax&module=foobar&format=json&client=0

But, it should be forbidden to call administrator module from the site. So if someone call &client=1 from the site then com_ajax should throw an error.

@fvlasenko
Copy link
Author

@Fedik i use this in admin panel modules
client="administrator"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants