[imp] changing signature at once for all users
Jens Wahnes
wahnes at uni-koeln.de
Wed Aug 15 07:20:12 UTC 2018
Cristian-Petru Pencov wrote:
> I'm again in situation to replace some text in user's signature for more
> than fifty accounts.
with the usual "SQL database" backend for preference storage, it is
possible to write code that retrieves the individual users' "identities"
preferences (they are serialized PHP objects and can be unserialize()d).
Note that one user can have several identities, so for each user, you
are looking at an array of arrays. Then, there is both a "signature"
and a "signature_html" preference. While parsing and manipulating the
normal signature with preg_replace or such shouldn't be too hard to do,
things get a bit more complicated when you're dealing with HTML code.
Depending on what you would like to change in every user's signature
(e.g. phone number or postal address), you might have a hard time
parsing the HTML code since users may have selected to use a different
font (small, bold, whatever) for parts of the signature, and they might
even have done so accidentally. For instance, imagine you're trying to
put a new phone number into everyone's signatures, but some user has got
opening or closing HTML tags inside the phone number because they missed
to select one digit of the phone number when they edited their signature
and put all other digits of the phone number into boldface. That really
is one mess to sort out if all you wanted to do is write one small
script to adapt you users' signatures. Oh, and you'll have to
serialize() that stuff and write it back to the database once you've
walked through each user's array of identities. Better have a backup of
the old data, too, in case something goes wrong.
Jens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5326 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.horde.org/archives/imp/attachments/20180815/151b61fb/attachment.bin>
More information about the imp
mailing list