OTRS sessiondata in your scripts
For an easy integration of some PHP scripts with the trouble ticket system OTRS I use a script to read all session data. The integration follows the method K.I.S.S. (keep it simple and stupid): include the file OTRS_Session.php and create an instance of the class OTRS_Session. After a successfull creation of an OTRS_Session object all available data except the uncrypted password will be available as a property. Here is a small example:
1 : <?php 2 : require_once 'OTRS_Session.php'; 3 : $dsn = 'mysql://user:passwort@host/databasename'; 4 : $o = new OTRS_Session($dsn); 5 : print $o->userLastname."\n"; 6 : print $o->userLogin."\n"; 7 : print $o->userEmail."\n"; 8 : >
After running this script you will see the user's lastname, loginname and his email - if he is logged in. For accessing the database I use the PEAR package MDB2, see the documentation for available drivers and the format for the dsn. Choose the driver you use with you OTRS installation.
At the moment, this script is tested with PHP 4, MySQL and OTRS 2.0.4 (cookie based authentification). For questions, bugfixes or corrections please send me an email. Also let me know your working configuration so I'm able to create a matrix with working configurations.

