Merge remote branch 'gallery3-contrib/master'
Conflicts: 3.0/modules/albumpassword/controllers/albumpassword.php 3.0/modules/albumpassword/helpers/MY_item.php 3.0/modules/albumpassword/views/assignpassword.html.php 3.0/modules/albumpassword/views/loginpassword.html.php 3.1/modules/albumpassword/controllers/albumpassword.php 3.1/modules/albumpassword/helpers/MY_item.php 3.1/modules/albumpassword/views/assignpassword.html.php 3.1/modules/albumpassword/views/loginpassword.html.php
This commit is contained in:
commit
d5728284c8
@ -84,7 +84,11 @@ class albumpassword_Controller extends Controller {
|
||||
|
||||
// Display a success message and close the dialog.
|
||||
message::success(t("Password saved."));
|
||||
<<<<<<< HEAD
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
=======
|
||||
json::reply(array("result" => "success"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
@ -112,10 +116,17 @@ class albumpassword_Controller extends Controller {
|
||||
// If not, close the dialog and display a rejected message.
|
||||
cookie::set("g3_albumpassword", $album_password);
|
||||
message::success(t("Password Accepted."));
|
||||
<<<<<<< HEAD
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
=======
|
||||
json::reply(array("result" => "success"));
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
json::reply(array("result" => "success"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +140,11 @@ class albumpassword_Controller extends Controller {
|
||||
$assignpassword_group->input("assignpassword_password")
|
||||
->id('assignpassword_password')
|
||||
->label(t("Password:"));
|
||||
<<<<<<< HEAD
|
||||
$assignpassword_group->submit("save_password")->value(t("Save"));
|
||||
=======
|
||||
$form->submit("save_password")->value(t("Save"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
@ -139,6 +154,7 @@ class albumpassword_Controller extends Controller {
|
||||
// Generate a form for allowing visitors to enter in their passwords.
|
||||
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||
array("id" => "g-login-password-form"));
|
||||
<<<<<<< HEAD
|
||||
|
||||
$assignpassword_group = $form->group("Enter Password")
|
||||
->label(t("Enter Password:"));
|
||||
@ -147,6 +163,14 @@ class albumpassword_Controller extends Controller {
|
||||
->label(t("Password:"));
|
||||
|
||||
$assignpassword_group->submit("")->value(t("Login"));
|
||||
=======
|
||||
$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"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
|
@ -36,8 +36,13 @@ class item extends item_Core {
|
||||
}
|
||||
|
||||
// set access::DENY if necessary.
|
||||
<<<<<<< HEAD
|
||||
$view_restrictions = array();
|
||||
if ($deny_access == true) {
|
||||
=======
|
||||
if ($deny_access == true) {
|
||||
$view_restrictions = array();
|
||||
>>>>>>> gallery3-contrib/master
|
||||
if (!identity::active_user()->admin) {
|
||||
foreach (identity::group_ids_for_active_user() as $id) {
|
||||
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||
|
@ -1,3 +1,23 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<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>
|
||||
>>>>>>> gallery3-contrib/master
|
||||
<div id="g-assign-password">
|
||||
<ul>
|
||||
<li id="g-assign-password-form">
|
||||
|
@ -1,3 +1,23 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<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>
|
||||
>>>>>>> gallery3-contrib/master
|
||||
<div id="g-login-password">
|
||||
<ul>
|
||||
<li id="g-login-password-form">
|
||||
|
@ -22,30 +22,55 @@ class downloadalbum_Controller extends Controller {
|
||||
/**
|
||||
* Generate a ZIP on-the-fly.
|
||||
*/
|
||||
public function zip($id) {
|
||||
$album = $this->init($id);
|
||||
$files = $this->getFilesList($album);
|
||||
public function zip($container_type, $id) {
|
||||
switch($container_type) {
|
||||
case "album":
|
||||
$container = ORM::factory("item", $id);
|
||||
if (!$container->is_album()) {
|
||||
throw new Kohana_Exception('container is not an album: '.$container->relative_path());
|
||||
}
|
||||
|
||||
$zipname = (empty($container->name))
|
||||
? 'Gallery.zip' // @todo purified_version_of($container->title).'.zip'
|
||||
: $container->name.'.zip';
|
||||
break;
|
||||
|
||||
case "tag":
|
||||
// @todo: if the module is not installed, it crash
|
||||
$container = ORM::factory("tag", $id);
|
||||
if (is_null($container->name)) {
|
||||
throw new Kohana_Exception('container is not a tag: '.$id);
|
||||
}
|
||||
|
||||
$zipname = $container->name.'.zip';
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Kohana_Exception('unhandled container type: '.$container_type);
|
||||
}
|
||||
|
||||
$files = $this->getFilesList($container);
|
||||
|
||||
// Calculate ZIP size (look behind for details)
|
||||
$zipsize = 22;
|
||||
foreach($files as $f) {
|
||||
$zipsize += 76 + 2*strlen($f) + filesize($f);
|
||||
foreach($files as $f_name => $f_path) {
|
||||
$zipsize += 76 + 2*strlen($f_name) + filesize($f_path);
|
||||
}
|
||||
|
||||
// Send headers
|
||||
$this->prepareOutput();
|
||||
$this->sendHeaders($album->name.'.zip', $zipsize);
|
||||
$this->sendHeaders($zipname, $zipsize);
|
||||
|
||||
// Generate and send ZIP file
|
||||
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT (v6.3.2)
|
||||
$lfh_offset = 0;
|
||||
$cds = '';
|
||||
$cds_offset = 0;
|
||||
foreach($files as $f) {
|
||||
$f_namelen = strlen($f);
|
||||
$f_size = filesize($f);
|
||||
$f_mtime = $this->unix2dostime(filemtime($f));
|
||||
$f_crc32 = $this->fixBug45028(hexdec(hash_file('crc32b', $f, false)));
|
||||
foreach($files as $f_name => $f_path) {
|
||||
$f_namelen = strlen($f_name);
|
||||
$f_size = filesize($f_path);
|
||||
$f_mtime = $this->unix2dostime(filemtime($f_path));
|
||||
$f_crc32 = $this->fixBug45028(hexdec(hash_file('crc32b', $f_path, false)));
|
||||
|
||||
// Local file header
|
||||
echo pack('VvvvVVVVvva' . $f_namelen,
|
||||
@ -60,12 +85,12 @@ class downloadalbum_Controller extends Controller {
|
||||
$f_namelen, // file name length (2 bytes)
|
||||
0, // extra field length (2 bytes)
|
||||
|
||||
$f // file name (variable size)
|
||||
$f_name // file name (variable size)
|
||||
// extra field (variable size) => n/a
|
||||
);
|
||||
|
||||
// File data
|
||||
readfile($f);
|
||||
readfile($f_path);
|
||||
|
||||
// Data descriptor (n/a)
|
||||
|
||||
@ -88,7 +113,7 @@ class downloadalbum_Controller extends Controller {
|
||||
0x81b40000, // external file attributes (4 bytes) => chmod 664
|
||||
$lfh_offset, // relative offset of local header (4 bytes)
|
||||
|
||||
$f // file name (variable size)
|
||||
$f_name // file name (variable size)
|
||||
// extra field (variable size) => n/a
|
||||
// file comment (variable size) => n/a
|
||||
);
|
||||
@ -128,59 +153,57 @@ class downloadalbum_Controller extends Controller {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
private function init($id) {
|
||||
$item = ORM::factory("item", $id);
|
||||
|
||||
// Only send an album
|
||||
if (!$item->is_album()) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'item is not an album: '.$item->relative_path());
|
||||
exit;
|
||||
}
|
||||
|
||||
// Must have view_full to download the originals files
|
||||
access::required("view_full", $item);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the files that must be included in the archive.
|
||||
*/
|
||||
private function getFilesList($album) {
|
||||
private function getFilesList($container) {
|
||||
$files = array();
|
||||
|
||||
// Go to the parent of album so the ZIP will not contains all the
|
||||
// server hierarchy
|
||||
if (!chdir($album->file_path().'/../')) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'unable to chdir('.$item->file_path().'/../)');
|
||||
exit;
|
||||
}
|
||||
$cwd = getcwd();
|
||||
if( $container instanceof Item_Model && $container->is_album() ) {
|
||||
$container_realpath = realpath($container->file_path().'/../');
|
||||
|
||||
$items = $album->viewable()
|
||||
->descendants(null, null, array(array("type", "<>", "album")));
|
||||
foreach($items as $i) {
|
||||
if (!access::can('view_full', $i)) {
|
||||
continue;
|
||||
$items = $container->viewable()
|
||||
->descendants(null, null, array(array("type", "<>", "album")));
|
||||
foreach($items as $i) {
|
||||
if (!access::can('view_full', $i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$i_realpath = realpath($i->file_path());
|
||||
if (!is_readable($i_realpath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$i_relative_path = str_replace($container_realpath.'/', '', $i_realpath);
|
||||
$files[$i_relative_path] = $i_realpath;
|
||||
}
|
||||
|
||||
$relative_path = str_replace($cwd.'/', '', realpath($i->file_path()));
|
||||
if (!is_readable($relative_path)) {
|
||||
continue;
|
||||
}
|
||||
} else if( $container instanceof Tag_Model ) {
|
||||
$items = $container->items();
|
||||
foreach($items as $i) {
|
||||
if (!access::can('view_full', $i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = $relative_path;
|
||||
if( $i->is_album() ) {
|
||||
foreach($this->getFilesList($i) as $f_name => $f_path) {
|
||||
$files[$container->name.'/'.$f_name] = $f_path;
|
||||
}
|
||||
|
||||
} else {
|
||||
$i_realpath = realpath($i->file_path());
|
||||
if (!is_readable($i_realpath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$i_relative_path = $container->name.'/'.$i->name;
|
||||
$files[$i_relative_path] = $i_realpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($files) === 0) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'no zippable files in ['.$album->relative_path().']');
|
||||
exit;
|
||||
throw new Kohana_Exception('no zippable files in ['.$container->name.']');
|
||||
}
|
||||
|
||||
return $files;
|
||||
|
@ -19,14 +19,22 @@
|
||||
*/
|
||||
class downloadalbum_event_Core {
|
||||
static function album_menu($menu, $theme) {
|
||||
if (access::can("view_full", $theme->item)) {
|
||||
$downloadLink = url::site("downloadalbum/zip/{$theme->item->id}");
|
||||
$menu
|
||||
->append(Menu::factory("link")
|
||||
->id("downloadalbum")
|
||||
->label(t("Download Album"))
|
||||
->url($downloadLink)
|
||||
->css_id("g-download-album-link"));
|
||||
}
|
||||
$downloadLink = url::site("downloadalbum/zip/album/{$theme->item->id}");
|
||||
$menu
|
||||
->append(Menu::factory("link")
|
||||
->id("downloadalbum")
|
||||
->label(t("Download Album"))
|
||||
->url($downloadLink)
|
||||
->css_id("g-download-album-link"));
|
||||
}
|
||||
|
||||
static function tag_menu($menu, $theme) {
|
||||
$downloadLink = url::site("downloadalbum/zip/tag/{$theme->tag()->id}");
|
||||
$menu
|
||||
->append(Menu::factory("link")
|
||||
->id("downloadalbum")
|
||||
->label(t("Download Album"))
|
||||
->url($downloadLink)
|
||||
->css_id("g-download-album-link"));
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
*/
|
||||
class downloadalbum_theme {
|
||||
static function head($theme) {
|
||||
if ($theme->item && access::can("view_full", $theme->item)) {
|
||||
$theme->css("downloadalbum_menu.css");
|
||||
}
|
||||
$theme->css("downloadalbum_menu.css");
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "DownloadAlbum"
|
||||
description = "Displays a link to download a ZIP archive of the current album."
|
||||
version = 1
|
||||
version = 2
|
||||
|
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;
|
||||
}
|
||||
|
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"
|
||||
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>
|
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 ($file == null) {
|
||||
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) {
|
||||
$server = '(brentil)';
|
||||
}
|
||||
@ -224,7 +224,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
//Check the Gallery3 Community Contributions GitHub
|
||||
if ($file == null) {
|
||||
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) {
|
||||
$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"
|
||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||
version = 2
|
||||
version = 3
|
||||
|
@ -84,7 +84,11 @@ class albumpassword_Controller extends Controller {
|
||||
|
||||
// Display a success message and close the dialog.
|
||||
message::success(t("Password saved."));
|
||||
<<<<<<< HEAD
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
=======
|
||||
json::reply(array("result" => "success"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
@ -112,10 +116,17 @@ class albumpassword_Controller extends Controller {
|
||||
// If not, close the dialog and display a rejected message.
|
||||
cookie::set("g3_albumpassword", $album_password);
|
||||
message::success(t("Password Accepted."));
|
||||
<<<<<<< HEAD
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
=======
|
||||
json::reply(array("result" => "success"));
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
json::reply(array("result" => "success"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +140,11 @@ class albumpassword_Controller extends Controller {
|
||||
$assignpassword_group->input("assignpassword_password")
|
||||
->id('assignpassword_password')
|
||||
->label(t("Password:"));
|
||||
<<<<<<< HEAD
|
||||
$assignpassword_group->submit("save_password")->value(t("Save"));
|
||||
=======
|
||||
$form->submit("save_password")->value(t("Save"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
@ -139,6 +154,7 @@ class albumpassword_Controller extends Controller {
|
||||
// Generate a form for allowing visitors to enter in their passwords.
|
||||
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||
array("id" => "g-login-password-form"));
|
||||
<<<<<<< HEAD
|
||||
|
||||
$assignpassword_group = $form->group("Enter Password")
|
||||
->label(t("Enter Password:"));
|
||||
@ -147,6 +163,14 @@ class albumpassword_Controller extends Controller {
|
||||
->label(t("Password:"));
|
||||
|
||||
$assignpassword_group->submit("")->value(t("Login"));
|
||||
=======
|
||||
$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"));
|
||||
>>>>>>> gallery3-contrib/master
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
|
@ -36,8 +36,13 @@ class item extends item_Core {
|
||||
}
|
||||
|
||||
// set access::DENY if necessary.
|
||||
<<<<<<< HEAD
|
||||
$view_restrictions = array();
|
||||
if ($deny_access == true) {
|
||||
=======
|
||||
if ($deny_access == true) {
|
||||
$view_restrictions = array();
|
||||
>>>>>>> gallery3-contrib/master
|
||||
if (!identity::active_user()->admin) {
|
||||
foreach (identity::group_ids_for_active_user() as $id) {
|
||||
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||
|
@ -1,3 +1,23 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<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>
|
||||
>>>>>>> gallery3-contrib/master
|
||||
<div id="g-assign-password">
|
||||
<ul>
|
||||
<li id="g-assign-password-form">
|
||||
|
@ -1,3 +1,23 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<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>
|
||||
>>>>>>> gallery3-contrib/master
|
||||
<div id="g-login-password">
|
||||
<ul>
|
||||
<li id="g-login-password-form">
|
||||
|
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;
|
||||
}
|
||||
|
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"
|
||||
description = "Manually edit the creation date of an item in Gallery."
|
||||
version = 1
|
||||
version = 2
|
||||
|
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 ($file == null) {
|
||||
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) {
|
||||
$server = '(brentil)';
|
||||
}
|
||||
@ -224,7 +224,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
//Check the Gallery3 Community Contributions GitHub
|
||||
if ($file == null) {
|
||||
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) {
|
||||
$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"
|
||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||
version = 2
|
||||
version = 3
|
||||
|
Reference in New Issue
Block a user