Please upgrade here. These earlier versions are no longer being updated and have security issues.

1 bug + 1/2 bug

ClémentClément
edited September 2014 in Vanilla 2.0 - 2.3

Hello,

I found two problems with the user profile when saving (Vanilla 2.1.3).


1) The module Profile Extender, type "birthday" field without required to fill it prevents to save the form. => Display : ValidateDate


2) Vanilla does not differentiate between two users: Clément & clement
I did the migration from phpBB. Unable to save the form.


Thank you for your help.

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited September 2014

    As far as I know, Vanilla distinguishes Users via their ID number and email not the name. The names can be changed but the ID stays the same.

    You can go into your database under the Users table and check to make sure no one has the same ID number

  • For number 1, you can use this:

    $PluginInfo['DateValidation'] = array(
       'Description' => 'Workaround to allow 0-0-0 dates entered via ProfileExtender',
       'Version' => '1.0',
       'Author' => "Bleistivt",
    );
    
    class DateValidation extends Gdn_Plugin {
    }
    
    if (!function_exists('ValidateDate')) {
        function ValidateDate($Value) {
            // Dates should be in YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format
            if (empty($Value) || $Value = "0-0-0") {
                return TRUE; // blank dates validated through required.
            } else {
                $Matches = [];
                if (preg_match('/^(\d{4})-(\d{2})-(\d{2})(?:\s{1}(\d{2}):(\d{2})(?::(\d{2}))?)?$/', $Value, $Matches)) {
                    $Year = $Matches[1];
                    $Month = $Matches[2];
                    $Day = $Matches[3];
                    $Hour = ArrayValue(4, $Matches, 0);
                    $Minutes = ArrayValue(5, $Matches, 0);
                    $Seconds = ArrayValue(6, $Matches, 0);
                    return checkdate($Month, $Day, $Year) && $Hour < 24 && $Minutes < 61 && $Seconds < 61;
                }
            }
            return FALSE;
        }
    }
    

    My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations

    vrijvlinderClément
  • ClémentClément
    edited September 2014

    For number 1, thank you very much Bleistivt, this is perfect !!! :)

    For number 2, After verification, Vanilla does well on a test name.

    Here is the code in question (class UserModel)

    `

    public function ValidateUniqueFields($Username, $Email, $UserID = '', $Return = FALSE) {
    $Valid = TRUE;
    $Where = array();
    if (is_numeric($UserID))
    $Where['UserID <> '] = $UserID;

      $Result = array('Name' => TRUE, 'Email' => TRUE);
    
      // Make sure the username & email aren't already being used
      if (C('Garden.Registration.NameUnique', TRUE) && $Username) {
         $Where['Name'] = $Username;
         $TestData = $this->GetWhere($Where);
         if ($TestData->NumRows() > 0) {
            $Result['Name'] = FALSE;
            $Valid = FALSE;
         }
         unset($Where['Name']);
      }
    
      if (C('Garden.Registration.EmailUnique', TRUE) && $Email) {
         $Where['Email'] = $Email;
         $TestData = $this->GetWhere($Where);
         if ($TestData->NumRows() > 0) {
            $Result['Email'] = FALSE;
            $Valid = FALSE;
         }
      }
    
      if ($Return) {
         return $Result;
      } else {
         if (!$Result['Name'])
            $this->Validation->AddValidationResult('Name', 'The name you entered is already in use by another member.');
         if (!$Result['Email'])
            $this->Validation->AddValidationResult('Email', 'The email you entered is in use by another member.');
         return $Valid;
      }
    

    }
    `

    Here is the generated query
    select * from GDN_User 'User' where UserID <> '2' and Name = 'Clément';

    Here is the result in phpMyAdmin => :\

    Just to let you know

  • I found the solution ! Just change the collation of the name field.
    utf8_unicode_ci => utf8_bin

    R_JBleistivt
Sign In or Register to comment.