Skip to content

Commit

Permalink
Review date and quick review date bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercreagh committed Jan 27, 2023
1 parent 195492e commit 57200cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/com_xbbooks/admin/models/book.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion src/com_xbbooks/admin/models/forms/review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@

<field name="rev_date" type="calendar"
label="XBBOOKS_FIELD_REVIEWED_LABEL" description="XBBOOKS_FIELD_REVIEWED_DESC"
class="inputbox" size="20" format="%Y-%m-%d" filter="user_utc"
class="inputbox" size="20" format="%Y-%m-%d 0:0:0" filter="user_utc"
showtime="false" translateformat="true"
required = "true"
/>

Expand Down
5 changes: 2 additions & 3 deletions src/com_xbbooks/admin/models/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']).' ';
Expand Down

0 comments on commit 57200cc

Please sign in to comment.