예제 #1
0
 public function save()
 {
     if (!$this->active) {
         $this->active = 0;
     }
     if (!$this->panelist_deny) {
         $this->panelist_deny = 0;
     }
     if (!$this->repair_status) {
         $this->repair_status = 0;
     }
     if (!$this->is_tester) {
         $this->is_tester = 0;
     }
     $this->_edited_datetime = M('Tools')->date()->dbDateTime();
     $this->_edited_user_id = me()->id();
     if ($this->status_id != $this->_propsInitial['status_id']) {
         $this->_mapper->statusChanged($this, $this->_propsInitial['status_id']);
         if ($this->status_id == 8 || $this->status_id == 11) {
             $this->diary_access_disabled = 1;
             $this->date_reject = M('Date')->dbDateTime();
         }
     }
     if ($this->city_id != $this->_propsInitial['city_id'] || !$this->_existsInDb()) {
         if (!isNull($city = M('City')->loadById($this->city_id))) {
             $this->home_longitude = $city->longitude;
             $this->home_latitude = $city->latitude;
         }
     }
     if ($this->metro_id != $this->_propsInitial['metro_id'] || !$this->_existsInDb() && $this->metro_id) {
         if (!isNull($metro = M('City')->loadMetroById($this->metro_id)) && $metro->longitude && $metro->latitude) {
             $this->home_longitude = $metro->longitude;
             $this->home_latitude = $metro->latitude;
         }
     }
     if ($this->diary_access_disabled) {
         if (!$this->_propsInitial['is_tester']) {
             $this->is_tester = 0;
         }
         if ($this->status_id == 10) {
             $this->status_id = 11;
         }
         if (!isNull($obHolder = M('Holder')->getPersonalHolderByUser($this)) && $obHolder->canClose()) {
             $obHolder->is_closed = 1;
             $obHolder->save();
         }
     }
     return parent::save();
 }