/** * Cron action on tasks : UpdateTypology * * @param $task for log, if NULL display * **/ static function cronNotValidated($task = NULL) { global $DB, $CFG_GLPI; if (!$CFG_GLPI["use_mailing"]) { return 0; } $cron_status = 0; $message = array(); $typo = new self(); $query_items = $typo->queryNotValidated(); $querys = array(Alert::END => $query_items); $task_infos = array(); $task_messages = array(); foreach ($querys as $type => $query) { $task_infos[$type] = array(); foreach ($DB->request($query) as $data) { $entity = $data['entities_id']; $message = $data["name"] . ": " . $data["error"] . "<br>\n"; $task_infos[$type][$entity][] = $data; if (!isset($tasks_infos[$type][$entity])) { $task_messages[$type][$entity] = __('Elements not match with the typology', 'typology') . "<br />"; } $task_messages[$type][$entity] .= $message; } } foreach ($querys as $type => $query) { foreach ($task_infos[$type] as $entity => $items) { Plugin::loadLang('typology'); $message = $task_messages[$type][$entity]; $cron_status = 1; if (NotificationEvent::raiseEvent("AlertNotValidatedTypology", new PluginTypologyTypology(), array('entities_id' => $entity, 'items' => $items))) { $message = $task_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) . ": {$message}\n"); $task->addVolume(count($items)); } else { Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}"); } } } } return $cron_status; }