Пример #1
0
 /**
  * constructor
  *
  * @throws Exception if $type is not valid
  * @access public
  */
 public function __construct($parentId, $name, $content, $debug = false)
 {
     $this->parentId = $parentId;
     $this->name = $name;
     $this->content = $content;
     $this->debug = $debug;
     $this->id = @IPS_GetScriptIDByName($this->name, $this->parentId);
     //check if event does already exist
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS script {$name}\n";
         }
         $this->id = IPS_CreateScript(0);
         IPS_SetName($this->id, $this->name);
         IPS_SetParent($this->id, $this->parentId);
         IPS_SetScriptContent($this->id, $this->content);
         IPS_SetInfo($this->id, "this script was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
     }
 }
Пример #2
0
function GetOrCreateScript($parent, $ident)
{
    $ObjId = @IPS_GetObjectIDByIdent($ident, $parent);
    if ($ObjId === false) {
        $ObjId = IPS_CreateScript(0);
        IPS_SetParent($ObjId, $parent);
        IPS_SetIdent($ObjId, $ident);
        IPS_SetName($ObjId, $ident);
        IPS_SetScriptContent($ObjId, ScriptContent($ident));
    }
    return $ObjId;
}