public function process() { if (!parent::process()) { $this->redirectNoSession(); } $category = new \model\category($this->getDbconnection()); if (!is_null($this->getRequestVar('submupload'))) { $newFile = new \model\file(); $icon = $newFile->uploadFile(); $category->setIconPath($icon); } if (!is_null($this->getRequestVar('category'))) { $data = $this->getRequestVar('category'); foreach ($data as $key => $value) { $data[$key] = $this->filterRequest($value, array(1, 4, 7)); } $category->setName($data['name']); $category->setIconPath($data['iconPath']); $category->setIsPrivate($data['isPrivate']); if ($category->save()) { $this->redirect('category/list', array('categoryadded=yes')); } else { \messages::registerError(\language::returnLanguageConstant('SAVE_FAILED_CATEGORY')); } } else { $category->setIsPrivate(0); } $view = new \model\view_acp('category_editor'); $view->assign('category', $category); $view->assign('editormode', 0); $view->assign('headlinetext', \language::returnLanguageConstant('HL_CATEGORIES_ADD')); $view->render(); }
public function process() { if (!parent::process()) { $this->redirectNoSession(); } $categoryId = $this->getRequestVar('categoryid', array(1, 4, 7)); if (is_null($categoryId)) { $this->redirect('category/list'); } $category = new \model\category($this->getDbconnection(), $categoryId); if (!is_null($this->getRequestVar('category'))) { $data = $this->getRequestVar('category'); foreach ($data as $key => $value) { $data[$key] = $this->filterRequest($value, array(1, 4, 7)); } $category->setName($data['name']); $category->setIconPath($data['iconPath']); $category->setIsPrivate($data['isPrivate']); if ($category->update()) { $this->redirect('category/list', array('categoryedited=yes')); } else { \messages::registerError(\language::returnLanguageConstant('SAVE_FAILED_CATEGORY')); } } $view = new \model\view_acp('category_editor'); $view->assign('category', $category); $view->assign('editormode', 1); $view->assign('systemmode', $this->getSysconfig()->getSystemMode()); $view->assign('headlinetext', \language::returnLanguageConstant('HL_CATEGORIES_EDIT')); $view->assign('dtMask', $this->getSysconfig()->getDateTimeMask()); $view->render(); }
/** * Ließt Daten ein * @return void */ private function loadData() { $where = $this->showPrivate ? 'isPrivate = 0 OR isPrivate = 1' : 'isPrivate = 0'; $categories = $this->dbconnection->select($this->categoryTab, 'id, name, iconPath, isPrivate', $where); if ($categories === false) { return; } foreach ($categories as $categoryData) { $category = new \model\category($this->dbconnection); $category->setId($categoryData['id']); $category->setName($categoryData['name']); $category->setIconPath($categoryData['iconPath']); $category->setIsPrivate($categoryData['isPrivate']); $this->categories[$categoryData['id']] = $category; } }