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 | } |
---|
48 | |
---|
49 | confirm_text = context.translation_service('description_confirm_delete') |
---|
50 | confirm_text.encode('ISO-8859-15', 'ignore') |
---|
51 | delete_action = { |
---|
52 | 'id': 'delete_entry', |
---|
53 | 'url': base_url+'member_delete?dirname='+dirname+'&id='+id, |
---|
54 | 'onclick': 'return window.confirm(\''+ confirm_text +'\')' , |
---|
55 | 'name': 'cpsdir_label_delete_entry', |
---|
56 | 'category': 'object', |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | # only actions with category 'object' have to be changed |
---|
61 | |
---|
62 | if dir.isSearchEntriesAllowed(): |
---|
63 | actions.update({'object': [search_action]}) |
---|
64 | |
---|
65 | if dir.isCreateEntryAllowed(): |
---|
66 | actions['object'].append(create_action) |
---|
67 | |
---|
68 | if mode in ['view', 'edit']: |
---|
69 | if dir.isViewEntryAllowed(id): |
---|
70 | actions['object'].append(view_action) |
---|
71 | if dir.isEditEntryAllowed(id): |
---|
72 | actions['object'].append(edit_action) |
---|
73 | if dir.isDeleteEntryAllowed(id): |
---|
74 | actions['object'].append(delete_action) |
---|
75 | |
---|
76 | return actions |
---|