function is_admin() { if (!isset($_SESSION['valid_user_id'])) { return false; } return get_user_status($_SESSION['valid_user_id']) == 2; }
/** * Returns if user is a guest. * * @param string $user_status used if $user not initialized * @return bool */ function is_a_guest($user_status = '') { return get_user_status($user_status) == 'guest'; }
function get_user_color($id) { $status = get_user_status($id); $str = ''; if ($status == 0) { $str = '<font color="green">On</font>'; } else { if ($status == 1) { $str = '<font color="red">Off</font>'; } else { $str = '<font color="grey">Unknown</font>'; } } return $str; }
$stmt->execute(); $result = $stmt->fetchAll(); if (!empty($result)) { foreach ($result as $row) { $ec = explode(",", $row['unit']); $result = array_intersect($ee, $ec); if ($result) { ?> <tr> <td style="width: 200px;"><small><?php echo name_of_user_ret($row['id']); ?> </small></td> <td style=""><small class="text-danger"><center><?php echo get_user_status($row['id']); ?> </center></small></td> <td style=""><small class="text-danger"><center><?php echo get_total_tickets_free($row['id']); ?> </center></small></td> <td style=""><small class="text-warning"><center><?php echo get_total_tickets_lock($row['id']); ?> </center></small></td> <td style=""><small class="text-success"><center><?php echo get_total_tickets_ok($row['id']); ?> </center></small></td> <td style=""><small class=""><center><?php
echo $row['last'] . ', ' . $row['first']; ?> </td> <td> <?php get_user_type($dbc, $row['type'], 'echo'); ?> </td> <td> <?php echo $row['email']; ?> </td> <td> <?php get_user_status($dbc, $row['status'], 'echo'); ?> </td> </tr> <?php } } else { echo mysqli_error($dbc); } ?> </tbody> </table>
function display_menu($with_ranking = false) { if (session_is_registered('valid_user_id')) { switch (get_user_status($_SESSION['valid_user_id'])) { case 1: // normal users have $user_menu global $user_menu; $menu = $user_menu; break; case 2: // admins have $admin_menu global $admin_menu; $menu = $admin_menu; break; // $user_menu and $admin_menu are defined in cfg/config.php } } else { // user not logged in, menu consists only of login option $menu = array('' => 'Zaloguj siê'); } ?> <td width="170" valign="top"> <table bgcolor="#D9E1F0" border="1" width="100%" cellpadding="3" cellspacing="0"> <tr> <th class="naglowek_maly">M E N U</th> </tr> <?php foreach ($menu as $link => $title) { echo '<tr><td><a href="' . get_www_root() . $link . '" class="menu">' . $title . '</a></td></tr>' . "\n"; } ?> </table> <?php if ($with_ranking && is_admin()) { // only admins can see the ranking. echo "<br>\n"; echo '<table bgcolor="#d9e1f0" border="1" width="100%" cellpadding="3" cellspacing="0">' . "\n"; echo '<tr><th class="naglowek_maly">'; echo 'T O P 5'; echo "</th></tr>\n"; $what_top = array('user_id' => 'U¿ytkownicy', 'project_id' => 'Projekty'); foreach ($what_top as $field => $label) { $top_5 = get_top_5($field, true); if ($top_5 !== false && !empty($top_5)) { echo '<tr><td align="center">'; display_star(); echo ' <b>' . $label . '</b> '; display_star(); echo "</td></tr>\n"; $cur = 1; foreach ($top_5 as $id => $count) { echo '<tr><td>' . $cur . '. '; if ($field == 'user_id') { display_link_to_user($id); } elseif ($field == 'project_id') { display_link_to_project($id); } echo ' (' . $count . ")</td></tr>\n"; ++$cur; } } } echo "</table>\n"; } ?> </td><td align="left" valign="top"> <?php }
"> <tr> <td><table> <tr> <td align="right">Nazwa projektu:</td> <td align="left"><input type="text" name="project_name" value="<?php echo htmlspecialchars($project_name); ?> " maxlength="25" size="35"></td> </tr> <tr> <td align="right">OCP:</td> <td align="left"><select name="ocp_id"> <?php $active_users = get_active_users(); if (get_user_status($ocp_id) == 0) { $active_users[$ocp_id] = get_user_login($ocp_id); asort($active_users); } foreach ($active_users as $user_id => $login) { echo '<option value="' . $user_id . '"'; if ($user_id == $ocp_id) { echo ' selected'; } echo '>' . $login . "</option>\n"; } ?> </select></td> </tr> </table> </td>