Disabled Category still showing for limited access user

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
kilimats
Posts: 18
Joined: Wed Nov 02, 2011 1:53 am

Disabled Category still showing for limited access user

Post by kilimats »

I've disabled a category for a non admin user, He do not see those category tickets in his profile (which is good) but can select that hidden category when making a new ticket, is this a bug or am i missing something ?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Disabled Category still showing for limited access user

Post by Klemen »

Like Microsoft would say - it's not a bug, it's a feature :lol:

Actually this is normal because usually even if a staff member doesn't have access to a category, he/she should be able to for example enter or move tickets to more appropriate category.

But I see your point, will consider adding a permission to disallow this.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Disabled Category still showing for limited access user

Post by steve »

Does anybody have any idea how to make a quick hack to only show categories the logged in user has permission to view?
-Steve
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Disabled Category still showing for limited access user

Post by Klemen »

Find the SQL code that gets category list in the file you are editing and check each category with the hesk_okCategory() function.

For example in admin_ticket.php this would probably work (didn't test it): change

Code: Select all

$categories_options='';
while ($row=hesk_dbFetchAssoc($result))
to

Code: Select all

$categories_options='';
while ($row=hesk_dbFetchAssoc($result) && hesk_okCategory($row['id'], 0) )
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Disabled Category still showing for limited access user

Post by steve »

That did seam to work, when this code is used the category drop down box does not have any data.


Here was my mod (admin/new_ticket.php)

Code: Select all

<?php
	if (!empty($_GET['catid']))
	{
		$_SESSION['as_category'] = intval($_GET['catid']);
	}

	$sql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'categories` ORDER BY `cat_order` ASC';
	$result = hesk_dbQuery($sql);
	while ($row=hesk_dbFetchAssoc($result) && hesk_okCategory($row['id'], 0) )
	{
	    if (isset($_SESSION['as_category']) && $_SESSION['as_category'] == $row['id']) {$selected = ' selected="selected"';}
	    else {$selected = '';}
	    echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['name'].'</option>';
	}

	?>
-Steve
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Disabled Category still showing for limited access user

Post by Klemen »

No, sorry, after thinking about it it's wrong code, obviously :lol:

Instead of that rather add this to inside the while loop, after {

Code: Select all

if ( ! hesk_okCategory($row['id'], 0) ) {continue;}
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
steve
Posts: 147
Joined: Tue Mar 27, 2012 9:32 pm

Re: Disabled Category still showing for limited access user

Post by steve »

Perfect! Thanks Klemen
-Steve
Goue1
Posts: 9
Joined: Wed May 23, 2012 4:05 pm

Re: Disabled Category still showing for limited access user

Post by Goue1 »

Where do you add your mod in /admin/new_ticket.php ?

I'm noob in php coding..

EDIT: sorry for my mistake I find where put it!

Thanks for your job!
Post Reply