Navigation

    Kopano
    • Register
    • Login
    • Search
    • Categories
    • Get Official Kopano Support
    • Recent
    Statement regarding the closure of the Kopano community forum and the end of the community edition

    Intranet: per-user Configuration

    Plugins for Kopano WebApp
    3
    6
    1574
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • itserv
      itserv last edited by

      Hello Community!

      I’d like to have a simple if-then-clause in my Intranet.conf config file to have a per-user variable definition.

      I’m not familiar with php-programming, especially I don’t know the PHP variable holding the user name or login name for WebApp. Can somebody please translate the following peudocode to valid php:

      if (login_name = "xxx"); then
        define('PLUGIN_INTRANET_BUTTON_TITLE_3', 'myURL');
        define('PLUGIN_INTRANET_URL_3', 'http://myURL.com/');
      end if
      

      Thank you very much!

      1 Reply Last reply Reply Quote 0
      • robertwbrandt
        robertwbrandt last edited by

        I wanted to do something similar, but I don’t think the Username is available via Environment Variables. Luckily I was able to using various VLANs instead. I also have an internal proxy for I needed to look for the source IP and the X-Forwarded-for IP:

        if ( strncmp("10.200.150.", $_SERVER['REMOTE_ADDR'], 11) === 0 ||
             strncmp("10.201.150.", $_SERVER['REMOTE_ADDR'], 11) === 0 ||
             strncmp("10.200.200.", $_SERVER['REMOTE_ADDR'], 11) === 0 ||
             strncmp("10.201.200.", $_SERVER['REMOTE_ADDR'], 11) === 0 ||
             strncmp("10.200.150.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 ||
             strncmp("10.201.150.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 ||
             strncmp("10.200.200.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 ||
             strncmp("10.201.200.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 ) {
                define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', true);
                define('PLUGIN_INTRANET_BUTTON_TITLE', 'Teams');
                define('PLUGIN_INTRANET_URL', 'https://teams/');
        } else {
                define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', false);
                define('PLUGIN_INTRANET_BUTTON_TITLE', 'Teams');
                define('PLUGIN_INTRANET_URL', 'https://teams/');
        }
        
        1 Reply Last reply Reply Quote 0
        • itserv
          itserv last edited by

          In another plugin, I found the environment variable

          $data['username']
          

          It might be as simple as

          if ( $data['username'] == 'xxx' ) {
            define('PLUGIN_INTRANET_BUTTON_TITLE_3', 'myURL');
            define('PLUGIN_INTRANET_URL_3', 'http://myURL.com/')
            }
          

          I will test this when I have access to my System. Right now, i’m on the road.

          1 Reply Last reply Reply Quote 1
          • itserv
            itserv last edited by

            OK, that does not work.

            $data[‘username’] is an empty string when the config file is called. Still looking for a solution …

            1 Reply Last reply Reply Quote 0
            • marty
              marty Kopano (Inactive) last edited by

              @itserv Maybe this will help you:
              $GLOBALS[‘mapisession’]->getUserName()

              https://documentation.kopano.io/deskapp_admin_manual
              http://documentation.kopano.io/webapp_smime_manual
              https://documentation.kopano.io/webapp_admin_manual

              itserv 1 Reply Last reply Reply Quote 1
              • itserv
                itserv @marty last edited by

                Great, that did the job. Thank you.

                For reference: my config file now more or less like this:

                <?php
                
                define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', false);
                
                define('PLUGIN_INTRANET_BUTTON_TITLE', 'Kopano.io');
                define('PLUGIN_INTRANET_URL', 'http://www.kopano.io/');
                define('PLUGIN_INTRANET_AUTOSTART', false);
                
                // More buttons can be added by adding a number as follows
                // Note: Numbers must start with 1 and be sequential
                define('PLUGIN_INTRANET_BUTTON_TITLE_1', 'Kopano.com');
                define('PLUGIN_INTRANET_URL_1', 'http://kopano.com/');
                define('PLUGIN_INTRANET_AUTOSTART_1', false);
                
                
                $user_name = $GLOBALS["mapisession"]->getUserName();
                
                if ( $user_name == 'someuser' ) {
                	define('PLUGIN_INTRANET_BUTTON_TITLE_2', 'AnotherTitle');
                	define('PLUGIN_INTRANET_URL_2', 'https://some_url');
                }
                
                
                1 Reply Last reply Reply Quote 2
                • First post
                  Last post