Hi,
Our team is quite comfortable with using osTicket and uneasy to use other web panels to manage main website. I would like to integrate another webadmin panel into osTicket (in other words use existing osticket authorization system to let Agents manage other website).
At first, I thought I will need to make a plugin, which will simply display some additional tab and all things there will be related to managing the main website.

Issues that I consider, before starting the work:
1. Plugin creation is poorly documented
2. It requires integration and compatibility to changing system (I need to make sure that the plugin does not need to be upgraded each time new osTicket is released, ergo I need to use minimum of osticket's variables and modules)
3. It seems I have only "Agent" and "Admin" role, I could either create another db with list of osTicket users who have specific rights or fix it to some specific group. What do you think is better?
4. The main website (to be managed) is on the same server, but under top level domain (osticket is in subdomain), additionally it has different database. As a result, I would need to put all php files with the osticket folder strucutre to execute them. The database could be access, but do you see any issues?

Any hints and comments will be appreciated.

  1. I agree
  2. I use INCLUDE. Yes, on every osTicket upgrade I need paste one line in source code.
    You need only one variable: $thisstaff. Because as you say: "let Agents manage other website".
  3. Role for others websites is better manage in another database. You will not be limited.

I use similar "plugin".

If authorised staff is logged in, can see the link. Not authorised staff see nothing.

    PavelH Hi and thanks for feedback. It seems I am trying to achieve something that you already have running. Is there any chance that you release some of the code (I mean at least frame for authorization, admin checking etc, the functions are not necessary). Thank you in advance.

    Of course.

    Database
    I use two DB. Ticket for osTicket and Extra for my modifications.
    In Extra is the table staff_settings. This is what interests you.

    Columns are id (of course), next staff_id and a column for authorization check.
    For authorization check i use only 1 or 0 (yes or no), but you can use more for authorization level, if you need.

    Directory and files in
    In osTicket directory is a subfolder ph_scripts with all my files. On upgrade osTicket I need copy only one folder.

    In this folder is, as example, file pA_modify.inc.php with following content:

    <?php
    //Connection with DB and table
    include "../PH_scripts/connect_db.php";
    
    $tabulka=mysqli_select_db($spojeni, "cis_extra");
    mysqli_query($spojeni, "set names utf8");
    if(!@tabulka) die ("Nicht verbunden mit Database cis_extra."); 
    
    //Get staff ID from osTicket
    $StaffID = $thisstaff->getId();
    $pa_anpassungen = 0;
    
    //Read value from table staff_settings into variable
    if(!$cis_staff_settings = mysqli_query($spojeni, "SELECT * FROM cis_staff_settings WHERE id=\"$StaffID\"")) {echo "<h2>Nicht verbunden mit Tabelle cis_staff_settings.</h2>\n"; }
    while($cis_staff_settings = mysqli_fetch_array($cis_staff_settings))
    	{
    		 $pa_anpassungen = $cis_staff_settings["pa_anpassungen"];
    	}
    	
    mysqli_close($spojeni);
    
    //If variable contains 1, show a link SCP
    if($pa_anpassungen == "1") {
    $Link = "./PAAD/get.php?StaffID=".$thisstaff->getId();?>
    | <a href="<?php echo ROOT_PATH.$Link ?>" target="_blank"><?php echo __('pA Anpassungen'); ?></a>
    <?php }	?>

    Editing osTicket core file
    Add INCLUDE function anywhere you want.

    In my case I add <?php include "../PH_scripts/pA_modify.inc.php"?> in \include\staff\header.inc.php

        <div id="header">
            <p id="info" class="pull-right no-pjax"><?php echo sprintf(__('Welcome, %s.'), '<strong>'.$thisstaff->getFirstName().'</strong>'); ?>
               <?php
                if($thisstaff->isAdmin() && !defined('ADMINPAGE')) { ?>
                | <a href="<?php echo ROOT_PATH ?>scp/admin.php" class="no-pjax"><?php echo __('Admin Panel'); ?></a>
                <?php }else{ ?>
                | <a href="<?php echo ROOT_PATH ?>scp/index.php" class="no-pjax"><?php echo __('Agent Panel'); ?></a>
                <?php } ?>
                | <a href="<?php echo ROOT_PATH ?>scp/profile.php"><?php echo __('Profile'); ?></a>	
    	    <?php include "../PH_scripts/pA_modify.inc.php"?>
                | <a href="<?php echo ROOT_PATH ?>scp/logout.php?auth=<?php echo $ost->getLinkToken(); ?>" class="no-pjax"><?php echo __('Log Out'); ?></a>
            </p>
            <a href="<?php echo ROOT_PATH ?>scp/index.php" class="no-pjax" id="logo">
                <span class="valign-helper"></span>
                <img src="<?php echo ROOT_PATH ?>scp/logo.php?<?php echo strtotime($cfg->lastModified('staff_logo_id')); ?>" alt="osTicket &mdash; <?php echo __('Customer Support System'); ?>"/>
            </a>
        </div>

    On upgrade osTicket I need add only this one line.

    Hi Pavel,

    Thanks a lot. It's interesting to read the mix of German and Slovak (I presume), since I speak Polish and German ?

    I have it working and tested, but I see that the link goes target=blank and to 3rd party script with admin id is given in $_GET. Have you simplified the code for publishing or is it like this? You are not containing the osTicket user inside the osTicket scp?

    Its czech and german.

    • target="_blank" open new tab or window, if link is clicked: https://www.w3schools.com/tags/att_a_target.asp
    • Yes, I give ID as GET parrametr. In this case is ID not a secret information. But this is only one option from many others. You can modify it as you need.
    • You are not containing the osTicket user inside the osTicket scp? - I don't understand.

    I don't think I'm the only one who has a similar modification. It would be interesting if the others also revealed their solution.

    Write a Reply...