本文整理汇总了PHP中Folder::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::get_instance方法的具体用法?PHP Folder::get_instance怎么用?PHP Folder::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
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);
}
}
}
示例2: __construct
/**
* @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;
}
}
示例3: io_handler
//.........这里部分代码省略.........
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();
}
示例4: create
/**
* @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();
}
}
示例5: __construct
/**
* @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;
}
}
}
示例6: get_browser_menu
/**
* @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);
}
示例7: change_permission
/**
* @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, '', '&');
if ($data_permission->set_permission_array($permissions) == true) {
return "1";
} else {
return "0";
}
} else {
throw new DataSecurityAccessDeniedException();
}
}
示例8: set_name
/**
* @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;
}
}
示例9: count_data_browser_array
/**
* @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
}
}
示例10: upload
/**
* @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, '', '&');
$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();
}
}
示例11: init
/**
* 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;
}
}
}
示例12: create
/**
* @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();
}
}
示例13: get_children
/**
* @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, '', '&');
$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);
}
}
示例14: search
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();
}
}
示例15: move_folder
/**
* @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;
}
}