示例#1
0
 public function beforeDelete()
 {
     //delete all photo
     $allphoto = ProListingPhotos::model()->findAllByAttributes(array('listing_id' => $this->id));
     if ($allphoto) {
         foreach ($allphoto as $photo) {
             if ($photo->delete()) {
                 ProListingPhotos::removePhoto($photo);
             }
         }
     }
     //delete all doc
     $allDoc = ProListingUploadCea::model()->findAllByAttributes(array('listing_id' => $this->id));
     if ($allDoc) {
         foreach ($allDoc as $doc) {
             if ($doc->delete()) {
                 ProListingUploadCea::removefileDoc($doc);
             }
         }
     }
     return parent::beforeDelete();
 }
示例#2
0
 public function actionAjaxdelete_photo($listing, $photo)
 {
     if (Listing::model()->findByAttributes(array('id' => $listing, 'user_id' => $this->userID))) {
         $model = ProListingPhotos::model()->findByPk($photo);
         if ($model->delete()) {
             ProListingPhotos::removePhoto($model);
             Listing::AutoSetCoverPhotoListing($listing);
         }
     }
 }