Weitere Einstellung "Sichtbar" für Kategorien (Ticket #1634). Dafür wird eine weitere Spalte in cat_categories benötigt. Upgrade-Skript enthalten.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2172 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-06-05 15:07:46 +00:00
parent 7125d102df
commit 4edddb7faa
12 changed files with 172 additions and 85 deletions

View File

@ -1120,3 +1120,5 @@ cms.ui.contentcenter.action=Action
cms.ui.set_home_folder=Set as home folder cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected cms.ui.no_home_folder_selected=No home folder selected
cms.ui.cateogry.is_visible=Visible?
cms.ui.category.is_visible=Visible?

View File

@ -1112,3 +1112,5 @@ cms.ui.contentcenter.action=Aktion
cms.ui.set_home_folder=Als Start-Ordner festlegen cms.ui.set_home_folder=Als Start-Ordner festlegen
cms.ui.go_to_home_folder=Zum Start-Ordner cms.ui.go_to_home_folder=Zum Start-Ordner
cms.ui.no_home_folder_selected=Kein Start-Ordner festgelegt cms.ui.no_home_folder_selected=Kein Start-Ordner festgelegt
cms.ui.cateogry.is_visible=Sichtbar?
cms.ui.category.is_visible=Sichtbar?

View File

@ -59,3 +59,5 @@ cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected cms.ui.no_home_folder_selected=No home folder selected
cms.ui.contentcenter.action=Action cms.ui.contentcenter.action=Action
cms.ui.cateogry.is_visible=
cms.ui.category.is_visible=

View File

@ -590,3 +590,5 @@ cms.ui.contentcenter.action=
cms.ui.set_home_folder=Set as home folder cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder= cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=No home folder selected cms.ui.no_home_folder_selected=No home folder selected
cms.ui.cateogry.is_visible=
cms.ui.category.is_visible=

View File

@ -38,7 +38,6 @@ import com.arsdigita.xml.Element;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* A form which creates a new category. Extends the edit form for * A form which creates a new category. Extends the edit form for
* convenience. * convenience.
@ -49,25 +48,23 @@ import org.apache.log4j.Logger;
* @version $Id: BaseCategoryForm.java 1951 2009-06-30 04:35:04Z terry $ * @version $Id: BaseCategoryForm.java 1951 2009-06-30 04:35:04Z terry $
*/ */
class BaseCategoryForm extends BaseForm { class BaseCategoryForm extends BaseForm {
private static final Logger s_log = Logger.getLogger
(BaseCategoryForm.class);
private static final Logger s_log = Logger.getLogger(BaseCategoryForm.class);
final CategoryRequestLocal m_parent; final CategoryRequestLocal m_parent;
final TextField m_name; final TextField m_name;
final TextArea m_description; final TextArea m_description;
final TextField m_url; final TextField m_url;
final RadioGroup m_isAbstract; final RadioGroup m_isAbstract;
final RadioGroup m_isVisible;
final RadioGroup m_isEnabled; final RadioGroup m_isEnabled;
private Label m_script = new Label( private Label m_script = new Label(
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", "<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>",
false); false);
private final static String NAME = "name";
private final static String NAME = "name";
private final static String DESCRIPTION = "description"; private final static String DESCRIPTION = "description";
private final static String URL = "url"; private final static String URL = "url";
private final static String IS_ABSTRACT = "isAbstract"; private final static String IS_ABSTRACT = "isAbstract";
private final static String IS_VISIBLE = "isVisible";
private final static String IS_ENABLED = "isEnabled"; private final static String IS_ENABLED = "isEnabled";
/** /**
@ -86,27 +83,30 @@ class BaseCategoryForm extends BaseForm {
m_name.setSize(30); m_name.setSize(30);
m_name.setMaxLength(200); m_name.setMaxLength(200);
m_name.addValidationListener(new NotNullValidationListener()); m_name.addValidationListener(new NotNullValidationListener());
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + " defaulting = true; this.form." + URL
" defaulting = true; this.form." + URL + + ".value = urlize(this.value); }");
".value = urlize(this.value); }"); m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
m_name.setOnKeyUp("if (defaulting) { this.form." + URL +
".value = urlize(this.value) }");
// is abstract? // is abstract?
m_isAbstract = new RadioGroup(IS_ABSTRACT); m_isAbstract = new RadioGroup(IS_ABSTRACT);
m_isAbstract.addOption(new Option("no", new Label(gz("cms.ui.no")))); m_isAbstract.addOption(new Option("no", new Label(gz("cms.ui.no"))));
m_isAbstract.addOption(new Option("yes", new Label(gz("cms.ui.yes")))); m_isAbstract.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_not_abstract"),m_isAbstract); addField(gz("cms.ui.category.is_not_abstract"), m_isAbstract);
// is visible
m_isVisible = new RadioGroup(IS_VISIBLE);
m_isVisible.addOption(new Option("no", new Label(gz("cms.ui.no"))));
m_isVisible.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_visible"), m_isVisible);
// is enabled? // is enabled?
m_isEnabled = new RadioGroup(IS_ENABLED); m_isEnabled = new RadioGroup(IS_ENABLED);
m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no")))); m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no"))));
m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes")))); m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_enabled"),m_isEnabled); addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
m_description = new TextArea m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
(new TrimmedStringParameter(DESCRIPTION));
addField(gz("cms.ui.description"), m_description); addField(gz("cms.ui.description"), m_description);
m_description.setWrap(TextArea.SOFT); m_description.setWrap(TextArea.SOFT);
@ -130,11 +130,9 @@ class BaseCategoryForm extends BaseForm {
m_url.setMaxLength(200); m_url.setMaxLength(200);
m_url.addValidationListener(new NotNullValidationListener()); m_url.addValidationListener(new NotNullValidationListener());
m_url.setOnFocus("defaulting = false"); m_url.setOnFocus("defaulting = false");
m_url.setOnBlur("if (this.value == '') " + m_url.setOnBlur("if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + NAME
"{ defaulting = true; this.value = urlize(this.form." + NAME + + ".value) } " + "else { this.value = urlize(this.value); }");
".value) } " + addField(gz("cms.ui.category.url"), m_url);
"else { this.value = urlize(this.value); }");
addField(gz("cms.ui.category.url"),m_url);
addAction(new Finish()); addAction(new Finish());
addAction(new Cancel()); addAction(new Cancel());
@ -146,6 +144,7 @@ class BaseCategoryForm extends BaseForm {
} }
class NameUniqueListener implements ParameterListener { class NameUniqueListener implements ParameterListener {
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
private final Widget m_widget; private final Widget m_widget;
private final int m_type; private final int m_type;
@ -153,8 +152,9 @@ class BaseCategoryForm extends BaseForm {
public final static int URL_FIELD = 2; public final static int URL_FIELD = 2;
NameUniqueListener(final CategoryRequestLocal category) { NameUniqueListener(final CategoryRequestLocal category) {
this(category,m_name,NAME_FIELD); this(category, m_name, NAME_FIELD);
} }
NameUniqueListener(final CategoryRequestLocal category, NameUniqueListener(final CategoryRequestLocal category,
Widget widget, int type) { Widget widget, int type) {
m_category = category; m_category = category;
@ -174,14 +174,14 @@ class BaseCategoryForm extends BaseForm {
while (children.next()) { while (children.next()) {
final Category child = children.getCategory(); final Category child = children.getCategory();
String compField = String compField =
(m_type == URL_FIELD) ? child.getURL() : child.getName(); (m_type == URL_FIELD) ? child.getURL() : child.getName();
if (compField.equalsIgnoreCase(title) if (compField.equalsIgnoreCase(title)
&& (m_category == null && (m_category == null
|| !m_category.getCategory(state).equals(child))) { || !m_category.getCategory(state).equals(child))) {
throw new FormProcessException throw new FormProcessException(lz("cms.ui.category.name_not_unique"));
(lz("cms.ui.category.name_not_unique"));
} }
} }
} }
} }
} }

View File

@ -35,9 +35,9 @@ import org.apache.log4j.Logger;
*/ */
final class CategoryEditForm extends BaseCategoryForm { final class CategoryEditForm extends BaseCategoryForm {
private static final Logger s_log = Logger.getLogger private static final Logger s_log = Logger.getLogger(CategoryEditForm.class);
(CategoryEditForm.class); private static final String NO = "no";
private static final String YES = "yes";
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
public CategoryEditForm(final CategoryRequestLocal parent, public CategoryEditForm(final CategoryRequestLocal parent,
@ -54,8 +54,10 @@ final class CategoryEditForm extends BaseCategoryForm {
} }
private class InitListener implements FormInitListener { private class InitListener implements FormInitListener {
@Override
public final void init(final FormSectionEvent e) public final void init(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final Category category = m_category.getCategory(state); final Category category = m_category.getCategory(state);
@ -70,22 +72,32 @@ final class CategoryEditForm extends BaseCategoryForm {
// items in this category. If the user says "yes" then the // items in this category. If the user says "yes" then the
// category is not abstract // category is not abstract
if (category.isAbstract()) { if (category.isAbstract()) {
m_isAbstract.setValue(state, "no"); m_isAbstract.setValue(state, NO);
} else { } else {
m_isAbstract.setValue(state, "yes"); m_isAbstract.setValue(state, YES);
} }
if (category.isEnabled("")) { if (category.isVisible()) {
m_isEnabled.setValue(state, "yes"); m_isVisible.setValue(state, YES);
} else { } else {
m_isEnabled.setValue(state, "no"); m_isVisible.setValue(state, NO);
}
if (category.isEnabled("")) {
m_isEnabled.setValue(state, YES);
} else {
m_isEnabled.setValue(state, NO);
} }
} }
} }
private class ProcessListener implements FormProcessListener { private class ProcessListener implements FormProcessListener {
@Override
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final Category category = m_category.getCategory(state); final Category category = m_category.getCategory(state);
@ -93,20 +105,28 @@ final class CategoryEditForm extends BaseCategoryForm {
category.setName((String) m_name.getValue(state)); category.setName((String) m_name.getValue(state));
category.setDescription((String) m_description.getValue(state)); category.setDescription((String) m_description.getValue(state));
category.setURL((String) m_url.getValue(state)); category.setURL((String) m_url.getValue(state));
String isAbstract = (String)m_isAbstract.getValue(state);
final String isAbstract = (String) m_isAbstract.getValue(state);
// this seems anti-intuitive but the question is "can you place // this seems anti-intuitive but the question is "can you place
// items in this category. If the user says "yes" then the // items in this category. If the user says "yes" then the
// category is not abstract // category is not abstract
if ("yes".equals(isAbstract)) { if (YES.equals(isAbstract)) {
category.setAbstract(false); category.setAbstract(false);
} else if ("no".equals(isAbstract)) { } else if (NO.equals(isAbstract)) {
category.setAbstract(true); category.setAbstract(true);
} }
String isEnabled = (String)m_isEnabled.getValue(state); final String isVisible = (String) m_isVisible.getValue(state);
if ("yes".equals(isEnabled)) { if (YES.equals(isVisible)) {
category.setVisible(true);
} else {
category.setVisible(false);
}
final String isEnabled = (String) m_isEnabled.getValue(state);
if (YES.equals(isEnabled)) {
category.setEnabled(true); category.setEnabled(true);
} else if ("no".equals(isEnabled)) { } else if (NO.equals(isEnabled)) {
category.setEnabled(false); category.setEnabled(false);
} }
@ -115,5 +135,6 @@ final class CategoryEditForm extends BaseCategoryForm {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
} }
} }
} }

View File

@ -86,10 +86,10 @@ class CategoryItemPane extends BaseItemPane {
private final SimpleContainer m_detailPane; private final SimpleContainer m_detailPane;
public CategoryItemPane(final SingleSelectionModel model, public CategoryItemPane(final SingleSelectionModel model,
final CategoryRequestLocal category, final CategoryRequestLocal category,
final ActionLink addLink, final ActionLink addLink,
final ActionLink editLink, final ActionLink editLink,
final ActionLink deleteLink) { final ActionLink deleteLink) {
m_model = model; m_model = model;
m_category = category; m_category = category;
@ -106,12 +106,14 @@ class CategoryItemPane extends BaseItemPane {
if (!super.isVisible(state)) { if (!super.isVisible(state)) {
return false; return false;
} }
CategorizedCollection items = m_category.getCategory(state).getObjects(ContentItem.BASE_DATA_OBJECT_TYPE); CategorizedCollection items = m_category.getCategory(state).
getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE); items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
boolean canOrder = items.size() > 1; boolean canOrder = items.size() > 1;
items.close(); items.close();
return canOrder; return canOrder;
} }
}; };
@ -133,7 +135,7 @@ class CategoryItemPane extends BaseItemPane {
// Summary // Summary
m_detailPane.add(new SummarySection(editLink, deleteLink, indexLink, m_detailPane.add(new SummarySection(editLink, deleteLink, indexLink,
viewIndexLink, editIndexLink, orderItemsLink)); viewIndexLink, editIndexLink, orderItemsLink));
// Quasimodo: BEGIN // Quasimodo: BEGIN
// Localizations // Localizations
@ -145,20 +147,21 @@ class CategoryItemPane extends BaseItemPane {
int countSupportedLanguages = (Kernel.getConfig()).getSupportedLanguagesTokenizer() int countSupportedLanguages = (Kernel.getConfig()).getSupportedLanguagesTokenizer()
.countTokens(); .countTokens();
long countLanguages = long countLanguages =
m_category.getCategory(state) m_category.getCategory(state)
.getCategoryLocalizationCollection().size(); .getCategoryLocalizationCollection().size();
if (m_category.getCategory(state).canEdit() if (m_category.getCategory(state).canEdit()
&& countLanguages < countSupportedLanguages) { && countLanguages < countSupportedLanguages) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
}; };
CategoryLocalizationAddForm addCategoryLocalizationForm = CategoryLocalizationAddForm addCategoryLocalizationForm =
new CategoryLocalizationAddForm(m_category); new CategoryLocalizationAddForm(m_category);
m_detailPane.add(new CategoryLocalizationSection(addCategoryLocalizationLink)); m_detailPane.add(new CategoryLocalizationSection(addCategoryLocalizationLink));
add(addCategoryLocalizationForm); add(addCategoryLocalizationForm);
connect(addCategoryLocalizationLink, addCategoryLocalizationForm); connect(addCategoryLocalizationLink, addCategoryLocalizationForm);
@ -203,6 +206,7 @@ class CategoryItemPane extends BaseItemPane {
public boolean hasPermission(PageState ps) { public boolean hasPermission(PageState ps) {
return m_category.getCategory(ps).canEdit(); return m_category.getCategory(ps).canEdit();
} }
} }
private class AdminVisible extends VisibilityComponent { private class AdminVisible extends VisibilityComponent {
@ -215,14 +219,15 @@ class CategoryItemPane extends BaseItemPane {
public boolean hasPermission(PageState ps) { public boolean hasPermission(PageState ps) {
return m_category.getCategory(ps).canAdmin(); return m_category.getCategory(ps).canAdmin();
} }
} }
private class SummarySection extends Section { private class SummarySection extends Section {
SummarySection(final ActionLink editLink, SummarySection(final ActionLink editLink,
final ActionLink deleteLink, final ActionLink deleteLink,
final ActionLink indexLink, final ActionLink indexLink,
final ActionLink orderItemsLink) { final ActionLink orderItemsLink) {
setHeading(new Label(gz("cms.ui.category.details"))); setHeading(new Label(gz("cms.ui.category.details")));
final ActionGroup group = new ActionGroup(); final ActionGroup group = new ActionGroup();
@ -241,11 +246,11 @@ class CategoryItemPane extends BaseItemPane {
* the user to view and edit the content index item. * the user to view and edit the content index item.
*/ */
SummarySection(final ActionLink editLink, SummarySection(final ActionLink editLink,
final ActionLink deleteLink, final ActionLink deleteLink,
final ActionLink indexLink, final ActionLink indexLink,
final BaseLink viewIndexItem, final BaseLink viewIndexItem,
final BaseLink editIndexItem, final BaseLink editIndexItem,
final ActionLink orderItemsLink) { final ActionLink orderItemsLink) {
setHeading(new Label(gz("cms.ui.category.details"))); setHeading(new Label(gz("cms.ui.category.details")));
final ActionGroup group = new ActionGroup(); final ActionGroup group = new ActionGroup();
@ -274,14 +279,14 @@ class CategoryItemPane extends BaseItemPane {
if (item != null) { if (item != null) {
itemTitle = item.getDisplayName(); itemTitle = item.getDisplayName();
} else if (!category.ignoreParentIndexItem() } else if (!category.ignoreParentIndexItem()
&& category.getParentCategoryCount() > 0) { && category.getParentCategoryCount() > 0) {
Category ancestor = findParentCategoryWithNonInheritedIndexItem(category); Category ancestor = findParentCategoryWithNonInheritedIndexItem(category);
if (ancestor != null) { if (ancestor != null) {
if (ancestor.getIndexObject() != null) { if (ancestor.getIndexObject() != null) {
itemTitle = ancestor.getIndexObject().getDisplayName(); itemTitle = ancestor.getIndexObject().getDisplayName();
} }
itemTitle += " (Inherited from " itemTitle += " (Inherited from "
+ ancestor.getDisplayName() + ")"; + ancestor.getDisplayName() + ")";
} else { } else {
// The complete hierarchy is set to inherit. // The complete hierarchy is set to inherit.
// Just leave the itemTitle as None. // Just leave the itemTitle as None.
@ -289,24 +294,29 @@ class CategoryItemPane extends BaseItemPane {
} }
props.add(new Property(gz("cms.ui.name"), props.add(new Property(gz("cms.ui.name"),
category.getName(""))); category.getName("")));
props.add(new Property(gz("cms.ui.description"), props.add(new Property(gz("cms.ui.description"),
category.getDescription(""))); category.getDescription("")));
props.add(new Property(gz("cms.ui.category.url"), props.add(new Property(gz("cms.ui.category.url"),
category.getURL(""))); category.getURL("")));
props.add(new Property(gz("cms.ui.category.is_not_abstract"), props.add(new Property(gz("cms.ui.category.is_not_abstract"),
category.isAbstract() category.isAbstract()
? gz("cms.ui.no") ? gz("cms.ui.no")
: gz("cms.ui.yes"))); : gz("cms.ui.yes")));
props.add(new Property(gz("cms.ui.cateogry.is_visible"),
category.isVisible()
? gz("cms.ui.yes")
: gz("cms.ui.no")));
props.add(new Property(gz("cms.ui.category.is_enabled"), props.add(new Property(gz("cms.ui.category.is_enabled"),
category.isEnabled("") category.isEnabled("")
? gz("cms.ui.yes") ? gz("cms.ui.yes")
: gz("cms.ui.no"))); : gz("cms.ui.no")));
props.add(new Property(gz("cms.ui.category.index_item"), props.add(new Property(gz("cms.ui.category.index_item"),
itemTitle)); itemTitle));
return props; return props;
} }
} }
} }
@ -362,6 +372,7 @@ class CategoryItemPane extends BaseItemPane {
super.register(page); super.register(page);
page.addComponentStateParam(m_editCategoryLocalizationForm, m_catLocaleParam); page.addComponentStateParam(m_editCategoryLocalizationForm, m_catLocaleParam);
} }
} }
private class SubcategorySection extends Section { private class SubcategorySection extends Section {
@ -375,6 +386,7 @@ class CategoryItemPane extends BaseItemPane {
group.setSubject(new SubcategoryList(m_category, m_model)); group.setSubject(new SubcategoryList(m_category, m_model));
group.addAction(new AdminVisible(addLink), ActionGroup.ADD); group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
} }
} }
private class LinkedCategorySection extends Section { private class LinkedCategorySection extends Section {
@ -393,6 +405,7 @@ class CategoryItemPane extends BaseItemPane {
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return !m_category.getCategory(state).isRoot(); return !m_category.getCategory(state).isRoot();
} }
} }
private class CategoryTemplateSection extends Section { private class CategoryTemplateSection extends Section {
@ -407,6 +420,7 @@ class CategoryItemPane extends BaseItemPane {
// XXX secvis // XXX secvis
//group.addAction(link); //group.addAction(link);
} }
} }
private class PermissionsSection extends Section { private class PermissionsSection extends Section {
@ -436,7 +450,8 @@ class CategoryItemPane extends BaseItemPane {
privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items"); privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items");
privMap.put("admin", "Admin"); privMap.put("admin", "Admin");
final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel(m_model)) { final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel(
m_model)) {
@Override @Override
public void showAdmin(PageState ps) { public void showAdmin(PageState ps) {
Assert.exists(m_model.getSelectedKey(ps)); Assert.exists(m_model.getSelectedKey(ps));
@ -444,6 +459,7 @@ class CategoryItemPane extends BaseItemPane {
super.showAdmin(ps); super.showAdmin(ps);
getAdminListingPanel().setVisible(ps, false); getAdminListingPanel().setVisible(ps, false);
} }
}; };
final ActionLink restoreDefault = new ActionLink(new Label(gz( final ActionLink restoreDefault = new ActionLink(new Label(gz(
@ -453,6 +469,7 @@ class CategoryItemPane extends BaseItemPane {
Category cat = m_category.getCategory(ps); Category cat = m_category.getCategory(ps);
return PermissionService.getContext(cat) == null; return PermissionService.getContext(cat) == null;
} }
}; };
final ActionLink useCustom = new ActionLink(new Label(gz( final ActionLink useCustom = new ActionLink(new Label(gz(
@ -462,6 +479,7 @@ class CategoryItemPane extends BaseItemPane {
Category cat = m_category.getCategory(ps); Category cat = m_category.getCategory(ps);
return PermissionService.getContext(cat) != null; return PermissionService.getContext(cat) != null;
} }
}; };
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
@ -489,7 +507,7 @@ class CategoryItemPane extends BaseItemPane {
// revoke all direct permissions so category will only // revoke all direct permissions so category will only
// have inherited permissions // have inherited permissions
ObjectPermissionCollection perms = ObjectPermissionCollection perms =
PermissionService.getDirectGrantedPermissions( PermissionService.getDirectGrantedPermissions(
cat.getOID()); cat.getOID());
while (perms.next()) { while (perms.next()) {
PermissionService.revokePermission( PermissionService.revokePermission(
@ -500,6 +518,7 @@ class CategoryItemPane extends BaseItemPane {
} }
permPane.reset(state); permPane.reset(state);
} }
}; };
restoreDefault.addActionListener(al); restoreDefault.addActionListener(al);
@ -516,8 +535,10 @@ class CategoryItemPane extends BaseItemPane {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
} }
}); });
} }
} }
private static class OrderItemsForm extends CMSForm { private static class OrderItemsForm extends CMSForm {
@ -532,6 +553,7 @@ class CategoryItemPane extends BaseItemPane {
add(new Submit("Done")); add(new Submit("Done"));
} }
} }
/* /*
@ -549,7 +571,7 @@ class CategoryItemPane extends BaseItemPane {
protected String prepareURL(final PageState state, String location) { protected String prepareURL(final PageState state, String location) {
ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state) ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state)
.getDirectIndexObject())) .getDirectIndexObject()))
.getPrimaryInstance(); .getPrimaryInstance();
if (indexItem == null) { if (indexItem == null) {
return ""; return "";
@ -571,6 +593,7 @@ class CategoryItemPane extends BaseItemPane {
return true; return true;
} }
} }
}; };
private class EditItemLink extends Link { private class EditItemLink extends Link {
@ -588,7 +611,7 @@ class CategoryItemPane extends BaseItemPane {
protected String prepareURL(final PageState state, String location) { protected String prepareURL(final PageState state, String location) {
boolean canEdit = false; boolean canEdit = false;
ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state) ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state)
.getDirectIndexObject())) .getDirectIndexObject()))
.getPrimaryInstance(); .getPrimaryInstance();
if (indexItem == null) { if (indexItem == null) {
return ""; return "";
@ -598,7 +621,7 @@ class CategoryItemPane extends BaseItemPane {
} else { } else {
BigDecimal draftID = indexItem.getDraftVersion().getID(); BigDecimal draftID = indexItem.getDraftVersion().getID();
return "item.jsp?item_id=" + draftID + "&set_tab=" return "item.jsp?item_id=" + draftID + "&set_tab="
+ ContentItemPage.AUTHORING_TAB; + ContentItemPage.AUTHORING_TAB;
} }
} }
@ -636,17 +659,18 @@ class CategoryItemPane extends BaseItemPane {
BigDecimal id = item.getID(); BigDecimal id = item.getID();
User user = Web.getContext().getUser(); User user = Web.getContext().getUser();
ContentItem ci = new ContentItem(new OID(ContentItem.class.getName(), ContentItem ci = new ContentItem(new OID(ContentItem.class.getName(),
Integer.parseInt(id.toString()))); Integer.parseInt(id.toString())));
Iterator permissions = PermissionService.getImpliedPrivileges( Iterator permissions = PermissionService.getImpliedPrivileges(
ci.getOID(), user.getOID()); ci.getOID(), user.getOID());
while (permissions.hasNext()) { while (permissions.hasNext()) {
PrivilegeDescriptor permission = (PrivilegeDescriptor) permissions.next(); PrivilegeDescriptor permission = (PrivilegeDescriptor) permissions.next();
if (permission.equals(PrivilegeDescriptor.ADMIN) if (permission.equals(PrivilegeDescriptor.ADMIN)
|| permission.equals(PrivilegeDescriptor.EDIT)) { || permission.equals(PrivilegeDescriptor.EDIT)) {
return true; return true;
} }
} }
return false; return false;
} }
}; };
} }

View File

@ -28,7 +28,7 @@ object type Category extends ACSObject {
String[1..1] name = cat_categories.name VARCHAR(200); String[1..1] name = cat_categories.name VARCHAR(200);
String[0..1] url = cat_categories.url VARCHAR(200); String[0..1] url = cat_categories.url VARCHAR(200);
Boolean[1..1] isEnabled = cat_categories.enabled_p CHAR(1); Boolean[1..1] isEnabled = cat_categories.enabled_p CHAR(1);
Boolean[1..1] isVisible = cat_categories.visible_p CHAR(1);
Boolean[1..1] isAbstract = cat_categories.abstract_p CHAR(1); Boolean[1..1] isAbstract = cat_categories.abstract_p CHAR(1);
String[1..1] defaultAncestors = cat_categories.default_ancestors VARCHAR(3209); String[1..1] defaultAncestors = cat_categories.default_ancestors VARCHAR(3209);
Boolean[1..1] ignoreParentIndexItem = cat_categories.ignore_parent_index_p CHAR(1); Boolean[1..1] ignoreParentIndexItem = cat_categories.ignore_parent_index_p CHAR(1);

View File

@ -0,0 +1,21 @@
--
-- Copyright (C) 2013 Jens Pelzetter. All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation; either version 2.1 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- $Id$
ALTER TABLE cat_categories ADD COLUMN visible_p CHAR(1);
UPDATE cat_categories SET visible_p = 1;

View File

@ -1,5 +1,5 @@
-- --
-- Copyright (C) 2013 Peter Boy. All Rights Reserved. -- Copyright (C) 2013 Jens Pelzetter. All Rights Reserved.
-- --
-- This library is free software; you can redistribute it and/or -- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License -- modify it under the terms of the GNU Lesser General Public License

View File

@ -25,6 +25,6 @@
begin; begin;
\i default/6.6.5-6.6.6/set_singleton.sql \i default/6.6.5-6.6.6/set_singleton.sql
\i default/6.6.5-6.6.6/add_cat_visible.sql
commit; commit;

View File

@ -173,6 +173,7 @@ public class Category extends ACSObject {
* An attribute name for the underlying data object. * An attribute name for the underlying data object.
*/ */
public static final String IS_ENABLED = "isEnabled"; public static final String IS_ENABLED = "isEnabled";
public static final String IS_VISIBLE = "isVisible";
/** /**
* An attribute name for the underlying data object. * An attribute name for the underlying data object.
*/ */
@ -213,6 +214,7 @@ public class Category extends ACSObject {
/** /**
* Returns the model name of {@link #BASE_DATA_OBJECT_TYPE}. * Returns the model name of {@link #BASE_DATA_OBJECT_TYPE}.
* *
* @return
*/ */
public static String getBaseDataObjectPackage() { public static String getBaseDataObjectPackage() {
return BASE_DATA_OBJECT_PACKAGE; return BASE_DATA_OBJECT_PACKAGE;
@ -290,6 +292,8 @@ public class Category extends ACSObject {
* storage mechanism. This method is just a wrapper for the {@link * storage mechanism. This method is just a wrapper for the {@link
* #Category(OID)} constructor. * #Category(OID)} constructor.
* *
* @param id
*
* @throws DataObjectNotFoundException * @throws DataObjectNotFoundException
*/ */
public Category(BigDecimal id) { public Category(BigDecimal id) {
@ -389,6 +393,7 @@ public class Category extends ACSObject {
setName("name me"); setName("name me");
} }
setEnabled(true); setEnabled(true);
setVisible(true);
setAbstract(false); setAbstract(false);
//by default do not ignore the parent index item //by default do not ignore the parent index item
setIgnoreParentIndexItem(false); setIgnoreParentIndexItem(false);
@ -807,6 +812,14 @@ public class Category extends ACSObject {
set(IS_ENABLED, isEnabled); set(IS_ENABLED, isEnabled);
} }
public boolean isVisible() {
return ((Boolean) get(IS_VISIBLE)).booleanValue();
}
public void setVisible(final boolean visible) {
set(IS_VISIBLE, visible);
}
/** /**
* An abstract category cannot have any child objects, but it can have child * An abstract category cannot have any child objects, but it can have child
* categories. * categories.