phpScheduleIt
May 26, 2013, 04:47:16 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1] 2
  Print  
Author Topic: Code to show specific HTML output only IF admin  (Read 7223 times)
italianstalian
Newbie
*

Karma: 0
Posts: 31


« on: April 12, 2009, 08:45:17 AM »

Good morning,

Please keep in mind that I am very new to phpScheduleIt.

I know that there's a simple method I can use to show specific output in HTML only to administrator, but I don't know PHP well enough to implement it.

Example:

<b>Show this to anyone</b>
<b>Show this to anyone</b>
PHP code
<b>Show this to only to admin</b>
end of PHP code
<b>Show this to anyone</b>
<b>Show this to anyone</b>
<b>Show this to anyone</b>

Please help. Thank you.

-ItalianStalian Huh
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #1 on: April 12, 2009, 09:07:05 AM »

I'm wondering if the code should look something like this:


$admin = new Admin(trim($_GET['tool']));
$admin->user = new User(Auth::getCurrentID());
if (!$admin->user->get_isadmin()) { $admin->user->is_admin = Auth::isAdmin(); }

if (!$admin->isUserAllowed()) {
('
<b>Show this to only to admin</b>
');
}

Like I said I know very little about PHP. I tried this code specifically and it printed the PHP on the page with the HTML. Huh I know I'm missing something. Any help would be appreciated.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #2 on: April 13, 2009, 02:05:02 PM »

Very close.  Try:

Code:
$admin = new Admin(trim($_GET['tool']));
$admin->user = new User(Auth::getCurrentID());
if (!$admin->user->get_isadmin()) { $admin->user->is_admin = Auth::isAdmin(); }

if (!$admin->isUserAllowed()) {
echo '<b>Show this to only to admin</b>';
}
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #3 on: April 14, 2009, 03:02:08 AM »

Thanks for the code.

I'm actually in template.class.php and I'm trying to only show a portion of my template HTML to admin.

Specifically I'm inside the class Template { function.

I inserted the code you provided but it's actually displaying in on the page with the HTML. I know the code is right but my usage is wrong. Do I need to add the little ?> to the front and end?

Thanks.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #4 on: April 14, 2009, 01:10:59 PM »

Can you post what you have?
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #5 on: April 15, 2009, 11:37:55 AM »

Thanks for taking a look. Like I said I'm PHP ignorant. Smiley

<html>
<body>
<span class="drop_pos">
      <div id="nav">
      <ul class="main">   
      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_1');" onmouseout="closeSubMenu(event,1);" href="mydomain.com/fsms/ctrlpnl.php">Home</a></div>
      <div class="dropdown" id="submenu_1" onmouseover=setActiveSubMenu(1) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,1);"></div></li>

?>      
$admin = new Admin(trim($_GET['tool']));
$admin->user = new User(Auth::getCurrentID());
if (!$admin->user->get_isadmin()) { $admin->user->is_admin = Auth::isAdmin(); }

if (!$admin->isUserAllowed()) {
echo '

      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_2');" onmouseout="closeSubMenu(event,2);" href="">Administrative</a></div>
      <div class="dropdown" id="submenu_2" onmouseover=setActiveSubMenu(2) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,2);">
      <ul class="sub">
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/schedule.php">Schedule a Service Call</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=users">Add/Remove Users</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=resources">Manage Technicians</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=additional_resources">Manage Services</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=announcements">Announcements</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=schedules">Manage Schedules Types</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/blackouts.php">Manage Blackouts Times</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=groups">Manage Groups</a></li>      
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=reservations">Manage Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=approval">Approve Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/usage.php">Search Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=email">Send Messages</a></li>   
      </ul></div></li>';
}
?>

      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_3');" onmouseout="closeSubMenu(event,3);" href="mydomain.com/fsms/schedule.php">Schedule</a></div>
      <div class="dropdown" id="submenu_3" onmouseover=setActiveSubMenu(3) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,3);">
      <ul class="sub">
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/mycalendar.php?view=3">My Calendar</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/rescalendar.php?view=3">Schedule Calendar</a></li>
      </ul></div></li>
</body>
</html>

I know my syntax is wrong.
« Last Edit: April 15, 2009, 11:45:07 AM by italianstalian » Logged
dunnts2
Jr. Member
**

Karma: 1
Posts: 82


« Reply #6 on: April 15, 2009, 04:08:31 PM »

Hello,

Perhaps this is what you want, just copy and paste it!

<html>
<body>
<span class="drop_pos">
      <div id="nav">
      <ul class="main">   
      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_1');" onmouseout="closeSubMenu(event,1);" href="mydomain.com/fsms/ctrlpnl.php">Home</a></div>
      <div class="dropdown" id="submenu_1" onmouseover=setActiveSubMenu(1) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,1);"></div></li>

<?php     
$admin = new Admin(trim($_GET['tool']));
$admin->user = new User(Auth::getCurrentID());
if (!$admin->user->get_isadmin()) { $admin->user->is_admin = Auth::isAdmin(); }

if (!$admin->isUserAllowed()) {
?>
      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_2');" onmouseout="closeSubMenu(event,2);" href="">Administrative</a></div>
      <div class="dropdown" id="submenu_2" onmouseover=setActiveSubMenu(2) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,2);">
      <ul class="sub">
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/schedule.php">Schedule a Service Call</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=users">Add/Remove Users</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=resources">Manage Technicians</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=additional_resources">Manage Services</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=announcements">Announcements</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=schedules">Manage Schedules Types</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/blackouts.php">Manage Blackouts Times</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=groups">Manage Groups</a></li>     
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=reservations">Manage Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=approval">Approve Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/usage.php">Search Reservations</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/admin.php?tool=email">Send Messages</a></li>   
      </ul></div></li>';
<?php
}
?>
      <li><div class="divide">
      <a class="nav" onmouseover="topnav_toggleDiv('submenu_3');" onmouseout="closeSubMenu(event,3);" href="mydomain.com/fsms/schedule.php">Schedule</a></div>
      <div class="dropdown" id="submenu_3" onmouseover=setActiveSubMenu(3) style="DISPLAY: block; VISIBILITY: hidden" onmouseout="closeSubMenu(event,3);">
      <ul class="sub">
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/mycalendar.php?view=3">My Calendar</a></li>
      <li class="droptitle"><a class="subtitle" href="mydomain.com/fsms/rescalendar.php?view=3">Schedule Calendar</a></li>
      </ul></div></li>
</body>
</html>


Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #7 on: April 17, 2009, 03:14:37 PM »

If this is the entire contents of your file, I'd try adding something like at the very top and bottom of the page. 

<?php
?>

I'd also make sure there wasn't a silly mistake of giving the file an extension of something other than .php
Logged
riders99
Newbie
*

Karma: 0
Posts: 1


« Reply #8 on: April 28, 2009, 11:53:46 PM »

There are many code in HTML then they can make an output in many categorized,and the code shall make a good data form..

_________________
Watch Hatton vs Pacquiao Live Online Free Stream
Logged
ddddyyyy
Newbie
*

Karma: 0
Posts: 1


« Reply #9 on: May 21, 2009, 01:46:45 AM »

I agree with  italianstalian




 









gucci shoes Gate valve mobile phone manufacturer True Religion Jeans puma shoes
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #10 on: June 19, 2009, 12:57:33 PM »

Unfortunately the code provided doesn't work. The file I'm modifying is template.class.php. In the body of the document I have HTML that shows up on every page but there's a certain snippet of HTML/Javascript code that I don't want visible to a non-administrator. It's similar to how the admin links don't show up on quick links on the main page of phpScheduleIt.

 I know this is a very basic PHP subject but some more help would be appreciated.

Thanks for all of the help and replies so far.

- ItalianStalian
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #11 on: June 19, 2009, 12:59:20 PM »

Unfortunately the code provided doesn't work. The file I'm modifying is template.class.php. In the body of the document I have HTML that shows up on every page but there's a certain snippet of HTML/Javascript code that I don't want visible to a non-administrator. It's similar to how the admin links don't show up on quick links on the main page of phpScheduleIt.

 I know this is a very basic PHP subject but some more help would be appreciated.

Thanks for all of the help and replies so far.

- ItalianStalian

The specific error is:

Fatal error: Class 'Admin' not found in /home/content/p/c/m/pcmdnwa/html/fsms/lib/Template.class.php on line 113

None of the rest of the content after the code works and that page becomes blank after the HTML before the admin entry.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #12 on: June 19, 2009, 01:54:07 PM »

Try adding this at line 16:

include_once($basedir . '/lib/Admin.class.php');
Logged
italianstalian
Newbie
*

Karma: 0
Posts: 31


« Reply #13 on: June 19, 2009, 02:49:11 PM »

It will try this. Thank you!
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #14 on: December 12, 2011, 01:20:52 PM »

It should work.  Can you post the code that you have?
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!