PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/faq/add_item.php

http://lansuite.googlecode.com/
PHP | 176 lines | 98 code | 63 blank | 15 comment | 29 complexity | a2f5a947f563b41d1bd4716137b47f8e MD5 | raw file
Possible License(s): LGPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /*************************************************************************
  3. *
  4. * Lansuite - Webbased LAN-Party Management System
  5. * -------------------------------------------------------------------
  6. * Lansuite Version: 2.0
  7. * File Version: 2.0
  8. * Filename: add_item.php
  9. * Module: FAQ
  10. * Main editor: Micheal@one-network.org
  11. * Last change: 29.03.2003 20:17
  12. * Description: Adds FAQ Items
  13. * Remarks:
  14. *
  15. **************************************************************************/
  16. switch($_GET["step"]) {
  17. case 2:
  18. // ERRORS
  19. $get_cat_names = $db->qry("SELECT name FROM %prefix%faq_cat");
  20. while($row=$db->fetch_array($get_cat_names)) {
  21. $name = $row["name"];
  22. if($name == $_POST["question_new_cat"] AND $_POST["question_new_cat"] != "" ) {
  23. $faq_error['question_cat'] = t('Dieser Kategoriename existiert bereits');
  24. $_GET["step"] = 1;
  25. }
  26. }
  27. $i = strlen($_POST["question_text"]);
  28. if($i > 5000) {
  29. $faq_error['question_text'] = t('Die Antwort darf nicht mehr als 5000 Zeichen enthalten');
  30. $_GET["step"] = 1;
  31. }
  32. if($_POST["question_new_cat"] == "" AND $_POST["question_cat"] == "new") {
  33. $faq_error['cat_name'] = t('Bitte gib einen Namen für die neue Kategorie ein');
  34. $_GET["step"] = 1;
  35. }
  36. if($_POST["question_caption"] == "") {
  37. $faq_error['question_caption'] = t('Bitte gib eine Frage ein');
  38. $_GET["step"] = 1;
  39. }
  40. if($_POST["question_text"] == "") {
  41. $faq_error['question_text'] = t('Bitte gib einen Text ein');
  42. $_GET["step"] = 1;
  43. }
  44. if($_POST["question_cat"] == 0 AND $_POST["question_new_cat"] == "") {
  45. $faq_error['question_cat'] = t('Bitte wähle eine Kategorie aus oder erstelle eine neue Kategorie');
  46. $_GET["step"] = 1;
  47. }
  48. if($_POST["question_cat"] != 0 AND $_POST["question_new_cat"] != "") {
  49. $faq_error['question_cat'] = t('Bitte wähle eine Kategorie aus <b> ODER </b> erstelle eine neue Kategorie');
  50. $_GET["step"] = 1;
  51. }
  52. break;
  53. } // close switch
  54. switch($_GET["step"]) {
  55. default:
  56. unset($_SESSION['add_blocker_faqitem']);
  57. $dsp->NewContent(t('Frage hinzufügen'),t(' Um eine Frage hinzuzufügen, fülle bitte das folgende Formular vollständig aus. Für das Feld Überschirft stehen 30 Zeichen, für das Feld Text 5000 Zeichen zur Verfügung. Im Feld Kategorie kannst du die Kategorie definieren, in der die Frage angezeigt werden soll.'));
  58. $dsp->SetForm("index.php?mod=faq&object=item&action=add_item&step=2");
  59. $get_cats = $db->qry("SELECT name,catid FROM %prefix%faq_cat");
  60. $faq_cats[] = "<option selected value=\"0\"> ".t('Kategorie wählen')." </option>";
  61. while($row=$db->fetch_array($get_cats)) {
  62. $faq_cats[] .= "<option value=" . $row["catid"] . "> " . $row["name"] . " </option>";
  63. }
  64. $dsp->AddTextFieldRow("question_caption",t('Frage / Überschrift'),$_POST['question_caption'],$faq_error['question_caption']);
  65. $dsp->AddTextAreaPlusRow("question_text",t('Text'),$_POST['question_text'],$faq_error['question_text'], 70, 20);
  66. $dsp->AddDropDownFieldRow("question_cat",t('Bestehende Kategorie'),$faq_cats,"");
  67. $dsp->AddTextFieldRow("question_new_cat",t('Neue Kategorie'),$_POST['question_new_cat'],$faq_error['question_cat']);
  68. $dsp->AddFormSubmitRow("add");
  69. $dsp->AddContent();
  70. break; // BREAK DEFAULT
  71. case 2:
  72. $courent_date = date("U");
  73. if($_POST["question_cat"] == 0 AND $_POST["question_new_cat"] != "" AND $_SESSION['add_blocker_faqitem'] != 1) {
  74. $add_it = $db->qry("INSERT INTO %prefix%faq_cat SET
  75. name = %string%,
  76. poster = %int%,
  77. date = %string%
  78. ", $_POST["question_new_cat"], $_SESSION["auth"]["userid"], $courent_date);
  79. $catid = $db->insert_id();
  80. $add_it = $db->qry("INSERT INTO %prefix%faq_item SET
  81. caption = %string%,
  82. text = %string%,
  83. poster = %int%,
  84. date = %string%,
  85. catid = %int%
  86. ", $_POST["question_caption"], $_POST["question_text"], $_SESSION["auth"]["userid"], $courent_date, $catid);
  87. if($add_it == 1) { $func->confirmation(t('Die Frage und die Kategorie wurden erfolgreich eingetragen'),"");
  88. $_SESSION['add_blocker_faqitem'] = 1;
  89. }
  90. else {
  91. $func->error("NO_REFRESH");
  92. }
  93. }
  94. else {
  95. if($_SESSION["add_blocker_faqitem"] != 1) {
  96. $add_it = $db->qry("INSERT INTO %prefix%faq_item SET
  97. caption = %string%,
  98. text = %string%,
  99. poster = %int%,
  100. date = %string%,
  101. catid = %string%
  102. ", $_POST["question_caption"], $_POST["question_text"], $_SESSION["auth"]["userid"], $courent_date, $_POST["question_cat"]);
  103. if($add_it == 1) { $func->confirmation(t('Die Frage wurde erfolgreich eingetragen'),"");
  104. $add_blocker_faqitem = 1;
  105. $_SESSION['add_blocker_faqitem'] = 1;
  106. }
  107. }
  108. else
  109. $func->error("NO_REFRESH");
  110. }
  111. break; // BREAK CASE 2
  112. } // close switch step
  113. ?>