Homepage | Products | OX Knowledge Base | Support | Try Now | Contact | Company
OX Logo
Results 1 to 5 of 5
  1. #1

    Default 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. #2
    Join Date
    Feb 2007
    Posts
    251

    Default

    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.

  3. #3

    Default

    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

  4. #4
    Join Date
    Feb 2007
    Posts
    251

    Default

    "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.

  5. #5

    Default

    Understood. Thank you for this additional piece of information.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •