hehexu

博客园 首页 新随笔 联系 订阅 管理
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;
}
}
posted on 2018-03-25 09:50  hehexu  阅读(144)  评论(0编辑  收藏  举报