public function uploadImage($catalogId, $productId) { try { ProductModel::getInstance()->checkProductExist($catalogId, $productId); $catalog = CatalogModel::getInstance()->getById($catalogId); $product = ProductModel::getInstance()->getById($catalogId, $productId); $this->setViewVariable('catalog', $catalog); $this->setViewVariable('product', $product); if (ProductModel::getInstance()->imageExist($catalogId, $productId)) { $this->setViewVariable('currentImagePath', ProductModel::getInstance()->getImagePath($catalogId, $productId)); } $this->setViewVariable('maxImageSizeMb', ProductModel::getInstance()->getMaxImageSizeToUpload() / 1024 / 1024); $this->render(); } catch (PhException $e) { messages::addGroup('error', $e->getErrors()); $this->systemRedirect('/catalog/editProducts/' . $catalogId); } }
public function index() { messages::addGroup('info', ['Welcome' => 1]); $this->render(); }
public function destroy($userId) { if (!$this->isPostRequest()) { exit; } try { if ($userId === AuthModel::getInstance()->getLoggedInUserId()) { PhException::throwErrors(['User_DeleteCurrentUser' => 1]); } $user = UserModel::getInstance()->getById($userId); UserModel::getInstance()->delete($userId); messages::add('User_Deleted', ['login' => $user['login']], 'success'); $this->systemRedirect('/user'); } catch (PhException $e) { messages::addGroup('error', $e->getErrors()); $this->systemRedirect('/user'); } }
public function editProducts($catalogId) { try { $catalog = CatalogModel::getInstance()->checkCatalogExist($catalogId); $this->setViewVariable("catalog", $catalog); if (ProductModel::getInstance()->productTableExist($catalogId)) { $this->setViewVariable("products", ProductModel::getInstance()->get($catalogId)); } $this->render(); } catch (PhException $e) { messages::addGroup('error', $e->getErrors()); $this->redirectBack(); } }