function showVisibility()
{
global $DB, $CFG_GLPI;
$ID = $this->fields['id'];
$canedit = $this->canEdit($ID);
$rand = mt_rand();
$nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' ";
echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>";
echo "<input type='hidden' name='reminders_id' value='{$ID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>";
echo "<tr class='tab_bg_2'><td width='100px'>";
$types = array('Entity', 'Group', 'Profile', 'User');
$addrand = Dropdown::showItemTypes('_type', $types);
$params = array('type' => '__VALUE__', 'right' => 'reminder_public');
Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
echo "</td>";
echo "<td><span id='visibility{$rand}'></span>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $nb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('delete' => _x('button', 'Delete permanently')));
if ($this->fields['users_id'] != Session::getLoginUserID()) {
$massiveactionparams['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
}
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $nb) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
// Users
if (count($this->users)) {
foreach ($this->users as $key => $val) {
foreach ($val as $data) {
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('Reminder_User', $data["id"]);
echo "</td>";
}
echo "<td>" . __('User') . "</td>";
echo "<td>" . getUserName($data['users_id']) . "</td>";
echo "</tr>";
}
}
}
// Groups
if (count($this->groups)) {
foreach ($this->groups as $key => $val) {
foreach ($val as $data) {
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('Group_Reminder', $data["id"]);
echo "</td>";
}
echo "<td>" . __('Group') . "</td>";
$names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
$entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
if ($data['entities_id'] >= 0) {
$entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
if ($data['is_recursive']) {
//TRANS: R for Recursive
sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
}
}
echo "<td>" . $entname . "</td>";
echo "</tr>";
}
}
}
// Entity
if (count($this->entities)) {
foreach ($this->entities as $key => $val) {
foreach ($val as $data) {
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('Entity_Reminder', $data["id"]);
echo "</td>";
}
echo "<td>" . __('Entity') . "</td>";
$names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
$tooltip = Html::showToolTip($names["comment"], array('display' => false));
$entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
if ($data['is_recursive']) {
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
}
echo "<td>" . $entname . "</td>";
echo "</tr>";
}
}
}
// Profiles
if (count($this->profiles)) {
foreach ($this->profiles as $key => $val) {
foreach ($val as $data) {
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('Profile_Reminder', $data["id"]);
echo "</td>";
}
echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
$names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
$tooltip = Html::showToolTip($names["comment"], array('display' => false));
$entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
if ($data['entities_id'] >= 0) {
$entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
if ($data['is_recursive']) {
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
}
}
echo "<td>" . $entname . "</td>";
echo "</tr>";
}
}
}
if ($nb) {
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $nb) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
// Add items
return true;
}