1 | ##parameters=actions, dirname, dir, mode, id='' |
---|
2 | #$Id: getDirectoryActions.py 25260 2005-07-26 00:41:23Z atchertchian $ |
---|
3 | """ |
---|
4 | Get the actions to provide on a directory view |
---|
5 | |
---|
6 | Parameters are: |
---|
7 | - the current actions |
---|
8 | - the directory id |
---|
9 | - the directory itself |
---|
10 | - the mode (create, edit, view or search) |
---|
11 | - the entry id (eventually) |
---|
12 | |
---|
13 | Return the updated actions |
---|
14 | """ |
---|
15 | |
---|
16 | from Products.CMFCore.utils import getToolByName |
---|
17 | |
---|
18 | utool = getToolByName(context, 'portal_url') |
---|
19 | base_url = utool.getBaseUrl() |
---|
20 | |
---|
21 | create_action = { |
---|
22 | 'id': 'new_entry', |
---|
23 | 'url': base_url+'member_create_form?dirname='+dirname, |
---|
24 | 'name': 'cpsdir_label_create_entry', |
---|
25 | 'category': 'object', |
---|
26 | } |
---|
27 | |
---|
28 | search_action = { |
---|
29 | 'id': 'search_entry', |
---|
30 | 'url': base_url+'search_members_form?dirname='+dirname, |
---|
31 | 'name': 'cpsdir_label_search_entry', |
---|
32 | 'category': 'object' |
---|
33 | } |
---|
34 | |
---|
35 | view_action = { |
---|
36 | 'id': 'view_entry', |
---|
37 | 'url': base_url+'member_view?dirname='+dirname+'&id='+id, |
---|
38 | 'name': 'cpsdir_label_view_entry', |
---|
39 | 'category': 'object', |
---|
40 | } |
---|
41 | |
---|
42 | edit_action = { |
---|
43 | 'id': 'edit_entry', |
---|
44 | 'url': base_url+'member_edit_form?dirname='+dirname+'&id='+id, |
---|
45 | 'name': 'cpsdir_label_edit_entry', |
---|
46 | 'category': 'object', |
---|
47 | 'available': True, |
---|
48 | 'visible': True, |
---|
49 | 'allowed': True, |
---|
50 | 'permissions': ('View',), |
---|
51 | } |
---|
52 | |
---|
53 | confirm_text = context.translation_service('description_confirm_delete') |
---|
54 | confirm_text.encode('ISO-8859-15', 'ignore') |
---|
55 | delete_action = { |
---|
56 | 'id': 'delete_entry', |
---|
57 | 'url': base_url+'member_delete?dirname='+dirname+'&id='+id, |
---|
58 | 'onclick': 'return window.confirm(\''+ confirm_text +'\')' , |
---|
59 | 'name': 'cpsdir_label_delete_entry', |
---|
60 | 'category': 'object', |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | # only actions with category 'object' have to be changed |
---|
65 | |
---|
66 | if dir.isSearchEntriesAllowed(): |
---|
67 | actions.update({'object': [search_action]}) |
---|
68 | |
---|
69 | if dir.isCreateEntryAllowed(): |
---|
70 | actions['object'].append(create_action) |
---|
71 | |
---|
72 | if mode in ['view', 'edit']: |
---|
73 | if dir.isViewEntryAllowed(id): |
---|
74 | actions['object'].append(view_action) |
---|
75 | if dir.isEditEntryAllowed(id): |
---|
76 | actions['object'].append(edit_action) |
---|
77 | if dir.isDeleteEntryAllowed(id): |
---|
78 | actions['object'].append(delete_action) |
---|
79 | |
---|
80 | return actions |
---|