コード例 #1
0
 public static function GetCurrentUserName()
 {
     if (UserRights::IsImpersonated()) {
         $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUserFriendlyName(), UserRights::GetUserFriendlyName());
     } else {
         $sUserString = UserRights::GetUserFriendlyName();
     }
     return $sUserString;
 }
コード例 #2
0
 protected function DeleteConnectedNetworkDevice()
 {
     $iNetworkDeviceID = $this->Get('networkdevice_id');
     $iDeviceID = $this->Get('connectableci_id');
     $oDevice = MetaModel::GetObject('ConnectableCI', $this->Get('connectableci_id'));
     $sOQL = "SELECT  lnkConnectableCIToNetworkDevice WHERE connectableci_id = :device AND networkdevice_id = :network AND network_port = :nwport AND device_port = :devport";
     $oConnectionSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('network' => $this->Get('connectableci_id'), 'device' => $this->Get('networkdevice_id'), 'devport' => $this->Get('network_port'), 'nwport' => $this->Get('device_port')));
     $iAlreadyExist = $oConnectionSet->count();
     if (get_class($oDevice) == 'NetworkDevice' && $iAlreadyExist != 0) {
         $oMyChange = MetaModel::NewObject("CMDBChange");
         $oMyChange->Set("date", time());
         if (UserRights::IsImpersonated()) {
             $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUser(), UserRights::GetUser());
         } else {
             $sUserString = UserRights::GetUser();
         }
         $oMyChange->Set("userinfo", $sUserString);
         $iChangeId = $oMyChange->DBInsert();
         $oConnection = $oConnectionSet->Fetch();
         $oConnection->DBDeleteTracked($oMyChange);
     }
 }