class IcewindDaleRP_IcewindDale_ControllerAdmin_ShopItems extends XenForo_ControllerAdmin_Abstract
{
protected function _preDispatch($action)
{
$this->assertAdminPermission('IcewindDale');
}
public function actionUpload()
{
$viewParams = array(
);
return $this->responseView(
'IcewindDaleRP_IcewindDale_ViewAdmin_Shop_Items_Upload',
'iwd_shop_items_upload',
$viewParams
);
}
public function actionUploadImage()
{
$this->_assertPostOnly();
$uploadItemImage = XenForo_Upload::getUploadedFile('imagename');
if ($uploadItemImage)
{
$imageFileName = $this->_getHelperUploadShopImageModel()->uploadItemImage($uploadItemImage);
if (!$this->_getShopImagesModel()->verifyUniqueImageUrlByFileName($imageFileName))
{
$imageName = $this->_getShopImagesModel()->createImageNameFromFileName($imageFileName);
$itemType = $this->_input->filterSingle('image_category', XenForo_Input::STRING);
$dw = XenForo_DataWriter::create('IcewindDaleRP_IcewindDale_DataWriter_ShopImages');
$dw->set('image_name', $imageName);
$dw->set('image_url', $imageFileName);
$dw->set('item_type', $itemType);
$dw->save();
}
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
XenForo_Link::buildAdminLink('iwd-shop-items/')
);
}
else
{
return $this->actionUpload();
}
}
}