<field reporter:label="Transmission Format" name="transmission_format" reporter:datatype="text"/>
<field reporter:label="Auth" name="auth" reporter:datatype="bool"/>
<field reporter:label="Attrs" name="attrs" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Use Permission" name="use_perm" reporter:datatype="link"/>
</fields>
<links>
<link field="attrs" reltype="has_many" key="source" map="" class="cza"/>
+ <link field="use_perm" reltype="has_a" key="id" map="" class="ppl"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
method => "query_services",
api_name => "open-ils.search.z3950.retrieve_services",
signature => q/
+ @param auth The login session key
Returns a list of service names that we have config
data for
/
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('REMOTE_Z3950_QUERY');
- return fetch_service_defs();
+ return fetch_service_defs($e);
}
# -------------------------------------------------------------------
# -------------------------------------------------------------------
sub fetch_service_defs {
+ my $editor_with_authtoken = shift;
+
my $hash = $sclient->config_value('z3950', 'services');
# overlay config file values with in-db values
- my $e = new_editor();
+ my $e = $editor_with_authtoken || new_editor();
if($e->can('search_config_z3950_source')) {
my $sources = $e->search_config_z3950_source(
record_format => $s->record_format,
transmission_format => $s->transmission_format,
auth => $s->auth,
+ use_perm => ($s->use_perm) ?
+ $e->retrieve_permission_perm_list($s->use_perm)->code : ''
};
for my $a ( @{ $s->attrs } ) {
}
};
+ # then filter out any services which the requestor lacks the perm for
+ foreach my $s (keys %{ $hash }) {
+ if ($$hash{$s}{use_perm}) {
+ if ($U->check_perms(
+ $e->requestor->id,
+ $e->requestor->ws_ou,
+ $$hash{$s}{use_perm}
+ )) {
+ delete $$hash{$s};
+ }
+ };
+ }
+
%services = %$hash; # cache these internally so we can actually use the db-configured sources
return $hash;
}
db TEXT NOT NULL,
record_format TEXT NOT NULL DEFAULT 'FI',
transmission_format TEXT NOT NULL DEFAULT 'usmarc',
- auth BOOL NOT NULL DEFAULT TRUE
+ auth BOOL NOT NULL DEFAULT TRUE,
+ use_perm INT -- REFERENCES permission.perm_list (id)
);
COMMENT ON TABLE config.z3950_source IS $$
Z39.50 preferred record syntax..
$$;
+COMMENT ON COLUMN config.z3950_source.use_perm IS $$
+If set, this permission is required for the source to be listed in the staff
+client Z39.50 interface. Similar to permission.grp_tree.application_perm.
+$$;
CREATE TABLE config.z3950_attr (
id SERIAL PRIMARY KEY,
CREATE INDEX by_heading_and_thesaurus ON authority.record_entry (authority.normalize_heading(marc)) WHERE deleted IS FALSE or deleted = FALSE;
CREATE INDEX by_heading ON authority.record_entry (authority.simple_normalize_heading(marc)) WHERE deleted IS FALSE or deleted = FALSE;
+ALTER TABLE config.z3950_source ADD CONSTRAINT use_perm_fkey FOREIGN KEY (use_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
+
COMMIT;
--- /dev/null
+-- Evergreen DB patch XXXX.schema.czs_use_perm_column.sql
+--
+-- This adds a column to config.z3950_source called use_perm.
+-- The idea is that if a permission is set for a given source,
+-- then staff will need the referenced permission to use that
+-- source.
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE config.z3950_source
+ ADD COLUMN use_perm INT REFERENCES permission.perm_list (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+COMMENT ON COLUMN config.z3950_source.use_perm IS $$
+If set, this permission is required for the source to be listed in the staff
+client Z39.50 interface. Similar to permission.grp_tree.application_perm.
+$$;
+
+COMMIT;