Esempio n. 1
0
 /**
  * creates a new object link controller
  * @return ObjectLinkController	ObjectController instance
  */
 public static function create()
 {
     //check, if an ObjectLinkController instance already exists
     if (ObjectLinkController::$objectLinkController == null) {
         ObjectLinkController::$objectLinkController = new ObjectLinkController();
     }
     return ObjectLinkController::$objectLinkController;
 }
 public function postResource($data)
 {
     $objectController = ObjectController::create();
     $objectLinkController = ObjectLinkController::create();
     try {
         $decodedData = json_decode($data);
         $objectIdB = $decodedData->objectIdB;
         $objectIdA = $this->uri[1];
         $objectA = $objectController->getObject($objectIdA, $this->user);
         $objectB = $objectController->getObject($objectIdB, $this->user);
         $objectLinkController->addObjectLink($objectA, $objectB, $this->user);
     } catch (Exception $e) {
         return new RestResponse(400);
     }
     $url = "rest.php/objectlinks/{$objectIdA}";
     return new RestResponse(201, $url);
 }
Esempio n. 3
0
use yourCMDB\controller\ObjectLogController;
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);
Esempio 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);
     }
 }