public function transientNewItemsCreate() { foreach ($this->getResponseArray() as $item) { $prod = Doctrine::getTable('Product')->findOneByCode($item['product_code']); if (!$prod) { continue; } $picObj = Doctrine::getTable('ProductPictures')->findOneByProductIdAndParameter($prod['id'], $item['parameter']); if ($picObj) { # do some sort of syncronizing... } else { # create totally new object $item['product_id'] = $prod['id']; $prodPic = new ProductPictures(); $prodPic->fromArray($item); $this->downloadVideoPic($item['file']); $this->getResultCollection()->add($prodPic); } } //exit; }
public function actionDelPicture() { $model = ProductPictures::model()->findByAttributes(array('img_id' => $_POST['img_id'], 'store_id' => 0)); if ($model) { $model->delete(); } }
/** * Action: Delete resource images * @return Response */ public function deleteUpload($id) { // Only allows you to share pictures on the cover of the current resource being deleted $filename = ProductPictures::where('id', $id)->where('user_id', Auth::user()->id)->first(); $oldImage = $filename->filename; $model = $this->model->find($filename->product_id); $oldThumbnails = $model->thumbnails; if (is_null($filename)) { return Redirect::back()->with('error', '没有找到对应的图片'); } elseif ($filename->delete()) { destoryUploadImages($this->destinationPath, $oldImage); if ($oldImage == $oldThumbnails) { $model->thumbnails = NULL; $model->save(); destoryUploadImages($this->thumbnailsPath, $oldThumbnails); } return Redirect::back()->with('success', '图片删除成功。'); } else { return Redirect::back()->with('warning', '图片删除失败。'); } }