コード例 #1
0
function add_library_hf($options)
{
    global $u;
    global $library_messages;
    global $APP;
    if (!isset($options['id_user'])) {
        echo "library add id_user not found!";
        exit;
    }
    if (!isset($options['hf_name'])) {
        echo "library add hf_name not found!";
        exit;
    }
    if (!isset($options['hf_expression'])) {
        echo "library add hf_expression not found!";
        exit;
    }
    if (!isset($options['inheritable'])) {
        echo "library add inheritable not found!";
        exit;
    }
    if (!isset($options['sys_kinds'])) {
        echo "library add sys_kinds not found!";
        exit;
    }
    if (!isset($options['resources'])) {
        echo "library add resources not found!";
        exit;
    }
    if (!isset($options['hf_parameters'])) {
        echo "library add hf_parameters not found!";
        exit;
    }
    $id_user = $options['id_user'];
    $hf_name = $options['hf_name'];
    $hf_expression = $options['hf_expression'];
    $inheritable = $options['inheritable'];
    $sys_kinds = $options['sys_kinds'];
    $resources = $options['resources'];
    $hf_parameters = $options['hf_parameters'];
    $inherit_from = "";
    if (isset($options['inherit_from'])) {
        $inherit_from = $options['inherit_from'];
    }
    $id_mime_type = "undefined";
    if (isset($options['mime'])) {
        $id_mime_type = $options['mime'];
    }
    $retval = "";
    $props = array();
    $props['id_user'] = $id_user;
    $props['id'] = sha1(microtime() . $hf_name . rand(1, 20));
    $retval = $props['id'];
    $props['name'] = $hf_name;
    $props['str_expression'] = $hf_expression;
    // CREATE HIS FUNCTION
    $props['id_condition'] = "perfectly";
    $props['str_cache_out_xml'] = "undefined";
    $props['str_cache_out_cxml'] = "undefined";
    $props['str_cache_approved'] = 'undefined';
    $props['str_cache_latest'] = 'undefined';
    $props['id_mime_type'] = $id_mime_type;
    $props['int_ws'] = "0";
    $props['int_wait'] = "0";
    $props['int_maxruntime'] = "0";
    $props['int_delay'] = "10";
    $new_hf = new hf_id_user();
    $new_hf->create($props);
    // CREATE SYSTEM KINDS
    foreach ($sys_kinds as $hf_sys_kind) {
        echo " ";
        $system_kind_current_id = "";
        // GET THIS SYS KIND FROM USER_SYSTEM_KINDS
        foreach ($u->obj_system_kinds as $user_system_kind) {
            if ($user_system_kind->name == $hf_sys_kind) {
                $system_kind_current_id = $user_system_kind->id;
            }
        }
        // end foreach (system kind name)
        if ($hf_sys_kind == "any") {
            $system_kind_current_id = "any";
        }
        if (strlen($system_kind_current_id) > 0) {
            $props = array();
            $props['id_hf'] = $new_hf->id;
            $props['id'] = sha1(microtime() . $system_kind_current_id . rand(1, 20));
            $props['id_sk'] = $system_kind_current_id;
            $new_hf_sk = new hf_system_kind();
            $new_hf_sk->create($props);
        } else {
            $library_message .= "Unable to find sys kind: {$hf_sys_kind} for function {$hf_name}.\n";
        }
    }
    // end foreach (system kind)
    foreach ($resources as $hf_resource) {
        echo " ";
        // CREATE RESOURCE
        $props = array();
        $props['id_hf'] = $new_hf->id;
        $props['id'] = sha1(microtime() . $hf_resource['content'] . rand(1, 20));
        $props['str_location'] = $hf_resource['content'];
        $props['str_filename'] = $hf_resource['filename'];
        $new_hf_resource = new hf_resource();
        $new_hf_resource->create($props);
        echo " ";
        if (isset($hf_resource['system_kinds'])) {
            foreach ($hf_resource['system_kinds'] as $hfr_system_kind) {
                echo " ";
                $system_kind_current_id = "";
                // GET THIS SYS KIND FROM USER_SYSTEM_KINDS
                foreach ($u->obj_system_kinds as $user_system_kind) {
                    if ($user_system_kind->name == $hfr_system_kind) {
                        $system_kind_current_id = $user_system_kind->id;
                    }
                }
                // end foreach (system kind name)
                if ($hfr_system_kind == "any") {
                    $system_kind_current_id = "any";
                }
                if (strlen($system_kind_current_id) > 0) {
                    $new_hfrsk = new hfr_system_kind();
                    $props = array();
                    $props['id_resource'] = $new_hf_resource->id;
                    $props['id'] = sha1(microtime() . rand(1, 20) . $system_kind_current_id);
                    $props['id_sk'] = $system_kind_current_id;
                    $new_hfrsk->create($props);
                } else {
                    echo "<pre>";
                    print_r($u);
                    echo "LIBRARY ERROR: UNABLE TO FIND SYSTEM KIND ({$hfr_system_kind})";
                    exit;
                }
            }
            // end foreach (system kind)
        }
        // end if (system kinds is set)
    }
    // end if (resource)
    if (strlen($inherit_from) > 0) {
        $props = array();
        $props['id_hf'] = $new_hf->id;
        $props['id'] = sha1(microtime() . rand(1, 20) . rand(2, 30));
        $props['id_inherit'] = $inherit_from;
        $new_hf_inherit = new hf_inherit();
        $new_hf_inherit->create($props);
    }
    // this part makes the function inherit from other functions
    if ($inheritable) {
        $props = array();
        $props['id_user'] = $id_user;
        $props['id_hf'] = $new_hf->id;
        $new_user_inherit = new user_inherit();
        $new_user_inherit->create($props);
    }
    foreach ($hf_parameters as $hf_parameter) {
        echo " ";
        $props = array();
        $props['id_hf'] = $new_hf->id;
        $props['id'] = sha1(microtime() . rand(1, 20) . $hf_parameter['keyword'] . $hf_parameter['parameter_name']);
        $props['keyword'] = $hf_parameter['keyword'];
        $props['parameter_name'] = $hf_parameter['parameter_name'];
        $props['str_default_value'] = $hf_parameter['default_value'];
        $props['int_preserve_encode'] = "0";
        if (isset($hf_parameter['int_preserve_encode'])) {
            if (strtolower($hf_parameter['int_preserve_encode']) == "true") {
                $props['int_preserve_encode'] = "1";
            }
        }
        $new_hf_parameter = new hf_parameter();
        $new_hf_parameter->create($props);
        if (isset($hf_parameter['constraints'])) {
            foreach ($hf_parameter['constraints'] as $hfp_constraint) {
                echo " ";
                $props = array();
                $props['id_hf_parameter'] = $new_hf_parameter->id;
                $props['id'] = sha1(microtime() . rand(1, 20) . $hfp_constraint['constraint_type'] . $hfp_constraint['constraint_text']);
                $props['id_constraint_type'] = $hfp_constraint['constraint_type'];
                $props['str_constraint_text'] = $hfp_constraint['constraint_text'];
                $new_hfp_vcs = new hfp_vcs();
                $new_hfp_vcs->create($props);
                //usleep(10);
            }
            // end foreach
        }
        //usleep(10);
    }
    // end foreach
    usleep(10);
    return $retval;
}
コード例 #2
0
ファイル: model.classes.php プロジェクト: hisapi/his
 public function build($obj_build_exclude = array(), $do_substitutions = true)
 {
     if ($this->obj_debug) {
         echo "building parent HF_ID_USER...\n";
     }
     parent::build($obj_build_exclude);
     if ($this->obj_debug) {
         echo "finished building parent...\n";
     }
     if (!isset($this->obj_expression)) {
         //echo "SETTING EXPRESSION";
         $this->obj_expression = new strings();
     }
     $this->obj_hf_inherit = array();
     $this->obj_hf_parameters = array();
     $this->obj_hf_node_filters = array();
     $this->obj_hf_tags = array();
     $this->obj_hf_outputs = array();
     $this->obj_hf_files = array();
     $this->obj_hf_kill = array();
     $this->obj_hf_resources = array();
     $this->obj_hf_system_kind = array();
     // MANY TO 1 RELATIONSHIPS
     if ($this->obj_debug) {
         echo "hf inherits...\n";
     }
     $hf_inherit = new hf_inherit();
     $all_hf_inherit = $hf_inherit->get_from_hashrange($this->id);
     if ($all_hf_inherit && !in_array("obj_hf_inherit", $obj_build_exclude)) {
         foreach ($all_hf_inherit as $each_hf_inherit) {
             $a_hf_inherit = new hf_inherit();
             $a_hf_inherit->set($each_hf_inherit);
             $a_hf_inherit->build();
             $this->obj_hf_inherit[] = $a_hf_inherit;
         }
     }
     if ($this->obj_debug) {
         echo "hf parameters...\n";
     }
     $hf_parameter = new hf_parameter();
     $all_hf_parameters = $hf_parameter->get_from_hashrange($this->id);
     if ($all_hf_parameters && !in_array("obj_hf_parameters", $obj_build_exclude)) {
         foreach ($all_hf_parameters as $each_hf_parameter) {
             $a_hf_parameter = new hf_parameter();
             $a_hf_parameter->set($each_hf_parameter);
             $a_hf_parameter->build();
             $this->obj_hf_parameters[] = $a_hf_parameter;
         }
         foreach ($this->obj_hf_parameters as &$a_hf_parameter) {
             $a_hf_parameter->merge($this->obj_hf_parameters);
         }
     }
     if ($this->obj_debug) {
         echo "hf resource...\n";
     }
     $hf_resource = new hf_resource();
     $all_hf_resource = $hf_resource->get_from_hashrange($this->id);
     if ($all_hf_resource && !in_array("obj_hf_resources", $obj_build_exclude)) {
         foreach ($all_hf_resource as $each_hf_resource) {
             $a_hf_resource = new hf_resource();
             $a_hf_resource->set($each_hf_resource);
             $a_hf_resource->build();
             $a_hf_resource->subs = $this->name;
             $this->obj_hf_resources[] = $a_hf_resource;
         }
     }
     if ($do_substitutions) {
         $this->int_maxruntime_value = replace_hf_parameters($this->int_maxruntime, $this->obj_hf_parameters);
     } else {
         $this->int_maxruntime_value = $this->int_maxruntime;
     }
     if ($this->obj_debug) {
         echo "hf node filters...\n";
     }
     $hf_node_filter = new hf_node_filter();
     $all_hf_node_filters = $hf_node_filter->get_from_hashrange($this->id);
     if ($all_hf_node_filters && !in_array("obj_hf_node_filters", $obj_build_exclude)) {
         foreach ($all_hf_node_filters as $each_hf_node_filter) {
             $a_hf_node_filter = new hf_node_filter();
             $a_hf_node_filter->set($each_hf_node_filter);
             $a_hf_node_filter->build();
             $this->obj_hf_node_filters[] = $a_hf_node_filter;
         }
     }
     foreach ($this->obj_hf_node_filters as &$a_hf_node_filter) {
         if ($do_substitutions) {
             $a_hf_node_filter->value = replace_hf_parameters($a_hf_node_filter->obj_filter->body, $this->obj_hf_parameters);
         } else {
             $a_hf_node_filter->value = $a_hf_node_filter->obj_filter->body;
         }
     }
     if ($this->obj_debug) {
         echo "hf tags...\n";
     }
     $hf_tag = new hf_tag();
     $all_hf_tags = $hf_tag->get_from_hashrange($this->id);
     if ($all_hf_tags && !in_array("obj_hf_tags", $obj_build_exclude)) {
         foreach ($all_hf_tags as $each_hf_tag) {
             $a_hf_tag = new hf_tag();
             $a_hf_tag->set($each_hf_tag);
             $a_hf_tag->build();
             $this->obj_hf_tags[] = $a_hf_tag;
         }
     }
     if ($this->obj_debug) {
         echo "hf file...\n";
     }
     $hf_file = new hf_file();
     $all_hf_files = $hf_file->get_from_hashrange($this->id);
     if ($all_hf_files && !in_array("obj_hf_files", $obj_build_exclude)) {
         foreach ($all_hf_files as $each_hf_file) {
             $a_hf_file = new hf_file();
             $a_hf_file->set($each_hf_file);
             $a_hf_file->build();
             $this->obj_hf_files[] = $a_hf_file;
         }
     }
     foreach ($this->obj_hf_files as &$a_hf_file) {
         if ($do_substitutions) {
             $a_hf_file->value = replace_hf_parameters($a_hf_file->obj_targetfile->body, $this->obj_hf_parameters);
         } else {
             $a_hf_file->value = $a_hf_file->obj_targetfile->body;
         }
     }
     if ($this->obj_debug) {
         echo "hf kill...\n";
     }
     $hf_kill = new hf_kill();
     $all_hf_kill = $hf_kill->get_from_hashrange($this->id);
     if ($all_hf_kill && !in_array("obj_hf_kill", $obj_build_exclude)) {
         foreach ($all_hf_kill as $each_hf_kill) {
             $a_hf_kill = new hf_kill();
             $a_hf_kill->set($each_hf_kill);
             $a_hf_kill->build();
             $this->obj_hf_kill[] = $a_hf_kill;
         }
     }
     foreach ($this->obj_hf_kill as &$a_hf_kill) {
         if ($do_substitutions) {
             $a_hf_kill->value = replace_hf_parameters($a_hf_kill->obj_name->body, $this->obj_hf_parameters);
         } else {
             $a_hf_kill->value = $a_hf_kill->obj_name->body;
         }
     }
     foreach ($this->obj_hf_resources as &$a_hf_resource) {
         if ($do_substitutions) {
             $a_hf_resource->value_location = replace_hf_parameters($a_hf_resource->obj_location->body, $this->obj_hf_parameters);
             $a_hf_resource->value_filename = replace_hf_parameters($a_hf_resource->obj_filename->body, $this->obj_hf_parameters);
         } else {
             $a_hf_resource->value_location = $a_hf_resource->obj_location->body;
             $a_hf_resource->value_filename = $a_hf_resource->obj_filename->body;
         }
     }
     if ($this->obj_debug) {
         echo "hf system kinds...\n";
     }
     $hf_system_kind = new hf_system_kind();
     $all_hf_system_kind = $hf_system_kind->get_from_hashrange($this->id);
     if ($all_hf_system_kind && !in_array("obj_hf_system_kind", $obj_build_exclude)) {
         foreach ($all_hf_system_kind as $each_hf_system_kind) {
             $a_hf_system_kind = new hf_system_kind();
             $a_hf_system_kind->set($each_hf_system_kind);
             $a_hf_system_kind->build();
             $this->obj_hf_system_kind[] = $a_hf_system_kind;
         }
     }
     if ($this->obj_debug) {
         echo "hf assimilation...\n";
     }
     // ASSIMILATE PARENT INHERITANCE
     foreach ($this->obj_hf_inherit as $hf_inherit) {
         // RECURSIVELY ASSIMILATE THE PARENT FUNCTION
         $hf_inherit->assimilate($this, $obj_build_exclude);
     }
     $local_sk_found = false;
     foreach ($this->obj_hf_system_kind as &$tsk) {
         if ($tsk->id_hf == $this->id) {
             $local_sk_found = true;
             break;
         }
     }
     if ($local_sk_found) {
         foreach ($this->obj_hf_system_kind as &$tsk) {
             if ($tsk->id_hf != $this->id) {
                 $tsk->obj_enabled = false;
             }
         }
     }
     /*
     if ($do_substitutions)
     {
     echo "<pre>";
     print_r($this);
     }
     */
     $this->obj_bool_inheritable = false;
     $hf_inheritable = new user_inherit();
     $hf_inheritable->get_from_hashrange($this->id_user, $this->id);
     if ($hf_inheritable->id_user != "undefined") {
         $this->obj_bool_inheritable = true;
     }
     // BUILD RECURSIVE EXPRESSION TREE
     if ($this->obj_debug) {
         echo "building hash expression tree";
     }
     $this->hash_to_expression_tree($this->str_expression, $do_substitutions);
     if (isset($this->obj_hf_parameters)) {
         if ($this->obj_debug) {
             echo "merging expressions";
         }
         if (isset($this->obj_expression) && !is_bool($this->obj_expression) && get_class($this->obj_expression) == "strings") {
             $this->obj_expression->merge($this->obj_hf_parameters);
         }
     }
     if ($this->obj_debug) {
         echo "finished building function";
     }
 }
コード例 #3
0
// end if action
if (isset($_GET['action'])) {
    if ($_GET['action'] == "regather-latest-cache") {
        if (isset($_POST['refresh_cache'])) {
            //print_r($_POST);
        }
    }
}
// end if action
if (isset($_GET['action'])) {
    if ($_GET['action'] == "update-input-resource-type") {
        if (isset($_POST['id_hf_resource']) && isset($_POST['new_hf_resource_type'])) {
            $this_hf = new hf_id_user();
            $this_hf->get_from_hashrange($u->id_user, $_GET['q']);
            if ($this_hf->id_hf_resource == $_POST['id_hf_resource']) {
                $this_hf_resource = new hf_resource();
                $this_hf_resource->get_from_hashrange($_POST['id_hf_resource']);
                $new_props = array();
                $new_props['id_type'] = $_POST['new_hf_resource_type'];
                $this_hf_resource->update_raw($new_props);
            }
        }
        // isset
    }
    // action
}
// end if action
if (isset($_GET['action'])) {
    if ($_GET['action'] == "edit-output-method") {
        if (isset($_POST['id_hf']) && isset($_POST['id_output_type']) && isset($_POST['str_output_expression'])) {
            $qid_val = $_POST['id_hf'];