|
Revision 49, 1.8 kB
(checked in by nperriault, 8 months ago)
|
Resolved the context "default" does not exist bug by removing calls to sfContext in the model.
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
class Recommendation extends BaseRecommendation |
|---|
| 8 |
{ |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
* Retrieves recommended user |
|---|
| 12 |
* |
|---|
| 13 |
* @return sfGuardUser |
|---|
| 14 |
*/ |
|---|
| 15 |
public function getRecommended() |
|---|
| 16 |
{ |
|---|
| 17 |
return $this->getsfGuardUserRelatedByRecommendedId(); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
* Retrieves recommended user display name |
|---|
| 22 |
* |
|---|
| 23 |
* @return string |
|---|
| 24 |
*/ |
|---|
| 25 |
public function getRecommendedName() |
|---|
| 26 |
{ |
|---|
| 27 |
return $this->getRecommended()->getDisplayName(); |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
* Retrieves recommender |
|---|
| 32 |
* |
|---|
| 33 |
* @return sfGuardUser |
|---|
| 34 |
*/ |
|---|
| 35 |
public function getRecommender() |
|---|
| 36 |
{ |
|---|
| 37 |
return $this->getsfGuardUserRelatedByRecommenderId(); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* Retrieves recommender display name |
|---|
| 42 |
* |
|---|
| 43 |
* @return string |
|---|
| 44 |
*/ |
|---|
| 45 |
public function getRecommenderName() |
|---|
| 46 |
{ |
|---|
| 47 |
return $this->getRecommender()->getDisplayName(); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
* Saves object |
|---|
| 52 |
* |
|---|
| 53 |
* @return int |
|---|
| 54 |
*/ |
|---|
| 55 |
public function save($con = null) |
|---|
| 56 |
{ |
|---|
| 57 |
$new = $this->isNew(); |
|---|
| 58 |
$modified = $this->isModified(); |
|---|
| 59 |
$save = parent::save($con); |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
if ($modified) |
|---|
| 63 |
{ |
|---|
| 64 |
$event = new Event(); |
|---|
| 65 |
$event->setSourceModel('sfGuardUser'); |
|---|
| 66 |
$event->setSourceSlug($this->getRecommender()->getUsername()); |
|---|
| 67 |
$event->setSourceName($this->getRecommender()->getDisplayName()); |
|---|
| 68 |
$event->setTargetModel('sfGuardUser'); |
|---|
| 69 |
$event->setTargetSlug($this->getRecommended()->getUsername()); |
|---|
| 70 |
$event->setTargetName($this->getRecommended()->getDisplayName()); |
|---|
| 71 |
if ($new) |
|---|
| 72 |
{ |
|---|
| 73 |
$event->setType('recommendation_addition'); |
|---|
| 74 |
$event->setOccuredAt($this->getCreatedAt()); |
|---|
| 75 |
} |
|---|
| 76 |
else |
|---|
| 77 |
{ |
|---|
| 78 |
$event->setType('recommendation_update'); |
|---|
| 79 |
$event->setOccuredAt($this->getUpdatedAt()); |
|---|
| 80 |
} |
|---|
| 81 |
$event->save(); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
return $save; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
} |
|---|
| 88 |
|
|---|