Skip to content
Browse files

Merge branch 'master' into talmdal_dev

  • Loading branch information...
2 parents 0273125 + 2257776 commit 0565d9f0f92ef9bd69c38e997e7c6e6d05d56ee1 @talmdal talmdal committed
View
1 modules/gallery/controllers/albums.php
@@ -107,6 +107,7 @@ public function create($parent_id) {
if ($valid) {
$album->save();
+ module::event("album_add_form_completed", $album, $form);
log::success("content", "Created an album",
html::anchor("albums/$album->id", "view album"));
message::success(t("Created album %album_title",
View
2 modules/gallery/controllers/reauthenticate.php
@@ -63,7 +63,7 @@ private static function _form() {
$group->password("password")->label(t("Password"))->id("g-password")->class(null)
->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
- ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages("invalid_password", t("Incorrect password"))
->error_messages(
"too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
View
70 modules/gallery/tests/Item_Rest_Helper_Test.php
@@ -42,13 +42,14 @@ public function get_scope_test() {
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
"entity" => $album1->as_restful_array(),
- "members" => array(
- rest::url("item", $photo1),
- rest::url("item", $album2)),
"relationships" => array(
"tags" => array(
"url" => rest::url("item_tags", $album1),
- "members" => array()))),
+ "members" => array())),
+ "members" => array(
+ rest::url("item", $photo1),
+ rest::url("item", $album2)),
+ ),
item_rest::get($request));
$request->url = rest::url("item", $album1);
@@ -56,13 +57,14 @@ public function get_scope_test() {
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
"entity" => $album1->as_restful_array(),
- "members" => array(
- rest::url("item", $photo1),
- rest::url("item", $album2)),
"relationships" => array(
"tags" => array(
"url" => rest::url("item_tags", $album1),
- "members" => array()))),
+ "members" => array())),
+ "members" => array(
+ rest::url("item", $photo1),
+ rest::url("item", $album2)),
+ ),
item_rest::get($request));
$request->url = rest::url("item", $album1);
@@ -70,14 +72,15 @@ public function get_scope_test() {
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
"entity" => $album1->as_restful_array(),
+ "relationships" => array(
+ "tags" => array(
+ "url" => rest::url("item_tags", $album1),
+ "members" => array())),
"members" => array(
rest::url("item", $photo1),
rest::url("item", $album2),
rest::url("item", $photo2)),
- "relationships" => array(
- "tags" => array(
- "url" => rest::url("item_tags", $album1),
- "members" => array()))),
+ ),
item_rest::get($request));
}
@@ -96,12 +99,13 @@ public function get_children_like_test() {
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
"entity" => $album1->as_restful_array(),
- "members" => array(
- rest::url("item", $photo2)),
"relationships" => array(
"tags" => array(
"url" => rest::url("item_tags", $album1),
- "members" => array()))),
+ "members" => array())),
+ "members" => array(
+ rest::url("item", $photo2)),
+ ),
item_rest::get($request));
}
@@ -118,12 +122,13 @@ public function get_children_type_test() {
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
"entity" => $album1->as_restful_array(),
- "members" => array(
- rest::url("item", $album2)),
"relationships" => array(
"tags" => array(
"url" => rest::url("item_tags", $album1),
- "members" => array() ))),
+ "members" => array())),
+ "members" => array(
+ rest::url("item", $album2)),
+ ),
item_rest::get($request));
}
@@ -134,7 +139,8 @@ public function update_album_test() {
$request = new stdClass();
$request->url = rest::url("item", $album1);
$request->params = new stdClass();
- $request->params->title = "my new title";
+ $request->params->entity = new stdClass();
+ $request->params->entity->title = "my new title";
item_rest::put($request);
$this->assert_equal("my new title", $album1->reload()->title);
@@ -147,8 +153,9 @@ public function update_album_illegal_value_fails_test() {
$request = new stdClass();
$request->url = rest::url("item", $album1);
$request->params = new stdClass();
- $request->params->title = "my new title";
- $request->params->slug = "not url safe";
+ $request->params->entity = new stdClass();
+ $request->params->entity->title = "my new title";
+ $request->params->entity->slug = "not url safe";
try {
item_rest::put($request);
@@ -166,9 +173,10 @@ public function add_album_test() {
$request = new stdClass();
$request->url = rest::url("item", $album1);
$request->params = new stdClass();
- $request->params->type = "album";
- $request->params->name = "my album";
- $request->params->title = "my album";
+ $request->params->entity = new stdClass();
+ $request->params->entity->type = "album";
+ $request->params->entity->name = "my album";
+ $request->params->entity->title = "my album";
$response = item_rest::post($request);
$new_album = rest::resolve($response["url"]);
@@ -183,10 +191,11 @@ public function add_album_illegal_value_fails_test() {
$request = new stdClass();
$request->url = rest::url("item", $album1);
$request->params = new stdClass();
- $request->params->type = "album";
- $request->params->name = "my album";
- $request->params->title = "my album";
- $request->params->slug = "not url safe";
+ $request->params->entity = new stdClass();
+ $request->params->entity->type = "album";
+ $request->params->entity->name = "my album";
+ $request->params->entity->title = "my album";
+ $request->params->entity->slug = "not url safe";
try {
item_rest::post($request);
@@ -205,8 +214,9 @@ public function add_photo_test() {
$request = new stdClass();
$request->url = rest::url("item", $album1);
$request->params = new stdClass();
- $request->params->type = "photo";
- $request->params->name = "my photo.jpg";
+ $request->params->entity = new stdClass();
+ $request->params->entity->type = "photo";
+ $request->params->entity->name = "my photo.jpg";
$request->file = MODPATH . "gallery/tests/test.jpg";
$response = item_rest::post($request);
$new_photo = rest::resolve($response["url"]);
View
1 modules/rest/tests/Rest_Controller_Test.php
@@ -27,6 +27,7 @@ public function setup() {
public function teardown() {
list($_GET, $_POST, $_SERVER) = $this->_save;
+ identity::set_active_user(identity::admin_user());
}
public function login_test() {
View
2 modules/tag/tests/Tag_Item_Rest_Helper_Test.php
@@ -32,7 +32,7 @@ public function get_test() {
$request->url = rest::url("tag_item", $tag, item::root());
$this->assert_equal_array(
array("url" => rest::url("tag_item", $tag, item::root()),
- "members" => array(
+ "entity" => array(
"tag" => rest::url("tag", $tag),
"item" => rest::url("item", item::root()))),
tag_item_rest::get($request));
View
32 modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -67,41 +67,13 @@ public function get_with_no_relationships_test() {
tag_rest::get($request));
}
- public function post_test() {
- $tag = test::random_tag();
-
- // Create an editable item to be tagged
- $album = test::random_album();
- access::allow(identity::everybody(), "edit", $album);
-
- // Add the album to the tag
- $request = new stdClass();
- $request->url = rest::url("tag", $tag);
- $request->params = new stdClass();
- $request->params->url = rest::url("item", $album);
- $this->assert_equal_array(
- array("url" => rest::url("tag_item", $tag, $album)),
- tag_rest::post($request));
- }
-
- public function post_with_no_item_url_test() {
- $request = new stdClass();
- try {
- tag_rest::post($request);
- } catch (Rest_Exception $e) {
- $this->assert_equal(400, $e->getCode());
- return;
- }
-
- $this->assert_true(false, "Shouldn't get here");
- }
-
public function put_test() {
$tag = test::random_tag();
$request = new stdClass();
$request->url = rest::url("tag", $tag);
$request->params = new stdClass();
- $request->params->name = "new name";
+ $request->params->entity = new stdClass();
+ $request->params->entity->name = "new name";
tag_rest::put($request);
$this->assert_equal("new name", $tag->reload()->name);
View
8 modules/tag/tests/Tags_Rest_Helper_Test.php
@@ -45,11 +45,12 @@ public function get_test() {
}
public function post_test() {
- access::allow(identity::everybody(), "edit", item::root());
+ identity::set_active_user(identity::guest());
$request = new stdClass();
$request->params = new stdClass();
- $request->params->name = "test tag";
+ $request->params->entity = new stdClass();
+ $request->params->entity->name = "test tag";
$this->assert_equal(
array("url" => url::site("rest/tag/1")),
tags_rest::post($request));
@@ -63,7 +64,8 @@ public function post_fails_without_permissions_test() {
try {
$request = new stdClass();
$request->params = new stdClass();
- $request->params->name = "test tag";
+ $request->params->entity = new stdClass();
+ $request->params->entity->name = "test tag";
tags_rest::post($request);
} catch (Exception $e) {
$this->assert_equal(403, $e->getCode());
View
2 modules/user/controllers/users.php
@@ -167,7 +167,7 @@ private function _get_change_password_form($user) {
$group->password("old_password")->label(t("Old password"))->id("g-password")
->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
- ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages("invalid_password", t("Incorrect password"))
->error_messages(
"too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
View
8 modules/user/helpers/user.php
@@ -72,7 +72,13 @@ static function is_correct_password($user, $password) {
static function valid_password($password_input) {
if (!user::is_correct_password(identity::active_user(), $password_input->value)) {
- $password_input->add_error("invalid", 1);
+ $password_input->add_error("invalid_password", 1);
+ }
+ }
+
+ static function valid_username($text_input) {
+ if (!self::lookup_by_name($text_input->value)) {
+ $text_input->add_error("invalid_username", 1);
}
}

0 comments on commit 0565d9f

Please sign in to comment.
Something went wrong with that request. Please try again.