Menu Close

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. 🙂