1
0

Merge branch 'master' of github.com:gallery/gallery3-contrib

This commit is contained in:
Bharat Mediratta 2010-06-20 09:55:00 -07:00
commit 76e0a771e7
38 changed files with 1010 additions and 98 deletions

View File

@ -265,7 +265,6 @@ class CalendarView_Controller extends Controller {
$str_year_id = Input::instance()->post("cal_year");
// redirect to the currect page.
url::redirect(url::site("calendarview/calendar/" . $str_year_id . "/" . $str_user_id));
url::redirect(url::site("calendarview/calendar/" . $str_year_id . "/" . $str_user_id, request::protocol()));
}
}

View File

@ -37,7 +37,6 @@ table.calendar caption {
table.calendar th, table.calendar td {
padding: 0.2em;
background: #ffffff;
border: 0px;
}

View File

@ -38,14 +38,32 @@ class calendarview_block_Core {
$display_date = $item->created;
}
// Make sure there are photo's to display.
$day_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, date("n", $display_date), date("j", $display_date), date("Y", $display_date)))
->where("captured", "<", mktime(0, 0, 0, date("n", $display_date), date("j", $display_date)+1, date("Y", $display_date)))
->find_all()
->count();
$month_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, date("n", $display_date), 1, date("Y", $display_date)))
->where("captured", "<", mktime(0, 0, 0, date("n", $display_date)+1, 1, date("Y", $display_date)))
->find_all()
->count();
switch ($block_id) {
case "calendarview_photo":
if ($display_date != "") {
if ( ($display_date != "") && (($day_count > 0) || ($month_count > 0)) ) {
$block = new Block();
$block->css_id = "g-calendarview-sidebar";
$block->title = t("Calendar");
$block->content = new View("calendarview_sidebar.html");
$block->content->date = $display_date;
$block->content->day_count = $day_count;
$block->content->month_count = $month_count;
}
break;
}

View File

@ -1,5 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul>
<? if ($day_count > 0): ?>
<li><a href="<?=url::site("calendarview/day/" . date("Y", $date) . "/-1/" . date("n", $date) . "/" . date("j", $date)); ?>"><?=t("More from"); ?> <?=date("F", $date); ?> <?=date("j", $date); ?><?=date("S", $date); ?></a></li>
<? endif ?>
<? if ($month_count > 0): ?>
<li><a href="<?=url::site("calendarview/month/" . date("Y", $date) . "/-1/" . date("n", $date)); ?>"><?=t("More from"); ?> <?=date("F", $date); ?></a></li>
<? endif ?>
</ul>

View File

@ -0,0 +1,36 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 database_info_block_Core {
static function get_admin_list() {
return array("database_info" => t("Database info"));
}
static function get($block_id) {
$block = new Block();
switch ($block_id) {
case "database_info":
$block->css_id = "g-database-info";
$block->title = t("Database information");
$block->content = new View("admin_block_db.html");
break;
}
return $block;
}
}

View File

@ -0,0 +1,3 @@
name = "Database Info"
description = "View information about your Gallery 3 database on the admin dashboard."
version = 1

View File

@ -0,0 +1,18 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
$db = Database::instance();
$tables = $db->query("SHOW TABLE STATUS");
$database_size = 0;
foreach($tables as $table) {
$database_size += ($table->Data_length + $table->Index_length);
}
$database_size = $database_size / 1024 / 1024;
?>
<ul>
<li>
<?= t("Database size: %dbsize MB", array("dbsize" => number_format($database_size, 2))) ?>
</li>
<li>
<?= t("Number of tables: %dbtables", array("dbtables" => count($tables))) ?>
</li>
</ul>

View File

@ -0,0 +1,105 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 Admin_EXIF_GPS_Controller extends Admin_Controller {
public function index() {
// Generate a new admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_exif_gps.html");
$view->content->exifgps_form = $this->_get_admin_form();
print $view;
}
public function saveprefs() {
// Save user preferences to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Make sure the user filled out the form properly.
$form = $this->_get_admin_form();
if ($form->validate()) {
Kohana_Log::add("error",print_r($form,1));
// Save settings to Gallery's database.
module::set_var("exif_gps", "googlemap_api_key", $form->Global->google_api_key->value);
module::set_var("exif_gps", "sidebar_zoom", $form->Sidebar->sidebar_default_zoom->value);
module::set_var("exif_gps", "sidebar_mapformat", $form->Sidebar->sidebar_mapformat->value);
module::set_var("exif_gps", "sidebar_maptype", $form->Sidebar->sidebar_maptype->value);
module::set_var("exif_gps", "largemap_maptype", $form->LargeMap->largemap_maptype->value);
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your settings have been saved."));
url::redirect("admin/exif_gps");
}
// Else show the page with errors
$view = new Admin_View("admin.html");
$view->content = new View("admin_exif_gps.html");
$view->content->exifgps_form = $form;
print $view;
}
private function _get_admin_form() {
// Make a new Form.
$form = new Forge("admin/exif_gps/saveprefs", "", "post",
array("id" => "g-exif-gps-adminForm"));
// Create group for global settings, like the Maps API Key
$gps_global_group = $form->group("Global")
->label(t("Global Settings"));
$gps_global_group->input("google_api_key")
->label(t("Google Maps API Key"))
->value(module::get_var("exif_gps", "googlemap_api_key"))
->rules("required");
// Create a group for sidebar settings
$gps_sidebar = $form->group("Sidebar")
->label(t("Sidebar Settings"));
$gps_sidebar->input("sidebar_default_zoom")
->label(t("Default Zoom Level"))
->value(module::get_var("exif_gps", "sidebar_zoom"))
->rules("required");
$gps_sidebar->dropdown("sidebar_mapformat")
->label(t("Map Interface"))
->options(array(t("Static"), t("Interactive")))
->selected(module::get_var("exif_gps", "sidebar_mapformat"));
$gps_sidebar->dropdown("sidebar_maptype")
->label(t("Default Map Type"))
->options(array(t("Map"), t("Satellite"),
t("Hybrid"), t("Terrain")))
->selected(module::get_var("exif_gps", "sidebar_maptype"));
// Create a group for map album/user settings
$gps_large_map_group = $form->group("LargeMap")
->label(t("Map Album/User Settings"));
$gps_large_map_group->dropdown("largemap_maptype")
->label(t("Default Map Type"))
->options(array(t("Map"), t("Satellite"),
t("Hybrid"), t("Terrain")))
->selected(module::get_var("exif_gps", "largemap_maptype"));
// Add a save button to the form.
$form->submit("SaveSettings")->value(t("Save"));
// Return the newly generated form.
return $form;
}
}

View File

@ -0,0 +1,78 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 EXIF_GPS_Controller extends Controller {
public function map($map_type, $type_id) {
// Map all items in the specified album or user.
$map_title = "";
if ($map_type == "album") {
// Generate an array of all items in the current album that have exif gps
// coordinates and order by latitude (to group items w/ the same
// coordinates together).
$items = ORM::factory("item", $type_id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants();
$curr_album = ORM::factory("item")->where("id", "=", $type_id)->find_all();
$map_title = $curr_album[0]->name;
} elseif ($map_type == "user") {
// Generate an array of all items uploaded by the current user that
// have exif gps coordinates and order by latitude (to group items
// w/ the same coordinates together).
$items = ORM::factory("item")
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->where("items.owner_id", "=", $type_id)
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->find_all();
$curr_user = ORM::factory("user")->where("id", "=", $type_id)->find_all();
$map_title = $curr_user[0]->full_name . "'s " . t("Photos");
}
// Make a new page.
$template = new Theme_View("page.html", "other", "EXIFMap");
$template->page_title = t("Gallery :: Map");
$template->content = new View("exif_gps_map.html");
if ($map_title == "") {
$template->content->title = t("Map");
} else {
$template->content->title = t("Map of") . " " . $map_title;
}
// Figure out default map type.
$int_map_type = module::get_var("exif_gps", "largemap_maptype");
if ($int_map_type == 0) $map_type = "ROADMAP";
if ($int_map_type == 1) $map_type = "SATELLITE";
if ($int_map_type == 2) $map_type = "HYBRID";
if ($int_map_type == 3) $map_type = "TERRAIN";
$template->content->map_type = $map_type;
// When mapping an album, generate a "return to album" link.
if (isset($curr_album)) $template->content->return_url = url::abs_site("{$curr_album[0]->type}s/{$curr_album[0]->id}");
// Load in module preferences.
$template->content->items = $items;
$template->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
// Display the page.
print $template;
}
}

View File

@ -17,12 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* This is the API for handling exif data.
*/
class exif_gps_Core {
protected static $exif_keys;
static function extract($item) {
@ -52,10 +47,10 @@ class exif_gps_Core {
$record->latitude = str_replace(",", ".", $keys["Latitude"]);
$record->longitude = str_replace(",", ".", $keys["Longitude"]);
// Represent N/S/E/W as postive and negative numbers
if ($keys["Latitude Reference"] == "S") {
if (substr(strtoupper($keys["Latitude Reference"]), 0, 1) == "S") {
$record->latitude = "-" . $record->latitude;
}
if ($keys["Longitude Reference"] == "W") {
if (substr(strtoupper($keys["Longitude Reference"]), 0, 1) == "W") {
$record->longitude = "-" . $record->longitude;
}
$record->save();
@ -74,4 +69,4 @@ class exif_gps_Core {
}
return self::$exif_keys;
}
}
}

View File

@ -19,48 +19,130 @@
*/
class exif_gps_block_Core {
static function get_site_list() {
return array("exif_gps_map" => t("EXIF GPS Map"));
return array("exif_gps_location" => t("EXIF GPS Location"),
"exif_gps_maps" => t("EXIF GPS Maps"));
}
static function get($block_id, $theme) {
$block = "";
// Make sure the current page belongs to an item.
if (!$theme->item()) {
return;
}
switch ($block_id) {
case "exif_gps_map":
// Check and see if the item has exif coordinates associated with it.
$record = ORM::factory("exif_coordinate")->where("item_id", "=", $theme->item->id)->find();
if ($record->loaded()) {
$block = new Block();
$block->css_id = "g-exif-gps-sidebar";
$block->title = t("Location");
$block->content = new View("exif_gps_sidebar.html");
$block->content->latitude = $record->latitude;
$block->content->longitude = $record->longitude;
} elseif (module::is_active("tagsmap") && module::is_active("tag")) {
// If there are no exif coordinates, check for tagsmap coordinates instead.
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", "=", $theme->item->id)
->find_all();
if (count($tagsItem) > 0) {
foreach ($tagsItem as $oneTag) {
$tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $oneTag->id)->find();
if ($tagsGPS->loaded()) {
$block = new Block();
$block->css_id = "g-exif-gps-sidebar";
$block->title = t("Location");
$block->content = new View("exif_gps_sidebar.html");
$block->content->latitude = $tagsGPS->latitude;
$block->content->longitude = $tagsGPS->longitude;
break;
case "exif_gps_maps":
// Display links to a map of the current album and
// a map of the current user.
if ($theme->item()) {
$album_id = "";
$item = $theme->item;
if ($item->is_album()) {
$album_id = $item->id;
} else {
$album_id = $item->parent_id;
}
$curr_user = ORM::factory("user")->where("id", "=", $item->owner_id)->find_all();
$user_name = $curr_user[0]->full_name;
// Make sure there are actually map-able items to display.
$album_items_count = ORM::factory("item", $album_id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants_count();
$user_items_count = ORM::factory("item")
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->where("items.owner_id", "=", $item->owner_id)
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->count_all();
if (($album_items_count > 0) || ($user_items_count > 0)) {
$block = new Block();
$block->css_id = "g-exif-gps-maps";
$block->title = t("Maps");
$block->content = new View("exif_gps_maps_sidebar.html");
$block->content->album_id = $album_id;
$block->content->user_id = $item->owner_id;
$block->content->user_name = $user_name;
$block->content->album_items = $album_items_count;
$block->content->user_items = $user_items_count;
}
}
break;
case "exif_gps_location":
// Look for coordinates to display.
$latitude = "";
$longitude = "";
if ($theme->item()) {
// Check and see if the item has exif coordinates associated with it.
$record = ORM::factory("exif_coordinate")->where("item_id", "=", $theme->item->id)->find();
if ($record->loaded()) {
$latitude = $record->latitude;
$longitude = $record->longitude;
} elseif (module::is_active("tagsmap") && module::is_active("tag")) {
// If there are no exif coordinates, check for tagsmap coordinates instead.
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", "=", $theme->item->id)
->find_all();
if (count($tagsItem) > 0) {
foreach ($tagsItem as $oneTag) {
$tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $oneTag->id)->find();
if ($tagsGPS->loaded()) {
$latitude = $tagsGPS->latitude;
$longitude = $tagsGPS->longitude;
break;
}
}
}
}
} elseif ( ($theme->tag()) && (module::is_active("tagsmap") && module::is_active("tag")) ) {
// If the current page belongs to a tag, check and see if the tag has GPS coordinates.
$tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $theme->tag()->id)->find();
if ($tagsGPS->loaded()) {
$latitude = $tagsGPS->latitude;
$longitude = $tagsGPS->longitude;
}
}
// If coordinates were found, create the block.
if ($latitude != "" && $longitude != "") {
$block = new Block();
$block->css_id = "g-exif-gps-location";
$block->title = t("Location");
if (module::get_var("exif_gps", "sidebar_mapformat") == 1) {
$block->content = new View("exif_gps_dynamic_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
} else {
$block->content = new View("exif_gps_static_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "satellite";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "hybrid";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "terrain";
}
$block->content->latitude = $latitude;
$block->content->longitude = $longitude;
} elseif (($theme->item()) && ($theme->item->is_album() && (module::get_var("exif_gps", "sidebar_mapformat") == 1))) {
// If coordinates were NOT found, and this is an album with a dynamic map, then map the contents of the album.
$items = ORM::factory("item", $theme->item->id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants();
if (count($items) > 0) {
$block = new Block();
$block->css_id = "g-exif-gps-location";
$block->title = t("Location");
$block->content = new View("exif_gps_dynamic2_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
$block->content->items = $items;
$block->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
}
}
break;
}

View File

@ -56,14 +56,15 @@ class exif_gps_event_Core {
static function item_edit_form($item, $form) {
// Allow users to set / edit the GPS coordinates associated with the current item.
$record = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find();
$gpsdata = $form->edit_item->group("gps_data")->label("GPS Data");
if ($record->loaded()) {
$form->edit_item->input("latitude")->label(t("Latitude"))
$gpsdata->input("latitude")->label(t("Latitude"))
->value($record->latitude);
$form->edit_item->input("longitude")->label(t("Longitude"))
$gpsdata->input("longitude")->label(t("Longitude"))
->value($record->longitude);
} else {
$form->edit_item->input("latitude")->label(t("Latitude"));
$form->edit_item->input("longitude")->label(t("Longitude"));
$gpsdata->input("latitude")->label(t("Latitude"));
$gpsdata->input("longitude")->label(t("Longitude"));
}
}
@ -72,7 +73,7 @@ class exif_gps_event_Core {
// Require a set of coordinates (both latitude and longitude).
// If one or both fields are blank, completely delete any coordinates associated with this item.
if (($form->edit_item->latitude->value == "") || ($form->edit_item->longitude->value == "")) {
if (($form->edit_item->gps_data->latitude->value == "") || ($form->edit_item->gps_data->longitude->value == "")) {
db::build()
->delete("exif_coordinates")
->where("item_id", "=", $item->id)
@ -82,9 +83,18 @@ class exif_gps_event_Core {
if (!$record->loaded()) {
$record->item_id = $item->id;
}
$record->latitude = $form->edit_item->latitude->value;
$record->longitude = $form->edit_item->longitude->value;
$record->latitude = $form->edit_item->gps_data->latitude->value;
$record->longitude = $form->edit_item->gps_data->longitude->value;
$record->save();
}
}
static function admin_menu($menu, $theme) {
// Add a link to the EXIF_GPS admin page to the Settings menu.
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("exif_gps")
->label(t("EXIF_GPS Settings"))
->url(url::site("admin/exif_gps")));
}
}

View File

@ -30,7 +30,35 @@ class exif_gps_installer {
KEY(`item_id`, `id`))
DEFAULT CHARSET=utf8;");
module::set_version("exif_gps", 1);
// If tagsmap is installed, copy the API key over.
if (module::is_active("tagsmap")) {
module::set_var("exif_gps", "googlemap_api_key", module::get_var("tagsmap", "googlemap_api_key"));
}
// Set some default values.
module::set_var("exif_gps", "sidebar_zoom", "14");
module::set_var("exif_gps", "sidebar_mapformat", "1");
module::set_var("exif_gps", "sidebar_maptype", "1");
module::set_var("exif_gps", "largemap_maptype", "2");
// Set the module version number.
module::set_version("exif_gps", 2);
}
static function upgrade($version) {
if ($version == 1) {
// If tagsmap is installed, copy the API key over.
if (module::is_active("tagsmap")) {
module::set_var("exif_gps", "googlemap_api_key", module::get_var("tagsmap", "googlemap_api_key"));
}
// Set some default values.
module::set_var("exif_gps", "sidebar_zoom", "14");
module::set_var("exif_gps", "sidebar_mapformat", "1");
module::set_var("exif_gps", "sidebar_maptype", "1");
module::set_var("exif_gps", "largemap_maptype", "2");
module::set_version("exif_gps", 2);
}
}
static function deactivate() {

View File

@ -18,4 +18,4 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class EXIF_Coordinate_Model extends ORM {
}
}

View File

@ -1,3 +1,3 @@
name = "Exif GPS Data"
description = "Extract Exif GPS data from photos."
version = 1
version = 2

View File

@ -0,0 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-exif-gps-admin">
<h2> <?= t("EXIF GPS Settings") ?> </h2>
<br /><div><?=t("You may sign up for a Google Maps API key at"); ?> <a href="http://code.google.com/apis/maps/signup.html" target="_new">http://code.google.com/apis/maps/signup.html</a>.<br /></div>
<?= $exifgps_form ?>
<br /><br /><div><strong><?=t("Default Zoom Level:"); ?></strong> <?=t("This value represents how far zoomed in or out the map will start out at. A value of 0 (the coarsest) will zoom the map all of the way out, while higher numbers will zoom the map further in. Depending on the map type, the highest zoom value you can use will be around 19-23."); ?></div>
</div>

View File

@ -0,0 +1,43 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript" src="http://www.google.com/jsapi?key=<?= module::get_var("exif_gps", "googlemap_api_key"); ?>"></script>
<script type="text/javascript">
google.load("maps", "3",{"other_params":"sensor=false"});
function initialize() {
var latlng = new google.maps.LatLng(0,0);
var myOptions = {
zoom: 1,
center: latlng,
mapTypeId: google.maps.MapTypeId.<?=$sidebar_map_type; ?>
};
var map = new google.maps.Map(document.getElementById("sidebar_map_canvas"), myOptions);
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
<? $counter = 1; ?>
<? foreach ($items as $item) { ?>
<? $item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find(); ?>
glatlngbounds.extend(new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>));
<? if (!isset($currLat)) { ?>
<? $currLat = $item_coordinates->latitude; ?>
<? $currLong = $item_coordinates->longitude; ?>
var marker<?=$counter; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
map: map
});
<? } elseif (($currLat != $item_coordinates->latitude) && ($currLong != $item_coordinates->longitude)) { ?>
<? $counter++; ?>
<? $currLat = $item_coordinates->latitude; ?>
<? $currLong = $item_coordinates->longitude; ?>
var marker<?=$counter; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
map: map
});
<? } else { ?>
<? } ?>
<? } ?>
map.fitBounds(glatlngbounds);
}
google.setOnLoadCallback(initialize);
</script>
<div id="sidebar_map_canvas" style="width:205px; height:214px"></div>

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript" src="http://www.google.com/jsapi?key=<?= module::get_var("exif_gps", "googlemap_api_key"); ?>"></script>
<script type="text/javascript">
google.load("maps", "3",{"other_params":"sensor=false"});
function initialize() {
var latlng = new google.maps.LatLng(<?=$latitude; ?>,<?=$longitude; ?>);
var myOptions = {
zoom: <?= module::get_var("exif_gps", "sidebar_zoom"); ?>,
center: latlng,
mapTypeId: google.maps.MapTypeId.<?=$sidebar_map_type ?>
};
var map = new google.maps.Map(document.getElementById("sidebar_map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
}
google.setOnLoadCallback(initialize);
</script>
<div id="sidebar_map_canvas" style="width:205px; height:214px"></div>

View File

@ -0,0 +1,80 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript" src="http://www.google.com/jsapi?key=<?= module::get_var("exif_gps", "googlemap_api_key"); ?>"></script>
<script type="text/javascript">
google.load("maps", "3",{"other_params":"sensor=false"});
function initialize() {
var latlng = new google.maps.LatLng(0,0);
var myOptions = {
zoom: 1,
center: latlng,
mapTypeId: google.maps.MapTypeId.<?=$map_type; ?>
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
<? $counter = 1; ?>
<? foreach ($items as $item) { ?>
<? $item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find(); ?>
glatlngbounds.extend(new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>));
<? if (!isset($currLat)) { ?>
<? $currLat = $item_coordinates->latitude; ?>
<? $currLong = $item_coordinates->longitude; ?>
var marker<?=$counter; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
map: map
});
<? $windowContent = "<div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
$item->url() . "\\\">" .
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
"</a></div>"; ?>
<? } elseif (($currLat != $item_coordinates->latitude) && ($currLong != $item_coordinates->longitude)) { ?>
var infowindow<?=$counter; ?> = new google.maps.InfoWindow({
content: "<?=$windowContent; ?>",
size: new google.maps.Size(50,50)
});
google.maps.event.addListener(marker<?=$counter; ?>, 'click', function() {
infowindow<?=$counter; ?>.open(map,marker<?=$counter; ?>);
});
<? $counter++; ?>
<? $currLat = $item_coordinates->latitude; ?>
<? $currLong = $item_coordinates->longitude; ?>
var marker<?=$counter; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
map: map
});
<? $windowContent = "<div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
$item->url() . "\\\">" .
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
"</a></div>"; ?>
<? } else { ?>
<? $windowContent = $windowContent . " <div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
$item->url() . "\\\">" .
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
"</a></div>"; ?>
<? } ?>
<? } ?>
var infowindow<?=$counter; ?> = new google.maps.InfoWindow({
content: "<?=$windowContent; ?>",
size: new google.maps.Size(50,50)
});
google.maps.event.addListener(marker<?=$counter; ?>, 'click', function() {
infowindow<?=$counter; ?>.open(map,marker<?=$counter; ?>);
});
map.fitBounds(glatlngbounds);
}
google.setOnLoadCallback(initialize);
</script>
<div id="g-exif-map-header">
<div id="g-exif-map-header-buttons">
<?= $theme->dynamic_top() ?>
</div>
<h1><?= html::clean($title) ?></h1>
</div>
<br />
<div id="map_canvas" style="width:600px; height:480px;"></div>
<? if ($return_url != ""): ?>
<br /><a href="<?=$return_url; ?>"><?=t("Return to album"); ?></a>
<? endif ?>
<?= $theme->dynamic_bottom() ?>

View File

@ -0,0 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul>
<? if ($album_items > 0): ?>
<li><a href="<?=url::site("exif_gps/map/album/" . $album_id) ?>"><?=t("Map this album"); ?></a></li>
<? endif ?>
<? if ($user_items > 0): ?>
<li><a href="<?=url::site("exif_gps/map/user/" . $user_id) ?>"><?=t("Map"); ?> <?=$user_name; ?><?=t("'s photos"); ?></a></li>
<? endif ?>
</ul>

View File

@ -1,3 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<img src="http://maps.google.com/maps/api/staticmap?center=<?=$latitude; ?>,<?=$longitude; ?>&zoom=14&size=205x214&maptype=roadmap&markers=color:red|color:red|<?=$latitude; ?>,<?=$longitude; ?>&sensor=false">

View File

@ -0,0 +1,2 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<img src="http://maps.google.com/maps/api/staticmap?center=<?=$latitude; ?>,<?=$longitude; ?>&zoom=<?= module::get_var("exif_gps", "sidebar_zoom"); ?>&size=205x214&maptype=<?=$sidebar_map_type ?>&markers=color:red|color:red|<?=$latitude; ?>,<?=$longitude; ?>&sensor=false">

View File

@ -48,6 +48,9 @@ class jhead_event_Core {
$image_info = getimagesize($item->file_path());
$item->width = $image_info[0];
$item->height = $image_info[1];
$item->resize_dirty = 1;
$item->thumb_dirty = 1;
$item->save();
graphics::generate($item);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -33,7 +33,7 @@
key($installed_locales) . "')\"><img src=\"" .
$flag_url . "\" width=\"50\" title=\"" . $one_locale .
"\" alt=\"" . $one_locale . "\" border=\"0\" class=\"" .
$img_class . "\"></a></div>";
$img_class . "\" /></a></div>";
}
next($installed_locales);
}

View File

@ -41,5 +41,5 @@
// Limit Description to 150 characters.
$metaDescription = substr($metaDescription, 0,150);
?>
<META NAME="KEYWORDS" CONTENT="<?= $metaTags ?>">
<META NAME="DESCRIPTION" CONTENT="<?= $metaDescription ?>">
<meta name="KEYWORDS" content="<?= $metaTags ?>" />
<meta name="DESCRIPTION" content="<?= $metaDescription ?>" />

View File

@ -0,0 +1,125 @@
<?php defined("SYSPATH") or die("No direct script access.");/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 Admin_Moduleupdates_Controller extends Admin_Controller {
/**
* Builds the backend information for the Module Updates page.
*
* Builds an array of data containing the needed information about an installed copy of Gallery3
* to determine if versions stored in the GitHub are newer.
*
* List ID: The name of the folder the module resides in (obtained from module::available)
* name: The given name of the module (obtained from module::available)
* locked: If the module is considered locked by Gallery (obtained from module::available)
* code_version: The version of the module in the modules directory (obtained from module::available)
* active: If the module is installed and enabled (obtained from module::available)
* version: The version installed and running (obtained from module::available)
* description: The description of the module (obtained from module::available)
* remote_version: The version of the code on GitHub (obtained from get_remote_module_version)
* remote_server: The server the remote version is on (obtained from get_remote_module_version)
* font_color: The color to display the update in depending on its status
*
* @author brentil <forums@inner-ninja.com>
*/
public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Gallery 3 :: Manage Module Updates");
$view->content = new View("admin_moduleupdates.html");
$all_modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
foreach (module::available() as $this_module_name => $module_info) {
list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name);
$font_color = "black";
if ($remote_version == "DNE") {
$font_color = "blue";
} else if ($remote_version < $module_info->code_version) {
$font_color = "green";
} else if ($remote_version > $module_info->code_version) {
$font_color = "red";
}
$all_modules->$this_module_name = array ("name" => $module_info->name, "locked" => $module_info->locked,
"code_version" => $module_info->code_version, "active" => $module_info->active,
"version" => $module_info->version,"description" => $module_info->description,
"remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color);
}
$view->content->vars = $all_modules;
print $view;
}
/**
* Parses the known GitHub repositories for new versions of modules.
*
* Searches the remote GitHub repositories for a module with a like filename to that of the ones
* installed in the running Gallery isntall. Reads the remote modules module.info file to
* gather the version information. Uses the following locations;
*
* http://github.com/gallery/gallery3
* http://github.com/gallery/gallery3-contrib
*
* @author brentil <forums@inner-ninja.com>
* @param String The folder name of the module to search for on the remote GitHub server
* @return Array An array with the remote module version and the server it was found on.
*/
private function get_remote_module_version ($module_name) {
$version = 'DNE';
$server = '';
$file = null;
try {
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
$server = '(G3)';
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
$server = '(G3CC)';
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
if ($file != null) {
while (!feof ($file)) {
$line = fgets ($file, 1024);
//Regular expression to find & gather the version number in the remote module.info file
if (preg_match ("@version = (.*)@i", $line, $out)) {
$version = $out[1];
break;
}
}
fclose ($file);
}
return array ($version, $server);
}
}

View File

@ -0,0 +1,30 @@
<?php defined("SYSPATH") or die("No direct script access.");/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 moduleupdates_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("moduleupdates_menu")
->label(t("Module Updates"))
->url(url::site("admin/moduleupdates")));
}
}

View File

@ -0,0 +1,37 @@
<?php defined("SYSPATH") or die("No direct script access.");/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 moduleupdates_installer {
static function install() {
$version = module::get_version("moduleupdates");
if ($version == 0) {
module::set_version("moduleupdates", 1);
}
}
static function upgrade($version) {
}
static function uninstall() {
module::delete("moduleupdates");
}
}

View File

@ -0,0 +1,3 @@
name = "Module Updates"
description = "Compares your installed module version against the ones stored in the GitHub."
version = 1

View File

@ -0,0 +1,36 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-moduleupdates" class="g-block">
<h1> <?= t("Module Updates") ?> </h1>
<p>
<?= t("Compares your installed module version against the ones stored in the GitHub.<br><br>") ?>
<?= t("<font color=red>Red = Out of Date</font><br>") ?>
<?= t("<font color=green>Green = Your version is newer</font><br>") ?>
<?= t("<font color=blue>Blue = Does Not Exist/No information available</font><br>") ?>
</p>
<ul id="g-action-status" class="g-message-block">
<li class="g-warning"><?= t("Versions are compared from the official Gallery3 (G3) and official Gallery3 Community Contributions (G3CC). Versions downloaded from the forums will not be shown.") ?></li>
</ul>
<div class="g-block-content">
<table>
<tr>
<th> <?= t("Module") ?> </th>
<th> <?= t("Your Version") ?> </th>
<th> <?= t("Remote Version") ?> </th>
<th> <?= t("Description") ?> </th>
</tr>
<? foreach ($vars as $module_name): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['name'] ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['remote_version'] ?> <?= $module_name['remote_server'] ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['description'] ?> </font> </td>
</tr>
<? endforeach ?>
</table>
</div>
</div>
<pre>
</pre>

View File

@ -3,5 +3,5 @@
<meta name="robots" content="noindex, nofollow, noarchive" />
<meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet, noodp, noimageindex, notranslate" />
<meta name="slurp" content="noindex, nofollow, noarchive, nosnippet, noodp, noydir" />
<meta name="msnbot" content="noindex, nofollow, noarchive, nosnippet, noodp">
<meta name="teoma" content="noindex, nofollow, noarchive">
<meta name="msnbot" content="noindex, nofollow, noarchive, nosnippet, noodp" />
<meta name="teoma" content="noindex, nofollow, noarchive" />

View File

@ -43,6 +43,7 @@ class Admin_Tag_Cloud_Controller extends Admin_Controller {
}
if ($valid) {
module::set_var("tag_cloud", "tagcolor", $options->tagcolor->value);
module::set_var("tag_cloud", "mouseover", $options->mouseover->value);
module::set_var("tag_cloud", "background_color", $options->background_color->value);
module::set_var("tag_cloud", "transparent", $options->transparent->value);
module::set_var("tag_cloud", "speed", $options->speed->value);
@ -67,6 +68,10 @@ class Admin_Tag_Cloud_Controller extends Admin_Controller {
->value(module::get_var("tag_cloud", "tagcolor", "0x333333"))
->error_message("not_valid", t("The color value must be specified as '0xhhhhhh'"))
->rules("required|length[8]");
$group->input("mouseover") ->label(t("Tag mouseover color"))
->value(module::get_var("tag_cloud", "mouseover", "0x000000"))
->error_message("not_valid", t("The color value must be specified as '0xhhhhhh'"))
->rules("required|length[8]");
$group->input("background_color")->label(t("Background color"))
->value(module::get_var("tag_cloud", "background_color", "0xffffff"))
->error_message("not_valid", t("The color value must be specified as '0xhhhhhh'"))

View File

@ -28,7 +28,7 @@ class tag_cloud_block {
switch ($block_id) {
case "tag_cloud_site":
$options = array();
foreach (array("tagcolor", "background_color", "transparent", "speed", "distribution")
foreach (array("tagcolor", "background_color", "mouseover", "transparent", "speed", "distribution")
as $option) {
$value = module::get_var("tag_cloud", $option, null);
if (!empty($value)) {
@ -36,6 +36,9 @@ class tag_cloud_block {
case "tagcolor":
$options["tcolor"] = $value;
break;
case "mouseover":
$options["hicolor"] = $value;
break;
case "background_color":
$options["bgColor"] = $value;
break;

View File

@ -105,7 +105,7 @@ $.Jcrop = function(obj,opt)
// Initialize some jQuery objects {{{
var $origimg = $(obj);
var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' });
var $img = $origimg.clone().removeAttr('id').css({ position: 'static' });
$img.width($origimg.width());
$img.height($origimg.height());

View File

@ -6,20 +6,20 @@
.jcrop-vline, .jcrop-hline
{
font-size: 0;
position: absolute;
background: white url('<?= url::file("modules/tagfaces/images/Jcrop.gif") ?>') top left repeat;
font-size: 0;
position: absolute;
background: white url('<?= url::file("modules/tagfaces/images/Jcrop.gif") ?>') top left repeat;
}
.jcrop-vline { height: 100%; width: 1px !important; }
.jcrop-hline { width: 100%; height: 1px !important; }
.jcrop-handle {
font-size: 1px;
width: 7px !important;
height: 7px !important;
border: 1px #eee solid;
background-color: #333;
*width: 9px;
*height: 9px;
font-size: 1px;
width: 7px !important;
height: 7px !important;
border: 1px #eee solid;
background-color: #333;
*width: 9px;
*height: 9px;
}
.jcrop-tracker { width: 100%; height: 100%; }
@ -27,14 +27,14 @@
.custom .jcrop-vline,
.custom .jcrop-hline
{
background: yellow;
background: yellow;
}
.custom .jcrop-handle
{
border-color: black;
background-color: #C7BB00;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-color: black;
background-color: #C7BB00;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
</style>
@ -60,30 +60,42 @@
};
</script>
<div id="g-album-header">
<div id="g-album-header-buttons">
<?= $theme->dynamic_top() ?>
</div>
<h1><?= html::clean($title) ?></h1>
</div>
<p><?=t("Use the mouse to select a face on the image below."); ?></p>
<fieldset>
<div id="g-item">
<div id="g-info">
<h2><?= html::purify($item->title) ?></h2>
</div>
<div id="g-photo">
<?= $item->resize_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize")) ?>
</div>
<?= html::script("modules/tagfaces/js/jquery.Jcrop.js") ?>
<script language="Javascript">
// Remember to invoke within jQuery(window).load(...)
// If you don't, Jcrop may not initialize properly
jQuery(document).ready(function(){
jQuery('#g-select-photo-id-<?=$item->id ?>').Jcrop({
onChange: showCoords,
onSelect: showCoords
});
});
// Our simple event handler, called from onChange and onSelect
// event handlers, as per the Jcrop invocation above
function showCoords(c) {
jQuery('#x1').val(c.x);
jQuery('#y1').val(c.y);
jQuery('#x2').val(c.x2);
jQuery('#y2').val(c.y2);
};
</script>
<div id="g-select-item">
<?= $theme->dynamic_top() ?>
<div id="g-select-photo" align="center">
<h1><?= html::clean($title) ?></h1>
<p><?=t("Use the mouse to select a face on the image below."); ?></p>
<?= $item->resize_img(array("id" => "g-select-photo-id-{$item->id}", "class" => "g-select-resize", "style" => "position: fixed;")) ?>
</div>
</fieldset>
</div>
<style>
#face_title {
width: 200px;
}
#face_description {
width: 400px;
}

View File

@ -27,7 +27,10 @@ class user_homes_event_Core {
static function user_login($user) {
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
if ($home->loaded() && $home->home != 0) {
Session::instance()->set("redirect_home", $home->home);
$continue_url = Session::instance()->get("continue_url", null);
if ($continue_url == null){
Session::instance()->set("redirect_home", $home->home);
}
}
}
@ -174,4 +177,121 @@ class user_homes_event_Core {
}
}
}
static function album_add_form($form){
$group = $form->group("privacy")
->label(t("album privacy settings"));
$group->checkbox("private")->label(t("Private"))->id("uh_private")->onClick("pc()");
$group->input("username")->label(t("Username"))->id("uh_username")
->callback("user_homes_event::user_already_exists")
->error_messages("in_use", t("There is already a user with that username"))
->error_messages("required", t("You must enter a username"))->callback("user_homes_event::valid_name")->rules("length[1,32]");
$group->password("password")->label(t("Password"))->id("uh_password")
->callback("user_homes_event::valid_password")
->error_messages("required", t("You must enter a password"))
->error_messages("minlength", t("Password is not long enough"));
$group->password("password2")->label(t("Confirm password"))->id("uh_password2")
->error_messages("matches", t("Passwords do not match"))
->matches($group->password);
$form->script("")->url(url::abs_file("modules/user_homes/js/user_homes_add_album.js"));
}
/**
* Validate the user name. Make sure there are no conflicts.
*/
static function valid_password($field) {
$input = Input::instance();
$method = $field->method;
$checked = $input->$method("private", false);
if ($checked)
{
if (!$field->value || strlen($field->value)==0){
$field->add_error("required", 1);
}
else
{
$minimum_length = module::get_var("user", "mininum_password_length", 5);
if (strlen($field->value) < $minimum_length) {
$field->add_error("minlength", 1);
}
}
}
}
/**
* Validate the user name. Make sure there are no conflicts.
*/
static function valid_name($field) {
$input = Input::instance();
$method = $field->method;
$checked = $input->$method("private", false);
if ($checked)
{
if (!$field->value || strlen($field->value)==0){
$field->add_error("required", 1);
}
elseif (db::build()->from("users")
->where("name", "=", $field->value)
->count_records() == 1) {
$field->add_error("in_use", 1);
}
}
}
static function album_add_form_completed($album, $form){
if ($form->privacy->private->checked)
{
$username = $form->privacy->username->value;
$password = $form->privacy->password->value;
// TODO validation
// create a group based on username
$group = identity::create_group($username);
// create a user based on username
$user = identity::create_user($username, $username, $password, $username."@unknown.com");
identity::add_user_to_group($user,$group->id);
// create user home
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
$home->id = $user->id;
$home->home = $album->id;
$home->save();
// reload album
$album->reload();
// set permissions
// deny all groups.
$groups = ORM::factory("group")->find_all();
foreach ($groups as $group2){
if ($group->id != $group2->id){
access::deny($group2 , "view", $album);
access::deny($group2 , "view_full", $album);
}
}
// deny all other albums
$albums = ORM::factory("item")
->where("type", "=", "album")->find_all();
foreach($albums as $albumt){
access::deny($group,"view", $albumt);
}
// allow access to newly created group
access::allow($group, "view_full", $album);
$parents = $album->parents();
foreach ($parents as $parent){
access::allow($group, "view", $parent);
}
access::allow($group, "view", $album);
}
}
}

View File

@ -0,0 +1,3 @@
var p=document.getElementById("uh_private"),u=document.getElementById("uh_username"),a=document.getElementById("uh_password"),b=document.getElementById("uh_password2");
function pc(){u.disabled=!p.checked;a.disabled=!p.checked;b.disabled=!p.checked;}
pc();