static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { global $CFG_GLPI; if ($item->getType() == 'NotificationMailSetting') { $target = $CFG_GLPI["root_doc"] . "/plugins/additionalalerts/front/config.form.php"; self::showFormAlerts($target); } else { if ($item->getType() == 'Entity') { PluginAdditionalalertsInfocomAlert::showNotificationOptions($item); PluginAdditionalalertsOcsAlert::showNotificationOptions($item); } } return true; }
static function showNotificationOptions(Entity $entity) { $con_spotted = false; $ID = $entity->getField('id'); if (!$entity->can($ID, 'r')) { return false; } // Notification right applied $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID); // Get data $entitynotification = new PluginAdditionalalertsOcsAlert(); if (!$entitynotification->getFromDBbyEntity($ID)) { $entitynotification->getEmpty(); } if ($canedit) { echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td>" . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>"; $default_value = $entitynotification->fields['use_newocs_alert']; Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $default_value, 'inherit_global' => 1)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>"; Alert::dropdownIntegerNever('delay_ocs', $entitynotification->fields["delay_ocs"], array('max' => 99, 'inherit_global' => 1)); echo " " . _n('Day', 'Days', 2) . "</td>"; echo "</tr>"; if ($canedit) { echo "<tr>"; echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='hidden' name='entities_id' value='{$ID}'>"; if ($entitynotification->fields["id"]) { echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">"; echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >"; } else { echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >"; } echo "</td></tr>"; echo "</table>"; Html::closeForm(); } else { echo "</table>"; } }
static function displayAlerts() { global $DB; $CronTask = new CronTask(); $config = new PluginAdditionalalertsConfig(); $config->getFromDB('1'); $infocom = new PluginAdditionalalertsInfocomAlert(); $infocom->getFromDBbyEntity($_SESSION["glpiactive_entity"]); if (isset($infocom->fields["use_infocom_alert"]) && $infocom->fields["use_infocom_alert"] > 0) { $use_infocom_alert = $infocom->fields["use_infocom_alert"]; } else { $use_infocom_alert = $config->fields["use_infocom_alert"]; } $ocsalert = new PluginAdditionalalertsOcsAlert(); $ocsalert->getFromDBbyEntity($_SESSION["glpiactive_entity"]); if (isset($ocsalert->fields["use_newocs_alert"]) && $ocsalert->fields["use_newocs_alert"] > 0) { $use_newocs_alert = $ocsalert->fields["use_newocs_alert"]; } else { $use_newocs_alert = $config->fields["use_newocs_alert"]; } if (isset($ocsalert->fields["delay_ocs"]) && $ocsalert->fields["delay_ocs"] > 0) { $delay_ocs = $ocsalert->fields["delay_ocs"]; } else { $delay_ocs = $config->fields["delay_ocs"]; } $additionalalerts_ocs = 0; if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsOcs")) { if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $delay_ocs > 0) { $additionalalerts_ocs = 1; } } $additionalalerts_new_ocs = 0; if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsNewOcs")) { if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $use_newocs_alert > 0) { $additionalalerts_new_ocs = 1; } } $additionalalerts_not_infocom = 0; if ($CronTask->getFromDBbyName("PluginAdditionalalertsInfocomAlert", "AdditionalalertsNotInfocom")) { if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $use_infocom_alert > 0) { $additionalalerts_not_infocom = 1; } } if ($additionalalerts_ocs == 0 && $additionalalerts_new_ocs == 0 && $additionalalerts_not_infocom == 0) { echo "<div align='center'><b>" . __('No used alerts', 'additionalalerts') . "</b></div>"; } if ($additionalalerts_not_infocom != 0) { if (Session::haveRight("infocom", "w")) { $query = PluginAdditionalalertsInfocomAlert::query($_SESSION["glpiactive_entity"]); $result = $DB->query($query); if ($DB->numrows($result) > 0) { if (Session::isMultiEntitiesMode()) { $nbcol = 7; } else { $nbcol = 6; } echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>"; echo PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Operating system') . "</th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Location') . "</th>"; echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th></tr>"; while ($data = $DB->fetch_array($result)) { echo PluginAdditionalalertsInfocomAlert::displayBody($data); } echo "</table></div>"; } else { echo "<br><div align='center'><b>" . __('No computers with no buy date', 'additionalalerts') . "</b></div>"; } echo "<br>"; } } if ($additionalalerts_new_ocs != 0) { $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng") && plugin_ocsinventoryng_haveRight("ocsng", "w")) { foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) { $query = PluginAdditionalalertsOcsAlert::queryNew($config, $_SESSION["glpiactive_entity"]); $result = $DB->query($query); if ($DB->numrows($result) > 0) { if (Session::isMultiEntitiesMode()) { $nbcol = 9; } else { $nbcol = 8; } echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>"; echo __('New imported computers from OCS-NG', 'additionalalerts') . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . __('Operating system') . "</th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Location') . "</th>"; echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th>"; echo "<th>" . __('Last OCSNG inventory date', 'additionalalerts') . "</th>"; echo "<th>" . __('Import date in GLPI', 'additionalalerts') . "</th>"; echo "<th>" . __('OCSNG server', 'additionalalerts') . "</th></tr>"; while ($data = $DB->fetch_array($result)) { echo PluginAdditionalalertsOcsAlert::displayBody($data); } echo "</table></div>"; } else { echo "<br><div align='center'><b>" . __('No new imported computer from OCS-NG', 'additionalalerts') . "</b></div>"; } } echo "<br>"; } } if ($additionalalerts_ocs != 0) { $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng") && plugin_ocsinventoryng_haveRight("ocsng", "w")) { foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) { $query = PluginAdditionalalertsOcsAlert::query($delay_ocs, $config, $_SESSION["glpiactive_entity"]); $result = $DB->query($query); if ($DB->numrows($result) > 0) { if (Session::isMultiEntitiesMode()) { $nbcol = 9; } else { $nbcol = 8; } echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>"; echo __('Computers not synchronized with OCS-NG since more', 'additionalalerts') . " " . $delay_ocs . " " . _n('Day', 'Days', 2) . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . __('Operating system') . "</th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Location') . "</th>"; echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th>"; echo "<th>" . __('Last OCSNG inventory date', 'additionalalerts') . "</th>"; echo "<th>" . __('Import date in GLPI', 'additionalalerts') . "</th>"; echo "<th>" . __('OCSNG server', 'additionalalerts') . "</th></tr>"; while ($data = $DB->fetch_array($result)) { echo PluginAdditionalalertsOcsAlert::displayBody($data); } echo "</table></div>"; } else { echo "<br><div align='center'><b>" . __('No computer not synchronized since more', 'additionalalerts') . " " . $delay_ocs . " " . _n('Day', 'Days', 2) . "</b></div>"; } } echo "<br>"; } } }
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Additionalalerts is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with additionalalerts. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $state = new PluginAdditionalalertsNotificationState(); $ocsalert = new PluginAdditionalalertsOcsAlert(); if (isset($_POST["add"])) { if ($ocsalert->canCreate()) { $newID = $ocsalert->add($_POST); } Html::back(); } else { if (isset($_POST["update"])) { if ($ocsalert->canCreate()) { $ocsalert->update($_POST); } Html::back(); } else { if (isset($_POST["add_state"])) { if ($ocsalert->canCreate()) { $newID = $state->add($_POST);
function getTags() { $tags = array('ocsmachine.name' => __('Name'), 'ocsmachine.urlname' => __('URL') . " " . __('Name'), 'ocsmachine.operatingsystem' => __('Operating system'), 'ocsmachine.state' => __('Status'), 'ocsmachine.location' => __('Location'), 'ocsmachine.user' => __('User'), 'ocsmachine.urluser' => __('URL') . " " . __('User'), 'ocsmachine.group' => __('Group'), 'ocsmachine.urlgroup' => __('URL') . " " . __('Group'), 'ocsmachine.contact' => __('Alternate username'), 'ocsmachine.lastocsupdate' => __('Last OCSNG inventory date', 'additionalalerts'), 'ocsmachine.lastupdate' => __('Import date in GLPI', 'additionalalerts'), 'ocsmachine.ocsserver' => __('OCSNG server', 'additionalalerts')); foreach ($tags as $tag => $label) { $this->addTagToList(array('tag' => $tag, 'label' => $label, 'value' => true)); } $this->addTagToList(array('tag' => 'additionalalerts', 'label' => PluginAdditionalalertsOcsAlert::getTypeName(2), 'value' => false, 'foreach' => true, 'events' => array('ocs', 'newocs'))); asort($this->tag_descriptions); }