Page 1 of 1

Admin New Ticket

Posted: Wed Apr 18, 2012 11:18 pm
by steve
I want to gray out the name and email field on the admin new_ticket.php page. I want the session variables to continue to populate the name and email field with the logged in use information, but i dont want the user to be able to change it, unless they are an admin.

Any ideas?

-Steve

Re: Admin New Ticket

Posted: Thu Apr 19, 2012 11:58 am
by Klemen
You can check if the user is an admin with $_SESSION['isadmin']

Code: Select all

if ($_SESSION['isadmin']) 
{
// Do admin stuff
}
else
{
// Do regular user stuff
}

However, note that staff should enter the name of the customer there, not their own name...

Re: Admin New Ticket

Posted: Thu Apr 19, 2012 8:43 pm
by steve
Thank you for your reply,

For this argument, what could i use in the else section so the name and email fields still appear and populate with the current user info, but make in so the user cannot edit the fields?

-Steve

Re: Admin New Ticket

Posted: Mon Apr 23, 2012 6:41 pm
by steve
Figured it out, here is the doe I used.

admin/newticket.php (around line 93)

Code: Select all

	<!-- Contact info -->
	<table border="0" width="100%">
	<tr>
<?php
if ($_SESSION['isadmin'])
{
?>
	<td style="text-align:right" width="150"><?php echo $hesklang['name']; ?>:</td>
	<td width="80%"><input type="text" name="name" size="40" maxlength="30" value="<?php if (isset($_SESSION['as_name'])) {echo stripslashes(hesk_input($_SESSION['as_name']));} ?>" <?php if (in_array('name',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> /></td>
<?php
}
else
{
?>
	<td style="text-align:right" width="150"><?php echo $hesklang['name']; ?>:</td>
	<td width="80%"><input type="text" name="name" size="40" maxlength="30" value="<?php if (isset($_SESSION['as_name'])) {echo stripslashes(hesk_input($_SESSION['as_name']));} ?>" <?php if (in_array('name',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> readonly/></td>
<?PHP
}
?>	


	</tr>
	<tr>
<?php
	if ($_SESSION['isadmin'])
	{
	?>
	<td style="text-align:right" width="150"><?php echo $hesklang['email']; ?>:</td>
	<td width="80%"><input type="text" name="email" size="40" maxlength="50" value="<?php if (isset($_SESSION['as_email'])) {echo stripslashes(hesk_input($_SESSION['as_email']));} ?>" <?php if (in_array('email',$_SESSION['iserror'])) {echo ' class="isError" ';} elseif (in_array('email',$_SESSION['isnotice'])) {echo ' class="isNotice" ';} ?> /></td>
<?php
}
else
{
?>
	<td style="text-align:right" width="150"><?php echo $hesklang['email']; ?>:</td>
	<td width="80%"><input type="text" name="email" size="40" maxlength="50" value="<?php if (isset($_SESSION['as_email'])) {echo stripslashes(hesk_input($_SESSION['as_email']));} ?>" <?php if (in_array('email',$_SESSION['iserror'])) {echo ' class="isError" ';} elseif (in_array('email',$_SESSION['isnotice'])) {echo ' class="isNotice" ';} ?> readonly/></td>
<?php
}
?>
	</tr>
	</table>

	<hr />