Our system requires a complete protocol of when an e-mail has been added to the system and a changelog for the settings (subscribe/unsubscribe from a certain newsletter).
I am implementing on our website and will put together in a patch the following changes:
DB Table simplenews_subscriber: add fields for created timestamp and protocol (serialized array).
Add an option in the simplenews admin interface, should the system record protocol changes?
For further background info:
It is simple to add such a feature as a custom profile field + rule implentation for registered users, but there is no good solution for a non-registered user.
The database table simplenews_subscriber already has the "changes" field, but it is overwritten when a new set of changes is made. Hence it is not truly a protocol.
Comments
Comment #1
jjchinquistGood morning,
The following patch includes the following changes:
.install - add 2 fields
.module - updated the subscriber_save so that the fields are set.
I will work on it again later:
* Make the protocol an option in the administration screen (many websites may not require such detailed info - we do though).
* Change the new field "protocol" to a BLOB (it will store a lot of info, so it should not be a string).
* Also the protocol field is only saving minimal information at this point (a record of save timestamps). Add the records.
* test this change - both manually and with test cases
Comment #2
jjchinquistMy apologies, improperly referenced the project to statstics. Changing to simplenews base module.
Comment #4
berdirThat shouldn't be here :)
You can add the .gitignore to .gitignore, to ignore itself.
Trailing whitespace.
What happens if two changes happen in the same request? Also, REQUEST probably shouldn't be hardcoded into the protocol.
The problem here is translatability. Your code will translate the string and then save the translation into the database. This means that if the subscriber used chinese, you will see the log entry in chinese, which will not be helpful.
So we'd probably need a system like watchdog, where you store untranslated strings and arguments and translate is done when viewed. Requires some tricks to be able to extract the translatable strings, though like adding them to a dummy function.
Maybe a separate table might make sense, then we don't have to worry about duplicate protocol entries, could build a list of recent changes easily and don't have to deal with a possibly large protocol data every time we load a subscriber.
Comment #5
jjchinquistThanks Berdir, will get the patch file cleaned up.
The protocol itself is only intended for administrators. Therefore, I will focus on removing all translations for the protocol field. If administors do required protocols translated, then I will do that.
Watchdog does not help me in this case because it eventually removes the entries. Technically, for legal reasons, my drupal simplenews needs to save the create date of a subscriber and the change dates (when a reader is removed, added, etc.).
Comment #6
berdirWell, administrators can also be talking chinese on a chinese website, so they want the messages translated.
I didn't mean actually using watchdog. I meant adding our own table that works similar to watchdog in the way that it stores an untranslated text and a serialized array for the parameters.
That table needs a serial key, reference to snid, a text and placeholders columns.
Comment #7
jjchinquistI am certainly for a watchdog style implementation because it is a cleaner solution. It requires more overhead though. Because this is an interpretation question as well, I will open a new discussion thread separately and change this issue/patch so that it only deals with the "timestamp_create" DB field in the subscriber object.
New protocol issue here:
http://drupal.org/node/1535360
Comment #8
jjchinquistPatch for created time.
I have tried to remove all trailing whitespaces, hope that is is correct now. Incidentally, the newest EGIT version seems to include files in patches that are officially labeled as "ignore". At least that is the case for me :(
Comment #10
berdirAgreed with splitting up the patches. Wondering if we shouldn't simply use created instead of timestamp_created, that's the defacto standard for that column. And timestamp should be changed, but that's another story.
Comment #11
berdirOh, crosspost with the bot.
Sounds like something with your patch is wrong, maybe you tried to split it up manually?
Comment #12
jjchinquistSorry for the multiple failed attempts. This patch should work.
Comment #13
jjchinquistConfiguration also tested manually on 2 Drupal installations (1 as an update, 1 as a clean install).
Comment #14
berdirThe status you meant is "reviewed & tested by the community" (RTBC). Which you should not set yourself :)
As mentioned, I'd prefer to name the column just "created". Patch looks good to me otherwise.
Comment #15
jjchinquistrenamed field
Comment #16
berdirThanks, commited.