Пример #1
0
/**
 * Registering Functions
 */
function register_project($include_id)
{
    if (Item::delete_holder_by_include_id($include_id)) {
        if (Item::register_holder("project", "Project", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (Folder::delete_type_by_include_id($include_id)) {
        if (Folder::register_type("project_folder", "ProjectFolder", $include_id) == false) {
            return false;
        }
        if (Folder::register_type("project_status_folder", "ProjectStatusFolder", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (ValueVar::delete_by_include_id($include_id)) {
        if (ValueVar::register_type("project", "ProjectValueVar", false, $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (!Registry::is_value("project_user_default_quota")) {
        $registry = new Registry(null);
        $registry->create("project_user_default_quota", $include_id, "1073741824");
    }
    if (!Registry::is_value("project_user_default_permission")) {
        $registry = new Registry(null);
        $registry->create("project_user_default_permission", $include_id, "15");
    }
    if (!Registry::is_value("project_leader_default_permission")) {
        $registry = new Registry(null);
        $registry->create("project_leader_default_permission", $include_id, "51");
    }
    if (!Registry::is_value("project_quality_manager_default_permission")) {
        $registry = new Registry(null);
        $registry->create("project_quality_manager_default_permission", $include_id, "1");
    }
    if (!Registry::is_value("project_group_default_permission")) {
        $registry = new Registry(null);
        $registry->create("project_group_default_permission", $include_id, "1");
    }
    if (!Registry::is_value("project_organisation_unit_default_permission")) {
        $registry = new Registry(null);
        $registry->create("project_organisation_unit_default_permission", $include_id, "1");
    }
    return true;
}
Пример #2
0
/**
 * Registering Functions
 */
function register_data($include_id)
{
    if (Item::delete_type_by_include_id($include_id)) {
        if (Item::register_type("file", "DataEntity", $include_id) == false or Item::register_type("value", "DataEntity", $include_id) == false or Item::register_type("parameter", "DataEntity", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (Folder::delete_type_by_include_id($include_id)) {
        if (Folder::register_type("system_folder", "SystemFolder", $include_id) == false) {
            return false;
        }
        if (Folder::register_type("user_folder", "UserFolder", $include_id) == false) {
            return false;
        }
        if (Folder::register_type("group_folder", "GroupFolder", $include_id) == false) {
            return false;
        }
        if (Folder::register_type("organisation_unit_folder", "OrganisationUnitFolder", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (ValueVar::delete_by_include_id($include_id)) {
        if (ValueVar::register_type("item", "ItemValueVar", true, $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (!Registry::is_value("data_user_default_quota")) {
        $registry = new Registry(null);
        $registry->create("data_user_default_quota", $include_id, "53687091200");
    }
    if (!Registry::is_value("data_quota_warning")) {
        $registry = new Registry(null);
        $registry->create("data_quota_warning", $include_id, "90");
    }
    if (!Registry::is_value("data_max_cached_images")) {
        $registry = new Registry(null);
        $registry->create("data_max_cached_images", $include_id, "100000");
    }
    if (!Registry::is_value("data_max_cache_period")) {
        $registry = new Registry(null);
        $registry->create("data_max_cache_period", $include_id, "30");
    }
    return true;
}
Пример #3
0
/**
 * Registering Functions
 */
function register_sample($include_id)
{
    if (Item::delete_holder_by_include_id($include_id)) {
        if (Item::register_holder("sample", "Sample", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (Item::delete_type_by_include_id($include_id)) {
        if (Item::register_type("sample", "Sample", $include_id) == false) {
            return false;
        }
        if (Item::register_type("parentsample", "Sample", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (Folder::delete_type_by_include_id($include_id)) {
        if (Folder::register_type("sample_folder", "SampleFolder", $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (ValueVar::delete_by_include_id($include_id)) {
        if (ValueVar::register_type("sample", "SampleValueVar", false, $include_id) == false) {
            return false;
        }
    } else {
        return false;
    }
    if (!Registry::is_value("sample_default_expiry_warning")) {
        $registry = new Registry(null);
        $registry->create("sample_default_expiry_warning", $include_id, "7");
    }
    return true;
}
Пример #4
0
 /**
  * @see ValueInterface::get_value_shape()
  * @return array
  */
 public function get_value_shape($value_type_id = null, $folder_id = null)
 {
     if ($this->value and $this->value_id or is_numeric($value_type_id)) {
         if ($folder_id == null and $this->value_id) {
             $folder_id = $this->get_parent_folder_id();
         }
         if (is_numeric($value_type_id)) {
             $value_type = new ValueType($value_type_id);
         } else {
             $value_type = new ValueType($this->value->get_type_id());
         }
         $olvdl = new Olvdl($value_type->get_template_id());
         $xml_array = $olvdl->get_xml_array();
         $return_array = array();
         $format_counter = 0;
         if ($this->array_contains_each_statements($xml_array)) {
             $xml_array = $this->resolve_each_statements($xml_array, $folder_id);
         }
         if (is_array($xml_array) and count($xml_array) >= 1) {
             foreach ($xml_array as $key => $value) {
                 $value[0] = trim(strtolower($value[0]));
                 $value[1] = trim(strtolower($value[1]));
                 $value[2] = trim(strtolower($value[2]));
                 if ($value[1] == "format" and $value[2] != "#") {
                     $in_format = true;
                     $line_counter = 0;
                     $format_max_column = 0;
                     $return_array[$format_counter] = array();
                     $return_array[$format_counter]['type'] = "format";
                     if ($value[3]['colspan']) {
                         $colspan_array = array();
                         $colspan_array = explode(",", $value[3]['colspan']);
                         $colspan_array_count = 0;
                     }
                 }
                 if ($value[1] == "format" and $value[2] == "#") {
                     if ($in_format == true) {
                         $return_array[$format_counter]['max_column'] = $format_max_column;
                         $in_format = false;
                         $format_counter++;
                         $element_counter = 0;
                         if ($colspan_array) {
                             unset($colspan_array);
                             unset($colspan_array_count);
                         }
                     }
                 }
                 if ($value[1] == "line" and $value[2] != "#") {
                     if ($in_format == true) {
                         $in_line = true;
                         $element_counter = 0;
                         $line_max_column = 0;
                         $return_array[$format_counter][$line_counter] = array();
                         $return_array[$format_counter][$line_counter]['type'] = "line";
                         if ($value[3]['colspan']) {
                             $colspan_array = array();
                             $colspan_array = explode(",", $value[3]['colspan']);
                             $return_array[$format_counter][$line_counter]['colspan'] = array();
                             $return_array[$format_counter][$line_counter]['colspan'] = $colspan_array;
                         }
                     }
                 }
                 if ($value[1] == "line" and $value[2] == "#") {
                     if ($in_format == true and $in_line == true) {
                         $return_array[$format_counter][$line_counter]['max_column'] = $line_max_column;
                         if ($format_max_column < $line_max_column) {
                             $format_max_column = $line_max_column;
                         }
                         $in_line = false;
                         $line_counter++;
                         $element_counter = 0;
                         if ($colspan_array) {
                             unset($colspan_array);
                             unset($colspan_array_count);
                         }
                     } else {
                         $return .= "<br />\n";
                     }
                 }
                 if ($value[1] == "print" and $value[2] != "#") {
                     $element_array = array();
                     if ($value[3]['format']) {
                         $element_array['format'] = $value[3]['format'];
                     }
                     if ($value[3]['width']) {
                         $element_array['width'] = $value[3]['width'];
                     }
                     $element_array['value'] = array();
                     if ($value[3]['value'] and !$value[3]['var']) {
                         array_push($element_array['value'], $value[3]['value']);
                     } elseif (!$value[3]['value'] and $value[3]['var']) {
                         $value_var = new ValueVar($folder_id);
                         $value_var_content = $value_var->get_content($value[3]['var']);
                         if (!is_array($value_var_content)) {
                             array_push($element_array['value'], $value_var_content);
                         } else {
                             array_push($element_array['value'], "Error: Array is given");
                         }
                     }
                     if ($in_line == true and $in_format == true) {
                         $return_array[$format_counter][$line_counter][$element_counter]['type'] = "element";
                         $return_array[$format_counter][$line_counter][$element_counter]['element'] = "print";
                         $return_array[$format_counter][$line_counter][$element_counter]['content'] = $element_array;
                         $element_counter++;
                         $line_max_column++;
                     } else {
                         $return_array[$format_counter]['type'] = "element";
                         $return_array[$format_counter]['element'] = "print";
                         $return_array[$format_counter]['content'] = $element_array;
                         $format_counter++;
                     }
                     unset($element_array);
                 }
                 if ($value[1] == "field" and $value[2] != "#") {
                     if ($value[3]['name']) {
                         $element_array['name'] = $value[3]['name'];
                     }
                     if ($value[3]['display_name']) {
                         $element_array['display_name'] = $value[3]['display_name'];
                     }
                     if ($value[3]['default']) {
                         $element_array['default'] = $value[3]['default'];
                     }
                     if ($value[3]['format']) {
                         $element_array['format'] = $value[3]['format'];
                     }
                     if ($value[3]['set']) {
                         $element_array['set'] = $value[3]['set'];
                     }
                     // Type of the input
                     if ($value[3]['vartype']) {
                         switch ($value[3]['vartype']) {
                             case "integer":
                             case "int":
                                 $element_array['vartype'] = "integer";
                                 break;
                             case "float":
                                 $element_array['vartype'] = "float";
                                 break;
                             default:
                                 $element_array['vartype'] = "string";
                                 break;
                         }
                     } else {
                         $element_array['vartype'] = "string";
                     }
                     // Minimum and Maximum Input (possbile with integer and float only)
                     if ($value[3]['min_value'] and ($element_array['vartype'] == "integer" or $element_array['vartype'] == "float")) {
                         if (is_numeric($value[3]['min_value'])) {
                             $element_array['min_value'] = $value[3]['min_value'];
                         }
                     }
                     if ($value[3]['max_value'] and ($element_array['vartype'] == "integer" or $element_array['vartype'] == "float")) {
                         if (is_numeric($value[3]['max_value'])) {
                             $element_array['max_value'] = $value[3]['max_value'];
                         }
                     }
                     if ($element_array['max_value'] and $element_array['min_value']) {
                         if ($element_array['max_value'] < $element_array['min_value']) {
                             // Removes min_value and max_value if it is impossible to fulfill it
                             $element_array['min_value'] = null;
                             $element_array['max_value'] = null;
                         }
                     }
                     // Displayed length of the field
                     if ($value[3]['length']) {
                         $element_array['length'] = $value[3]['length'];
                     } else {
                         $element_array['length'] = 30;
                     }
                     // Requirement of the field
                     if ($value[3]['requirement']) {
                         switch ($value[3]['requirement']) {
                             case "required":
                                 $element_array['requirement'] = 1;
                                 break;
                             case "important":
                                 $element_array['requirement'] = 2;
                                 break;
                             default:
                                 $element_array['requirement'] = 0;
                                 break;
                         }
                     } else {
                         $element_array['requirement'] = 0;
                     }
                     // Size of a textarea
                     if ($value[3]['size']) {
                         $sizeArray = explode(",", $value[3]['size']);
                         $field_cols = $sizeArray[0];
                         $field_rows = $sizeArray[1];
                         unset($sizeArray);
                     } else {
                         $field_cols = 64;
                         $field_rows = 15;
                     }
                     $element_array['size'] = array();
                     $element_array['size']['cols'] = $field_cols;
                     $element_array['size']['rows'] = $field_rows;
                     $element_array['value'] = array();
                     if ($value[3]['type']) {
                         switch (trim(strtolower($value[3]['type']))) {
                             case "textarea":
                                 $element_array['type'] = "textarea";
                                 break;
                             case "checkbox":
                                 $element_array['type'] = "checkbox";
                                 break;
                             case "dropdown":
                                 $element_array['type'] = "dropdown";
                                 if ($value[3]['value'] and !$value[3]['var']) {
                                     $value_array = explode(";;", $value[3]['value']);
                                     $value_array_length = substr_count($value[3]['value'], ";;");
                                     for ($i = 0; $i <= $value_array_length; $i++) {
                                         array_push($element_array['value'], $value_array[$i]);
                                     }
                                 } elseif (!$value[3]['value'] and $value[3]['var']) {
                                     $value_var = new ValueVar($folder_id);
                                     $value_var_content = $value_var->get_content($value[3]['var']);
                                     if (is_array($value_var_content) and count($value_var_content) >= 1) {
                                         foreach ($value_var_content as $value_var_key => $value_var_value) {
                                             if (!is_array($value_var_value)) {
                                                 array_push($element_array['value'], $value_var_value);
                                             }
                                         }
                                     }
                                 }
                                 break;
                             default:
                                 $element_array['type'] = "textfield";
                                 break;
                         }
                     } else {
                         $element_array['type'] = "textfield";
                     }
                     if ($in_line == true and $in_format == true) {
                         $return_array[$format_counter][$line_counter][$element_counter]['type'] = "element";
                         $return_array[$format_counter][$line_counter][$element_counter]['element'] = "field";
                         $return_array[$format_counter][$line_counter][$element_counter]['content'] = $element_array;
                         $element_counter++;
                         $line_max_column++;
                     } else {
                         $return_array[$format_counter]['type'] = "element";
                         $return_array[$format_counter]['element'] = "field";
                         $return_array[$format_counter]['content'] = $element_array;
                         $format_counter++;
                     }
                 }
             }
             return $return_array;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }