PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/WebCalendar-1.2.5/assistant_edit.php

#
PHP | 84 lines | 66 code | 14 blank | 4 comment | 17 complexity | 0f0eb4cd9d68a6b95cddce9ef489222e MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* $Id: assistant_edit.php,v 1.38 2007/07/28 19:21:57 bbannon Exp $ */
  3. include_once 'includes/init.php';
  4. if ( empty ( $login ) || $login == '__public__' ) {
  5. // Do not allow public access.
  6. do_redirect ( empty ( $STARTVIEW ) ? 'month.php' : "$STARTVIEW" );
  7. exit;
  8. }
  9. if ( $user != $login )
  10. $user = ( ( $is_admin || $is_nonuser_admin ) && $user ) ? $user : $login;
  11. print_header ( ( $GROUPS_ENABLED == 'Y'
  12. ? array ( 'js/assistant_edit.php/true' ) : '' ) );
  13. ob_start ();
  14. echo '
  15. <form action="assistant_edit_handler.php" method="post" '
  16. . 'name="assistanteditform">' . ( $user ? '
  17. <input type="hidden" name="user" value="' . $user . '" />' : '' ) . '
  18. <h2>';
  19. $assistStr = translate ( 'Assistants' );
  20. if ( $is_nonuser_admin ) {
  21. nonuser_load_variables ( $user, 'nonuser' );
  22. echo $nonuserfullname . ' ' . $assistStr . '<br />
  23. -- ' . translate ( 'Admin mode' ) . ' --';
  24. } else
  25. echo translate ( 'Your assistants' );
  26. echo '</h2>
  27. ' . display_admin_link () . '
  28. <table>
  29. <tr>
  30. <td class="aligntop"><label for="users">'
  31. . $assistStr . ':</label></td>
  32. <td>
  33. <select name="users[]" id="users" size="10" multiple="multiple">';
  34. // Get list of all users.
  35. $users = get_my_users ();
  36. // Get list of users for this view.
  37. $res = dbi_execute ( 'SELECT cal_boss, cal_assistant FROM webcal_asst
  38. WHERE cal_boss = ?', array ( $user ) );
  39. if ( $res ) {
  40. while ( $row = dbi_fetch_row ( $res ) ) {
  41. $assistantuser[$row[1]] = 1;
  42. }
  43. dbi_free_result ( $res );
  44. }
  45. for ( $i = 0, $cnt = count ( $users ); $i < $cnt; $i++ ) {
  46. $u = $users[$i]['cal_login'];
  47. if ( $u == $login || $u == '__public__' )
  48. continue;
  49. echo '
  50. <option value="' . $u . '"'
  51. . ( ! empty ( $assistantuser[$u] ) ? ' selected="selected"' : '' ) . '>'
  52. . $users[$i]['cal_fullname'] . '</option>';
  53. }
  54. echo '
  55. </select>' . ( $GROUPS_ENABLED == 'Y' ? '
  56. <input type="button" onclick="selectUsers()" value="'
  57. . translate ( 'Select' ) . '..." />' : '' ) . '
  58. </td>
  59. </tr>
  60. <tr>
  61. <td colspan="2" class="aligncenter"><br /><input type="submit" '
  62. . 'name="action" value="' . translate ( 'Save' ) . '" />
  63. </td>
  64. </tr>
  65. </table>
  66. </form>
  67. ';
  68. ob_end_flush ();
  69. echo print_trailer ();
  70. ?>