delete CDU

function DeletePDU(){
global $person;
$this->MakeSafe();

// Do not attempt anything else if the lookup fails
if(!$this->GetPDU()){return false;}

// Check rights
$cab=new Cabinet();
$cab->CabinetID=$this->CabinetID;
$cab->GetCabinet();

//person 不具有写权限 ,无法删除设备
if(!$person->canWrite($cab->AssignedTo)){return false;}

// First, remove any connections to the PDU
$tmpConn=new PowerConnection();
$tmpConn->PDUID=$this->PDUID;
$connList=$tmpConn->GetConnectionsByPDU();

foreach($connList as $delConn){
$delConn->RemoveConnection();
}

// Clear out any records from PDUStats, possible S.U.T. involving changing
// a devicetype but leaving behind a phantom reading for a non-power device
$sql="DELETE FROM fac_PDUStats WHERE PDUID=$this->PDUID;";
$this->exec($sql);

$sql="DELETE FROM fac_PowerDistribution WHERE PDUID=$this->PDUID;";
if(!$this->exec($sql)){
// Something went south and this didn't delete.
return false;
}else{
(class_exists('LogActions'))?LogActions::LogThis($this):'';
return true;
}
}
原文地址:https://www.cnblogs.com/hehexu/p/8643096.html