| 17 | | class sfPropelOwnedBehavior |
|---|
| 18 | | { |
|---|
| 19 | | static protected $paranoidFlag = true; |
|---|
| 20 | | protected $paranoidFlags = array(); |
|---|
| 21 | | |
|---|
| 22 | | public function doSelectRS($class, $criteria, $con = null) |
|---|
| 23 | | { |
|---|
| 24 | | $columnName = sfConfig::get('propel_behavior_paranoid_'.$class.'_column', 'deleted_at'); |
|---|
| 25 | | |
|---|
| 26 | | if (self::$paranoidFlag) |
|---|
| 27 | | { |
|---|
| 28 | | $criteria->add(call_user_func(array($class, 'translateFieldName'), $columnName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME), null, Criteria::ISNULL); |
|---|
| 29 | | } |
|---|
| 30 | | else |
|---|
| 31 | | { |
|---|
| 32 | | self::$paranoidFlag = true; |
|---|
| 33 | | } |
|---|
| 34 | | |
|---|
| 35 | | return false; |
|---|
| 36 | | } |
|---|
| 37 | | |
|---|
| 38 | | public function preDelete($object, $con = null) |
|---|
| 39 | | { |
|---|
| 40 | | if ($this->getParanoidFlag($object) || !self::$paranoidFlag) |
|---|
| 41 | | { |
|---|
| 42 | | self::$paranoidFlag = true; |
|---|
| 43 | | $this->setParanoidFlag($object, false); |
|---|
| 44 | | |
|---|
| 45 | | return false; |
|---|
| 46 | | } |
|---|
| 47 | | |
|---|
| 48 | | $class = get_class($object); |
|---|
| 49 | | $peerClass = get_class($object->getPeer()); |
|---|
| 50 | | |
|---|
| 51 | | $columnName = sfConfig::get('propel_behavior_paranoid_'.$class.'_column', 'deleted_at'); |
|---|
| 52 | | $method = 'set'.call_user_func(array($peerClass, 'translateFieldName'), $columnName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME); |
|---|
| 53 | | $object->$method(time()); |
|---|
| 54 | | $object->save(); |
|---|
| 55 | | |
|---|
| 56 | | return true; |
|---|
| 57 | | } |
|---|
| 58 | | |
|---|
| 59 | | public function forceDelete($object, $con = null) |
|---|
| 60 | | { |
|---|
| 61 | | $this->setParanoidFlag($object); |
|---|
| 62 | | $object->delete($con); |
|---|
| 63 | | } |
|---|
| 64 | | |
|---|
| 65 | | protected function setParanoidFlag($object) |
|---|
| 66 | | { |
|---|
| 67 | | $this->paranoidFlags[get_class($object).'_'.$object->getPrimaryKey()] = true; |
|---|
| 68 | | } |
|---|
| 69 | | |
|---|
| 70 | | protected function getParanoidFlag($object) |
|---|
| 71 | | { |
|---|
| 72 | | $key = get_class($object).'_'.$object->getPrimaryKey(); |
|---|
| 73 | | |
|---|
| 74 | | return isset($this->paranoidFlags[$key]) ? $this->paranoidFlags[$key] : false; |
|---|
| 75 | | } |
|---|
| 76 | | |
|---|
| 77 | | public static function disable() |
|---|
| 78 | | { |
|---|
| 79 | | self::$paranoidFlag = false; |
|---|
| 80 | | } |
|---|
| | 17 | class sfPropelOwnedBehavior { |
|---|