Merge remote branch 'upstream/master'
This commit is contained in:
commit
2ec848686b
152
3.0/modules/albumpassword/controllers/albumpassword.php
Normal file
152
3.0/modules/albumpassword/controllers/albumpassword.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?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 albumpassword_Controller extends Controller {
|
||||||
|
public function assign($id) {
|
||||||
|
// Display prompt for assigning a new password.
|
||||||
|
|
||||||
|
// Make sure user has view/edit access for this item.
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
access::required("view", $item);
|
||||||
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
// Create the page.
|
||||||
|
$view = new View("assignpassword.html");
|
||||||
|
$view->form = $this->_get_password_form($id);
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login() {
|
||||||
|
// Display prompt to allow visitors to use their passwords.
|
||||||
|
|
||||||
|
// Create the page.
|
||||||
|
$view = new View("loginpassword.html");
|
||||||
|
$view->form = $this->_get_login_form();
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove($id) {
|
||||||
|
// Remove a password from an album
|
||||||
|
|
||||||
|
// Make sure user has view/edit privileges for this item
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
access::required("view", $item);
|
||||||
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
// Check for and delete the password.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
db::build()->delete("items_albumpasswords")->where("album_id", "=", $id)->execute();
|
||||||
|
message::success(t("Password Removed."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect the user back to the album.
|
||||||
|
url::redirect(url::abs_site("albums/" . $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function savepassword() {
|
||||||
|
// Save a newly assigned password.
|
||||||
|
|
||||||
|
// Prevent Cross Site Request Forgery
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
// Convert submitted data to local variables.
|
||||||
|
$album_id = Input::instance()->post("item_id");
|
||||||
|
$album_password = Input::instance()->post("assignpassword_password");
|
||||||
|
|
||||||
|
// Check for, and remove, any existing passwords.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $album_id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
db::build()->delete("items_albumpasswords")->where("album_id", "=", $album_id)->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the new password.
|
||||||
|
$new_password = ORM::factory("items_albumpassword");
|
||||||
|
$new_password->album_id = $album_id;
|
||||||
|
$new_password->password = $album_password;
|
||||||
|
$new_password->save();
|
||||||
|
|
||||||
|
// Display a success message and close the dialog.
|
||||||
|
message::success(t("Password saved."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout() {
|
||||||
|
// Delete a stored password cookie.
|
||||||
|
cookie::delete("g3_albumpassword");
|
||||||
|
url::redirect(url::abs_site("albums/1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkpassword() {
|
||||||
|
// Check that a password is valid, then store in a browser cookie.
|
||||||
|
|
||||||
|
// Prevent Cross Site Request Forgery
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
// Convert submitted data to local variables.
|
||||||
|
$album_password = Input::instance()->post("albumpassword_password");
|
||||||
|
|
||||||
|
// See if the submitted password matches any in the database.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("password", "=", $album_password)
|
||||||
|
->find_all();
|
||||||
|
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
// If the password if valid, then store it, and display a success message.
|
||||||
|
// If not, close the dialog and display a rejected message.
|
||||||
|
cookie::set("g3_albumpassword", $album_password);
|
||||||
|
message::success(t("Password Accepted."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
} else {
|
||||||
|
message::error(t("Password Rejected."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_password_form($id) {
|
||||||
|
// Generate a form for assigning a new password.
|
||||||
|
$form = new Forge("albumpassword/savepassword", "", "post",
|
||||||
|
array("id" => "g-assign-password-form"));
|
||||||
|
$assignpassword_group = $form->group("Enter Password")
|
||||||
|
->label(t("Enter Password:"));
|
||||||
|
$assignpassword_group->hidden("item_id")->value($id);
|
||||||
|
$assignpassword_group->input("assignpassword_password")
|
||||||
|
->id('assignpassword_password')
|
||||||
|
->label(t("Password:"));
|
||||||
|
$form->submit("save_password")->value(t("Save"));
|
||||||
|
|
||||||
|
// Return the newly generated form.
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_login_form($id) {
|
||||||
|
// Generate a form for allowing visitors to enter in their passwords.
|
||||||
|
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||||
|
array("id" => "g-login-password-form"));
|
||||||
|
$assignpassword_group = $form->group("Enter Password")
|
||||||
|
->label(t("Enter Password:"));
|
||||||
|
$assignpassword_group->input("albumpassword_password")
|
||||||
|
->id('albumpassword_password')
|
||||||
|
->label(t("Password:"));
|
||||||
|
$form->submit("login_password")->value(t("Login"));
|
||||||
|
|
||||||
|
// Return the newly generated form.
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
}
|
53
3.0/modules/albumpassword/helpers/MY_item.php
Normal file
53
3.0/modules/albumpassword/helpers/MY_item.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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 item extends item_Core {
|
||||||
|
static function viewable($model) {
|
||||||
|
// Hide the contents of a password protected album,
|
||||||
|
// Unless the current user is an admin, or the albums owner.
|
||||||
|
|
||||||
|
$model = item_Core::viewable($model);
|
||||||
|
$album_item = ORM::factory("item")->where("id", "=", $model->id)->find();
|
||||||
|
|
||||||
|
// Figure out if the user can access this album.
|
||||||
|
$deny_access = false;
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $model->id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||||
|
(identity::active_user()->id != $album_item->owner_id))
|
||||||
|
$deny_access = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set access::DENY if necessary.
|
||||||
|
if ($deny_access == true) {
|
||||||
|
$view_restrictions = array();
|
||||||
|
if (!identity::active_user()->admin) {
|
||||||
|
foreach (identity::group_ids_for_active_user() as $id) {
|
||||||
|
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($view_restrictions)) {
|
||||||
|
$model->and_open()->merge_or_where($view_restrictions)->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
104
3.0/modules/albumpassword/helpers/albumpassword_event.php
Normal file
104
3.0/modules/albumpassword/helpers/albumpassword_event.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?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 albumpassword_event_Core {
|
||||||
|
static function site_menu($menu, $theme) {
|
||||||
|
// Add menu options for Adding / Removing / Using passwords to the menu.
|
||||||
|
|
||||||
|
// If this page doesn't belong to an item, don't display the menu.
|
||||||
|
if (!$theme->item()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$item = $theme->item();
|
||||||
|
|
||||||
|
// If there isn't currently a password stored in the cookie,
|
||||||
|
// then display the enter password link.
|
||||||
|
if (cookie::get("g3_albumpassword") == "") {
|
||||||
|
$menu->append(Menu::factory("dialog")
|
||||||
|
->id("albumpassword_login")
|
||||||
|
->css_id("g-album-password-login")
|
||||||
|
->url(url::site("albumpassword/login"))
|
||||||
|
->label(t("Enter password")));
|
||||||
|
} else {
|
||||||
|
// If a password has been entered already
|
||||||
|
// display the log out link, and links to the protected albums
|
||||||
|
$menu->append(Menu::factory("submenu")
|
||||||
|
->id("albumpassword_protected")
|
||||||
|
->css_id("g-album-password-protected")
|
||||||
|
->label(t("Protected albums")));
|
||||||
|
$menu->get("albumpassword_protected")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_logout")
|
||||||
|
->css_id("g-album-password-logout")
|
||||||
|
->url(url::site("albumpassword/logout"))
|
||||||
|
->label(t("Clear password")));
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("password", "=", cookie::get("g3_albumpassword"))
|
||||||
|
->find_all();
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
$counter = 0;
|
||||||
|
while ($counter < count($existing_password)) {
|
||||||
|
$item_album = ORM::factory("item")->where("id", "=", $existing_password[$counter]->album_id)->find();
|
||||||
|
$menu->get("albumpassword_protected")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_album" . $counter)
|
||||||
|
->label(html::purify($item_album->title))
|
||||||
|
->css_id("g-album-password-album" . $counter)
|
||||||
|
->url(url::abs_site("{$item_album->type}s/{$item_album->id}")));
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is an album without a password, display a link for assigning one.
|
||||||
|
// If this is an album with a password, display a link to remove it.
|
||||||
|
if ($item->is_album()) {
|
||||||
|
if ((access::can("view", $item)) && (access::can("edit", $item))) {
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("album_id", "=", $item->id)
|
||||||
|
->find_all();
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_remove")
|
||||||
|
->label(t("Remove password"))
|
||||||
|
->css_id("g-album-password-remove")
|
||||||
|
->url(url::site("albumpassword/remove/" . $item->id)));
|
||||||
|
} else {
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("dialog")
|
||||||
|
->id("albumpassword_assign")
|
||||||
|
->label(t("Assign password"))
|
||||||
|
->css_id("g-album-password-assign")
|
||||||
|
->url(url::site("albumpassword/assign/" . $item->id)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function item_deleted($item) {
|
||||||
|
// If an album is deleted, remove any associated passwords.
|
||||||
|
$existingPasswords = ORM::factory("items_albumpassword")
|
||||||
|
->where("album_id", "=", $item->id)
|
||||||
|
->find_all();
|
||||||
|
if (count($existingPasswords) > 0) {
|
||||||
|
db::build()->delete("items_albumpassword")->where("album_id", "=", $item->id)->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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-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 albumpassword_installer {
|
||||||
|
static function install() {
|
||||||
|
// Create a table to store passwords in.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("CREATE TABLE IF NOT EXISTS {items_albumpasswords} (
|
||||||
|
`id` int(9) NOT NULL auto_increment,
|
||||||
|
`album_id` int(9) NOT NULL,
|
||||||
|
`password` varchar(64) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`))
|
||||||
|
DEFAULT CHARSET=utf8;");
|
||||||
|
|
||||||
|
|
||||||
|
// Set the module's version number.
|
||||||
|
module::set_version("albumpassword", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function uninstall() {
|
||||||
|
// Delete the password table before uninstalling.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("DROP TABLE IF EXISTS {items_albumpassword};");
|
||||||
|
module::delete("albumpassword");
|
||||||
|
}
|
||||||
|
}
|
21
3.0/modules/albumpassword/models/items_albumpassword.php
Normal file
21
3.0/modules/albumpassword/models/items_albumpassword.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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 Items_Albumpassword_Model extends ORM {
|
||||||
|
}
|
3
3.0/modules/albumpassword/module.info
Normal file
3
3.0/modules/albumpassword/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Album Password"
|
||||||
|
description = "Restrict access to individual albums."
|
||||||
|
version = 1
|
24
3.0/modules/albumpassword/views/assignpassword.html.php
Normal file
24
3.0/modules/albumpassword/views/assignpassword.html.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
function ajaxify_login_reset_form() {
|
||||||
|
$("#g-login form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-login form").replaceWith(data.form);
|
||||||
|
ajaxify_login_reset_form();
|
||||||
|
}
|
||||||
|
if (data.result == "success") {
|
||||||
|
$("#g-dialog").dialog("close");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<div id="g-assign-password">
|
||||||
|
<ul>
|
||||||
|
<li id="g-assign-password-form">
|
||||||
|
<?= $form ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
24
3.0/modules/albumpassword/views/loginpassword.html.php
Normal file
24
3.0/modules/albumpassword/views/loginpassword.html.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
function ajaxify_login_reset_form() {
|
||||||
|
$("#g-login form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-login form").replaceWith(data.form);
|
||||||
|
ajaxify_login_reset_form();
|
||||||
|
}
|
||||||
|
if (data.result == "success") {
|
||||||
|
$("#g-dialog").dialog("close");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<div id="g-login-password">
|
||||||
|
<ul>
|
||||||
|
<li id="g-login-password-form">
|
||||||
|
<?= $form ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
7
3.0/modules/editcreation/css/editcreation.css
Normal file → Executable file
7
3.0/modules/editcreation/css/editcreation.css
Normal file → Executable file
@ -1,3 +1,8 @@
|
|||||||
select {
|
form#g-edit-album-form fieldset ul li input,
|
||||||
|
form#g-edit-album-form fieldset ul li select,
|
||||||
|
form#g-edit-album-form fieldset ul li textarea,
|
||||||
|
form#g-edit-photo-form fieldset ul li input,
|
||||||
|
form#g-edit-photo-form fieldset ul li select,
|
||||||
|
form#g-edit-photo-form fieldset ul li textarea {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
2
3.0/modules/editcreation/module.info
Normal file → Executable file
2
3.0/modules/editcreation/module.info
Normal file → Executable file
@ -1,3 +1,3 @@
|
|||||||
name = "Edit Creation"
|
name = "Edit Creation"
|
||||||
description = "Manually edit the creation date of an item in Gallery."
|
description = "Manually edit the creation date of an item in Gallery."
|
||||||
version = 1
|
version = 2
|
||||||
|
52
3.0/modules/hide/controllers/admin_hide.php
Normal file
52
3.0/modules/hide/controllers/admin_hide.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?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_Hide_Controller extends Admin_Controller {
|
||||||
|
|
||||||
|
public function index() {
|
||||||
|
$view = new Admin_View("admin.html");
|
||||||
|
$view->page_title = t("Item hiding settings");
|
||||||
|
$view->content = new View("admin_hide.html");
|
||||||
|
$view->content->form = $this->_get_admin_form();
|
||||||
|
$view->content->title = $view->page_title;
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
access::verify_csrf();
|
||||||
|
$form = $this->_get_admin_form();
|
||||||
|
$form->validate();
|
||||||
|
module::set_var("hide", "access_permissions",
|
||||||
|
$form->access_permissions->value);
|
||||||
|
message::success(t("Item hiding settings updated"));
|
||||||
|
url::redirect("admin/hide");
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
70
3.0/modules/hide/controllers/display.php
Normal file
70
3.0/modules/hide/controllers/display.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?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 Display_Controller extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the given item.
|
||||||
|
*
|
||||||
|
* @param int $id the item id
|
||||||
|
*/
|
||||||
|
public function hide($id) {
|
||||||
|
$item = model_cache::get("item", $id);
|
||||||
|
$msg = t("Hidden <b>%title</b> item", array("title" => html::purify($item->title)));
|
||||||
|
|
||||||
|
$this->_check_hide_permissions($item);
|
||||||
|
hide::hide($item);
|
||||||
|
message::success($msg);
|
||||||
|
|
||||||
|
json::reply(array("result" => "success", "reload" => 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the given item to be displayed again.
|
||||||
|
*
|
||||||
|
* @param int $id the item id
|
||||||
|
*/
|
||||||
|
public function show($id) {
|
||||||
|
$item = model_cache::get("item", $id);
|
||||||
|
$msg = t("Displayed <b>%title</b> item", array("title" => html::purify($item->title)));
|
||||||
|
|
||||||
|
$this->_check_hide_permissions($item);
|
||||||
|
hide::show($item);
|
||||||
|
message::success($msg);
|
||||||
|
|
||||||
|
json::reply(array("result" => "success", "reload" => 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given object can be hidden by the active user.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item
|
||||||
|
*/
|
||||||
|
private function _check_hide_permissions(Item_Model $item) {
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
access::required("view", $item);
|
||||||
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
if (!hide::can_hide()) {
|
||||||
|
access::forbidden();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
3.0/modules/hide/helpers/MY_item.php
Normal file
34
3.0/modules/hide/helpers/MY_item.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?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 item extends item_Core {
|
||||||
|
|
||||||
|
static function viewable($model) {
|
||||||
|
$model = parent::viewable($model);
|
||||||
|
|
||||||
|
if (!hide::can_view_hidden_items($model)) {
|
||||||
|
// only fetches items that are not hidden
|
||||||
|
$model->join("hidden_items", "items.id", "hidden_items.item_id", "LEFT OUTER")
|
||||||
|
->and_where("hidden_items.item_id", "IS", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
147
3.0/modules/hide/helpers/hide.php
Normal file
147
3.0/modules/hide/helpers/hide.php
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<?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 hide_Core {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value defining no group can see hidden items.
|
||||||
|
*/
|
||||||
|
const NONE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the group list for a dropdown widget.
|
||||||
|
*
|
||||||
|
* @return array the group list
|
||||||
|
*/
|
||||||
|
static function get_groups_as_dropdown_options() {
|
||||||
|
$options = ORM::factory("group")->select_list("id", "name");
|
||||||
|
return array_merge(array(self::NONE => t("Nobody")), $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hidden_item model related to the given item.
|
||||||
|
*
|
||||||
|
* There is an attempt to fetch the model from the database through the model
|
||||||
|
* cache. If it fails, a new unsaved model is created.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item
|
||||||
|
* @return Hidden_Item_Model the related hidden_item model
|
||||||
|
*/
|
||||||
|
static function get_hidden_item_model(Item_Model $item) {
|
||||||
|
try {
|
||||||
|
$model = model_cache::get("item", $id);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$model = ORM::factory("hidden_item");
|
||||||
|
$model->item_id = $item->id;
|
||||||
|
$model->validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given item can be hidden.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
static function can_be_hidden(Item_Model $item) {
|
||||||
|
if (empty($item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item->type == "album") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given item is hidden.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
static function is_hidden(Item_Model $item) {
|
||||||
|
$model = self::get_hidden_item_model($item);
|
||||||
|
return $model->loaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the given item.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item to hide
|
||||||
|
*/
|
||||||
|
static function hide(Item_Model $item) {
|
||||||
|
if (self::is_hidden($item)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hidden_item = self::get_hidden_item_model($item);
|
||||||
|
$hidden_item->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the given item to be displayed again.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the item to display
|
||||||
|
*/
|
||||||
|
static function show(Item_Model $item) {
|
||||||
|
if (!self::is_hidden($item)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hidden_item = self::get_hidden_item_model($item);
|
||||||
|
$hidden_item->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the active user can view hidden items.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
static function can_view_hidden_items() {
|
||||||
|
if (identity::active_user()->admin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$authorized_group = module::get_var("hide", "access_permissions");
|
||||||
|
if (in_array($authorized_group, identity::group_ids_for_active_user())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the active user can hide any items.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
static function can_hide() {
|
||||||
|
if (identity::active_user()->admin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
88
3.0/modules/hide/helpers/hide_event.php
Normal file
88
3.0/modules/hide/helpers/hide_event.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?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 hide_event_Core {
|
||||||
|
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
$menu->get("settings_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->label(t("Item hiding"))
|
||||||
|
->url(url::site("admin/hide")));
|
||||||
|
}
|
||||||
|
|
||||||
|
static function site_menu($menu, $theme, $item_css_selector) {
|
||||||
|
$item = $theme->item();
|
||||||
|
|
||||||
|
if (!empty($item) && hide::can_be_hidden($item) && hide::can_hide($item)) {
|
||||||
|
$csrf = access::csrf_token();
|
||||||
|
$link = self::_get_hide_link_data($item);
|
||||||
|
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("ajax_link")
|
||||||
|
->label($link["text"])
|
||||||
|
->ajax_handler("function(data) { window.location.reload() }")
|
||||||
|
->url(url::site("display/".$link["action"]."/$item->id?csrf=$csrf")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function context_menu($menu, $theme, $item, $thumb_css_selector) {
|
||||||
|
if (hide::can_be_hidden($item) && hide::can_hide($item)) {
|
||||||
|
$csrf = access::csrf_token();
|
||||||
|
$link = self::_get_hide_link_data($item);
|
||||||
|
|
||||||
|
$menu
|
||||||
|
->get("options_menu")
|
||||||
|
->append(Menu::factory("ajax_link")
|
||||||
|
->label($link["text"])
|
||||||
|
->ajax_handler("function(data) { window.location.reload() }")
|
||||||
|
->url(url::site("display/".$link["action"]."/$item->id?csrf=$csrf")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns some data used to create a hide link.
|
||||||
|
*
|
||||||
|
* @param Item_Model $item the related item
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function _get_hide_link_data(Item_Model $item) {
|
||||||
|
if (hide::is_hidden($item)) {
|
||||||
|
$action = "show";
|
||||||
|
$action_label = "Show";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$action = "hide";
|
||||||
|
$action_label = "Hide";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($item->type) {
|
||||||
|
case "movie":
|
||||||
|
$item_type_label = "movie";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$item_type_label = "photo";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = t("$action_label this $item_type_label");
|
||||||
|
|
||||||
|
return array("text" => $label, "action" => $action);
|
||||||
|
}
|
||||||
|
}
|
38
3.0/modules/hide/helpers/hide_installer.php
Normal file
38
3.0/modules/hide/helpers/hide_installer.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?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 hide_installer {
|
||||||
|
|
||||||
|
static function install() {
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("CREATE TABLE IF NOT EXISTS {hidden_items} (
|
||||||
|
`item_id` int(9) NOT NULL,
|
||||||
|
PRIMARY KEY (`item_id`))
|
||||||
|
DEFAULT CHARSET=utf8;");
|
||||||
|
|
||||||
|
module::set_var("hide", "access_permissions", hide::NONE);
|
||||||
|
module::set_version("hide", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function uninstall() {
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("DROP TABLE IF EXISTS {hidden_items};");
|
||||||
|
}
|
||||||
|
}
|
24
3.0/modules/hide/models/hidden_item.php
Normal file
24
3.0/modules/hide/models/hidden_item.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?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 Hidden_Item_Model extends ORM {
|
||||||
|
|
||||||
|
protected $primary_key = "item_id";
|
||||||
|
}
|
3
3.0/modules/hide/module.info
Normal file
3
3.0/modules/hide/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Hide"
|
||||||
|
description = "Allows admins to hide some items from everyone but a given group."
|
||||||
|
version = 1
|
7
3.0/modules/hide/views/admin_hide.html.php
Normal file
7
3.0/modules/hide/views/admin_hide.html.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= $title ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<?= $form ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -86,4 +86,4 @@ class itemchecksum_Controller extends Controller {
|
|||||||
print "0";
|
print "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
3.0/modules/itemchecksum/helpers/item_itemchecksums_rest.php
Normal file
42
3.0/modules/itemchecksum/helpers/item_itemchecksums_rest.php
Normal file
@ -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-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 item_itemchecksums_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
|
||||||
|
$checksums = array(rest::url("itemchecksum_md5", $item), rest::url("itemchecksum_sha1", $item));
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"members" => $checksums);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/item_checksums/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
55
3.0/modules/itemchecksum/helpers/itemchecksum_md5_rest.php
Normal file
55
3.0/modules/itemchecksum/helpers/itemchecksum_md5_rest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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 itemchecksum_md5_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
$checksum = "0";
|
||||||
|
// If the KeepOriginal module is active, check for/use the
|
||||||
|
// original image instead of the gallery edited version.
|
||||||
|
if (module::is_active("keeporiginal")) {
|
||||||
|
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
|
||||||
|
if ($item->is_photo() && file_exists($original_image)) {
|
||||||
|
$checksum = md5_file($original_image);
|
||||||
|
} else {
|
||||||
|
$checksum = md5_file($item->file_path());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$checksum = md5_file($item->file_path());
|
||||||
|
}
|
||||||
|
$data = array("checksum" => $checksum);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"entity" => $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum_md5/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
41
3.0/modules/itemchecksum/helpers/itemchecksum_rest.php
Normal file
41
3.0/modules/itemchecksum/helpers/itemchecksum_rest.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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 itemchecksum_rest_Core {
|
||||||
|
static function relationships($resource_type, $resource) {
|
||||||
|
switch ($resource_type) {
|
||||||
|
case "item":
|
||||||
|
return array(
|
||||||
|
"itemchecksums" => array(
|
||||||
|
"url" => rest::url("item_itemchecksums", $resource)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
55
3.0/modules/itemchecksum/helpers/itemchecksum_sha1_rest.php
Normal file
55
3.0/modules/itemchecksum/helpers/itemchecksum_sha1_rest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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 itemchecksum_sha1_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
$checksum = "0";
|
||||||
|
// If the KeepOriginal module is active, check for/use the
|
||||||
|
// original image instead of the gallery edited version.
|
||||||
|
if (module::is_active("keeporiginal")) {
|
||||||
|
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
|
||||||
|
if ($item->is_photo() && file_exists($original_image)) {
|
||||||
|
$checksum = sha1_file($original_image);
|
||||||
|
} else {
|
||||||
|
$checksum = sha1_file($item->file_path());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$checksum = sha1_file($item->file_path());
|
||||||
|
}
|
||||||
|
$data = array("checksum" => $checksum);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"entity" => $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum_sha1/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
@ -16,13 +16,13 @@ vertical-align: middle;
|
|||||||
width: 40px;
|
width: 40px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto }
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#g-selected-language-flag img {
|
#g-selected-language-flag img {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto }
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,5 +41,5 @@
|
|||||||
// Limit Description to 150 characters.
|
// Limit Description to 150 characters.
|
||||||
$metaDescription = substr($metaDescription, 0,150);
|
$metaDescription = substr($metaDescription, 0,150);
|
||||||
?>
|
?>
|
||||||
<meta name="KEYWORDS" content="<?= $metaTags ?>" />
|
<meta name="keywords" content="<?= $metaTags ?>" />
|
||||||
<meta name="DESCRIPTION" content="<?= $metaDescription ?>" />
|
<meta name="description" content="<?= $metaDescription ?>" />
|
||||||
|
4
3.0/modules/moduleupdates/controllers/admin_moduleupdates.php
Normal file → Executable file
4
3.0/modules/moduleupdates/controllers/admin_moduleupdates.php
Normal file → Executable file
@ -197,7 +197,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||||||
if ($devDebug == true){
|
if ($devDebug == true){
|
||||||
if ($file == null) {
|
if ($file == null) {
|
||||||
try {
|
try {
|
||||||
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/3.0/modules/".$module_name."/module.info", "r");
|
||||||
if ($file != null) {
|
if ($file != null) {
|
||||||
$server = '(brentil)';
|
$server = '(brentil)';
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||||||
//Check the Gallery3 Community Contributions GitHub
|
//Check the Gallery3 Community Contributions GitHub
|
||||||
if ($file == null) {
|
if ($file == null) {
|
||||||
try {
|
try {
|
||||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/3.0/modules/".$module_name."/module.info", "r");
|
||||||
if ($file != null) {
|
if ($file != null) {
|
||||||
$server = '(G3CC)';
|
$server = '(G3CC)';
|
||||||
}
|
}
|
||||||
|
2
3.0/modules/moduleupdates/module.info
Normal file → Executable file
2
3.0/modules/moduleupdates/module.info
Normal file → Executable file
@ -1,3 +1,3 @@
|
|||||||
name = "Module Updates"
|
name = "Module Updates"
|
||||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||||
version = 2
|
version = 3
|
||||||
|
42
3.0/modules/square_thumbs/helpers/square_thumbs_graphics.php
Normal file
42
3.0/modules/square_thumbs/helpers/square_thumbs_graphics.php
Normal file
@ -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-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 square_thumbs_graphics_Core {
|
||||||
|
/**
|
||||||
|
* Crop the input image so that it's square. Focus on the center of the image.
|
||||||
|
*
|
||||||
|
* @param string $input_file
|
||||||
|
* @param string $output_file
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
static function crop_to_square($input_file, $output_file, $options) {
|
||||||
|
graphics::init_toolkit();
|
||||||
|
|
||||||
|
if (@filesize($input_file) == 0) {
|
||||||
|
throw new Exception("@todo EMPTY_INPUT_FILE");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = module::get_var("gallery", "thumb_size");
|
||||||
|
$dims = getimagesize($input_file);
|
||||||
|
Image::factory($input_file)
|
||||||
|
->crop(min($dims[0], $dims[1]), min($dims[0], $dims[1]))
|
||||||
|
->quality(module::get_var("gallery", "image_quality"))
|
||||||
|
->save($output_file);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?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 square_thumbs_installer {
|
||||||
|
static function install() {
|
||||||
|
// Add rules for generating our thumbnails and resizes
|
||||||
|
graphics::add_rule(
|
||||||
|
"square_thumbs", "thumb", "square_thumbs_graphics::crop_to_square", array(),
|
||||||
|
50);
|
||||||
|
module::set_version("square_thumbs", 1);
|
||||||
|
}
|
||||||
|
}
|
3
3.0/modules/square_thumbs/module.info
Normal file
3
3.0/modules/square_thumbs/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Square Thumbnails"
|
||||||
|
description = "Force all thumbnails to be square for a uniform appearance."
|
||||||
|
version = 1
|
152
3.1/modules/albumpassword/controllers/albumpassword.php
Normal file
152
3.1/modules/albumpassword/controllers/albumpassword.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?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 albumpassword_Controller extends Controller {
|
||||||
|
public function assign($id) {
|
||||||
|
// Display prompt for assigning a new password.
|
||||||
|
|
||||||
|
// Make sure user has view/edit access for this item.
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
access::required("view", $item);
|
||||||
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
// Create the page.
|
||||||
|
$view = new View("assignpassword.html");
|
||||||
|
$view->form = $this->_get_password_form($id);
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login() {
|
||||||
|
// Display prompt to allow visitors to use their passwords.
|
||||||
|
|
||||||
|
// Create the page.
|
||||||
|
$view = new View("loginpassword.html");
|
||||||
|
$view->form = $this->_get_login_form();
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove($id) {
|
||||||
|
// Remove a password from an album
|
||||||
|
|
||||||
|
// Make sure user has view/edit privileges for this item
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
access::required("view", $item);
|
||||||
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
// Check for and delete the password.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
db::build()->delete("items_albumpasswords")->where("album_id", "=", $id)->execute();
|
||||||
|
message::success(t("Password Removed."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect the user back to the album.
|
||||||
|
url::redirect(url::abs_site("albums/" . $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function savepassword() {
|
||||||
|
// Save a newly assigned password.
|
||||||
|
|
||||||
|
// Prevent Cross Site Request Forgery
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
// Convert submitted data to local variables.
|
||||||
|
$album_id = Input::instance()->post("item_id");
|
||||||
|
$album_password = Input::instance()->post("assignpassword_password");
|
||||||
|
|
||||||
|
// Check for, and remove, any existing passwords.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $album_id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
db::build()->delete("items_albumpasswords")->where("album_id", "=", $album_id)->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the new password.
|
||||||
|
$new_password = ORM::factory("items_albumpassword");
|
||||||
|
$new_password->album_id = $album_id;
|
||||||
|
$new_password->password = $album_password;
|
||||||
|
$new_password->save();
|
||||||
|
|
||||||
|
// Display a success message and close the dialog.
|
||||||
|
message::success(t("Password saved."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout() {
|
||||||
|
// Delete a stored password cookie.
|
||||||
|
cookie::delete("g3_albumpassword");
|
||||||
|
url::redirect(url::abs_site("albums/1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkpassword() {
|
||||||
|
// Check that a password is valid, then store in a browser cookie.
|
||||||
|
|
||||||
|
// Prevent Cross Site Request Forgery
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
// Convert submitted data to local variables.
|
||||||
|
$album_password = Input::instance()->post("albumpassword_password");
|
||||||
|
|
||||||
|
// See if the submitted password matches any in the database.
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("password", "=", $album_password)
|
||||||
|
->find_all();
|
||||||
|
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
// If the password if valid, then store it, and display a success message.
|
||||||
|
// If not, close the dialog and display a rejected message.
|
||||||
|
cookie::set("g3_albumpassword", $album_password);
|
||||||
|
message::success(t("Password Accepted."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
} else {
|
||||||
|
message::error(t("Password Rejected."));
|
||||||
|
json::reply(array("result" => "success"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_password_form($id) {
|
||||||
|
// Generate a form for assigning a new password.
|
||||||
|
$form = new Forge("albumpassword/savepassword", "", "post",
|
||||||
|
array("id" => "g-assign-password-form"));
|
||||||
|
$assignpassword_group = $form->group("Enter Password")
|
||||||
|
->label(t("Enter Password:"));
|
||||||
|
$assignpassword_group->hidden("item_id")->value($id);
|
||||||
|
$assignpassword_group->input("assignpassword_password")
|
||||||
|
->id('assignpassword_password')
|
||||||
|
->label(t("Password:"));
|
||||||
|
$form->submit("save_password")->value(t("Save"));
|
||||||
|
|
||||||
|
// Return the newly generated form.
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_login_form($id) {
|
||||||
|
// Generate a form for allowing visitors to enter in their passwords.
|
||||||
|
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||||
|
array("id" => "g-login-password-form"));
|
||||||
|
$assignpassword_group = $form->group("Enter Password")
|
||||||
|
->label(t("Enter Password:"));
|
||||||
|
$assignpassword_group->input("albumpassword_password")
|
||||||
|
->id('albumpassword_password')
|
||||||
|
->label(t("Password:"));
|
||||||
|
$form->submit("login_password")->value(t("Login"));
|
||||||
|
|
||||||
|
// Return the newly generated form.
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
}
|
53
3.1/modules/albumpassword/helpers/MY_item.php
Normal file
53
3.1/modules/albumpassword/helpers/MY_item.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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 item extends item_Core {
|
||||||
|
static function viewable($model) {
|
||||||
|
// Hide the contents of a password protected album,
|
||||||
|
// Unless the current user is an admin, or the albums owner.
|
||||||
|
|
||||||
|
$model = item_Core::viewable($model);
|
||||||
|
$album_item = ORM::factory("item")->where("id", "=", $model->id)->find();
|
||||||
|
|
||||||
|
// Figure out if the user can access this album.
|
||||||
|
$deny_access = false;
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $model->id)->find();
|
||||||
|
if ($existing_password->loaded()) {
|
||||||
|
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||||
|
(identity::active_user()->id != $album_item->owner_id))
|
||||||
|
$deny_access = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set access::DENY if necessary.
|
||||||
|
if ($deny_access == true) {
|
||||||
|
$view_restrictions = array();
|
||||||
|
if (!identity::active_user()->admin) {
|
||||||
|
foreach (identity::group_ids_for_active_user() as $id) {
|
||||||
|
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($view_restrictions)) {
|
||||||
|
$model->and_open()->merge_or_where($view_restrictions)->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
104
3.1/modules/albumpassword/helpers/albumpassword_event.php
Normal file
104
3.1/modules/albumpassword/helpers/albumpassword_event.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?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 albumpassword_event_Core {
|
||||||
|
static function site_menu($menu, $theme) {
|
||||||
|
// Add menu options for Adding / Removing / Using passwords to the menu.
|
||||||
|
|
||||||
|
// If this page doesn't belong to an item, don't display the menu.
|
||||||
|
if (!$theme->item()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$item = $theme->item();
|
||||||
|
|
||||||
|
// If there isn't currently a password stored in the cookie,
|
||||||
|
// then display the enter password link.
|
||||||
|
if (cookie::get("g3_albumpassword") == "") {
|
||||||
|
$menu->append(Menu::factory("dialog")
|
||||||
|
->id("albumpassword_login")
|
||||||
|
->css_id("g-album-password-login")
|
||||||
|
->url(url::site("albumpassword/login"))
|
||||||
|
->label(t("Enter password")));
|
||||||
|
} else {
|
||||||
|
// If a password has been entered already
|
||||||
|
// display the log out link, and links to the protected albums
|
||||||
|
$menu->append(Menu::factory("submenu")
|
||||||
|
->id("albumpassword_protected")
|
||||||
|
->css_id("g-album-password-protected")
|
||||||
|
->label(t("Protected albums")));
|
||||||
|
$menu->get("albumpassword_protected")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_logout")
|
||||||
|
->css_id("g-album-password-logout")
|
||||||
|
->url(url::site("albumpassword/logout"))
|
||||||
|
->label(t("Clear password")));
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("password", "=", cookie::get("g3_albumpassword"))
|
||||||
|
->find_all();
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
$counter = 0;
|
||||||
|
while ($counter < count($existing_password)) {
|
||||||
|
$item_album = ORM::factory("item")->where("id", "=", $existing_password[$counter]->album_id)->find();
|
||||||
|
$menu->get("albumpassword_protected")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_album" . $counter)
|
||||||
|
->label(html::purify($item_album->title))
|
||||||
|
->css_id("g-album-password-album" . $counter)
|
||||||
|
->url(url::abs_site("{$item_album->type}s/{$item_album->id}")));
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is an album without a password, display a link for assigning one.
|
||||||
|
// If this is an album with a password, display a link to remove it.
|
||||||
|
if ($item->is_album()) {
|
||||||
|
if ((access::can("view", $item)) && (access::can("edit", $item))) {
|
||||||
|
$existing_password = ORM::factory("items_albumpassword")
|
||||||
|
->where("album_id", "=", $item->id)
|
||||||
|
->find_all();
|
||||||
|
if (count($existing_password) > 0) {
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("albumpassword_remove")
|
||||||
|
->label(t("Remove password"))
|
||||||
|
->css_id("g-album-password-remove")
|
||||||
|
->url(url::site("albumpassword/remove/" . $item->id)));
|
||||||
|
} else {
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("dialog")
|
||||||
|
->id("albumpassword_assign")
|
||||||
|
->label(t("Assign password"))
|
||||||
|
->css_id("g-album-password-assign")
|
||||||
|
->url(url::site("albumpassword/assign/" . $item->id)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function item_deleted($item) {
|
||||||
|
// If an album is deleted, remove any associated passwords.
|
||||||
|
$existingPasswords = ORM::factory("items_albumpassword")
|
||||||
|
->where("album_id", "=", $item->id)
|
||||||
|
->find_all();
|
||||||
|
if (count($existingPasswords) > 0) {
|
||||||
|
db::build()->delete("items_albumpassword")->where("album_id", "=", $item->id)->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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-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 albumpassword_installer {
|
||||||
|
static function install() {
|
||||||
|
// Create a table to store passwords in.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("CREATE TABLE IF NOT EXISTS {items_albumpasswords} (
|
||||||
|
`id` int(9) NOT NULL auto_increment,
|
||||||
|
`album_id` int(9) NOT NULL,
|
||||||
|
`password` varchar(64) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`))
|
||||||
|
DEFAULT CHARSET=utf8;");
|
||||||
|
|
||||||
|
|
||||||
|
// Set the module's version number.
|
||||||
|
module::set_version("albumpassword", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function uninstall() {
|
||||||
|
// Delete the password table before uninstalling.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("DROP TABLE IF EXISTS {items_albumpassword};");
|
||||||
|
module::delete("albumpassword");
|
||||||
|
}
|
||||||
|
}
|
21
3.1/modules/albumpassword/models/items_albumpassword.php
Normal file
21
3.1/modules/albumpassword/models/items_albumpassword.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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 Items_Albumpassword_Model extends ORM {
|
||||||
|
}
|
3
3.1/modules/albumpassword/module.info
Normal file
3
3.1/modules/albumpassword/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Album Password"
|
||||||
|
description = "Restrict access to individual albums."
|
||||||
|
version = 1
|
24
3.1/modules/albumpassword/views/assignpassword.html.php
Normal file
24
3.1/modules/albumpassword/views/assignpassword.html.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
function ajaxify_login_reset_form() {
|
||||||
|
$("#g-login form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-login form").replaceWith(data.form);
|
||||||
|
ajaxify_login_reset_form();
|
||||||
|
}
|
||||||
|
if (data.result == "success") {
|
||||||
|
$("#g-dialog").dialog("close");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<div id="g-assign-password">
|
||||||
|
<ul>
|
||||||
|
<li id="g-assign-password-form">
|
||||||
|
<?= $form ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
24
3.1/modules/albumpassword/views/loginpassword.html.php
Normal file
24
3.1/modules/albumpassword/views/loginpassword.html.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
function ajaxify_login_reset_form() {
|
||||||
|
$("#g-login form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-login form").replaceWith(data.form);
|
||||||
|
ajaxify_login_reset_form();
|
||||||
|
}
|
||||||
|
if (data.result == "success") {
|
||||||
|
$("#g-dialog").dialog("close");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<div id="g-login-password">
|
||||||
|
<ul>
|
||||||
|
<li id="g-login-password-form">
|
||||||
|
<?= $form ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
7
3.1/modules/editcreation/css/editcreation.css
Normal file → Executable file
7
3.1/modules/editcreation/css/editcreation.css
Normal file → Executable file
@ -1,3 +1,8 @@
|
|||||||
select {
|
form#g-edit-album-form fieldset ul li input,
|
||||||
|
form#g-edit-album-form fieldset ul li select,
|
||||||
|
form#g-edit-album-form fieldset ul li textarea,
|
||||||
|
form#g-edit-photo-form fieldset ul li input,
|
||||||
|
form#g-edit-photo-form fieldset ul li select,
|
||||||
|
form#g-edit-photo-form fieldset ul li textarea {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
2
3.1/modules/editcreation/module.info
Normal file → Executable file
2
3.1/modules/editcreation/module.info
Normal file → Executable file
@ -1,3 +1,3 @@
|
|||||||
name = "Edit Creation"
|
name = "Edit Creation"
|
||||||
description = "Manually edit the creation date of an item in Gallery."
|
description = "Manually edit the creation date of an item in Gallery."
|
||||||
version = 1
|
version = 2
|
||||||
|
@ -86,4 +86,4 @@ class itemchecksum_Controller extends Controller {
|
|||||||
print "0";
|
print "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
3.1/modules/itemchecksum/helpers/item_itemchecksums_rest.php
Normal file
42
3.1/modules/itemchecksum/helpers/item_itemchecksums_rest.php
Normal file
@ -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-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 item_itemchecksums_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
|
||||||
|
$checksums = array(rest::url("itemchecksum_md5", $item), rest::url("itemchecksum_sha1", $item));
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"members" => $checksums);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/item_checksums/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
55
3.1/modules/itemchecksum/helpers/itemchecksum_md5_rest.php
Normal file
55
3.1/modules/itemchecksum/helpers/itemchecksum_md5_rest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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 itemchecksum_md5_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
$checksum = "0";
|
||||||
|
// If the KeepOriginal module is active, check for/use the
|
||||||
|
// original image instead of the gallery edited version.
|
||||||
|
if (module::is_active("keeporiginal")) {
|
||||||
|
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
|
||||||
|
if ($item->is_photo() && file_exists($original_image)) {
|
||||||
|
$checksum = md5_file($original_image);
|
||||||
|
} else {
|
||||||
|
$checksum = md5_file($item->file_path());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$checksum = md5_file($item->file_path());
|
||||||
|
}
|
||||||
|
$data = array("checksum" => $checksum);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"entity" => $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum_md5/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
41
3.1/modules/itemchecksum/helpers/itemchecksum_rest.php
Normal file
41
3.1/modules/itemchecksum/helpers/itemchecksum_rest.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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 itemchecksum_rest_Core {
|
||||||
|
static function relationships($resource_type, $resource) {
|
||||||
|
switch ($resource_type) {
|
||||||
|
case "item":
|
||||||
|
return array(
|
||||||
|
"itemchecksums" => array(
|
||||||
|
"url" => rest::url("item_itemchecksums", $resource)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
55
3.1/modules/itemchecksum/helpers/itemchecksum_sha1_rest.php
Normal file
55
3.1/modules/itemchecksum/helpers/itemchecksum_sha1_rest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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 itemchecksum_sha1_rest_Core {
|
||||||
|
static function get($request) {
|
||||||
|
$item = rest::resolve($request->url);
|
||||||
|
access::required("view", $item);
|
||||||
|
$checksum = "0";
|
||||||
|
// If the KeepOriginal module is active, check for/use the
|
||||||
|
// original image instead of the gallery edited version.
|
||||||
|
if (module::is_active("keeporiginal")) {
|
||||||
|
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
|
||||||
|
if ($item->is_photo() && file_exists($original_image)) {
|
||||||
|
$checksum = sha1_file($original_image);
|
||||||
|
} else {
|
||||||
|
$checksum = sha1_file($item->file_path());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$checksum = sha1_file($item->file_path());
|
||||||
|
}
|
||||||
|
$data = array("checksum" => $checksum);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"url" => $request->url,
|
||||||
|
"entity" => $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function resolve($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if (!access::can("view", $item)) {
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function url($item) {
|
||||||
|
return url::abs_site("rest/itemchecksum_sha1/{$item->id}");
|
||||||
|
}
|
||||||
|
}
|
@ -16,13 +16,13 @@ vertical-align: middle;
|
|||||||
width: 40px;
|
width: 40px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto }
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#g-selected-language-flag img {
|
#g-selected-language-flag img {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto }
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
3.1/modules/max_size/helpers/max_size_event.php
Normal file
37
3.1/modules/max_size/helpers/max_size_event.php
Normal 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 max_size_event_Core {
|
||||||
|
static function item_before_create($item) {
|
||||||
|
$max_size = module::get_var("max_size", "max_size", 600);
|
||||||
|
if ($item->is_photo()) {
|
||||||
|
list ($width, $height, $mime_type) = photo::get_file_metadata($item->data_file);
|
||||||
|
if ($width > $max_size || $height > $max_size) {
|
||||||
|
$tempnam = tempnam(TMPPATH, "size");
|
||||||
|
$tmpfile = $tempnam . "." . pathinfo($item->data_file, PATHINFO_EXTENSION);
|
||||||
|
gallery_graphics::resize(
|
||||||
|
$item->data_file, $tmpfile,
|
||||||
|
array("width" => $max_size, "height" => $max_size, "master" => Image::AUTO));
|
||||||
|
rename($tmpfile, $item->data_file);
|
||||||
|
unlink($tempnam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
3.1/modules/max_size/helpers/max_size_installer.php
Normal file
25
3.1/modules/max_size/helpers/max_size_installer.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?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 max_size_installer {
|
||||||
|
static function install() {
|
||||||
|
module::set_var("max_size", "max_size", 1024);
|
||||||
|
module::set_version("max_size", 1);
|
||||||
|
}
|
||||||
|
}
|
3
3.1/modules/max_size/module.info
Normal file
3
3.1/modules/max_size/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Max Size"
|
||||||
|
description = "Automatically scale down the original image if it's too large."
|
||||||
|
version = 1
|
@ -41,5 +41,5 @@
|
|||||||
// Limit Description to 150 characters.
|
// Limit Description to 150 characters.
|
||||||
$metaDescription = substr($metaDescription, 0,150);
|
$metaDescription = substr($metaDescription, 0,150);
|
||||||
?>
|
?>
|
||||||
<meta name="KEYWORDS" content="<?= $metaTags ?>" />
|
<meta name="keywords" content="<?= $metaTags ?>" />
|
||||||
<meta name="DESCRIPTION" content="<?= $metaDescription ?>" />
|
<meta name="description" content="<?= $metaDescription ?>" />
|
||||||
|
4
3.1/modules/moduleupdates/controllers/admin_moduleupdates.php
Normal file → Executable file
4
3.1/modules/moduleupdates/controllers/admin_moduleupdates.php
Normal file → Executable file
@ -197,7 +197,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||||||
if ($devDebug == true){
|
if ($devDebug == true){
|
||||||
if ($file == null) {
|
if ($file == null) {
|
||||||
try {
|
try {
|
||||||
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/3.1/modules/".$module_name."/module.info", "r");
|
||||||
if ($file != null) {
|
if ($file != null) {
|
||||||
$server = '(brentil)';
|
$server = '(brentil)';
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||||||
//Check the Gallery3 Community Contributions GitHub
|
//Check the Gallery3 Community Contributions GitHub
|
||||||
if ($file == null) {
|
if ($file == null) {
|
||||||
try {
|
try {
|
||||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/3.1/modules/".$module_name."/module.info", "r");
|
||||||
if ($file != null) {
|
if ($file != null) {
|
||||||
$server = '(G3CC)';
|
$server = '(G3CC)';
|
||||||
}
|
}
|
||||||
|
2
3.1/modules/moduleupdates/module.info
Normal file → Executable file
2
3.1/modules/moduleupdates/module.info
Normal file → Executable file
@ -1,3 +1,3 @@
|
|||||||
name = "Module Updates"
|
name = "Module Updates"
|
||||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||||
version = 2
|
version = 3
|
||||||
|
42
3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php
Normal file
42
3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php
Normal file
@ -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-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 square_thumbs_graphics_Core {
|
||||||
|
/**
|
||||||
|
* Crop the input image so that it's square. Focus on the center of the image.
|
||||||
|
*
|
||||||
|
* @param string $input_file
|
||||||
|
* @param string $output_file
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
static function crop_to_square($input_file, $output_file, $options) {
|
||||||
|
graphics::init_toolkit();
|
||||||
|
|
||||||
|
if (@filesize($input_file) == 0) {
|
||||||
|
throw new Exception("@todo EMPTY_INPUT_FILE");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = module::get_var("gallery", "thumb_size");
|
||||||
|
$dims = getimagesize($input_file);
|
||||||
|
Image::factory($input_file)
|
||||||
|
->crop(min($dims[0], $dims[1]), min($dims[0], $dims[1]))
|
||||||
|
->quality(module::get_var("gallery", "image_quality"))
|
||||||
|
->save($output_file);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?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 square_thumbs_installer {
|
||||||
|
static function install() {
|
||||||
|
// Add rules for generating our thumbnails and resizes
|
||||||
|
graphics::add_rule(
|
||||||
|
"square_thumbs", "thumb", "square_thumbs_graphics::crop_to_square", array(),
|
||||||
|
50);
|
||||||
|
module::set_version("square_thumbs", 1);
|
||||||
|
}
|
||||||
|
}
|
3
3.1/modules/square_thumbs/module.info
Normal file
3
3.1/modules/square_thumbs/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Square Thumbnails"
|
||||||
|
description = "Force all thumbnails to be square for a uniform appearance."
|
||||||
|
version = 1
|
Reference in New Issue
Block a user