| 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@855 | 6 config.app_version = "2.0.4" | 
| bsw@731 | 7 | 
| bsw@731 | 8 if config.enabled_languages == nil then | 
| bsw@843 | 9   config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu', 'it', 'nl', 'zh-TW' } | 
| bsw@731 | 10 end | 
| bsw@731 | 11 | 
| bsw@731 | 12 if config.default_lang == nil then | 
| bsw@731 | 13   config.default_lang = "en" | 
| bsw@731 | 14 end | 
| bsw@731 | 15 | 
| bsw@731 | 16 if config.mail_subject_prefix == nil then | 
| bsw@731 | 17   config.mail_subject_prefix = "[LiquidFeedback] " | 
| bsw@731 | 18 end | 
| bsw@731 | 19 | 
| bsw@731 | 20 if config.member_image_content_type == nil then | 
| bsw@731 | 21   config.member_image_content_type = "image/jpeg" | 
| bsw@731 | 22 end | 
| bsw@731 | 23 | 
| bsw@731 | 24 if config.member_image_convert_func == nil then | 
| bsw@731 | 25   config.member_image_convert_func = { | 
| bsw@731 | 26     avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail",   "48x48", "jpeg:-") end, | 
| bsw@731 | 27     photo =  function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end | 
| bsw@731 | 28   } | 
| bsw@731 | 29 end | 
| bsw@731 | 30 | 
| bsw@736 | 31 if config.locked_profile_fields == nil then | 
| bsw@736 | 32   config.locked_profile_fields = {} | 
| bsw@736 | 33 end | 
| bsw@736 | 34 | 
| bsw@732 | 35 if not config.database then | 
| bsw@732 | 36   config.database = { engine='postgresql', dbname='liquid_feedback' } | 
| bsw@732 | 37 end | 
| bsw@732 | 38 | 
| bsw@729 | 39 request.set_404_route{ module = 'index', view = '404' } | 
| bsw@729 | 40 | 
| bsw@729 | 41 -- open and set default database handle | 
| bsw@734 | 42 db = assert(mondelefant.connect(config.database)) | 
| bsw@729 | 43 at_exit(function() | 
| bsw@729 | 44   db:close() | 
| bsw@729 | 45 end) | 
| bsw@729 | 46 function mondelefant.class_prototype:get_db_conn() return db end | 
| bsw@729 | 47 | 
| bsw@729 | 48 -- enable output of SQL commands in trace system | 
| bsw@729 | 49 function db:sql_tracer(command) | 
| bsw@729 | 50   return function(error_info) | 
| bsw@729 | 51     local error_info = error_info or {} | 
| bsw@729 | 52     trace.sql{ command = command, error_position = error_info.position } | 
| bsw@729 | 53   end | 
| bsw@729 | 54 end | 
| bsw@729 | 55 | 
| bsw@729 | 56 request.set_absolute_baseurl(config.absolute_base_url) | 
| bsw@729 | 57 | 
| bsw@729 | 58 | 
| bsw@729 | 59 -- TODO abstraction | 
| bsw@729 | 60 -- get record by id | 
| bsw@729 | 61 function mondelefant.class_prototype:by_id(id) | 
| bsw@729 | 62   local selector = self:new_selector() | 
| bsw@729 | 63   selector:add_where{ 'id = ?', id } | 
| bsw@729 | 64   selector:optional_object_mode() | 
| bsw@729 | 65   return selector:exec() | 
| bsw@729 | 66 end | 
| bsw@729 | 67 |