summaryrefslogtreecommitdiff
path: root/modules/server_add/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/server_add/helpers')
-rw-r--r--modules/server_add/helpers/server_add.php49
-rw-r--r--modules/server_add/helpers/server_add_event.php42
-rw-r--r--modules/server_add/helpers/server_add_installer.php73
-rw-r--r--modules/server_add/helpers/server_add_theme.php27
4 files changed, 191 insertions, 0 deletions
diff --git a/modules/server_add/helpers/server_add.php b/modules/server_add/helpers/server_add.php
new file mode 100644
index 0000000..5cf08ce
--- /dev/null
+++ b/modules/server_add/helpers/server_add.php
@@ -0,0 +1,49 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class server_add_Core {
+ static function check_config($paths=null) {
+ if ($paths === null) {
+ $paths = unserialize(module::get_var("server_add", "authorized_paths"));
+ }
+ if (empty($paths)) {
+ site_status::warning(
+ t("Server Add needs configuration. <a href=\"%url\">Configure it now!</a>",
+ array("url" => html::mark_clean(url::site("admin/server_add")))),
+ "server_add_configuration");
+ } else {
+ site_status::clear("server_add_configuration");
+ }
+ }
+
+ static function is_valid_path($path) {
+ if (!is_readable($path) || is_link($path)) {
+ return false;
+ }
+
+ $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths"));
+ foreach (array_keys($authorized_paths) as $valid_path) {
+ if (strpos($path, $valid_path) === 0) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/modules/server_add/helpers/server_add_event.php b/modules/server_add/helpers/server_add_event.php
new file mode 100644
index 0000000..a718e2f
--- /dev/null
+++ b/modules/server_add/helpers/server_add_event.php
@@ -0,0 +1,42 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class server_add_event_Core {
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("server_add")
+ ->label(t("Server add"))
+ ->url(url::site("admin/server_add")));
+ }
+
+ static function site_menu($menu, $theme) {
+ $item = $theme->item();
+ $paths = unserialize(module::get_var("server_add", "authorized_paths"));
+
+ if ($item && identity::active_user()->admin && $item->is_album() && !empty($paths) &&
+ is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path())) {
+ $menu->get("add_menu")
+ ->append(Menu::factory("dialog")
+ ->id("server_add")
+ ->label(t("Server add"))
+ ->url(url::site("server_add/browse/$item->id")));
+ }
+ }
+}
diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php
new file mode 100644
index 0000000..b62bbcf
--- /dev/null
+++ b/modules/server_add/helpers/server_add_installer.php
@@ -0,0 +1,73 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class server_add_installer {
+ static function install() {
+ $db = Database::instance();
+ $db->query("CREATE TABLE {server_add_entries} (
+ `id` int(9) NOT NULL auto_increment,
+ `checked` boolean default 0,
+ `is_directory` boolean default 0,
+ `item_id` int(9),
+ `parent_id` int(9),
+ `path` varchar(255) NOT NULL,
+ `task_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`))
+ DEFAULT CHARSET=utf8;");
+ server_add::check_config();
+ }
+
+ static function upgrade($version) {
+ $db = Database::instance();
+ if ($version == 1) {
+ $db->query("CREATE TABLE {server_add_files} (
+ `id` int(9) NOT NULL auto_increment,
+ `task_id` int(9) NOT NULL,
+ `file` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`))
+ DEFAULT CHARSET=utf8;");
+ module::set_version("server_add", $version = 2);
+ }
+
+ if ($version == 2) {
+ $db->query("ALTER TABLE {server_add_files} ADD COLUMN `item_id` int(9)");
+ $db->query("ALTER TABLE {server_add_files} ADD COLUMN `parent_id` int(9)");
+ module::set_version("server_add", $version = 3);
+ }
+
+ if ($version == 3) {
+ $db->query("DROP TABLE {server_add_files}");
+ $db->query("CREATE TABLE {server_add_entries} (
+ `id` int(9) NOT NULL auto_increment,
+ `checked` boolean default 0,
+ `is_directory` boolean default 0,
+ `item_id` int(9),
+ `parent_id` int(9),
+ `path` varchar(255) NOT NULL,
+ `task_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`))
+ DEFAULT CHARSET=utf8;");
+ module::set_version("server_add", $version = 4);
+ }
+ }
+
+ static function deactivate() {
+ site_status::clear("server_add_configuration");
+ }
+}
diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php
new file mode 100644
index 0000000..7dfe658
--- /dev/null
+++ b/modules/server_add/helpers/server_add_theme.php
@@ -0,0 +1,27 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class server_add_theme_Core {
+ static function head($theme) {
+ if (identity::active_user()->admin) {
+ return $theme->css("server_add.css")
+ . $theme->script("server_add.js");
+ }
+ }
+} \ No newline at end of file