当前位置: 首页>>代码示例>>PHP>>正文


PHP Uploader::deleteFile方法代码示例

本文整理汇总了PHP中Uploader::deleteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Uploader::deleteFile方法的具体用法?PHP Uploader::deleteFile怎么用?PHP Uploader::deleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Uploader的用法示例。


在下文中一共展示了Uploader::deleteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 /**
  * 编辑
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel();
     //旧文件
     $old_file = $model->attach_file;
     $old_thumb = $model->attach_thumb;
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach'], 'image', true);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $upload->deleteFile($upload->_thumb_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             //删除旧文件
             $upload->deleteFile($old_file);
             $upload->deleteFile($old_thumb);
             $model->attach_file = $upload->_file_name;
             $model->attach_thumb = $upload->_thumb_name;
         }
         $model->update_time = time();
         if ($model->save()) {
             $this->message('success', Yii::t('admin', 'Update Success'), $this->createUrl('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:github-zjh,项目名称:task,代码行数:35,代码来源:CatalogController.php

示例2: run

 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             foreach ((array) $ids as $id) {
                 $softModel = Soft::model()->findByPk($id);
                 if ($softModel) {
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_icon);
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_file);
                 }
             }
             Soft::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Soft::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Soft::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:35,代码来源:BatchAction.php

示例3: actionBatch

 /**
  * 批量操作
  * @throws CHttpException
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($this->_request->getParam('command'));
         $ids = intval($this->_request->getParam('id'));
     } elseif ($this->method() == 'POST') {
         $command = $this->_request->getPost('command');
         $ids = $this->_request->getPost('id');
     } else {
         throw new CHttpException(404, Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'attachDelete':
             foreach ((array) $ids as $id) {
                 $uploadModel = Upload::model()->findByPk($id);
                 if ($uploadModel) {
                     Uploader::deleteFile($uploadModel->file_name);
                     $uploadModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
开发者ID:github-zjh,项目名称:task,代码行数:32,代码来源:AttachController.php

示例4: actionSetting

 /**
  * 修改基本资料
  * @param string $setting
  */
 public function actionSetting()
 {
     $this->_seoTitle = Yii::t('common', 'User Setting') . ' - ' . Yii::t('common', 'Setting Profile') . ' - ' . $this->_setting['site_name'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/jquery.Jcrop.min.css");
     $model = $this->loadModel();
     //判断账号是否已激活
     if ($this->_active_need && $model->status == -1) {
         $this->redirect($this->createUrl('activeEmail'));
     }
     $old_avatar = $model->avatar;
     if (isset($_POST['User'])) {
         $model->attributes = array_map('trim', $_POST['User']);
         //把确定上传的头像重命名
         $new_avatar = str_replace('old_', '', $model->avatar);
         @rename($model->avatar, $new_avatar);
         $model->avatar = $new_avatar;
         if ($model->save()) {
             if ($old_avatar != $model->avatar) {
                 Uploader::deleteFile($old_avatar);
             }
             //删除游离的图片
             $avatar_path = 'uploads/avatar';
             $old_files = Helper::scanfDir($avatar_path, true);
             foreach ((array) $old_files['files'] as $old) {
                 $path_parts = pathinfo($old);
                 if (!strstr($path_parts['basename'], $model->uid . '_old_')) {
                     continue;
                 }
                 Uploader::deleteFile($old);
             }
             //同步昵称
             Yii::app()->user->nickname = $model->nickname;
             //提示信息
             Yii::app()->user->setFlash('success', Yii::t('common', 'Update Profile Success'));
         }
     }
     $this->render('setting_profile', array('model' => $model));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:45,代码来源:UserController.php

示例5: updateProfilePicture

 /**
  * Update Profile Picture.
  *
  * @access public
  * @param  integer $userId
  * @param  array   $fileData
  * @return mixed
  * @throws Exception If failed to update profile picture.
  */
 public function updateProfilePicture($userId, $fileData)
 {
     $image = Uploader::uploadPicture($fileData, $userId);
     if (!$image) {
         $this->errors = Uploader::errors();
         return false;
     }
     $database = Database::openConnection();
     $query = "UPDATE users SET profile_picture = :profile_picture WHERE id = :id LIMIT 1";
     $database->prepare($query);
     $database->bindValue(':profile_picture', $image["basename"]);
     $database->bindValue(':id', $userId);
     $result = $database->execute();
     //if update failed, then delete the user picture
     if (!$result) {
         Uploader::deleteFile(IMAGES . "profile_pictures/" . $image["basename"]);
         throw new Exception("Profile Picture " . $image["basename"] . " couldn't be updated");
     }
     return $image;
 }
开发者ID:E01T,项目名称:miniPHP,代码行数:29,代码来源:User.php

示例6: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除文章
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $image_list = $postModel->image_list;
                     $image_list && ($image_list = unserialize($image_list));
                     if ($image_list) {
                         foreach ($image_list as $image) {
                             Uploader::deleteFile($image['file']);
                             $file = Upload::model()->findByPk($image['fileId']);
                             if ($file) {
                                 $file->delete();
                             }
                         }
                     }
                     Uploader::deleteFile($postModel->attach_file);
                     Uploader::deleteFile($postModel->attach_thumb);
                     $postModel->delete();
                     //删除关联的标签
                     TagData::model()->deleteAll('content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'show':
             //文章显示
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'Y';
                     $postModel->save();
                     //更新关联的标签
                     $tagData = TagData::model()->updateAll(array('status' => 'Y'), 'content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'hidden':
             //文章隐藏
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'N';
                     $postModel->save();
                     //更新关联的标签
                     $tagData = TagData::model()->updateAll(array('status' => 'N'), 'content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'commend':
             //文章推荐
             foreach ((array) $ids as $id) {
                 $recom_id = intval($_POST['recom_id']);
                 if ($recom_id) {
                     $postModel = Post::model()->findByPk($id);
                     if ($postModel) {
                         $postModel->commend = 'Y';
                         $postModel->save();
                         $recom_post = new RecommendPost();
                         $recom_post->id = $recom_id;
                         $recom_post->post_id = $id;
                         $recom_post->save();
                     }
                 } else {
                     $this->message('error', Yii::t('admin', 'RecommendPosition is Required'));
                 }
             }
             break;
         case 'stick':
             //文章置顶
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->top_line = 'Y';
                     $postModel->save();
                 }
             }
             break;
         case 'cancelStick':
             //文章取消置顶
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->top_line = 'N';
//.........这里部分代码省略.........
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:101,代码来源:PostController.php

示例7: actionRemove

 /**
  * 删除附件
  * @return [type] [description]
  */
 public function actionRemove()
 {
     $imageId = intval($this->_request->getParam('imageId'));
     try {
         $imageModel = Upload::model()->findByPk($imageId);
         if ($imageModel == false) {
             throw new Exception("附件已经被删除");
         }
         Uploader::deleteFile($imageModel->file_name);
         Uploader::deleteFile($imageModel->thumb_name);
         if (!$imageModel->delete()) {
             throw new Exception("数据删除失败");
         }
         $var['state'] = 'success';
         $var['message'] = '删除完成';
     } catch (Exception $e) {
         $var['state'] = 'error';
         $var['message'] = '失败:' . $e->getMessage();
     }
     exit(CJSON::encode($var));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:25,代码来源:UploadifyController.php

示例8: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除视频
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     Uploader::deleteFile($postModel->cover_image);
                     $postModel->delete();
                 }
             }
             break;
         case 'show':
             //视频显示
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'Y';
                     $postModel->save();
                 }
             }
             break;
         case 'hidden':
             //视频隐藏
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'N';
                     $postModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:53,代码来源:VideoController.php

示例9: updateBackup

 /**
  * Update the backup file from the backup directory in file system
  * The user of the database MUST be assigned privilege of ADMINISTRATION -> LOCK TABLES.
  *
  * @access public
  * @return bool
  */
 public function updateBackup()
 {
     $dir = APP . "backups/";
     $files = scandir($dir);
     //delete and clean all current files in backup directory
     foreach ($files as $file) {
         if ($file != "." && $file != "..") {
             if (is_file("{$dir}/{$file}")) {
                 Uploader::deleteFile("{$dir}/{$file}");
             }
         }
     }
     //Use another username and password only for this function, while the main user has limited privileges
     $windows = true;
     if ($windows) {
         exec('C:\\wamp\\bin\\mysql\\mysql5.6.17\\bin\\mysqldump --user=' . escapeshellcmd(Config::get('DB_USER')) . ' --password=' . escapeshellcmd(Config::get('DB_PASS')) . ' ' . escapeshellcmd(Config::get('DB_NAME')) . ' > ' . APP . 'backups\\backup-' . time() . '.sql');
     } else {
         exec('mysqldump --user=' . escapeshellcmd(Config::get('DB_USER')) . ' --password=' . escapeshellcmd(Config::get('DB_PASS')) . ' ' . escapeshellcmd(Config::get('DB_NAME')) . ' > ' . APP . 'backups/backup-' . time() . '.sql');
     }
     return true;
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:28,代码来源:Admin.php

示例10: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } else {
         if ($this->method() == 'POST') {
             $command = trim($_POST['command']);
             $ids = $_POST['id'];
         } else {
             $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
         }
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'adDelete':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     Uploader::deleteFile($adModel->attach_file);
                     $adModel->delete();
                 }
             }
             break;
         case 'adVerify':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     $adModel->status = 'Y';
                     $adModel->save();
                 }
             }
             break;
         case 'adUnVerify':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     $adModel->status = 'N';
                     $adModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:52,代码来源:AdController.php

示例11: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'specialDelete':
             foreach ((array) $ids as $id) {
                 $specialModel = Special::model()->findByPk($id);
                 if ($specialModel) {
                     Uploader::deleteFile($specialModel->attach_file);
                     Uploader::deleteFile($specialModel->attach_thumb);
                     $specialModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:33,代码来源:SpecialController.php

示例12: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($this->_request->getParam('command'));
         $ids = intval($this->_request->getParam('id'));
     } elseif ($this->method() == 'POST') {
         $command = $this->_request->getPost('command');
         $ids = $this->_request->getPost('id');
     } else {
         throw new CHttpException(404, Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'userLock':
             foreach ((array) $ids as $id) {
                 $userModel = User::model()->findByPk($id);
                 if ($userModel) {
                     $userModel->status = 0;
                     $userModel->save();
                 }
             }
             break;
         case 'userunLock':
             foreach ((array) $ids as $id) {
                 $userModel = User::model()->findByPk($id);
                 if ($userModel) {
                     $userModel->status = 1;
                     $userModel->save();
                 }
             }
             break;
         case 'userUnpass':
             foreach ((array) $ids as $id) {
                 $userModel = User::model()->findByPk($id);
                 if ($userModel) {
                     $userModel->status = -1;
                     $userModel->save();
                 }
             }
             break;
         case 'userDelete':
             foreach ((array) $ids as $id) {
                 $userModel = User::model()->findByPk($id);
                 if ($userModel) {
                     $userModel->delete();
                     //删除绑定用户
                     OAuthQQ::model()->deleteAllByAttributes(array('uid' => $id));
                     OAuthSinawb::model()->deleteAllByAttributes(array('uid' => $id));
                     OAuthRenren::model()->deleteAllByAttributes(array('uid' => $id));
                     OAuthWeixin::model()->deleteAllByAttributes(array('uid' => $id));
                     //删除头像
                     Uploader::deleteFile($userModel->avatar);
                 }
             }
             break;
         case 'groupDelete':
             foreach ((array) $ids as $id) {
                 $groupModel = UserGroup::model()->findByPk($id);
                 if ($groupModel) {
                     $groupModel->delete();
                 }
             }
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
开发者ID:github-zjh,项目名称:task,代码行数:72,代码来源:UserController.php

示例13: actionFile

 /**
  * 上传文件(单个不能超过50M)
  */
 public function actionFile()
 {
     if ($this->method() == 'POST') {
         $adminiUserId = Yii::app()->user->id;
         $file = new Uploader();
         $file->_allow_exts = 'pdf,doc,docx,xls,ppt,exe,zip,tar,gz,msi,7z';
         //普通文件类型限制
         $file->_allow_exts .= ',mp3,mp4,wma';
         //音频文件
         $file->_allow_exts .= ',swf,mv,avi,mp4,flv,rmvb,mov,asf,wmv,3GP,ra,rm';
         //视频文件
         $file->_rand_name = false;
         //用原来的名称
         if (is_array($_FILES['file']) && !empty($_FILES['file'])) {
             foreach ($_FILES['file'] as $value) {
                 if (is_array($value)) {
                     $files = $_FILES['file'];
                 } else {
                     $files = array($_FILES['file']);
                 }
                 break;
             }
         } else {
             exit(CJSON::encode(array('state' => 'error', 'message' => Yii::t('admin', 'Please select a file.'))));
         }
         foreach ($files as $simplefile) {
             $file->uploadFile($simplefile);
             if ($file->_error) {
                 exit(CJSON::encode(array('state' => 'error', 'message' => Yii::t('admin', $file->_error))));
             } else {
                 $model = new Upload();
                 $model->user_id = intval($adminiUserId);
                 $model->file_name = $file->_file_name;
                 $model->thumb_name = $file->_thumb_name;
                 $model->real_name = $file->_real_name;
                 $model->file_ext = $file->_file_ext;
                 $model->file_mime = $file->_mime_type;
                 $model->file_size = $file->_file_size;
                 $model->create_time = time();
                 if ($model->save()) {
                     exit(CJSON::encode(array('state' => 'success', 'realname' => $file->_real_name, 'fileId' => $model->id)));
                 } else {
                     $file->deleteFile($file->_file_name);
                     exit(CJSON::encode(array('state' => 'error', 'message' => Yii::t('admin', 'Save failed, Upload error'))));
                 }
             }
         }
     }
 }
开发者ID:uxff,项目名称:myyiicms,代码行数:52,代码来源:UploadifyController.php

示例14: deleteById

 /**
  * deletes file.
  * This method overrides the deleteById() method in Model class.
  *
  * @access public
  * @param  array    $id
  * @throws Exception If failed to delete the file
  *
  */
 public function deleteById($id)
 {
     $database = Database::openConnection();
     $database->getById("files", $id);
     $file = $database->fetchAssociative();
     //start a transaction to guarantee the file will be deleted from both; database and filesystem
     $database->beginTransaction();
     $database->deleteById("files", $id);
     if ($database->countRows() !== 1) {
         $database->rollBack();
         throw new Exception("Couldn't delete file");
     }
     $basename = $file["hashed_filename"] . "." . $file["extension"];
     Uploader::deleteFile(APP . "uploads/" . $basename);
     $database->commit();
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:25,代码来源:File.php

示例15: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除商品
             foreach ((array) $ids as $id) {
                 $goodsModel = Goods::model()->findByPk($id);
                 if ($goodsModel) {
                     $image_list = $goodsModel->image_list;
                     $image_list && ($image_list = unserialize($image_list));
                     if ($image_list) {
                         foreach ($image_list as $image) {
                             Uploader::deleteFile($image['file']);
                             $file = Upload::model()->findByPk($image['fileId']);
                             if ($file) {
                                 $file->delete();
                             }
                         }
                     }
                     Uploader::deleteFile($goodsModel->default_image);
                     Uploader::deleteFile($goodsModel->default_thumb);
                     $goodsModel->delete();
                 }
             }
             break;
         case 'show':
             //商品显示
             foreach ((array) $ids as $id) {
                 $goodsModel = Goods::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->status = 'Y';
                     $goodsModel->save();
                 }
             }
             break;
         case 'hidden':
             //商品隐藏
             foreach ((array) $ids as $id) {
                 $goodsModel = Goods::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->status = 'N';
                     $goodsModel->save();
                 }
             }
             break;
         case 'commend':
             //商品推荐
             foreach ((array) $ids as $id) {
                 $recom_id = intval($_POST['recom_id']);
                 if ($recom_id) {
                     $goodsModel = Goods::model()->findByPk($id);
                     if ($goodsModel) {
                         $goodsModel->recommend = 'Y';
                         $goodsModel->save();
                     }
                 } else {
                     $this->message('error', Yii::t('admin', 'RecommendPosition is Required'));
                 }
             }
             break;
         case 'unCommend':
             //商品取消推荐
             foreach ((array) $ids as $id) {
                 $goodsModel = Goods::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->commend = 'N';
                     $goodsModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:90,代码来源:GoodsController.php


注:本文中的Uploader::deleteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。