public function __construct($request) { parent::__construct($request); $this->templateDirectory = realpath(dirname(__FILE__) . "/../template") . "/"; $this->template = "itemEdit.html.php"; $UserModel = new User_Model(); $this->component = "menu"; $itemId = $request->get("itemId"); if (empty($itemId)) { $this->action = "insert"; } else { $this->action = "update"; } $this->aItemSelect = DKY_Item::getItems(null, true); if (empty($itemId) && !empty($_SESSION["aBlock"][$this->block_id]["itemId"])) { $itemId = $_SESSION["aBlock"][$this->block_id]["itemId"]; } if (empty($itemId) || $this->action == "insert") { $this->action = "insert"; $this->aItem = null; unset($_SESSION["aBlock"][$this->block_id]["itemId"]); } else { $_SESSION["aBlock"][$this->block_id]["itemId"] = $itemId; $this->aItem = DKY_Item::getItemById($itemId); $this->action = "update"; unset($this->aItemSelect[$itemId]); // Can't select itself as a parent. } $this->aGroups = $UserModel->getGroups(true); $this->getItemsURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "get_items"); $this->cancelURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "list_items"); }
public function action_delete_item($request) { $itemId = $request->get("itemId"); $result = DKY_Item::deleteitem($itemId); if (!empty($result)) { DKY_Output::raiseMessage("Item deleted successfully.", DKY_MSG_SUCCESS); } else { DKY_Output::raiseMessage("Item NOT deleted.", DKY_MSG_ERROR); } DKY_HTTP::redirect(DKY_HTTP::makeURL($request->aURL["path"], "menu", "list_items")); }
public function __construct($request) { parent::__construct($request); $this->templateDirectory = realpath(dirname(__FILE__) . "/../template") . "/"; $this->template = "itemList.html.php"; $pageNum = $request->get("page"); if (empty($pageNum)) { if (!empty($_SESSION["aBlock"][$this->block_id]["page"])) { $pageNum = $_SESSION["aBlock"][$this->block_id]["page"]; } else { $pageNum = 1; } } $_SESSION["aBlock"][$this->block_id]["page"] = $pageNum; $sth = DKY_Item::buildItemQuery(); $this->aPagedData = DKY_Pager::getPagedData($sth, $pageNum, 10, 3); $this->editURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "edit_item"); $this->deleteURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "delete_item"); }