@@ -, +, @@ --- C4/Koha.pm | 80 +++++++++- .../data/mysql/de-DE/mandatory/userpermissions.sql | 1 + .../data/mysql/en/mandatory/userpermissions.sql | 1 + installer/data/mysql/en/optional/sample_quotes.sql | 34 ++++ installer/data/mysql/en/optional/sample_quotes.txt | 1 + .../mysql/fr-FR/1-Obligatoire/userpermissions.sql | 1 + .../data/mysql/it-IT/necessari/userpermissions.sql | 1 + installer/data/mysql/kohastructure.sql | 13 ++ .../mysql/nb-NO/1-Obligatorisk/userpermissions.sql | 1 + .../data/mysql/pl-PL/mandatory/userpermissions.sql | 1 + .../ru-RU/mandatory/permissions_and_user_flags.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../uk-UA/mandatory/permissions_and_user_flags.sql | 1 + installer/data/mysql/updatedatabase.pl | 23 +++ koha-tmpl/intranet-tmpl/prog/en/css/datatables.css | 23 ++- .../intranet-tmpl/prog/en/includes/tools-menu.inc | 3 + .../prog/en/modules/admin/preferences/opac.pref | 8 +- .../intranet-tmpl/prog/en/modules/tools/quotes.tt | 182 ++++++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 4 + koha-tmpl/opac-tmpl/prog/en/css/opac.css | 23 +++ koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt | 4 + opac/opac-main.pl | 9 +- tools/quotes.pl | 44 +++++ tools/quotes/quotes_ajax.pl | 118 +++++++++++++ 24 files changed, 570 insertions(+), 8 deletions(-) create mode 100644 installer/data/mysql/en/optional/sample_quotes.sql create mode 100644 installer/data/mysql/en/optional/sample_quotes.txt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt create mode 100755 tools/quotes.pl create mode 100755 tools/quotes/quotes_ajax.pl --- a/C4/Koha.pm +++ a/C4/Koha.pm @@ -22,10 +22,15 @@ package C4::Koha; use strict; #use warnings; FIXME - Bug 2505 + use C4::Context; + use Memoize; +use DateTime; +use DateTime::Format::MySQL; +use autouse 'Data::Dumper' => qw(Dumper); -use vars qw($VERSION @ISA @EXPORT $DEBUG); +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG); BEGIN { $VERSION = 3.01; @@ -67,6 +72,7 @@ BEGIN { $DEBUG ); $DEBUG = 0; +@EXPORT_OK = qw( GetDailyQuote ); } # expensive functions @@ -1298,6 +1304,78 @@ sub GetNormalizedOCLCNumber { } } +=head2 GetDailyQuote($opts) + +Takes a hashref of options + +Currently supported options are: + +'id' An exact quote id +'random' Select a random quote +noop When no option is passed in, this sub will return the quote timestamped for the current day + +The function returns an anonymous hash following this format: + + { + 'source' => 'source-of-quote', + 'timestamp' => 'timestamp-value', + 'text' => 'text-of-quote', + 'id' => 'quote-id' + }; + +=cut + +# This is definitely a candidate for some sort of caching once we finally settle caching/persistence issues... +# at least for default option + +sub GetDailyQuote { + my %opts = @_; + my $dbh = C4::Context->dbh; + my $query = ''; + my $sth = undef; + my $quote = undef; + if ($opts{'id'}) { + $query = 'SELECT * FROM quotes WHERE id = ?'; + $sth = $dbh->prepare($query); + $sth->execute($opts{'id'}); + $quote = $sth->fetchrow_hashref(); + } + elsif ($opts{'random'}) { + # Fall through... we also return a random quote as a catch-all if all else fails + } + else { + $query = 'SELECT * FROM quotes WHERE timestamp LIKE CONCAT(CURRENT_DATE,\'%\') ORDER BY timestamp LIMIT 0,1'; + $sth = $dbh->prepare($query); + $sth->execute(); + $quote = $sth->fetchrow_hashref(); + } + unless ($quote) { # if there are not matches, choose a random quote + # get a list of all available quote ids + $sth = C4::Context->dbh->prepare('SELECT count(*) FROM quotes;'); + $sth->execute; + my $range = ($sth->fetchrow_array)[0]; + if ($range > 1) { + # chose a random id within that range if there is more than one quote + my $id = int(rand($range)); + # grab it + $query = 'SELECT * FROM quotes WHERE id = ?;'; + $sth = C4::Context->dbh->prepare($query); + $sth->execute($id); + } + else { + $query = 'SELECT * FROM quotes;'; + $sth = C4::Context->dbh->prepare($query); + $sth->execute(); + } + $quote = $sth->fetchrow_hashref(); + # update the timestamp for that quote + $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; + $sth = C4::Context->dbh->prepare($query); + $sth->execute(DateTime::Format::MySQL->format_datetime(DateTime->now), $quote->{'id'}); + } + return $quote; +} + sub _normalize_match_point { my $match_point = shift; (my $normalized_match_point) = $match_point =~ /([\d-]*[X]*)/; --- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql +++ a/installer/data/mysql/de-DE/mandatory/userpermissions.sql @@ -22,6 +22,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Benutzerkommentare moderieren'), (13, 'edit_notices', 'Benachrichtigungen verwalten'), (13, 'edit_notice_status_triggers', 'Mahntrigger für überfällige Medien verwalten'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Logs durchsuchen/einsehen'), (13, 'inventory', 'Inventur durchführen'), (13, 'stage_marc_import', 'MARC-Datensätze zwischenspeichern'), --- a/installer/data/mysql/en/mandatory/userpermissions.sql +++ a/installer/data/mysql/en/mandatory/userpermissions.sql @@ -22,6 +22,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Moderate patron comments'), (13, 'edit_notices', 'Define notices'), (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Browse the system logs'), (13, 'inventory', 'Perform inventory (stocktaking) of your catalog'), (13, 'stage_marc_import', 'Stage MARC records into the reservoir'), --- a/installer/data/mysql/en/optional/sample_quotes.sql +++ a/installer/data/mysql/en/optional/sample_quotes.sql @@ -0,0 +1,34 @@ +/*!40000 ALTER TABLE `quotes` DISABLE KEYS */; +INSERT INTO `quotes` VALUES +(1,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.','0000-00-00 00:00:00'), +(2,'Thomas Jefferson','When angry, count ten, before you speak; if very angry, an hundred.','0000-00-00 00:00:00'), +(3,'Abraham Lincoln','Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.','2012-04-12 20:30:59'), +(4,'Abraham Lincoln','I have always found that mercy bears richer fruits than strict justice.','0000-00-00 00:00:00'), +(5,'Andrew Johnson','I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.','0000-00-00 00:00:00'), +(6,'Rutherford B. Hayes','He serves his party best who serves his country best.','0000-00-00 00:00:00'), +(7,'Theodore Roosevelt','No President has ever enjoyed himself as much as I?','0000-00-00 00:00:00'), +(8,'Theodore Roosevelt','Speak softly and carry a big stick.','0000-00-00 00:00:00'), +(9,'William H. Taft','I have come to the conclusion that the major part of the president is to increase the gate receipts of expositions and fairs and bring tourists to town.','0000-00-00 00:00:00'), +(11,'Woodrow Wilson','You cannot become thorough Americans if you think of yourselves in groups. America does not consist of groups. A man who thinks of himself as belonging to a particular national group in America has not yet become an American.','0000-00-00 00:00:00'), +(12,'Calvin Coolidge','If you don\'t say anything, you won\'t be called on to repeat it.','0000-00-00 00:00:00'), +(13,'Calvin Coolidge','Four fifths of all our troubles in this life would disappear if we would only sit down and keep still.','0000-00-00 00:00:00'), +(14,'Herbert Hoover','The slogan of progress is changing from the full dinner pail to the full garage.','0000-00-00 00:00:00'), +(15,'Franklin D. Roosevelt','Let me assert my firm belief that the only thing we have to fear is fear itself.','0000-00-00 00:00:00'), +(16,'Harry S. Truman','If you can\'t stand the heat, get out of the kitchen.','0000-00-00 00:00:00'), +(17,'Harry S. Truman','The atom bomb was no great decision. It was merely another powerful weapon in the arsenal of righteousness.','0000-00-00 00:00:00'), +(18,'Harry S. Truman','The buck stops here.','0000-00-00 00:00:00'), +(19,'Dwight D. Eisenhower','History does not long entrust the care of freedom to the weak or the timid.','0000-00-00 00:00:00'), +(20,'John F. Kennedy','My fellow Americans, ask not what your country can do for you; ask what you can do for your country.','0000-00-00 00:00:00'), +(22,'John F. Kennedy','I do not think it altogether inappropriate to introduce myself to this audience. I am the man who accompanied Jacqueline Kennedy to Paris, and I have enjoyed it.','0000-00-00 00:00:00'), +(23,'Lyndon B. Johnson','The Great Society is a place where every child can find knowledge to enrich his mind and to enlarge his talents. It is a place where the city of man serves not only the needs of the body and the demands of commerce but the desire for beauty and the hunger for community. It is a place where men are more concerned with the quality of their goals than the quantity of their goods.','0000-00-00 00:00:00'), +(24,'Richard Nixon','People have got to know whether or not their president is a crook. Well, I\'m not a crook.','0000-00-00 00:00:00'), +(25,'Richard Nixon','When the President does it, that means that it is not illegal.','0000-00-00 00:00:00'), +(26,'Gerald R. Ford','Our Long national nightmare is over.','2012-04-18 19:42:14'), +(27,'Gerald R. Ford','Our constitution works. Our great republic is a government of laws, not of men.','0000-00-00 00:00:00'), +(28,'Jimmy Carter','A strong nation, like a strong person, can afford to be gentle, firm, thoughtful, and restrained. It can afford to extend a helping hand to others. It\'s a weak nation, like a weak person, that must behave with bluster and boasting and rashness and other signs of insecurity.','0000-00-00 00:00:00'), +(30,'Ronald Reagan','It is not my intention to do away with government. It is rather to make it work -work with us, not over us; stand by our side, not ride on our back. Government can and must provide opportunity, not smother it; foster productivity, not stifle it. This Administration\'s objective will be a healthy, vigorous, growing economy.','0000-00-00 00:00:00'), +(31,'Ronald Reagan','Each generation goes further than the generation preceding it because it stands on the shoulders of that generation. You will have opportunities beyond anything we\'ve ever known.','0000-00-00 00:00:00'), +(32,'George H. W. Bush ','We have ...drawn a line in the sand.','0000-00-00 00:00:00'), +(33,'George W. Bush','If America shows weakness and uncertainty, the world will drift toward tragedy. That will not happen on my watch.','0000-00-00 00:00:00'), +(34,'George W. Bush','Every nation in every region now has a decision to make. Either you are with us, or you are with the terrorists.','0000-00-00 00:00:00'); +/*!40000 ALTER TABLE `quotes` ENABLE KEYS */; --- a/installer/data/mysql/en/optional/sample_quotes.txt +++ a/installer/data/mysql/en/optional/sample_quotes.txt @@ -0,0 +1, @@ +Sample Quotes --- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql +++ a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql @@ -12,6 +12,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Modérer les commentaires des adhérents'), (13, 'edit_notices', 'Définir les notifications'), (13, 'edit_notice_status_triggers', 'Définir les déclencheurs de notification de retard'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Parcourir les journaux de l''activité du système'), (13, 'inventory', 'Réaliser les tâches de récolement'), (13, 'stage_marc_import', 'Importer des notices MARC dans le réservoir'), --- a/installer/data/mysql/it-IT/necessari/userpermissions.sql +++ a/installer/data/mysql/it-IT/necessari/userpermissions.sql @@ -24,6 +24,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Modera i commenti degli utenti'), (13, 'edit_notices', 'Definisci le notifiche'), (13, 'edit_notice_status_triggers', 'Imposta il messaggio o lo stato delle notifiche per le copie in ritardo'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Scorri i log di sistema'), (13, 'inventory', 'Lavora sugli inventari (stocktaking) del tuo catalogo'), (13, 'stage_marc_import', 'Opera sui Record MARC presenti nella zona di lavoro'), --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2829,6 +2829,19 @@ CREATE TABLE ratings ( CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `quotes` +-- + +DROP TABLE IF EXISTS quotes; +CREATE TABLE `quotes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `source` varchar(45) DEFAULT NULL, + `text` mediumtext NOT NULL, + `timestamp` datetime NOT NULL, + PRIMARY KEY (`id`) +) 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 */; --- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql +++ a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql @@ -43,6 +43,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Behandle kommentarer fra lånere'), (13, 'edit_notices', 'Definere meldinger'), (13, 'edit_notice_status_triggers', 'Definere utløsere for meldinger og statusenderinger for for sent leverte dokumenter'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Se Koha sine logger'), (13, 'inventory', 'Foreta varetelling'), (13, 'stage_marc_import', 'Importere MARC-poster til brønnen'), --- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql +++ a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql @@ -22,6 +22,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Moderate patron comments'), (13, 'edit_notices', 'Define notices'), (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Przeglądanie logów systemowych'), (13, 'inventory', 'Perform inventory (stocktaking) of your catalog'), (13, 'stage_marc_import', 'Stage MARC records into the reservoir'), --- a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql +++ a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql @@ -46,6 +46,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Регулировка комментариев от посетителей'), (13, 'edit_notices', 'Определение сообщений'), (13, 'edit_notice_status_triggers', 'Установка триггеров сообщений/статусов для просроченных экземпляров'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Просмотр протоколов системы'), (13, 'inventory', 'Проведение инвентаризации(анализа) Вашего каталога'), (13, 'stage_marc_import', 'Заготовка МАРК-записей в хранилище'), --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -95,6 +95,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacPublic',1,'Turn on/off public OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserjs','','Define custom javascript for inclusion in OPAC','70|10','Textarea'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserlogin',1,'Enable or disable display of user login features',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QuoteOfTheDay',0,'Enable or disable display of Quote of the Day on the OPAC home page',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('patronimages',0,'Enable patron images for the Staff Client',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('printcirculationslips',1,'If ON, enable printing circulation receipts','','YesNo'); --- a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql +++ a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql @@ -46,6 +46,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_comments', 'Регулювання коментарів від відвідувачів'), (13, 'edit_notices', 'Визначення повідомлень'), (13, 'edit_notice_status_triggers', 'Встановлення тригерів повідомлень/статусів для прострочених примірників'), + (13, 'edit_quotes', 'Edit quotes for quote-of-the-day feature'), (13, 'view_system_logs', 'Перегляд протоколів системи'), (13, 'inventory', 'Проведення інвентаризації(аналізу) Вашого каталогу'), (13, 'stage_marc_import', 'Заготівля МАРК-записів у сховище'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -5212,6 +5212,29 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + unless (TableExists('quotes')) { + $dbh->do( qq{ + CREATE TABLE `quotes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `source` varchar(45) DEFAULT NULL, + `text` mediumtext NOT NULL, + `timestamp` datetime NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 + }); + } + $dbh->do( qq{ + INSERT IGNORE INTO permissions VALUES (13, "edit_quotes","Edit quotes for quote-of-the-day feature"); + }); + $dbh->do( qq{ + INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QuoteOfTheDay',0,'Enable or disable display of Quote of the Day on the OPAC home page',NULL,'YesNo'); + }); + print "Upgrade to $DBversion done (Adding Quote of the Day Option.)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css +++ a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css @@ -85,25 +85,25 @@ div.dataTables_paginate { .paging_full_numbers a.paginate_button.first { background-image : url('../../img/first.png'); background-repeat: no-repeat; - background-position : 2px center; + background-position : 1% center; padding-left : 2em; } .paging_full_numbers a.paginate_button.previous { background-image : url('../../img/prev.png'); background-repeat: no-repeat; - background-position : 2px center; + background-position : 1% center; padding-left : 2em; } .paging_full_numbers a.paginate_button.next { background-image : url('../../img/next.png'); background-repeat: no-repeat; - background-position : right center; + background-position : 96% center; padding-right : 2em; } .paging_full_numbers a.paginate_button.last { background-image : url('../../img/last.png'); background-repeat: no-repeat; - background-position : right center; + background-position : 96% center; border-right : 1px solid #686868; padding-right : 2em; } @@ -175,6 +175,21 @@ div.dataTables_paginate.paging_four_button { cursor: pointer; } +.dataTables_processing { + background-color: white; + border: 1px solid #DDDDDD; + color: #999999; + font-size: 14px; + height: 30px; + left: 50%; + margin-left: -125px; + margin-top: -15px; + padding: 14px 0 2px; + position: fixed; + text-align: center; + top: 50%; + width: 250px; +} /* table.display { --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -91,4 +91,7 @@ [% IF ( CAN_user_tools_schedule_tasks ) %]
  • Task scheduler
  • [% END %] + [% IF ( CAN_user_tools_edit_quotes ) %] +
  • Quote Editor
  • + [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -330,7 +330,13 @@ OPAC: yes: Enable no: Disable - browsing and paging search results from the OPAC detail page. - + - + - pref: QuoteOfTheDay + default: 0 + choices: + yes: Enable + no: Disable + - Quote of the Day display on OPAC home page Policy: - - pref: singleBranchMode --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt @@ -0,0 +1,182 @@ + [% INCLUDE 'doc-head-open.inc' %] + Koha › Tools › Quote Editor + [% INCLUDE 'doc-head-close.inc' %] + + + [% INCLUDE 'datatables-strings.inc' %] + + + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    IDSourceTextLast DisplayedActions
    Loading data...
    +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -87,6 +87,10 @@
    Schedule tasks to run
    [% END %] + [% IF ( CAN_user_tools_edit_quotes ) %] +
    Edit Quotes for QOD Feature
    +
    Quote editor for Quote-of-the-day feature in OPAC
    + [% END %]
    --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ a/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2366,6 +2366,29 @@ span.sep { text-shadow: 1px 1px 0 #FFF; } +#daily-quote { + /*border-top : 1px solid #000000;*/ + border : 1px solid #000000; + margin-top: 2px; + margin-bottom: 10px; + margin-left: 2px; + margin-right: 2px; + width: 300px; + text-align: center; + font-family: "Georgia","Palatino","Times New Roman",sans-serif; +} + +#daily-quote h1 { + font-size: 18px; + font-weight: normal; + margin: 0; +} + +#daily-quote div { + font-size: 12px; + margin: 5px; +} + /* ## BABELTHEQUE ## */ /* Uncomment if babeltheque configuration no contains these lines */ /* --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt @@ -35,6 +35,10 @@ [% END %] + [% IF ( display_daily_quote && daily_quote ) %] +

    Quote of the Day

    [% daily_quote.text %] ~ [% daily_quote.source %]
    +[% END %] + [% IF ( OpacMainUserBlock ) %]
    [% OpacMainUserBlock %]
    [% END %] --- a/opac/opac-main.pl +++ a/opac/opac-main.pl @@ -23,6 +23,7 @@ use C4::Auth; # get_template_and_user use C4::Output; use C4::NewsChannels; # get_opac_news use C4::Languages qw(getTranslatedLanguages accept_language); +use C4::Koha qw( GetDailyQuote ); my $input = new CGI; my $dbh = C4::Context->dbh; @@ -50,9 +51,13 @@ my ($theme, $news_lang) = C4::Templates::themelanguage(C4::Context->config('opac my $all_koha_news = &GetNewsToDisplay($news_lang); my $koha_news_count = scalar @$all_koha_news; +my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha + $template->param( - koha_news => $all_koha_news, - koha_news_count => $koha_news_count + koha_news => $all_koha_news, + koha_news_count => $koha_news_count, + display_daily_quote => C4::Context->preference('QuoteOfTheDay'), + daily_quote => $quote, ); # If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens --- a/tools/quotes.pl +++ a/tools/quotes.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# Copyright 2012 Foundations Bible College Inc. +# +# 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 2 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 strict; +use warnings; + +use CGI; +use autouse 'Data::Dumper' => qw(Dumper); + +use C4::Auth; +use C4::Koha; +use C4::Context; +use C4::Output; + +my $cgi = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "tools/quotes.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { tools => 'edit_quotes' }, + debug => 1, + } +); + +output_html_with_http_headers $cgi, $cookie, $template->output; --- a/tools/quotes/quotes_ajax.pl +++ a/tools/quotes/quotes_ajax.pl @@ -0,0 +1,118 @@ +#!/usr/bin/perl + +# Copyright 2012 Foundations Bible College Inc. +# +# 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 2 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 strict; +use warnings; + +use CGI; +use JSON; +use autouse 'Data::Dumper' => qw(Dumper); + +use C4::Auth; +use C4::Context; + +my $cgi = CGI->new; +my $dbh = C4::Context->dbh; +my $sort_columns = ["id", "source", "text", "timestamp"]; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { tools => 'edit_quotes' }, + debug => 1, + } +); + +# NOTE: This is a collection of ajax functions for use with tools/quotes.pl + +my $params = $cgi->Vars; # NOTE: Multivalue parameters NOT allowed!! + +warn Dumper($params); #XXX + +print $cgi->header('application/json'); + +if ($params->{'action'} eq 'add') { + my $sth = $dbh->prepare('INSERT INTO quotes (source, text) VALUES (?, ?);'); + $sth->execute($params->{'source'}, $params->{'text'}); + if ($sth->err) { + warn sprintf('Database returned the following error: %s', $sth->errstr); + exit 0; + } + exit 1; +} +elsif ($params->{'action'} eq 'edit') { + my $editable_columns = [qw(source text)]; # pay attention to element order; these columns match the quotes table columns + my $sth = $dbh->prepare("UPDATE quotes SET $editable_columns->[$params->{'column'}-1] = ? WHERE id = ?;"); + $sth->execute($params->{'value'}, $params->{'id'}); + if ($sth->err) { + warn sprintf('Database returned the following error: %s', $sth->errstr); + exit 0; + } + print $params->{'value'}; + exit 1; +} +elsif ($params->{'action'} eq 'delete') { + my $sth = $dbh->prepare("DELETE FROM quotes WHERE id = ?;"); + $sth->execute($params->{'id'}); + if ($sth->err) { + warn sprintf('Database returned the following error: %s', $sth->errstr); + exit 0; + } + exit 1; +} +else { + my $aaData = []; + my $iTotalRecords = ''; + my $sth = ''; + + # FIXME: the use of "Action" in the SELECTs below is a hack to supply the fifth column; there should be a nicer way todo this... + if (my $filter = $params->{'sSearch'}) { + # This seems a bit brute force and ungraceful, but it provides a very general, simple search on all fields + my $like = " id LIKE \"%$filter%\" OR source LIKE \"%$filter%\" OR text LIKE \"%$filter%\" OR timestamp LIKE \"%$filter%\""; + $iTotalRecords = $dbh->selectrow_array("SELECT count(*) FROM quotes WHERE $like;"); + # At present we only support sorting by a single column + #$sth = $dbh->prepare("SELECT *, \"Action\" FROM quotes WHERE $like ORDER BY $sort_columns->[$params->{'iSortCol_0'}] $params->{'sSortDiri_0'} LIMIT $params->{'iDisplayStart'}, $params->{'iDisplayLength'};"); + $sth = $dbh->prepare("SELECT *, \"Action\" FROM quotes;"); + } + else { + $iTotalRecords = $dbh->selectrow_array('SELECT count(*) FROM quotes;'); + #$sth = $dbh->prepare("SELECT *, \"Action\" FROM quotes ORDER BY $sort_columns->[$params->{'iSortCol_0'}] $params->{'sSortDiri_0'} LIMIT $params->{'iDisplayStart'}, $params->{'iDisplayLength'};"); + $sth = $dbh->prepare("SELECT *, \"Action\" FROM quotes;"); + } + + $sth->execute(); + if ($sth->err) { + warn sprintf('Database returned the following error: %s', $sth->errstr); + exit 0; + } + + $aaData = $sth->fetchall_arrayref; + my $iTotalDisplayRecords = $iTotalRecords; # no filtering happening here + + + print to_json({ + iTotalRecords => $iTotalRecords, + iTotalDisplayRecords=> $iTotalDisplayRecords, + sEcho => $params->{'sEcho'}, + aaData => $aaData, + }); +} --