Changeset 73

Show
Ignore:
Timestamp:
08/22/08 10:23:22 (2 years ago)
Author:
nperriault
Message:

Fixed user model class incorrectly calculates the age of a member (thanks to Russ)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/model/PluginsfGuardUser.php

    r23 r73  
    4343  { 
    4444    $age = null; 
     45 
    4546    if ($this->getBirthdate()) 
    4647    { 
    47       $age = date("Y") - (int) $this->getBirthdate('Y'); 
    48       $month_diff = date("m") - (int) $this->getBirthdate('m'); 
    49       $day_diff = date("d") - (int) $this->getBirthdate('d'); 
    50       $age -= $day_diff < 0 || $month_diff < 0 ? 1 : 0; 
    51     } 
     48      $age   = date("Y") - (int) $this->getBirthdate('Y'); 
     49      $month = (int) $this->getBirthdate('m'); 
     50      $day   = (int) $this->getBirthdate('d'); 
     51 
     52      if (date("m") < $month || (date("m") == $month && date("d") < $day)) 
     53      { 
     54        --$age; 
     55      } 
     56    } 
     57 
    5258    return $age; 
    5359  } 
    54    
     60 
    5561  /** 
    5662   * Check if user allow to be contacted. If he published a job offer in its own 
     
    6369  { 
    6470    $allow = parent::getAllowContact(); 
    65      
     71 
    6672    if ($check_jobs && $this->countJobs(new Criteria) > 0) 
    6773    { 
    6874      $allow = true; 
    6975    } 
    70      
     76 
    7177    return $allow; 
    7278  }