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

/www/include/options/accessLists/menusACL/listsMenusAccess.php

https://gitlab.com/florianocomercial/centreon
PHP | 169 lines | 93 code | 20 blank | 56 comment | 22 complexity | cd2490ccd5661915448b3a7b27ecec43 MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright 2005-2015 Centreon
  4. * Centreon is developped by : Julien Mathis and Romain Le Merlus under
  5. * GPL Licence 2.0.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License as published by the Free Software
  9. * Foundation ; either version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, see <http://www.gnu.org/licenses>.
  17. *
  18. * Linking this program statically or dynamically with other modules is making a
  19. * combined work based on this program. Thus, the terms and conditions of the GNU
  20. * General Public License cover the whole combination.
  21. *
  22. * As a special exception, the copyright holders of this program give Centreon
  23. * permission to link this program with independent modules to produce an executable,
  24. * regardless of the license terms of these independent modules, and to copy and
  25. * distribute the resulting executable under terms of Centreon choice, provided that
  26. * Centreon also meet, for each linked independent module, the terms and conditions
  27. * of the license of that module. An independent module is a module which is not
  28. * derived from this program. If you modify this program, you may extend this
  29. * exception to your version of the program, but you are not obliged to do so. If you
  30. * do not wish to do so, delete this exception statement from your version.
  31. *
  32. * For more information : contact@centreon.com
  33. *
  34. * SVN : $URL$
  35. * SVN : $Id$
  36. *
  37. */
  38. if (!isset($oreon))
  39. exit();
  40. include("./include/common/autoNumLimit.php");
  41. $SearchStr = "";
  42. $search = '';
  43. if (isset($_POST['searchACLM']) && $_POST['searchACLM'])
  44. $search = $_POST['searchACLM'];
  45. $SearchStr = " WHERE (acl_topo_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_topo_alias LIKE '".htmlentities($search, ENT_QUOTES, "UTF-8")."')";
  46. $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM acl_topology" . $SearchStr);
  47. $tmp = $DBRESULT->fetchRow();
  48. $rows = $tmp["COUNT(*)"];
  49. include("./include/common/checkPagination.php");
  50. /*
  51. * Smarty template Init
  52. */
  53. $tpl = new Smarty();
  54. $tpl = initSmartyTpl($path, $tpl);
  55. /*
  56. * start header menu
  57. */
  58. $tpl->assign("headerMenu_name", _("Name"));
  59. $tpl->assign("headerMenu_alias", _("Description"));
  60. $tpl->assign("headerMenu_status", _("Status"));
  61. $tpl->assign("headerMenu_options", _("Options"));
  62. # end header menu
  63. $SearchStr = "";
  64. if (isset($search) && $search)
  65. $SearchStr = "WHERE (acl_topo_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_topo_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')";
  66. $rq = "SELECT acl_topo_id, acl_topo_name, acl_topo_alias, acl_topo_activate FROM acl_topology $SearchStr ORDER BY acl_topo_name LIMIT ".$num * $limit.", ".$limit;
  67. $DBRESULT = $pearDB->query($rq);
  68. $search = tidySearchKey($search, $advanced_search);
  69. $form = new HTML_QuickForm('select_form', 'POST', "?p=".$p);
  70. /*
  71. * Different style between each lines
  72. */
  73. $style = "one";
  74. /*
  75. * Fill a tab with a mutlidimensionnal Array we put in $tpl
  76. */
  77. $elemArr = array();
  78. for ($i = 0; $topo = $DBRESULT->fetchRow(); $i++) {
  79. $selectedElements = $form->addElement('checkbox', "select[".$topo['acl_topo_id']."]");
  80. if ($topo["acl_topo_activate"])
  81. $moptions = "<a href='main.php?p=".$p."&acl_topo_id=".$topo['acl_topo_id']."&o=u&limit=".$limit."&num=".$num."&search=".$search."'><img src='img/icons/disabled.png' class='ico-14 margin_right' border='0' alt='"._("Disabled")."'></a>&nbsp;&nbsp;";
  82. else
  83. $moptions = "<a href='main.php?p=".$p."&acl_topo_id=".$topo['acl_topo_id']."&o=s&limit=".$limit."&num=".$num."&search=".$search."'><img src='img/icons/enabled.png' class='ico-14 margin_right' border='0' alt='"._("Enabled")."'></a>&nbsp;&nbsp;";
  84. $moptions .= "&nbsp;";
  85. $moptions .= "<input onKeypress=\"if(event.keyCode > 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$topo['acl_topo_id']."]'></input>";
  86. /* Contacts */
  87. $ctNbr = array();
  88. $rq = "SELECT COUNT(*) AS nbr FROM acl_topology_relations WHERE acl_topo_id = '".$topo['acl_topo_id']."'";
  89. $DBRESULT2 = $pearDB->query($rq);
  90. $ctNbr = $DBRESULT2->fetchRow();
  91. $elemArr[$i] = array("MenuClass"=>"list_".$style,
  92. "RowMenu_select"=>$selectedElements->toHtml(),
  93. "RowMenu_name"=>$topo["acl_topo_name"],
  94. "RowMenu_link"=>"?p=".$p."&o=c&acl_topo_id=".$topo['acl_topo_id'],
  95. "RowMenu_alias"=>myDecode($topo["acl_topo_alias"]),
  96. "RowMenu_status"=>$topo["acl_topo_activate"] ? _("Enabled") : _("Disabled"),
  97. "RowMenu_options"=>$moptions);
  98. $style != "two" ? $style = "two" : $style = "one";
  99. }
  100. $tpl->assign("elemArr", $elemArr);
  101. /*
  102. * Different messages we put in the template
  103. */
  104. $tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?")));
  105. ?>
  106. <script type="text/javascript">
  107. function setO(_i) {
  108. document.forms['form'].elements['o'].value = _i;
  109. }
  110. </SCRIPT>
  111. <?php
  112. $attrs1 = array(
  113. 'onchange'=>"javascript: " .
  114. "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" .
  115. " setO(this.form.elements['o1'].value); submit();} " .
  116. "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" .
  117. " setO(this.form.elements['o1'].value); submit();} " .
  118. "else if (this.form.elements['o1'].selectedIndex == 3) {" .
  119. " setO(this.form.elements['o1'].value); submit();} " .
  120. "");
  121. $form->addElement('select', 'o1', NULL, array(NULL=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1);
  122. $form->setDefaults(array('o1' => NULL));
  123. $attrs2 = array(
  124. 'onchange'=>"javascript: " .
  125. "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" .
  126. " setO(this.form.elements['o2'].value); submit();} " .
  127. "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" .
  128. " setO(this.form.elements['o2'].value); submit();} " .
  129. "else if (this.form.elements['o2'].selectedIndex == 3) {" .
  130. " setO(this.form.elements['o2'].value); submit();} " .
  131. "");
  132. $form->addElement('select', 'o2', NULL, array(NULL=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2);
  133. $form->setDefaults(array('o2' => NULL));
  134. $o1 = $form->getElement('o1');
  135. $o1->setValue(NULL);
  136. $o1->setSelected(NULL);
  137. $o2 = $form->getElement('o2');
  138. $o2->setValue(NULL);
  139. $o2->setSelected(NULL);
  140. $tpl->assign('limit', $limit);
  141. $tpl->assign('searchACLM', $search);
  142. /*
  143. * Apply a template definition
  144. */
  145. $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
  146. $form->accept($renderer);
  147. $tpl->assign('form', $renderer->toArray());
  148. $tpl->display("listsMenusAccess.ihtml");
  149. ?>