home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / administrator / users / index.php < prev    next >
PHP Script  |  2004-03-08  |  7KB  |  196 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. require($GO_LANGUAGE->get_language_file('users'));
  15. require($GO_CONFIG->class_path."users.class.inc");
  16. $users = new users();
  17.  
  18. $GO_SECURITY->authenticate(true);
  19.  
  20. $return_to = $GO_CONFIG->host.'configuration/';
  21.  
  22. if (isset($_REQUEST['delete_user']))
  23. {
  24.     if (($_REQUEST['delete_user'] != $GO_SECURITY->user_id) && ($_REQUEST['delete_user'] != 1))
  25.     {
  26.         $users->delete_user($_REQUEST['delete_user']);
  27.     }else
  28.     {
  29.         $feedback = '<p class="Error">'.$delete_fail.'</p>';
  30.     }
  31. }
  32.  
  33. $max_rows = isset($_REQUEST['max_rows']) ? $_REQUEST['max_rows'] : $_SESSION['GO_SESSION']['max_rows_list'];
  34. $first = isset($_REQUEST['first']) ? $_REQUEST['first'] : 0;
  35.  
  36. //remember sorting in cookie
  37. if (isset($_REQUEST['newsort']))
  38. {
  39.     SetCookie("admin_sort",$_REQUEST['newsort'],time()+3600*24*365,"/","",0);
  40.     $_COOKIE['admin_sort'] = $_REQUEST['newsort'];
  41. }
  42. if (isset($_REQUEST['newdirection']))
  43. {
  44.     SetCookie("admin_direction",$_REQUEST['newdirection'],time()+3600*24*365,"/","",0);
  45.     $_COOKIE['admin_direction'] = $_REQUEST['newdirection'];
  46. }
  47.  
  48. $admin_sort = isset($_COOKIE['admin_sort']) ? $_COOKIE['admin_sort'] : 'name';
  49. $admin_direction = isset($_COOKIE['admin_direction']) ? $_COOKIE['admin_direction'] : 'ASC';
  50.  
  51. if ($admin_direction == "DESC")
  52. {
  53.     $image_string = ' <img src="'.$GO_THEME->images['arrow_down'].'" border="0" />';
  54.     $newdirection = "ASC";
  55. }else
  56. {
  57.     $image_string = ' <img src="'.$GO_THEME->images['arrow_up'].'" border="0" />';
  58.     $newdirection = "DESC";
  59. }
  60.  
  61. $page_title = $menu_users;
  62. require($GO_THEME->theme_path."header.inc");
  63.  
  64.  
  65. $count = $users->get_users($admin_sort, $admin_direction, $first, $max_rows);
  66.  
  67. if ($count > 0)
  68. {
  69.         echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
  70.  
  71.     if ($GO_CONFIG->max_users == 0 || ($count < $GO_CONFIG->max_users))
  72.         echo '<tr><td colspan="99" align="right"><a href="register.php" class="normal">'.$admin_new_user.'</a></td></tr>';
  73.  
  74.     echo '<tr><td colspan="99"><h1>'.$menu_users.'</h1>';
  75.     if (isset($feedback)) echo $feedback;
  76.     echo '</td></tr>';
  77.         echo '<tr><td colspan="99" align="right" class="small">'.$count.' '.$strUsers;
  78.         if ($GO_CONFIG->max_users != 0)
  79.                 echo ' '.$strMaxOf.' '.$GO_CONFIG->max_users;
  80.  
  81.     echo '</td></tr>';
  82.     echo "<tr>";
  83.     echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?newsort=name&newdirection=".$newdirection."\">".$strName;
  84.     if ($admin_sort == "name")
  85.             echo $image_string;
  86.     echo "</a></td>\n";
  87.     echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?newsort=company&newdirection=".$newdirection."\">".$strCompany;
  88.     if ($admin_sort == "company")
  89.             echo $image_string;
  90.     echo "</a></td>\n";
  91.     echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?newsort=logins&newdirection=".$newdirection."\">".$strLogins;
  92.     if ($admin_sort == "logins")
  93.             echo $image_string;
  94.     echo "</a></td>\n";
  95.             echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?newsort=lastlogin&newdirection=".$newdirection."\">".$ac_lastlogin;
  96.     if ($admin_sort == "lastlogin")
  97.             echo $image_string;
  98.     echo "</a></td>\n";
  99.     echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?newsort=registration_time&newdirection=".$newdirection."\">".$strRegistrationDate;
  100.     if ($admin_sort == "registration_time")
  101.             echo $image_string;
  102.     echo "</a></td>\n";
  103.     echo "<td class=\"TableHead2\"> </td>\n";
  104.     echo "</tr>\n";
  105.  
  106.     while ($users->next_record())
  107.     {
  108.         $middle_name = $users->f('middle_name') == '' ? '' : $users->f('middle_name').' ';
  109.         $name = $users->f('first_name').' '.$middle_name.$users->f('last_name');
  110.         echo '<tr height="18"><td><a class="normal" href="edit_user.php?id='.$users->f("id").'" title="'.$strEdit.' '.$name.'">'.$name.'</a> </td>';
  111.         echo '<td>'.empty_to_stripe($users->f("company")).' </td>';
  112.         echo '<td>'.number_format($users->f("logins"), 0, $_SESSION['GO_SESSION']['decimal_seperator'], $_SESSION['GO_SESSION']['thousands_seperator']).' </td>';
  113.         echo '<td>'.date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $users->f("lastlogin")+($_SESSION['GO_SESSION']['timezone']*3600)).'   </td>';
  114.         echo '<td>'.date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'],$users->f("registration_time")+($_SESSION['GO_SESSION']['timezone']*3600)).'</td>';
  115.         echo "<td> <a href='javascript:confirm_action(\"".$_SERVER['PHP_SELF']."?delete_user=".$users->f("id")."\",\"".rawurlencode($strDeletePrefix."'".$name."'".$strDeleteSuffix)."\")' title=\"".$strDeleteItem." '".$name."'\"><img src=\"".$GO_THEME->images['delete']."\" border=\"0\"></a></td>";
  116.         echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  117.     }
  118.  
  119.  
  120.     $links = '';
  121.     $max_links=10;
  122.     if ($max_rows != 0)
  123.     {
  124.         if ($count > $max_rows)
  125.         {
  126.             $links = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>';
  127.             $next_start = $first+$max_rows;
  128.             $previous_start = $first-$max_rows;
  129.             if ($first != 0)
  130.             {
  131.                 $links .= '<a href="'.$_SERVER['PHP_SELF'].'?first=0"><<</a> ';
  132.                 $links .= '<a href="'.$_SERVER['PHP_SELF'].'?first='.$previous_start.'">'.$cmdPrevious.'</a> ';
  133.             }else
  134.             {
  135.                 $links .= '<font color="#cccccc"><< '.$cmdPrevious.'</font> ';
  136.             }
  137.  
  138.             $start = ($first-(($max_links/2)*$max_rows));
  139.  
  140.             $end = ($first+(($max_links/2)*$max_rows));
  141.  
  142.             if ($start < 0)
  143.             {
  144.                 $end = $end - $start;
  145.                 $start=0;
  146.             }
  147.             if ($end > $count)
  148.             {
  149.                 $end = $count;
  150.             }
  151.             if ($start > 0)
  152.             {
  153.                 $links .= '... ';
  154.             }
  155.  
  156.             for ($i=$start;$i<$end;$i+=$max_rows)
  157.             {
  158.                 $page = ($i/$max_rows)+1;
  159.                 if ($i==$first)
  160.                 {
  161.                     $links .= '<b><i>'.$page.'</i></b> ';
  162.                 }else
  163.                 {
  164.                     $links .= '<a href="'.$_SERVER['PHP_SELF'].'?first='.$i.'">'.$page.'</a> ';
  165.                 }
  166.             }
  167.  
  168.             if ($end < $count)
  169.             {
  170.                 $links .= '... ';
  171.             }
  172.  
  173.             $last_page = floor($count/$max_rows)*$max_rows;
  174.  
  175.             if ($count > $next_start)
  176.             {
  177.                 $links .= '<a href="'.$_SERVER['PHP_SELF'].'?first='.$next_start.'">'.$cmdNext.'</a> ';
  178.                 $links .= '<a href="'.$_SERVER['PHP_SELF'].'?first='.$last_page.'">>></a>';
  179.             }else
  180.             {
  181.                 $links .= '<font color="#cccccc">'.$cmdNext.' >></font>';
  182.             }
  183.             $links .= '</td><td align="right"><a class="normal" href="'.$_SERVER['PHP_SELF'].'?max_rows=0">'.$cmdShowAll.'</a></td></tr></table>';
  184.         }
  185.         echo '<tr><td colspan="99" height="20">'.$links.'</td></tr>';
  186.         echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  187.     }
  188.     echo '</table>';
  189. }
  190.  
  191.  
  192. echo '<br />';
  193. $button = new button($cmdClose, "javascript:document.location='".$return_to ."'");
  194. require($GO_THEME->theme_path."footer.inc");
  195. ?>
  196.