Ejemplo n.º 1
0
 public function getResource()
 {
     $objectController = ObjectController::create();
     $objectLogController = ObjectLogController::create();
     //try to get object log
     try {
         $objectId = $this->uri[1];
         $object = $objectController->getObject($objectId, $this->user);
         $objectLogEntries = $objectLogController->getLogEntries($object, 0, 0, $this->user);
         //generate output
         $output = array();
         $output['objectId'] = $objectId;
         $output['logEntries'] = array();
         foreach ($objectLogEntries as $logEntry) {
             $output['logEntries'][] = array('date' => $logEntry->getTimestamp(), 'action' => $logEntry->getAction(), 'description' => $logEntry->getDescription(), 'user' => $logEntry->getUser());
         }
     } catch (Exception $e) {
         return new RestResponse(404);
     }
     return new RestResponse(200, json_encode($output));
 }
Ejemplo n.º 2
0
use yourCMDB\security\AuthorisationProviderLocal;
use yourCMDB\taskscheduler\EventProcessor;
use yourCMDB\info\InfoController;
//define base directories
$webScriptBaseDir = dirname(__FILE__);
$coreBaseDir = realpath("{$webScriptBaseDir}/../../core");
//include yourCMDB bootstrap
include "{$coreBaseDir}/bootstrap.php";
//include function definitions
include "functions.inc.php";
//define variables
$config = CmdbConfig::create();
$accessGroupController = AccessGroupController::create();
$objectController = ObjectController::create();
$objectLinkController = ObjectLinkController::create();
$objectLogController = ObjectLogController::create();
$authorisationProvider = new AuthorisationProviderLocal();
$eventProcessor = new EventProcessor();
$infoController = new InfoController();
//set default values of some variables
$authUser = "";
//get configuration
$installTitle = $config->getViewConfig()->getInstallTitle();
//setup i18n with gettext
$i18nLocale = $config->getViewConfig()->getLocale();
$i18nDomain = "web";
$i18nCodeset = "utf-8";
$i18nBaseDir = realpath("{$webScriptBaseDir}/../../i18n");
setlocale(LC_ALL, $i18nLocale);
bindtextdomain($i18nDomain, $i18nBaseDir);
bind_textdomain_codeset($i18nDomain, $i18nCodeset);
Ejemplo n.º 3
0
 /**
  * Deletes all CmdbObjectLinks for a given CmdbObject
  * @param CmdbObject $object	the CmdbObject
  * @param string $user		name of the user
  * @throws CmdbObjectLinkNotFoundException
  */
 public function deleteObjectLinks($object, $user)
 {
     //get ObjectLogController
     $objectLogController = ObjectLogController::create();
     //find the links
     $links = $this->getObjectLinks($object, $user);
     foreach ($links as $link) {
         //remove the link
         $this->entityManager->remove($link);
         //create log entry
         $objectA = $link->getObjectA();
         $objectB = $link->getObjectB();
         $logString = $objectA->getId() . " <-> " . $objectB->getId();
         $objectLogController->addLogEntry($objectA, "delete link", $logString, $user);
         $objectLogController->addLogEntry($objectB, "delete link", $logString, $user);
     }
     //flush output
     $this->entityManager->flush();
 }
Ejemplo n.º 4
0
 /**
  * Deletes the CmdbObject with the given ID
  * @param int $id	ID of the CmdbObject
  * @param string	$user		name of user that wishes the change
  * @throws CmdbObjectNotFoundException
  */
 public function deleteObject($id, $user)
 {
     //get object and references
     $object = $this->getObject($id, $user);
     $references = $this->getObjectReferences($id, $user);
     //remove object links
     $objectLinkController = ObjectLinkController::create();
     $objectLinkController->deleteObjectLinks($object, $user);
     //remove log entries
     $objectLogController = ObjectLogController::create();
     $objectLogController->deleteLogEntries($object, $user);
     //process event
     $eventProcessor = new EventProcessor();
     $eventProcessor->generateEvent("objectDeleted", $object->getId(), $object->getType());
     //remove the object
     $this->entityManager->remove($object);
     //flush
     $this->entityManager->flush();
     //delete references to object
     foreach ($references as $reference) {
         $this->updateObject($reference->getId(), $reference->getStatus(), array(), $user);
     }
 }