PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/add_editor.php

https://github.com/adamfranco/segue-1.x
PHP | 156 lines | 115 code | 22 blank | 19 comment | 24 complexity | 3d03f94b5f26937ca2cf0030d6ed22b5 MD5 | raw file
  1. <? /* $Id$ */
  2. //error_reporting(E_ALL && ~E_NOTICE);
  3. require("objects/objects.inc.php");
  4. ob_start();
  5. session_start();
  6. if (isset($_REQUEST['n'])) {
  7. //include("config.inc.php");
  8. //include("functions.inc.php");
  9. include("includes.inc.php");
  10. $usernames=userlookup($_REQUEST[n],LDAP_BOTH,LDAP_WILD,LDAP_LASTNAME,0);
  11. }
  12. // sort alphabetically
  13. if (isset($usernames) && count($usernames)) {
  14. // $usernames = array_change_key_case($usernames, CASE_LOWER);
  15. asort($usernames);
  16. reset($usernames);
  17. }
  18. /* print "<pre>"; */
  19. /* print_r($usernames); */
  20. /* print "</pre>"; */
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html>
  24. <head>
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  26. <title>Add Editors</title>
  27. <script type='text/javascript'>
  28. // <![CDATA[
  29. function addEditor(na) {
  30. f = document.lookup;
  31. o = opener.document.addform;
  32. if (na == '') {
  33. alert("You must enter a username, or search for one by pressing 'find'.");
  34. } else {
  35. <? if (isset($_REQUEST['comingfrom']) && $_REQUEST['comingfrom'] == "add_slot") { ?>
  36. o.owner.value = na;
  37. window.close();
  38. <? } else if (isset($_REQUEST['comingfrom']) && $_REQUEST['comingfrom'] == "classes") { ?>
  39. o.owner.value = na;
  40. window.close();
  41. <? } else { ?>
  42. o.edaction.value = 'add';
  43. o.edname.value = na;
  44. o.submit();
  45. <? } ?>
  46. }
  47. }
  48. // ]]>
  49. </script>
  50. <style type='text/css'>
  51. table {
  52. border: 1px solid #555;
  53. }
  54. th, td {
  55. border: 0px;
  56. background-color: #ddd;
  57. }
  58. th {
  59. background-color: #ccc;
  60. font-variant: small-caps;
  61. }
  62. body {
  63. background-color: white;
  64. }
  65. body, table, td, th, input {
  66. font-size: 12px;
  67. font-family: "Verdana", "sans-serif";
  68. }
  69. input {
  70. border: 1px solid black;
  71. background-color: white;
  72. font-size: 10px;
  73. }
  74. </style>
  75. </head>
  76. <body onload="document.lookup.n.focus()">
  77. <form action="<? echo $_SERVER['PHP_SELF'] ?>" method='get' name='lookup'>
  78. <table cellspacing='1' width='100%'>
  79. <tr>
  80. <th>Use</th>
  81. <th>Full Name</th>
  82. <th>Username</th>
  83. </tr>
  84. <tr>
  85. <td align='center'>
  86. <?
  87. if ($_SESSION['ltype']=='admin')
  88. print "<input type='button' name='use' value='add' onclick='addEditor(document.lookup.n.value)' />";
  89. else
  90. print "&nbsp;";
  91. ?>
  92. </td>
  93. <td>
  94. Name: <input type='text' name='n' size='20' value='<? if (isset($_REQUEST['n'])) echo $_REQUEST['n'];?>' />
  95. </td>
  96. <td>
  97. <input type='submit' value='find' />
  98. </td>
  99. </tr>
  100. <?
  101. if (isset($usernames) && count($usernames)) {
  102. $c = 1;
  103. foreach ($usernames as $u=>$f) {
  104. if (!$u || $u=='') next;
  105. if (!ereg("[a-z]",$u)) next;
  106. $u = strtolower($u);
  107. print "<tr>";
  108. print "<td align='center'><input type='button' name='use' value='add' onclick='addEditor(\"$u\")' /></td>";
  109. print "<td>$f</td><td>$u</td>";
  110. print "</tr>";
  111. $c++;
  112. }
  113. } else {
  114. print "<tr><td colspan='3'>No usernames. Enter a name or part of a name above.</td></tr>";
  115. }
  116. ?>
  117. </table>
  118. <input type='hidden' name="comingfrom" value="<? if (isset($_REQUEST['comingfrom'])) echo $_REQUEST['comingfrom']; ?>" />
  119. </form>
  120. <div align='right'>
  121. <input type='button' value='Done' onclick='window.close()' /></div>
  122. <?
  123. // debug output -- handy :)
  124. /* print "<pre>"; */
  125. /* print "request:\n"; */
  126. /* print_r($_REQUEST); */
  127. /* print "\n\n"; */
  128. /* print "session:\n"; */
  129. /* print_r($_SESSION); */
  130. /* print "\n\n"; */
  131. /* print "</pre>"; */
  132. ?>
  133. </body>
  134. </html>