From 57200cca8686bf1a926fee52ee01e564db26911b Mon Sep 17 00:00:00 2001 From: rogercreagh <44980188+rogercreagh@users.noreply.github.com> Date: Fri, 27 Jan 2023 08:36:04 +0000 Subject: [PATCH] Review date and quick review date bug fixed --- src/com_xbbooks/admin/models/book.php | 7 ++----- src/com_xbbooks/admin/models/forms/review.xml | 3 ++- src/com_xbbooks/admin/models/review.php | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/com_xbbooks/admin/models/book.php b/src/com_xbbooks/admin/models/book.php index a4ecbe8..e2edfd6 100644 --- a/src/com_xbbooks/admin/models/book.php +++ b/src/com_xbbooks/admin/models/book.php @@ -324,10 +324,7 @@ public function save($data) { $data['tags'] = ($data['tags']) ? array_unique(array_merge($data['tags'],$data['taggroup4'])) : $data['taggroup4']; } - //if only first_seen or last_seen is set then copy to other one - if (($data['first_read']=='') && ($data['last_read']!='')) { - $data['first_read']=$data['last_read']; - } + //first_read is required, if last_read empty copy first_read to it if (($data['last_read']=='') && ($data['first_read']!='')) { $data['last_read']=$data['first_read']; } @@ -388,7 +385,7 @@ public function save($data) { } $qry = 'INSERT INTO '.$db->quoteName('#__xbbookreviews').' (title, alias, book_id, catid, reviewer, rating, rev_date, created, created_by, state ) '; $qry .= 'VALUES ('.$db->quote($rtitle).','.$db->quote($ralias).','.$bid.','.$catid.','.$db->quote($reviewer).','. - $data['quick_rating'].','.$db->quote($data['first_read']).','.$db->quote($date->toSql()).','.$db->quote($data['created_by']).',1)'; + $data['quick_rating'].','.$db->quote($data['last_read']).','.$db->quote($date->toSql()).','.$db->quote($data['created_by']).',1)'; $db->setQuery($qry); $db->execute(); } diff --git a/src/com_xbbooks/admin/models/forms/review.xml b/src/com_xbbooks/admin/models/forms/review.xml index de33a2c..b1f1805 100644 --- a/src/com_xbbooks/admin/models/forms/review.xml +++ b/src/com_xbbooks/admin/models/forms/review.xml @@ -82,7 +82,8 @@ diff --git a/src/com_xbbooks/admin/models/review.php b/src/com_xbbooks/admin/models/review.php index 69de0b9..5dabfe0 100644 --- a/src/com_xbbooks/admin/models/review.php +++ b/src/com_xbbooks/admin/models/review.php @@ -2,7 +2,7 @@ /******* * @package xbBooks * @filesource admin/models/review.php - * @version 0.9.10.2 14th November 2022 + * @version 1.0.3.7 27th January 2023 * @author Roger C-O * @copyright Copyright (c) Roger Creagh-Osborne, 2021 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html @@ -141,8 +141,7 @@ public function save($data) { if (parent::save($data)) { //get the saved id (valid for new items as well where $data['id'] will still = 0 $rid = $this->getState('review.id'); - //if ((array_key_exists('rev2read', $data)) && ($data['rev2read']==1)) { - //just do it if the date is later than existing + //if rev_date is later than last_read for book then update last_read $db = $this->getDbo(); $query= $db->getQuery(true); $query = 'UPDATE `#__xbbooks` SET `last_read` = '.$db->quote($data['rev_date']).' ';