Announcement

Collapse
No announcement yet.

issues setting up gui parameters via a plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • issues setting up gui parameters via a plugin

    Hello,

    I'm trying to set up gui parameters in a gui plugin. I get a strange behavior: the parameters that I am setting only seem to be taken into account under certain circumstances. Here is the scenario:

    * the register.js file of the plugin looks like this

    Code:
    start_user_env_initialization();
    
    // entry point for the initialization
    function start_user_env_initialization() {
    
       // set gui parameters
       set_gui_parameters();
    }
    
    function set_gui_parameters() {
       var default_param = {"global":{"landing_page":{"module":"calendar"}}};
       ox.JSON.put(AjaxRoot + "/config/gui?session=" + session, default_param,set_gui_parameters_ok, operation_nok, true);
    }
    
    function set_gui_parameters_ok(reply) {
       console.log("Set default categories OK: " + reply);
    }
    
    function operation_nok(reply) {
       console.log ("Operation NOK: " + reply);
    }
    * with this code, every time a user logs in, the default landing page in its properties should be changed to "Calendar".

    * to check this, I have changed the landing page to "Contacts" and I have logged out and logged in using several browsers.

    * the issue is: the landing page stays to "Contacts" instead of being "Calendar"

    I manage to get the "Calendar" landing page when I do the following:

    * before logging out, I restart the groupware

    * then I log in again

    => the landing page is set to "Calendar"

    Any idea where this behavior is coming from and how to counter it?

    Michaël

  • #2
    The GUI loads the configuration during login and saves it back to the server during logout. Your request overwrites the entire GUI configuration, but it gets overwritten again by the GUI when you log out.

    The global variable config stores the loaded configuration. Change it (don't reassign!) if you want to modify a user's settings. Then these changes will take effect on the next login.

    Comment


    • #3
      That does indeed the trick. Thank you!

      Now, with this approach, the config object is modified locally. In order to save the object before the user logs out, is triggerEvent('OX_SAVE_OBJECT') the right way to do the save? Or is this some internal API that shouldn't be used?

      Michaël

      Comment


      • #4
        "OX_SAVE_OBJECT" is an internal event triggered by the big "Save" button in some views. To work, it requires the correvt configuration view to be displayed, and the internal state to indicate that the right input fields were changed.

        To store the configuration before logout, save the config.gui object like in your first example. Note that this doesn't switch the view. By the time your plugin is loaded, the default view is probably already displayed. The only purpose that serves, is storing the configuration for the case that the user closes the browser window without logging out.

        Comment


        • #5
          Understood. Thank you for this additional piece of information.

          Comment

          Working...
          X