| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
class Job extends BaseJob |
|---|
| 8 |
{ |
|---|
| 9 |
|
|---|
| 10 |
protected $place = null; |
|---|
| 11 |
|
|---|
| 12 |
public function getCountryName() |
|---|
| 13 |
{ |
|---|
| 14 |
if ($this->getCountry()) |
|---|
| 15 |
{ |
|---|
| 16 |
sfLoader::loadHelpers('I18N'); |
|---|
| 17 |
return format_country($this->getCountry()); |
|---|
| 18 |
} |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
public function getIsActive() |
|---|
| 22 |
{ |
|---|
| 23 |
return !$this->getExpiresAt() or $this->getExpiresAt(null) > time(); |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
public function getPlace() |
|---|
| 27 |
{ |
|---|
| 28 |
if (is_null($this->place)) |
|---|
| 29 |
{ |
|---|
| 30 |
$place = ''; |
|---|
| 31 |
$country = $this->getCountry(); |
|---|
| 32 |
$state = $this->getState(); |
|---|
| 33 |
$city = $this->getCity(); |
|---|
| 34 |
if ($this->getCountry()) |
|---|
| 35 |
{ |
|---|
| 36 |
sfLoader::loadHelpers('I18N'); |
|---|
| 37 |
$country = format_country($country); |
|---|
| 38 |
if ($city) |
|---|
| 39 |
{ |
|---|
| 40 |
if ($state) |
|---|
| 41 |
{ |
|---|
| 42 |
$place .= sprintf("%s, %s (%s)", $city, $state, $country); |
|---|
| 43 |
} |
|---|
| 44 |
else |
|---|
| 45 |
{ |
|---|
| 46 |
$place .= sprintf("%s (%s)", $city, $country); |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
else |
|---|
| 50 |
{ |
|---|
| 51 |
$place .= $country; |
|---|
| 52 |
} |
|---|
| 53 |
} |
|---|
| 54 |
$this->place = $place; |
|---|
| 55 |
} |
|---|
| 56 |
return $this->place; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
public function getOwnerName() |
|---|
| 60 |
{ |
|---|
| 61 |
if ($this->getCompanyId()) |
|---|
| 62 |
{ |
|---|
| 63 |
return $this->getCompany()->getName(); |
|---|
| 64 |
} |
|---|
| 65 |
elseif ($this->getContactId()) |
|---|
| 66 |
{ |
|---|
| 67 |
return $this->getsfGuardUser()->getDisplayName(); |
|---|
| 68 |
} |
|---|
| 69 |
else |
|---|
| 70 |
{ |
|---|
| 71 |
return null; |
|---|
| 72 |
} |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
public function save($con = null) |
|---|
| 76 |
{ |
|---|
| 77 |
$new = $this->isNew(); |
|---|
| 78 |
$modified = $this->isModified(); |
|---|
| 79 |
$affectedRows = parent::save($con); |
|---|
| 80 |
|
|---|
| 81 |
if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) |
|---|
| 82 |
{ |
|---|
| 83 |
$this->getCompany()->setAllowContact(true); |
|---|
| 84 |
$this->getCompany()->save(); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
if ($modified) |
|---|
| 89 |
{ |
|---|
| 90 |
$event = new Event(); |
|---|
| 91 |
if ($this->getCompanyId()) |
|---|
| 92 |
{ |
|---|
| 93 |
$event->setSourceModel('Company'); |
|---|
| 94 |
$event->setSourceName($this->getCompany()->getName()); |
|---|
| 95 |
$event->setSourceSlug($this->getCompany()->getSlug()); |
|---|
| 96 |
} |
|---|
| 97 |
else |
|---|
| 98 |
{ |
|---|
| 99 |
$event->setSourceModel('sfGuardUser'); |
|---|
| 100 |
$event->setSourceSlug($this->getsfGuardUser()->getUsername()); |
|---|
| 101 |
$event->setSourceName($this->getsfGuardUser()->getDisplayName()); |
|---|
| 102 |
} |
|---|
| 103 |
$event->setTargetModel('Job'); |
|---|
| 104 |
$event->setTargetSlug($this->getSlug()); |
|---|
| 105 |
$event->setTargetName($this->getTitle()); |
|---|
| 106 |
if ($new) |
|---|
| 107 |
{ |
|---|
| 108 |
$event->setType('addition'); |
|---|
| 109 |
} |
|---|
| 110 |
else |
|---|
| 111 |
{ |
|---|
| 112 |
$event->setType('update'); |
|---|
| 113 |
} |
|---|
| 114 |
$event->save(); |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
return $affectedRows; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
$columns_map = array('from' => JobPeer::TITLE, |
|---|
| 123 |
'to' => JobPeer::SLUG); |
|---|
| 124 |
|
|---|
| 125 |
sfPropelBehavior::add('Job', |
|---|
| 126 |
array('sfPropelActAsSluggableBehavior' => |
|---|
| 127 |
array('columns' => $columns_map, |
|---|
| 128 |
'separator' => '-', |
|---|
| 129 |
'permanent' => true), |
|---|
| 130 |
'sfPropelActAsLocalizableBehavior' => |
|---|
| 131 |
array('location_getter' => 'getPlace'))); |
|---|
| 132 |
|
|---|
| 133 |
|
|---|