Changeset 74
- Timestamp:
- 08/22/08 11:07:16 (2 years ago)
- Files:
-
- trunk/lib/model/PluginsfGuardUser.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/model/PluginsfGuardUser.php
r53 r74 52 52 { 53 53 $age = null; 54 54 55 if ($this->getBirthdate()) 55 56 { 56 $age = date("Y") - (int) $this->getBirthdate('Y'); 57 $month_diff = date("m") - (int) $this->getBirthdate('m'); 58 $day_diff = date("d") - (int) $this->getBirthdate('d'); 59 $age -= $day_diff < 0 || $month_diff < 0 ? 1 : 0; 60 } 57 $age = date("Y") - (int) $this->getBirthdate('Y'); 58 $month = (int) $this->getBirthdate('m'); 59 $day = (int) $this->getBirthdate('d'); 60 61 if (date("m") < $month || (date("m") == $month && date("d") < $day)) 62 { 63 --$age; 64 } 65 } 66 61 67 return $age; 62 68 } 63 69 64 70 /** 65 71 * Check if user allow to be contacted. If he published a job offer in its own … … 72 78 { 73 79 $allow = parent::getAllowContact(); 74 80 75 81 if ($check_jobs && $this->countJobs(new Criteria) > 0) 76 82 { 77 83 $allow = true; 78 84 } 79 85 80 86 return $allow; 81 87 } … … 278 284 279 285 /** 280 * Return full avatar path 281 * 282 * @param string $format 283 * @return string 284 */ 285 public function getFullAvatarPath($format = 'standard') 286 { 287 if (!$this->getAvatarPath()) 288 { 289 return sfConfig::get('app_people_default_avatar'); 290 } 291 return sprintf('/%s/%s/%s/%s', 292 sfConfig::get('sf_upload_dir_name'), 293 sfConfig::get('app_people_upload_dir', 'people'), 294 $format, 295 $this->getAvatarPath()); 286 * Return avatar path, with optional stored format 287 * 288 * @param string $format (small16, small48, standard) 289 * @return string 290 */ 291 public function getAvatarPath($format = 'standard') 292 { 293 if (!parent::getAvatarPath()) 294 { 295 return null; 296 } 297 298 return sprintf('/%s/%s', $format, parent::getAvatarPath()); 296 299 } 297 300 … … 318 321 $user = $user->getRawValue(); 319 322 } 323 320 324 if ($user instanceof sfGuardUser) 321 325 { 322 326 $user = $user->getId(); 323 327 } 328 324 329 $c = new Criteria(); 325 330 $c->add(RecommendationPeer::RECOMMENDED_ID, $this->getId()); 326 331 $c->add(RecommendationPeer::RECOMMENDER_ID, $user); 332 327 333 return (RecommendationPeer::doCount($c) > 0); 328 334 } … … 367 373 { 368 374 } 369 375 370 376 public function setPasswordHash($v) 371 377 { … … 409 415 { 410 416 $algorithm = $this->getAlgorithm(); 411 417 412 418 if (false !== $pos = strpos($algorithm, '::')) 413 419 { 414 420 $algorithm = array(substr($algorithm, 0, $pos), substr($algorithm, $pos + 2)); 415 421 } 416 422 417 423 if (!is_callable($algorithm)) 418 424 { 419 425 throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithm)); 420 426 } 421 427 422 428 return $this->getPassword() == call_user_func_array($algorithm, array($this->getSalt().$password)); 423 429 }
