mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-05 04:29:09 -04:00
Merge branch 'master' into talmdal_dev
Conflicts: modules/gallery/controllers/admin_users.php modules/gallery/controllers/password.php modules/gallery/helpers/group.php modules/gallery/helpers/user.php modules/notification/helpers/notification.php
This commit is contained in:
@@ -22,8 +22,8 @@ class Admin_Users_Controller extends Admin_Controller {
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_users.html");
|
||||
$view->content->writable = user::is_writable();
|
||||
$view->content->users = user::users(array("orderby" => array("name" => "ASC")));
|
||||
$view->content->groups = group::groups(array("orderby" => array("name" => "ASC")));
|
||||
$view->content->users = user::get_user_list(array("orderby" => array("name" => "ASC")));
|
||||
$view->content->groups = group::get_group_list(array("orderby" => array("name" => "ASC")));
|
||||
print $view;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,18 @@ class Movies_Controller extends Items_Controller {
|
||||
access::required("edit", $movie);
|
||||
|
||||
$form = movie::get_edit_form($movie);
|
||||
if ($valid = $form->validate()) {
|
||||
$valid = $form->validate();
|
||||
|
||||
if ($valid) {
|
||||
$new_ext = pathinfo($form->edit_item->filename->value, PATHINFO_EXTENSION);
|
||||
$old_ext = pathinfo($photo->name, PATHINFO_EXTENSION);
|
||||
if (strcasecmp($new_ext, $old_ext)) {
|
||||
$form->edit_item->filename->add_error("illegal_extension", 1);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
if ($form->edit_item->filename->value != $movie->name ||
|
||||
$form->edit_item->slug->value != $movie->slug) {
|
||||
// Make sure that there's not a name or slug conflict
|
||||
|
||||
@@ -32,7 +32,7 @@ class Password_Controller extends Controller {
|
||||
if (request::method() == "post") {
|
||||
$this->_change_password();
|
||||
} else {
|
||||
$user = user::lookyp_by_hash(Input::instance()->get("key"));
|
||||
$user = user::lookup_by_hash(Input::instance()->get("key"));
|
||||
if (!empty($user)) {
|
||||
print $this->_new_password_form($user->hash);
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ class Password_Controller extends Controller {
|
||||
private function _change_password() {
|
||||
$view = $this->_new_password_form();
|
||||
if ($view->content->validate()) {
|
||||
$user = user::lookyp_by_hash(Input::instance()->get("key"));
|
||||
$user = user::lookup_by_hash(Input::instance()->get("key"));
|
||||
if (empty($user)) {
|
||||
throw new Exception("@todo FORBIDDEN", 503);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,17 @@ class Photos_Controller extends Items_Controller {
|
||||
|
||||
$form = photo::get_edit_form($photo);
|
||||
$valid = $form->validate();
|
||||
if ($valid = $form->validate()) {
|
||||
|
||||
if ($valid) {
|
||||
$new_ext = pathinfo($form->edit_item->filename->value, PATHINFO_EXTENSION);
|
||||
$old_ext = pathinfo($photo->name, PATHINFO_EXTENSION);
|
||||
if (strcasecmp($new_ext, $old_ext)) {
|
||||
$form->edit_item->filename->add_error("illegal_extension", 1);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
if ($form->edit_item->filename->value != $photo->name ||
|
||||
$form->edit_item->slug->value != $photo->slug) {
|
||||
// Make sure that there's not a name or slug conflict
|
||||
|
||||
@@ -91,7 +91,7 @@ class group_Core {
|
||||
* @return Group_Model the group object, or null if the id was invalid.
|
||||
*/
|
||||
static function lookup($id) {
|
||||
return Identity::instance()->lookup_group($id);
|
||||
return Identity::instance()->lookup_group_by_field("id", $id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,16 +100,16 @@ class group_Core {
|
||||
* @return Group_Core the group object, or null if the name was invalid.
|
||||
*/
|
||||
static function lookup_by_name($name) {
|
||||
return Identity::instance()->lookup_group_by_name($name);
|
||||
return Identity::instance()->lookup_group_by_field("name", $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the groups
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @param mixed options to apply to the selection of the user (@see Database.php)
|
||||
* @return array the group list.
|
||||
*/
|
||||
static function groups($filter=array()) {
|
||||
return Identity::instance()->list_groups($filter);
|
||||
static function get_group_list($filter=array()) {
|
||||
return Identity::instance()->get_group_list($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,7 +141,8 @@ class movie_Core {
|
||||
->callback("item::validate_no_slashes")
|
||||
->error_messages("no_slashes", t("The movie name can't contain a \"/\""))
|
||||
->callback("item::validate_no_trailing_period")
|
||||
->error_messages("no_trailing_period", t("The movie name can't end in \".\""));
|
||||
->error_messages("no_trailing_period", t("The movie name can't end in \".\""))
|
||||
->error_messages("illegal_extension", t("You cannot change the filename extension"));
|
||||
$group->input("slug")->label(t("Internet Address"))->value($movie->slug)
|
||||
->callback("item::validate_url_safe")
|
||||
->error_messages(
|
||||
|
||||
@@ -169,7 +169,8 @@ class photo_Core {
|
||||
->callback("item::validate_no_slashes")
|
||||
->error_messages("no_slashes", t("The photo name can't contain a \"/\""))
|
||||
->callback("item::validate_no_trailing_period")
|
||||
->error_messages("no_trailing_period", t("The photo name can't end in \".\""));
|
||||
->error_messages("no_trailing_period", t("The photo name can't end in \".\""))
|
||||
->error_messages("illegal_extension", t("You cannot change the filename extension"));
|
||||
$group->input("slug")->label(t("Internet Address"))->value($photo->slug)
|
||||
->callback("item::validate_url_safe")
|
||||
->error_messages(
|
||||
|
||||
@@ -310,18 +310,19 @@ class user_Core {
|
||||
* @return User_Model the user object, or null if the id was invalid.
|
||||
*/
|
||||
static function lookup($id) {
|
||||
return Identity::instance()->lookup_user($id);
|
||||
return Identity::instance()->lookup_user_by_field("id", $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by name.
|
||||
* @param integer $id the user name
|
||||
* @param integer $name the user name
|
||||
* @return User_Model the user object, or null if the name was invalid.
|
||||
*/
|
||||
static function lookup_by_name($name) {
|
||||
return Identity::instance()->lookup_user_by_field("name", $name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Look up a user by hash.
|
||||
* @param string $name the user name
|
||||
@@ -336,8 +337,8 @@ class user_Core {
|
||||
* @param mixed options to apply to the selection of the user(optional)
|
||||
* @return array the group list.
|
||||
*/
|
||||
static function users($filter=array()) {
|
||||
return Identity::instance()->list_users($filter);
|
||||
static function get_user_list($filter=array()) {
|
||||
return Identity::instance()->get_user_list($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,15 +146,6 @@ class Identity_Core {
|
||||
return $this->driver->hash_password($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by id.
|
||||
* @param integer $id the user id
|
||||
* @return Identity_Model the user object, or null if the id was invalid.
|
||||
*/
|
||||
public function lookup_user($id) {
|
||||
return $this->driver->lookup_user($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by field value.
|
||||
* @param string search field
|
||||
@@ -193,22 +184,13 @@ class Identity_Core {
|
||||
return $this->driver->everybody();
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a group by id.
|
||||
* @param integer $id the user id
|
||||
* @return Group_Model the group object, or null if the id was invalid.
|
||||
*/
|
||||
public function lookup_group($id) {
|
||||
return $this->driver->lookup_group($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a group by name.
|
||||
* @param integer $id the group name
|
||||
* @return Group_Model the group object, or null if the name was invalid.
|
||||
*/
|
||||
public function lookup_group_by_name($name) {
|
||||
return $this->driver->lookup_group_by_name($name);
|
||||
public function lookup_group_by_field($field_name, $value) {
|
||||
return $this->driver->lookup_group_by_field($field_name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,8 +198,8 @@ class Identity_Core {
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_users($filter=array()) {
|
||||
return $this->driver->list_users($filter);
|
||||
public function get_user_list($filter=array()) {
|
||||
return $this->driver->get_user_list($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,8 +207,8 @@ class Identity_Core {
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_groups($filter=array()) {
|
||||
return $this->driver->list_groups($filter);
|
||||
public function get_group_list($filter=array()) {
|
||||
return $this->driver->get_group_list($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,15 +52,9 @@ interface Identity_Driver {
|
||||
* @return string hashed password
|
||||
*/
|
||||
public function hash_password($password);
|
||||
/**
|
||||
* Look up a user by id.
|
||||
* @param integer $id the user id
|
||||
* @return User_Core the user object, or null if the id was invalid.
|
||||
*/
|
||||
public function lookup_user($id);
|
||||
|
||||
/**
|
||||
* Look up a user by name.
|
||||
* Look up a user by by search the specified field.
|
||||
* @param string search field
|
||||
* @param string search value
|
||||
* @return User_Core the user object, or null if the name was invalid.
|
||||
@@ -89,35 +83,21 @@ interface Identity_Driver {
|
||||
*/
|
||||
public function registered_users();
|
||||
|
||||
/**
|
||||
* Look up a group by id.
|
||||
* @param integer $id the user id
|
||||
* @return Group_Model the group object, or null if the id was invalid.
|
||||
*/
|
||||
public function lookup_group($id);
|
||||
|
||||
/**
|
||||
* Look up a group by name.
|
||||
* @param integer $id the group name
|
||||
* @return Group_Model the group object, or null if the name was invalid.
|
||||
*/
|
||||
public function lookup_group_by_name($name);
|
||||
|
||||
/**
|
||||
* List the users
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @todo Do a longer write up on format of filters (@see Database.php)
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_users($filter=array());
|
||||
public function get_user_list($filter=array());
|
||||
|
||||
/**
|
||||
* List the groups
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @param mixed options to apply to the selection of the group
|
||||
* @todo Do a longer write up on format of filters (@see Database.php)
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_groups($filter=array());
|
||||
public function get_group_list($filter=array());
|
||||
|
||||
/**
|
||||
* Return the edit rules associated with an group.
|
||||
|
||||
@@ -33,7 +33,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
} catch (Exception $e) { }
|
||||
|
||||
try {
|
||||
$user = ORM::factory("user")->where("name", "access_test")->find();
|
||||
$user = user::lookup_by_name("access_test");
|
||||
if ($user->loaded) {
|
||||
$user->delete();
|
||||
}
|
||||
@@ -307,7 +307,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
$group->save();
|
||||
access::allow($group, "edit", $root);
|
||||
|
||||
$user = ORM::factory("user", $user->id); // reload() does not flush related columns
|
||||
$user = user::lookup($user->id); // reload() does not flush related columns
|
||||
user::set_active($user);
|
||||
|
||||
// And verify that the user can edit.
|
||||
|
||||
@@ -79,8 +79,8 @@ class notification {
|
||||
$subscriber_ids[] = $subscriber->user_id;
|
||||
}
|
||||
|
||||
$users = user::users(array("in" => array("id", $subscriber_ids),
|
||||
"where" => array("email IS NOT" => null)));
|
||||
$users = user::get_user_list(array("in" => array("id", $subscriber_ids),
|
||||
"where" => array("email IS NOT" => null)));
|
||||
|
||||
$subscribers = array();
|
||||
foreach ($users as $user) {
|
||||
|
||||
@@ -104,19 +104,6 @@ class Identity_Gallery_Driver implements Identity_Driver {
|
||||
return $hashGenerator->HashPassword($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by id.
|
||||
* @param integer $id the user id
|
||||
* @return User_Model the user object, or null if the id was invalid.
|
||||
*/
|
||||
public function lookup_user($id) {
|
||||
$user = model_cache::get("user", $id);
|
||||
if ($user->loaded) {
|
||||
return new Gallery_User($user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by field value.
|
||||
* @param string search field
|
||||
@@ -174,27 +161,15 @@ class Identity_Gallery_Driver implements Identity_Driver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a user by id.
|
||||
* @param integer $id the user id
|
||||
* @return User_Model the user object, or null if the id was invalid.
|
||||
* Look up a group by field value.
|
||||
* @param string search field
|
||||
* @param string search value
|
||||
* @return Group_Core the group object, or null if the name was invalid.
|
||||
*/
|
||||
public function lookup_group($id) {
|
||||
$group = model_cache::get("group", $id);
|
||||
if ($group->loaded) {
|
||||
return new Gallery_Group($group);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a group by name.
|
||||
* @param integer $id the group name
|
||||
* @return Group_Model the group object, or null if the name was invalid.
|
||||
*/
|
||||
public function lookup_group_by_name($name) {
|
||||
public function lookup_user_by_field($field_name, $value) {
|
||||
try {
|
||||
$group = model_cache::get("group", $name, "name");
|
||||
if ($group->loaded) {
|
||||
$user = model_cache::get("group", $value, $field_name);
|
||||
if ($user->loaded) {
|
||||
return new Gallery_Group($group);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -205,12 +180,13 @@ class Identity_Gallery_Driver implements Identity_Driver {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List the users
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_users($filter=array()) {
|
||||
public function get_user_list($filter=array()) {
|
||||
$results = $this->_do_search("user", $filter);
|
||||
$users = array();
|
||||
foreach ($results->as_array() as $user) {
|
||||
@@ -222,10 +198,10 @@ class Identity_Gallery_Driver implements Identity_Driver {
|
||||
|
||||
/**
|
||||
* List the groups
|
||||
* @param mixed options to apply to the selection of the user
|
||||
* @param mixed options to apply to the selection of the group
|
||||
* @return array the group list.
|
||||
*/
|
||||
public function list_groups($filter=array()) {
|
||||
public function get_group_list($filter=array()) {
|
||||
$results = $this->_do_search("group", $filter);
|
||||
$groups = array();
|
||||
foreach ($results->as_array() as $group) {
|
||||
|
||||
Reference in New Issue
Block a user