WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.12.x) »
  • Modules »
  • OneForAll - Set image to inactive won't save
  • Print
Pages: [1]   Go Down

Author Topic: OneForAll - Set image to inactive won't save  (Read 64354 times)

Offline CodeALot

  • Posts: 579
  • Gender: Male
OneForAll - Set image to inactive won't save
« on: July 11, 2019, 10:53:39 AM »
OneForAll 2.0.2.23

  • Go into modify_item.php  and set one or more images to "Active: NO"
  • Save
  • Go back into the item.
  • Images are all set to "Active: YES"  :| :|

  • Go into the database.
  • Find table mod_oneforall_image s
  • Set an image to "Active: 0"
  • Go back into modify_item.php of the item that you just set an image inactive for
  • You'll see that the image you set to inactive in the database, is now indeed inactive.
  • Click the checkbox to make it Active again.
  • Save the item.
  • Go back
  • The image is now Active again.

So, I can't set an image to INactive, but I CAN set it to Active.
 
What's wrong here? It did work as expected in earlier versions.

(Sorry, this should have gone into a different forum board: WebsiteBaker 2.12.2 --> Modules)
« Last Edit: July 11, 2019, 10:59:56 AM by CodeALot »
Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5920
Re: OneForAll - Set image to inactive won't save
« Reply #1 on: July 11, 2019, 11:11:21 AM »
works for me

the only point, what i see:  go into save_item.php  ~ Line 491

and add here the integer-specification  (int) to the $image[active] like this

Code: [Select]
    // Update image data
    $database->query('UPDATE `'.TABLE_PREFIX.'mod_'.$mod_name.'_images` '
                    .'SET   `active` = '.(int)$image['active'].', '
                    .'         `alt` = \''.$image['alt'].'\', '
                    .'       `title` = \''.$image['title'].'\', '
                    .'     `caption` = \''.$image['caption'].'\' '
                    .'WHERE `img_id` = '.(int)$img_id.' ');
Logged

Offline dbs

  • Betatester
  • **
  • Posts: 8916
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: OneForAll - Set image to inactive won't save
« Reply #2 on: July 11, 2019, 11:20:56 AM »
With or without (int) it works for me also not.
Logged
https://onkel-franky.de

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: OneForAll - Set image to inactive won't save
« Reply #3 on: July 11, 2019, 11:21:16 AM »
Unfortunately, that did not do the trick for me :(
Thanks for your reply, though :)
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: OneForAll - Set image to inactive won't save
« Reply #4 on: July 11, 2019, 11:28:03 AM »
Quote from: dbs on July 11, 2019, 11:20:56 AM
With or without (int) it works for me also not.
You mean you have the same problem?
Logged

Offline dbs

  • Betatester
  • **
  • Posts: 8916
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: OneForAll - Set image to inactive won't save
« Reply #5 on: July 11, 2019, 11:32:15 AM »
Yes.
Try this in line 489:
Code: [Select]
                    .'SET   `active` = \''.$image['active'].'\', '
I think the field type in db is enum and expects a string.
Logged
https://onkel-franky.de

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: OneForAll - Set image to inactive won't save
« Reply #6 on: July 11, 2019, 11:42:21 AM »
Quote from: dbs on July 11, 2019, 11:32:15 AM
Yes.
Try this in line 489:
Code: [Select]
                    .'SET   `active` = \''.$image['active'].'\', '
I think the field type in db is enum and expects a string.
In the table definition it says:

   active   enum('1', '0')   utf8_general_ci   


But your solution worked! Thanks a lot!
Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5920
Re: OneForAll - Set image to inactive won't save
« Reply #7 on: July 11, 2019, 12:00:53 PM »
i think, the "secret" and the different is the MYSQL-Version - but i'm not sure, that i understand everything correct here -> https://dev.mysql.com/doc/refman/8.0/en/enum.html

i understand: if i use a unmasked number, it works as an index from the enum-field -

submitted 1 == index(1) = in this case: 1
submitted 2 == index(2) = in this case: 0

and a masked value (like  \''.$image['active'].'\') is the value like 1 or 0

may and hope, Manu or Dietmar can help, because OFA and Bakery are full of enum-fields like this
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: OneForAll - Set image to inactive won't save
« Reply #8 on: July 11, 2019, 12:25:06 PM »
The weird thing is that it DID work if you had an INactive image and you set it to Active, it would save correctly.
Only setting it back to INactive was not saved...
Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5920
Re: OneForAll - Set image to inactive won't save
« Reply #9 on: July 11, 2019, 12:57:03 PM »
if you activate the checkbox for image-activity, you submit a "1", but if you not activate this checkbox, you submit nothing (for this activity-setting) - thats the result, if you use 1 or 0 in a checkbox (also in a radio-button)
(If you use instead of 1 or 0 - now 1 or 2, you submit a result in every case, but it needs one or two lines more in the code of save_image.php)

next part is the save_image - the same procedure....
if the field "image_active" == empty (means: nothing submitted), set the Value to 0
if it's not empty (means: something submitted, no matter, what), set it to 1

now, we have a numeric value like 1 or 0. in older mysql-version's it doesn't matter, what kind of type you have, integer or string, maybe important, if you use MYSQL-STRICT, i've not test it.
but in the newer version, you can submitted this value as string (like post from dbs) or as numeric index

for example: you use a enum-field like enum('Berlin','Paris','London')
a submitted 1 as integer is here == Berlin, because 'Berlin" is the first definition (or Index) in the field definition), a submitted 3 is == London, a submitted 4 == nothing, because, you have only 3 indizes, not 4 - #4 is invalid). if you have "nothing", use the default value or (if not defined) do nothing

back to OFA
definition of this database field: enum('1','0') default '1'
Index 1 == 1
Index 2 == 0

but you submit not valid index, you submit index == 0. And if you submit a invalide index, it use the default value == 1

Solution from dbs submitted a string ( not the number of the index like my first solution), that's why it works also with 0
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: OneForAll - Set image to inactive won't save
« Reply #10 on: July 11, 2019, 01:52:09 PM »
Very clear explanation, thanks!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.12.x) »
  • Modules »
  • OneForAll - Set image to inactive won't save
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2