Merge branch 'master' of git://github.com/Glooper/gallery3-contrib
This commit is contained in:
commit
a765d88d17
@ -1,187 +1,169 @@
|
|||||||
<?php defined("SYSPATH") or die("No direct script access.");
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/*
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2009 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 user_homes_event_Core
|
class user_homes_event_Core {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* called when a user logs in. This will setup the session with the
|
|
||||||
* user home if it exists on the database. This means when the page
|
|
||||||
* is refreshed after logging in the direction can occur.
|
|
||||||
*/
|
|
||||||
static function user_login($user)
|
|
||||||
{
|
|
||||||
$home = ORM::factory("user_home")
|
|
||||||
->where("id", $user->id)->find();
|
|
||||||
if ($home)
|
|
||||||
{
|
|
||||||
if ($home->home!=0)
|
|
||||||
{
|
|
||||||
$session = Session::instance();
|
|
||||||
$session->set("redirect_home",$home->home);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* called when a user logs in. This will setup the session with the
|
||||||
|
* user home if it exists on the database. This means when the page
|
||||||
|
* is refreshed after logging in the direction can occur.
|
||||||
|
*/
|
||||||
|
static function user_login($user) {
|
||||||
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
|
if ($home) {
|
||||||
|
if ($home->home!=0) {
|
||||||
|
$session = Session::instance();
|
||||||
|
$session->set("redirect_home",$home->home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called after a log in occurs and when the first gallery is loaded.
|
* called after a log in occurs and when the first gallery is loaded.
|
||||||
* if the home variable exists on the session then a redirect will
|
* if the home variable exists on the session then a redirect will
|
||||||
* occur to that home and the variable removed from the session to
|
* occur to that home and the variable removed from the session to
|
||||||
*/
|
*/
|
||||||
static function gallery_ready()
|
static function gallery_ready() {
|
||||||
{
|
$session = Session::instance();
|
||||||
|
$home = $session->get("redirect_home");
|
||||||
|
if ($home) {
|
||||||
|
// remove from session to ensure redirect does not
|
||||||
|
// occur again
|
||||||
|
$session->set("redirect_home",null);
|
||||||
|
url::redirect("albums/$home");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$session = Session::instance();
|
/**
|
||||||
$home = $session->get("redirect_home");
|
* called just before a user is deleted. This will remove the user from
|
||||||
if ($home)
|
* the user_homes directory.
|
||||||
{
|
*/
|
||||||
// remove from session to ensure redirect does not
|
static function user_before_delete($user) {
|
||||||
// occur again
|
ORM::factory("user_home")
|
||||||
$session->set("redirect_home",null);
|
->where("id", $user->id)
|
||||||
url::redirect("albums/$home");
|
->delete_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* called when admin is adding a user
|
||||||
|
*/
|
||||||
|
static function user_add_form_admin($user, $form) {
|
||||||
|
$form->add_user->dropdown("user_home")
|
||||||
|
->label(t("Home Gallery"))
|
||||||
|
->options(self::createGalleryArray())
|
||||||
|
->selected(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called just before a user is deleted. This will remove the user from
|
* called after a user has been added
|
||||||
* the user_homes directory.
|
*/
|
||||||
*/
|
static function user_add_form_admin_completed($user, $form) {
|
||||||
static function user_before_delete($user)
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
{
|
$home->id=$user->id;
|
||||||
ORM::factory("user_home")
|
$home->home=$form->add_user->user_home->value;
|
||||||
->where("id", $user->id)
|
$home->save();
|
||||||
->delete_all();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when admin is adding a user
|
* called when admin is editing a user
|
||||||
*/
|
*/
|
||||||
static function user_add_form_admin($user, $form)
|
static function user_edit_form_admin($user, $form) {
|
||||||
{
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
$form->add_user->dropdown("user_home")
|
|
||||||
->label(t("Home Gallery"))
|
|
||||||
->options(self::createGalleryArray())
|
|
||||||
->selected(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if ($home) {
|
||||||
* called after a user has been added
|
$selected = $home->home;
|
||||||
*/
|
} else {
|
||||||
static function user_add_form_admin_completed($user, $form)
|
$selected = 0;
|
||||||
{
|
}
|
||||||
$home = ORM::factory("user_home")
|
$form->edit_user->dropdown("user_home")
|
||||||
->where("id", $user->id)->find();
|
->label(t("Home Gallery"))
|
||||||
$home->id=$user->id;
|
->options(self::createGalleryArray())
|
||||||
$home->home=$form->add_user->user_home->value;
|
->selected($selected);
|
||||||
$home->save();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when admin is editing a user
|
* called after a user had been edited by the admin
|
||||||
*/
|
*/
|
||||||
static function user_edit_form_admin($user, $form)
|
static function user_edit_form_admin_completed($user, $form) {
|
||||||
{
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
$home = ORM::factory("user_home")
|
$home->id=$user->id;
|
||||||
->where("id", $user->id)->find();
|
$home->home=$form->edit_user->user_home->value;
|
||||||
|
$home->save();
|
||||||
if ($home)
|
}
|
||||||
{
|
|
||||||
$selected = $home->home;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$selected = 0;
|
|
||||||
}
|
|
||||||
$form->edit_user->dropdown("user_home")
|
|
||||||
->label(t("Home Gallery"))
|
|
||||||
->options(self::createGalleryArray())
|
|
||||||
->selected($selected);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* called after a user had been edited by the admin
|
|
||||||
*/
|
|
||||||
static function user_edit_form_admin_completed($user, $form)
|
|
||||||
{
|
|
||||||
$home = ORM::factory("user_home")
|
|
||||||
->where("id", $user->id)->find();
|
|
||||||
$home->id=$user->id;
|
|
||||||
$home->home=$form->edit_user->user_home->value;
|
|
||||||
$home->save();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when user is editing their own form
|
* called when user is editing their own form
|
||||||
*/
|
*/
|
||||||
static function user_edit_form($user, $form)
|
static function user_edit_form($user, $form) {
|
||||||
{
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
$home = ORM::factory("user_home")
|
|
||||||
->where("id", $user->id)->find();
|
|
||||||
|
|
||||||
if ($home)
|
if ($home) {
|
||||||
{
|
$selected = $home->home;
|
||||||
$selected = $home->home;
|
} else {
|
||||||
}
|
$selected = 0;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
$selected = 0;
|
|
||||||
}
|
|
||||||
$form->edit_user->dropdown("user_home")
|
|
||||||
->label(t("Home Gallery"))
|
|
||||||
->options(self::createGalleryArray())
|
|
||||||
->selected($selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$form->edit_user->dropdown("user_home")
|
||||||
* called after a user had been edited by the user
|
->label(t("Home Gallery"))
|
||||||
*/
|
->options(self::createGalleryArray())
|
||||||
static function user_edit_form_completed($user, $form)
|
->selected($selected);
|
||||||
{
|
}
|
||||||
$home = ORM::factory("user_home")
|
|
||||||
->where("id", $user->id)->find();
|
|
||||||
$home->id=$user->id;
|
|
||||||
$home->home=$form->edit_user->user_home->value;
|
|
||||||
$home->save();
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* called after a user had been edited by the user
|
||||||
|
*/
|
||||||
|
static function user_edit_form_completed($user, $form) {
|
||||||
|
$home = ORM::factory("user_home")->where("id", $user->id)->find();
|
||||||
|
$home->id=$user->id;
|
||||||
|
$home->home=$form->edit_user->user_home->value;
|
||||||
|
$home->save();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates an array of galleries
|
* creates an array of galleries
|
||||||
*/
|
*/
|
||||||
static function createGalleryArray()
|
static function createGalleryArray() {
|
||||||
{
|
$array[0] = "none";
|
||||||
$array[0] = "none";
|
$root = ORM::factory("item", 1);
|
||||||
$root = ORM::factory("item", 1);
|
self::tree($root, "", $array);
|
||||||
self::tree($root, "", $array);
|
return $array;
|
||||||
|
}
|
||||||
return $array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* recursive function to build array for drop down list
|
|
||||||
*/
|
|
||||||
static function tree($parent, $dashes, &$array)
|
|
||||||
{
|
|
||||||
if ($parent->id == "1")
|
|
||||||
{
|
|
||||||
$array[$parent->id] = "home";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$array[$parent->id] = "$dashes $parent->name";
|
|
||||||
}
|
|
||||||
|
|
||||||
$albums = ORM::factory("item")
|
|
||||||
->where(array("parent_id" => $parent->id, "type" => "album"))
|
|
||||||
->orderby(array("title" => "ASC"))
|
|
||||||
->find_all();
|
|
||||||
foreach ($albums as $album)
|
|
||||||
{
|
|
||||||
self::tree($album, "-$dashes", $array);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* recursive function to build array for drop down list
|
||||||
|
*/
|
||||||
|
static function tree($parent, $dashes, &$array) {
|
||||||
|
if ($parent->id == "1") {
|
||||||
|
$array[$parent->id] = "home";
|
||||||
|
} else {
|
||||||
|
$array[$parent->id] = "$dashes $parent->name";
|
||||||
|
}
|
||||||
|
|
||||||
|
$albums = ORM::factory("item")
|
||||||
|
->where(array("parent_id" => $parent->id, "type" => "album"))
|
||||||
|
->orderby(array("title" => "ASC"))
|
||||||
|
->find_all();
|
||||||
|
foreach ($albums as $album) {
|
||||||
|
self::tree($album, "-$dashes", $array);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,48 @@
|
|||||||
<?php defined("SYSPATH") or die("No direct script access.");
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/*
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2009 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 user_homes_installer
|
class user_homes_installer {
|
||||||
{
|
static function install() {
|
||||||
static function install()
|
module::set_version("user_homes", 1);
|
||||||
{
|
}
|
||||||
module::set_version("user_homes", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* installs the the table of user homes when the
|
* installs the the table of user homes when the
|
||||||
* module is installed
|
* module is installed
|
||||||
*/
|
*/
|
||||||
|
static function activate() {
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->query("CREATE TABLE IF NOT EXISTS {user_homes} (
|
||||||
|
`id` int(9) NOT NULL,
|
||||||
|
`home` int(9) default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY(`id`))
|
||||||
|
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
||||||
|
}
|
||||||
|
|
||||||
static function activate()
|
/**
|
||||||
{
|
* drops the table of user homes when the
|
||||||
$db = Database::instance();
|
* module is uninstalled
|
||||||
$db->query("CREATE TABLE IF NOT EXISTS {user_homes} (
|
*/
|
||||||
`id` int(9) NOT NULL,
|
static function deactivate() {
|
||||||
`home` int(9) default NULL,
|
$db = Database::instance();
|
||||||
PRIMARY KEY (`id`),
|
$db->query("DROP TABLE IF EXISTS {user_homes};");
|
||||||
UNIQUE KEY(`id`))
|
}
|
||||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* drops the table of user homes when the
|
|
||||||
* module is uninstalled
|
|
||||||
*/
|
|
||||||
static function deactivate()
|
|
||||||
{
|
|
||||||
$db = Database::instance();
|
|
||||||
$db->query("DROP TABLE IF EXISTS {user_homes};");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
<?php defined("SYSPATH") or die("No direct script access.");
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
class User_home_Model extends ORM
|
/*
|
||||||
{
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2009 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 User_home_Model extends ORM {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user