Пример #1
0
function CreateCategory($Name, $Ident = '', $ParentID = 0)
{
    global $RootCategoryID;
    echo "CreateCategory: ( {$Name}, {$Ident}, {$ParentID} ) \n";
    if ('' != $Ident) {
        $CatID = @IPS_GetObjectIDByIdent($Ident, $ParentID);
        if (false !== $CatID) {
            $Obj = IPS_GetObject($CatID);
            if (0 == $Obj['ObjectType']) {
                // is category?
                return $CatID;
            }
        }
    }
    $CatID = IPS_CreateCategory();
    IPS_SetName($CatID, $Name);
    IPS_SetIdent($CatID, $Ident);
    if (0 == $ParentID) {
        if (IPS_ObjectExists($RootCategoryID)) {
            $ParentID = $RootCategoryID;
        }
    }
    IPS_SetParent($CatID, $ParentID);
    return $CatID;
}
 protected function HideOrDeaktiv(bool $hidden)
 {
     if ($this->ReadPropertyBoolean("Invert")) {
         $hidden = !$hidden;
     }
     if ($this->ReadPropertyInteger("Target") == 0) {
         echo "Target invalid.";
         return;
     }
     $Target = $this->ReadPropertyInteger("Target");
     if (!IPS_ObjectExists($Target)) {
         echo "Target invalid.";
         return;
     }
     if ($this->ReadPropertyInteger("TargetType") == 0) {
         $this->SetHiddenOrDisabled($Target, $hidden);
     } elseif ($this->ReadPropertyInteger("TargetType") == 1) {
         $Source = $this->ReadPropertyInteger("Source");
         $Childs = IPS_GetChildrenIDs($Target);
         foreach ($Childs as $Child) {
             if ($Child == $Source) {
                 continue;
             }
             if (IPS_GetObject($Child)['ObjectType'] == 6) {
                 if (IPS_GetLink($Child)['TargetID'] == $Source) {
                     continue;
                 }
             }
             $this->SetHiddenOrDisabled($Child, $hidden);
         }
     } else {
         echo "TargetType invalid.";
         return;
     }
 }