function populate_row($row) { $row["view"] = "display"; $row["folder"] = 0; if ($pos = strpos($row["url"], "?")) { $url = array(); parse_str(substr($row["url"], $pos + 1), $url); $row = array_merge($row, $url); } $row["path"] = modify::getpath($row["folder"]); return $row; }
private static function _html_vertical() { $url = self::_url_folder(); $path = modify::getpath($GLOBALS["sel_folder"]["id"]); $output = "<html><head>\n <title>Simple Groupware & CMS - " . $path . "</title>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n <link rel='alternate' type='application/atom+xml' title='Atom-Feed' href='" . $url . "&export=rss'>\n <meta name='generator' content='Simple Groupware' />\n <style>\n\th2, pre, img, p, div {margin:0px; padding:0px; border:0px; border-spacing:0px;}\n body,table {font-family: Arial; font-size: 12px; width:99%;}\n table {border-top:1px solid #666; border-left:1px solid #666;}\n td {border-right:1px solid #666; border-bottom:1px solid #666; vertical-align:top;}\n\ta {text-decoration:none;}\n\ta:hover {text-decoration:underline;}\n\t.show .hide_field {visibility:visible; text-decoration:none;}\n\t.hide .hide_field {visibility:hidden;}\n </style>\n <script>\n\tfunction hide_column(id) {\n\t var objs = document.getElementsByClassName('col'+id);\n\t for (var i=0; i<objs.length; i++) objs[i].style.display='none';\n\t}\n </script>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n </head>\n <body class='hide'>\n "; $data = self::_build_data(true); $output .= "<a href='" . $url . "' target='_blank'>" . $path . "</a><br/><br/>"; if (count($data) > 0) { foreach ($data as $asset) { $output .= "<table cellpadding='4' cellspacing='0' class='sgs_table'>"; $i = 0; foreach ($asset as $aval) { if (!isset($aval["filter"]) or $aval["filter"] == "") { continue; } $output .= "<tr class='col" . $i . "'>"; $output .= "<td style='width:20%;' onmouseover='document.body.className=\"show\";' onmouseout='document.body.className=\"hide\";'>"; $output .= "<b>" . q($aval["name"]) . "</b>"; $output .= " <a title='{t}Hide{/t}' class='hide_field' href='javascript:hide_column(" . $i . ");'>–</a></td>"; $data = self::_html_quote($aval["filter"], $aval["type"]); if (trim($data) == "") { $data = " "; } else { $data = self::_html_link($data, $aval); } $output .= "<td>" . $data . "</td>"; $output .= "</tr>"; $i++; } $output .= "</table><br>"; } } return $output . "</body></html>"; }
static function delete($folder) { $row = db_select_first("simple_sys_tree", array("id", "rgt", "lft", "ftitle", "parent"), "id=@id@", "", array("id" => $folder)); $rows = array(); if (!empty($row["id"])) { $rows = db_select("simple_sys_tree", array("id", "ftype"), "lft between @left@ and @right@", "lft asc", "", array("left" => $row["lft"], "right" => $row["rgt"])); } if (!is_array($rows) or count($rows) == 0) { return ""; } if (!folder_in_trash($folder)) { $trash = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "trash")); if (empty($trash)) { exit("{t}Error{/t}: {t}Trash folder not found.{/t}"); } $id = self::create(sys_date("{t}m/d/Y{/t}"), "blank", "", $trash, true); $old_path = modify::getpath($folder); if (!self::move($row["id"], $id, true)) { exit("{t}The folder cannot be deleted.{/t}"); } $data = array("rread_users" => "", "rread_groups" => "", "rwrite_users" => "", "rwrite_groups" => "", "radmin_users" => "", "radmin_groups" => "", "rexception_users" => "", "rexception_groups" => "", "anchor" => ""); $data["history"] = sprintf("{t}Item deleted by %s at %s{/t}\n", $_SESSION["username"], sys_date("{t}m/d/y g:i:s a{/t}")); foreach ($rows as $folder) { db_update("simple_sys_tree", $data, array("id=@id@"), array("id" => $folder["id"])); } db_update("simple_sys_tree", array("history" => "{t}Origin{/t}: " . $old_path . "\n"), array("id=@id@"), array("id" => $rows[0]["id"])); sys_log_stat("deleted_folders", count($rows)); } else { foreach ($rows as $folder) { if ($folder["ftype"] != "sys_tree") { $schema_data = db_get_schema(sys_find_module($folder["ftype"])); $tname = $schema_data["att"]["NAME"]; if (!strpos($tname, "_nodb_")) { $delete_fields = array(); foreach ($schema_data["fields"] as $key => $field) { if ($field["SIMPLE_TYPE"] == "files") { $delete_fields[] = $key; } } if (count($delete_fields) > 0) { $data = db_select($tname, $delete_fields, "folder=@folder@", "created asc", "", array("folder" => $folder["id"])); if (is_array($data) and count($data) > 0) { foreach ($data as $ditem) { foreach ($delete_fields as $field) { $files = explode("|", $ditem[$field]); sys_unlink($files); } } } } db_delete($tname, array("folder=@folder@"), array("folder" => $folder["id"])); } } db_search_delete("simple_sys_tree", $folder["id"], $folder["id"]); db_search_delete_folder($folder["id"]); db_delete("simple_sys_tree", array("id=@id@"), array("id" => $folder["id"])); } db_update_subfolder_count($row["parent"]); } $folder = $row["id"]; if (isset($_SESSION["folder_states"][$folder])) { foreach ($_SESSION["folder_states"][$folder] as $child) { unset($_SESSION["folder_states"][$child]); } unset($_SESSION["folder_states"][$folder]); } return $row["parent"]; }
static function folder_get_category($type, $folder, $folders) { $where = array("ftype=@type@", "id!=@id@", $_SESSION["permission_sql_read"]); $vars = array("type" => $type, "id" => $folder); $rows = db_select("simple_sys_tree", "id", $where, "lft asc", "200", $vars); if (is_array($rows) and count($rows) > 0) { foreach ($rows as $key => $row) { $rows[$key]["path"] = modify::getpath($row["id"]); } } $tpl = new template(); $tpl->items = $rows; $tpl->folder = $folder; $tpl->folders = $folders; $tpl->style = $_SESSION["theme"]; return $tpl->render("templates/ajax_folder_categories.php"); }
static function runxml($id, $data, $params) { list($file, $parent_anchor) = $params; $home = folder_from_path("^" . $parent_anchor); if (!empty($home) and file_exists(sys_custom($file))) { sys_notification(sprintf("{t}Processing %s ...{/t}", $file)); $folder = folders::create_default_folders($file, $home, false, $data); sys_notification(sprintf("{t}Folder structure created.{/t} (%s)", modify::getpath($folder) . " / ")); } return ""; }