Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-13461

ezgeneraldigest notification handler w/ multilingual sites : [always] user notification settings get lost, [may] incorrect digest sending date



    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Obsolete
    • Affects Version/s: 4.0.0, extension/ezwebin 1.3
    • Fix Version/s: None
    • Labels:
    • Environment:

      Operating System: Debian Etch
      PHP Version: PHP 5.2.0-8+etch7
      Database and version: 5.0.32-Debian_7etch1-log
      Browser (and version): Firefox 2


      By design, the ezgeneraldigest notification handler uses the localized 'week day' names to store the user notification settings in the 'day' field of the 'ezgeneral_digest_user_settings' database table.

      Fact #1 :
      The templates in the admin, base and standard design ( design/admin/templates/notification/handler/ezgeneraldigest/settings/edit.tpl, design/base/templates/notification/handler/ezgeneraldigest/settings/edit.tpl and design/standard/templates/notification/handler/ezgeneraldigest/settings/edit.tpl ) and in the ezwebin design ( extension/ezwebin/design/ezwebin/templates/notification/handler/ezgeneraldigest/settings/edit.tpl ) just compare the 'day' value to the current locale's 'week_day_names' list.

      Problem #1 :
      The digest 'week day' selected on a LOCALE_A siteaccess "notification/settings" page is lost on a LOCALE_B siteaccess "notification/settings" page, for instance between two admin siteaccess, one in english, the other in french, or two language front siteaccesses (english and german) of the same site .
      As 'Wednesday' hardly equals 'Mercredi' or 'Mittwoch'.

      Fact #2 :
      eZSubTreeHandler::handlePublishEvent ( kernel/classes/notification/handler/ezsubtree/ezsubtreehandler.php ) use the following logic to compute the date to send the digest in 'week_day' mode :
      1) Get the current locale's 'weekday_name_list' attribute : an array like [ 0 => Sunday, 1 => Monday, 2 => Tuesday, ...]
      2) Flip (array_flip) the returned array to access a numerical value (the number of a week day) by using a string index (the name of a week day) : [ 'Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, ... ]
      3) Get the numerical identifier of the 'day' field and compute the 'send_date' value (a unix timestamp) according to it

      Problem #2 :
      If the notification cronjob is using a siteaccess with a different locale than the one the user "used" on its "notification/settings" page, eZSubTreeHandler::handlePublishEvent can't extract the correct numerical day identifier (as the 'day' database field value is nowhere to be found in the array keys) and ends up with "0", hence, planning to send the digest on a Sunday, whatever the user choice is.

      Conclusion :
      The best way to do it would be to store the numerical 'week day' representation (eZLocale::WeekDays) in the 'day' field of the 'ezgeneral_digest_user_settings', hence patching both kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigesthandler.php and kernel/classes/notification/handler/ezsubtree/ezsubtreehandler.php and modifying/overriding the ezgeneral digest handler templates.

      Post-scriptum :
      I know the notification system is useless AS IS in a multilingual context anyway (the language used to build the digest mails content is the one of the siteaccess used with the runcronjobs call, not according to non-existing user preference) BUT this would be a first step towards it


          Issue Links



              unknown unknown
              rba_ic Richard Bayet
              0 Vote for this issue
              0 Start watching this issue