rev |
line source |
bsw@734
|
1 -- ========================================================================
|
bsw@734
|
2 -- DO NOT CHANGE ANYTHING IN THIS FILE
|
bsw@734
|
3 -- (except when you really know what you are doing!)
|
bsw@734
|
4 -- ========================================================================
|
bsw@734
|
5
|
bsw@734
|
6
|
bsw@731
|
7 config.app_version = "2.beta12"
|
bsw@731
|
8
|
bsw@731
|
9 if not config.instance_name then
|
bsw@731
|
10 config.instance_name = request.get_config_name()
|
bsw@731
|
11 end
|
bsw@731
|
12
|
bsw@731
|
13 if
|
bsw@731
|
14 not config.app_service_provider or
|
bsw@731
|
15 not config.use_terms or
|
bsw@731
|
16 not config.use_terms_checkboxes
|
bsw@731
|
17 then
|
bsw@731
|
18 error("Missing mandatory config option")
|
bsw@731
|
19 end
|
bsw@731
|
20
|
bsw@731
|
21 if config.enabled_languages == nil then
|
bsw@731
|
22 config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu' }
|
bsw@731
|
23 end
|
bsw@731
|
24
|
bsw@731
|
25 if config.default_lang == nil then
|
bsw@731
|
26 config.default_lang = "en"
|
bsw@731
|
27 end
|
bsw@731
|
28
|
bsw@731
|
29 if config.mail_subject_prefix == nil then
|
bsw@731
|
30 config.mail_subject_prefix = "[LiquidFeedback] "
|
bsw@731
|
31 end
|
bsw@731
|
32
|
bsw@731
|
33 if config.absolute_base_url == nil then
|
bsw@731
|
34 config.absolute_base_url = request.get_relative_baseurl()
|
bsw@731
|
35 end
|
bsw@731
|
36
|
bsw@731
|
37 if config.member_image_content_type == nil then
|
bsw@731
|
38 config.member_image_content_type = "image/jpeg"
|
bsw@731
|
39 end
|
bsw@731
|
40
|
bsw@731
|
41 if config.member_image_convert_func == nil then
|
bsw@731
|
42 config.member_image_convert_func = {
|
bsw@731
|
43 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
|
bsw@731
|
44 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
|
bsw@731
|
45 }
|
bsw@731
|
46 end
|
bsw@731
|
47
|
bsw@734
|
48 if config.public_access == nil then
|
bsw@734
|
49 config.public_access = "full"
|
bsw@734
|
50 end
|
bsw@734
|
51
|
bsw@736
|
52 if config.locked_profile_fields == nil then
|
bsw@736
|
53 config.locked_profile_fields = {}
|
bsw@736
|
54 end
|
bsw@736
|
55
|
bsw@732
|
56 if not config.database then
|
bsw@732
|
57 config.database = { engine='postgresql', dbname='liquid_feedback' }
|
bsw@732
|
58 end
|
bsw@732
|
59
|
bsw@729
|
60 request.set_404_route{ module = 'index', view = '404' }
|
bsw@729
|
61
|
bsw@729
|
62 -- open and set default database handle
|
bsw@734
|
63 db = assert(mondelefant.connect(config.database))
|
bsw@729
|
64 at_exit(function()
|
bsw@729
|
65 db:close()
|
bsw@729
|
66 end)
|
bsw@729
|
67 function mondelefant.class_prototype:get_db_conn() return db end
|
bsw@729
|
68
|
bsw@729
|
69 -- enable output of SQL commands in trace system
|
bsw@729
|
70 function db:sql_tracer(command)
|
bsw@729
|
71 return function(error_info)
|
bsw@729
|
72 local error_info = error_info or {}
|
bsw@729
|
73 trace.sql{ command = command, error_position = error_info.position }
|
bsw@729
|
74 end
|
bsw@729
|
75 end
|
bsw@729
|
76
|
bsw@729
|
77 request.set_absolute_baseurl(config.absolute_base_url)
|
bsw@729
|
78
|
bsw@729
|
79
|
bsw@729
|
80 -- TODO abstraction
|
bsw@729
|
81 -- get record by id
|
bsw@729
|
82 function mondelefant.class_prototype:by_id(id)
|
bsw@729
|
83 local selector = self:new_selector()
|
bsw@729
|
84 selector:add_where{ 'id = ?', id }
|
bsw@729
|
85 selector:optional_object_mode()
|
bsw@729
|
86 return selector:exec()
|
bsw@729
|
87 end
|
bsw@729
|
88
|