当前位置: 首页>>代码示例>>PHP>>正文


PHP CronTask::getFromDBbyName方法代码示例

本文整理汇总了PHP中CronTask::getFromDBbyName方法的典型用法代码示例。如果您正苦于以下问题:PHP CronTask::getFromDBbyName方法的具体用法?PHP CronTask::getFromDBbyName怎么用?PHP CronTask::getFromDBbyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CronTask的用法示例。


在下文中一共展示了CronTask::getFromDBbyName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_reservation_install

function plugin_reservation_install()
{
    global $DB;
    $migration = new Migration(100);
    if (!TableExists("glpi_plugin_reservation_manageresa")) {
        //INSTALL
        $query = "CREATE TABLE `glpi_plugin_reservation_manageresa` (\n      `id` int(11) NOT NULL AUTO_INCREMENT,\n      `resaid` int(11) NOT NULL,\n      `matid` int(11) NOT NULL,\n      `date_return` datetime,\n      `date_theorique` datetime NOT NULL,\n      `itemtype` VARCHAR(100) NOT NULL,\n      `dernierMail` datetime,\n      PRIMARY KEY (`id`)\n\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, $DB->error());
    } else {
        // UPDATE
    }
    if (TableExists("glpi_plugin_reservation_config")) {
        $query = "RENAME TABLE `glpi_plugin_reservation_config` TO `glpi_plugin_reservation_configdayforauto`";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_reservation_configdayforauto")) {
        // Création de la table config
        $query = "CREATE TABLE `glpi_plugin_reservation_configdayforauto` (\n        `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,\n        `jour` char(32) NOT NULL default '',\n        `actif` int(1) NOT NULL default '1'\n        )ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
        $query = "INSERT INTO `glpi_plugin_reservation_configdayforauto` (`jour` , `actif`)\n                VALUES (\"lundi\",1),\n                       (\"mardi\",1),\n                       (\"mercredi\",1),\n                       (\"jeudi\",1),\n                       (\"vendredi\",1),\n                       (\"samedi\",0),\n                       (\"dimanche\",0)";
        $DB->queryOrDie($query) or die($DB->error());
    } else {
        // UPDATE
    }
    if (!TableExists("glpi_plugin_reservation_config")) {
        // Création de la table config
        $query = "CREATE TABLE `glpi_plugin_reservation_config` (\n        `name` VARCHAR(10) NOT NULL PRIMARY KEY,\n        `value` VARCHAR(10) NOT NULL\n        )ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
        $query = "INSERT INTO `glpi_plugin_reservation_config` (`name` , `value`)\n                VALUES (\"methode\",\"manual\")";
        $DB->queryOrDie($query) or die($DB->error());
    } else {
        // UPDATE
    }
    $cron = new CronTask();
    if (!$cron->getFromDBbyName('PluginReservationTask', 'SurveilleResa')) {
        CronTask::Register('PluginReservationTask', 'SurveilleResa', 5 * MINUTE_TIMESTAMP, array('param' => 24, 'mode' => 2, 'logs_lifetime' => 10));
    }
    if (!$cron->getFromDBbyName('PluginReservationTask', 'MailUserDelayedResa')) {
        CronTask::Register('PluginReservationTask', 'MailUserDelayedResa', DAY_TIMESTAMP, array('hourmin' => 23, 'hourmax' => 24, 'mode' => 2, 'logs_lifetime' => 30, 'state' => 0));
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:42,代码来源:hook.php

示例2: cronAdditionalalertsNewOcs

 static function cronAdditionalalertsNewOcs($task = NULL)
 {
     global $DB, $CFG_GLPI;
     if (!$CFG_GLPI["use_mailing"]) {
         return 0;
     }
     $CronTask = new CronTask();
     if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsNewOcs")) {
         if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
             return 0;
         }
     } else {
         return 0;
     }
     $message = array();
     $cron_status = 0;
     foreach (self::getEntitiesToNotify('use_newocs_alert') as $entity => $repeat) {
         foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) {
             $query_newocsmachine = self::queryNew($config, $entity);
             $newocsmachine_infos = array();
             $newocsmachine_messages = array();
             $type = Alert::END;
             $newocsmachine_infos[$type] = array();
             foreach ($DB->request($query_newocsmachine) as $data) {
                 $entity = $data['entities_id'];
                 $message = $data["name"];
                 $newocsmachine_infos[$type][$entity][] = $data;
                 if (!isset($newocsmachines_infos[$type][$entity])) {
                     $newocsmachine_messages[$type][$entity] = __('New imported computers from OCS-NG', 'additionalalerts') . "<br />";
                 }
                 $newocsmachine_messages[$type][$entity] .= $message;
             }
             $delay_ocs = 0;
             foreach ($newocsmachine_infos[$type] as $entity => $newocsmachines) {
                 Plugin::loadLang('additionalalerts');
                 if (NotificationEvent::raiseEvent("newocs", new PluginAdditionalalertsOcsAlert(), array('entities_id' => $entity, 'ocsmachines' => $newocsmachines, 'delay_ocs' => $delay_ocs))) {
                     $message = $newocsmachine_messages[$type][$entity];
                     $cron_status = 1;
                     if ($task) {
                         $task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ":  {$message}\n");
                         $task->addVolume(1);
                     } else {
                         Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ":  {$message}");
                     }
                 } else {
                     if ($task) {
                         $task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ":  Send newocsmachines alert failed\n");
                     } else {
                         Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ":  Send newocsmachines alert failed", false, ERROR);
                     }
                 }
             }
         }
     }
     return $cron_status;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:56,代码来源:ocsalert.class.php

示例3: plugin_additionalalerts_install

function plugin_additionalalerts_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/additionalalerts/inc/profile.class.php";
    $install = false;
    $update78 = false;
    $update80 = false;
    if (!TableExists("glpi_plugin_alerting_config") && !TableExists("glpi_plugin_additionalalerts_notificationstates")) {
        $install = true;
        $DB->runFile(GLPI_ROOT . "/plugins/additionalalerts/sql/empty-1.7.0.sql");
    } else {
        if (TableExists("glpi_plugin_alerting_profiles") && FieldExists("glpi_plugin_alerting_profiles", "interface")) {
            $update78 = true;
            $update80 = true;
            $DB->runFile(GLPI_ROOT . "/plugins/additionalalerts/sql/update-1.2.0.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/additionalalerts/sql/update-1.3.0.sql");
        } else {
            if (!TableExists("glpi_plugin_additionalalerts_notificationstates")) {
                $update78 = true;
                $update80 = true;
                $DB->runFile(GLPI_ROOT . "/plugins/additionalalerts/sql/update-1.3.0.sql");
            } else {
                if (TableExists("glpi_plugin_additionalalerts_reminderalerts")) {
                    $DB->runFile(GLPI_ROOT . "/plugins/additionalalerts/sql/update-1.5.0.sql");
                    $notif = new Notification();
                    $options = array('itemtype' => 'PluginAdditionalalertsReminderAlert', 'event' => 'reminder', 'FIELDS' => 'id');
                    foreach ($DB->request('glpi_notifications', $options) as $data) {
                        $notif->delete($data);
                    }
                    $template = new NotificationTemplate();
                    $translation = new NotificationTemplateTranslation();
                    $options = array('itemtype' => 'PluginAdditionalalertsReminderAlert', 'FIELDS' => 'id');
                    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
                        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
                        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
                            $translation->delete($data_template);
                        }
                        $template->delete($data);
                    }
                    $temp = new CronTask();
                    if ($temp->getFromDBbyName('PluginAdditionalalertsReminderAlert', 'AdditionalalertsReminder')) {
                        $temp->delete(array('id' => $temp->fields["id"]));
                    }
                }
            }
        }
    }
    if ($install || $update78) {
        //Do One time on 0.78
        $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginAdditionalalertsInfocomAlert' AND `name` = 'Alert infocoms'";
        $result = $DB->query($query_id) or die($DB->error());
        $itemtype = $DB->result($result, 0, 'id');
        $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n                                 VALUES(NULL, " . $itemtype . ", '','##lang.notinfocom.title## : ##notinfocom.entity##',\n                        '##FOREACHnotinfocoms##\n   ##lang.notinfocom.name## : ##notinfocom.name##\n   ##lang.notinfocom.computertype## : ##notinfocom.computertype##\n   ##lang.notinfocom.operatingsystem## : ##notinfocom.operatingsystem##\n   ##lang.notinfocom.state## : ##notinfocom.state##\n   ##lang.notinfocom.location## : ##notinfocom.location##\n   ##lang.notinfocom.user## : ##notinfocom.user## / ##notinfocom.group## / ##notinfocom.contact##\n   ##ENDFOREACHnotinfocoms##',\n                        '&lt;table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\"&gt;\n   &lt;tbody&gt;\n   &lt;tr&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.name##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.computertype##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.operatingsystem##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.state##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.location##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.notinfocom.user##&lt;/span&gt;&lt;/td&gt;\n   &lt;/tr&gt;\n   ##FOREACHnotinfocoms##            \n   &lt;tr&gt;\n   &lt;td&gt;&lt;a href=\"##notinfocom.urlname##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.name##&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.computertype##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.operatingsystem##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.state##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.location##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;a href=\"##notinfocom.urluser##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.user##&lt;/span&gt;&lt;/a&gt; / &lt;a href=\"##notinfocom.urlgroup##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.group##&lt;/span&gt;&lt;/a&gt; / &lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##notinfocom.contact##&lt;/span&gt;&lt;/td&gt;\n   &lt;/tr&gt;\n   ##ENDFOREACHnotinfocoms##\n   &lt;/tbody&gt;\n   &lt;/table&gt;');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\n                                   VALUES (NULL, 'Alert infocoms', 0, 'PluginAdditionalalertsInfocomAlert', 'notinfocom',\n                                          'mail'," . $itemtype . ",\n                                          '', 1, 1, '2010-03-13 10:36:46');";
        $result = $DB->query($query);
        ////////////////////
        $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginAdditionalalertsOcsAlert' AND `name` = 'Alert machines ocs'";
        $result = $DB->query($query_id) or die($DB->error());
        $itemtype = $DB->result($result, 0, 'id');
        $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n                                 VALUES(NULL, " . $itemtype . ", '','##lang.ocsmachine.title## : ##ocsmachine.entity##',\n                        '##FOREACHocsmachines##\n   ##lang.ocsmachine.name## : ##ocsmachine.name##\n   ##lang.ocsmachine.operatingsystem## : ##ocsmachine.operatingsystem##\n   ##lang.ocsmachine.state## : ##ocsmachine.state##\n   ##lang.ocsmachine.location## : ##ocsmachine.location##\n   ##lang.ocsmachine.user## : ##ocsmachine.user## / ##lang.ocsmachine.group## : ##ocsmachine.group## / ##lang.ocsmachine.contact## : ##ocsmachine.contact##\n   ##lang.ocsmachine.lastocsupdate## : ##ocsmachine.lastocsupdate##\n   ##lang.ocsmachine.lastupdate## : ##ocsmachine.lastupdate##\n   ##lang.ocsmachine.ocsserver## : ##ocsmachine.ocsserver##\n   ##ENDFOREACHocsmachines##',\n                        '&lt;table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\"&gt;\n   &lt;tbody&gt;\n   &lt;tr&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.name##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.operatingsystem##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.state##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.location##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.user##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.lastocsupdate##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.lastupdate##&lt;/span&gt;&lt;/td&gt;\n   &lt;td style=\"text-align: left;\" bgcolor=\"#cccccc\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##lang.ocsmachine.ocsserver##&lt;/span&gt;&lt;/td&gt;\n   &lt;/tr&gt;\n   ##FOREACHocsmachines##                 \n   &lt;tr&gt;\n   &lt;td&gt;&lt;a href=\"##ocsmachine.urlname##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.name##&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.operatingsystem##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.state##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.location##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;##IFocsmachine.user##&lt;a href=\"##ocsmachine.urluser##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.user##&lt;/span&gt;&lt;/a&gt; / ##ENDIFocsmachine.user####IFocsmachine.group##&lt;a href=\"##ocsmachine.urlgroup##\"&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.group##&lt;/span&gt;&lt;/a&gt; / ##ENDIFocsmachine.group####IFocsmachine.contact##&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.contact####ENDIFocsmachine.contact##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.lastocsupdate##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.lastupdate##&lt;/span&gt;&lt;/td&gt;\n   &lt;td&gt;&lt;span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"&gt;##ocsmachine.ocsserver##&lt;/span&gt;&lt;/td&gt;\n   &lt;/tr&gt;\n   ##ENDFOREACHocsmachines##\n   &lt;/tbody&gt;\n   &lt;/table&gt;');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\n                                   VALUES (NULL, 'Alert new machines ocs', 0, 'PluginAdditionalalertsOcsAlert', 'newocs',\n                                          'mail'," . $itemtype . ",\n                                          '', 1, 1, '2010-03-20 10:36:46');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\n                                   VALUES (NULL, 'Alert ocs synchronization', 0, 'PluginAdditionalalertsOcsAlert', 'ocs',\n                                          'mail'," . $itemtype . ",\n                                          '', 1, 1, '2010-03-20 10:36:46');";
        $result = $DB->query($query);
    }
    if ($update78) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_additionalalerts_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_additionalalerts_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_additionalalerts_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
    }
    // To be called for each task the plugin manage
    CronTask::Register('PluginAdditionalalertsOcsAlert', 'AdditionalalertsOcs', DAY_TIMESTAMP);
    CronTask::Register('PluginAdditionalalertsOcsAlert', 'AdditionalalertsNewOcs', HOUR_TIMESTAMP);
    CronTask::Register('PluginAdditionalalertsInfocomAlert', 'AdditionalalertsNotInfocom', HOUR_TIMESTAMP);
    PluginAdditionalalertsProfile::initProfile();
    PluginAdditionalalertsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.7.0");
    $migration->dropTable('glpi_plugin_accounts_profiles');
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:90,代码来源:hook.php

示例4: plugin_fusioninventory_check_prerequisites

function plugin_fusioninventory_check_prerequisites()
{
    global $DB;
    if (!isset($_SESSION['glpi_plugins'])) {
        $_SESSION['glpi_plugins'] = array();
    }
    if (version_compare(GLPI_VERSION, '0.85', 'lt') || version_compare(GLPI_VERSION, '0.92', 'ge')) {
        echo __('Your GLPI version not compatible, require >= 0.85', 'fusioninventory');
        return FALSE;
    }
    if (!function_exists('finfo_open')) {
        echo __('fileinfo extension (PHP) is required...', 'fusioninventory');
        return FALSE;
    }
    $plugin = new Plugin();
    if ($plugin->isActivated("fusioninventory") && !TableExists("glpi_plugin_fusioninventory_configs")) {
        return FALSE;
    }
    $a_plugins = array('fusinvinventory', 'fusinvsnmp', 'fusinvdeploy');
    foreach ($a_plugins as $pluginname) {
        if (file_exists(GLPI_ROOT . '/plugins/' . $pluginname)) {
            printf(__('Please remove folder %s in glpi/plugins/', 'fusioninventory'), $pluginname);
            return FALSE;
        }
    }
    $crontask = new CronTask();
    if ($plugin->isActivated("fusioninventory")) {
        if (TableExists("glpi_plugin_fusioninventory_agents") and !FieldExists("glpi_plugin_fusioninventory_agents", "tag") or $crontask->getFromDBbyName('PluginFusioninventoryTaskjobstatus', 'cleantaskjob') or TableExists("glpi_plugin_fusioninventory_agentmodules") and FieldExists("glpi_plugin_fusioninventory_agentmodules", "url")) {
            $DB->query("UPDATE `glpi_plugin_fusioninventory_configs` SET `value`='0.80+1.4'\n                        WHERE `type`='version'");
            $DB->query("UPDATE `glpi_plugins` SET `version`='0.80+1.4'\n                        WHERE `directory` LIKE 'fusi%'");
        }
    }
    return TRUE;
}
开发者ID:AircraftRu,项目名称:fusioninventory-for-glpi,代码行数:34,代码来源:setup.php

示例5: install

 static function install(Migration $migration)
 {
     $cron = new CronTask();
     if (!$cron->getFromDBbyName(__CLASS__, 'purgeLogs')) {
         CronTask::Register(__CLASS__, 'purgeLogs', 7 * DAY_TIMESTAMP, array('param' => 24, 'mode' => CronTask::MODE_EXTERNAL));
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:7,代码来源:purge.class.php

示例6: date

*/
include '../../../inc/includes.php';
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources");
} else {
    Html::helpHeader(PluginResourcesResource::getTypeName(2));
}
if (empty($_POST["date_end"])) {
    $_POST["date_end"] = date("Y-m-d");
}
$resource = new PluginResourcesResource();
$checklistconfig = new PluginResourcesChecklistconfig();
if (isset($_POST["removeresources"]) && $_POST["plugin_resources_resources_id"] != 0) {
    $date = date("Y-m-d H:i:s");
    $CronTask = new CronTask();
    $CronTask->getFromDBbyName("PluginResourcesEmployment", "ResourcesLeaving");
    $input["id"] = $_POST["plugin_resources_resources_id"];
    $input["date_end"] = $_POST["date_end"];
    if ($_POST["date_end"] < $date || $CronTask->fields["state"] == CronTask::STATE_DISABLE) {
        $input["is_leaving"] = "1";
    } else {
        $input["is_leaving"] = "0";
    }
    $input["plugin_resources_leavingreasons_id"] = $_POST["plugin_resources_leavingreasons_id"];
    $input["withtemplate"] = "0";
    $input["users_id_recipient_leaving"] = Session::getLoginUserID();
    $input['send_notification'] = 1;
    $resource->update($input);
    //test it
    $resource->getFromDB($_POST["plugin_resources_resources_id"]);
    $resources_checklist = PluginResourcesChecklist::checkIfChecklistExist($_POST["plugin_resources_resources_id"]);
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:resource.remove.php

示例7: plugin_ocsinventoryng_uninstall

function plugin_ocsinventoryng_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_threads", "glpi_plugin_ocsinventoryng_servers", "glpi_plugin_ocsinventoryng_configs", "glpi_plugin_ocsinventoryng_notimportedcomputers", "glpi_plugin_ocsinventoryng_details", "glpi_plugin_ocsinventoryng_registrykeys", "glpi_plugin_ocsinventoryng_networkports", "glpi_plugin_ocsinventoryng_networkporttypes");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_bookmarks", "glpi_displaypreferences", "glpi_documents_items", "glpi_logs", "glpi_tickets");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE\n                  FROM `" . $table_glpi . "`\n                  WHERE `itemtype` IN ('PluginMassocsimportNotimported',\n                                       'PluginMassocsimportDetail',\n                                       'PluginOcsinventoryngOcsServer',\n                                       'PluginOcsinventoryngNotimportedcomputer',\n                                       'PluginOcsinventoryngDetail')");
    }
    $query = "DELETE\n             FROM `glpi_alerts`\n             WHERE `itemtype` IN ('PluginMassocsimportNotimported',\n                                  'PluginOcsinventoryngNotimportedcomputer')";
    $DB->queryOrDie($query, $DB->error());
    // clean rules
    $rule = new RuleImportEntity();
    foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity', 'name' => 'RootOcs')) as $data) {
        $rule->delete($data);
    }
    $notification = new Notification();
    foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $notification->delete($data);
    }
    $template = new NotificationTemplate();
    foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $template->delete($data);
    }
    $cron = new CronTask();
    if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) {
        // creation du cron - param = duree de conservation
        CronTask::Unregister('massocsimport');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) {
        // creation du cron - param = duree de conservation
        CronTask::Unregister('ocsinventoryng');
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:37,代码来源:hook.php

示例8: cronCleanOldAgents

 /**
  * @param $task
  * @return int
  */
 static function cronCleanOldAgents($task)
 {
     global $DB;
     $CronTask = new CronTask();
     if ($CronTask->getFromDBbyName("PluginOcsinventoryngOcsServer", "CleanOldAgents")) {
         if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
             return 0;
         }
     } else {
         return 0;
     }
     $cron_status = 0;
     $plugin_ocsinventoryng_ocsservers_id = 0;
     foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1 AND `use_cleancron` = 1") as $config) {
         $plugin_ocsinventoryng_ocsservers_id = $config["id"];
         if ($plugin_ocsinventoryng_ocsservers_id > 0) {
             $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id);
             $agents = $ocsClient->getOldAgents();
             $computers = array();
             if (count($agents) > 0) {
                 $nb = $ocsClient->deleteOldAgents($agents);
                 if ($nb) {
                     self::manageDeleted($plugin_ocsinventoryng_ocsservers_id, false);
                     $cron_status = 1;
                     if ($task) {
                         $task->addVolume($nb);
                         $task->log(__('Clean old agents OK', 'ocsinventoryng'));
                     }
                 } else {
                     $task->log(__('Clean old agents failed', 'ocsinventoryng'));
                 }
             }
         }
     }
     return $cron_status;
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:40,代码来源:ocsserver.class.php

示例9: cronAdditionalalertsNotInfocom

 /**
  * Cron action
  *
  * @param $task for log, if NULL display
  *
  **/
 static function cronAdditionalalertsNotInfocom($task = NULL)
 {
     global $DB, $CFG_GLPI;
     if (!$CFG_GLPI["use_mailing"]) {
         return 0;
     }
     $CronTask = new CronTask();
     if ($CronTask->getFromDBbyName("PluginAdditionalalertsInfocomAlert", "AdditionalalertsNotInfocom")) {
         if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
             return 0;
         }
     } else {
         return 0;
     }
     $message = array();
     $cron_status = 0;
     foreach (self::getEntitiesToNotify('use_infocom_alert') as $entity => $repeat) {
         $query_notinfocom = self::query($entity);
         $notinfocom_infos = array();
         $notinfocom_messages = array();
         $type = Alert::END;
         $notinfocom_infos[$type] = array();
         foreach ($DB->request($query_notinfocom) as $data) {
             $entity = $data['entities_id'];
             $message = $data["name"];
             $notinfocom_infos[$type][$entity][] = $data;
             if (!isset($notinfocoms_infos[$type][$entity])) {
                 $notinfocom_messages[$type][$entity] = PluginAdditionalalertsInfocomAlert::getTypeName(2) . "<br />";
             }
             $notinfocom_messages[$type][$entity] .= $message;
         }
         foreach ($notinfocom_infos[$type] as $entity => $notinfocoms) {
             Plugin::loadLang('additionalalerts');
             if (NotificationEvent::raiseEvent("notinfocom", new PluginAdditionalalertsInfocomAlert(), array('entities_id' => $entity, 'notinfocoms' => $notinfocoms))) {
                 $message = $notinfocom_messages[$type][$entity];
                 $cron_status = 1;
                 if ($task) {
                     $task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ":  {$message}\n");
                     $task->addVolume(1);
                 } else {
                     Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ":  {$message}");
                 }
             } else {
                 if ($task) {
                     $task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ":  Send infocoms alert failed\n");
                 } else {
                     Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ":  Send infocoms alert failed", false, ERROR);
                 }
             }
         }
     }
     return $cron_status;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:59,代码来源:infocomalert.class.php

示例10: plugin_ocsinventoryng_uninstall

/**
 * @return bool
 */
function plugin_ocsinventoryng_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/menu.class.php";
    $tables = array("glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_threads", "glpi_plugin_ocsinventoryng_snmpocslinks", "glpi_plugin_ocsinventoryng_ipdiscoverocslinks", "glpi_plugin_ocsinventoryng_servers", "glpi_plugin_ocsinventoryng_configs", "glpi_plugin_ocsinventoryng_notimportedcomputers", "glpi_plugin_ocsinventoryng_details", "glpi_plugin_ocsinventoryng_registrykeys", "glpi_plugin_ocsinventoryng_networkports", "glpi_plugin_ocsinventoryng_networkporttypes", "glpi_plugin_ocsinventoryng_ocsservers_profiles", "glpi_plugin_ocsinventoryng_devicebiosdatas", "glpi_plugin_ocsinventoryng_items_devicebiosdatas");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_bookmarks", "glpi_displaypreferences", "glpi_logs");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE\r\n                  FROM `" . $table_glpi . "`\r\n                  WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n                                       'PluginMassocsimportDetail',\r\n                                       'PluginOcsinventoryngOcsServer',\r\n                                       'PluginOcsinventoryngNotimportedcomputer',\r\n                                       'PluginOcsinventoryngDetail')");
    }
    $tables_ocs = array("ocs_glpi_crontasks", "ocs_glpi_displaypreferences", "ocs_glpi_ocsadmininfoslinks", "ocs_glpi_ocslinks", "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles");
    foreach ($tables_ocs as $table_ocs) {
        $DB->query("DROP TABLE IF EXISTS `{$table_ocs}`;");
    }
    $tables_mass = array("backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", "backup_glpi_plugin_massocsimport_notimported", "backup_glpi_plugin_massocsimport_servers", "backup_glpi_plugin_massocsimport_threads");
    foreach ($tables_mass as $table_mass) {
        $DB->query("DROP TABLE IF EXISTS `{$table_mass}`;");
    }
    $query = "DELETE\r\n             FROM `glpi_alerts`\r\n             WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n                                  'PluginOcsinventoryngNotimportedcomputer')";
    $DB->queryOrDie($query, $DB->error());
    // clean rules
    $rule = new RuleImportEntity();
    foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity')) as $data) {
        $rule->delete($data);
    }
    $rule = new RuleImportComputer();
    foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportComputer')) as $data) {
        $rule->delete($data);
    }
    $notification = new Notification();
    foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $notification->delete($data);
    }
    $template = new NotificationTemplate();
    foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $template->delete($data);
    }
    $cron = new CronTask();
    if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) {
        CronTask::Unregister('massocsimport');
        CronTask::Unregister('CleanOldThreads');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) {
        CronTask::Unregister('ocsinventoryng');
        CronTask::Unregister('ocsng');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) {
        CronTask::Unregister('SendAlerts');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) {
        CronTask::Unregister('CleanOldAgents');
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginOcsinventoryngProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginOcsinventoryngMenu::removeRightsFromSession();
    PluginOcsinventoryngProfile::removeRightsFromSession();
    return true;
}
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:67,代码来源:hook.php

示例11: displayAlerts

 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>";
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:additionalalert.class.php

示例12: pluginMonitoringUpdate


//.........这里部分代码省略.........
    $newTable = "glpi_plugin_monitoring_tags";
    if (!TableExists($newTable)) {
        $query = "CREATE TABLE `" . $newTable . "` (\n                        `id` int(11) NOT NULL AUTO_INCREMENT,\n                        PRIMARY KEY (`id`)\n                     ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query);
    }
    $migration->addField($newTable, 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
    $migration->addField($newTable, 'ip', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
    $migration->addField($newTable, 'username', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
    $migration->addField($newTable, 'password', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
    $migration->migrationOneTable($newTable);
    /*
     * Table Delete old table not used
     */
    if (TableExists("glpi_plugin_monitoring_servicesuggests")) {
        $DB->query("DROP TABLE `glpi_plugin_monitoring_servicesuggests`");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
    }
    $query = "SELECT * FROM `glpi_calendars`\n      WHERE `name`='24x7'\n      LIMIT 1";
    $result = $DB->query($query);
    if ($DB->numrows($result) == 0) {
        $calendar = new Calendar();
        $input = array();
        $input['name'] = '24x7';
        $input['is_recursive'] = 1;
        $calendars_id = $calendar->add($input);
        $calendarSegment = new CalendarSegment();
        $input = array();
        $input['calendars_id'] = $calendars_id;
        $input['is_recursive'] = 1;
        $input['begin'] = '00:00:00';
        $input['end'] = '24:00:00';
        $input['day'] = '0';
        $calendarSegment->add($input);
        $input['day'] = '1';
        $calendarSegment->add($input);
        $input['day'] = '2';
        $calendarSegment->add($input);
        $input['day'] = '3';
        $calendarSegment->add($input);
        $input['day'] = '4';
        $calendarSegment->add($input);
        $input['day'] = '5';
        $calendarSegment->add($input);
        $input['day'] = '6';
        $calendarSegment->add($input);
    }
    $crontask = new CronTask();
    if (!$crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd')) {
        CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringLog', 'cleanlogs')) {
        CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility')) {
        CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringDisplayview_rule', 'replayallviewrules')) {
        CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    /*
     * Clean services not have host
     */
    $query = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n      LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n         ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` = `plugin_monitoring_componentscatalogs_hosts_id`\n   WHERE `is_static` IS NULL";
    $result = $DB->query($query);
    while ($data = $DB->fetch_array($result)) {
        $queryd = "DELETE FROM `glpi_plugin_monitoring_services`\n         WHERE `id`='" . $data['id'] . "'";
        $DB->query($queryd);
    }
    include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php";
    $pmHostconfig = new PluginMonitoringHostconfig();
    $pmHostconfig->initConfig();
    include GLPI_ROOT . "/plugins/monitoring/inc/host.class.php";
    $pmHost = new PluginMonitoringHost();
    $pmHost->verifyHosts();
    if ($insertrealm == '1') {
        // Insert into hostconfigs
        $query = "UPDATE `glpi_plugin_monitoring_hostconfigs` \n         SET `plugin_monitoring_realms_id` = '1'\n         WHERE `items_id` = '0'\n            AND `itemtype` = 'Entity'";
        $DB->query($query);
    }
    include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php";
    $pmConfig = new PluginMonitoringConfig();
    $pmConfig->initConfig();
    // * Recalculate unavaibility
    if ($unavaibility_recalculate == 1) {
        $query = "SELECT * FROM `glpi_plugin_monitoring_unavaibilities`\n            WHERE `end_date` IS NOT NULL";
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $time = strtotime($data['end_date']) - strtotime($data['begin_date']);
            $queryd = "UPDATE `glpi_plugin_monitoring_unavaibilities`\n               SET `duration`='" . $time . "'\n               WHERE `id`='" . $data['id'] . "'";
            $DB->query($queryd);
        }
    }
    $query = "UPDATE `glpi_plugin_monitoring_configs`\n      SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n         WHERE `id`='1'";
    $DB->query($query);
}
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:update.php

示例13: showProcesses

 /**
  * @param $target
  **/
 function showProcesses($target)
 {
     global $DB, $CFG_GLPI;
     $canedit = plugin_ocsinventoryng_haveRight("ocsng", "w");
     $config = new PluginOcsinventoryngConfig();
     $config->getFromDB(1);
     $minfreq = 9999;
     $task = new CronTask();
     if ($task->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) {
         //First of all, deleted old processes
         $this->deleteOldProcesses($task->fields['param']);
         if ($task->fields['param'] > 0) {
             $minfreq = $task->fields['param'];
         }
     }
     $imported_number = new PluginOcsinventoryngMiniStat();
     $synchronized_number = new PluginOcsinventoryngMiniStat();
     $linked_number = new PluginOcsinventoryngMiniStat();
     $failed_number = new PluginOcsinventoryngMiniStat();
     $notupdated_number = new PluginOcsinventoryngMiniStat();
     $notunique_number = new PluginOcsinventoryngMiniStat();
     $linkedrefused_number = new PluginOcsinventoryngMiniStat();
     $process_time = new PluginOcsinventoryngMiniStat();
     $sql = "SELECT `id`, `processid`, SUM(`total_number_machines`) AS total_machines,\n                     `plugin_ocsinventoryng_ocsservers_id`, `status`, COUNT(*) AS threads_number,\n                     MIN(`start_time`) AS starting_date, MAX(`end_time`) AS ending_date,\n                     TIME_TO_SEC(MAX(`end_time`)) - TIME_TO_SEC(MIN(`start_time`)) AS duree,\n                     SUM(`imported_machines_number`) AS imported_machines,\n                     SUM(`synchronized_machines_number`) AS synchronized_machines,\n                     SUM(`linked_machines_number`) AS linked_machines,\n                     SUM(`failed_rules_machines_number`) AS failed_rules_machines,\n                     SUM(`notupdated_machines_number`) AS notupdated_machines,\n                     SUM(`not_unique_machines_number`) AS not_unique_machines_number,\n                     SUM(`link_refused_machines_number`) AS link_refused_machines_number,\n                     `end_time` >= DATE_ADD(NOW(), INTERVAL - " . $minfreq . " HOUR) AS DoStat\n              FROM `" . $this->getTable() . "`\n              GROUP BY `processid`\n              ORDER BY `id` DESC";
     $result = $DB->query($sql);
     echo "<div class='center'>";
     echo "<form name='processes' id='processes' action='{$target}' method='post'>";
     echo "<table class='tab_cadrehov'>";
     echo "<tr><th colspan='16'>" . __('Processes execution of automatic actions', 'ocsinventoryng') . "</th></tr>";
     echo "<tr>";
     echo "<th>&nbsp;</th>";
     echo "<th>&nbsp;</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "<th>" . __('Number of threads', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Beginning date of execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Ending date of execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers imported by automatic actions', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers synchronized', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers linked', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not imported by automatic actions', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not updated', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not unique', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers refused', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Process time execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Server') . "</th>";
     echo "<th>&nbsp;</th>";
     echo "</th></tr>\n";
     if ($DB->numrows($result)) {
         while ($thread = $DB->fetch_array($result)) {
             if ($config->fields["is_displayempty"] || $thread["status"] != PLUGIN_OCSINVENTORYNG_STATE_FINISHED || !$config->fields["is_displayempty"] && $thread["total_machines"] > 0 && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                 if ($thread["DoStat"] && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                     $imported_number->AddValue($thread["imported_machines"]);
                     $synchronized_number->AddValue($thread["synchronized_machines"]);
                     $linked_number->AddValue($thread["linked_machines"]);
                     $failed_number->AddValue($thread["failed_rules_machines"]);
                     $notupdated_number->AddValue($thread["notupdated_machines"]);
                     $notunique_number->AddValue($thread["not_unique_machines_number"]);
                     $linkedrefused_number->AddValue($thread["link_refused_machines_number"]);
                     $process_time->AddValue($thread["duree"]);
                 } else {
                     if ($imported_number->GetCount() > 0) {
                         $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time);
                         $imported_number->Reset();
                     }
                 }
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10'>";
                 if ($canedit) {
                     echo "<input type='checkbox' name='item[" . $thread["processid"] . "]' value='1'>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 echo "<td class='center'>";
                 echo "<a href=\"./thread.form.php?pid=" . $thread["processid"] . "\">" . $thread["processid"] . "</a></td>";
                 echo "<td class='center'>";
                 $this->displayProcessStatusIcon($this->getProcessStatus($thread["processid"]));
                 echo "</td>";
                 echo "<td class='center'>" . $thread["threads_number"] . "</td>";
                 echo "<td class='center'>" . Html::convDateTime($thread["starting_date"]) . "</td>";
                 echo "<td class='center'>" . Html::convDateTime($thread["ending_date"]) . "</td>";
                 echo "<td class='center'>" . $thread["imported_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["synchronized_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["linked_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["failed_rules_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["notupdated_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["not_unique_machines_number"] . "</td>";
                 echo "<td class='center'>" . $thread["link_refused_machines_number"] . "</td>";
                 echo "<td class='center'>";
                 if ($thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                     echo Html::timestampToString($thread["duree"]);
                 } else {
                     echo Dropdown::EMPTY_VALUE;
                 }
                 echo "</td>";
                 echo "<td class='center'>";
                 if ($thread["plugin_ocsinventoryng_ocsservers_id"] != -1) {
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:thread.class.php

示例14: pluginMonitoringUpdate


//.........这里部分代码省略.........
    }
    // Update calendars
    $query = "SELECT * FROM `glpi_calendars`\n      WHERE `name`='24x7'\n      LIMIT 1";
    $result = $DB->query($query);
    if ($DB->numrows($result) == 0) {
        $calendar = new Calendar();
        $input = array();
        $input['name'] = '24x7';
        $input['is_recursive'] = 1;
        $calendars_id = $calendar->add($input);
        $calendarSegment = new CalendarSegment();
        $input = array();
        $input['calendars_id'] = $calendars_id;
        $input['is_recursive'] = 1;
        $input['begin'] = '00:00:00';
        $input['end'] = '24:00:00';
        $input['day'] = '0';
        $calendarSegment->add($input);
        $input['day'] = '1';
        $calendarSegment->add($input);
        $input['day'] = '2';
        $calendarSegment->add($input);
        $input['day'] = '3';
        $calendarSegment->add($input);
        $input['day'] = '4';
        $calendarSegment->add($input);
        $input['day'] = '5';
        $calendarSegment->add($input);
        $input['day'] = '6';
        $calendarSegment->add($input);
    }
    // Update crontasks
    $crontask = new CronTask();
    if (!$crontask->getFromDBbyName('PluginMonitoringDowntime', 'DowntimesExpired')) {
        CronTask::Register('PluginMonitoringDowntime', 'DowntimesExpired', '3600', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringLog', 'cleanlogs')) {
        CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringUnavailability', 'unavailability')) {
        CronTask::Register('PluginMonitoringUnavailability', 'Unavailability', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if (!$crontask->getFromDBbyName('PluginMonitoringDisplayview_rule', 'replayallviewrules')) {
        CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    }
    if ($crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility')) {
        $crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility');
        $crontask->delete($crontask->fields);
    }
    if ($crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd')) {
        $crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd');
        $crontask->delete($crontask->fields);
    }
    if ($crontask->getFromDBbyName('PluginMonitoringHostdailycounter', 'DailyCounters')) {
        $crontask->getFromDBbyName('PluginMonitoringHostdailycounter', 'DailyCounters');
        $crontask->delete($crontask->fields);
    }
    include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php";
    $pmCommand = new PluginMonitoringCommand();
    $a_list = $pmCommand->find();
    $check_dummy_found = false;
    $restart_shinken_found = false;
    $host_action_found = false;
    foreach ($a_list as $data) {
        if ($data['command_name'] == "check_dummy") {
            $check_dummy_found = true;
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:67,代码来源:update.php

示例15: changeCronTaskStatus

 /**
  * Enable or disable db replication check cron task
  *
  * @param enable of disable cron task (true by default)
  **/
 static function changeCronTaskStatus($enable = true)
 {
     $cron = new CronTask();
     $cron->getFromDBbyName('DBConnection', 'CheckDBreplicate');
     $input['id'] = $cron->fields['id'];
     $input['state'] = $enable ? 1 : 0;
     $cron->update($input);
 }
开发者ID:pvasener,项目名称:glpi,代码行数:13,代码来源:dbconnection.class.php


注:本文中的CronTask::getFromDBbyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。