Moodle

YUI files are not loaded when user is not logged in

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7
  • Fix Version/s: 1.7.1, 1.8
  • Component/s: AJAX
  • Labels:
    None
  • Affected Branches:
    MOODLE_17_STABLE
  • Fixed Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE

Description

YUI files are not loaded when user is not logged in. On those pages you get the error "YAHOO" not found.

The YUI files are called via the ajaxlib function.

The YUI libraries should always load - independent from the login state.

Activity

Hide
Vy-Shane Sin Fat added a comment -

I've added a check in ajaxenabled() in lib/ajax/ajaxlib.php. The function now returns true if ajax is enabled for the site and the user is not logged in. If a user is logged in, then we check whether the user wants ajax.

Show
Vy-Shane Sin Fat added a comment - I've added a check in ajaxenabled() in lib/ajax/ajaxlib.php. The function now returns true if ajax is enabled for the site and the user is not logged in. If a user is logged in, then we check whether the user wants ajax.
Hide
Urs Hunkler added a comment -

Great, thank you Vy.

Your answer shows another important aspect about using the YUI libraries.

Is the "Ajax" option meant to switch all YUI functionality like "Drag & Drop", "Dialogues", "Animation" etc. or just the "Drag & Drop course?

1) The option disables the general use of YUI on a user base. Development of YUI enhanced interfaces will be hindered. Developers are forced to create alternate solutions without YUI support. This is not possible and economically realistic in some areas.

2) The option disables YUI only for the "Drag & Drop" course.

From the actual discussion I am not sure if the difference is clear and planed? I vote for 2). I will need to continue using a workaround for the YUI library for Moodle 1.7 with the actual option.

Do you know a way to check if some YUI libraries are already loaded? If people - like me - start to use their own loading routines Moodle possibly gets into trouble with double loaded YUI files.

Can you think about a function collecting all YUI load calls and build one call from it?

Some background: In the moment I use different php files for every YUI functionality. Each should call only those YUI files it needs. Actually I have to call all YUI libraries together somewhere. And this call may conflict with the "Drag & Drop" course YUI loading functions.

In header.php I reference only those functionality files I want to use in the theme. This gives me greater flexibility in combining different functionality. YUI supports this way, In Moodle problems may arise.

Show
Urs Hunkler added a comment - Great, thank you Vy. Your answer shows another important aspect about using the YUI libraries. Is the "Ajax" option meant to switch all YUI functionality like "Drag & Drop", "Dialogues", "Animation" etc. or just the "Drag & Drop course? 1) The option disables the general use of YUI on a user base. Development of YUI enhanced interfaces will be hindered. Developers are forced to create alternate solutions without YUI support. This is not possible and economically realistic in some areas. 2) The option disables YUI only for the "Drag & Drop" course. From the actual discussion I am not sure if the difference is clear and planed? I vote for 2). I will need to continue using a workaround for the YUI library for Moodle 1.7 with the actual option. Do you know a way to check if some YUI libraries are already loaded? If people - like me - start to use their own loading routines Moodle possibly gets into trouble with double loaded YUI files. Can you think about a function collecting all YUI load calls and build one call from it? Some background: In the moment I use different php files for every YUI functionality. Each should call only those YUI files it needs. Actually I have to call all YUI libraries together somewhere. And this call may conflict with the "Drag & Drop" course YUI loading functions. In header.php I reference only those functionality files I want to use in the theme. This gives me greater flexibility in combining different functionality. YUI supports this way, In Moodle problems may arise.
Hide
Vy-Shane Sin Fat added a comment -

Hi Urs,

The option is really meant to disable the ajax in course editing. As you can tell, the ajax integration with Moodle is very patchy right now, and very much tied to the course editing stuff.

I agree that 2) is probably the better option.

Adding the isloggedin() check in ajaxenabled() is really a hack. What we need is a way to check whether the YUI libs are loaded.

We would want something like a require_once_js() too. We just haven't got around to defining a proper set of general purpose functions for YUI use in Moodle.

Unfortunately, you are ahead of the curve here by making use of YUI so early in the game. Not much thought has yet been given with regards to the bigger picture. The push was to get ajax course editing working first (it's not stable yet).

Show
Vy-Shane Sin Fat added a comment - Hi Urs, The option is really meant to disable the ajax in course editing. As you can tell, the ajax integration with Moodle is very patchy right now, and very much tied to the course editing stuff. I agree that 2) is probably the better option. Adding the isloggedin() check in ajaxenabled() is really a hack. What we need is a way to check whether the YUI libs are loaded. We would want something like a require_once_js() too. We just haven't got around to defining a proper set of general purpose functions for YUI use in Moodle. Unfortunately, you are ahead of the curve here by making use of YUI so early in the game. Not much thought has yet been given with regards to the bigger picture. The push was to get ajax course editing working first (it's not stable yet).
Hide
Urs Hunkler added a comment -

Please follow the forum disussion http://moodle.org/mod/forum/discuss.php?d=63792.

Show
Urs Hunkler added a comment - Please follow the forum disussion http://moodle.org/mod/forum/discuss.php?d=63792.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: