tomolimo / processmaker

GLPI plugin that provides an interface with ProcessMaker (http://www.processmaker.com/)
31 stars 11 forks source link

glpi connection to pm #13

Closed lekzz closed 7 years ago

lekzz commented 7 years ago

Hi,

I can't get GLPI to connect to PM.

Ubuntu: 14.04 with php5.6 from ondrej ppa GLPI: 9.1.3 ProcessMaker: 3.0.1.8-RE-1.5 GLPI URL: http://ticket.intra/ PM URL: http://pmos.intra/ user/pass during testing: admin / admin (no special characters)

No problems with PM itself. Install and operation seem to work fine.

GLPI's php-errors.log: 2017-05-05 11:51:00 [512@glpi01] *** PHP Notice(8): Undefined offset: 2 Backtrace : plugins/processmaker/inc/config.class.php:101 plugins/processmaker/inc/config.class.php:86 PluginProcessmakerConfig::getCommonDomain() inc/commondbtm.class.php:1065 PluginProcessmakerConfig->prepareInputForUpdate() plugins/processmaker/front/config.form.php:15 CommonDBTM->update() 2017-05-05 11:51:00 [512@glpi01] *** PHP Runtime Notice(2048): Only variables should be passed by reference Backtrace : plugins/processmaker/inc/config.class.php:104 plugins/processmaker/inc/config.class.php:86 PluginProcessmakerConfig::getCommonDomain() inc/commondbtm.class.php:1065 PluginProcessmakerConfig->prepareInputForUpdate() plugins/processmaker/front/config.form.php:15 CommonDBTM->update() 2017-05-05 11:51:00 [512@glpi01] *** PHP Runtime Notice(2048): Only variables should be passed by reference Backtrace : plugins/processmaker/inc/config.class.php:105 plugins/processmaker/inc/config.class.php:86 PluginProcessmakerConfig::getCommonDomain() inc/commondbtm.class.php:1065 PluginProcessmakerConfig->prepareInputForUpdate() plugins/processmaker/front/config.form.php:15 CommonDBTM->update() 2017-05-05 11:51:01 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:175 plugins/processmaker/inc/config.class.php:302 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab() 2017-05-05 11:51:01 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:190 plugins/processmaker/inc/config.class.php:302 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab()

Maybe an issue with pm_admin_user?

tomolimo commented 7 years ago

Hello, Could you screen copy the PM plugin configuration form? thank you, Tomolimo

tomolimo commented 7 years ago

Could you try to change the getCommonDomain function in plugins/processmaker/config.class.php? replace it by:

 static function getCommonDomain($url1, $url2) {
  $domain = '';
  try {
     $glpi = explode( "/", $url1) ;
     $glpi = explode( ".", $glpi[2] );
     $pm = explode( "/", $url2) ;
     $pm = explode( ".", $pm[2] );
     $cglpi = explode(":", array_pop( $glpi ));
     $cglpi = array_shift($cglpi) ;
     $cpm = explode(":", array_pop( $pm));
     $cpm = array_shift($cpm) ;
     while( $cglpi && $cpm && $cglpi == $cpm ) {
        $domain = $cglpi.($domain==''?'':'.'.$domain) ;
        $cglpi = array_pop( $glpi ) ;
        $cpm = array_pop( $pm ) ;
     }
     if( $domain != '' ) {
        return $domain ;
     }
  } catch(Exception $e) {}
  return '';
}
lekzz commented 7 years ago

I tried the new function but same result. Plugin config screenshot: image

btw: joe (joe's own editor) thinks the $domain line's syntax is not right: image

the number of errors in glpi's errors log seems to have reduced tho: 2017-05-05 13:32:06 [512@glpi01] *** PHP Notice(8): Undefined offset: 2 Backtrace : plugins/processmaker/inc/config.class.php:101 plugins/processmaker/inc/config.class.php:86 PluginProcessmakerConfig::getCommonDomain() inc/commondbtm.class.php:1065 PluginProcessmakerConfig->prepareInputForUpdate() plugins/processmaker/front/config.form.php:15 CommonDBTM->update() 2017-05-05 13:32:06 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:177 plugins/processmaker/inc/config.class.php:304 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab() 2017-05-05 13:32:06 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:192 plugins/processmaker/inc/config.class.php:304 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab()

Instructions according to https://github.com/tomolimo/processmaker-server/wiki where followed. I do however just notice i'm still running mysql 5.5 which is unsupported, i'll try to get it updated to 5.7. (A bit annoying that processmaker doesn't support php7 and thus no ubuntu 16.04, but also doesn't support the default ubuntu 14.04 php/mysql versions, but that is ofcourse not your problem). But i doubt the mysql version prevents the glpi pm integration.

tomolimo commented 7 years ago

Your problem is coming from the fact that GLPI URL is not defined in the "General setup" tab. As you can see, the "None!" in red shows that GLPI URL and PM URL don't share the same root domain. So define GLPI URL in the "General Setup" tab Keep your current version of MySQL: you'll see later if it's necessary to upgrade Regards, Tomolimo

tomolimo commented 7 years ago

Also I've prepared a new and more efficient function:

static function getCommonDomain($url1, $url2) {
  $domain = '';
  try {
     $glpi = explode(".", parse_url($url1, PHP_URL_HOST));
     $pm = explode( ".", parse_url($url2, PHP_URL_HOST));
     $cglpi = array_pop( $glpi );
     $cpm = array_pop( $pm );
     while( $cglpi && $cpm && $cglpi == $cpm ) {
        $domain = $cglpi.($domain==''?'':'.'.$domain) ;
        $cglpi = array_pop( $glpi ) ;
        $cpm = array_pop( $pm ) ;
     }
     if( $domain != '' ) {
        return $domain ;
     }
  } catch(Exception $e) {}
  return '';
}
tomolimo commented 7 years ago

And also for javascript:

echo Html::scriptBlock("
        function setCommonDomain() {

           function parseUrl( url ) {
              var a = document.createElement('a');
              a.href = url;
              return { host: a.hostname, port: a.port, scheme: a.protocol.slice(0, -1), path: a.pathname, query: a.search.slice(1), fragment: a.hash.slice(1)  } ;
           }
           var domain = '';
           try {
              var glpi = parseUrl( '".$CFG_GLPI['url_base']."' ).host.split('.') ;
              var pm = parseUrl( $('input[name=pm_server_URL]').val()).host.split('.');
              var cglpi = glpi.pop() ;
              var cpm = pm.pop() ;
              while( cglpi && cpm && cglpi == cpm ) {
                 domain = cglpi + (domain==''?'':'.' + domain) ;
                 cglpi = glpi.pop() ;
                 cpm = pm.pop() ;
              }
              if( domain != '' ) {
                 $('div[name=domain]').text(domain) ;
                 $('div[name=domain]').parent().attr('color', 'green');
                 return;
              }
           } catch(ex) {}
           $('div[name=domain]').text('".$LANG['processmaker']['config']['domain-error']."') ;
           $('div[name=domain]').parent().attr('color', 'red');
        };
        $('input[name=pm_server_URL]').on('keyup', setCommonDomain ) ;
        setCommonDomain() ;
    ");
lekzz commented 7 years ago

Thanks again for your fast answer(s).

The GLPI URL was definied but apparently not in the right way. It was set to ticket.intra, after changing it to http://ticket.intra/. "None!" now changed to "intra" in green.

However even after changing the URL and updating the function and the javascript still the same problem. Mysql has been upgraded to 5.7 using the official mysql repository.

The errors now seem to have go down to only 2 lines: 2017-05-05 16:37:08 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:180 plugins/processmaker/inc/config.class.php:307 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab() 2017-05-05 16:37:08 [512@glpi01] *** PHP Notice(8): Undefined index: pm_admin_user Backtrace : plugins/processmaker/inc/config.class.php:195 plugins/processmaker/inc/config.class.php:307 PluginProcessmakerConfig::showConfigForm() inc/commonglpi.class.php:483 PluginProcessmakerConfig::displayTabContentForItem() ajax/common.tabs.php:97 CommonGLPI::displayStandardTab()

Regards, Lex

tomolimo commented 7 years ago

You need to define the pm admin that will be used by the plug-in when needed. This user is a PM admin. And you must set it in the plug-in configuration.

lekzz commented 7 years ago

Just discovered something else. Looks like the problem is with the pm_admin_user variable which doesn't seem to get filled.

I removed the mysql user/pass to empty all user/pass fields. Then if i fill in only the username for mysql and press save, the connection obviously fails but the settings page will reload and username will stay filled in to what was just entered. However if i do the same with the username for pmos and press save, the page will reload but the pmos username will be empty again.

tomolimo commented 7 years ago

This will clear the error message 'test failed'

tomolimo commented 7 years ago

Could you check the config table in the DB?

lekzz commented 7 years ago

Before pressing save: image

After pressing save: image

tomolimo commented 7 years ago

The glpi_plugin_processmaker_configs table?

tomolimo commented 7 years ago

There is something wrong between config form and PHP script and table

lekzz commented 7 years ago

mysql> select * from glpi_plugin_processmaker_configs; +----+-----------------+--------------------+--------------+-----------------+---------------------+-------------------+ ----------+---------------+------------------+------------------+--------------------+--------+-------------+---------+ | id | name | pm_server_URL | pm_workspace | pm_theme | date_mod | taskcategories_id | users_id | pm_group_guid | pm_dbserver_name | pm_dbserver_user | pm_dbserver_passwd | domain | maintenance | comment | +----+-----------------+--------------------+--------------+-----------------+---------------------+-------------------+ ----------+---------------+------------------+------------------+--------------------+--------+-------------+---------+ | 1 | Process Maker 1 | http://pmos.intra/ | workflow | glpi_neoclassic | 2017-05-05 16:49:13 | 1 | 283 | 0 | localhost | root | *REMOVED* | intra | 0 | NULL | +----+-----------------+--------------------+--------------+-----------------+---------------------+-------------------+ ----------+---------------+------------------+------------------+--------------------+--------+-------------+---------+ 1 row in set (0.00 sec)

lekzz commented 7 years ago

btw: i tried some reinstalls by removing /opt/processmaker and droping the processmaker database. However i never did something with the glpi database.

tomolimo commented 7 years ago

It seems like you did an upgrade of plug in? Could you try to uninstall the plug-in, drop glpi_plugin_processmaker_xxx tables And re-install the plug-in ?

tomolimo commented 7 years ago

Normally in the config table you should be able to find pm_admin_xxx fields

lekzz commented 7 years ago

uninstall/drop/install seemed to have fixed the issue! thnx!

I can't select any group in "Group in ProcessMaker which will contain all GLPi users" yet tho. The group does exist in pmos. Is there anything else that needs to be done to be able to select a group or should it just work right away?

tomolimo commented 7 years ago

The group list comes from the db, which is accessed by the identification set in the config form, above.

lekzz commented 7 years ago

Yeah was afraid of that :)

It stays empty even after rebooting the server and relaunching the browser (to make sure everything is reloaded): image

lekzz commented 7 years ago

pmos screenshot: image

tomolimo commented 7 years ago

Did you change the name of the std workspace?

tomolimo commented 7 years ago

Someone else have had that issue also, check in the solved issues

tomolimo commented 7 years ago

It was Satyan01

lekzz commented 7 years ago

Ok will do! Thnx so far for your fast support!