1
0

Merge branch 'master' of git@github.com:gallery/gallery3-contrib into bharat_dev

This commit is contained in:
Bharat Mediratta 2010-01-25 20:46:35 -08:00
commit 04b8238a44
16 changed files with 131 additions and 34 deletions

View File

@ -3,6 +3,6 @@
<? $not_first = 0; ?> <? $not_first = 0; ?>
<? foreach ($tags as $tag): ?> <? foreach ($tags as $tag): ?>
<?= ($not_first++) ? "," : "" ?> <?= ($not_first++) ? "," : "" ?>
<a href="<?= url::site("tags/{$tag->name}") ?>"><?= html::clean($tag->name) ?></a> <a href="<?= $tag->url() ?>"><?= html::clean($tag->name) ?></a>
<? endforeach ?> <? endforeach ?>
</div> </div>

View File

@ -34,7 +34,7 @@ class Json_Album_Controller extends Controller {
$item = ORM::factory("item", $item_id); $item = ORM::factory("item", $item_id);
access::required("view", $item); access::required("view", $item);
$children = $item->children(null, 0, $where); $children = $item->children(null, null, $where);
$encoded = array(); $encoded = array();
foreach ($children as $id => $child){ foreach ($children as $id => $child){
$encoded[$id] = self::child_json_encode($child); $encoded[$id] = self::child_json_encode($child);
@ -44,7 +44,7 @@ class Json_Album_Controller extends Controller {
} }
function is_admin() { function is_admin() {
if (user::active()->admin) { if (identity::active_user()->admin) {
print json_encode(array("result" => "success", "csrf" => access::csrf_token())); print json_encode(array("result" => "success", "csrf" => access::csrf_token()));
return; return;
} }
@ -54,7 +54,7 @@ class Json_Album_Controller extends Controller {
function albums($item_id) { function albums($item_id) {
print $this->child_elements($item_id,array("type" => "album")); print $this->child_elements($item_id, array(array("type", "=", "album")));
} }
function children($item_id){ function children($item_id){

View File

@ -18,15 +18,19 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
class ldap_installer { class ldap_installer {
static function install() { static function can_activate() {
module::set_version("ldap", 1); $messages = array();
$root = item::root(); if (array_search("ldap", get_loaded_extensions()) === false) {
$ldap_provider = new IdentityProvider("ldap"); $messages["error"][] =
foreach ($ldap_provider->groups() as $group) { t("Cannot install LDAP identity provider as the PHP LDAP extension module is not enabled.");
module::event("group_created", $group); } else {
access::allow($group, "view", $root); $messages["warn"][] = IdentityProvider::confirmation_message();
access::allow($group, "view_full", $root);
} }
return $messages;
}
static function install() {
IdentityProvider::change_provider("ldap");
} }
static function uninstall() { static function uninstall() {
@ -36,4 +40,14 @@ class ldap_installer {
module::event("group_deleted", $group); module::event("group_deleted", $group);
} }
} }
static function initialize() {
module::set_version("ldap", 1);
$root = item::root();
foreach (IdentityProvider::instance()->groups() as $group) {
module::event("group_created", $group);
access::allow($group, "view", $root);
access::allow($group, "view_full", $root);
}
}
} }

View File

@ -239,9 +239,6 @@ class Ldap_User implements User_Definition {
case "id": case "id":
return $this->ldap_entry["uidnumber"][0]; return $this->ldap_entry["uidnumber"][0];
case "groups":
return IdentityProvider_Ldap_Driver::groups_for($this);
case "locale": // @todo case "locale": // @todo
return null; return null;
@ -266,6 +263,10 @@ class Ldap_User implements User_Definition {
} }
} }
public function groups() {
return IdentityProvider_Ldap_Driver::groups_for($this);
}
public function avatar_url($size=80, $default=null) { public function avatar_url($size=80, $default=null) {
return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s", return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s",
md5($this->email), $size, $default ? "&d=" . urlencode($default) : ""); md5($this->email), $size, $default ? "&d=" . urlencode($default) : "");

View File

@ -1,6 +1,3 @@
name = "LDAP" name = "LDAP"
description = "Use LDAP for authentication" description = "Use LDAP for authentication"
version = 1 version = 1
; Don't show this module on the module administration screen
no_module_admin = 1

View File

@ -32,6 +32,9 @@ class Admin_register_Controller extends Admin_Controller {
access::verify_csrf(); access::verify_csrf();
$post = new Validation($_POST); $post = new Validation($_POST);
$post->add_rules("policy", "required");
$post->add_rules("group", array($this, "passthru"));
$post->add_rules("email_verification", array($this, "passthru"));
$group_list = array(); $group_list = array();
if ($post->validate()) { if ($post->validate()) {
module::set_var("registration", "policy", $post->policy); module::set_var("registration", "policy", $post->policy);
@ -49,6 +52,12 @@ class Admin_register_Controller extends Admin_Controller {
} }
} }
// We need this validation callback in order to have the optional fields copied to
// validation array.
public function passthru($field) {
return true;
}
public function activate() { public function activate() {
access::verify_csrf(); access::verify_csrf();

View File

@ -37,13 +37,13 @@ class register_Controller extends Controller {
$policy = module::get_var("registration", "policy"); $policy = module::get_var("registration", "policy");
if ($policy == "visitor") { if ($policy == "visitor") {
if ($pending_user->state == 1) { if ($pending_user->state == 1) {
Session::instance()->set("registration_first_usage");
$user = register::create_new_user($pending_user->id); $user = register::create_new_user($pending_user->id);
Session::instance()->set("registration_first_usage");
auth::login($user); auth::login($user);
Session::instance()->set("registration_first_usage", true); Session::instance()->set("registration_first_usage", true);
$pending_user->delete(); $pending_user->delete();
} else { } else {
register::send_confirmation($pending_user); $user = register::create_new_user($pending_user->id, true);
message::success(t("A confirmation email has been sent to your email address.")); message::success(t("A confirmation email has been sent to your email address."));
} }
} else if ($pending_user->state == 1) { } else if ($pending_user->state == 1) {

View File

@ -21,8 +21,13 @@ class register_Core {
private static $_states; private static $_states;
static function format_registration_state($state) { static function format_registration_state($state) {
if (empty(self::$_state)) { if (empty(self::$_states)) {
self::$_states = array(t("Unconfirmed"), t("Confirmed"), t("Activated")); $policy = module::get_var("registration", "policy");
$email_verification = module::get_var("registration", "email_verification");
$pending = $policy == "admin_only" || ($policy == "admin_approval" && !$email_verification);
self::$_states = array(t("Unconfirmed"),
$pending ? t("Pending") : t("Confirmed"),
t("Activated"));
} }
return self::$_states[$state]; return self::$_states[$state];
} }
@ -37,10 +42,11 @@ class register_Core {
return $user->loaded(); return $user->loaded();
} }
static function send_user_created_confirmation($user) { static function send_user_created_confirmation($user, $requires_first=false) {
$message = new View("register_welcome.html"); $message = new View("register_welcome.html");
$message->user = $user; $message->user = $user;
$message->site_url = url::abs_site("register/first/{$user->hash}"); $message->site_url = $requires_first ? url::abs_site("register/first/{$user->hash}") :
url::abs_site("");
self::_sendemail($user->email, t("Your userid has been created"), $message); self::_sendemail($user->email, t("Your userid has been created"), $message);
} }

View File

@ -31,6 +31,8 @@
<? if (!empty($group_list)): ?> <? if (!empty($group_list)): ?>
<label for="group" class="g-left"> <?= t("Default group: ") ?></label> <label for="group" class="g-left"> <?= t("Default group: ") ?></label>
<?= form::dropdown(array("name" => "group"), $group_list, $form["group"]) ?></label> <?= form::dropdown(array("name" => "group"), $group_list, $form["group"]) ?></label>
<? else: ?>
<?= form::hidden("group", $form["group"]) ?></label>
<? endif ?> <? endif ?>
</li> </li>
<li> <li>

View File

@ -0,0 +1,32 @@
<?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 sso_event {
static function gallery_ready() {
$sso_username = Input::instance()->server("REMOTE_USER");
$user = Session::instance()->get("user");
if (empty($user) || $user->name != $sso_username) {
try {
identity::set_active_user(identity::lookup_user_by_name($sso_username));
} catch (Exception $e) {
Kohana_Log::add("error", "Couldn't authenticate as $sso_username: " .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
}
}
}

3
modules/sso/module.info Normal file
View File

@ -0,0 +1,3 @@
name = "SSO"
description = "Support single-signon authentication"
version = 1

View File

@ -85,8 +85,8 @@ class tagfaces_Controller extends Controller {
$str_face_title = str_replace("'", "\'", Input::instance()->post("face_title")); $str_face_title = str_replace("'", "\'", Input::instance()->post("face_title"));
$str_face_description = str_replace("'", "\'", Input::instance()->post("face_description")); $str_face_description = str_replace("'", "\'", Input::instance()->post("face_description"));
$item_data = Input::instance()->post("item_id"); $item_data = Input::instance()->post("item_id");
$str_x1 = Input::instance()->post("x"); $str_x1 = Input::instance()->post("x1");
$str_y1 = Input::instance()->post("y"); $str_y1 = Input::instance()->post("y1");
$str_x2 = Input::instance()->post("x2"); $str_x2 = Input::instance()->post("x2");
$str_y2 = Input::instance()->post("y2"); $str_y2 = Input::instance()->post("y2");
@ -192,13 +192,17 @@ class tagfaces_Controller extends Controller {
// Generate input boxes to hold the coordinates of the face. // Generate input boxes to hold the coordinates of the face.
$coordinates_group = $form->group("FaceCoordinates") $coordinates_group = $form->group("FaceCoordinates")
->label(t("Coordinates:")); ->label(t("Coordinates:"));
$coordinates_group->input("x") $coordinates_group->input("x1")
->id('x1')
->label(t("X1")); ->label(t("X1"));
$coordinates_group->input("y") $coordinates_group->input("y1")
->id('y1')
->label(t("Y1")); ->label(t("Y1"));
$coordinates_group->input("x2") $coordinates_group->input("x2")
->id('x2')
->label(t("X2")); ->label(t("X2"));
$coordinates_group->input("y2") $coordinates_group->input("y2")
->id('y2')
->label(t("Y2")); ->label(t("Y2"));
// Add the id# of the photo and a save button to the form. // Add the id# of the photo and a save button to the form.

View File

@ -53,8 +53,8 @@
// Our simple event handler, called from onChange and onSelect // Our simple event handler, called from onChange and onSelect
// event handlers, as per the Jcrop invocation above // event handlers, as per the Jcrop invocation above
function showCoords(c) { function showCoords(c) {
jQuery('#x').val(c.x); jQuery('#x1').val(c.x);
jQuery('#y').val(c.y); jQuery('#y1').val(c.y);
jQuery('#x2').val(c.x2); jQuery('#x2').val(c.x2);
jQuery('#y2').val(c.y2); jQuery('#y2').val(c.y2);
}; };
@ -87,10 +87,10 @@
#face_description { #face_description {
width: 400px; width: 400px;
} }
#x { #x1 {
width: 40px; width: 40px;
} }
#y { #y1 {
width: 40px; width: 40px;
} }
#x2 { #x2 {
@ -108,7 +108,7 @@ li {
</style> </style>
<div id="g-coordinates"> <div id="g-coordinates">
<?= $form ?> <?=$form ?>
</div> </div>
<br/><br/><br/> <br/><br/><br/>
@ -121,6 +121,12 @@ li {
</div> </div>
</fieldset> </fieldset>
<br/> <br/>
<div id="g-exit-faces"> <div id="g-exit-faces">

View File

@ -83,7 +83,7 @@
foreach ($existingFaces as $oneFace) { foreach ($existingFaces as $oneFace) {
$oneTag = ORM::factory("tag", $oneFace->tag_id) $oneTag = ORM::factory("tag", $oneFace->tag_id)
?> ?>
<area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=url::site("tags/$oneFace->tag_id") ?>" title="<?=html::clean($oneTag->name); ?>" alt="<?=$oneTag->name; ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=html::clean($oneTag->name); ?>', '<?=html::clean($oneFace->description); ?>', '<?=url::site("tags/$oneFace->tag_id") ?>')" /> <area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=$oneTag->url() ?>" title="<?=html::clean($oneTag->name); ?>" alt="<?=$oneTag->name; ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=html::clean($oneTag->name); ?>', '<?=html::clean($oneFace->description); ?>', '<?=$oneTag->url() ?>')" />
<? } ?> <? } ?>
<? <?

View File

@ -161,4 +161,17 @@ class user_homes_event_Core {
} }
return; return;
} }
static function show_user_profile($data) {
$home = ORM::factory("user_home")->where("id", "=", $data->user->id)->find();
if ($home->loaded()) {
$view = new View("user_profile_home.html");
$item = ORM::factory("item")->where("id", "=", $home->home)->find();
if ($item->loaded()) {
$view->item = $item;
$data->content[] = (object)array("title" => t("Home album"), "view" => $view);
}
}
}
} }

View File

@ -0,0 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-user-home-detail">
<ul>
<li id="g-user_home-<?= $item->id ?>">
<a href="<?= $item->url() ?>">
<?= html::purify($item->title) ?>
</a>
</li>
</ul>
</div>