/** * @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 } }
/** * @see ProjectPermissionInterface::set_permission() * @param integer $permission * @return bool */ public function set_permission($permission) { if (is_numeric($permission) and $this->project_permission and $this->permission_id) { if (($user_id = $this->project_permission->get_user_id()) != null) { $current_permission_string = strrev(decbin($this->project_permission->get_permission())); $new_permission_string = strrev(decbin($permission)); $project_folder_id = ProjectFolder::get_folder_by_project_id($this->project_permission->get_project_id()); if ($current_permission_string[2] == 0 and $current_permission_string[3] == 0 and $current_permission_string[7] == 0) { $folder_id = UserFolder::get_folder_by_user_id($user_id); $virtual_folder = new VirtualFolder(null); $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id); foreach ($virtual_folder_array as $key => $value) { $virtual_folder = new ProjectVirtualFolder($value); if ($virtual_folder->is_project_vfolder() == true) { $virtual_folder_id = $value; } } if (is_numeric($virtual_folder_id)) { $virtual_folder = new VirtualFolder($virtual_folder_id); if ($virtual_folder->link_folder($project_folder_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return null; } } } } return $this->project_permission->set_permission($permission); } else { return false; } }
/** * @see SampleSecurityInterface::delete_user() * @param integer $entry_id * @return bool */ public function delete_user($entry_id) { global $transaction; if ($this->sample_id and is_numeric($entry_id)) { $transaction_id = $transaction->begin(); $sample_has_user = new SampleHasUser_Access($entry_id); $write = $sample_has_user->get_write(); $user_id = $sample_has_user->get_user_id(); $success = $sample_has_user->delete(); if ($success == true) { if ($write == true) { $sample_folder_id = SampleFolder::get_folder_by_sample_id($this->sample_id); $folder_id = UserFolder::get_folder_by_user_id($user_id); $virtual_folder = new VirtualFolder(null); $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id); foreach ($virtual_folder_array as $key => $value) { $virtual_folder = new SampleVirtualFolder($value); if ($virtual_folder->is_sample_vfolder() == true) { $virtual_folder_id = $value; } } if ($virtual_folder_id) { $virtual_folder = new VirtualFolder($virtual_folder_id); if ($virtual_folder->unlink_folder($sample_folder_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } } } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } } else { return false; } }
/** * @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; } }
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, '', '&'); $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, '', '&'); $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(); } }
/** * @see ProjectPermissionUserInterface::delete() * @return bool * @throws ProjectPermissionUserDeleteException * @throws ProjectPermisisonUserDeleteVirtualFolderException */ public function delete() { global $transaction; if ($this->permission_id and $this->project_permission) { $transaction_id = $transaction->begin(); $project_id = $this->project_permission->get_project_id(); $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id); $permission_string = strrev(decbin($this->project_permission->get_permission())); if ($permission_string[2] == 1 or $permission_string[3] == 1 or $permission_string[7] == 1) { if (ProjectPermission_Access::count_entries_with_project_id_and_user_id($project_id, $this->project_permission->get_user_id()) <= 1) { $folder_id = UserFolder::get_folder_by_user_id($this->project_permission->get_user_id()); $virtual_folder = new VirtualFolder(null); $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id); foreach ($virtual_folder_array as $key => $value) { $virtual_folder = new ProjectVirtualFolder($value); if ($virtual_folder->is_project_vfolder() == true) { $virtual_folder_id = $value; } } if ($virtual_folder_id) { $virtual_folder = new VirtualFolder($virtual_folder_id); if ($virtual_folder->unlink_folder($project_folder_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectPermissionUserDeleteVirtualFolderException(); } } } } if (parent::delete() == true) { if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectPermissionUserDeleteException(); } } else { throw new ProjectPermissionUserDeleteException(); } }
/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof UserCreateEvent) { $user_folder = new UserFolder(null); if ($user_folder->create($event_object->get_user_id()) == false) { return false; } } if ($event_object instanceof UserPostDeleteEvent) { $folder_id = UserFolder::get_folder_by_user_id($event_object->get_user_id()); $user_folder = new UserFolder($folder_id); if ($user_folder->delete(true, true) == false) { return false; } } if ($event_object instanceof UserRenameEvent) { $user = new User($event_object->get_user_id()); $user_folder = new UserFolder(self::get_folder_by_user_id($event_object->get_user_id())); if ($user_folder->set_name($user->get_username()) == false) { return false; } } return true; }