private function __tryToUnlockEverything() { $current_option = new Application_Model_Option_Value(); $current_option->find($this->getValueId()); if ($current_option->getId() and $current_option->getApplication()) { $application = $current_option->getApplication(); $has_another_padlock = false; foreach ($application->getOptions() as $option) { if ($option->getCode() == $current_option->getCode() and $option->getId() != $current_option->getId() and $option->getData("is_active")) { Zend_Debug::dump($current_option->getData()); Zend_Debug::dump($option->getData()); $has_another_padlock = true; } } if (!$has_another_padlock) { $this->setValueIds(array()); $application->setRequireToBeLoggedIn(0)->save(); $this->saveValueIds($application->getId()); } } }
public function deletecategoryAction() { if ($datas = $this->getRequest()->getParams()) { try { // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $category = new Folder_Model_Category(); $category->find($datas['category_id']); $parent_id = $category->getParentId(); $category->delete(); $value_ids = array(); $option_value = new Application_Model_Option_Value(); $option_values = $option_value->findAll(array('a.app_id' => $this->getApplication()->getId()), 'position ASC'); foreach ($option_values as $option_value) { if ($option_value->getFolderId() or $option_value->getCode() == "folder") { continue; } $value_ids[] = $option_value->getId(); } $html = array('success' => 1, 'parent_id' => $parent_id, 'value_ids' => $value_ids); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
private function setIcon($icon_id, $option_value_id) { try { // Récupère l'application $application = $this->getApplication(); // Charge l'option_value $option_value = new Application_Model_Option_Value(); $option_value->find($option_value_id); // Charge l'icône $icon = new Media_Model_Library_Image(); $icon->find($icon_id); if (!$icon->getId() or $icon->getLibraryId() != $option_value->getLibraryId() && $option_value->getCode() != 'folder') { throw new Exception($this->_('An error occurred while saving. The selected icon is not valid.')); } // Tout va bien, on met à jour l'icône pour cette option_value $option_value->setIconId($icon->getId())->setIcon(null)->save(); $icon_url = $option_value->resetIconUrl()->getIconUrl(true); $colored_header_icon_url = $icon_url; if ($option_value->getImage()->getCanBeColorized()) { $header_color = $application->getDesignBlock('header')->getColor(); $colored_header_icon_url = $this->getUrl('template/block/colorize', array('id' => $option_value->getIconId(), 'color' => str_replace('#', '', $header_color))); } $return = array('colored_header_icon_url' => $colored_header_icon_url, 'icon_url' => $icon_url); return $return; } catch (Exception $e) { return false; } }