public static function RemoveFileOnly($pk, $fieldName) { $modelRemove = self::model()->findByPk($pk); if (is_null($modelRemove) || empty($modelRemove->{$fieldName})) { return; } $aDate = explode('-', $modelRemove->date_only); $pathUpload = ProGlobalEnquiry::$folderUpload . "/{$aDate['0']}/{$aDate['1']}/{$aDate['2']}"; $ImageHelper = new ImageHelper(); $ImageHelper->folder = '/' . $pathUpload; $ImageHelper->deleteFile($ImageHelper->folder . '/' . $modelRemove->{$fieldName}); }
public function deleteImage($fieldName, $path, $oldImage) { if (!empty($oldImage)) { ImageHelper::deleteFile($path . '/' . $oldImage); if (array_key_exists($fieldName, $this->aImageSize) && is_array($this->aImageSize[$fieldName])) { $aSize = $this->aImageSize[$fieldName]; foreach ($aSize as $key => $value) { ImageHelper::deleteFile($path . '/' . $key . '/' . $oldImage); } } } }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionEdit() { if (!empty($this->catalog)) { $message = ""; $catalog = $this->catalog; $action = Yii::app()->request->getParam("action", ""); if ($this->id) { $item = $catalog::fetch($this->id); } else { $item = new $catalog(); } // Удаление картинки if ($action == "img_del") { $imageField = Yii::app()->request->getParam("field", ""); if (!empty($imageField)) { ImageHelper::deleteFile($item, $imageField); $item->save(); $message = "Фото успешно удаленно"; } } // Удаляем картинки в галлере if ($action == "gal_del") { $id = (int) Yii::app()->request->getParam("img_id", 0); if (!empty($id)) { $imageModel = CatGallery::fetch($id); if ($imageModel->id > 0) { $imageModel->delete(); $message = "Фото успешно удаленно"; } } } $addGallery = new CatGallery(); if ($item->id > 0) { $listImage = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setOrderBy("pos, id")->setCache(0)->setLimit(-1)); } else { $listImage = array(); } $this->arrayParams["catalog"] = $catalog; $this->render('edit', array('arrayParams' => $this->arrayParams, 'controller' => $this, 'form' => $item, 'catalog' => SiteHelper::getCamelCase($item->tableName()), 'listImage' => $listImage, 'message' => $message, 'addGallery' => $addGallery)); } }
public static function RemoveFileOnly($pk, $fieldName, $aSize) { $modelRemove = self::model()->findByPk($pk); if (is_null($modelRemove) || empty($modelRemove->{$fieldName})) { return; } $pathUpload = ProInventoryPhoto::$folderUpload; $ImageHelper = new ImageHelper(); $ImageHelper->folder = '/' . $pathUpload; $ImageHelper->deleteFile($ImageHelper->folder . '/' . $modelRemove->{$fieldName}); foreach ($aSize as $key => $value) { $ImageHelper->deleteFile($ImageHelper->folder . '/' . $key . '/' . $modelRemove->{$fieldName}); } }
$mUser->scenario = null; $mUser->agent_company_name = $model->company_name; $mUser->first_name = $model->salesperson_name; if (trim($mUser->first_name) == '' && $model->type == ProTransactionsBillTo::TYPE_VENDOR_PURCHASER) { $mUser->first_name = $model->attn_to; } $mUser->nric_passportno_roc = $model->nric_no; $mUser->contact_no = $model->contact_no; $mUser->address = $model->billing_address; $mUser->postal_code = $model->postal_code; $mUser->status = STATUS_INACTIVE; $mUser->application_id = FE; $mUser->role_id = $role_id;
public static function deleteImage($model) { $model = self::model()->findByPk($model->id); if (is_null($model) || empty($model->photo)) { return; } $ImageHelper = new ImageHelper(); $ImageHelper->folder = '/' . self::$folderUpload . '/' . $model->id; $ImageHelper->deleteFile($ImageHelper->folder . '/' . $model->photo); }