Bugzilla – Attachment 66246 Details for
Bug 8628
Add digital signs to the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8628: [FOLLOW-UP] Add digital signs to the OPAC
Bug-8628-FOLLOW-UP-Add-digital-signs-to-the-OPAC.patch (text/plain), 59.77 KB, created by
Aleisha Amohia
on 2017-08-20 21:52:15 UTC
(
hide
)
Description:
Bug 8628: [FOLLOW-UP] Add digital signs to the OPAC
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2017-08-20 21:52:15 UTC
Size:
59.77 KB
patch
obsolete
>From 766ba364f56f7521cc284661413e91267e66a950 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Wed, 4 Jan 2017 22:28:32 +0000 >Subject: [PATCH] Bug 8628: [FOLLOW-UP] Add digital signs to the OPAC > >This patch rewrites all modules from the original patch to be object >oriented. > >Follows above test plan. > >Sponsored-by: Region Halland >--- > Koha/Schema/Result/SavedSql.pm | 21 +- > Koha/Schema/Result/Sign.pm | 132 ++++++++ > Koha/Schema/Result/SignStream.pm | 105 +++++++ > Koha/Schema/Result/SignsToStream.pm | 114 +++++++ > Koha/Sign.pm | 40 +++ > Koha/SignStream.pm | 40 +++ > Koha/SignStreams.pm | 59 ++++ > Koha/Signs.pm | 343 +++------------------ > Koha/SignsToStream.pm | 40 +++ > Koha/SignsToStreams.pm | 59 ++++ > .../mysql/atomicupdate/bug_8628-digital-signs.sql | 2 +- > installer/data/mysql/kohastructure.sql | 45 +++ > .../intranet-tmpl/prog/en/includes/tools-menu.inc | 3 + > .../intranet-tmpl/prog/en/modules/tools/signs.tt | 149 ++++----- > opac/opac-signs.pl | 72 ++++- > tools/signs.pl | 126 +++++--- > 16 files changed, 922 insertions(+), 428 deletions(-) > create mode 100644 Koha/Schema/Result/Sign.pm > create mode 100644 Koha/Schema/Result/SignStream.pm > create mode 100644 Koha/Schema/Result/SignsToStream.pm > create mode 100644 Koha/Sign.pm > create mode 100644 Koha/SignStream.pm > create mode 100644 Koha/SignStreams.pm > create mode 100644 Koha/SignsToStream.pm > create mode 100644 Koha/SignsToStreams.pm > >diff --git a/Koha/Schema/Result/SavedSql.pm b/Koha/Schema/Result/SavedSql.pm >index cb32ef0..57e8bf2 100644 >--- a/Koha/Schema/Result/SavedSql.pm >+++ b/Koha/Schema/Result/SavedSql.pm >@@ -162,9 +162,26 @@ __PACKAGE__->add_columns( > > __PACKAGE__->set_primary_key("id"); > >+=head1 RELATIONS > >-# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-24 09:58:16 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eGWRRzpe1+EBialePAIhMQ >+=head2 sign_streams >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::SignStream> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "sign_streams", >+ "Koha::Schema::Result::SignStream", >+ { "foreign.saved_sql_id" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f9cgj30zP/aIRPhEmZNT6g > > > # You can replace this text with custom content, and it will be preserved on regeneration >diff --git a/Koha/Schema/Result/Sign.pm b/Koha/Schema/Result/Sign.pm >new file mode 100644 >index 0000000..a39489f >--- /dev/null >+++ b/Koha/Schema/Result/Sign.pm >@@ -0,0 +1,132 @@ >+use utf8; >+package Koha::Schema::Result::Sign; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::Sign >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<signs> >+ >+=cut >+ >+__PACKAGE__->table("signs"); >+ >+=head1 ACCESSORS >+ >+=head2 sign_id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 name >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 64 >+ >+=head2 webapp >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 transition >+ >+ data_type: 'char' >+ default_value: 'none' >+ is_nullable: 0 >+ size: 16 >+ >+=head2 swatch >+ >+ data_type: 'char' >+ default_value: (empty string) >+ is_nullable: 0 >+ size: 1 >+ >+=head2 idleafter >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 pagedelay >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 reloadafter >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "sign_id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "name", >+ { data_type => "varchar", is_nullable => 1, size => 64 }, >+ "webapp", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, >+ "transition", >+ { data_type => "char", default_value => "none", is_nullable => 0, size => 16 }, >+ "swatch", >+ { data_type => "char", default_value => "", is_nullable => 0, size => 1 }, >+ "idleafter", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, >+ "pagedelay", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, >+ "reloadafter", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</sign_id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("sign_id"); >+ >+=head1 RELATIONS >+ >+=head2 signs_to_streams >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::SignsToStream> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "signs_to_streams", >+ "Koha::Schema::Result::SignsToStream", >+ { "foreign.sign_id" => "self.sign_id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OWtbToVshm6D/q7jMbhAEA >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/SignStream.pm b/Koha/Schema/Result/SignStream.pm >new file mode 100644 >index 0000000..864998a >--- /dev/null >+++ b/Koha/Schema/Result/SignStream.pm >@@ -0,0 +1,105 @@ >+use utf8; >+package Koha::Schema::Result::SignStream; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::SignStream >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<sign_streams> >+ >+=cut >+ >+__PACKAGE__->table("sign_streams"); >+ >+=head1 ACCESSORS >+ >+=head2 sign_stream_id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 saved_sql_id >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 name >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 64 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "sign_stream_id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "saved_sql_id", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "name", >+ { data_type => "varchar", is_nullable => 1, size => 64 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</sign_stream_id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("sign_stream_id"); >+ >+=head1 RELATIONS >+ >+=head2 saved_sql >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::SavedSql> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "saved_sql", >+ "Koha::Schema::Result::SavedSql", >+ { id => "saved_sql_id" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, >+); >+ >+=head2 signs_to_streams >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::SignsToStream> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "signs_to_streams", >+ "Koha::Schema::Result::SignsToStream", >+ { "foreign.sign_stream_id" => "self.sign_stream_id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+QnTPOZSc8xl1o2qI0YB8A >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/SignsToStream.pm b/Koha/Schema/Result/SignsToStream.pm >new file mode 100644 >index 0000000..f13e772 >--- /dev/null >+++ b/Koha/Schema/Result/SignsToStream.pm >@@ -0,0 +1,114 @@ >+use utf8; >+package Koha::Schema::Result::SignsToStream; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::SignsToStream >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<signs_to_streams> >+ >+=cut >+ >+__PACKAGE__->table("signs_to_streams"); >+ >+=head1 ACCESSORS >+ >+=head2 sign_to_stream_id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 sign_stream_id >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 sign_id >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 params >+ >+ data_type: 'varchar' >+ default_value: (empty string) >+ is_nullable: 0 >+ size: 255 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "sign_to_stream_id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "sign_stream_id", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "sign_id", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "params", >+ { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</sign_to_stream_id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("sign_to_stream_id"); >+ >+=head1 RELATIONS >+ >+=head2 sign >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Sign> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "sign", >+ "Koha::Schema::Result::Sign", >+ { sign_id => "sign_id" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, >+); >+ >+=head2 sign_stream >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::SignStream> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "sign_stream", >+ "Koha::Schema::Result::SignStream", >+ { sign_stream_id => "sign_stream_id" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fAi1KA4VmwQM96sQoI5DMQ >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/Koha/Sign.pm b/Koha/Sign.pm >new file mode 100644 >index 0000000..6c8c7fc >--- /dev/null >+++ b/Koha/Sign.pm >@@ -0,0 +1,40 @@ >+package Koha::Sign; >+ >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use base qw( Koha::Object ); >+ >+=head1 NAME >+ >+Koha::Sign - Koha Sign object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+sub _type { >+ return 'Sign'; >+} >+ >+1; >diff --git a/Koha/SignStream.pm b/Koha/SignStream.pm >new file mode 100644 >index 0000000..daabddc >--- /dev/null >+++ b/Koha/SignStream.pm >@@ -0,0 +1,40 @@ >+package Koha::SignStream; >+ >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use base qw( Koha::Object ); >+ >+=head1 NAME >+ >+Koha::SignStream - Koha SignStream object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+sub _type { >+ return 'SignStream'; >+} >+ >+1; >diff --git a/Koha/SignStreams.pm b/Koha/SignStreams.pm >new file mode 100644 >index 0000000..26b5596 >--- /dev/null >+++ b/Koha/SignStreams.pm >@@ -0,0 +1,59 @@ >+package Koha::SignStreams; >+ >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+use Koha::SignStream; >+ >+use base qw( Koha::Objects ); >+ >+=head1 NAME >+ >+Koha::SignStreams - Koha SignStream object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SignStream'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::SignStream'; >+} >+ >+=head1 AUTHOR >+ >+Aleisha Amohia <aleisha@catalyst.net.nz> >+ >+=cut >+ >+1; >diff --git a/Koha/Signs.pm b/Koha/Signs.pm >index a542e2e..da32aff 100644 >--- a/Koha/Signs.pm >+++ b/Koha/Signs.pm >@@ -1,330 +1,59 @@ > package Koha::Signs; > >-use C4::Context; >-use C4::Biblio; >-use C4::Koha; >-use C4::Items; >-use Modern::Perl; >- >-use base qw( Exporter ); >- >-# set the version for version checking >-our @EXPORT = qw( >- >- AddSignStream >- ModSignStream >- GetSignStream >- GetSignStreams >- DelSignStream >- >- GetSignStreamRecords >- >- AddSign >- ModSign >- GetSign >- GetSigns >- DelSign >- >- AttachSignStreamToSign >- DetachSignStreamFromSign >- GetSignStreamsAttachedToSign >- GetSignStreamsAttachedToSignWithRecords >- >- ModSignStreamParams >- GetSignStreamParams >-); >- >-my $dbh = C4::Context->dbh; >- >-# Streams >- >-# Returns id of new sign_stream >-sub AddSignStream { >- >- my ( $name, $report ) = @_; >- >- my $sth=$dbh->prepare("INSERT INTO sign_streams SET name = ?, saved_sql_id = ?"); >- $sth->execute( $name, $report ); >- return $dbh->last_insert_id( undef, undef, 'sign_streams', 'sign_stream_id' ); >- >-} >- >-sub ModSignStream { >- >- my ( $name, $report, $sign_stream_id ) = @_; >- >- my $sth = $dbh->prepare("UPDATE sign_streams SET name = ?, saved_sql_id = ? WHERE sign_stream_id = ?"); >- return $sth->execute( $name, $report, $sign_stream_id ); >- >-} >- >-sub GetSignStream { >- >- my ( $sign_id ) = @_; >- >- return unless $sign_id; >- >- my $query = "SELECT s.*, sq.report_name, sq.savedsql >- FROM sign_streams AS s, saved_sql AS sq >- WHERE s.saved_sql_id = sq.id >- AND s.sign_stream_id = ?"; >- my $sth = $dbh->prepare($query); >- $sth->execute($sign_id); >- return $sth->fetchrow_hashref(); >- >-} >- >-sub GetSignStreams { >- >- my $query = "SELECT s.*, sq.report_name, sq.savedsql >- FROM sign_streams AS s, saved_sql AS sq >- WHERE s.saved_sql_id = sq.id >- ORDER BY s.name"; >- my $sth = $dbh->prepare($query); >- $sth->execute(); >- return $sth->fetchall_arrayref({}); >- >-} >- >-sub DelSignStream { >- >- my ( $sign_stream_id ) = @_; >- >- return unless $sign_stream_id; >- >- my $sth = $dbh->prepare('DELETE FROM sign_streams WHERE sign_stream_id = ?'); >- return $sth->execute($sign_stream_id); >- >-} >- >-sub GetSignStreamRecords { >- my ( $stream, $sign_to_stream_id) = @_; >- my $sql = $stream->{'savedsql'}; >- >- if ( defined $sign_to_stream_id ) { >- my $params = GetSignStreamParams( $sign_to_stream_id ); >- $sql = ReplaceParamsInSQL( $sql, $params ); >- return undef if ( $sql =~ m/<</ ); >- } >- >- return {result => RunSQL( $sql ), sql => $sql }; >-} >- >-# Signs >- >-# Returns id of new sign >-sub AddSign { >- >- my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ) = @_; >- >- my $sth=$dbh->prepare("INSERT INTO signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ?"); >- $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ); >- return $dbh->last_insert_id( undef, undef, 'signs', 'sign_id' ); >- >-} >- >-sub ModSign { >- >- my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ) = @_; >- >- my $sth = $dbh->prepare("UPDATE signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ? WHERE sign_id = ?"); >- return $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ); >- >-} >- >-sub GetSign { >- >- my ( $sign_id ) = @_; >- >- return unless $sign_id; >- >- my $query = "SELECT * >- FROM signs >- WHERE sign_id = ?"; >- my $sth = $dbh->prepare($query); >- $sth->execute($sign_id); >- return $sth->fetchrow_hashref(); >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-} >- >-sub GetSigns { >- >- my $query = "SELECT * >- FROM signs >- ORDER BY name"; >- my $sth = $dbh->prepare($query); >- $sth->execute(); >- return $sth->fetchall_arrayref({}); >- >-} >- >-sub DelSign { >- >- my ( $sign_id ) = @_; >- >- return unless $sign_id; >- >- my $sth = $dbh->prepare('DELETE FROM signs WHERE sign_id = ?'); >- return $sth->execute($sign_id); >- >-} >- >-# Streams attached to signs >- >-# Returns the ID of the connection between sign and stream >-sub AttachSignStreamToSign { >- >- my ( $sign_stream_id, $sign_id ) = @_; >- >- return unless $sign_stream_id || $sign_id; >- >- my $sth = $dbh->prepare( 'INSERT INTO signs_to_streams SET sign_stream_id = ?, sign_id = ?' ); >- $sth->execute( $sign_stream_id, $sign_id ); >- return $dbh->last_insert_id( undef, undef, 'signs_to_streams', 'sign_to_stream_id' ); >- >-} >- >-sub ModSignStreamParams { >- >- my ( $sign_to_stream_id, $params ) = @_; >- return unless $sign_to_stream_id; >- my $sth = $dbh->prepare( 'UPDATE signs_to_streams SET params = ? WHERE sign_to_stream_id = ?' ); >- return $sth->execute( $params, $sign_to_stream_id ); >- >-} >- >-# Returns the string of params for a given stream-attached-to-sign >-sub GetSignStreamParams { >- >- my ( $sign_to_stream_id ) = @_; >- >- return unless $sign_to_stream_id; >- >- my $query = 'SELECT params FROM signs_to_streams WHERE sign_to_stream_id = ?'; >- my $sth = $dbh->prepare( $query ); >- $sth->execute( $sign_to_stream_id ); >- return $sth->fetchrow_array(); >- >-} >- >-sub ReplaceParamsInSQL { >- >- my ( $sql, $params ) = @_; >- >- return unless $sql || $params; >- return $sql unless $sql =~ m/<</; >- >- foreach my $param ( split /&/, $params ) { >- my ( $key, $value ) = split /=/, $param; >- # FIXME Handle spaces >- $sql =~ s/<<$key>>/$value/g; >- } >- return $sql; >- >-} >- >-sub GetSignStreamsAttachedToSign { >- >- my ( $sign_id ) = @_; >- >- return unless $sign_id; >- >- my $query = 'SELECT s.*, sts.sign_to_stream_id, sts.params, sq.report_name, sq.savedsql >- FROM sign_streams AS s, signs_to_streams AS sts, saved_sql AS sq >- WHERE s.sign_stream_id = sts.sign_stream_id >- AND s.saved_sql_id = sq.id >- AND sts.sign_id = ? >- ORDER BY s.name'; >- my $sth = $dbh->prepare( $query ); >- $sth->execute( $sign_id ); >- return $sth->fetchall_arrayref({}); >- >-} >- >-sub GetSignStreamsAttachedToSignWithRecords { >- >- my ( $sign_id, $include_marc ) = @_; >- >- return unless $sign_id; >- >- my $streams = GetSignStreamsAttachedToSign( $sign_id ); >- my @changedstreams; >- my %record_cache = (); >- >- # Add records to the streams >- foreach my $stream ( @{$streams} ) { >- >- my $records = RunSQL( ReplaceParamsInSQL( $stream->{'savedsql'}, $stream->{'params'} ) ); >- >- if ( $include_marc ) { >- >- my @processed_records; >- foreach my $rec ( @{$records} ) { >- unless(defined $record_cache{$rec->{'biblionumber'}}) { >- my $marc = GetMarcBiblio( $rec->{'biblionumber'} ); >- if ( ! $marc ) { >- next; >- } >- >- my $isbn = GetNormalizedISBN( undef, $marc, C4::Context->preference("marcflavor") ) || ''; >- $rec->{'isbn'} = $isbn; >+use Modern::Perl; > >- my $dat = GetBiblioData($rec->{'biblionumber'}); >- my @items = GetItemsInfo($rec->{'biblionumber'}); >- foreach my $item ( @items ) { >- my $shelflocations = GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac'); >- if ( defined $item->{'location'} ) { >- $item->{'location_description'} = $shelflocations->{ $item->{'location'} }; >- } >- } >- $rec->{'items'} = \@items; >- foreach ( keys %{$dat} ) { >- $rec->{"$_"} = defined $dat->{$_} ? $dat->{$_} : ''; >- } >+use Koha::Database; >+use Koha::Sign; > >- $rec->{'marc'} = $marc; >+use base qw( Koha::Objects ); > >- $record_cache{$rec->{'biblionumber'}} = $rec; >- } >- push @processed_records, $record_cache{$rec->{'biblionumber'}}; >- } >- $stream->{'records'} = \@processed_records; >+=head1 NAME > >- } else { >+Koha::Signs - Koha Sign object set class > >- $stream->{'records'} = $records; >+=head1 API > >- } >+=head2 Class Methods > >- push @changedstreams, $stream; >+=cut > >- } >+=head3 type > >- return \@changedstreams; >+=cut > >+sub _type { >+ return 'Sign'; > } > >-sub DetachSignStreamFromSign { >- >- my ( $sign_to_stream_id ) = @_; >- >- return unless $sign_to_stream_id; >+=head3 object_class > >- my $sth = $dbh->prepare( 'DELETE FROM signs_to_streams WHERE sign_to_stream_id = ?' ); >- return $sth->execute( $sign_to_stream_id ); >+=cut > >+sub object_class { >+ return 'Koha::Sign'; > } > >-sub RunSQL { >+=head1 AUTHOR > >- my ( $query ) = @_; >+Aleisha Amohia <aleisha@catalyst.net.nz> > >- return unless $query; >- >- my $sth = $dbh->prepare($query); >- $sth->execute(); >- return $sth->fetchall_arrayref({}); >- >-} >+=cut > > 1; >diff --git a/Koha/SignsToStream.pm b/Koha/SignsToStream.pm >new file mode 100644 >index 0000000..b76f160 >--- /dev/null >+++ b/Koha/SignsToStream.pm >@@ -0,0 +1,40 @@ >+package Koha::SignsToStream; >+ >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use base qw( Koha::Object ); >+ >+=head1 NAME >+ >+Koha::SignsToStream - SignsToStream object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+sub _type { >+ return 'SignsToStream'; >+} >+ >+1; >diff --git a/Koha/SignsToStreams.pm b/Koha/SignsToStreams.pm >new file mode 100644 >index 0000000..c677bcb >--- /dev/null >+++ b/Koha/SignsToStreams.pm >@@ -0,0 +1,59 @@ >+package Koha::SignsToStreams; >+ >+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# This file is part of Koha. >+# >+# Koha 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 3 of the License, or (at your option) any later >+# version. >+# >+# Koha 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 Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+use Koha::SignsToStream; >+ >+use base qw( Koha::Objects ); >+ >+=head1 NAME >+ >+Koha::SignsToStreams - Koha SignsToStream object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SignsToStream'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::SignsToStream'; >+} >+ >+=head1 AUTHOR >+ >+Aleisha Amohia <aleisha@catalyst.net.nz> >+ >+=cut >+ >+1; >diff --git a/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql b/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql >index 4c608b2..002a3f3 100644 >--- a/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql >+++ b/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql >@@ -1,4 +1,3 @@ >-DROP TABLE IF EXISTS signs_to_streams; > DROP TABLE IF EXISTS sign_streams; > CREATE TABLE sign_streams ( > sign_stream_id int(11) NOT NULL auto_increment, -- primary key, used to identify streams >@@ -19,6 +18,7 @@ CREATE TABLE signs ( > reloadafter int(11) NOT NULL default 0, -- seconds to wait before reloading all the pages > PRIMARY KEY (sign_id) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+DROP TABLE IF EXISTS signs_to_streams; > CREATE TABLE signs_to_streams ( > sign_to_stream_id int(11) NOT NULL auto_increment, -- primary key, used to identify connections between signs and streams (the same stream can be attached to a sign more than once, with different parameters) > sign_stream_id int(11) NOT NULL, -- foreign key from the decks sign_streams table >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index e227125..a720d06 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -4099,6 +4099,51 @@ CREATE TABLE IF NOT EXISTS club_fields ( > CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > >+-- >+-- Table structure for table 'sign_streams' >+-- >+ >+DROP TABLE IF EXISTS sign_streams; >+CREATE TABLE sign_streams ( >+ `sign_stream_id` int(11) NOT NULL auto_increment, -- primary key, used to identify streams >+ `saved_sql_id` int(11) NOT NULL, -- foreign key from the saved_sql table >+ `name` varchar(64), -- name/title of the sign >+ PRIMARY KEY (`sign_stream_id`), >+ CONSTRAINT `sign_streams_ibfk_1` FOREIGN KEY (`saved_sql_id`) REFERENCES `saved_sql` (`id`) ON DELETE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Table structure for table 'signs' >+-- >+ >+DROP TABLE IF EXISTS signs; >+CREATE TABLE signs ( >+ `sign_id` int(11) NOT NULL auto_increment, -- primary key, used to identify signs >+ `name` varchar(64), -- name/title of the deck >+ `webapp` int(1) NOT NULL DEFAULT 0, -- display as web app or normal page >+ `transition` char(16) NOT NULL DEFAULT 'none', -- transition to use between pages, must be one of the transitions defined by jQuery Mobile (see their docs) >+ `swatch` char(1) NOT NULL DEFAULT '', -- swatches determine the colors of page elements >+ `idleafter` int(11) NOT NULL default 0, -- seconds to wait before automatic page turning clicks in >+ `pagedelay` int(11) NOT NULL default 0, -- seconds to wait before turning to a new page/record >+ `reloadafter` int(11) NOT NULL default 0, -- seconds to wait before reloading all the pages >+ PRIMARY KEY (`sign_id`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Table structure for table 'signs_to_streams' >+-- >+ >+DROP TABLE IF EXISTS signs_to_streams; >+CREATE TABLE signs_to_streams ( >+ `sign_to_stream_id` int(11) NOT NULL auto_increment, -- primary key, used to identify connections between signs and streams (the same stream can be attached to a sign more than once, with different parameters) >+ `sign_stream_id` int(11) NOT NULL, -- foreign key from the decks sign_streams table >+ `sign_id` int(11) NOT NULL, -- foreign key from the signs table >+ `params` varchar(255) NOT NULL DEFAULT '', -- list of parameters for the SQL associated with the sign_stream >+ PRIMARY KEY (`sign_to_stream_id`), >+ CONSTRAINT `signs_to_streams_ibfk_1` FOREIGN KEY (`sign_stream_id`) REFERENCES `sign_streams` (`sign_stream_id`) ON DELETE CASCADE, >+ CONSTRAINT `signs_to_streams_ibfk_2` FOREIGN KEY (`sign_id`) REFERENCES `signs` (`sign_id`) ON DELETE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ > /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; > /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; > /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >index d7b40cf..6453ed0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >@@ -119,6 +119,9 @@ > [% IF ( CAN_user_tools_edit_quotes ) %] > <li><a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a></li> > [% END %] >+ [% IF ( CAN_user_tools_edit_digital_signs ) %] >+ <li><a href="/cgi-bin/koha/tools/signs.pl">Digital signs</a></li> >+ [% END %] > [% IF ( UseKohaPlugins && CAN_user_plugins_tool ) %] > <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt >index 100c814..b9bec0c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt >@@ -6,35 +6,25 @@ > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> > //<![CDATA[ >- >- // prepare DOM for YUI Toolbar >- $(document).ready(function() { >+ // prepare DOM for YUI Toolbar >+ $(document).ready(function() { > $("#table_signs").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumns": [ >- null, >- {"bSearchable": false}, >- {"bSearchable": false}, >- {"bSearchable": false}, >- {"bSearchable": false}, >- {"bSearchable": false}, >- {"bSearchable": false}, >- {"bSearchable": false, "bSortable": false}, >- {"bSearchable": false, "bSortable": false}, >- {"bSearchable": false, "bSortable": false}, >- {"bSearchable": false, "bSortable": false} >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSearchable": false, "bSortable": false }, > ], > "sPaginationType": "four_button" >- } )); >+ })); > $("#table_streams").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumns": [ >- null, >- {"bSearchable": false}, >- {"bSearchable": false, "bSortable": false}, >- {"bSearchable": false, "bSortable": false}, >+ "aoColumnDefs": [ >+ { "aTargets" : [ -1 ], "bSearchable": false, "bSortable": false }, > ], > "sPaginationType": "four_button" >- } )); >- }); >+ })); >+ >+ $(".detach").on("click", function(){ >+ return confirmDelete(_("Are you sure you want to detach this stream from this sign?")); >+ }); >+ }); > //]]> > </script> > </head> >@@ -80,26 +70,21 @@ > </div> > > <div id="doc3" class="yui-t2"> >- >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >+<div id="bd"> >+<div id="yui-main"> >+<div class="yui-b"> > > [% UNLESS Koha.Preference( 'OPACDigitalSigns' ) %] > <div class="dialog alert"> >- <p> >- Digital signs are not enabled. Please enable >- <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=OPACDigitalSigns">OPACDigitalSigns</a> >- for OPAC digital signs to work. >- </p> >+ <p>Digital signs are not enabled. Please enable <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=OPACDigitalSigns">OPACDigitalSigns</a> for OPAC digital signs to work.</p> > </div> > [% END %] > > [% IF ( else ) %] > <div id="toolbar"> > <ul class="toolbar"> >- <li><a id="newsign" href="?op=add_sign" class="btn btn-small"><i class="icon-plus"></i>New sign</a></li> >- <li><a id="newstream" href="?op=add_stream" class="btn btn-small"><i class="icon-plus"></i>New stream</a></li> >+ <li><a id="newsign" href="?op=add_sign" class="btn btn-small"><i class="fa fa-plus"></i> New sign</a></li> >+ <li><a id="newstream" href="?op=add_stream" class="btn btn-small"><i class="fa fa-plus"></i> New stream</a></li> > </ul> > </div> > [% END %] >@@ -127,8 +112,8 @@ > <fieldset class="rows"> > <ol> > <li><label for="name">Name</label><input type="text" name="name" value="[% stream.name %]" /></li> >- <li><label for="report">Report</label> >- <select name="report" id="report"> >+ <li><label for="report" class="required">Report</label> >+ <select name="report" id="report" class="required" required="required"> > [% UNLESS ( stream.sign_stream_id ) %] > <option value="">Choose report</option> > [% END %] >@@ -140,6 +125,7 @@ > [% END %] > [% END %] > </select> >+ <span class="required">Required</span> > </li> > </ol> > </fieldset> >@@ -223,24 +209,28 @@ > > <h1>Edit streams attached to [% sign.name %]</h1> > <h2>Streams already attached to this sign</h2> >- [% IF ( attached.size ) %] >+ [% IF ( sts ) %] > <table> > <thead> >- <tr><th>Name</th><th>Parameters</th><th>Edit parameters</th><th>Detach</th></tr> >+ <tr> >+ <th>Name</th> >+ <th colspan="2">Parameters</th> >+ <th> </th> >+ </tr> > </thead> > <tbody> >- [% FOREACH s IN attached %] >+ [% FOREACH s IN sts %] > <tr> >- <td>[% s.name %]</td> >- <td>[% s.params %]</td> >- <td>[% IF s.savedsql.match('<<') %]<a href="?op=get_params&sign_to_stream_id=[% s.sign_to_stream_id %]&sign_stream_id=[% s.sign_stream_id %]&sign_id=[% sign.sign_id %]">Edit parameters</a>[% ELSE %]No parameters[% END %]</td> >- <td><a href="?op=detach_stream_from_sign&sign_id=[% sign.sign_id %]&sign_to_stream_id=[% s.sign_to_stream_id %]">Detach</a></td> >+ <td>[% s.sign_stream.name %]</td> >+ <td>[% IF ( s.params ) %][% s.params %][% ELSE %]None[% END %]</td> >+ <td class="actions">[% IF ( s.params ) %]<a href="?op=get_params&sign_to_stream_id=[% s.sign_to_stream_id %]&sign_stream_id=[% s.sign_stream_id %]&sign_id=[% s.sign_id %]" class="btn btn-mini" title="Edit parameters"><i class="fa fa-pencil"></i></a>[% ELSE %]<a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% s.sign_stream.saved_sql_id %]&phase=Edit SQL" class="btn btn-mini" title="Edit SQL"><i class="fa fa-pencil"></i></a>[% END %]</td> >+ <td class="actions"><a href="?op=detach_stream_from_sign&sign_id=[% sign.sign_id %]&sign_to_stream_id=[% s.sign_to_stream_id %]" class="btn btn-mini detach"><i class="fa fa-times"></i> Detach</a></td> > </tr> > [% END %] > </tbody> > </table> > [% ELSE %] >- <p>There are no streams attached to this sign, yet.</p> >+ <p>There are no streams attached to this sign.</p> > [% END %] > > <h2>Attach a new stream to this sign</h2> >@@ -264,7 +254,7 @@ > [% ELSIF op == 'get_params' %] > > <h1>Parameters for [% stream.name %]</h1> >- <p>Based on report: [% stream.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a></p> >+ <p>Based on report: [% sql.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a></p> > > <form action="[% script_name %]" name="get_params_form" id="get_params_form" method="post"> > <input type="hidden" name="op" value="save_params" /> >@@ -272,14 +262,14 @@ > <input type="hidden" name="sign_stream_id" value="[% sign_stream_id %]" /> > <input type="hidden" name="sign_id" value="[% sign_id %]" /> > <fieldset class="rows"> >- [% IF ( params ) %] >+ [% IF ( params.params ) %] > <legend id="save_params_lgd">Edit parameters</legend> > [% ELSE %] > <legend id="save_params_lgd">Add parameters</legend> > [% END %] > <ol> > <li><label for="stream">Parameters</label> >- <input type="text" size="60" name="parameters" id="parameters" value="[% params %]" /> >+ <input type="text" size="60" name="parameters" id="parameters" value="[% params.params %]" /> > </li> > </ol> > </fieldset> >@@ -287,7 +277,7 @@ > </form> > > <h2>Raw SQL</h2> >- <pre id="sql_output">[% stream.savedsql | html %]</pre> >+ <pre id="sql_output">[% sql.savedsql | html %]</pre> > > <h2>SQL with current parameters replaced</h2> > <pre id="sql_output">[% newsql | html %]</pre> >@@ -305,10 +295,11 @@ > <form action="[% script_name %]" id ="confirm_stream_delete_form" method="post"> > <input type="hidden" name="op" value="del_stream_ok" /> > <input type="hidden" name="sign_stream_id" value="[% stream.sign_stream_id %]" /> >- <input type="submit" class="approve" value="Yes, Delete this stream" /></form> >+ <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this stream</button> >+ </form> > > <form action="[% script_name %]" id="cancel_stream_delete_form" method="get"> >- <input type="submit" value="No, do not delete" class="deny" /> >+ <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> > </form> > </div> > >@@ -328,10 +319,11 @@ > <form action="[% script_name %]" id ="confirm_sign_delete_form" method="post"> > <input type="hidden" name="op" value="del_sign_ok" /> > <input type="hidden" name="sign_id" value="[% sign.sign_id %]" /> >- <input type="submit" class="approve" value="Yes, Delete this sign" /></form> >+ <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this sign</button> >+ </form> > > <form action="[% script_name %]" id="cancel_sign_delete_form" method="get"> >- <input type="submit" value="No, do not delete" class="deny" /> >+ <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> > </form> > </div> > >@@ -351,7 +343,7 @@ > > [% IF ( streams ) %] > [% FOREACH stream IN streams %] >- <h3>[% stream.name %]</h3> >+ <h3>[% stream.sign_stream.name %]</h3> > <ul> > [% FOREACH record IN stream.records %] > <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.biblionumber %]">[% record.title %]</a></li> >@@ -365,12 +357,12 @@ > [% ELSIF op == 'view_stream' %] > > <h1>[% stream.name %]</h1> >- <p>Based on report: [% stream.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a></p> >+ <p>Based on report: [% stream.saved_sql_id.report_name %] | <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% stream.saved_sql_id %]&phase=Edit SQL">Edit this report</a></p> > <h2>SQL</h2> >- <pre id="sql_output">[% stream.savedsql | html %]</pre> >+ <pre id="sql_output">[% stream.saved_sql_id.savedsql | html %]</pre> > <h2>Records</h2> > [% IF ( has_params ) %] >- <p>Sorry, the report this stream is based on has parameters and displaying it only makes sense after it has been attached to a sign and parameters have been added.</p> >+ <p>Unable to display records. Check that this stream has been attached to a sign and any parameters have been filled appropriately.</p> > [% ELSE %] > [% INCLUDE display_records %] > [% END %] >@@ -379,8 +371,14 @@ > > <h1>Digital signs</h1> > >+ [% IF ( error_on_insert_stream ) %] >+ <div class="dialog error">Failed to create a new stream.</div> >+ [% ELSIF ( success_on_insert_stream ) %] >+ <div class="dialog message">New stream added.</div> >+ [% END %] >+ >+ <h2>Signs</h2> > [% IF signs %] >- <h2>Signs</h2> > <table id="table_signs"> > <thead> > <tr> >@@ -391,10 +389,7 @@ > <th>Idle after</th> > <th>Page delay</th> > <th>Reload after</th> >- <th>Edit</th> >- <th>Edit streams</th> >- <th>Delete</th> >- <th>View sign</th> >+ <th> </th> > </tr> > </thead> > <tbody> >@@ -407,43 +402,51 @@ > <td>[% s.idleafter %]</td> > <td>[% s.pagedelay %]</td> > <td>[% s.reloadafter %]</td> >- <td><a href="?op=edit_sign&sign_id=[% s.sign_id %]">Edit</a></td> >- <td><a href="?op=edit_streams&sign_id=[% s.sign_id %]">Edit streams</a></td> >- <td><a href="?op=del_sign&sign_id=[% s.sign_id %]">Delete</a></td> >- <td>[% IF ( OPACBaseURL ) %]<a href="http://[% OPACBaseURL %]/cgi-bin/koha/opac-signs.pl?sign=[% s.sign_id %]" title="View this sign in the OPAC">View sign</a>[% END %]</td> >+ <td> >+ <div class="dropdown"> >+ <a class="btn btn-mini dropdown-toggle" id="opensignsactions[% s.sign_id %]" role="button" data-toggle="dropdown" href="#"> Actions <b class="caret"></b></a> >+ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="opensignsactions[% s.sign_id %]"> >+ <li><a href="/cgi-bin/koha/tools/signs.pl?op=edit_sign&sign_id=[% s.sign_id %]"><i class="fa fa-pencil"></i> Edit</a></li> >+ <li><a href="/cgi-bin/koha/tools/signs.pl?op=edit_streams&sign_id=[% s.sign_id %]"><i class="fa fa-pencil"></i> Edit streams</a></li> >+ <li><a href="/cgi-bin/koha/tools/signs.pl?op=del_sign&sign_id=[% s.sign_id %]"><i class="fa fa-trash"></i> Delete</a></li> >+ [% IF ( OPACBaseURL ) %]<li><a href="[% OPACBaseURL %]/cgi-bin/koha/opac-signs.pl?sign=[% s.sign_id %]" title="View this sign in the OPAC"><i class="fa fa-eye"></i> View sign</a></li>[% END %] >+ </ul> >+ </div> >+ </td> > </tr> > [% END %] > </tbody> > </table> > [% UNLESS ( OPACBaseURL ) %]<p>Please note: Links to view signs in the OPAC will only be displayed if you fill in the OPACBaseURL system preference.</p>[% END %] > [% ELSE %] >- <p>No signs defined!</p> >+ <div class="dialog message">No signs defined. <a href="/cgi-bin/koha/tools/signs.pl?op=add_sign">Create a new sign.</a></div> > [% END %] > >+ <h2>Streams</h2> > [% IF streams %] >- <h2>Streams</h2> > <table id="table_streams"> > <thead> > <tr> > <th>Name</th> > <th>Report</th> >- <th>Edit</th> >- <th>Delete</th> >+ <th>Actions</th> > </tr> > </thead> > <tbody> > [% FOREACH s IN streams %] > <tr> > <td><a href="?op=view_stream&sign_stream_id=[% s.sign_stream_id %]">[% s.name %]</a></td> >- <td title="ID: [% s.saved_sql_id %]">[% s.report_name %]</td> >- <td><a href="?op=edit_stream&sign_stream_id=[% s.sign_stream_id %]">Edit</a></td> >- <td><a href="?op=del_stream&sign_stream_id=[% s.sign_stream_id %]">Delete</a></td> >+ <td>[% FOREACH r IN reports %][% IF r.id == s.saved_sql_id %][% r.report_name %][% END %][% END %]</td> >+ <td class="actions"> >+ <a href="/cgi-bin/koha/tools/signs.pl?op=edit_stream&sign_stream_id=[% s.sign_stream_id %]" class="btn btn-mini"><i class="fa fa-pencil"></i> Edit</a> >+ <a href="/cgi-bin/koha/tools/signs.pl?op=del_stream&sign_stream_id=[% s.sign_stream_id %]" class="btn btn-mini"><i class="fa fa-trash"></i> Delete</a> >+ </td> > </tr> > [% END %] > </tbody> > </table> > [% ELSE %] >- <p>No streams defined!</p> >+ <div class="dialog message">No streams defined. <a href="/cgi-bin/koha/tools/signs.pl?op=add_stream">Create a new stream.</a></div> > [% END %] > > [% END %] >diff --git a/opac/opac-signs.pl b/opac/opac-signs.pl >index 66057df..5db1791 100755 >--- a/opac/opac-signs.pl >+++ b/opac/opac-signs.pl >@@ -20,7 +20,15 @@ > use CGI; > use C4::Auth; > use C4::Output; >+use C4::Biblio; >+use C4::Reports::Guided; >+use C4::Context; >+use C4::Koha; >+use C4::Items; >+use Koha::AuthorisedValues; > use Koha::Signs; >+use Koha::SignStreams; >+use Koha::SignsToStreams; > use Modern::Perl; > > binmode STDOUT, ':encoding(UTF-8)'; # FIXME Non-ASCII is broken without this >@@ -38,11 +46,65 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ > > if ( C4::Context->preference('OPACDigitalSigns') ) { > if ( $sign_id ne '' ) { # Display a sign with streams >- $template->{VARS}->{'sign'} = GetSign( $sign_id ); >- $template->{VARS}->{'streams'} = GetSignStreamsAttachedToSignWithRecords( $sign_id, 1 ); >- } >- else { # Display a list of all available signs >- $template->{VARS}->{'signs'} = GetSigns(); >+ $template->{VARS}->{'sign'} = Koha::Signs->find( $sign_id ); >+ >+ # Getting sign streams attached to sign with records >+ my $schema = Koha::Database->new()->schema(); >+ my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); >+ my @changedstreams; >+ my %record_cache = (); >+ foreach my $s ( @signstostreams ) { >+ my $stream = Koha::SignStreams->find( $s->sign_stream_id ); >+ my $sql = get_saved_report($stream->saved_sql_id); >+ my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $s->sign_to_stream_id }); >+ >+ # Generate SQL with added params >+ my $newsql = $sql->{'savedsql'}; >+ foreach my $param ( split /&/, $params->params ) { >+ my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself >+ $newsql =~ s/$key/$value/g; >+ } >+ >+ # Run query with new sql >+ my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); >+ if ( ! $error ) { >+ $records = $records->fetchall_arrayref({}); >+ } >+ # Include marc >+ my @processed_records; >+ foreach my $rec ( @{$records} ) { >+ unless (defined $record_cache{$rec->{'biblionumber'}}) { >+ my $marc = GetMarcBiblio( $rec->{'biblionumber'} ); >+ if ( ! $marc ) { >+ next; >+ } >+ >+ my $isbn = GetNormalizedISBN( undef, $marc, C4::Context->preference("marcflavor") ) || ''; >+ $rec->{'isbn'} = $isbn; >+ >+ my $dat = GetBiblioData($rec->{'biblionumber'}); >+ my @items = GetItemsInfo($rec->{'biblionumber'}); >+ foreach my $item ( @items ) { >+ my $shelflocations = { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) }; >+ if ( defined $item->{'location'} ) { >+ $item->{'location_description'} = $shelflocations->{ $item->{'location'} }; >+ } >+ } >+ $rec->{'items'} = \@items; >+ foreach ( keys %{$dat} ) { >+ $rec->{"$_"} = defined $dat->{$_} ? $dat->{$_} : ''; >+ } >+ $rec->{'marc'} = $marc; >+ $record_cache{$rec->{'biblionumber'}} = $rec; >+ } >+ push @processed_records, $record_cache{$rec->{'biblionumber'}}; >+ } >+ $s->{'records'} = \@processed_records; >+ push @changedstreams, $s; >+ } >+ $template->{VARS}->{'streams'} = \@changedstreams; >+ } else { # Display a list of all available signs >+ $template->{VARS}->{'signs'} = Koha::Signs->search({}); > } > } > >diff --git a/tools/signs.pl b/tools/signs.pl >index 702829d..dfb3f8d 100755 >--- a/tools/signs.pl >+++ b/tools/signs.pl >@@ -16,9 +16,6 @@ > # You should have received a copy of the GNU General Public License along > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >-# >-# >-# > > =head1 NAME > >@@ -34,7 +31,12 @@ Allows authorized users to create and manage digital signs for the OPAC. > > =cut > >+use Koha::Sign; > use Koha::Signs; >+use Koha::SignStream; >+use Koha::SignStreams; >+use Koha::SignsToStreams; >+ > use CGI; > use C4::Auth; > use C4::Context; >@@ -73,7 +75,7 @@ if ( $op eq 'add_stream' ) { > > } elsif ( $op eq 'edit_stream' && $sign_stream_id ne '') { > >- my $stream = GetSignStream( $sign_stream_id ); >+ my $stream = Koha::SignStreams->find( $sign_stream_id ); > > $template->param( > 'op' => 'stream_form', >@@ -84,22 +86,25 @@ if ( $op eq 'add_stream' ) { > > } elsif ( $op eq 'save_stream' ) { > >+ my $name = $cgi->param('name'); >+ my $report = $cgi->param('report'); > if ( $sign_stream_id ne '' ) { >- ModSignStream( $cgi->param('name'), $cgi->param('report'), $cgi->param('sign_stream_id') ); >+ Koha::SignStreams->find( $sign_stream_id )->set({ name => $name, saved_sql_id => $report })->store; # modify > } else { >- AddSignStream( $cgi->param('name'), $cgi->param('report'), ); >+ Koha::SignStream->new({ name => $name, saved_sql_id => $report })->store; # add new > } > print $cgi->redirect($script_name); > > } elsif ( $op eq 'view_stream' && $sign_stream_id ne '' ) { >- >- my $stream = GetSignStream( $sign_stream_id ); >- >- if ( $stream->{'savedsql'} =~ m/<</ ) { >- $template->param( 'has_params' => 1 ); >+ my $stream = Koha::SignStreams->find( $sign_stream_id ); >+ my $report = get_saved_report($stream->saved_sql_id); >+ my $sql = $report->{'savedsql'}; >+ my ( $records, $error ) = execute_query( $sql, 0, 999999 ); >+ if ( $records && not $error ) { >+ $records = $records->fetchall_arrayref({}); >+ $template->param( 'records' => $records ); > } else { >- my $records = GetSignStreamRecords( $stream ); >- $template->param( 'records' => $records->{result} ); >+ $template->param( 'has_params' => 1 ); > } > > $template->param( >@@ -110,7 +115,7 @@ if ( $op eq 'add_stream' ) { > > } elsif ( $op eq 'del_stream' ) { > >- my $stream = GetSignStream( $sign_stream_id ); >+ my $stream = Koha::SignStreams->find( $sign_stream_id ); > > $template->param( > 'op' => 'del_stream', >@@ -119,8 +124,7 @@ if ( $op eq 'add_stream' ) { > ); > > } elsif ( $op eq 'del_stream_ok' ) { >- >- DelSignStream( $sign_stream_id ); >+ Koha::SignStreams->find( $sign_stream_id )->delete; > > $template->param( > 'op' => 'del_stream_ok', >@@ -139,25 +143,48 @@ if ( $op eq 'add_stream' ) { > > $template->param( > 'op' => 'sign_form', >- 'sign' => GetSign( $sign_id ), >+ 'sign' => Koha::Signs->find( $sign_id ), > 'script_name' => $script_name, > ); > > } elsif ( $op eq 'save_sign' ) { > > if ($cgi->param('sign_id')) { >- ModSign( $cgi->param('name'), $cgi->param('webapp'), $cgi->param('swatch'), $cgi->param('transition'), $cgi->param('idleafter'), $cgi->param('pagedelay'), $cgi->param('reloadafter'), $cgi->param('sign_id') ); >+ Koha::Signs->find( $cgi->param('sign_id') )->set({ name => $cgi->param('name'), webapp => $cgi->param('webapp'), swatch => $cgi->param('swatch'), transition => $cgi->param('transition'), idleafter => $cgi->param('idleafter'), pagedelay => $cgi->param('pagedelay'), reloadafter => $cgi->param('reloadafter') })->store; # modify > } else { >- AddSign( $cgi->param('name'), $cgi->param('webapp'), $cgi->param('swatch'), $cgi->param('transition'), $cgi->param('idleafter'), $cgi->param('pagedelay'), $cgi->param('reloadafter') ); >+ Koha::Sign->new({ name => $cgi->param('name'), webapp => $cgi->param('webapp'), swatch => $cgi->param('swatch'), transition => $cgi->param('transition'), idleafter => $cgi->param('idleafter'), pagedelay => $cgi->param('pagedelay'), reloadafter => $cgi->param('reloadafter') })->store; # add new > } > print $cgi->redirect($script_name); > > } elsif ( $op eq 'view_sign' && $sign_id ne '' ) { > >+ # Getting sign streams attached to sign with records >+ my $schema = Koha::Database->new()->schema(); >+ my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); >+ my @changedstreams; >+ >+ foreach my $s ( @signstostreams ) { >+ my $stream = Koha::SignStreams->find( $s->sign_stream_id ); >+ my $sql = get_saved_report($stream->saved_sql_id); >+ my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $s->sign_to_stream_id }); >+ # Generate SQL with added params >+ my $newsql = $sql->{'savedsql'}; >+ foreach my $param ( split /&/, $params->params ) { >+ my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself >+ $newsql =~ s/$key/$value/g; >+ } >+ # Run query with new sql >+ my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); >+ if ( $records && not $error ) { >+ $s->{'records'} = $records->fetchall_arrayref({}); >+ push @changedstreams, $s; >+ } >+ } >+ > $template->param( > 'op' => 'view_sign', >- 'sign' => GetSign( $sign_id ), >- 'streams' => GetSignStreamsAttachedToSignWithRecords( $sign_id, 0 ), >+ 'sign' => Koha::Signs->find( $sign_id ), >+ 'streams' => \@changedstreams, > 'script_name' => $script_name, > ); > >@@ -165,13 +192,13 @@ if ( $op eq 'add_stream' ) { > > $template->param( > 'op' => 'del_sign', >- 'sign' => GetSign( $sign_id ), >+ 'sign' => Koha::Signs->find( $sign_id ), > 'script_name' => $script_name, > ); > > } elsif ( $op eq 'del_sign_ok' ) { > >- DelSign( $sign_id ); >+ Koha::Signs->find( $sign_id )->delete; > > $template->param( > 'op' => 'del_sign_ok', >@@ -182,22 +209,29 @@ if ( $op eq 'add_stream' ) { > > } elsif ( $op eq 'edit_streams' && $sign_id ne '') { > >+ my $sign = Koha::Signs->find( $sign_id ); >+ my $streams = Koha::SignStreams->search({}); >+ >+ my $schema = Koha::Database->new()->schema(); >+ my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); >+ > $template->param( > 'op' => 'edit_streams', >- 'sign' => GetSign( $sign_id ), >+ 'sign' => $sign, > 'sign_id' => $sign_id, >- 'streams' => GetSignStreams(), >- 'attached' => GetSignStreamsAttachedToSign( $sign_id ), >+ 'streams' => $streams, >+ 'sts' => \@signstostreams, > 'script_name' => $script_name > ); > > } elsif ( $op eq 'attach_stream_to_sign' && $sign_stream_id ne '' && $sign_id ne '' ) { > >- my $sign_to_stream_id = AttachSignStreamToSign( $sign_stream_id, $sign_id ); >+ Koha::SignsToStream->new({ sign_stream_id => $sign_stream_id, sign_id => $sign_id })->store; > > # Check if the SQL associated with the stream needs parameters >- my $stream = GetSignStream( $sign_stream_id ); >- if ( $stream->{'savedsql'} =~ m/<</ ) { >+ my $stream = Koha::SignStreams->find( $sign_stream_id ); >+ my $sql = get_saved_report($stream->saved_sql_id); >+ if ( $sql->{'savedsql'} =~ m/WHERE/ ) { > print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id ); > } else { > print $cgi->redirect( $script_name . '?op=edit_streams&sign_id=' . $sign_id ); >@@ -205,10 +239,19 @@ if ( $op eq 'add_stream' ) { > > } elsif ( $op eq 'get_params' && $sign_to_stream_id ne '' && $sign_stream_id ne '' && $sign_id ne '' ) { > >- my $stream = GetSignStream( $sign_stream_id ); >- my $records = GetSignStreamRecords($stream, $sign_to_stream_id); >- if ( $records ) { >- $template->param( 'records' => $records->{result} ); >+ my $stream = Koha::SignStreams->find( $sign_stream_id ); >+ my $sql = get_saved_report($stream->saved_sql_id); >+ my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $sign_to_stream_id }); >+ # Generate SQL with added params >+ my $newsql = $sql->{'savedsql'}; >+ foreach my $param ( split /&/, $params->params ) { >+ my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself >+ $newsql =~ s/$key/$value/g; >+ } >+ # Run query with new sql >+ my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); >+ if ( $records && not $error) { >+ $template->param( 'records' => $records->fetchall_arrayref({}) ); > } else { > $template->param( 'has_params' => 1 ); > } >@@ -219,28 +262,31 @@ if ( $op eq 'add_stream' ) { > 'sign_id' => $sign_id, > 'sign_stream_id' => $sign_stream_id, > 'sign_to_stream_id' => $sign_to_stream_id, >- 'params' => GetSignStreamParams( $sign_to_stream_id ), >- 'newsql' => $records->{sql}, >+ 'params' => $params, >+ 'sql' => $sql, >+ 'newsql' => $newsql, > 'script_name' => $script_name, > ); > > } elsif ( $op eq 'save_params' && $sign_to_stream_id ne '' && $sign_id ne '' ) { > >- ModSignStreamParams( $sign_to_stream_id, $parameters ); >+ Koha::SignsToStreams->find( $sign_to_stream_id )->set({ params => $parameters })->store; > print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id ); > > } elsif ( $op eq 'detach_stream_from_sign' && $sign_to_stream_id ne '' ) { > >- DetachSignStreamFromSign( $sign_to_stream_id ); >+ Koha::SignsToStreams->find( $sign_to_stream_id )->delete; > print $cgi->redirect($script_name . '?op=edit_streams&sign_id=' . $sign_id); > > } else { > >- # TODO Check the setting of OPACDigitalSigns, give a warning if it is off >+ my $streams = Koha::SignStreams->search({}); >+ my $signs = Koha::Signs->search({}); > > $template->param( >- 'streams' => GetSignStreams(), >- 'signs' => GetSigns(), >+ 'streams' => $streams, >+ 'signs' => $signs, >+ 'reports' => get_saved_reports( { group => 'SIG' } ), > 'OPACBaseURL' => C4::Context->preference( 'OPACBaseURL' ) || '', > 'else' => 1 > ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8628
:
42703
|
42704
|
45968
|
45969
|
58602
|
58603
|
58604
|
58605
|
62338
|
64249
|
66246
|
66247
|
66248
|
66249
|
66250
|
77025
|
77026
|
77027
|
77028
|
77141
|
77142
|
77143
|
77144
|
77145
|
78709
|
80248
|
80249
|
80250
|
80252
|
82896
|
82897
|
82898
|
82899
|
82900
|
82901
|
83312
|
88821
|
88822
|
88823
|
88824
|
88825
|
88826
|
93054
|
93055
|
93056
|
93057
|
93058
|
93059
|
93066
|
93067
|
93068
|
93069
|
93070
|
93071
|
99608
|
99609
|
99610
|
99611
|
99612
|
99613
|
99614
|
99615
|
99616
|
99617
|
99618
|
99619
|
99620
|
99621
|
99622
|
99623
|
99624
|
99717
|
99718
|
99801
|
118472
|
118473
|
118474
|
118475
|
118476
|
118477
|
118478
|
118479
|
118480
|
119455
|
131223
|
131224
|
145645
|
145646
|
145647
|
145648
|
145649
|
145650
|
145651
|
145652
|
145653
|
145654
|
147000
|
147001
|
147002
|
147003
|
147004
|
147005
|
147006
|
147007
|
147008
|
147009
|
147010