Kayako logo
Modifications & Addon Releases Modification guides and addons are posted here to share with the community. Do not post requests in here!

Notices

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  (#1) Old
phpimpact Offline
New Member
 
Posts: 10
Join Date: Jul 2007
View Ticket: Hide tabs - 12-07-2007, 05:10 PM

If you want to prevent users replying or releasing other users tickets, you can hide the "Post reply" and "Release" tabs (or any other tab).

1. Open this file /modules/tickets/staff_viewticket.php with notepad.

2. Add this somewhere on the top of the document (line 99 will do, after the $navtitled variable):

PHP Code:
    $userIsAdmin = (bool) $_SWIFT["staff"]['is_admin'];
    
$userTicketOwnerId = (int) $_ticket["ownerstaffid"]; 
    
$userOwnsTicket = ($_SWIFT["staff"]['staffid'] === $_ticket["ownerstaffid"]) ? true false
3. Almost there. After line 150, the script prints the list tags <li>, that are part of the tabs.

4. Wrap the echo between an if statement:

PHP Code:
    if ($userIsAdmin === true 
        
|| $userOwnsTicket === true
        
|| $userTicketOwnerId === 0)
    {
        echo ...
    } 
If the user is not an administrator ($userIsAdmin), or if he doesn't own the ticket ($userOwnsTicket), he'll not see the tabs. If the ticket is --unassigned-- ($userTicketOwnerId), all the users will see the tabs.

That's it!

Last edited by phpimpact; 13-07-2007 at 11:04 AM.
   
Reply With Quote
  (#2) Old
Siora Offline
Member
 
Siora's Avatar
 
Posts: 1,300
Join Date: Apr 2007
Location: Toronto Canada
09-08-2007, 12:08 PM

This is a great mod but how would this effect managers who are not admins. Managers are those that oversee their team and assign tickets accordingly but do not have access to the admin side of things. Can this be added to the mod?


Siora Solutions Inc.
www.sioraIT.com
   
Reply With Quote
  (#3) Old
craigbrass Offline
Senior Member
 
Posts: 5,394
Join Date: Jun 2005
Location: Cumbria, UK
09-08-2007, 12:15 PM

Ooo, this is good. Thanks for sharing!


Craig Brass - Kayako Forum Squatter (Note: I am NOT a staff member)

Icon Headquarters - Its Elixir - Web2Messenger
   
Reply With Quote
  (#4) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 134
Join Date: May 2007
Location: Denmark
09-08-2007, 12:43 PM

can this maybe be altered so it hides these tabs for a specific staff group instead?


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#5) Old
craigbrass Offline
Senior Member
 
Posts: 5,394
Join Date: Jun 2005
Location: Cumbria, UK
09-08-2007, 01:01 PM

Quote:
Originally Posted by mopa View Post
can this maybe be altered so it hides these tabs for a specific staff group instead?
I would like to see the ability to do this too.


Craig Brass - Kayako Forum Squatter (Note: I am NOT a staff member)

Icon Headquarters - Its Elixir - Web2Messenger
   
Reply With Quote
  (#6) Old
Siora Offline
Member
 
Siora's Avatar
 
Posts: 1,300
Join Date: Apr 2007
Location: Toronto Canada
09-08-2007, 01:02 PM

Yes that would make sense as this would also solve my question.


Siora Solutions Inc.
www.sioraIT.com
   
Reply With Quote
  (#7) Old
phpimpact Offline
New Member
 
Posts: 10
Join Date: Jul 2007
20-08-2007, 11:23 AM

Yeah sure, you have to add the following line bellow $userOwnsTicket...

PHP Code:
// add the id's of the groups that can view the tabs
$allowedGroupIds = array(357);
$userGroupId = (int) $_SWIFT["staff"]["staffgroupid"]; 
And then wrap the echo between an if statement:

PHP Code:
if (in_array($userGroupId$allowedGroupIds))
{
    echo ...

That's all
   
Reply With Quote
  (#8) Old
phpimpact Offline
New Member
 
Posts: 10
Join Date: Jul 2007
20-08-2007, 11:28 AM

The quickest way to find out the ID number of a group is logging in as admin and going to: Staff > Manage Team.

Click on a team and check the URL, it should end with something like this: index.php?_m=core&_a=editstaffgroup&staffgroupid=4

So there you have it, "staffgroupid" 4

Code:
$allowedGroupIds = array(4); 
   
Reply With Quote
  (#9) Old
Siora Offline
Member
 
Siora's Avatar
 
Posts: 1,300
Join Date: Apr 2007
Location: Toronto Canada
20-08-2007, 11:47 AM

Quote:
Originally Posted by phpimpact View Post
Yeah sure, you have to add the following line bellow $userOwnsTicket...

PHP Code:
// add the id's of the groups that can view the tabs
$allowedGroupIds = array(357);
$userGroupId = (int) $_SWIFT["staff"]["staffgroupid"]; 
And then wrap the echo between an if statement:

PHP Code:
if (in_array($userGroupId$allowedGroupIds))
{
    echo ...

That's all
Is this the full code or do we still have to add statements/code? Besides changing the groupID's is there anything else we need to add ourselves? Sorry I'm not a coder so I wouldn't know what to add if we did.


Siora Solutions Inc.
www.sioraIT.com
   
Reply With Quote
  (#10) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 134
Join Date: May 2007
Location: Denmark
20-08-2007, 12:04 PM

Quote:
And then wrap the echo between an if statement:

PHP Code:
if (in_array($userGroupId$allowedGroupIds))
{
    echo ...

That's all
Sorry I don't quite get what that means?
Where should this be copied to? Can you please specify?
(because when I put it in somewhere - I end up with a blank page when clicking on a ticket with that usergroup)


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#11) Old
phpimpact Offline
New Member
 
Posts: 10
Join Date: Jul 2007
20-08-2007, 01:51 PM

Hi guys, sorry if I wasn't clear enough.

It's similar to the first post, but we are going to add a couple of extra lines:

1. Open this file /modules/tickets/staff_viewticket.php with notepad.

2. Add this somewhere on the top of the document (line 99 will do, after the $navtitled variable):

PHP Code:
$userIsAdmin = (bool) $_SWIFT["staff"]['is_admin'];
$userTicketOwnerId = (int) $_ticket["ownerstaffid"]; 
$userOwnsTicket = ($_SWIFT["staff"]['staffid'] === $_ticket["ownerstaffid"]) ? true false

$allowedGroupIds = array(357);
$userGroupId = (int) $_SWIFT["staff"]["staffgroupid"]; 


Note
that now we have added 2 new lines, $allowedGroupIds and $userGroupId.

3. Almost there. After line 150, the script prints the list tags <li>, that are part of the tabs.

4. Wrap the echo between an if statement:

You have different options:

4.1. Option 1

PHP Code:
if ($userIsAdmin === true
    
|| $userOwnsTicket === true
    
|| $userTicketOwnerId === 0)
{
    echo <
li>...

If the user is not an administrator ($userIsAdmin), or if he doesn't own the ticket ($userOwnsTicket), he'll not see the tabs. If the ticket is --unassigned-- ($userTicketOwnerId), all the users will see the tabs.

4.2. Option 2

PHP Code:
if (in_array($userGroupId$allowedGroupIds))
{
    echo <
li>...

This will show the tab only to groups with the ID 3, 4 and 5. You can change the ID of the allowed groups by editing the line: $allowedGroupIds = array(3, 5, 7);

4.3. Option 3

PHP Code:
if ($userIsAdmin === true 
    
|| $userOwnsTicket === true 
    
|| $userTicketOwnerId === 
    
|| in_array($userGroupId$allowedGroupIds))
{
    echo <
li>...

This combines options 1 and 2.

Hope this helps
   
Reply With Quote
  (#12) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 134
Join Date: May 2007
Location: Denmark
20-08-2007, 01:55 PM

Thanks alot

I really love this mod now that I can exclude specific groups.


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#13) Old
phpimpact Offline
New Member
 
Posts: 10
Join Date: Jul 2007
20-08-2007, 02:05 PM

Pay attention to this line: array(group_id, group_id, etc), it holds the group id's, example:

PHP Code:
$allowedGroupIds = array(457); 
The quickest way to find out the ID number of a group is logging in as admin and going to: Staff > Manage Team.

Click on a team and check the URL, it should end with something like this: index.php?_m=core&_a=editstaffgroup&staffgroupid=4

So there you have it, "staffgroupid" 4

PHP Code:
  $allowedGroupIds = array(4); 
You can add as many id's as you want:

PHP Code:
  $allowedGroupIds = array(4579); 
   
Reply With Quote
  (#14) Old
Siora Offline
Member
 
Siora's Avatar
 
Posts: 1,300
Join Date: Apr 2007
Location: Toronto Canada
22-08-2007, 11:34 PM

Okay I'm confused. There are a few echo <li> statements around line 150. Some are already wrapped around if statements and one of them isn't. Here is a section of code:

Code:
<li><a class="currenttab" href="#" onClick="this.blur(); return switchGridTab(\'ttgeneral\', \'tickets\');" id="ttgeneral" title="'. $_SWIFT["language"]["tabgeneral"] .'">'. $_SWIFT["language"]["tabgeneral"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttpostreply\', \'tickets\'); document.replyform.replycontents.focus(); EDITORON(); startTicketLock(\''. intval($_ticket["ticketid"]) .'\');" id="ttpostreply" title="'. $_SWIFT["language"]["tabpostreply"] .'">'. $_SWIFT["language"]["tabpostreply"] .'</a></li>';
 if ($_SWIFT["staff"]["tforward"] != "0")
 {
  echo '<li><a href="#" onClick="this.blur();switchGridTab(\'ttforward\', \'tickets\');if (!loadedStates[\'forward\']) {fetchData(\'forward\', \''. $_ticket["ticketid"] .'\', \''. intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttforward" title="'. $_SWIFT["language"]["tabforward"] .'">'. $_SWIFT["language"]["tabforward"] .'</a></li>';
 }
 echo '<li><a href="#" onClick="this.blur();switchGridTab(\'ttfollowup\', \'tickets\');if (!loadedStates[\'followup\']) {fetchData(\'followup\', \''. $_ticket["ticketid"] .'\', \''. intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttfollowup" title="'. $_SWIFT["language"]["tabfollowup"] .'">'. $_SWIFT["language"]["tabfollowup"] .'</a></li>';
 if ($_SWIFT["staff"]["tbilling"] != "0")
 {
  echo '<li><a href="#" onClick="this.blur(); switchGridTab(\'ttbilling\', \'tickets\');if (!loadedStates[\'billing\']) {fetchData(\'billing\', \''. $_ticket["ticketid"] .'\');}" id="ttbilling" title="'. $_SWIFT["language"]["billing"] .'">'. $_SWIFT["language"]["billing"] .'</a></li>';
 }
 $_total = $dbCore->queryFetch("SELECT COUNT(*) AS totalitems FROM `". TABLE_PREFIX ."tickets` WHERE `email` = '". $dbCore->escape($_ticket["email"]) ."';");
 $_tickethistorycount = intval($_total["totalitems"]);
 if ($_tickethistorycount > 0)
 {
  $_strhistorycount = ' <font color="#CF5D60">('. $_tickethistorycount .')';
 } else {
  $_strhistorycount = ' (0)';
 }
 echo '<li><a href="#" onClick="this.blur(); switchGridTab(\'ttaddnotes\', \'tickets\');if (!loadedStates[\'addnotes\']) {fetchData(\'addnotes\', \''. $_ticket["ticketid"] .'\', \''. intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttaddnotes" title="'. $_SWIFT["language"]["tabaddnotes"] .'">'. $_SWIFT["language"]["tabaddnotes"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttrelease\', \'tickets\');if (!loadedStates[\'release\']) {fetchData(\'release\', \''. $_ticket["ticketid"] .'\', \''. intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttrelease" title="'. $_SWIFT["language"]["tabrelease"] .'">'. $_SWIFT["language"]["tabrelease"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'tthistory\', \'tickets\');if (!loadedStates[\'history\']) {fetchData(\'history\', \''. $_ticket["email"] .'\');}" id="tthistory" title="'. $_SWIFT["language"]["tabhistory"] .'">'. sprintf($_SWIFT["language"]["tabhistorycnt"], $_strhistorycount) .'</a></li>';
 
 if ($module->isRegistered(MODULE_LIVESUPPORT) && !empty($_ticket["email"]))
 {
  $_total = $dbCore->queryFetch("SELECT COUNT(*) AS totalitems FROM `". TABLE_PREFIX ."chatobjects` WHERE `useremail` = '". $dbCore->escape($_ticket["email"]) ."';");
  $_chatcount = intval($_total["totalitems"]);
  if ($_chatcount > 0)
  {
   $_strchatcount = ' <font color="#CF5D60">('. $_chatcount.')';
  } else {
   $_strchatcount = ' <font color="gray">(0)</font>';
  }
  echo '<li><a href="#" onClick="this.blur(); switchGridTab(\'ttlschats\', \'tickets\');if (!loadedStates[\'lschats\']) {fetchData(\'lschats\', \''. "&email[]=".urlencode($_ticket["email"]) .'\');}" id="ttlschats" title="'. $_SWIFT["language"]["strchats"] .'">'. sprintf($_SWIFT["language"]["tabchats"], $_strchatcount) .'</a></li>';
 }
 echo '<li><a href="#" onClick="this.blur(); switchGridTab(\'ttlog\', \'tickets\');if (!loadedStates[\'auditlog\']) {fetchData(\'auditlog\', \''. $_ticket["ticketid"] .'\');}" id="ttlog" title="'. $_SWIFT["language"]["tablog"] .'">'. $_SWIFT["language"]["tablog"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttedit\', \'tickets\');if (!loadedStates[\'edit\']) {fetchData(\'edit\', \''. $_ticket["ticketid"] .'\');}" id="ttedit" title="'. $_SWIFT["language"]["tabedit"] .'">'. $_SWIFT["language"]["tabedit"] .'</a></li>
 </ul></div></td></tr>'.SWIFT_CRLF;
Where do I wrap the if?


Siora Solutions Inc.
www.sioraIT.com
   
Reply With Quote
  (#15) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 134
Join Date: May 2007
Location: Denmark
23-08-2007, 07:40 AM

I didn't do it my self, but here is some code from mine that works.
I removed ALL the tabs from the usergroup 3.

My code is taken from line 140 - 214

I can't really help you more, but maybe you can see something you can use from it.

PHP Code:
    $userIsAdmin = (bool) $_SWIFT["staff"]['is_admin'];
    
$userTicketOwnerId = (int) $_ticket["ownerstaffid"];
    
$userOwnsTicket = ($_SWIFT["staff"]['staffid'] === $_ticket["ownerstaffid"]) ? true false;
    
// add the id's of the groups that can view the tabs
    
$allowedGroupIds = array(12);
    
$userGroupId = (int) $_SWIFT["staff"]["staffgroupid"];
 
 
$interface->staffNavBar($nav""2);
 
printInfoBox($_SWIFT["infomessage"]);
 
printErrorBox($_SWIFT["errormessage"]);
    if (
in_array($userGroupId$allowedGroupIds))
    {
    echo 
'<table cellspacing="0" cellpadding="0" border="0" width="100%" id="tickettableopt'$_ticket["ticketid"] .'"><tr style="height: 1em"><td align="left"><div id="ticketopt'$_ticket["ticketid"] .'"><ul id="tab">
 <li><a class="currenttab" href="#" onClick="this.blur(); return switchGridTab(\'ttgeneral\', \'tickets\');" id="ttgeneral" title="'
$_SWIFT["language"]["tabgeneral"] .'">'$_SWIFT["language"]["tabgeneral"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttpostreply\', \'tickets\'); document.replyform.replycontents.focus(); startTicketLock(\''
intval($_ticket["ticketid"]) .'\');" id="ttpostreply" title="'$_SWIFT["language"]["tabpostreply"] .'">'$_SWIFT["language"]["tabpostreply"] .'</a></li>';
 if (
$_SWIFT["staff"]["tforward"] != "0")
 {
  echo 
'<li><a href="#" onClick="this.blur();switchGridTab(\'ttforward\', \'tickets\');if (!loadedStates[\'forward\']) {fetchData(\'forward\', \''$_ticket["ticketid"] .'\', \''intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttforward" title="'$_SWIFT["language"]["tabforward"] .'">'$_SWIFT["language"]["tabforward"] .'</a></li>';
 }
 echo 
'<li><a href="#" onClick="this.blur();switchGridTab(\'ttfollowup\', \'tickets\');if (!loadedStates[\'followup\']) {fetchData(\'followup\', \''$_ticket["ticketid"] .'\', \''intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttfollowup" title="'$_SWIFT["language"]["tabfollowup"] .'">'$_SWIFT["language"]["tabfollowup"] .'</a></li>';
 if (
$_SWIFT["staff"]["tbilling"] != "0")
 {
  echo 
'<li><a href="#" onClick="this.blur(); switchGridTab(\'ttbilling\', \'tickets\');if (!loadedStates[\'billing\']) {fetchData(\'billing\', \''$_ticket["ticketid"] .'\');}" id="ttbilling" title="'$_SWIFT["language"]["billing"] .'">'$_SWIFT["language"]["billing"] .'</a></li>';
 }
 
$_total $dbCore->queryFetch("SELECT COUNT(*) AS totalitems FROM `"TABLE_PREFIX ."tickets` WHERE `email` = '"$dbCore->escape($_ticket["email"]) ."';");
 
$_tickethistorycount intval($_total["totalitems"]);
 if (
$_tickethistorycount 0)
 {
  
$_strhistorycount ' <font color="#CF5D60">('$_tickethistorycount .')';
 } else {
  
$_strhistorycount ' (0)';
 }
 echo 
'<li><a href="#" onClick="this.blur(); switchGridTab(\'ttaddnotes\', \'tickets\');if (!loadedStates[\'addnotes\']) {fetchData(\'addnotes\', \''$_ticket["ticketid"] .'\', \''intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttaddnotes" title="'$_SWIFT["language"]["tabaddnotes"] .'">'$_SWIFT["language"]["tabaddnotes"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttrelease\', \'tickets\');if (!loadedStates[\'release\']) {fetchData(\'release\', \''
$_ticket["ticketid"] .'\', \''intval($_REQUEST["ticketlabelid"]) .'\');}" id="ttrelease" title="'$_SWIFT["language"]["tabrelease"] .'">'$_SWIFT["language"]["tabrelease"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'tthistory\', \'tickets\');if (!loadedStates[\'history\']) {fetchData(\'history\', \''
$_ticket["email"] .'\');}" id="tthistory" title="'$_SWIFT["language"]["tabhistory"] .'">'sprintf($_SWIFT["language"]["tabhistorycnt"], $_strhistorycount) .'</a></li>';
 if (
$module->isRegistered(MODULE_LIVESUPPORT) && !empty($_ticket["email"]))
 {
  
$_total $dbCore->queryFetch("SELECT COUNT(*) AS totalitems FROM `"TABLE_PREFIX ."chatobjects` WHERE `useremail` = '"$dbCore->escape($_ticket["email"]) ."';");
  
$_chatcount intval($_total["totalitems"]);
  if (
$_chatcount 0)
  {
   
$_strchatcount ' <font color="#CF5D60">('$_chatcount.')';
  } else {
   
$_strchatcount ' <font color="gray">(0)</font>';
  }
  echo 
'<li><a href="#" onClick="this.blur(); switchGridTab(\'ttlschats\', \'tickets\');if (!loadedStates[\'lschats\']) {fetchData(\'lschats\', \''"&email[]=".urlencode($_ticket["email"]) .'\');}" id="ttlschats" title="'$_SWIFT["language"]["strchats"] .'">'sprintf($_SWIFT["language"]["tabchats"], $_strchatcount) .'</a></li>';
 }
 echo 
'<li><a href="#" onClick="this.blur(); switchGridTab(\'ttlog\', \'tickets\');if (!loadedStates[\'auditlog\']) {fetchData(\'auditlog\', \''$_ticket["ticketid"] .'\');}" id="ttlog" title="'$_SWIFT["language"]["tablog"] .'">'$_SWIFT["language"]["tablog"] .'</a></li>
 <li><a href="#" onClick="this.blur(); switchGridTab(\'ttedit\', \'tickets\');if (!loadedStates[\'edit\']) {fetchData(\'edit\', \''
$_ticket["ticketid"] .'\');}" id="ttedit" title="'$_SWIFT["language"]["tabedit"] .'">'$_SWIFT["language"]["tabedit"] .'</a></li>
 </ul></div></td></tr>'
.SWIFT_CRLF;
 echo 
'<tr style="height: 1em"><td align="left">'.SWIFT_CRLF;
    } else
    {
     echo 
'<table cellspacing="0" cellpadding="0" border="0" width="100%" id="tickettableopt'$_ticket["ticketid"] .'"><tr style="height: 1em">
     <td align="left">
     <div id="ticketopt'
$_ticket["ticketid"] .'">
     </div></td></tr>'
.SWIFT_CRLF;
    }
 
 echo 
'<tr style="height: 1em"><td align="left">'.SWIFT_CRLF


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
Reply

Tags
hide, tabs, ticket

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ticket View -> Quick Search: Is there a way to set the default criteria? richm How do I? 0 30-04-2007 02:22 PM
New Build: 3.10.02 STABLE Ryan Lederman News and Announcements 0 05-03-2007 09:53 PM
Admin missing ticket view and other tabs duplex Presales Questions 8 21-02-2007 08:24 PM



Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16