Exemplo n.º 1
0
 public static function create()
 {
     if ($_GET['nextpage'] == 1) {
         $page_1_passed = true;
     } else {
         $page_1_passed = false;
         $error = "";
     }
     if ($page_1_passed == false) {
         $template = new HTMLTemplate("sample/admin/sample_template/add.html");
         $paramquery = $_GET;
         $paramquery['nextpage'] = "1";
         $params = http_build_query($paramquery, '', '&');
         $template->set_var("params", $params);
         if ($error) {
             $template->set_var("error", $error);
         } else {
             $template->set_var("error", "");
         }
         $folder = Folder::get_instance(constant("OLDL_FOLDER_ID"));
         $data_entity_array = $folder->get_children();
         if (is_array($data_entity_array)) {
             $result = array();
             $counter = 0;
             foreach ($data_entity_array as $key => $value) {
                 if (($file_id = File::get_file_id_by_data_entity_id($value)) != null) {
                     $file = File::get_instance($file_id);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $file->get_name();
                     $counter++;
                 }
             }
             $template->set_var("file", $result);
         }
         $category_array = SampleTemplateCat::list_entries();
         if (is_array($category_array)) {
             $result = array();
             $counter = 0;
             foreach ($category_array as $key => $value) {
                 $sample_template_cat = new SampleTemplateCat($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $sample_template_cat->get_name();
                 $counter++;
             }
             $template->set_var("category", $result);
         }
         $template->output();
     } else {
         $sample_template = new SampleTemplate(null);
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&');
         if ($sample_template->create($_POST['data_entity_id'], $_POST['category_id'])) {
             Common_IO::step_proceed($params, "Add Sample Template", "Operation Successful", null);
         } else {
             Common_IO::step_proceed($params, "Add Sample Template", "Operation Failed", null);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @see DataPermissionInterface::__construct()
  * @param string type
  * @param integer $id
  */
 function __construct($type, $id)
 {
     if (is_numeric($id) and $type) {
         $this->type = $type;
         switch ($type) {
             case "file":
                 $this->id = $id;
                 $this->object = File::get_instance($id);
                 break;
             case "value":
                 $this->id = $id;
                 $this->object = Value::get_instance($id);
                 break;
             case "parameter":
                 $this->id = $id;
                 $this->object = Parameter::get_instance($id);
                 break;
             case "folder":
                 $this->id = $id;
                 $this->object = Folder::get_instance($id);
                 break;
         }
         $this->automatic = $this->object->get_automatic();
         $this->permission = $this->object->get_permission();
         $this->owner_id = $this->object->get_owner_id();
         $this->owner_group_id = $this->object->get_owner_group_id();
     } else {
         $this->id = null;
         $this->object = null;
     }
 }
Exemplo n.º 3
0
 /**
  * @param string $alias
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  * @throws ProjectSecurityAccessDeniedException
  * @throws BaseModuleDialogNotFoundException
  * @throws ItemAddIOClassNotFoundException
  * @throws ItemAddIOFileNotFoundException
  * @throws ItemHandlerClassNotFoundException
  * @throws ItemPositionIDMissingException
  * @throws ItemParentIDMissingException
  * @throws ItemParentTypeMissingException
  * @throws ProjectStatusWithoutExtensionException
  * @throws BaseExtensionClassNotFoundException
  * @throws BaseExtensionFileNotFoundException
  * @throws BaseExtensionNotFoundException
  * @throws BaseExtensionMissingException
  */
 public static function io_handler($alias)
 {
     global $project_security, $session, $transaction;
     if (isset($_GET['project_id']) and is_numeric($_GET['project_id'])) {
         $project_security = new ProjectSecurity($_GET['project_id']);
         if ($_GET['run'] != "new_subproject") {
             require_once "io/project_common.io.php";
             ProjectCommon_IO::tab_header();
         }
     } else {
         $project_security = new ProjectSecurity(null);
     }
     if (isset($_GET['run'])) {
         switch ($_GET['run']) {
             case "new":
             case "new_subproject":
                 require_once "io/project.io.php";
                 ProjectIO::create();
                 break;
             case "myprojects":
             case "workon":
             case "accessdata":
             case "analyse":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
             case "userprojects":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects($_GET['id']);
                 break;
             case "organ_unit":
                 require_once "io/project.io.php";
                 ProjectIO::list_organisation_unit_related_projects();
                 break;
             case "detail":
                 require_once "io/project.io.php";
                 ProjectIO::detail();
                 break;
             case "structure":
                 require_once "io/project.io.php";
                 ProjectIO::structure();
                 break;
                 // Project Log
             // Project Log
             case "log":
                 require_once "io/project_log.io.php";
                 ProjectLogIO::list_project_related_logs();
                 break;
                 // Tasks and Schedule
             // Tasks and Schedule
             case "add_task":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::add();
                 break;
             case "schedule":
             case "show_tasks":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::show();
                 break;
             case "task_detail":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::detail();
                 break;
             case "task_delete":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::delete();
                 break;
             case "task_edit_start":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_start();
                 break;
             case "task_edit_end":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_end();
                 break;
                 // Administration
             // Administration
             case "admin":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::menu();
                 break;
             case "admin_rename":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::rename();
                 break;
             case "admin_chown":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::chown();
                 break;
             case "admin_move":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::move();
                 break;
             case "admin_quota":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::quota();
                 break;
                 // Administration - Permission
             // Administration - Permission
             case "admin_permission":
                 require_once "io/project_admin.io.php";
                 $project_admin_io = new ProjectAdminIO();
                 ProjectAdminIO::permission();
                 break;
             case "admin_permission_add_user":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_user();
                 break;
             case "admin_permission_add_group":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_group();
                 break;
             case "admin_permission_add_ou":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_organisation_unit();
                 break;
             case "admin_permission_edit":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_edit();
                 break;
             case "admin_permission_delete":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_delete();
                 break;
                 // Item Lister
             // Item Lister
             case "item_list":
                 if ($project_security->is_access(1, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['dialog'] == "data") {
                             $path_stack_array = array();
                             $folder_id = ProjectFolder::get_folder_by_project_id($_GET['project_id']);
                             $folder = Folder::get_instance($folder_id);
                             $init_array = $folder->get_object_id_path();
                             foreach ($init_array as $key => $value) {
                                 $temp_array = array();
                                 $temp_array['virtual'] = false;
                                 $temp_array['id'] = $value;
                                 array_unshift($path_stack_array, $temp_array);
                             }
                             if (!$_GET['folder_id']) {
                                 $session->write_value("stack_array", $path_stack_array, true);
                             }
                         }
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_list", $_GET['dialog']);
                         if (file_exists($module_dialog['class_path'])) {
                             require_once $module_dialog['class_path'];
                             if (class_exists($module_dialog['class'])) {
                                 if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                     $module_dialog['class']::$module_dialog['method']("project", $_GET['project_id'], true);
                                 } else {
                                     throw new BaseModuleDialogMethodNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogClassNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogFileNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Item Add
             // Item Add
             case "item_add":
             case "item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['run'] == "item_add") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']);
                         } elseif ($_GET['run'] == "item_edit") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']);
                         }
                         if (is_array($module_dialog) and $module_dialog['class_path']) {
                             if (file_exists($module_dialog['class_path'])) {
                                 require_once $module_dialog['class_path'];
                                 if (class_exists($module_dialog['class'])) {
                                     if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                         $project = new Project($_GET['project_id']);
                                         $project_item = new ProjectItem($_GET['project_id']);
                                         $project_item->set_status_id($project->get_current_status_id());
                                         $project_item->set_gid($_GET['key']);
                                         $description_required = $project_item->is_description_required();
                                         $keywords_required = $project_item->is_keywords_required();
                                         if ($description_required and !$_POST['description'] and !$_GET['idk_unique_id'] or $keywords_required and !$_POST['keywords'] and !$_GET['idk_unique_id']) {
                                             require_once "core/modules/item/io/item.io.php";
                                             ItemIO::information(http_build_query($_GET), $description_required, $keywords_required);
                                         } else {
                                             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
                                             if ($_GET['run'] == "item_add") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['type_id'], $current_status_requirements[$_GET['key']]['category_id'], "Project", $_GET['project_id'], $_GET['key']);
                                             } elseif ($_GET['run'] == "item_edit") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['fulfilled'][0]['item_id']);
                                             }
                                         }
                                     } else {
                                         throw new BaseModuleDialogMethodNotFoundException();
                                     }
                                 } else {
                                     throw new BaseModuleDialogClassNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogFileNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Sub Item Add and Edit
             // Sub Item Add and Edit
             case "sub_item_add":
             case "sub_item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['parent']) {
                         if (is_numeric($_GET['parent_id'])) {
                             if (is_numeric($_GET['key'])) {
                                 $item_handling_class = Item::get_handling_class_by_type($_GET['parent']);
                                 if (class_exists($item_handling_class)) {
                                     $item_io_handling_class = $item_handling_class::get_item_add_io_handling_class();
                                     if (file_exists("core/modules/" . $item_io_handling_class[0])) {
                                         require_once "core/modules/" . $item_io_handling_class[0];
                                         if (class_exists($item_io_handling_class[1])) {
                                             if ($_GET['run'] == "sub_item_add") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("add");
                                             } elseif ($_GET['run'] == "sub_item_edit") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("edit");
                                             }
                                         } else {
                                             throw new ItemAddIOClassNotFoundException();
                                         }
                                     } else {
                                         throw new ItemAddIOFileNotFoundException();
                                     }
                                 } else {
                                     throw new ItemHandlerClassNotFoundException();
                                 }
                             } else {
                                 throw new ItemPositionIDMissingException();
                             }
                         } else {
                             throw new ItemParentIDMissingException();
                         }
                     } else {
                         throw new ItemParentTypeMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Extension
                 /**
                  * @todo type filter
                  */
             // Extension
             /**
              * @todo type filter
              */
             case "extension":
                 if ($_GET['extension']) {
                     $extension_id = Extension::get_id_by_identifier($_GET['extension']);
                     if ($extension_id) {
                         $extension = new Extension($extension_id);
                         $main_file = constant("EXTENSION_DIR") . "/" . $extension->get_folder() . "/" . $extension->get_main_file();
                         $main_class = $extension->get_class();
                         if (file_exists($main_file)) {
                             require_once $main_file;
                             if (class_exists($main_class)) {
                                 $project = new Project($_GET['project_id']);
                                 $project_item = new ProjectItem($_GET['project_id']);
                                 $project_status_requirements = $project->get_current_status_requirements();
                                 if (is_array($project_status_requirements) and count($project_status_requirements) >= 1) {
                                     foreach ($project_status_requirements as $key => $value) {
                                         if ($value['element_type'] == "extension" and $value['extension'] == $_GET['extension']) {
                                             if (is_array($value['filter']) and count($value['filter']) >= 1) {
                                                 $filter_array = $value['filter'];
                                             } else {
                                                 $filter_array = null;
                                             }
                                             break;
                                         }
                                     }
                                 } else {
                                     throw new ProjectStatusWithoutExtensionException();
                                 }
                                 if ($filter_array) {
                                     $item_array = array();
                                     foreach ($filter_array as $key => $value) {
                                         if (is_numeric($value['status'])) {
                                             $item_array = array_merge($item_array, $project_item->get_project_status_items($value['status'], true));
                                         }
                                     }
                                 } else {
                                     $item_array = $project_item->get_project_items(true);
                                 }
                                 $event_identifier = uniqid("", true);
                                 if ($session->is_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY")) {
                                     $project_extension_event_identifier_array = $session->read_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY");
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 } else {
                                     $project_extension_event_identifier_array = array();
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 }
                                 $session->write_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY", $project_extension_event_identifier_array);
                                 $main_class::set_event_identifier($event_identifier);
                                 $main_class::set_target_folder_id(ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id()));
                                 $main_class::push_data($item_array);
                             } else {
                                 throw new BaseExtensionClassNotFoundException();
                             }
                         } else {
                             throw new BaseExtensionFileNotFoundException();
                         }
                     } else {
                         throw new BaseExtensionNotFoundException();
                     }
                 } else {
                     throw new BaseExtensionMissingException();
                 }
                 break;
                 // Common Dialogs
             // Common Dialogs
             case "common_dialog":
                 require_once "core/modules/base/common.request.php";
                 CommonRequest::common_dialog();
                 break;
                 // Default
             // Default
             default:
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
         }
     } else {
         require_once "io/project.io.php";
         ProjectIO::list_user_related_projects(null);
     }
 }
Exemplo n.º 4
0
 /**
  * @see ValueInterface::create()
  * @param integer $folder_id
  * @param integer $owner_id
  * @param integer $type_id
  * @param array $value
  * @param bool $premature
  * @return integer
  */
 public function create($folder_id, $owner_id, $type_id, $value)
 {
     global $user, $transaction;
     if ($folder_id and $type_id) {
         $transaction_id = $transaction->begin();
         try {
             if ($owner_id == null) {
                 $owner_id = $user->get_user_id();
             }
             $checksum = md5(serialize($value));
             $folder = Folder::get_instance($folder_id);
             $data_entity_id = parent::create($owner_id, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             $value_access = new Value_Access(null);
             if (($value_id = $value_access->create($data_entity_id, $type_id)) == null) {
                 throw new ValueCreateFailedException();
             }
             if ($type_id != 2 and is_array($value)) {
                 $full_text_index = false;
                 $full_text_key_array = array();
                 $full_text_content_string = "";
                 foreach ($value as $fe_key => $fe_value) {
                     if (strpos($fe_key, "-vartype") !== false) {
                         if ($fe_value == "string") {
                             $full_text_index = true;
                             $tmp_key = str_replace("-vartype", "", $fe_key);
                             array_push($full_text_key_array, $tmp_key);
                         }
                     }
                 }
                 if (is_array($full_text_key_array) and count($full_text_key_array) >= 1) {
                     foreach ($full_text_key_array as $fe_key => $fe_value) {
                         if ($full_text_content_string) {
                             $full_text_content_string = $full_text_content_string . " " . $value[$fe_value];
                         } else {
                             $full_text_content_string = $value[$fe_value];
                         }
                     }
                 }
             } else {
                 $full_text_index = true;
                 $full_text_content_string = $value;
             }
             $value_version_access = new ValueVersion_access(null);
             if ($value_version_access->create($value_id, 1, serialize($value), $checksum, null, 1, true, $owner_id) == null) {
                 throw new ValueCreateVersionCreateFailedException();
             }
             if ($full_text_index == true and $full_text_content_string) {
                 $value_version_access->set_text_search_vector($full_text_content_string, "english");
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($value_id);
         return $value_id;
     } else {
         throw new ValueCreateIDMissingException();
     }
 }
Exemplo n.º 5
0
 /**
  * @see DataEntityInterface::__construct()
  * @param integer $entity_id
  * @param boolean $light_instance
  * @throws DataEntityNotFoundException
  */
 function __construct($entity_id, $light_instance = false)
 {
     if (is_numeric($entity_id) and $entity_id > 0) {
         if (DataEntity_Access::exist_id($entity_id) == true) {
             $this->data_entity_id = $entity_id;
             $this->data_entity = new DataEntity_Access($entity_id);
             $data_entity_is_item = new DataEntityIsItem_Access($entity_id);
             $this->item_id = $data_entity_is_item->get_item_id();
             parent::__construct($this->item_id);
         } else {
             throw new DataEntityNotFoundException();
         }
     } else {
         $this->data_entity_id = null;
         $this->data_entity = new DataEntity_Access(null);
         parent::__construct(null);
     }
     if ($light_instance == false) {
         $this->data_entity_permission = new DataEntityPermission($this->data_entity->get_permission(), $this->data_entity->get_automatic(), $this->data_entity->get_owner_id(), $this->data_entity->get_owner_group_id());
         if (!self::$data_entity_object_array[$entity_id]) {
             self::$data_entity_object_array[$entity_id] = $this;
         }
         if ($this->data_entity_permission->is_access(1)) {
             $this->read_access = true;
         } else {
             $this->read_access = false;
         }
         if ($this->data_entity_permission->is_access(2)) {
             $this->write_access = true;
         } else {
             $this->write_access = false;
         }
         if ($this->data_entity_permission->is_access(3)) {
             $this->delete_access = true;
         } else {
             $this->delete_access = false;
         }
         if ($this->data_entity_permission->is_access(4)) {
             $this->control_access = true;
         } else {
             $this->control_access = false;
         }
         $this->parent_folder_id = $this->calc_parent_folder_id();
         // Can create folder als methode => flag nur noch f�r corrupt (�ber parent folder object)
         if (is_a($this, "SystemFolder") == false and is_numeric($this->parent_folder_id)) {
             $this->parent_folder_object = Folder::get_instance($this->parent_folder_id);
             if ($this->parent_folder_object->get_inherit_permission() == true and is_a($this->parent_folder_object, "SystemFolder") == false) {
                 $this->inherit_permission = true;
                 if ($this->parent_folder_object->is_read_access(true) == true) {
                     $this->read_access = true;
                 } else {
                     $this->read_access = false;
                 }
                 if ($this->parent_folder_object->is_write_access(true) == true) {
                     $this->write_access = true;
                 } else {
                     $this->write_access = false;
                 }
                 if ($this->parent_folder_object->is_delete_access(true) == true) {
                     $this->delete_access = true;
                 } else {
                     $this->delete_access = false;
                 }
                 if ($this->parent_folder_object->is_control_access(true) == true) {
                     $this->control_access = true;
                 } else {
                     $this->control_access = false;
                 }
                 if ($this->parent_folder_object->can_set_data_entity() == true) {
                     $this->set_data_entity = true;
                 }
             } else {
                 $this->inherit_permission = false;
             }
         } else {
             $this->inherit_permission = false;
         }
     }
 }
Exemplo n.º 6
0
 /**
  * @param integer $folder_id
  * @return string
  */
 public static function get_browser_menu($folder_id)
 {
     $return_array = array("add" => true, "add_list" => "", "image_browser" => true);
     $folder = Folder::get_instance($folder_id);
     if ($folder->is_write_access()) {
         if ($folder->can_add_folder()) {
             $add_folder_link = "run=folder_add&folder_id=" . $folder_id;
             $html .= "<img src='images/icons/upload.png' alt='' /><a href=" . $add_folder_link . ">Add Folder</a><br/>";
         }
         $add_file_link = "run=file_add&folder_id=" . $folder_id;
         $add_value_link = "run=value_add&folder_id=" . $folder_id;
         $html .= "<img src='images/icons/upload.png' alt='' /><a href=" . $add_file_link . ">Add File(s)</a><br/>";
         $html .= "<img src='images/icons/upload.png' alt='' /><a href=" . $add_value_link . ">Add Values</a><br/>";
         $return_array["add_list"] = $html;
     } else {
         $return_array["add"] = false;
     }
     //check image browser
     return json_encode($return_array);
 }
Exemplo n.º 7
0
 /**
  * @param string $permission_array
  * @param string $type
  * @return string
  * @throws DataSecurityAccessDeniedException
  */
 public static function change_permission($permission_array, $type)
 {
     global $user;
     $permissions = (array) $permission_array;
     switch ($type) {
         case "File":
             $id = $_POST['file_id'];
             $object = File::get_instance($id);
             break;
         case "Folder":
             $id = $_POST['folder_id'];
             $object = Folder::get_instance($id);
             break;
         case "Value":
             $id = $_POST['value_id'];
             $object = Value::get_instance($id);
             break;
         case "Parameter":
             $id = $_POST['parameter_id'];
             $object = Parameter::get_instance($id);
             break;
     }
     if ($object->is_control_access() == true) {
         $full_access = true;
     } else {
         $full_access = false;
     }
     if ($object->get_owner_id() == $user->get_user_id()) {
         $user_access = true;
     } else {
         $user_access = false;
     }
     if ($full_access == true or $user_access == true) {
         $type = strtolower($type);
         $id = intval($id);
         echo $id;
         $data_permission = new DataPermission($type, $id);
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&#38;');
         if ($data_permission->set_permission_array($permissions) == true) {
             return "1";
         } else {
             return "0";
         }
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Exemplo n.º 8
0
 /**
  * @see ProjectInterface::set_name()
  * @param string $name
  * @return bool
  */
 public function set_name($name)
 {
     global $transaction;
     if ($this->project_id and $this->project and $name) {
         if ($this->project->get_toid_organ_unit()) {
             if (self::exist_project_name($this->project->get_toid_organ_unit(), null, $name) == true) {
                 return false;
             }
         } else {
             if (self::exist_project_name(null, $this->project->get_toid_project(), $name) == true) {
                 return false;
             }
         }
         $transaction_id = $transaction->begin();
         $folder_id = ProjectFolder::get_folder_by_project_id($this->project_id);
         $folder = Folder::get_instance($folder_id);
         if ($folder->set_name($name) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         }
         if ($this->project->set_name($name) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         } else {
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 9
0
 /**
  * @see DataBrowserInterface::count_data_browser_array()
  * @param integer $folder_id
  * @param integer $virtual_folder_id
  * @return integer
  */
 public static function count_data_browser_array($folder_id, $virtual_folder_id)
 {
     global $user;
     if ($folder_id and !$virtual_folder_id or !$folder_id and !$virtual_folder_id) {
         if ($folder_id == null) {
             $new_folder_id = UserFolder::get_folder_by_user_id($user->get_user_id());
             if ($new_folder_id != null) {
                 self::$folder_id = $new_folder_id;
             } else {
                 // Exception
             }
         } else {
             self::$folder_id = $folder_id;
         }
         $folder = Folder::get_instance(self::$folder_id);
         return Data_Wrapper_Access::count_list_data_entity_childs($folder->get_data_entity_id());
     } elseif (!$folder_id and $virtual_folder_id) {
         $virtual_folder = new VirtualFolder($virtual_folder_id);
         return Data_Wrapper_Access::count_list_data_entity_childs($virtual_folder->get_data_entity_id());
     } else {
         // Exception
     }
 }
Exemplo n.º 10
0
 /**
  * @throws FolderIDMissingException
  * @throws DataSecurityAccessDeniedException
  */
 public static function upload()
 {
     if ($_GET['folder_id']) {
         $folder = Folder::get_instance($_GET['folder_id']);
         if ($folder->is_write_access() == true) {
             $template = new HTMLTemplate("data/file_upload.html");
             $unique_id = uniqid();
             $paramquery = $_GET;
             $paramquery['unique_id'] = $unique_id;
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("unique_id", $unique_id);
             $template->set_var("session_id", $_GET['session_id']);
             if ($_GET['retrace']) {
                 $js_retrace_array = array();
                 $js_retrace_counter = 0;
                 $retrace_array = unserialize(base64_decode($_GET['retrace']));
                 foreach ($retrace_array as $key => $value) {
                     $js_retrace_array[$js_retrace_counter][0] = $key;
                     $js_retrace_array[$js_retrace_counter][1] = $value;
                     $js_retrace_counter++;
                 }
                 $template->set_var("retrace", serialize($js_retrace_array));
             } else {
                 $template->set_var("retrace", "");
             }
             $template->output();
         } else {
             throw new DataSecurityAccessDeniedExcpetion();
         }
     } else {
         throw new FolderIDMissingException();
     }
 }
Exemplo n.º 11
0
 /**
  * Inits a caching procedure
  * @return bool
  */
 private function init()
 {
     global $transaction;
     if ($this->data_entity_id) {
         $transaction_id = $transaction->begin();
         $file_id = File::get_file_id_by_data_entity_id($this->data_entity_id);
         $file = File::get_instance($file_id);
         $folder = Folder::get_instance($file->get_parent_folder());
         $folder_path = $folder->get_path();
         $extension_array = explode(".", $file->get_name());
         $extension_array_length = substr_count($file->get_name(), ".");
         $file_path = constant("BASE_DIR") . "/" . $folder_path . "/" . $this->data_entity_id . "-1." . $extension_array[$extension_array_length];
         $this->xml_string = $file->get_file_content();
         if (strlen($this->xml_string) > 0) {
             $xml = new Xml($this->xml_string);
             $xml->parser();
             $this->xml_array = $xml->get_array();
             if (is_array($this->xml_array) and count($this->xml_array) >= 1) {
                 $this->xml_cache = new XmlCache_Access(null);
                 $id = $this->xml_cache->create($this->data_entity_id, $file_path, md5_file($file_path));
                 foreach ($this->xml_array as $key => $value) {
                     $xml_cache_element = new XmlCacheElement_Access(null);
                     $xml_cache_element->create($id, $value[0], $value[1], $value[2], $value[3]);
                 }
                 self::__construct($this->data_entity_id);
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         }
     }
 }
Exemplo n.º 12
0
 /**
  * @see ParameterInterface::create()
  * @param integer $folder_id
  * @param integer $limit_id
  * @param array $parameter_array
  * @param integer $owner_id
  * @return integer
  * @throws ParameterCreateFailedException
  * @throws ParameterCreateVersionCreateFailedException
  * @throws ParameterCreateValueCreateFailedException
  * @throws ParameterCreateIDMissingException
  */
 protected function create($folder_id, $limit_id, $parameter_array, $owner_id = null)
 {
     global $user, $regional, $transaction;
     if (is_numeric($folder_id) and is_array($parameter_array)) {
         $transaction_id = $transaction->begin();
         try {
             if ($owner_id == null) {
                 $owner_id = $user->get_user_id();
             }
             $folder = Folder::get_instance($folder_id);
             $data_entity_id = parent::create($owner_id, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             $parameter_access = new Parameter_Access(null);
             if (($parameter_id = $parameter_access->create($data_entity_id)) == null) {
                 throw new ParameterCreateFailedException();
             }
             $parameter_version_access = new ParameterVersion_Access(null);
             if (($parameter_version_id = $parameter_version_access->create($parameter_id, 1, 1, null, true, $owner_id, null, $limit_id)) == null) {
                 throw new ParameterCreateVersionCreateFailedException();
             }
             foreach ($parameter_array as $key => $value) {
                 $value['value'] = str_replace($regional->get_decimal_separator(), ".", $value['value']);
                 if (is_numeric($value['value'])) {
                     $parameter_field_value = new ParameterFieldValue_Access(null);
                     if ($parameter_field_value->create($parameter_version_id, $key, $value['method'], $value['value']) == null) {
                         throw new ParameterCreateValueCreateFailedException();
                     }
                 }
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($parameter_id);
         return $parameter_id;
     } else {
         throw new ParameterCreateIDMissingException();
     }
 }
Exemplo n.º 13
0
 /**
  * @param integer $id
  */
 public static function get_children($id)
 {
     if (is_numeric($id) and $id != 0) {
         $return_array = array();
         $folder = Folder::get_instance($id);
         $folder_array = $folder->get_subfolder_array();
         if (is_array($folder_array) and count($folder_array) >= 1) {
             $counter = 0;
             foreach ($folder_array as $key => $value) {
                 $folder = Folder::get_instance($value);
                 $return_array[$counter][0] = -1;
                 $return_array[$counter][1] = $value;
                 $return_array[$counter][2] = $folder->get_name();
                 $return_array[$counter][3] = "folder.png";
                 if ($folder->is_read_access() == true) {
                     $return_array[$counter][4] = true;
                 } else {
                     $return_array[$counter][4] = false;
                 }
                 $return_array[$counter][5] = true;
                 // Clickable
                 $paramquery['username'] = $_GET['username'];
                 $paramquery['session_id'] = $_GET['session_id'];
                 $paramquery['nav'] = "data";
                 $paramquery['folder_id'] = $value;
                 $params = http_build_query($paramquery, '', '&#38;');
                 $return_array[$counter][6] = $params;
                 //link
                 $return_array[$counter][7] = false;
                 //open
                 $return_array[$counter][8] = Data_Wrapper::has_folder_children($value);
                 //has children
                 $counter++;
             }
         }
         echo json_encode($return_array);
     }
 }
Exemplo n.º 14
0
 public static function search()
 {
     global $user, $session;
     if ($_GET['nextpage']) {
         if ($_GET['sortvalue'] and $_GET['sortmethod']) {
             if ($_GET['nextpage'] == "2" and $_POST['string']) {
                 $name = $_POST['string'];
                 $folder_id = $session->read_value("SEARCH_FFV_FOLDER_ID");
             } else {
                 $name = $session->read_value("SEARCH_FFV_NAME");
                 $folder_id = $session->read_value("SEARCH_FFV_FOLDER_ID");
             }
         } else {
             if ($_GET['page']) {
                 $name = $session->read_value("SEARCH_FFV_NAME");
                 $folder_id = $session->read_value("SEARCH_FFV_FOLDER_ID");
             } else {
                 if ($_GET['nextpage'] == "1") {
                     $name = $_POST['string'];
                     if (isset($_POST['folder_id']) and is_numeric($_POST['folder_id'])) {
                         $folder_id = $_POST['folder_id'];
                     } else {
                         $data_path = new DataPath();
                         $data_path_folder_id = $data_path->get_folder_id();
                         if (is_numeric($data_path_folder_id)) {
                             $folder_id = $data_path_folder_id;
                         } else {
                             $folder_id = UserFolder::get_folder_by_user_id($user->get_user_id());
                         }
                     }
                     $session->delete_value("SEARCH_FFV_NAME");
                     $session->delete_value("SEARCH_FFV_FOLDER_ID");
                 } else {
                     $name = $_POST['string'];
                     $folder_id = $session->read_value("SEARCH_FFV_FOLDER_ID");
                 }
             }
         }
         $no_error = true;
     } else {
         $no_error = false;
     }
     if ($no_error == false) {
         $template = new HTMLTemplate("data/search/ffv_search.html");
         $paramquery = $_GET;
         unset($paramquery['page']);
         $paramquery['nextpage'] = "1";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("params", $params);
         $template->set_var("error", "");
         $template->output();
     } else {
         if (!$folder_id) {
             $folder_id = $_POST['folder_id'];
         }
         $session->write_value("SEARCH_FFV_NAME", $name, true);
         $session->write_value("SEARCH_FFV_FOLDER_ID", $folder_id, true);
         $argument_array = array();
         $argument_array[0][0] = "folder_id";
         $argument_array[0][1] = $folder_id;
         $argument_array[1][0] = "name";
         $argument_array[1][1] = $name;
         $list = new List_IO("DataSearch", "ajax.php?nav=data", "search_data_list_data", "search_data_count_data", $argument_array, "DataSearch");
         $list->add_column("", "symbol", false, "16px");
         $list->add_column(Language::get_message("DataGeneralListColumnName", "general"), "name", true, null);
         $list->add_column(Language::get_message("DataGeneralListColumnType", "general"), "type", false, null);
         $list->add_column(Language::get_message("DataGeneralListColumnVersion", "general"), "version", false, null);
         $list->add_column(Language::get_message("DataGeneralListColumnDateTime", "general"), "datetime", true, null);
         $list->add_column(Language::get_message("DataGeneralListColumnSize", "general"), "size", true, null);
         $list->add_column(Language::get_message("DataGeneralListColumnOwner", "general"), "owner", true, null);
         $list->add_column(Language::get_message("DataGeneralListColumnPermission", "general"), "permission", false, null);
         $folder = Folder::get_instance($folder_id);
         $template = new HTMLTemplate("data/search/ffv_search_result.html");
         $paramquery = $_GET;
         $paramquery['nextpage'] = "2";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("params", $params);
         $template->set_var("name", $name);
         $template->set_var("folder", $folder->get_name());
         $template->set_var("list", $list->get_list());
         $template->output();
     }
 }
Exemplo n.º 15
0
 /**
  * @see FolderInterface::move_folder()
  * @param integer $destination_id
  * @param bool $force_exist_check
  * @return bool
  */
 public function move_folder($destination_id, $force_exist_check)
 {
     global $session, $transaction;
     if ($this->folder_id and $this->folder and is_numeric($destination_id)) {
         $destination_folder = Folder::get_instance($destination_id);
         if ($destination_folder->exist_subfolder_name($this->get_name()) == false or $force_exist_check == true) {
             $transaction_id = $transaction->begin();
             $current_path = new Path($this->get_path());
             $destination_path = new Path($destination_folder->get_path());
             $destination_path->add_element($current_path->get_last_element());
             $new_path = $destination_path->get_path_string();
             // create new folder
             if (mkdir(constant("BASE_DIR") . "/" . $new_path) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
             // change database
             if ($this->folder->set_path($new_path) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 rmdir(constant("BASE_DIR") . "/" . $new_path);
                 return false;
             }
             if ($this->unset_child_of($this->get_parent_folder()) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 rmdir(constant("BASE_DIR") . "/" . $new_path);
                 return false;
             }
             if ($this->set_as_child_of($destination_folder->get_data_entity_id()) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 rmdir(constant("BASE_DIR") . "/" . $new_path);
                 return false;
             }
             // subfolder filesystem move
             if (($subfolder_array = $this->get_subfolder_array()) != null) {
                 if (is_array($subfolder_array) and count($subfolder_array) >= 1) {
                     foreach ($subfolder_array as $key => $value) {
                         $folder = Folder::get_instance($value);
                         if ($folder->move_folder($this->folder_id, true) == false) {
                             if ($transaction_id != null) {
                                 $transaction->rollback($transaction_id);
                             }
                             return false;
                         }
                     }
                 }
             }
             // Move Files
             $handle = opendir(constant("BASE_DIR") . "/" . $current_path->get_path_string());
             while (($file_name = readdir($handle)) !== false) {
                 if ($file_name != "." and $file_name != "..") {
                     $current_file = constant("BASE_DIR") . "/" . $current_path->get_path_string() . "/" . $file_name;
                     $destination_file = constant("BASE_DIR") . "/" . $new_path . "/" . $file_name;
                     copy($current_file, $destination_file);
                     unlink($current_file);
                 }
             }
             closedir($handle);
             rmdir(constant("BASE_DIR") . "/" . $current_path->get_path_string());
             // Delete Folder Stack
             $session->delete_value("stack_array");
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 16
0
 /**
  * @throws FolderIDMissingException
  */
 public static function change_group()
 {
     if ($_GET['file_id'] or $_GET['value_id'] or $_GET['parameter_id'] or $_GET['folder_id']) {
         if ($_GET['file_id']) {
             $id = $_GET['file_id'];
             $object = File::get_instance($id);
             $type = "file";
             $title = $object->get_name();
         }
         if ($_GET['value_id']) {
             $id = $_GET['value_id'];
             $object = Value::get_instance($id);
             $type = "value";
             $title = $object->get_type_name();
         }
         if ($_GET['parameter_id']) {
             $id = $_GET['parameter_id'];
             $object = Parameter::get_instance($id);
             $type = "parameter";
             $title = $object->get_name();
         }
         if ($_GET['folder_id']) {
             $id = $_GET['folder_id'];
             $object = Folder::get_instance($id);
             $type = "folder";
             $title = $object->get_name();
         }
     } else {
         throw new FolderIDMissingException();
     }
     if ($object->is_control_access() == true) {
         $data_permission = new DataPermission($type, $id);
         if (!$_GET['nextpage']) {
             $template = new HTMLTemplate("data/data_change_group.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("title", $title);
             $template->set_var("error", "");
             $group_array = Group::list_groups();
             $result = array();
             $counter = 0;
             foreach ($group_array as $key => $value) {
                 $group = new Group($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $group->get_name();
                 $counter++;
             }
             $template->set_var("option", $result);
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("back_link", $params);
             $template->output();
         } else {
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($data_permission->set_owner_group_id($_POST['group']) == true) {
                 Common_IO::step_proceed($params, "Permission: " . $title . "", "Changes saved succesful", null);
             } else {
                 Common_IO::step_proceed($params, "Permission: " . $title . "", "Operation failed", null);
             }
         }
     } else {
         throw new DataSecuriyAccessDeniedException();
     }
 }
Exemplo n.º 17
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_data($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     if (is_array($argument_array)) {
         $folder_id = $argument_array[0][1];
         $name = $argument_array[1][1];
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Data_Wrapper::list_search_ffv($folder_id, $name, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 $owner = new User($value['owner']);
                 $list_array[$key]['owner'] = $owner->get_full_name(true);
                 if (is_numeric($value['file_id'])) {
                     $file = File::get_instance($value['file_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['action'] = "file_detail";
                     $paramquery['file_id'] = $value['file_id'];
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($file->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='" . File::get_icon_by_name($value['name']) . "' alt='' style='border:0;' />";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=" . File::get_icon_by_name($value['name']) . "' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "File";
                     $list_array[$key]['version'] = $file->get_version();
                     $list_array[$key]['size'] = Convert::convert_byte_1024($file->get_size());
                     $list_array[$key]['permission'] = $file->get_permission_string();
                 }
                 if (is_numeric($value['value_id'])) {
                     $value_obj = Value::get_instance($value['value_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['action'] = "value_detail";
                     $paramquery['value_id'] = $value['value_id'];
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($value_obj->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/fileicons/16/unknown.png' alt='' style='border: 0;'>";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/fileicons/16/unknown.png' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "Value";
                     $list_array[$key]['version'] = $value_obj->get_version();
                     $list_array[$key]['permission'] = $value_obj->get_permission_string();
                 }
                 if (is_numeric($value['folder_id'])) {
                     $folder = Folder::get_instance($value['folder_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['folder_id'] = $value['folder_id'];
                     unset($paramquery['run']);
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($folder->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/icons/folder.png' alt='' style='border: 0;'>";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/icons/folder.png' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "Folder";
                     $list_array[$key]['permission'] = $folder->get_permission_string();
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
 }
Exemplo n.º 18
0
 /**
  * @todo business logic exceptions
  * @param integer $folder_id
  * @param integer $type_id
  * @param string $value_array
  * @param string $get_array
  * @return string
  */
 public static function add_as_item($folder_id, $type_id, $value_array, $get_array)
 {
     global $user, $transaction;
     $parent_folder = Folder::get_instance($folder_id);
     if ($parent_folder->is_write_access()) {
         $transaction_id = $transaction->begin();
         $value_array = json_decode($value_array, true);
         $value = Value::get_instance(null);
         $value_add_successful = $value->create($folder_id, $user->get_user_id(), $type_id, $value_array);
         if ($value_add_successful) {
             $item_id = $value->get_item_id();
             $item_add_event = new ItemAddEvent($item_id, unserialize($get_array), null);
             $event_handler = new EventHandler($item_add_event);
             if ($event_handler->get_success() == true) {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return "1";
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new BaseException();
             }
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new BaseException();
         }
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Exemplo n.º 19
0
 /**
  * @see SampleInterface::set_name()
  * @param string $name
  * @return bool
  */
 public function set_name($name)
 {
     global $transaction;
     if ($this->sample_id and $this->sample and $name) {
         $transaction_id = $transaction->begin();
         $folder_id = SampleFolder::get_folder_by_sample_id($this->sample_id);
         $folder = Folder::get_instance($folder_id);
         $folder_name = $name . " (" . $this->get_formatted_id() . ")";
         if ($folder->set_name($folder_name) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         }
         if ($this->sample->set_name($name) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         } else {
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 20
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserFolderCreateEvent or $event_object instanceof GroupFolderCreateEvent or $event_object instanceof OrganisationUnitFolderCreateEvent or $event_object instanceof SampleFolderCreateEvent or $event_object instanceof ProjectFolderCreateEvent) {
         $sample_virtual_folder = new SampleVirtualFolder(null);
         if (($virtual_folder_id = $sample_virtual_folder->create($event_object->get_folder_id(), "samples")) == null) {
             return false;
         }
         $sample_virtual_folder = new SampleVirtualFolder($virtual_folder_id);
         if ($sample_virtual_folder->set_sample_vfolder() == false) {
             return false;
         }
     }
     if ($event_object instanceof VirtualFolderDeleteEvent) {
         $sample_virtual_folder = new SampleVirtualFolder($event_object->get_virtual_folder_id());
         if ($sample_virtual_folder->is_sample_vfolder() == true) {
             $virtual_folder_is_sample = new VirtualFolderIsSample_Access($event_object->get_virtual_folder_id());
             if ($virtual_folder_is_sample->delete() == false) {
                 return false;
             }
         }
     }
     if ($event_object instanceof SampleItemLinkEvent or $event_object instanceof ProjectItemLinkEvent) {
         if (($sample_id = Sample::get_entry_by_item_id($event_object->get_item_id())) != null) {
             $sample_folder_id = SampleFolder::get_folder_by_sample_id($sample_id);
             $folder = Folder::get_instance($event_object->get_folder_id());
             $child_array = $folder->get_children();
             if (is_array($child_array) and count($child_array) >= 1) {
                 foreach ($child_array as $key => $value) {
                     if (($virtual_folder_id = VirtualFolder::get_virtual_folder_id_by_data_entity_id($value)) != null) {
                         $sample_virtual_folder = new SampleVirtualFolder($virtual_folder_id);
                         if ($sample_virtual_folder->is_sample_vfolder() == true) {
                             if ($sample_virtual_folder->link_folder($sample_folder_id) == false) {
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 21
0
 /**
  * @param string $alias
  * @throws SampleSecurityAccessDeniedException
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  * @throws BaseModuleDialogNotFoundException
  * @throws ItemAddIOClassNotFoundException
  * @throws ItemAddIOFileNotFoundException
  * @throws ItemHandlerClassNotFoundException
  * @throws ItemPositionIDMissingException
  * @throws ItemParentIDMissingException
  * @throws ItemParentTypeMissingException
  */
 public static function io_handler($alias)
 {
     global $sample_security, $session, $transaction;
     if ($_GET['sample_id']) {
         $sample_security = new SampleSecurity($_GET['sample_id']);
         require_once "io/sample_common.io.php";
         SampleCommon_IO::tab_header();
     } else {
         $sample_security = new SampleSecurity(null);
     }
     switch ($_GET['run']) {
         case "new":
         case "new_subsample":
             require_once "io/sample.io.php";
             SampleIO::create();
             break;
         case "clone":
             require_once "io/sample.io.php";
             SampleIO::clone_sample();
             break;
         case "organ_unit":
             require_once "io/sample.io.php";
             SampleIO::list_organisation_unit_related_samples();
             break;
         case "detail":
             require_once "io/sample.io.php";
             SampleIO::detail();
             break;
         case "move":
             require_once "io/sample.io.php";
             SampleIO::move();
             break;
         case "set_availability":
             require_once "io/sample.io.php";
             SampleIO::set_availability();
             break;
         case "location_history":
             require_once "io/sample.io.php";
             SampleIO::location_history();
             break;
             // Administration
         // Administration
         case "delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::delete();
             break;
         case "rename":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::rename();
             break;
         case "admin_permission_user":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission();
             break;
         case "admin_permission_user_add":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission_add();
             break;
         case "admin_permission_user_delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission_delete();
             break;
         case "admin_permission_ou":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission();
             break;
         case "admin_permission_ou_add":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission_add();
             break;
         case "admin_permission_ou_delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission_delete();
             break;
             // Item Lister
         // Item Lister
         case "item_list":
             if ($sample_security->is_access(1, false) == true) {
                 if ($_GET['dialog']) {
                     if ($_GET['dialog'] == "data") {
                         $path_stack_array = array();
                         $folder_id = SampleFolder::get_folder_by_sample_id($_GET['sample_id']);
                         $folder = Folder::get_instance($folder_id);
                         $init_array = $folder->get_object_id_path();
                         foreach ($init_array as $key => $value) {
                             $temp_array = array();
                             $temp_array['virtual'] = false;
                             $temp_array['id'] = $value;
                             array_unshift($path_stack_array, $temp_array);
                         }
                         if (!$_GET['folder_id']) {
                             $session->write_value("stack_array", $path_stack_array, true);
                         }
                     }
                     $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_list", $_GET['dialog']);
                     if (file_exists($module_dialog['class_path'])) {
                         require_once $module_dialog['class_path'];
                         if (class_exists($module_dialog['class'])) {
                             if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                 $module_dialog['class']::$module_dialog['method']("sample", $_GET['sample_id'], true, false);
                             } else {
                                 throw new BaseModuleDialogMethodNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogClassNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogFileNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
         case "item_add":
         case "item_edit":
             if ($sample_security->is_access(2, false) == true) {
                 if ($_GET['dialog']) {
                     if ($_GET['run'] == "item_add") {
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']);
                     } elseif ($_GET['run'] == "item_edit") {
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']);
                     }
                     if (is_array($module_dialog) and $module_dialog['class_path']) {
                         if (file_exists($module_dialog['class_path'])) {
                             require_once $module_dialog['class_path'];
                             if (class_exists($module_dialog['class'])) {
                                 if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                     $sample_item = new SampleItem($_GET['sample_id']);
                                     $sample_item->set_gid($_GET['key']);
                                     $description_required = $sample_item->is_description_required();
                                     $keywords_required = $sample_item->is_keywords_required();
                                     if ($description_required and !$_POST['description'] and !$_GET['idk_unique_id'] or $keywords_required and !$_POST['keywords'] and !$_GET['idk_unique_id']) {
                                         require_once "core/modules/item/io/item.io.php";
                                         ItemIO::information(http_build_query($_GET), $description_required, $keywords_required);
                                     } else {
                                         $sample = new Sample($_GET['sample_id']);
                                         $current_requirements = $sample->get_requirements();
                                         if ($_GET['run'] == "item_add") {
                                             $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['type_id'], $current_requirements[$_GET['key']]['category_id'], "Sample", $_GET['sample_id'], $_GET['key']);
                                         } elseif ($_GET['run'] == "item_edit") {
                                             $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['fulfilled'][0]['item_id']);
                                         }
                                     }
                                 } else {
                                     throw new BaseModuleDialogMethodNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogClassNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogFileNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Sub Item Add
         // Sub Item Add
         case "sub_item_add":
         case "sub_item_edit":
             if ($sample_security->is_access(2, false) == true) {
                 if ($_GET['parent']) {
                     if (is_numeric($_GET['parent_id'])) {
                         if (is_numeric($_GET['key'])) {
                             $item_handling_class = Item::get_handling_class_by_type($_GET['parent']);
                             if (class_exists($item_handling_class)) {
                                 $item_io_handling_class = $item_handling_class::get_item_add_io_handling_class();
                                 if (file_exists("core/modules/" . $item_io_handling_class[0])) {
                                     require_once "core/modules/" . $item_io_handling_class[0];
                                     if (class_exists($item_io_handling_class[1])) {
                                         if ($_GET['run'] == "sub_item_add") {
                                             $item_io_handling_class[1]::item_add_edit_handler("add");
                                         } else {
                                             $item_io_handling_class[1]::item_add_edit_handler("edit");
                                         }
                                     } else {
                                         throw new ItemAddIOClassNotFoundException();
                                     }
                                 } else {
                                     throw new ItemAddIOFileNotFoundException();
                                 }
                             } else {
                                 throw new ItemHandlerClassNotFoundException();
                             }
                         } else {
                             throw new ItemPositionIDMissingException();
                         }
                     } else {
                         throw new ItemParentIDMissingException();
                     }
                 } else {
                     throw new ItemParentTypeMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Parent Item Lister
         // Parent Item Lister
         case "parent_item_list":
             if ($sample_security->is_access(1, false) == true) {
                 if ($_GET['dialog']) {
                     $sample = new Sample($_GET['sample_id']);
                     $item_id = $sample->get_item_id();
                     $module_dialog = ModuleDialog::get_by_type_and_internal_name("parent_item_list", $_GET['dialog']);
                     if (file_exists($module_dialog['class_path'])) {
                         require_once $module_dialog['class_path'];
                         if (class_exists($module_dialog['class'])) {
                             if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                 $module_dialog['class']::$module_dialog['method']($item_id);
                             } else {
                                 throw new BaseModuleDialogMethodNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogClassNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogFileNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Common Dialogs
         // Common Dialogs
         case "common_dialog":
             require_once "core/modules/base/common.request.php";
             CommonRequest::common_dialog();
             break;
         default:
             require_once "io/sample.io.php";
             SampleIO::list_user_related_samples();
             break;
     }
 }
Exemplo n.º 22
0
 /**
  * @param integer $folder_id
  * @return string
  * @throws DataSecurityAccessDeniedException
  */
 private static function delete_folder($folder_id)
 {
     $folder = Folder::get_instance($folder_id);
     if ($folder->can_command_folder()) {
         $folder->delete(true, true);
         return "1";
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Exemplo n.º 23
0
 /**
  * @see DataPathInterface::delete_stack()
  */
 public function delete_stack($reinit = false)
 {
     global $session;
     $session->delete_value("stack_array");
     if ($reinit == true) {
         $folder_id = UserFolder::get_folder_by_user_id($session->get_user_id());
         $folder = Folder::get_instance($folder_id);
         $this->init_stack($folder_id);
         $this->path = $folder->get_object_path();
         $this->folder_id = $folder_id;
         $this->virtual_folder_id = null;
         return $folder_id;
     } else {
         return -1;
     }
 }
Exemplo n.º 24
0
 /**
  * @see VirtualFolderInterface::create()
  * @param integer $folder_id
  * @param string $name
  * @return integer
  * @throws VirtualFolderCreateFailedException
  * @throws VirtualFolderCreateFolderNotFoundException
  * @throws VirtualFolderCreateIDMissingException
  */
 public final function create($folder_id, $name)
 {
     global $transaction;
     if (is_numeric($folder_id) and $name) {
         $transaction_id = $transaction->begin();
         try {
             $folder = Folder::get_instance($folder_id);
             if ($folder->exist_folder() == false) {
                 throw new VirtualFolderCreateFolderNotFoundException();
             }
             $data_entity_id = parent::create(1, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             if (($vfolder_id = $this->virtual_folder->create($data_entity_id, $name)) == null) {
                 throw new VirtualFolderCreateFailedException();
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($vfolder_id);
         return $vfolder_id;
     } else {
         throw new VirtualFolderCreateIDMissingException();
     }
 }
Exemplo n.º 25
0
 /**
  * @return object
  */
 private function open_image()
 {
     if ($this->file_id) {
         $file = File::get_instance($this->file_id);
         if ($this->internal_revision) {
             $file->open_internal_revision($this->internal_revision);
         }
         if ($file->is_read_access() == true) {
             $folder = Folder::get_instance($file->get_parent_folder_id());
             $folder_path = $folder->get_path();
             $extension_array = explode(".", $file->get_name());
             $extension_array_length = substr_count($file->get_name(), ".");
             $file_path = constant("BASE_DIR") . "/" . $folder_path . "/" . $file->get_data_entity_id() . "-" . $file->get_internal_revision() . "." . $extension_array[$extension_array_length];
             if (file_exists($file_path)) {
                 try {
                     return new Imagick($file_path);
                 } catch (ImagickException $e) {
                     die("Unsupported File or Internal Error");
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
 /**
  * @param string $folder_id
  * @return string
  * @throws DataSecurityAccessDeniedException
  */
 public static function add_file($folder_id)
 {
     $parent_folder = Folder::get_instance($folder_id);
     if ($parent_folder->is_write_access()) {
         $paramquery = array();
         $unique_id = uniqid();
         $paramquery['session_id'] = $_GET['session_id'];
         $paramquery['folder_id'] = $folder_id;
         $paramquery['unique_id'] = $unique_id;
         $params = http_build_query($paramquery);
         $template = new HTMLTemplate("data/file_upload_window.html");
         $template->set_var("params", $params);
         $template->set_var("unique_id", $unique_id);
         $template->set_var("session_id", $_GET['session_id']);
         $button_handler_template = new JSTemplate("data/js/file_upload_window.js");
         $button_handler = $button_handler_template->get_string();
         $button_handler_caption = "Add";
         $html_caption = "Add File";
         $html = $template->get_string();
         $additional_script_template = new JSTemplate("data/js/file_upload_window_additional.js");
         $additional_script_template->set_var("session_id", $_GET['session_id']);
         $additional_script_template->set_var("unique_id", $unique_id);
         $additional_script = $additional_script_template->get_string();
         $array = array("content" => $html, "content_caption" => $html_caption, "handler" => $button_handler, "handler_caption" => $button_handler_caption, "additional_script" => $additional_script);
         return json_encode($array);
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Exemplo n.º 27
0
 /**
  * @see FileInterface::get_file_content()
  * @return string
  */
 public function get_file_content()
 {
     if ($this->file_id) {
         $folder = Folder::get_instance($this->get_parent_folder_id());
         $extension_array = explode(".", $this->file_version->get_name());
         $extension_array_length = substr_count($this->file_version->get_name(), ".");
         if ($extension_array_length == 0) {
             $extension = "";
         } else {
             $extension = "." . $extension_array[$extension_array_length];
         }
         $path = constant("BASE_DIR") . "/" . $folder->get_path() . "/" . $this->data_entity_id . "-" . $this->file_version->get_internal_revision() . "" . $extension . "";
         $size = filesize($path);
         $handle = fopen($path, "r");
         $content = fread($handle, $size);
         return $content;
     } else {
         return null;
     }
 }