/** * 削除 */ public function delete() { $request = Request::getInstance(); $blog_templates_model = Model::load('BlogTemplates'); $id = $request->get('id'); $blog_id = $this->getBlogId(); // 使用中のテンプレート判定 $blog = $this->getBlog($blog_id); $template_ids = BlogsModel::getTemplateIds($blog); if (in_array($id, $template_ids)) { $this->setErrorMessage(__('You can not delete a template in use')); $this->redirect(array('action' => 'index')); } // 削除データの取得 if (!($blog_template = $blog_templates_model->findByIdAndBlogId($id, $blog_id))) { $this->redirect(array('action' => 'index')); } if (Session::get('sig') && Session::get('sig') === $request->get('sig')) { // 削除処理 $blog_templates_model->deleteByIdAndBlogId($id, $blog_id); $this->setInfoMessage(__('I removed the template')); } $this->redirectBack(array('action' => 'index')); }