Example #1
1
 public function upgrade()
 {
     if (php_sapi_name() == "cli") {
         // @todo this may screw up some module installers, but we don't have a better answer at
         // this time.
         $_SERVER["HTTP_HOST"] = "example.com";
     } else {
         if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
     }
     // Upgrade gallery and user first
     module::install("gallery");
     module::install("user");
     // Then upgrade the rest
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             module::install($id);
         }
     }
     if (php_sapi_name() == "cli") {
         print "Upgrade complete\n";
     } else {
         url::redirect("upgrader?done=1");
     }
 }
 function save($album_id)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $album_id);
     access::required("edit", $album);
     if (Input::instance()->post("save")) {
         $titles = Input::instance()->post("title");
         $descriptions = Input::instance()->post("description");
         $filenames = Input::instance()->post("filename");
         $internetaddresses = Input::instance()->post("internetaddress");
         $tags = Input::instance()->post("tags");
         $enable_tags = module::is_active("tag");
         foreach (array_keys($titles) as $id) {
             $item = ORM::factory("item", $id);
             if ($item->loaded() && access::can("edit", $item)) {
                 $item->title = $titles[$id];
                 $item->description = $descriptions[$id];
                 $item->name = $filenames[$id];
                 $item->slug = $internetaddresses[$id];
                 $item->save();
                 if ($enable_tags) {
                     tag::clear_all($item);
                     foreach (explode(",", $tags[$id]) as $tag_name) {
                         if ($tag_name) {
                             tag::add($item, trim($tag_name));
                         }
                     }
                     tag::compact();
                 }
             }
         }
         message::success(t("Captions saved"));
     }
     url::redirect($album->abs_url());
 }
Example #3
0
 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "random_image":
             // The random_query approach is flawed and doesn't always return a
             // result when there actually is one. Retry a *few* times.
             // @todo Consider another fallback if further optimizations are necessary.
             $image_count = module::get_var("image_block", "image_count");
             $items = array();
             for ($i = 0; $i < $image_count; $i++) {
                 $attempts = 0;
                 $item = null;
                 do {
                     $item = item::random_query()->where("type", "!=", "album")->find_all(1)->current();
                 } while (!$item && $attempts++ < 3);
                 if ($item) {
                     $items[] = $item;
                 }
             }
             if ($items) {
                 $block = new Block();
                 $block->css_id = "g-image-block";
                 $block->title = t2("Random image", "Random images", $image_count);
                 $block->content = new View("image_block_block.html");
                 $block->content->items = $items;
             }
             break;
     }
     return $block;
 }
 static function uninstall()
 {
     // Delete the face mapping table before uninstalling.
     $db = Database::instance();
     $db->query("DROP TABLE IF EXISTS {picasa_faces};");
     module::delete("picasa_faces");
 }
Example #5
0
 private function _dump_database()
 {
     // We now have a clean install with just the packages that we want.  Make sure that the
     // database is clean too.
     $i = 1;
     foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) {
         $blocks = array();
         foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) {
             $blocks[++$i] = $value;
         }
         module::set_var("gallery", "blocks_{$key}", serialize($blocks));
     }
     Database::instance()->query("TRUNCATE {caches}");
     Database::instance()->query("TRUNCATE {sessions}");
     Database::instance()->query("TRUNCATE {logs}");
     db::build()->update("users")->set(array("password" => ""))->where("id", "in", array(1, 2))->execute();
     $dbconfig = Kohana::config('database.default');
     $conn = $dbconfig["connection"];
     $sql_file = DOCROOT . "installer/install.sql";
     if (!is_writable($sql_file)) {
         print "{$sql_file} is not writeable";
         return;
     }
     $command = sprintf("mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > {$sql_file}", escapeshellarg("-h{$conn['host']}"), escapeshellarg("-u{$conn['user']}"), $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "", escapeshellarg($conn['database']));
     exec($command, $output, $status);
     if ($status) {
         print "<pre>";
         print "{$command}\n";
         print "Failed to dump database\n";
         print implode("\n", $output);
         return;
     }
     // Post-process the sql file
     $buf = "";
     $root = ORM::factory("item", 1);
     $root_created_timestamp = $root->created;
     $root_updated_timestamp = $root->updated;
     $table_name = "";
     foreach (file($sql_file) as $line) {
         // Prefix tables
         $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
         if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
             $table_name = $matches[1];
         }
         // Normalize dates
         $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
         if ($table_name != "search_records") {
             $line = preg_replace("/ENGINE=\\S+ /", "", $line);
         }
         // Null out ids in the vars table since it's an auto_increment table and this will result in
         // more stable values so we'll have less churn in install.sql.
         $line = preg_replace("/^INSERT INTO {vars} VALUES \\(\\d+/", "INSERT INTO {vars} VALUES (NULL", $line);
         $buf .= $line;
     }
     $fd = fopen($sql_file, "wb");
     fwrite($fd, $buf);
     fclose($fd);
 }
Example #6
0
 static function photo_menu($menu, $theme)
 {
     if (module::get_var("ecard", "location") == "top") {
         $item = $theme->item();
         $menu->append(Menu::factory("link")->id("ecard")->label(t("Send as eCard"))->url(url::site("ecard/form_send/{$item->id}"))->css_class("g-dialog-link ui-icon-ecard")->css_id("g-send-ecard"));
     }
 }
Example #7
0
 private function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = Input::instance()->get("page", "1");
     $album_defn = unserialize(module::get_var("dynamic", $album));
     $children_count = $album_defn->limit;
     if (empty($children_count)) {
         $children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all();
     }
     $offset = ($page - 1) * $page_size;
     $max_pages = ceil($children_count / $page_size);
     // Make sure that the page references a valid offset
     if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
         throw new Kohana_404_Exception();
     }
     $template = new Theme_View("page.html", "collection", "dynamic");
     $template->set_global("page", $page);
     $template->set_global("page_size", $page_size);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = t($album_defn->title);
     print $template;
 }
 static function install()
 {
     $db = Database::instance();
     $db->query("CREATE TABLE IF NOT EXISTS {item_links} (\n               `id` int(9) NOT NULL auto_increment,\n               `item_id` int(9) NOT NULL,\n               `url` text default NULL,\n               PRIMARY KEY (`id`),\n               KEY(`item_id`, `id`))\n               DEFAULT CHARSET=utf8;");
     // Set the module's version number.
     module::set_version("item_links", 1);
 }
Example #9
0
 static function admin($menu, $theme)
 {
     $menu->get("settings_menu")->append(Menu::factory("link")->id("akismet")->label(t("Akismet"))->url(url::site("admin/akismet")));
     if (module::get_var("akismet", "api_key")) {
         $menu->get("statistics_menu")->append(Menu::factory("link")->id("akismet")->label(t("Akismet"))->url(url::site("admin/akismet/stats")));
     }
 }
Example #10
0
 public function googlemap($fullsize)
 {
     // Display all tags with GPS coordinates on a google map.
     // Generate a list of GPS coordinates.
     $tagsGPS = ORM::factory("tags_gps")->find_all();
     // Set up and display the actual page.
     //  If fullsize is true, allow the map to take up the entire browser window,
     //  if not, then display the map in the gallery theme.
     if ($fullsize == true) {
         $view = new View("tagsmap_googlemap.html");
         $view->map_fullsize = true;
         // Load in module preferences.
         $view->tags_gps = $tagsGPS;
         $view->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
         $view->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
         $view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
         $view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
         $view->google_map_type = module::get_var("tagsmap", "googlemap_type");
         print $view;
     } else {
         $template = new Theme_View("page.html", "TagsMap");
         $template->page_title = t("Gallery :: Map");
         $template->content = new View("tagsmap_googlemap.html");
         // Load in module preferences.
         $template->content->tags_gps = $tagsGPS;
         $template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
         $template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
         $template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
         $template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
         $template->content->google_map_type = module::get_var("tagsmap", "googlemap_type");
         print $template;
     }
 }
Example #11
0
 /**
  * @see REST_Controller::_update($resource)
  */
 public function _update($photo)
 {
     access::verify_csrf();
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     if ($valid = $form->validate()) {
         if ($form->edit_photo->filename->value != $photo->name) {
             // Make sure that there's not a conflict
             if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_photo->filename->value)->count_records()) {
                 $form->edit_photo->filename->add_error("conflict", 1);
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $photo->title = $form->edit_photo->title->value;
         $photo->description = $form->edit_photo->description->value;
         $photo->rename($form->edit_photo->filename->value);
         $photo->save();
         module::event("photo_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
         print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
Example #12
0
 static function uninstall()
 {
     $db = Database::instance();
     $sql = "SELECT `item_id` FROM {comments}";
     module::event("item_related_update_batch", $sql);
     $db->query("DROP TABLE IF EXISTS {comments};");
 }
Example #13
0
 static function api_key($api_key = null)
 {
     if ($api_key !== null) {
         module::set_var("gallery", "l10n_client_key", $api_key);
     }
     return module::get_var("gallery", "l10n_client_key", "");
 }
Example #14
0
 /**
  * Create a new album.
  * @param integer $parent_id id of parent album
  * @param string  $name the name of this new album (it will become the directory name on disk)
  * @param integer $title the title of the new album
  * @param string  $description (optional) the longer description of this album
  * @return Item_Model
  */
 static function create($parent, $name, $title, $description = null, $owner_id = null)
 {
     if (!$parent->loaded || !$parent->is_album()) {
         throw new Exception("@todo INVALID_PARENT");
     }
     if (strpos($name, "/")) {
         throw new Exception("@todo NAME_CANNOT_CONTAIN_SLASH");
     }
     // We don't allow trailing periods as a security measure
     // ref: http://dev.kohanaphp.com/issues/684
     if (rtrim($name, ".") != $name) {
         throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD");
     }
     $album = ORM::factory("item");
     $album->type = "album";
     $album->title = $title;
     $album->description = $description;
     $album->name = $name;
     $album->owner_id = $owner_id;
     $album->thumb_dirty = 1;
     $album->resize_dirty = 1;
     $album->rand_key = (double) mt_rand() / (double) mt_getrandmax();
     $album->sort_column = "weight";
     $album->sort_order = "ASC";
     while (ORM::factory("item")->where("parent_id", $parent->id)->where("name", $album->name)->find()->id) {
         $album->name = "{$name}-" . rand();
     }
     $album = $album->add_to_parent($parent);
     mkdir($album->file_path());
     mkdir(dirname($album->thumb_path()));
     mkdir(dirname($album->resize_path()));
     module::event("item_created", $album);
     return $album;
 }
Example #15
0
 public function save()
 {
     access::verify_csrf();
     $form = theme::get_edit_form_admin();
     if ($form->validate()) {
         module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
         $thumb_size = $form->edit_theme->thumb_size->value;
         $thumb_dirty = false;
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         $resize_size = $form->edit_theme->resize_size->value;
         $resize_dirty = false;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
             graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "resize_size", $resize_size);
         }
         module::set_var("gallery", "header_text", $form->edit_theme->header_text->value);
         module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
         module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }
Example #16
0
 public function save()
 {
     access::verify_csrf();
     $changes->activate = array();
     $changes->deactivate = array();
     $activated_names = array();
     $deactivated_names = array();
     foreach (module::available() as $module_name => $info) {
         if ($info->locked) {
             continue;
         }
         $desired = $this->input->post($module_name) == 1;
         if ($info->active && !$desired && module::is_active($module_name)) {
             $changes->deactivate[] = $module_name;
             $deactivated_names[] = $info->name;
             module::deactivate($module_name);
         } else {
             if (!$info->active && $desired && !module::is_active($module_name)) {
                 $changes->activate[] = $module_name;
                 $activated_names[] = $info->name;
                 module::install($module_name);
                 module::activate($module_name);
             }
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from a i18n perspective
     if ($activated_names) {
         message::success(t("Activated: %names", array("names" => join(", ", $activated_names))));
     }
     if ($deactivated_names) {
         message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names))));
     }
     url::redirect("admin/modules");
 }
Example #17
0
 function start($id)
 {
     access::verify_csrf();
     $paths = unserialize(module::get_var("server_add", "authorized_paths"));
     $input_files = $this->input->post("path");
     $files = array();
     $total_count = 0;
     foreach (array_keys($paths) as $valid_path) {
         $path_length = strlen($valid_path);
         foreach ($input_files as $key => $path) {
             if ($valid_path != $path && strpos($path, $valid_path) === 0) {
                 $relative_path = substr(dirname($path), $path_length);
                 $name = basename($path);
                 $files[$valid_path][] = array("path" => $relative_path, "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file");
                 $total_count++;
                 unset($input_files[$key]);
             }
         }
     }
     if ($total_count == 0) {
         print json_encode(array("result" => "success", "url" => "", "task" => array("id" => -1, "done" => 1, "percent_complete" => 100, "status" => t("No Eligible files, import cancelled"))));
         return;
     }
     $task_def = Task_Definition::factory()->callback("server_add_task::add_from_server")->description(t("Add photos or movies from the local server"))->name(t("Add from server"));
     $task = task::create($task_def, array("item_id" => $id, "next_path" => 0, "files" => $files, "counter" => 0, "position" => 0, "total" => $total_count));
     batch::start();
     print json_encode(array("result" => "started", "url" => url::site("server_add/add_photo/{$task->id}?csrf=" . access::csrf_token()), "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
 }
Example #18
0
 static function required($perm_name, $item)
 {
     // Original code from the required function in modules/gallery/helpers/access.php.
     if (!access::can($perm_name, $item)) {
         if ($perm_name == "view") {
             // Treat as if the item didn't exist, don't leak any information.
             throw new Kohana_404_Exception();
         } else {
             access::forbidden();
         }
         // Begin rWatcher modifications.
         //   Throw a 404 error when a user attempts to access a protected item,
         //   unless the password has been provided, or the user is the item's owner.
     } elseif (module::get_var("albumpassword", "hideonly") == false) {
         $item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
         if (count($item_protected) > 0) {
             $existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
             if ($existing_password->loaded()) {
                 if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
                     throw new Kohana_404_Exception();
                 }
             }
         }
     }
 }
Example #19
0
 private function _get_admin_form()
 {
     $form = new Forge("admin/star/save", "", "post", array("id" => "g-star-admin-form"));
     $form->dropdown("show")->label(t("Default to showing..."))->options(array(0 => "All", 1 => "Starred"))->selected(module::get_var("star", "show"));
     $form->submit("save")->value(t("Save"));
     return $form;
 }
 public function save($module_name, $var_name)
 {
     access::verify_csrf();
     module::set_var($module_name, $var_name, Input::instance()->post("value"));
     message::success(t("Saved value for %var (%module_name)", array("var" => $var_name, "module_name" => $module_name)));
     json::reply(array("result" => "success"));
 }
Example #21
0
 public function show($tag_id)
 {
     $tag = ORM::factory("tag", $tag_id);
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = (int) Input::instance()->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             url::redirect($album->abs_url("page={$max_pages}"));
         }
     }
     $template = new Theme_View("page.html", "collection", "tag");
     $template->set_global("page", $page);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("page_size", $page_size);
     $template->set_global("tag", $tag);
     $template->set_global("children", $tag->items($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = $tag->name;
     print $template;
 }
 static function movie_menu($menu, $theme)
 {
     // Display embedlinks toolbar icon, if the corresponding setting is enabled.
     if (module::get_var("embedlinks", "ToolbarLinks") == true) {
         $menu->append(Menu::factory("link")->id("embedlinks")->label(t("Link to this page"))->url(url::site("embedlinks/showlinks/" . $theme->item()->id))->css_class("g-dialog-link")->css_id("g-embedlinks-link"));
     }
 }
Example #23
0
 private function _dump_database()
 {
     // We now have a clean install with just the packages that we want.  Make sure that the
     // database is clean too.
     $i = 1;
     foreach (array("blocks_dashboard_sidebar", "blocks_dashboard_center") as $key) {
         $blocks = array();
         foreach (unserialize(module::get_var("gallery", $key)) as $rnd => $value) {
             $blocks[++$i] = $value;
         }
         module::set_var("gallery", $key, serialize($blocks));
     }
     $db = Database::instance();
     $db->query("TRUNCATE {sessions}");
     $db->query("TRUNCATE {logs}");
     $db->query("DELETE FROM {vars} WHERE `module_name` = 'core' AND `name` = '_cache'");
     $db->update("users", array("password" => ""), array("id" => 1));
     $db->update("users", array("password" => ""), array("id" => 2));
     $dbconfig = Kohana::config('database.default');
     $conn = $dbconfig["connection"];
     $pass = $conn["pass"] ? "-p{$conn['pass']}" : "";
     $sql_file = DOCROOT . "installer/install.sql";
     if (!is_writable($sql_file)) {
         print "{$sql_file} is not writeable";
         return;
     }
     $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} {$pass} {$conn['database']} > {$sql_file}";
     exec($command, $output, $status);
     if ($status) {
         print "<pre>";
         print "{$command}\n";
         print "Failed to dump database\n";
         print implode("\n", $output);
         return;
     }
     // Post-process the sql file
     $buf = "";
     $root = ORM::factory("item", 1);
     $root_created_timestamp = $root->created;
     $root_updated_timestamp = $root->updated;
     $table_name = "";
     foreach (file($sql_file) as $line) {
         // Prefix tables
         $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
         if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
             $table_name = $matches[1];
         }
         // Normalize dates
         $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
         if ($table_name != "search_records") {
             $line = preg_replace("/ENGINE=\\S+ /", "", $line);
         }
         $buf .= $line;
     }
     $fd = fopen($sql_file, "wb");
     fwrite($fd, $buf);
     fclose($fd);
 }
 public function saveprefs()
 {
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     $form = $this->_get_admin_form();
     if ($form->validate()) {
         Kohana_Log::add("error", print_r($form, 1));
         module::set_var("tag_albums", "tag_page_title", $form->Tag_Albums_Tag_Sort->tag_page_title->value);
         module::set_var("tag_albums", "tag_index", $form->Tag_Albums_Tag_Sort->tag_index->value);
         module::set_var("tag_albums", "tag_index_scope", count($form->Tag_Albums_Tag_Sort->tag_index_scope->value));
         module::set_var("tag_albums", "tag_index_filter_top", count($form->Tag_Albums_Tag_Sort->tag_index_filter_top->value));
         module::set_var("tag_albums", "tag_index_filter_bottom", count($form->Tag_Albums_Tag_Sort->tag_index_filter_bottom->value));
         module::set_var("tag_albums", "tag_sort_by", $form->Tag_Albums_Tag_Sort->tag_sort_by->value);
         module::set_var("tag_albums", "tag_sort_direction", $form->Tag_Albums_Tag_Sort->tag_sort_direction->value);
         module::set_var("tag_albums", "subalbum_sort_by", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_by->value);
         module::set_var("tag_albums", "subalbum_sort_direction", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_direction->value);
         message::success(t("Your settings have been saved."));
         url::redirect("admin/tag_albums");
     }
     // Else show the page with errors
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_tag_albums.html");
     $view->content->tag_albums_form = $form;
     print $view;
 }
Example #25
0
 public function print_proxy($site_key, $file_id)
 {
     // This function retrieves the full-sized image for fotomoto.
     //   As this function by-passes normal Gallery security, a private
     //   site-key is used to try and prevent people other then fotomoto
     //   from finding the URL.
     // If the site key doesn't match, display a 404 error.
     if ($site_key != module::get_var("fotomotorw", "fotomoto_private_key")) {
         throw new Kohana_404_Exception();
     }
     // Load the photo from the provided id.  If the id# is invalid, display a 404 error.
     $item = ORM::factory("item", $file_id);
     if (!$item->loaded()) {
         throw new Kohana_404_Exception();
     }
     // If the image file doesn't exist for some reason, display a 404 error.
     if (!file_exists($item->file_path())) {
         throw new Kohana_404_Exception();
     }
     // Display the image.
     header("Content-Type: {$item->mime_type}");
     Kohana::close_buffers(false);
     $fd = fopen($item->file_path(), "rb");
     fpassthru($fd);
     fclose($fd);
 }
Example #26
0
 static function install()
 {
     $db = Database::instance();
     $db->query("CREATE TABLE IF NOT EXISTS {watermarks} (\n                 `id` int(9) NOT NULL auto_increment,\n                 `name` varchar(32) NOT NULL,\n                 `width` int(9) NOT NULL,\n                 `height` int(9) NOT NULL,\n                 `active` boolean default 0,\n                 `position` boolean default 0,\n                 `mime_type` varchar(64) default NULL,\n                 PRIMARY KEY (`id`),\n                 UNIQUE KEY(`name`))\n               DEFAULT CHARSET=utf8;");
     @mkdir(VARPATH . "modules/watermark");
     module::set_version("watermark", 1);
 }
Example #27
0
 static function install()
 {
     $version = module::get_version("akismet");
     if ($version == 0) {
         module::set_version("akismet", 1);
     }
 }
Example #28
0
 static function install()
 {
     $version = module::get_version("recaptcha");
     if ($version == 0) {
         module::set_version("recaptcha", 1);
     }
 }
Example #29
0
 private function _get_admin_form()
 {
     $form = new Forge("admin/hide/save", "", "post", array("id" => "g-hide-admin-form"));
     $form->dropdown("access_permissions")->label(t("Who can see hidden items?"))->options(hide::get_groups_as_dropdown_options())->selected(module::get_var("hide", "access_permissions"));
     $form->submit("save")->value(t("Save"));
     return $form;
 }
Example #30
0
 /**
  * constructor
  */
 public function __construct($moduleInfo)
 {
     global $My_Kernel, $My_Sql;
     parent::__construct($moduleInfo);
     //$this->_newsModel = $My_Kernel->getClass('news', $My_Kernel->getSystemDbHandler());
     $this->_loadModel($My_Kernel->getSystemDbHandler());
 }