public function uploadEvidenceFile(IncidentInterface $incident) { // if (null === $incident->getEvidenceFile()) { // return; // } // if there is an error when moving the file, an exception will // be automatically thrown by move(). This will properly prevent // the entity from being persisted to the database on error $uploadDir = $this->getUploadDirectory() . $incident->getEvidenceSubDirectory(); if (!file_exists($uploadDir)) { if (!mkdir($uploadDir, 0777, true)) { die('Failed to create folders...'); } } if ($incident->getEvidenceFile()) { $incident->getEvidenceFile()->move($uploadDir, $incident->getEvidenceFilePath()); } // check if we have an old image // if ($incident->getEvidenceFileTemp()) { // // delete the old image // unlink($this->getUploadDirectory() . $incident->getEvidenceFileTemp()); // // clear the temp image path // $incident->setEvidenceFileTemp(null); // } }
public function send_report(IncidentInterface $incident, $body = null, $echo = null, $is_new_incident = FAlSE) { if (!$echo) { if ($incident->getSendReport() || $is_new_incident) { $html = $this->getBody($incident); $text = strip_tags($this->getBody($incident, 'txt')); $message = \Swift_Message::newInstance()->setSubject(sprintf($this->environment . '[CERTunlp] Incidente de tipo "%s" en el host %s [ID:%s]', $incident->getType()->getName(), $incident->getHostAddress(), $incident->getId()))->setFrom($this->cert_email)->setCc($this->cert_email)->setTo($incident->getNetworkAdmin()->getEmail())->setBody($text)->addPart($html, 'text/html'); if ($incident->getEvidenceFilePath()) { $message->attach(\Swift_Attachment::fromPath($this->upload_directory . $incident->getEvidenceFilePath(true))); } if ($incident->getReportMessageId()) { $message->setId($incident->getReportMessageId()); } $this->mailer->send($message); } } else { $html = $this->getBody($incident); echo $html; } }
public function updateIssue(IncidentInterface $incident) { $this->getClient()->setImpersonateUser($incident->getReporter()->getUsername()); $this->getClient()->api('issue')->setIssueStatus($incident->getRedmineIssueId(), $incident->getState()->getName()); $this->getClient()->setImpersonateUser(null); }