本文整理汇总了PHP中CronTask::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CronTask::delete方法的具体用法?PHP CronTask::delete怎么用?PHP CronTask::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CronTask
的用法示例。
在下文中一共展示了CronTask::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pluginFusioninventoryUpdate
//.........这里部分代码省略.........
}
if (TableExists('glpi_plugin_fusioninventory_configs')) {
$id = 'id';
if (FieldExists('glpi_plugin_fusioninventory_configs', 'ID')) {
$id = 'ID';
}
$query = "SELECT * FROM `glpi_plugin_fusioninventory_configs`\n WHERE `type`='version'\n LIMIT 1, 10";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$DB->query("DELETE FROM `glpi_plugin_fusioninventory_configs`\n WHERE `" . $id . "`='" . $data[$id] . "'");
}
}
$a_table = array();
$a_table['name'] = 'glpi_plugin_fusioninventory_configs';
$a_table['oldname'] = array('glpi_plugin_tracker_config');
$a_table['fields'] = array();
$a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
$a_table['fields']['type'] = array('type' => 'string', 'value' => NULL);
$a_table['fields']['value'] = array('type' => 'string', 'value' => NULL);
$a_table['oldfields'] = array();
$a_table['oldfields'][] = 'version';
$a_table['oldfields'][] = 'URL_agent_conf';
$a_table['oldfields'][] = 'ssl_only';
$a_table['oldfields'][] = 'authsnmp';
$a_table['oldfields'][] = 'inventory_frequence';
$a_table['oldfields'][] = 'criteria1_ip';
$a_table['oldfields'][] = 'criteria1_name';
$a_table['oldfields'][] = 'criteria1_serial';
$a_table['oldfields'][] = 'criteria1_macaddr';
$a_table['oldfields'][] = 'criteria2_ip';
$a_table['oldfields'][] = 'criteria2_name';
$a_table['oldfields'][] = 'criteria2_serial';
$a_table['oldfields'][] = 'criteria2_macaddr';
$a_table['oldfields'][] = 'delete_agent_process';
$a_table['oldfields'][] = 'activation_history';
$a_table['oldfields'][] = 'activation_connection';
$a_table['oldfields'][] = 'activation_snmp_computer';
$a_table['oldfields'][] = 'activation_snmp_networking';
$a_table['oldfields'][] = 'activation_snmp_peripheral';
$a_table['oldfields'][] = 'activation_snmp_phone';
$a_table['oldfields'][] = 'activation_snmp_printer';
$a_table['oldfields'][] = 'plugins_id';
$a_table['oldfields'][] = 'module';
$a_table['renamefields'] = array();
$a_table['renamefields']['ID'] = 'id';
$a_table['keys'] = array();
$a_table['keys'][] = array('field' => array("type"), 'name' => 'unicity', 'type' => 'UNIQUE');
$a_table['oldkeys'] = array();
migrateTablesFusionInventory($migration, $a_table);
/*
* Table glpi_plugin_fusioninventory_entities
*/
$a_table = array();
$a_table['name'] = 'glpi_plugin_fusioninventory_entities';
$a_table['oldname'] = array();
$a_table['fields'] = array();
$a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
$a_table['fields']['entities_id'] = array('type' => 'integer', 'value' => NULL);
$a_table['fields']['transfers_id_auto'] = array('type' => 'integer', 'value' => NULL);
$a_table['fields']['agent_base_url'] = array('type' => 'string', 'value' => '');
$a_table['oldfields'] = array();
$a_table['renamefields'] = array();
$a_table['keys'] = array();
$a_table['keys'][] = array('field' => array('entities_id', 'transfers_id_auto'), 'name' => 'entities_id', 'type' => 'INDEX');
$a_table['oldkeys'] = array();
migrateTablesFusionInventory($migration, $a_table);
示例2: 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 '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.computertype##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.operatingsystem##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.state##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.notinfocom.user##</span></td>\n </tr>\n ##FOREACHnotinfocoms## \n <tr>\n <td><a href=\"##notinfocom.urlname##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.name##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.computertype##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.operatingsystem##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.state##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.location##</span></td>\n <td><a href=\"##notinfocom.urluser##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.user##</span></a> / <a href=\"##notinfocom.urlgroup##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.group##</span></a> / <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##notinfocom.contact##</span></td>\n </tr>\n ##ENDFOREACHnotinfocoms##\n </tbody>\n </table>');";
$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 '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.operatingsystem##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.state##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.user##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.lastocsupdate##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.lastupdate##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.ocsmachine.ocsserver##</span></td>\n </tr>\n ##FOREACHocsmachines## \n <tr>\n <td><a href=\"##ocsmachine.urlname##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.name##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.operatingsystem##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.state##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.location##</span></td>\n <td>##IFocsmachine.user##<a href=\"##ocsmachine.urluser##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.user##</span></a> / ##ENDIFocsmachine.user####IFocsmachine.group##<a href=\"##ocsmachine.urlgroup##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.group##</span></a> / ##ENDIFocsmachine.group####IFocsmachine.contact##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.contact####ENDIFocsmachine.contact##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.lastocsupdate##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.lastupdate##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##ocsmachine.ocsserver##</span></td>\n </tr>\n ##ENDFOREACHocsmachines##\n </tbody>\n </table>');";
$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;
}
示例3: Unregister
/**
* Unregister tasks for a plugin (call by glpi after uninstall)
*
* @param $plugin : name of the plugin
*
* @return bool for success
**/
public static function Unregister($plugin)
{
global $DB;
if (empty($plugin)) {
return false;
}
$temp = new CronTask();
$ret = true;
$query = "SELECT *\n FROM `glpi_crontasks`\n WHERE `itemtype` LIKE 'Plugin{$plugin}%'";
$result = $DB->query($query);
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
if (!$temp->delete($data)) {
$ret = false;
}
}
}
return $ret;
}
示例4: pluginMonitoringUpdate
//.........这里部分代码省略.........
$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;
}
if ($data['command_name'] == "restart_shinken") {
$restart_shinken_found = true;
}
if ($data['command_name'] == "host_action") {
$host_action_found = true;
}
}
if (!$host_action_found) {
// Host action command
$pmCommand = new PluginMonitoringCommand();
$input = array();
$input['name'] = "Host action";
$input['command_name'] = "host_action";