1 | ##parameters=mode |
---|
2 | #$Id: getMembersDirectoryActions.py 2348 2007-10-11 10:28:55Z henrik $ |
---|
3 | """ |
---|
4 | Get the actions to provide on members directory view |
---|
5 | |
---|
6 | Return the updated actions |
---|
7 | """ |
---|
8 | try: |
---|
9 | from Products.zdb import set_trace |
---|
10 | except: |
---|
11 | def set_trace(): |
---|
12 | pass |
---|
13 | |
---|
14 | from Products.CMFCore.utils import getToolByName |
---|
15 | request = context.REQUEST |
---|
16 | qstring = request.get('QUERY_STRING','') |
---|
17 | if qstring: |
---|
18 | id = '' |
---|
19 | for par in qstring.split('&'): |
---|
20 | if par.startswith('id='): |
---|
21 | id = par[3:] |
---|
22 | else: |
---|
23 | id = request.form.get('id','') |
---|
24 | utool = getToolByName(context, 'portal_url') |
---|
25 | dtool = getToolByName(context, 'portal_directories') |
---|
26 | base_url = utool.getBaseUrl() |
---|
27 | renderActionIcon = context.portal_cpsportlets.renderActionIcon |
---|
28 | dirname = 'members' |
---|
29 | dir = getattr(dtool,'members') |
---|
30 | actions_list = (('create_action', |
---|
31 | 'new_entry', |
---|
32 | 'Create New Member', |
---|
33 | base_url+'member_create_form?dirname=members', |
---|
34 | ), |
---|
35 | ('search_action', |
---|
36 | 'search_entry', |
---|
37 | 'Search Member', |
---|
38 | base_url+'search_members_form?dirname=members', |
---|
39 | ), |
---|
40 | ('view_action', |
---|
41 | 'view_entry', |
---|
42 | 'View', |
---|
43 | base_url+'member_view?dirname=members'+'&id='+id, |
---|
44 | ), |
---|
45 | ('edit_action', |
---|
46 | 'edit_entry', |
---|
47 | 'Edit', |
---|
48 | base_url+'member_edit_form?dirname=members'+'&id='+id, |
---|
49 | ), |
---|
50 | ) |
---|
51 | ad = {} |
---|
52 | for action_id,name,desc,url in actions_list: |
---|
53 | ad[action_id] = { |
---|
54 | 'id': name, |
---|
55 | 'title': desc, |
---|
56 | 'icon_tag': renderActionIcon(action_id= name, |
---|
57 | category='object', |
---|
58 | base_url=base_url, |
---|
59 | alt= name), |
---|
60 | 'url': url, |
---|
61 | 'name': desc, |
---|
62 | 'category': 'object', |
---|
63 | } |
---|
64 | if not dtool.members.isSectionOfficer(): |
---|
65 | return [ad['view_action'], |
---|
66 | ad['edit_action'] |
---|
67 | ] |
---|
68 | |
---|
69 | if mode in ['view', 'edit']: |
---|
70 | return [ad['view_action'], |
---|
71 | ad['edit_action'], |
---|
72 | ad['create_action'], |
---|
73 | ad['search_action'] |
---|
74 | ] |
---|
75 | elif mode in ['create']: |
---|
76 | return [ad['search_action'],] |
---|
77 | return [ad['create_action'],] |
---|