/** * Delete a folder * - exit on failure * - mountpoint folders are directly deleted * - database folders are moved to /Workspace/System/Trash/ first * * @param int|string $folder Folder ID or String (/Workspace/.../) * @return empty string */ static function folder_delete($folder) { self::_require_access($folder, "write"); self::tree_close($folder); if (!is_numeric($folder)) { $url = sys_parse_folder($folder); $handler = "lib_" . $url["handler"]; self::require_method("delete_folder", $handler); $return = call_user_func(array($handler, "delete_folder"), $url["mountpoint"], $url["mfolder"]); if ($return == "ok") { return dirname($folder) . "/"; } else { if ($return != "") { exit($return); } } } else { return folders::delete($folder); } return ""; }
function sys_credentials($mfolder, $mountpoint = "") { static $creds = array(); if ($mountpoint != "") { $mountpoint = sys_parse_folder($mountpoint); if (empty($mountpoint["mfolder"])) { return array(); } if ($mfolder == "") { $mfolder = $mountpoint["mfolder"]; } $creds[$mfolder] = array("server" => $mountpoint["mfolder"], "username" => $mountpoint["user"], "password" => $mountpoint["pass"], "port" => $mountpoint["port"], "ssl" => $mountpoint["ssl"], "options" => $mountpoint["options"]); return $mountpoint; } if (!isset($creds[$mfolder]) and isset($_SESSION["permission_sql_read"]) and $mountpoint == "" and $mfolder != "") { $mp = db_select_value("simple_sys_tree", "fmountpoint", array("id=@id@", $_SESSION["permission_sql_read"]), array("id" => $mfolder)); if (!empty($mp)) { sys_credentials($mfolder, $mp); } } if (!isset($creds[$mfolder])) { $creds[$mfolder] = array("server" => "", "username" => "", "password" => "", "port" => "", "ssl" => "", "options" => ""); } return $creds[$mfolder]; }
function __construct($folder, $view, $items = array(), $writeable = true) { // Mountpoint $folders = array($folder); if (!is_numeric($folder)) { $url = sys_parse_folder($folder); $type = "sys_nodb_" . $url["handler"]; $mfolder = $url["mfolder"]; sys_credentials($mfolder); } else { $row = db_select_first("simple_sys_tree", array("ftype", "folders"), "id=@id@", "", array("id" => $folder)); if (empty($row["ftype"])) { throw new Exception("{t}Folder not found.{/t}"); } $type = $row["ftype"]; if ($row["folders"] != "") { $folders = array(); foreach (explode("|", trim($row["folders"], "|")) as $val) { if (empty($val) or !db_get_right($val, $writeable ? "write" : "read", $view)) { continue; } $folders[] = $val; } } $mfolder = ""; } if (isset($_SESSION["disabled_modules"][$type])) { exit("{t}Module disabled.{/t}"); } $this->schema = db_get_schema(sys_find_module($type), $folder, $view); $view = sys_array_shift(array_keys($this->schema["views"])); $this->current_view =& $this->schema["views"][$view]; if (isset($this->current_view["SCHEMA"]) and $this->current_view["SCHEMA"] != "") { $this->schema = db_get_schema(sys_find_module($this->current_view["SCHEMA"]), "", $view); $view = sys_array_shift(array_keys($this->schema["views"])); $this->current_view =& $this->schema["views"][$view]; } $this->folder = $folder; $this->view = $view; $this->fields =& $this->schema["fields"]; $this->att =& $this->schema["att"]; $this->tname = $this->att["NAME"]; $this->where = $this->current_view["SQLWHERE"]; $this->handler = $this->current_view["SQL_HANDLER"]; $this->buttons = $this->current_view["buttons"]; $this->rowvalidates = $this->current_view["rowvalidates"]; $this->rowfilters = $this->current_view["rowfilters"]; $this->current_fields =& $this->current_view["fields"]; $this->notification = true; $this->vars = array("item" => $items, "folder" => $this->folder, "folders" => $folders, "mfolder" => $mfolder); $this->vars_noquote = array(); if (!empty($this->att["ENABLE_ASSET_RIGHTS"])) { if ($writeable) { $this->where[] = "@permission_sql_write_nq@"; } $this->vars_noquote["permission_sql_read_nq"] = $_SESSION["permission_sql_read"]; $this->vars_noquote["permission_sql_write_nq"] = $_SESSION["permission_sql_write"]; } if (is_array($this->where) and count($this->where) > 0) { foreach ($this->where as $key => $val) { $matches = array(); if (!preg_match_all("|@(.*?)@|i", $val, $matches, PREG_SET_ORDER)) { continue; } foreach ($matches as $match) { if (count($match) != 2) { continue; } $wkey = $match[1]; if (empty($this->vars[$wkey]) and empty($this->vars_noquote[$wkey])) { $this->where[$key] = "1=1"; } } } } }