Hi, I have filed this the following bugs now: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23272 <- this one has patches https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23271
The idea is that we have Koha::Object::Limit::Library, currently only used in Koha::Patron::Attribute::Type, and we should use it as a reference. But I have a question: I noticed in Koha::AuthorisedValues we overload ->search by allowing it to have a (surprise?) parameter: branchcode. I use the word 'surprise' because we've been leaning to the 'least surprise' principle and allowing to pass an attribute name that isn't in the model, seems like a surprise we would like to avoid. I would like to propose we create an analogous Koha::Objects::Limit::Library class (notice the plural), implementing a specialized search method, with a name that clearly states the goal as discussed previously in the context of a bug I now don't remember :-D In the lines of sub search_with_branch_limits { my ( $self, $params, $attributes, $library_id ) = @_; my $or = $library_id ? { '-or' => [ 'authorised_values_branches.branchcode' => undef, 'authorised_values_branches.branchcode' => $library_id, ] } : {}; my $join = $library_id ? { join => 'authorised_values_branches' } : {}; $attributes //= {}; $attributes = { %$attributes, %$join }; return $self->SUPER::search( { %$params, %$or, }, $attributes ); } Note: I'd replace the table and column names for the configured ones. Opinions? -- Tomás Cohen Arazi Theke Solutions (http://theke.io) ✆ +54 9351 3513384 GPG: B2F3C15F
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/