PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/nacridan/conquest/cqglobalMP.inc.php

https://gitlab.com/nacridan/Nacridan
PHP | 133 lines | 100 code | 32 blank | 1 comment | 8 complexity | 2050fbd0e83950005dc363570556298c MD5 | raw file
  1. <?php
  2. class CQGlobalMP extends HTMLObject
  3. {
  4. public $nacridan;
  5. public $players;
  6. public $db;
  7. public $style;
  8. public function CQGlobalMP($nacridan, $style, $db)
  9. {
  10. $this->db = $db;
  11. $this->nacridan = $nacridan;
  12. if ($nacridan == null)
  13. $this->players = array();
  14. else
  15. $this->players = $this->nacridan->loadSessPlayers();
  16. $this->style = $style;
  17. }
  18. public function toString()
  19. {
  20. $db = $this->db;
  21. $players = $this->players;
  22. $id = 0;
  23. $curAdmin = $this->nacridan->loadCurSessPlayer($db);
  24. if (isset($_POST['createconfirm'])) // ------------------- CREATION -----------------
  25. {
  26. if ($_POST['createconfirm'] == 'yes') {
  27. require_once (HOMEPATH . "/factory/MailFactory.inc.php");
  28. $title = base64_decode($_POST["title"]);
  29. $body = base64_decode($_POST["MPcontent"]);
  30. $author = $curAdmin;
  31. $target = $curAdmin->get("name");
  32. $dbplayers = new DBCollection('SELECT name FROM Player WHERE id_member!=0 AND authlevel<2 AND disabled!=99 AND status="PC" AND name IS NOT NULL ', $db);
  33. while (! $dbplayers->eof()) {
  34. $target .= "," . $dbplayers->get("name");
  35. $dbplayers->next();
  36. }
  37. $targetArray = explode(",", $target);
  38. $type = 0; // message normal
  39. MailFactory::sendSingleDestMsg($author, $title, $body, $targetArray, $type, $err, $this->db, - 1, 0);
  40. $str = "<table class='maintable " . $this->style . "'>\n";
  41. $str .= "<tr><td class='mainbgbody'>" . $err . "</td></tr>";
  42. $str .= "</table>";
  43. } else {
  44. $str = "<table class='maintable " . $this->style . "'>\n";
  45. $str .= "<tr><td class='mainbgbody'>Le message n'a pas été envoyé.</td></tr>";
  46. $str .= "</table>";
  47. }
  48. return $str;
  49. } elseif (isset($_POST['check'])) // --------------VERIFICATION DE L'ANNONCE
  50. {
  51. $content = array();
  52. $title = array();
  53. $section = array();
  54. $str = "<form name='form' method=post target='_self'>\n";
  55. $str .= "<table class='maintable " . $this->style . "'>\n";
  56. $str .= "<tr>\n";
  57. $str .= "<td colspan='2' class='mainbgtitle'><b>" . localize('CRÉATION D\'UNE ANNONCE') . "</b></td>\n";
  58. $str .= "</tr>\n";
  59. $str .= "<tr><td class='mainbgbody'>Cette annonce convient-elle ? Attention le message sera envoyé à tous les joueurs !</td></tr>";
  60. $str .= "<tr><td>";
  61. $str .= "<div style='color: #999999'>";
  62. $str .= "<b>" . stripslashes($_POST["title"]) . "</b><br/>";
  63. $str .= "<br/>";
  64. $str .= str_replace("\n", "<br/>", stripslashes($_POST["MPcontent"])) . "<br/>";
  65. $str .= "<br/>";
  66. $title = stripslashes($_POST["title"]);
  67. $MPcontent = stripslashes($_POST["MPcontent"]);
  68. $str .= "</div>";
  69. $str .= "</td></tr>";
  70. $str .= "<tr><td class='mainbgbody'>" . "<input type='radio' name='createconfirm' value='yes' id='yes' />" . "<label for='yes'>Oui.</label></td></tr>";
  71. $str .= "<tr><td class='mainbgbody'>" . "<input type='radio' name='createconfirm' value='no' id='no' />" . "<label for='no'>Non.</label></td></tr>";
  72. // $str.="<tr><td class='mainbgbody'>".serialize($content)."</td></tr>";
  73. $str .= "</table>";
  74. $str .= "<input type='hidden' name='title' value='" . base64_encode($title) . "'/>";
  75. $str .= "<input type='hidden' name='MPcontent' value='" . base64_encode($MPcontent) . "'/>";
  76. $str .= "<td><input type='submit' name='ok' value='Ok'/></td></tr>";
  77. $str .= "</form>";
  78. return $str;
  79. } else // ------- FORMULAIRE DE CREATION
  80. {
  81. $str = "<table class='maintable " . $this->style . "'>\n";
  82. $str .= "<form name='form' method=post target='_self'>\n";
  83. $str .= "<tr>\n";
  84. $str .= "<td colspan='2' class='mainbgtitle'><b>" . localize('CRÉATION D\'UN MP DIFFUSÉ A TOUS LES JOUEURS') . "</b></td>\n";
  85. $str .= "</tr>\n";
  86. $str .= "<tr>\n";
  87. $str .= "<td class='mainbgbody' width='100px' align='left'><label for='title'> Sujet du message</label> </td>";
  88. $str .= "<td class='mainbgbody' width='200px' align='center'> <input type='text' name='title' id='title' /> </td>";
  89. $str .= "</tr>";
  90. $str .= "<tr>";
  91. $str .= "<td class='mainbgbody' width='100px' align='left'><label for='MPcontent'> Contenu du message </label> </td>";
  92. $str .= "<td class='mainbgbody' width='200px' align='center'> <textarea rows=6 cols=40 name='MPcontent' id='MPcontent' /> </textarea></td>";
  93. $str .= "</tr>";
  94. $str .= "<td><input type='submit' name='check' value='Créer'/></td></tr>";
  95. $str .= "</form>";
  96. $str .= "</table>";
  97. return $str;
  98. }
  99. }
  100. }
  101. ?>