diff --git a/lang/fr/LC_MESSAGES/messages.po b/lang/fr/LC_MESSAGES/messages.po index 120e669974f..142e748c5a8 100644 --- a/lang/fr/LC_MESSAGES/messages.po +++ b/lang/fr/LC_MESSAGES/messages.po @@ -14690,3 +14690,9 @@ msgstr "Certains collecteurs ne sont pas à jour en base de données; vérifiez msgid "Latency detected, check configuration for better optimization" msgstr "Latence détectée, vérifiez la configuration pour une meilleure optimisation" + +msgid "You can't edit this downtime because you don't have access to all of its resources" +msgstr "Vous ne pouvez pas éditer ce temps d’arrêt car vous n'êtes pas autorisé à accéder à toutes les ressources liées" + +msgid "You can't edit this hostgroup because you don't have access to all its resources" +msgstr "Vous ne pouvez pas éditer groupe d'hote car vous n'êtes pas autorisé à accéder à toutes les ressources liées" diff --git a/www/include/configuration/configObject/hostgroup/formHostGroup.ihtml b/www/include/configuration/configObject/hostgroup/formHostGroup.ihtml index f0af2b97481..447e6ccf1d4 100644 --- a/www/include/configuration/configObject/hostgroup/formHostGroup.ihtml +++ b/www/include/configuration/configObject/hostgroup/formHostGroup.ihtml @@ -1,66 +1,119 @@ {$form.javascript}{$javascript}
-
- {if $o == "a" || $o == "c"} -

{$form.submitC.html}{$form.submitA.html}   {$form.reset.html}

- {else if $o == "w"} -

{$form.change.html}

- {/if} -
-
- - - - - - - - - - - - - - + {if !$form.msgacl } +
+ {if $o == "a" || $o == "c"} +

{$form.submitC.html}{$form.submitA.html}   {$form.reset.html}

+ {else if $o == "w"} +

{$form.change.html}

+ {/if} +
+ {/if} + {if $form.msgacl } +
+ {t}You can't edit this hostgroup because you don't have access to all its resources{/t} +
+ {/if} +
+
-

| {$form.header.title}

-
-

{$form.header.information}

-
{$form.hg_name.label}{$form.hg_name.html}
{$form.hg_alias.label}{$form.hg_alias.html}
-

{$form.header.relation}

-
{$form.hg_hosts.label}

{$form.hg_hosts.html}

+ + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - {if $o == "a" || $o == "c"} - - {/if} -
+

| {$form.header.title}

+
+

{$form.header.information}

+
{$form.hg_name.label}{$form.hg_name.html}
{$form.hg_alias.label}{$form.hg_alias.html}
-

{$form.header.extended}

-
{$form.hg_notes.label}

{$form.hg_notes.html}

{$form.hg_notes_url.label}

{$form.hg_notes_url.html}

{$form.hg_action_url.label}

{$form.hg_action_url.html}

{$form.hg_icon_image.label}

{$form.hg_icon_image.html}  

{$form.hg_map_icon_image.label}

{$form.hg_map_icon_image.html}  

{$form.geo_coords.label}{$form.geo_coords.html}
-

{$form.header.furtherInfos}

-
{$form.hg_rrd_retention.label}{$form.hg_rrd_retention.html} {$days}
{$form.hg_comment.label}{$form.hg_comment.html}
{$form.hg_activate.label}{$form.hg_activate.html}
{$form.required._note}
-
-
- {if $o == "a" || $o == "c"} -

{$form.submitC.html}{$form.submitA.html}   {$form.reset.html}

- {else if $o == "w"} -

{$form.change.html}

- {/if} -
- {$form.hidden} + + +

{$form.header.relation}

+ + + + {$form.hg_hosts.label} +

{$form.hg_hosts.html}

+ + + + +

{$form.header.extended}

+ + + + {$form.hg_notes.label} +

{$form.hg_notes.html}

+ + + {$form.hg_notes_url.label} +

{$form.hg_notes_url.html}

+ + + {$form.hg_action_url.label} +

{$form.hg_action_url.html}

+ + + {$form.hg_icon_image.label} +

{$form.hg_icon_image.html}  

+ + + + {$form.hg_map_icon_image.label} + +

{$form.hg_map_icon_image.html}  

+ + + {$form.geo_coords.label} + {$form.geo_coords.html} + + + + +

{$form.header.furtherInfos}

+ + + + + {$form.hg_rrd_retention.label} + + {$form.hg_rrd_retention.html} {$days} + + + {$form.hg_comment.label} + {$form.hg_comment.html} + + + {$form.hg_activate.label} + {$form.hg_activate.html} + + {if $o == "a" || $o == "c"} + + {$form.required._note} + + {/if} + + + {if !$form.msgacl } +
+ {if $o == "a" || $o == "c"} +

{$form.submitC.html}{$form.submitA.html}   {$form.reset.html}

+ {else if $o == "w"} +

{$form.change.html}

+ {/if} +
+ {/if} + {$form.hidden}
{$helptext} diff --git a/www/include/configuration/configObject/hostgroup/formHostGroup.php b/www/include/configuration/configObject/hostgroup/formHostGroup.php index f5720077173..eb39e5dd565 100644 --- a/www/include/configuration/configObject/hostgroup/formHostGroup.php +++ b/www/include/configuration/configObject/hostgroup/formHostGroup.php @@ -37,7 +37,7 @@ exit(); } -if (!$oreon->user->admin) { +if (!$centreon->user->admin) { if ($hg_id && false === strpos($hgString, "'" . $hg_id . "'")) { $msg = new CentreonMsg(); $msg->setImage("./img/icons/warning.png"); @@ -212,12 +212,27 @@ function myReplace() $form->setDefaults($hg); $form->freeze(); } elseif ($o == "c") { - /* - * Modify a HostGroup information - */ + //Modify a HostGroup information $subC = $form->addElement('submit', 'submitC', _("Save"), array("class" => "btc bt_success")); $res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default")); $form->setDefaults($hg); + + //check host resources + $hostArray = array(); + $host = $acl->getHostAclConf(null, 'broker'); + $accessHost = array_keys($host); + $rq = "SELECT DISTINCT h.host_id FROM hostgroup_relation hgr, host h " . + " WHERE hostgroup_hg_id = '" . $hg_id . "' AND h.host_id = hgr.host_host_id AND h.host_register = '1' "; + $db = $pearDB->query($rq); + while ($row = $db->fetch()) { + $hostArray[] = $row['host_id']; + } + $result = array_diff($hostArray, $accessHost); + if (!empty($result) && (!$centreon->user->admin)) { + $form->addElement('text', 'msgacl', _("error"), 'error'); + $form->freeze(); + } + } elseif ($o == "a") { /* * Add a HostGroup information diff --git a/www/include/configuration/configObject/hostgroup/hostGroup.php b/www/include/configuration/configObject/hostgroup/hostGroup.php index 7279b3e76c1..9596d1d3038 100644 --- a/www/include/configuration/configObject/hostgroup/hostGroup.php +++ b/www/include/configuration/configObject/hostgroup/hostGroup.php @@ -39,7 +39,7 @@ isset($_GET["hg_id"]) ? $hG = $_GET["hg_id"] : $hG = null; isset($_POST["hg_id"]) ? $hP = $_POST["hg_id"] : $hP = null; -$hG ? $hg_id = $hG : $hg_id = $hP; +$hG ? $hg_id = (int)$hG : $hg_id = (int)$hP; isset($_GET["select"]) ? $cG = $_GET["select"] : $cG = null; isset($_POST["select"]) ? $cP = $_POST["select"] : $cP = null; diff --git a/www/include/monitoring/recurrentDowntime/formDowntime.html b/www/include/monitoring/recurrentDowntime/formDowntime.html index daea361b064..70015d5b446 100644 --- a/www/include/monitoring/recurrentDowntime/formDowntime.html +++ b/www/include/monitoring/recurrentDowntime/formDowntime.html @@ -235,21 +235,31 @@ } {/literal} +
{$msg_err}
+ +{if $form.msgacl } +
+ {t}You can't edit this downtime because you don't have access to all of its resources{/t} +
+{/if} +
-
- {if $o == "a" || $o == "c" || $o == "mc"} -

{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}   {$form.reset.html}

- {else if $o == "w"} -

{$form.change.html}

+ {if !$form.msgacl } +
+ {if $o == "a" || $o == "c" || $o == "mc"} +

{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}   {$form.reset.html}

+ {else if $o == "w"} +

{$form.change.html}

+ {/if} +
{/if}
-
@@ -276,13 +286,22 @@

{$form.header.periods}

{if $period_err }{/if} - + {if !$form.msgacl } + + {/if}
{$period_err}
{if $o != "w"}{/if} + {if $o != "w"} +
+ + {$add} +
+ {/if} +
    - {if $o == "w"} + {if $o == "w" || $form.msgacl } {foreach item=period from=$periods_tab} {assign var='nbperiod' value='1'} {if $period.month_cycle == 'none'} @@ -360,13 +379,15 @@

    {$form.header.linkManagement}

    {/if}
-
- {if $o == "a" || $o == "c" || $o == "mc"} -

{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}   {$form.reset.html}

- {else if $o == "w"} -

{$form.change.html}

+ {if !$form.msgacl } +
+ {if $o == "a" || $o == "c" || $o == "mc"} +

{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}   {$form.reset.html}

+ {else if $o == "w"} +

{$form.change.html}

+ {/if} +
{/if} -
{$form.hidden}
-{$helptext} \ No newline at end of file +{$helptext} diff --git a/www/include/monitoring/recurrentDowntime/formDowntime.php b/www/include/monitoring/recurrentDowntime/formDowntime.php index 30aedbce51a..7e65c64d8a8 100644 --- a/www/include/monitoring/recurrentDowntime/formDowntime.php +++ b/www/include/monitoring/recurrentDowntime/formDowntime.php @@ -156,6 +156,7 @@ function testDowntimeNameExistence($downtimeName = null) $attrHosts, array('defaultDatasetRoute' => $routeAttrHosts) ); + $form->addElement('select2', 'host_relation', _("Linked with Hosts"), array(), $attrHost1); /* @@ -212,6 +213,7 @@ function testDowntimeNameExistence($downtimeName = null) ); } + /* * Smarty template Init */ @@ -234,6 +236,39 @@ function testDowntimeNameExistence($downtimeName = null) /* * Modify a service information */ + require_once _CENTREON_PATH_ . "/www/class/centreonACL.class.php"; + + $userId = $centreon->user->user_id; + $isAdmin = $centreon->user->admin; + $acl = new CentreonACL($userId, $isAdmin); + + //check host resources + $host = $acl->getHostAclConf(null, 'broker'); + $accessHost = array_keys($host); + $result = array_diff($default_dt['host_relation'], $accessHost); + if (!empty($result)) { + $form->addElement('text', 'msgacl', _("error"), 'error'); + $form->freeze(); + } else { + //check hostgroup resources + $hgs = $acl->getHostGroupAclConf(null, 'broker'); + $accessHg = array_keys($hgs); + $result = array_diff($default_dt['hostgroup_relation'], $accessHg); + if (!empty($result)) { + $form->addElement('text', 'msgacl', _("error"), 'error'); + $form->freeze(); + } else { + //check servicegroup resources + $sgs = $acl->getServiceGroupAclConf(null, 'broker'); + $accessSg = array_keys($sgs); + $result = array_diff($default_dt['svcgroup_relation'], $accessSg); + if (!empty($result)) { + $form->addElement('text', 'msgacl', _("error"), 'error'); + $form->freeze(); + } + } + } + $subC = $form->addElement( 'button', 'submitC', diff --git a/www/include/monitoring/recurrentDowntime/templates/monthly_basis.html b/www/include/monitoring/recurrentDowntime/templates/monthly_basis.html index 8fcaf300f57..fdabedced40 100644 --- a/www/include/monitoring/recurrentDowntime/templates/monthly_basis.html +++ b/www/include/monitoring/recurrentDowntime/templates/monthly_basis.html @@ -65,5 +65,13 @@ jQuery(".timepicker").timepicker(); }); + + + $(document).ready(function () { + var validButton = $('#validForm'); + if (!validButton.length) { + $("#tabs_periods :input").prop("disabled", true); + } + }); {/literal} \ No newline at end of file diff --git a/www/include/monitoring/recurrentDowntime/templates/specific_date.html b/www/include/monitoring/recurrentDowntime/templates/specific_date.html index 8e9b9a1836e..0eb91054934 100644 --- a/www/include/monitoring/recurrentDowntime/templates/specific_date.html +++ b/www/include/monitoring/recurrentDowntime/templates/specific_date.html @@ -72,5 +72,12 @@ jQuery(".timepicker").timepicker(); }); + + $(document).ready(function () { + var validButton = $('#validForm'); + if (!validButton.length) { + $("#tabs_periods :input").prop("disabled", true); + } + }); {/literal} diff --git a/www/include/monitoring/recurrentDowntime/templates/weekly_basis.html b/www/include/monitoring/recurrentDowntime/templates/weekly_basis.html index 08bc86cbe38..2e0a85ffd00 100644 --- a/www/include/monitoring/recurrentDowntime/templates/weekly_basis.html +++ b/www/include/monitoring/recurrentDowntime/templates/weekly_basis.html @@ -59,8 +59,14 @@ }); } - jQuery(".timepicker").timepicker(); }); + +$(document).ready(function () { + var validButton = $('#validForm'); + if (!validButton.length) { + $("#tabs_periods :input").prop("disabled", true); + } +}); -{/literal} \ No newline at end of file +{/literal}