Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Mon 2803 acl resources access #6962

Merged
merged 10 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 114 additions & 61 deletions www/include/configuration/configObject/hostgroup/formHostGroup.ihtml
Original file line number Diff line number Diff line change
@@ -1,66 +1,119 @@
{$form.javascript}{$javascript}
<form {$form.attributes}>
<div id="validFormTop">
{if $o == "a" || $o == "c"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
<div id='tab1' class='tab'>
<table class="formTable table">
<tr class="ListHeader">
<td class="FormHeader" colspan="2">
<h3>| {$form.header.title}</h3>
</td>
</tr>
<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.information}</h4>
</td>
</tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="hostgroup_name"> {$form.hg_name.label}</td><td class="FormRowValue">{$form.hg_name.html}</td></tr>
<tr class="list_two"><td class="FormRowField"><img class="helpTooltip" name="alias"> {$form.hg_alias.label}</td><td class="FormRowValue">{$form.hg_alias.html}</td></tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.relation}</h4>
</td>
</tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="members"> {$form.hg_hosts.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_hosts.html} </p></td></tr>
{if !$form.msgacl }
<div id="validFormTop">
{if $o == "a" || $o == "c"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
{/if}
{if $form.msgacl }
<div style="color: red; text-align: center; font-weight: bold; margin: 4px">
{t}you can't edit this hostgroup because you have not access at all of this resources{/t}
loiclau marked this conversation as resolved.
Show resolved Hide resolved
</div>
{/if}
<div id='tab1' class='tab'>
<table class="formTable table">
<tr class="ListHeader">
<td class="FormHeader" colspan="2">
<h3>| {$form.header.title}</h3>
</td>
</tr>
<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.information}</h4>
</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="hostgroup_name"> {$form.hg_name.label}</td>
<td class="FormRowValue">{$form.hg_name.html}</td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="alias"> {$form.hg_alias.label}</td>
<td class="FormRowValue">{$form.hg_alias.html}</td>
</tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.extended}</h4>
</td>
</tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="notes"> {$form.hg_notes.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_notes.html}</p></td></tr>
<tr class="list_two"><td class="FormRowField"><img class="helpTooltip" name="notes_url"> {$form.hg_notes_url.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_notes_url.html}</p></td></tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="action_url"> {$form.hg_action_url.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_action_url.html}</p></td></tr>
<tr class="list_two"><td class="FormRowField"><img class="helpTooltip" name="icon_image"> {$form.hg_icon_image.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_icon_image.html}&nbsp;&nbsp;<img id='hg_icon_image_img' src='./img/blank.gif'></p></td></tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="statusmap_image"> {$form.hg_map_icon_image.label}</td><td class="FormRowValue"><p class="oreonbutton">{$form.hg_map_icon_image.html}&nbsp;&nbsp;<img id='hg_map_icon_image' src='./img/blank.gif'></p></td></tr>
<tr class="list_two"><td class="FormRowField"><img class="helpTooltip" name="geo_coords"> {$form.geo_coords.label}</td><td class="FormRowValue">{$form.geo_coords.html}</td></tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.furtherInfos}</h4>
</td>
</tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="hg_rrd_retention"> {$form.hg_rrd_retention.label}</td><td class="FormRowValue">{$form.hg_rrd_retention.html} {$days}</td></tr>
<tr class="list_two"><td class="FormRowField"><img class="helpTooltip" name="hg_comment"> {$form.hg_comment.label}</td><td class="FormRowValue">{$form.hg_comment.html}</td></tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="hg_activate"> {$form.hg_activate.label}</td><td class="FormRowValue">{$form.hg_activate.html}</td></tr>
{if $o == "a" || $o == "c"}
<tr class="list_lvl_2"><td class="ListColLvl2_name" colspan="2">{$form.required._note}</td></tr>
{/if}
</table>
</div>
<div id="validForm">
{if $o == "a" || $o == "c"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
{$form.hidden}
<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.relation}</h4>
</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="members"> {$form.hg_hosts.label}</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_hosts.html} </p></td>
</tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.extended}</h4>
</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="notes"> {$form.hg_notes.label}</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_notes.html}</p></td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="notes_url"> {$form.hg_notes_url.label}</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_notes_url.html}</p></td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="action_url"> {$form.hg_action_url.label}</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_action_url.html}</p></td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="icon_image"> {$form.hg_icon_image.label}</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_icon_image.html}&nbsp;&nbsp;<img
id='hg_icon_image_img' src='./img/blank.gif'></p></td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="statusmap_image">
{$form.hg_map_icon_image.label}
</td>
<td class="FormRowValue"><p class="oreonbutton">{$form.hg_map_icon_image.html}&nbsp;&nbsp;<img
id='hg_map_icon_image' src='./img/blank.gif'></p></td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="geo_coords"> {$form.geo_coords.label}</td>
<td class="FormRowValue">{$form.geo_coords.html}</td>
</tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.furtherInfos}</h4>
</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="hg_rrd_retention">
{$form.hg_rrd_retention.label}
</td>
<td class="FormRowValue">{$form.hg_rrd_retention.html} {$days}</td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="hg_comment"> {$form.hg_comment.label}</td>
<td class="FormRowValue">{$form.hg_comment.html}</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="hg_activate"> {$form.hg_activate.label}</td>
<td class="FormRowValue">{$form.hg_activate.html}</td>
</tr>
{if $o == "a" || $o == "c"}
<tr class="list_lvl_2">
<td class="ListColLvl2_name" colspan="2">{$form.required._note}</td>
</tr>
{/if}
</table>
</div>
{if !$form.msgacl }
<div id="validForm">
{if $o == "a" || $o == "c"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
{/if}
{$form.hidden}
</form>
{$helptext}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -218,6 +218,25 @@ function myReplace()
$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 resources Access of linked object
$aclFrom = "";
$aclCond = "";
if (!$centreon->user->admin) {
$aclFrom = ", $aclDbName.centreon_acl acl ";
$aclCond = " AND h.host_id = acl.host_id AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") ";
}
$rq = "SELECT DISTINCT h.host_id, h.host_activate FROM hostgroup_relation hgr, host h " . $aclFrom .
" WHERE hostgroup_hg_id = '" . $hg_id . "' AND h.host_id = hgr.host_host_id AND h.host_register = '1' ";
$db = $pearDB->query($rq);
$total = $db->rowCount();
$rq .= $aclCond;
$db = $pearDB->query($rq);
if (($db->rowCount() != $total) && (!$centreon->user->admin)) {
$form->addElement('text', 'msgacl', _("error"), 'error');
$form->freeze();
}

} elseif ($o == "a") {
/*
* Add a HostGroup information
Expand Down
51 changes: 36 additions & 15 deletions www/include/monitoring/recurrentDowntime/formDowntime.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,31 @@
}
</script>
{/literal}

<div id="msg_err" style="color: red; text-align: center; font-weight: bold; margin: 4px; {if !$msg_err }display: none;{/if}">{$msg_err}</div>

{if $form.msgacl }
<div style="color: red; text-align: center; font-weight: bold; margin: 4px" >
{t}you can't edit this downtime because you have not access at all of this resources{/t}
loiclau marked this conversation as resolved.
Show resolved Hide resolved
</div>
{/if}

<form {$form.attributes}>
<div class="headerTabContainer">
<ul id="mainnav">
<li class="a" id='c1'><a href="#" onclick="javascript:montre('1');">{$sort1}</a></li>
<li class="b" id='c2'><a href="#" onclick="javascript:montre('2');">{$sort2}</a></li>
</ul>
<div id="validFormTop">
{if $o == "a" || $o == "c" || $o == "mc"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{if !$form.msgacl }
<div id="validFormTop">
{if $o == "a" || $o == "c" || $o == "mc"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
{/if}
</div>
</div>
<div id="tab1" class="tab">
<table class="formTable table">
<tr class="ListHeader">
Expand All @@ -276,13 +286,22 @@ <h4>{$form.header.periods}</h4>
<table>
{if $period_err }<tr><td colspan="2" style="color: red;">{$period_err}</td></tr>{/if}
<tr>
<td class="FormRowValue">{if $o != "w"}<div style="cursor: pointer; color : #009fdf;"><img src="./img/icons/circle-plus.png" class="ico-14" style="vertical-align: middle;" onclick="addPeriods()" /> <a href="#" onclick="javascript:addPeriods()" style="color: #4ccaff; text-decoration: none;">{$add}</a></div>{/if}</td>
{if !$form.msgacl }
<td class="FormRowValue">
{if $o != "w"}
<div style="cursor: pointer; color : #009fdf;">
<img src="./img/icons/circle-plus.png" class="ico-14" style="vertical-align: middle;" onclick="addPeriods()" />
<a href="#" onclick="javascript:addPeriods()" style="color: #4ccaff; text-decoration: none;">{$add}</a>
</div>
{/if}
</td>
{/if}
</tr>
<tr>
<td>
<div id="tabs_periods">
<ul id="ul_tabs">
{if $o == "w"}
{if $o == "w" || $form.msgacl }
{foreach item=period from=$periods_tab}
{assign var='nbperiod' value='1'}
{if $period.month_cycle == 'none'}
Expand Down Expand Up @@ -360,13 +379,15 @@ <h4>{$form.header.linkManagement}</h4>
{/if}
</table>
</div>
<div id="validForm">
{if $o == "a" || $o == "c" || $o == "mc"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{if !$form.msgacl }
<div id="validForm">
{if $o == "a" || $o == "c" || $o == "mc"}
<p class="oreonbutton">{$form.submitC.html}{$form.submitMC.html}{$form.submitA.html}&nbsp;&nbsp;&nbsp;{$form.reset.html}</p>
{else if $o == "w"}
<p class="oreonbutton">{$form.change.html}</p>
{/if}
</div>
{/if}
</div>
{$form.hidden}
</form>
{$helptext}
{$helptext}
35 changes: 35 additions & 0 deletions www/include/monitoring/recurrentDowntime/formDowntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function testDowntimeNameExistence($downtimeName = null)
$attrHosts,
array('defaultDatasetRoute' => $routeAttrHosts)
);

$form->addElement('select2', 'host_relation', _("Linked with Hosts"), array(), $attrHost1);

/*
Expand Down Expand Up @@ -212,6 +213,7 @@ function testDowntimeNameExistence($downtimeName = null)
);
}


/*
* Smarty template Init
*/
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@
});

}

jQuery(".timepicker").timepicker();
});

$(document).ready(function () {
var validButton = $('#validForm');
if (!validButton.length) {
$("#tabs_periods :input").prop("disabled", true);
loiclau marked this conversation as resolved.
Show resolved Hide resolved
}
});
</script>
{/literal}