private function RefreshLinks() { if ($this->ReadPropertyInteger("LinkSource") == 0) { foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) { if (IPS_GetObject($Child)['ObjectType'] == 6) { IPS_DeleteLink($Child); } } return; } $present = array(); foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) { if (IPS_GetObject($Child)['ObjectType'] == 6) { $present[] = IPS_GetLink($Child)['TargetID']; } } $create = array_diff(IPS_GetChildrenIDs($this->ReadPropertyInteger("LinkSource")), $present); foreach ($create as $Target) { if (IPS_GetObject($Target)["ObjectIsHidden"]) { continue; } $Link = IPS_CreateLink(); IPS_SetParent($Link, $this->InstanceID); IPS_SetName($Link, IPS_GetName($Target)); IPS_SetLinkTargetID($Link, $Target); } }
protected function removeVariableAction($name, $links) { $vid = @$this->GetIDForIdent($name); if ($vid) { // delete links to Variable foreach ($links as $key => $value) { if ($value['TargetID'] === $vid) { IPS_DeleteLink($value['LinkID']); } } $this->DisableAction($name); $this->UnregisterVariable($name); } }
protected function DeleteLink($Ident) { if ($LinkID = @IPS_GetObjectIdByIdent($Ident, $this->InstanceID)) { IPS_DeleteLink($LinkID); } }