bsw@1071: local ldap_uid
bsw@1071:
bsw@1071: if config.ldap.member and app.session.authority == "ldap" then
bsw@1071: ldap_uid = app.session.authority_data_uid
bsw@1071: end
bsw@1071:
bsw@1071: if config.registration_disabled and not ldap_uid then
bsw@1071: error("registration disabled")
bsw@1071: end
bsw@1071:
bsw@441: execute.view{ module = "index", view = "_lang_chooser" }
bsw@441:
bsw@286: local step = param.get("step", atom.integer)
bsw/jbe@5: local code = param.get("code")
bsw/jbe@6: local notify_email = param.get("notify_email")
bsw/jbe@5: local name = param.get("name")
bsw/jbe@5: local login = param.get("login")
bsw/jbe@5:
bsw@1073: local member
bsw/jbe@5:
bsw@1073: if ldap_uid then
bsw@1073: member, err = ldap.create_member(ldap_uid, true)
bsw@1073: if err then
bsw@1073: error(err)
bsw@1073: end
bsw@1073: elseif code then
bsw@1073: member = Member:new_selector()
bsw@1073: :add_where{ "invite_code = ?", code }
bsw@1073: :add_where{ "activated ISNULL" }
bsw@1073: :optional_object_mode()
bsw@1073: :exec()
bsw@1073: end
bsw@286:
bsw@1073:
bsw@1073:
bsw@1073: ui.section( function()
bsw@1073:
bsw@1073: if not code and not ldap_uid then
bsw@1073: ui.title(_"Registration (step 1 of 3: Invite code)")
bsw@1073: ui.sectionHead( function()
bsw@1073: ui.heading { level = 1, content = _"Invite code" }
bsw@1073: end )
bsw@1073: elseif (not member.notify_email and not notify_email)
bsw@1071: or (not member.name and not name)
bsw@1071: or (not member.login and not login and not member.authority)
bsw@1071: or step == 1 then
bsw@1073: ui.title(_"Registration (step 2 of 3: Personal information)")
bsw@1073: ui.sectionHead( function()
bsw@1073: ui.heading { level = 1, content = _"Check and enter personal data" }
bsw@1073: end )
bsw@1073: else
bsw@1073: ui.title(_"Registration (step 3 of 3: Terms of use and password)")
bsw@1073: ui.sectionHead( function()
bsw@1073: ui.heading { level = 1, content = _"Read and accept the terms and choose a password" }
bsw@1073: end )
bsw@1073: end
bsw@1045:
bsw@1073: ui.sectionRow( function()
bsw@1073: ui.form{
bsw@1073: attr = { class = "wide" },
bsw@1073: module = 'index',
bsw@1073: action = 'register',
bsw@1073: params = {
bsw@1073: code = code,
bsw@1073: notify_email = notify_email,
bsw@1073: name = name,
bsw@1073: login = login
bsw@1073: },
bsw@1073: content = function()
bsw@1073:
bsw@1073: if not code and not ldap_uid then
bsw@1073: ui.field.hidden{ name = "step", value = 1 }
bsw@1073: ui.heading { level = 2, content = _"Please enter the invite code you've received" }
bsw@1073: ui.field.text{
bsw@1073: name = 'code',
bsw@1073: value = param.get("invite")
bsw@1073: }
bsw@1045: ui.submit{
bsw@1073: text = _'proceed with registration',
bsw@1073: attr = { class = "btn btn-default" }
bsw@745: }
bsw@1045: slot.put(" ")
bsw@1073: else
bsw@1073: if (not member.notify_email and not notify_email)
bsw@1073: or (not member.name and not name)
bsw@1073: or (not member.login and not login and not member.authority)
bsw@1073: or step == 1 then
bsw@1073: ui.field.hidden{ name = "step", value = 2 }
bsw@286:
bsw@1073: ui.tag{
bsw@1073: tag = "p",
bsw@1073: content = _"This invite key is connected with the following information:"
bsw@1073: }
bsw@1073:
bsw@1073: execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
bsw@1045:
bsw@1073: if not util.is_profile_field_locked(member, "notify_email") then
bsw@1073: ui.heading { level = 2, content = _'Email address' }
bsw@1073: ui.tag{
bsw@1073: tag = "p",
bsw@1073: content = _"Please enter your email address. This address will be used for automatic notifications (if you request them) and in case you've lost your password. This address will not be published. After registration you will receive an email with a confirmation link."
bsw@1073: }
bsw@1073: ui.field.text{
bsw@1073: name = 'notify_email',
bsw@1073: value = param.get("notify_email") or member.notify_email
bsw@1073: }
bsw@1073: end
bsw@1073: if not util.is_profile_field_locked(member, "name") then
bsw@1073: ui.heading { level = 2, content = _'Screen name' }
bsw@1073: ui.tag{
bsw@1073: tag = "p",
bsw@1073: content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
bsw@1073: }
bsw@1073: ui.field.text{
bsw@1073: name = 'name',
bsw@1073: value = param.get("name") or member.name
bsw@1073: }
bsw@1073: end
bsw@1073: if not util.is_profile_field_locked(member, "login") then
bsw@1073: ui.heading { level = 2, content = _'Login name' }
bsw@1073: ui.tag{
bsw@1073: tag = "p",
bsw@1073: content = _"Please choose a login name. This name will not be shown to others and is used only by you to login into the system. The login name is case sensitive."
bsw@1073: }
bsw@1073: ui.field.text{
bsw@1073: name = 'login',
bsw@1073: value = param.get("login") or member.login
bsw@1073: }
bsw@1073: end
bsw@1073: ui.submit{
bsw@1073: text = _'proceed with registration',
bsw@1073: attr = { class = "btn btn-default" }
bsw@1073: }
bsw@1073: slot.put(" ")
bsw@1073: ui.link{
bsw@1073: content = _"one step back",
bsw@1073: module = "index",
bsw@1073: view = "register",
bsw@1073: params = {
bsw@1073: invite = code
bsw@1073: }
bsw@1073: }
bsw@1073: else
bsw@1073:
bsw@1073: ui.field.hidden{ name = "step", value = "3" }
bsw@1073: ui.container{
bsw@1073: attr = { class = "wiki use_terms" },
bsw@1045: content = function()
bsw@1073: slot.put(config.use_terms)
bsw@1045: end
bsw@1045: }
bsw@1045:
bsw@1073: for i, checkbox in ipairs(config.use_terms_checkboxes) do
bsw@1073: slot.put("
")
bsw@1073: ui.tag{
bsw@1073: tag = "div",
bsw@1073: content = function()
bsw@1073: ui.tag{
bsw@1073: tag = "input",
bsw@1073: attr = {
bsw@1073: type = "checkbox",
bsw@1073: id = "use_terms_checkbox_" .. checkbox.name,
bsw@1073: name = "use_terms_checkbox_" .. checkbox.name,
bsw@1073: value = "1",
bsw@1073: style = "float: left;",
bsw@1073: checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
bsw@1073: }
bsw@1073: }
bsw@1073: slot.put(" ")
bsw@1073: ui.tag{
bsw@1073: tag = "label",
bsw@1073: attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
bsw@1073: content = function() slot.put(checkbox.html) end
bsw@1073: }
bsw@1073: end
bsw@1073: }
bsw@1073: end
bsw@1073:
bsw@1073: slot.put("
")
bsw@1073:
bsw@1073: member.notify_email = notify_email or member.notify_email
bsw@1073: member.name = name or member.name
bsw@1073: member.login = login or member.login
bsw@1073:
bsw@1073: ui.heading { level = 2, content = _"Personal information" }
bsw@1073: execute.view{ module = "member", view = "_profile", params = {
bsw@1073: member = member, include_private_data = true
bsw@1073: } }
bsw@1071: ui.field.text{
bsw@1071: readonly = true,
bsw@1071: label = _'Login name',
bsw@1071: name = 'login',
bsw@1071: value = member.login
bsw@1071: }
bsw@1073:
bsw@1073: if not (member.authority == "ldap") then
bsw@1073: ui.heading { level = 2, content = _'Password' }
bsw@1073: ui.tag{
bsw@1073: tag = "p",
bsw@1073: content = _"Please choose a password and enter it twice. The password is case sensitive."
bsw@1073: }
bsw@1073: ui.field.password{
bsw@1073: name = 'password1',
bsw@1073: }
bsw@1073: ui.field.password{
bsw@1073: name = 'password2',
bsw@1073: }
bsw@1073: end
bsw@1073:
bsw@1073: ui.submit{
bsw@1073: text = _'activate account',
bsw@1073: attr = { class = "btn btn-default" }
bsw@1071: }
bsw@1073: slot.put(" ")
bsw@1073: ui.link{
bsw@1073: content = _"one step back",
bsw@1073: module = "index",
bsw@1073: view = "register",
bsw@1073: params = {
bsw@1073: code = code,
bsw@1073: notify_email = notify_email,
bsw@1073: name = name,
bsw@1073: login = login,
bsw@1073: step = 1
bsw@1073: }
bsw@1071: }
bsw@1071: end
bsw@1073: end
bsw@286: end
bsw@1073: }
bsw@1073:
bsw@1073: slot.put("
")
bsw/jbe@5:
bsw@1073: ui.link{
bsw@1073: content = _"cancel registration",
bsw@1073: module = "index",
bsw@1073: action = "cancel_register",
bsw@1073: routing = { default = {
bsw@1073: mode = "redirect", module = "index", view = "index"
bsw@1073: } }
bsw@1073: }
bsw@1073: end )
bsw@1073: end )
bsw/jbe@5: