Beispiel #1
0
 protected function saveLocationsToListing($model)
 {
     foreach ($_POST['Listing']['p_locations'] as $locationId) {
         $listingLocation = new ListingLocation();
         $listingLocation->listing_id = $model->listing_id;
         $listingLocation->location_id = $locationId;
         if (!$listingLocation->save()) {
             return false;
         }
     }
     return true;
 }
Beispiel #2
0
 function beforeDelete()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'listing_id=:listing_id';
     $criteria->params = array(':listing_id' => $this->listing_id);
     ListingCategory::model()->deleteAll($criteria);
     ListingLocation::model()->deleteAll($criteria);
     Coupon::model()->deleteAll($criteria);
     // delete logo file
     if ($this->logo != '') {
         $imageFile = Yii::app()->user->getFullPathToImages(Yii::app()->params['listingLogo']) . $this->logo;
         @unlink($imageFile);
     }
     return parent::beforeDelete();
 }
Beispiel #3
0
 public function verifyDelete()
 {
     $locationId = $this->location_id;
     // check if it has some subcategories
     $locs = $this->findByAttributes(array('parent_location_id' => $locationId));
     if ($locs) {
         throw new CHttpException(400, 'You cannot delete location that contains some sublocations!');
     }
     $listings = ListingLocation::model()->findByAttributes(array('location_id' => $locationId));
     if ($listings) {
         throw new CHttpException(400, 'You cannot delete location that contains some listings!');
     }
     $pads = PremiumAdLocation::model()->findByAttributes(array('location_id' => $locationId));
     if ($pads) {
         throw new CHttpException(400, 'You cannot delete location that contains some premium ads!');
     }
     return true;
 }