Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Multiple Front ends

I am trying to create multiple frontend for OSticket so each department has its own front end for people to add tickets to. On the open.php page I am trying to filter the help topics by department id. So it would only show tickets for department 2 (which could be HR)

I have found the code that is loading the drop down for ticket categories. This is in the file

                if($topics=Topic::getPublicHelpTopics()) {
                    foreach($topics as $id =>$name) {
                        echo sprintf('<option value="%d" %s>%s</option>',
                                $id, ($info['topicId']==$id)?'selected="selected"':'', $name);
                } else { ?>

I could just write some basic SQL to get the records but id like to know where this data is coming from ie the getPublicHelpTopics

If there is any reading I need to do around this please let me know. My coding is abit rusty
Any questions ask away and I will explain as best as I can


  • I presume your running v1.10?

    Off the top of my head:
    help topics are stored in the ost_help_topic table.
    forms associated with the topic are identified in the ost_help_topic_form table.
  • Thank you however what is getPublicHelpTopics and where do I find it
  • I am abit furth in the puzzle. I have found the class.topic.php which defines the getPublicHelpTopics function. So far on the function I have

    the bit I don't understand is how this is filtering the tickets. Below is where my code is so far. I understand I need to pass the argument in, so I have setup 3, 1 for each department. The part of code I am really not understanding the the //resolve parent names part

    static function getHelpTopics($publicOnly=false, $disabled=false, $itonly=false, $hronly=false, $finonly=false) {
            global $cfg;
            static $topics, $names = array();

            if (!$names) {
                $sql = 'SELECT topic_id, topic_pid, ispublic, isactive, topic, dept_id FROM '.TOPIC_TABLE
                    . ' ORDER BY `sort`';
                $res = db_query($sql);

                // Fetch information for all topics, in declared sort order
                $topics = array();
                while (list($id, $pid, $pub, $act, $topic) = db_fetch_row($res))
                    $topics[$id] = array('pid'=>$pid, 'public'=>$pub,
                        'disabled'=>!$act, 'topic'=>$topic, 'dept_idid'=>$depid );

                // Resolve parent names
                foreach ($topics as $id=>$info) {
                    $name = $info['topic'];
                    $loop = array($id=>true);
                    $parent = false;
                    while ($info['pid'] && ($info = $topics[$info['pid']])) {
                        $name = sprintf('%s / %s', $info['topic'], $name);
                        if ($parent && $parent['disabled'])
                            // Cascade disabled flag
                            $topics[$id]['disabled'] = true;
                        if (isset($loop[$info['pid']]))
                        $loop[$info['pid']] = true;
                        $parent = $info;
                    $names[$id] = $name;

            // Apply requested filters
            $requested_names = array();
            foreach ($names as $id=>$n) {
                $info = $topics[$id];
                if ($publicOnly && !$info['public'])
                if (!$disabled && $info['disabled'])
                if ($disabled === self::DISPLAY_DISABLED && $info['disabled'])
                    $n .= " - ".__("(disabled)");
                $requested_names[$id] = $n;

            return $requested_names;

        function getPublicHelpTopics() {
            return self::getHelpTopics(true);

        function getAllHelpTopics() {
            return self::getHelpTopics(false, true);
     function getitHelpTopics() {
            return self::getHelpTopics(true, false, 2);

  • Q: what is getPublicHelpTopics and where do I find it

    A: I would recommend search.  T hats how I find things in the code.
Sign In or Register to comment.