public function deleteAction() { if ($datas = $this->getRequest()->getPost()) { try { if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while deleting the option')); } // Récupère les données de l'application pour cette option $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $app_id = $this->getApplication()->getId(); if (!$option_value->getId() or $option_value->getAppId() != $app_id) { throw new Exception($this->_('An error occurred while deleting the option')); } $html = array('success' => 1, 'value_id' => $datas['value_id'], 'path' => $option_value->getPath(null, array(), "mobile"), 'was_folder' => false, 'was_category' => false, 'was_feature' => false); // Option folder if (isset($datas['category_id'])) { $option_value->setFolderId(null)->setFolderCategoryId(null)->setFolderCategoryPosition(null)->save(); $html['was_category'] = true; $html['category'] = array('id' => $datas['category_id']); } else { // Récupère l'option $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $html['was_feature'] = true; $html['use_user_account'] = $this->getApplication()->usesUserAccount(); if ($option_value->getCode() == "folder") { $html['was_folder'] = true; } // Supprime l'option de l'application $option_value->delete(); if ($option->onlyOnce()) { $html['page'] = array('id' => $option->getId(), 'name' => $option->getName(), 'icon_url' => $option->getIconUrl(), 'category_id' => $option->getCategoryId()); } // Renvoi le nouveau code HTML // $this->getLayout()->setBaseRender('content', 'application/customization/page/list.phtml', 'admin_view_default'); } } catch (Exception $e) { $html = array('message' => $this->_('An error occurred while deleting the option'), 'message_button' => 1, 'message_loader' => 1); } $this->_sendHtml($html); } }