Menu

#301 Reports case sensitive

Future_Requests
open
nobody
None
1
2014-12-15
2014-05-14
Anonymous
No

Hello,

1) In MRBS a user can login with an case insensitive username (not a problem).
2) In the reporting/user, the reporting results are not being merged, i.e. the same username is listed several times, depending the case used during login -->

Username: 1 meeting
username: 1 meeting
USERNAME= 1 meeting

and not:
Username: 3 meetings

Can this be fixed?

Thanks,
Sven

Discussion

  • Treblig

    Treblig - 2014-07-23

    Would love to see this too.

     
  • Anonymous

    Anonymous - 2014-12-01

    Hello,

    Any idea if and when this would be implemented, because at this moment our reports are useless? Thanks a lot for considering it!

     
  • Treblig

    Treblig - 2014-12-02

    We have a case where bookings are made by one person on behalf of real bookers.
    This person logs on MRBS with her own id and puts the name of the real booker in the short description. Of course, the short description is sometimes all uppercase, other times with accentuated characters, in "camel case" and whatever other variants she sees fit which make summarized reports a total mess.

    I did a quick and dirty fix in report.php somewhere around line 800 as follows :

    function get_sumby_name_from_row(&$row)
    {
      global $sumby;
    
      // Use brief description, created by or type as the name:
      switch( $sumby )
      {
        case 'd':
          $name = $row['name'];
          // MOD GJL - BEG
          // Clean the name, i.e get rid of accentuated characters, take what is on the left of "/" and "uppercase" it
          $name = strtr(strtoupper($name), array(
            "à" => "A", "è" => "E", "ì" => "I", "ò" => "O", "ù" => "U",
            "á" => "A", "é" => "E", "í" => "I", "ó" => "O", "ú" => "U",
            "â" => "A", "ê" => "E", "î" => "I", "ô" => "O", "û" => "U",
            "ä" => "A", "ë" => "E", "ï" => "I", "ö" => "O", "ü" => "U",
            "À" => "A", "È" => "E", "Ì" => "I", "Ò" => "O", "Ù" => "U",
            "Á" => "A", "É" => "E", "Í" => "I", "Ó" => "O", "Ú" => "U",
            "Â" => "A", "Ê" => "E", "Î" => "I", "Ô" => "O", "Û" => "U",
            "Ä" => "A", "Ë" => "E", "Ï" => "I", "Ö" => "O", "Ü" => "U",
            "ç" => "Ç", "ÿ" => "Y")); 
          $pos = strpos($name, "/");
          if (!$pos === FALSE) {
            $name = trim(strstr($name, '/', true));
          }
          // MOD GJL - END
          break;
        case 't':
          $name = get_type_vocab($row['type']);
          break;
        case 'c':
        default:
          $name = $row['create_by'];
          break;
      }
      return escape($name);
    }
    

    I'm sure there are better ways to do this and mostly only the french the accentuated letters are taken into account and will have to be adapted to other languages (unless there an inbuilt PHP functions that takes care of this).

    The above can be used for the "username" case ($row['create_by'] ?) of the same function which would solve your problem.

     

    Last edit: Treblig 2014-12-02
  • Anonymous

    Anonymous - 2014-12-15

    Treblig: Thanks a lot, is working like a charm!
    Hope that it will be included in one of the future code releases as well.

     
  • John Beranek

    John Beranek - 2014-12-15

    Possible in PHP, but only with PHP >= 5.3.0 and with the intl extension enabled. Also needs to be applied for a specific locale, but that could presumably be the user's locale.

    e.g.

    $coll = collator_create("fr_FR");
    collator_set_strength($coll, Collator::PRIMARY);
    echo collator_compare($coll, "CAfé", "caFe");
    

    Gives the output '0' telling you that "CAfé" and "caFe" can be considered identical.

     

    Last edit: John Beranek 2014-12-15
  • Campbell Morrison

    I think it should also be possible to shift the task of ignoring accents and cases to the SQL query using "COLLATE utf8_general_ci".

     

    Last edit: Campbell Morrison 2014-12-15
  • Treblig

    Treblig - 2014-12-15

    @Anonymous : happy it helps. Don't trust my coding though, I'm not a "real" developer. You'd probably trust John's or Campbell's solutions above rather than mine which is bound to fall short for many languages. This said I don't know how to use either of their solutions ;-)

    @John Beranek & Campbell : thanks for your inputs, it may help people who know what they are doing. As stated earlier, while I'm occasionally putting my hands under the PHP bonnet, I'm galaxies away from you guys when it comes to trusted knowledge of PHP (and MySQL for that matter) therefore I'm not too sure how I would implement either of your solutions.

     
MongoDB Logo MongoDB