/** * Delete a simple widget. */ public function delete(){ $view = $this->getView(); $request = $this->getPageRequest(); if(!\Core\user()->checkAccess('p:/core/widgets/manage')){ return View::ERROR_ACCESSDENIED; } if(!$request->isPost()){ return View::ERROR_BADREQUEST; } $baseurl = $request->getParameter('baseurl'); $class = substr($baseurl, 0, strpos($baseurl, '/')) . 'widget'; if(!class_exists($class)){ \Core\set_message('Class [' . $class . '] was not found on the system, invalid widget!', 'error'); \Core\go_back(); } /** @var Widget_2_1 $obj */ $obj = new $class(); if(!($obj instanceof Widget_2_1)){ \Core\set_message('Wrong parent class for [' . $class . '], it does not appear to be a Widget_2_1 instance, invalid widget!', 'error'); \Core\go_back(); } if(!$obj->is_simple){ \Core\set_message('Widget [' . $class . '] does not appear to be a simple widget. Only simple widgets can be created via this page.', 'error'); \Core\go_back(); } $model = new WidgetModel($baseurl); $model->delete(); \Core\set_message('Deleted widget ' . $model->get('title') . ' successfully!', 'success'); \Core\go_back(); }
/** * Delete a simple widget. */ public function widget_delete(){ $view = $this->getView(); $request = $this->getPageRequest(); if(!\Core\user()->checkAccess('p:/core/widgets/manage')){ return View::ERROR_ACCESSDENIED; } if(!$request->isPost()){ return View::ERROR_BADREQUEST; } $baseurl = $request->getParameter('baseurl'); $class = substr($baseurl, 0, strpos($baseurl, '/')) . 'widget'; if(!class_exists($class)){ \Core\set_message('t:MESSAGE_ERROR_CLASS_S_NOT_AVAILABLE', $class); \Core\go_back(); } /** @var Widget_2_1 $obj */ $obj = new $class(); if(!($obj instanceof Widget_2_1)){ \Core\set_message('t:MESSAGE_ERROR_CLASS_S_NOT_VALID_WIDGET', $class); \Core\go_back(); } if(!$obj->is_simple){ \Core\set_message('t:MESSAGE_ERROR_CLASS_S_NOT_SIMPLE_WIDGET', $class); \Core\go_back(); } $model = new WidgetModel($baseurl); $model->delete(); \Core\set_message('t:MESSAGE_SUCCESS_DELETED_WIDGET_S', $baseurl); \Core\go_back(); }
public function delete() { $view = $this->getView(); $request = $this->getPageRequest(); if (!\Core\user()->checkAccess('p:/gallery/manage_all')) { return View::ERROR_ACCESSDENIED; } if ($request->getParameter(0)) { $model = new WidgetModel('/gallery/view/' . $request->getParameter(0)); } else { $model = new WidgetModel(); } if (!$request->isPost()) { return View::ERROR_BADREQUEST; } if (!$model->exists()) { return View::ERROR_NOTFOUND; } $model->delete(); \Core\go_back(); }