How to Create 3 New Permissions (Can Post Reply, Can Post Internal Notes, and Can Assign Tickets) into osTicket 1.6 ST

Can Post Internal Notes, and Can Assign Tickets) into osTicket 1.6 ST

November 15, 2012 by Masino Sinaga
source: openscriptsolution.com

osTicket does very good job to restrict the certain permissions to the staff by implementing the User Groups feature. There are seven permissions that have been provided in the User Groups. They are: Can Create Tickets, Can Edit Tickets, Can Close Tickets, Can Transfer Tickets, Can Delete Tickets, Can Ban Emails, and Can Manage Premade. Unfortunately, up to osTicket version 1.6 ST, there are no permissions for the following action: Can Post Reply, Can Post Internal Notes, and Can Assign Tickets.

In this article, I will show you how you can add those three new permissions into the User Groups feature. They are very useful whenever you want to create a User Group and then assign it to the certain users which do not have the abilities for that three new permissions. By default, these three new permissions are all set to 1 (Enabled). If you want to change the values or disable those three new permissions, then you have to login as Administrator, and then go to Admin Panel -> Staff -> User Groups, then edit a user group record from the list which you want to disable them.

1. First of all, alter your ost_groups table by adding the three new fields called by using the following script into your osTicket database (please adjust the table prefix if you are using the different one with mine using ost_):

    ALTER TABLE `ost_groups` ADD COLUMN `can_post_reply` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `can_create_tickets`;
    ALTER TABLE `ost_groups` ADD COLUMN `can_post_internal_notes` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `can_post_reply`;
    ALTER TABLE `ost_groups` ADD COLUMN `can_assign_tickets` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `can_post_internal_notes`;

2. Open your /include/staff/group.inc.php file, and find this code:

    <tr><th>Can <b>Create</b> Tickets</th>
        <td>
            <input type="radio" name="can_create_tickets"  value="1"   <?=$info['can_create_tickets']?'checked':''?> />Yes
            <input type="radio" name="can_create_tickets"  value="0"   <?=!$info['can_create_tickets']?'checked':''?> />No
              <i>Ability to open tickets on behalf of users!</i>
        </td>
    </tr>

after the last line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
            <tr><th>Can <b>Post Reply</b></th>
                <td>
                    <input type="radio" name="can_post_reply"  value="1"   <?=$info['can_post_reply']?'checked':''?> />Yes
                    <input type="radio" name="can_post_reply"  value="0"   <?=!$info['can_post_reply']?'checked':''?> />No
                      <i>Ability to post replies!</i>
                </td>
            </tr>
            <tr><th>Can <b>Post Internal Notes</b></th>
                <td>
                    <input type="radio" name="can_post_internal_notes"  value="1"   <?=$info['can_post_internal_notes']?'checked':''?> />Yes
                    <input type="radio" name="can_post_internal_notes"  value="0"   <?=!$info['can_post_internal_notes']?'checked':''?> />No
                      <i>Ability to post Internal Notes!</i>
                </td>
            </tr>
            <tr><th>Can <b>Assign</b> Tickets</th>
                <td>
                    <input type="radio" name="can_assign_tickets"  value="1"   <?=$info['can_assign_tickets']?'checked':''?> />Yes
                    <input type="radio" name="can_assign_tickets"  value="0"   <?=!$info['can_assign_tickets']?'checked':''?> />No
                      <i>Ability to assign tickets!</i>
                </td>
            </tr>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

3. Open your /include/class.group.php file, and find this code:

', can_create_tickets='.db_input($vars['can_create_tickets']).

then replace it with this following code:

                     ', can_create_tickets='.db_input($vars['can_create_tickets']).
    // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012
                     ', can_post_reply='.db_input($vars['can_post_reply']).
                     ', can_post_internal_notes='.db_input($vars['can_post_internal_notes']).               
                     ', can_assign_tickets='.db_input($vars['can_assign_tickets']).
    // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012

4. Open your /include/class.staff.php file, and find this code:

function canCreateTickets(){
        return ($this->isadmin() || $this->udata['can_create_tickets'])?true:false;
    }

after the last line of that code, please insert this following code:

// Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012
        function canPostReply(){
            return ($this->isadmin() || $this->udata['can_post_reply'])?true:false;   
        }
     
        function canPostInternalNotes(){
            return ($this->isadmin() || $this->udata['can_post_internal_notes'])?true:false;   
        }  
         
        function canAssignTickets(){
            return ($this->isadmin() || $this->udata['can_assign_tickets'])?true:false;   
        }
    // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012

5. Open your /include/staff/viewticket.inc.php file, and find this code:

<div id="reply" class="tabbertab" align="left">
        <h2>Post Reply</h2>

before the first line of that code, please insert this following code:

<?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php if ($thisuser->canPostReply()) { ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

6. Still in the /include/staff/viewticket.inc.php file, find this code:

                <p>
                    <div  style="margin-left: 50px; margin-top: 30px; margin-bottom: 10px;border: 0px;">
                        <input class="button" type='submit' value='Post Reply' />
                        <input class="button" type='reset' value='Reset' />
                        <input class="button" type='button' value='Cancel' onClick="history.go(-1)" />
                    </div>
                </p>
            </form>               
        </p>
    </div>

after the last line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php } ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

7. Still in the /include/staff/viewticket.inc.php file, find this code:

    <div id="notes" class="tabbertab"  align="left">
        <h2>Post Internal Note</h2>

before the first line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php if ($thisuser->canPostInternalNotes()) { ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

8. Still in the /include/staff/viewticket.inc.php file, find this code:

                <div style="margin-top: 3px;">
                    <b>Ticket Status:</b>
                    <?
                    $checked=($info && isset($info['ticket_status']))?'checked':''; //not selected by default.
                    if($ticket->isOpen()){?>
                    <label><input type="checkbox" name="ticket_status" id="ticket_status" value="Close" <?=$checked?> > Close Ticket</label>
                    <?}else{ ?>
                    <label><input type="checkbox" name="ticket_status" id="ticket_status" value="Reopen" <?=$checked?> > Reopen Ticket</label>
                    <?}?>
                </div>
                <?}?>
                <p>
                    <div  align="left" style="margin-left: 50px;margin-top: 10px; margin-bottom: 10px;border: 0px;">
                        <input class="button" type='submit' value='Submit' />
                        <input class="button" type='reset' value='Reset' />
                        <input class="button" type='button' value='Cancel' onClick="history.go(-1)" />
                    </div>
                </p>
            </form>
        </p>
    </div>

after the last line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php } ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

9. Still in the /include/staff/viewticket.inc.php file, find this code:

    <?
     //When the ticket is assigned Allow assignee, admin or ANY dept manager to reassign the ticket.
    if(!$ticket->isAssigned() || $thisuser->isadmin()  || $thisuser->isManager() || $thisuser->getId()==$ticket->getStaffId()) {
         ?>
    <div id="assign" class="tabbertab"  align="left">
         
        <h2><?=$staff?'Re Assign Ticket':'Assign to Staff'?></h2>

before the first line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php if ($thisuser->canAssignTickets()) { ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

10. Still in the /include/staff/viewticket.inc.php file, find this code:

                <p>
                    <div  style="margin-left: 50px; margin-top: 5px; margin-bottom: 10px;border: 0px;" align="left">
                        <input class="button" type='submit' value='Assign' />
                        <input class="button" type='reset' value='Reset' />
                        <input class="button" type='button' value='Cancel' onClick="history.go(-1)" />
                    </div>
                </p>
            </form>
        </p>
    </div>
    <?}?>

after the last line of that code, please insert this following code:

    <?php // Begin of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>
             <?php } ?>
    <?php // End of MOD Adding 3 New Permissions, by Masino Sinaga, January 20, 2012 ?>

Hopefully you find it useful. 🙂

OSTicket 1.6: How to add a db populated drop down and admin interface [version 1.0]

OSTicket 1.6 ST – MOD: How to add a db populated drop down and admin interface [version 1.0]

These directions are for adding this feature to OSTicket v1.6ST. While it will be similar for any current version (RC through ST) release it has only been tested on 1.6ST. Directions for modified OSTicket v1.6ST will be similar but the line numbers may be different based on how you have modified your own implementation. These directions require that you already have a working implemtation of OSTickets v1.6ST.

Before you start following the directions on this or any other mod please be aware that you should always back up your site and your database to be safe.

First we are going to create a table to store the information for the extra drop down field that we will be creating. For the purposes of this article we are creating the drop down box will be called “Agencies”. To use another name (such as “Program” or “Company” simply replace every occurance in these directions of the word “agencies” with what you want to call it.

There are several ways to create the table (command line, phpmyadmin, MySQL Administrator, MySQL Workbench, etc.) so please feel free to use the way that you are most comfortable.

CREATE TABLE `ost_agencies` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `agency` varchar(255) NOT NULL,
  `addDate` datetime NOT NULL,
  `isenabled` tinyint(1) unsigned NOT NULL,
  `editor` varchar(25) default NULL,
  `upDate` datetime default NULL,
  PRIMARY KEY  (`id`),
  FULLTEXT KEY `agency` (`agency`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

note1: Please make sure that the ost_ prefix is what you are using for your setup. If you are using a different prefix make sure that you change this everywhere in the instructions.

note2: Please note that if you aren’t using “Agencies” please change all references to “Agencies” or “agency” to what you want it to be. There are 4 referrences in the aboce SQL query that should be changed. This same holds true for every instance in every step and the files distirubuted with this mod.

While we are here lets add one (1) entry into the table that you can change or edit later.

INSERT INTO `ost_agencies` (`id`,`agency`,`addDate`,`isenabled`,`editor`,`upDate`)
VALUES (1,'EMAILED TICKET','2010-09-01 11:23:47',1,'','0000-00-00 00:00:00');

Next we need to add a field to the ost_ticket table that will hold the Agency number.

ALTER TABLE `DATABASENAME`.`ost_ticket` ADD COLUMN `agency` INTEGER 
UNSIGNED NOT NULL DEFAULT 0 AFTER `updated`;

Next we will be performing a number of edits to different files in the OSTicket directory tree.

edit include/client/open.inc.php
circa line 48 add the following:

    <tr>
     <select name=agency>
     <option value=0 selected>--select one--
      
        <option value="" >
      
     </select>
    </tr>

It is good habit to make sure that this section lines up with the sections before and after it (code indentation). Copying and pasting this will probably not make it line up right. If you fix this is ultimately up to you, but it will not impact how it works either way.

Next edit include/class.ticket.php
circa line 74 add the following:

$this->agency     =$row['agency'];

circa line 141 add the following:

function getAgency(){
 return $this->agency;
}

— OPTIONAL —
If you think that you might want to use %agency in your ticket templates do the following

circa line 429 locate the line

$search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/',
'/%topic/','/%phone/','/%status/','/%priority/',

and change it to

$search = array('/%id/','/%ticket/','/%email/','/%name/','/%agency/','/%subject/',
'/%topic/','/%phone/','/%status/','/%priority/',

circa line 435 add the following:

$this->getAgency(),

–END OPTIONAL —

circa line 1085 (optional?) add line

$fields['agency']    = array('type'=>'string',    
'required'=>1, 'error'=>'Agency required');

circa line 1132 add the following:

',agency='.db_input(Format::striptags($var['agency'])).

If you would like agency to be required then on
circa line 1174 add the following:

$fields['agency']    = array('type'=>'string',    
'required'=>1, 'error'=>'Agency required');

circa line 1321 add the following:

',agency='.db_input($var['agency']).

note: make sure that if you add this at the end of the $sql lines that you turn the ; on the line before it into a . or it will cause errors.

Next edit include/class.mailfetch.php
circa line 235 and add the following:

$var['agency']="1";

This means that it will use a default value of 1 for any tickets that are opened via email. This is also the entry that we added to the DB manually earlier in this tutorial.

edit /include/client/viewticket.inc.php
circa line 47 add the following:

<tr>
 <th width="100">Agency:
 <td>
getAgency and convert it into its name from the ost_agencies table
 $agencies= db_query('SELECT agency FROM '.TABLE_PREFIX.'agencies WHERE id='.$ticket->getAgency().'');
 $agency = db_fetch_row($agencies); ?>
 
 </td>
</tr>

edit /include/staff/newticket.inc.php
circa line 36 add the following:

<tr>
 <td align="left">Agency:
 <td>
  <select name=agency>
  <option value=0 selected>--select one--
  
    <option value="" ></option>
  
  </select>
   <font class="error"><b>*</b> </font>
 </td>
</tr>

edit /include/staff/editticket.inc.php
circa line 11 add the following:

'agency'=>$ticket->getAgency(),

circa line 54 add the following:

    
      <tr>
        <td align="left">Agency:
        <td>
            <select name="agency">
              
                    <option value=""  ></option>
              
            </select>
        </td>
       </tr>
    

edit /include/staff/viewticket.inc.php
circa line 58 add the following:

			<tr>
								<th> </th>
								<td> </td>
						</tr>

circa line 89 add the following:

            <tr>
                <th>Agency:</th>
                <td>
                    getAgency and convert it into its name from the ost_agencies table
 	            $agencies= db_query('SELECT agency FROM ost_agencies WHERE id='.$ticket->getAgency().'');
 	            $agency = db_fetch_row($agencies); ?>
 	            
		</td>
            </tr>

Now let’s create the admin interface to allow addition of, disable/enabling of, and deletion of Agencies in the DB. This part requires that you download the agencies_interface_files.zip attached to this post. It should include the following files:

README
/scp/agency.php
/include/staff/agency_name.inc.php
/include/staff/agency.inc.php

Please put those files in the directories where they belong.

Next edit /include/staff/header.inc.php
circa line 56 add the following

						if($thisuser->isAdmin() && defined('ADMINPAGE')) {?>
						    <li><a href="agency.php" title="Agencies">Agencies </a></li> 

It is important to note that this mod is distributed as is. It is not distributed with any warranty of any kind express or implied. If you like this mod please consider donating to my web site.

Here is a link to the additional files mentioned in this article:
MOD-agencies.zip

OSTicket 1.6: Reporting Mod v4.2 has been released

Scottro and I just finished troubleshooting a problem with his Report Mod for OSTicket v1.6ST. And he will be posting a new update to his site shortly. If you need reporting capabilities for your implementation of OSTicket I urge you to check it out.

You can get his reporting mod at:
http://sudobash.net/ostickets-reports/

release notes:
This release fixes a problem with “Replies by Staff”
puts the missing icon back in to the distribution archive

OSTicket 1.6 ST: Add Pending Status, and Autoclose tickets after 5 days.

Based on the Pending and Autoclose mod posted by GooseMoose on the OSTicket forums, here are my re-written directions on how to do it, as well as a bug fix.

What:

This MOD is for OSTicket 1.6 ST and will add in a new ticket status type of “pending”. If any ticket is left pending for 5 days it will close the ticket. It also adds a new section at the top [see image] that displays how many pending tickets there are and lets you click the link to look at them.

UPDATE: Please note that today Sept 14th, 2011 I noticed that I forgot to include part of step 1 in my directions. This step has been updated accordingly, sorry for any confusion it may have caused.

Directions:

Step 1 –

Copy the two files [preLogin.pgp and autoClose.php] in the attached zip to /include/staff

In /scp/login.php at circa line 54 after

require_once('index.php'); //Just incase header is messed up.

add the following code:

define("OMEGAPVTLTD",TRUE); //Make includes happy        
// do tasks prior to redirecting
include_once(INCLUDE_DIR.'staff/preLogin.php');

Step 2 –

update the database [please edit this to fit your installation] with the following MySQL Query

ALTER TABLE ost_ticket CHANGE status status ENUM('open','closed','pending') DEFAULT 'open';

Step 3 –

Make the following code changes

3A: In [document root]/scp/tickets.php

at circa line 56

Change

$statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed');

to

$statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed','Pending'=>'Pending');

at circa line 96 after

}

and before

//Finally upload attachment if any

Add the following

$wasPending=$ticket->isPending();
if(isset($_POST['pending_status']) && $_POST['pending_status']) {
   if($ticket->setStatus($_POST['pending_status']) && $ticket->reload()) {
	   $note=sprintf('%s %s the ticket on reply',$thisuser->getName(),($ticket->isPending()?'Pending': $ticket->isOpen() ? 'Open' : 'Closed'));
	   $ticket->logActivity('Ticket status changed to '.($ticket->isPending()?'Pending': $ticket->isOpen() ? 'Open' : 'Closed'),$note);
   }
}
if($wasPending && !isset($_POST['pending_status']))
{
	$ticket->setStatus('open');
	$note=sprintf('%s %s the ticket on reply',$thisuser->getName(),$ticket->isOpen()?'reopened':'closed');
	$ticket->logActivity('Ticket status changed to '.($ticket->isOpen()?'Open':'Closed'),$note);
}

at circa line 432 change

$sql='SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered '.
     ',count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned '.
     ' FROM '.TICKET_TABLE.' ticket '.
     'LEFT JOIN '.TICKET_TABLE.' open ON open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=0 '.
     'LEFT JOIN '.TICKET_TABLE.' answered ON answered.ticket_id=ticket.ticket_id AND answered.status=\'open\' AND answered.isanswered=1 '.
     'LEFT JOIN '.TICKET_TABLE.' overdue ON overdue.ticket_id=ticket.ticket_id AND overdue.status=\'open\' AND overdue.isoverdue=1 '.
     'LEFT JOIN '.TICKET_TABLE.' assigned ON assigned.ticket_id=ticket.ticket_id AND assigned.staff_id='.db_input($thisuser->getId());

to

$sql='SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered '.
',count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned, count(pending.ticket_id) as pending '.
' FROM '.TICKET_TABLE.' ticket '.
'LEFT JOIN '.TICKET_TABLE.' open ON open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=0 '.
'LEFT JOIN '.TICKET_TABLE.' answered ON answered.ticket_id=ticket.ticket_id AND answered.status=\'open\' AND answered.isanswered=1 '.
'LEFT JOIN '.TICKET_TABLE.' pending ON pending.ticket_id=ticket.ticket_id AND pending.status=\'pending\' '.
'LEFT JOIN '.TICKET_TABLE.' overdue ON overdue.ticket_id=ticket.ticket_id AND overdue.status=\'open\' AND overdue.isoverdue=1 '.
'LEFT JOIN '.TICKET_TABLE.' assigned ON assigned.ticket_id=ticket.ticket_id AND assigned.staff_id='.db_input($thisuser->getId());

at circa line 463 after

if($stats['overdue']) {
    $nav->addSubMenu(array('desc'=>'Overdue ('.$stats['overdue'].')','title'=>'Stale Tickets',
                    'href'=>'tickets.php?status=overdue','iconclass'=>'overdueTickets'));

    if(!$sysnotice && $stats['overdue']>10)
        $sysnotice=$stats['overdue'] .' overdue tickets!';
}

add the following

$nav->addSubMenu(array('desc'=>'Pending Tickets ('.$stats['pending'].')','title'=>'Pending Tickets', 'href'=>'tickets.php?status=pending', 'iconclass'=>'closedTickets'));

3B: In [document root]/include/staff/viewticket.inc.php

circa line 333 change

isOpen()){?>
<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Close"  > Close on Reply

<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Reopen"  > Reopen on Reply

to

isPending())
{
	?>
	
	isOpen()){?>
	<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Close"  > Close on Reply
	
	<label><input type="checkbox" name="ticket_status" id="l_ticket_status" value="Reopen"  > Reopen on Reply
	isClosed())
{
	if($ticket->isPending()){
	?>
	<label><input type="checkbox" name="pending_status" id="l_pending_status" value="Pending" checked="checked" > Ticket is pending (Untick to mark not pending)
	
	<label><input type="checkbox" name="pending_status" id="l_pending_status" value="Pending"  > Mark As Pending
	

3C: In [document root]/include/class.ticket.php

circa line 107 add
note: I added this after the isOpen function and before the isClosed function.

    function isPending(){
        return (strcasecmp($this->getStatus(),'Pending')==0)?true:false;
    }

Locate function setStatus circa line 378 and add:

case 'pending':
            return $this->pending();
            break;

circa line 397 add

function pending(){
        
        $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('pending').',updated=NOW() '.
              ' WHERE ticket_id='.db_input($this->getId());
        return (db_query($sql) && db_affected_rows())?true:false;
    }

3D: In [document root]/include/staff/tickets.inc.php

circa line 32 add

case 'pending':
        $status='pending';
        break;


*** Update 05 Mar 2013 ***
For some reason Drupal hosed some of my file attachments. Here is a link to the pending mod files that you need to complete this modification.

Pending Mod files: pending-mod-files.zip

OSTicket 1.6: Report Page v3.2.1 is out

Scottro’s wonderful Report Page v3.2.1 is now out. I’ve also given him my own modifications to the project. Not sure if he will integrate them into the next release or not. There are a couple new reporting options since I first mentioned this mod here at tmib.net. He also has a Spanish version of 2.1 on his site.

Offical screen shot:

You can get his reporting mod at:
http://sudobash.net/?p=821

The complete change log is located at his page.

OSTicket 1.6: Report Page v2.0 is out

One of the things that has long been lacking in OSTicket (1.6ST) is the ability to do some basic reporting. This was so lacking that it even prompted me to write some of my own custom page and reports. I have to admit though, Scottro over at sudobash.net out did me for an integrated and aesthetically pleasing solution.

You can get his reporting mod at:
http://sudobash.net/?p=821

This is a fantastic mod and I recommend it. First off let me say that the installation of this mod was easy enough that I feel a first day OST newbie that is not familiar with PHP but is minorly familiar with HTML should have no problem installing it. Secondly the charts look fantastic when they work (see browser tests below). While the authors implementation integrates well with the OST architecture, I will be adding it as a tab also. I will also be sending some ideas to the author or modding his code to implement some of my own custom reporting that others may find useful.

I have tested this on the following browsers:
Firefix 4.0.1 works as expected.
Opera 11.11 works as expected.
Internet Explorer does not display graphs.
Chrome 12.0.742.100 works as expected.

I have emailed the author to let him know these results. I suspect that either IE is mishandling the google graph drawing routines, or the google graph drawing routines have a bug. Either way I hope that an IE ‘fix’ will be forth coming because it still has a large market share.

Kudos to Scottro for this wonderful contribution!

OSTicket 1.6: Allow 2 to 5 digit file extensions (or more)

File extensions on OSTicket 1.6 ST are limited to 3 – 4 digits in the stock distribution. But some times you want to change this to allow for slightly longer or slightly smaller file extensions. Such as .gz or .xhtml.

Edit [document root]/include/class.config.php

circa line X locate the following:

$ext = strtolower(preg_replace("/.*\.(.{3,4})$/", "$1", $filename));

and change it to

$ext = strtolower(preg_replace("/.*\.(.{2,5})$/", "$1", $filename));

This will allow file extensions as small as 2 character and as large as 5.

Alternatively if you dont care how many characters are in the extentsion you could do

$ext = strtolower(preg_replace("/.*\.(.+)$/", "$1", $filename));

Which would allow any extension greater than 0 character.

OSTicket v1.6: How to ensure lowercase email addresses

By default OSTicket lets users input their email addresses using upper, lower case, or mixed case. RFC 5322 states that the local part of an email can be either upper or lowercase (i.e. local-part@domain). In my experience most companies do not utilize this, or they generally accept iAMTMiB@ as iamtmib@ as iamTMiB@, etc. OSTicket by default lets the user type in iamTMiB@tmib.net when opening a ticket, and inserts it into the database as “iamTMiB@tmib.net”. This is fine behavior, but not the behavior that we want where I work.

Why not? Simply put, because when OST pulls up tickets if the user didn’t use the same capitalization every time they opened a ticket, they will not see tickets that have different mismatched case. For example, if I opened three (3) tickets as iamtmib@tmib.net and one (1) as iamTMiB@tmib.net and later went back to check on the status of my ticket and I enter iamtmib@tmib.net and the ticket number I would not see the iamTMiB@tmib.net ticket and vice versa. Presuming that we just want to change this for clients (non-staff) we would have to make changes to authentication (we don’t want login to fail because they use UseRNamE@), the input form (in case of errors), make sure the data is lowercase before inserting it into the database, and lastly update the information already in the database to be all lower case.

[document root] is the location of your installation.
so [document root]/includes would be the includes folder.

Authentication changes

Edit [document root]/login.php

circa line 28 locate the following:

$email=trim($_POST['lemail']);

and change it to

$email=strtolower(trim($_POST['lemail']));

Form changes

Edit [document root]/include/client/open.inc.php

circa line 36 through line 38 change

<input type="hidden" name="email" size="25" value="">
<?}else {?>             
<input type="text" name="email" size="25" value="">

to

<input type="hidden" name="email" size="25" value=""><?=strtolower($email)?>
<?}else {?>             
<input type="text" name="email" size="25" value="">

This makes sure that if they fill out the form wrong, that it echos back the lowercase email address.

Database insertion changes

Edit [document root]/include/class.ticket.php

circa line 1131 and 1320 change

',email='.db_input($var['email']).

to

',email='.db_input(strtolower($var['email'])).

This ensures that the email address is lower case when it is injected into the database.

Sorry for the delay.

Database Changes

Lastly we want to make sure that the data already in the database is all lower case (so it all matches). Using MySQL Work Bench or a mysql cli run the following:

connect <databasename>;

Make sure that you use the name of your database.

UPDATE ost_ticket SET email = LOWER(email);

This MySQL query literally take the value in email, converts it to lowercase and saves it where it was.

That’s it for now. Enjoy.

OSTicket v1.6RC5: How to add ticket subject to autogenerated email

At work we have been using OSTicket as our support ticketing software for a while now. And one of the things that has always really annoyed me about the software is when someone opens a ticket and I get the autogenerated email, the email is missing the ticket subject. Normally this wouldn’t be a big deal, but for some unfathomable reason a goodly portion of my coworkers seem to think that the subject line is where you should put important details. As you can imagine this can be troublesome if I am working from home or otherwise cannot get to the support site.

Take the following example:

    subject: Jon Doh
    body: Please add to security group alpha.
    

That example with out the subject is completely un-processable. So since I like to think that I am handy with PHP and MySQL I started digging. The email is generated using entries in the email_template table. [note: This may be ost_email_template]
So since this table doesn’t have a way to edit it in the admin interface how do I change it? Great question! First get to a command prompt. [note: windows users can use the MySQL Administrator GUI]

    > mysqldump -u username -p osticketDatabaseName --tables ost_email_template > ost_email_template.sql
    

Make sure that you replace username with your usernamme, and osticketDatabaseName with your database name. This will dump just the contents of your ost_email_template to the file ost_email_template.sql. Feel free to rename the file to something else. Please at this point make a copy of your back up. We’re going to be editting it, and if something bad happens you want to have a back up original copy. Open the copy of the file in your choice of text editor. [Windows Trick: opening it in word pad will put it in a more readable format.]

Locate the following text string: “Name: %name\r\nEmail: %email\r\n”

After that carefully insert “Subject: %subject”.

Save the file. Import the the table back into your database.

It import the data back into your database do the following:

    > mysql -u username -p osticketDatabaseName < ost_email_template.sql
    

Once you have imported the template back into the database your emails will now include the ticket Subject. Honestly it was so easy I think that the devs just forgot to do it.

On the off chance that you hose your ost_email_template I have attached the default one to this article.

default_email_template.sql