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@1071:
bsw/jbe@5: ui.form{
bsw@1045: attr = { class = "section vertical" },
bsw/jbe@5: module = 'index',
bsw/jbe@5: action = 'register',
bsw/jbe@5: params = {
bsw/jbe@5: code = code,
bsw/jbe@6: notify_email = notify_email,
bsw/jbe@5: name = name,
bsw/jbe@5: login = login
bsw/jbe@5: },
bsw/jbe@5: content = function()
bsw/jbe@5:
bsw@1071: if not code and not ldap_uid then
bsw@1045: ui.field.hidden{ name = "step", value = 1 }
bsw@743: ui.title(_"Registration (step 1 of 3: Invite code)")
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Please enter the invite code you've received" }
bsw@1045: end )
bsw@1045: ui.sectionRow( function()
bsw@1045: ui.field.text{
bsw@1045: label = _'Invite code',
bsw@1045: name = 'code',
bsw@1045: value = param.get("invite")
bsw@1045: }
bsw@1045: ui.submit{
bsw@1045: text = _'proceed with registration'
bsw@1045: }
bsw@1045: slot.put(" ")
bsw@742: ui.link{
bsw@1045: content = _"cancel registration",
bsw@742: module = "index",
bsw@1071: action = "cancel_register",
bsw@1071: routing = { default = {
bsw@1071: mode = "redirect", module = "index", view = "index"
bsw@1071: } }
bsw@742: }
bsw@1045: end )
bsw/jbe@5: else
bsw@1071: local member
bsw@1071:
bsw@1071: if ldap_uid then
bsw@1071: member, err = ldap.create_member(ldap_uid, true)
bsw@1071: if err then
bsw@1071: error(err)
bsw@1071: end
bsw@1071: else
bsw@1071: member = Member:new_selector()
bsw@1071: :add_where{ "invite_code = ?", code }
bsw@1071: :add_where{ "activated ISNULL" }
bsw@1071: :optional_object_mode()
bsw@1071: :exec()
bsw@1071: end
bsw@286:
bsw@1071: if (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@740: ui.title(_"Registration (step 2 of 3: Personal information)")
bsw@286: ui.field.hidden{ name = "step", value = 2 }
bsw@1045:
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Check and enter personal data" }
bsw@1045: end )
bsw@1045: ui.sectionRow( function()
bsw@1045: ui.tag{
bsw@1045: tag = "p",
bsw@1045: content = _"This invite key is connected with the following information:"
bsw@1045: }
bsw@1045:
bsw@1045: execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
bsw@1045:
bsw@1071: if not util.is_profile_field_locked(member, "notify_email") then
bsw@1045: ui.tag{
bsw@1045: tag = "p",
bsw@1045: 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@1045: }
bsw@1045: ui.field.text{
bsw@1045: label = _'Email address',
bsw@1045: name = 'notify_email',
bsw@1045: value = param.get("notify_email") or member.notify_email
bsw@1045: }
bsw@1045: end
bsw@1071: if not util.is_profile_field_locked(member, "name") then
bsw@1045: ui.tag{
bsw@1045: tag = "p",
bsw@1045: 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@1045: }
bsw@1045: ui.field.text{
bsw@1045: label = _'Screen name',
bsw@1045: name = 'name',
bsw@1045: value = param.get("name") or member.name
bsw@1045: }
bsw@1045: end
bsw@1071: if not util.is_profile_field_locked(member, "login") then
bsw@1045: ui.tag{
bsw@1045: tag = "p",
bsw@1045: 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@1045: }
bsw@1045: ui.field.text{
bsw@1045: label = _'Login name',
bsw@1045: name = 'login',
bsw@1045: value = param.get("login") or member.login
bsw@1045: }
bsw@1045: end
bsw@1045: ui.submit{
bsw@1045: text = _'proceed with registration'
bsw@1045: }
bsw@1045: slot.put(" ")
bsw@286: ui.link{
bsw@1045: content = _"one step back",
bsw@745: module = "index",
bsw@745: view = "register",
bsw@745: params = {
bsw@750: invite = code
bsw@745: }
bsw@745: }
bsw@1045: slot.put(" ")
bsw@745: ui.link{
bsw@1045: content = _"cancel registration",
bsw@742: module = "index",
bsw@1071: action = "cancel_register",
bsw@1071: routing = { default = {
bsw@1071: mode = "redirect", module = "index", view = "index"
bsw@1071: } }
bsw@742: }
bsw@1045: end )
bsw@286: else
bsw@286:
bsw@286: ui.field.hidden{ name = "step", value = "3" }
bsw@740: ui.title(_"Registration (step 3 of 3: Terms of use and password)")
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Read and accept the terms and choose a password" }
bsw@1045: end )
bsw@1045: ui.sectionRow( function()
bsw@1045: ui.container{
bsw@1045: attr = { class = "wiki use_terms" },
bsw@286: content = function()
bsw@1045: slot.put(config.use_terms)
bsw@1045: end
bsw@1045: }
bsw@1045:
bsw@1045: member.notify_email = notify_email or member.notify_email
bsw@1045: member.name = name or member.name
bsw@1045: member.login = login or member.login
bsw@1045:
bsw@1045: execute.view{ module = "member", view = "_profile", params = {
bsw@1045: member = member, include_private_data = true
bsw@1045: } }
bsw@1045:
bsw@1045: for i, checkbox in ipairs(config.use_terms_checkboxes) do
bsw@1045: slot.put("
")
bsw@1045: ui.tag{
bsw@1045: tag = "div",
bsw@1045: content = function()
bsw@1045: ui.tag{
bsw@1045: tag = "input",
bsw@1045: attr = {
bsw@1045: type = "checkbox",
bsw@1045: id = "use_terms_checkbox_" .. checkbox.name,
bsw@1045: name = "use_terms_checkbox_" .. checkbox.name,
bsw@1045: value = "1",
bsw@1045: style = "float: left;",
bsw@1045: checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
bsw@1045: }
bsw@1045: }
bsw@1045: slot.put(" ")
bsw@1045: ui.tag{
bsw@1045: tag = "label",
bsw@1045: attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
bsw@1045: content = function() slot.put(checkbox.html) end
bsw@1045: }
bsw@1045: end
bsw@1045: }
bsw@1045: end
bsw@1045:
bsw@1045: slot.put("
")
bsw@1045:
bsw@1071: if not member.authority == "ldap" then
bsw@1071: ui.tag{
bsw@1071: tag = "p",
bsw@1071: content = _"Please choose a password and enter it twice. The password is case sensitive."
bsw@1071: }
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@1071: ui.field.password{
bsw@1071: label = _'Password',
bsw@1071: name = 'password1',
bsw@1071: }
bsw@1071: ui.field.password{
bsw@1071: label = _'Password (repeat)',
bsw@1071: name = 'password2',
bsw@1071: }
bsw@1071: end
bsw@1071:
bsw@1045: ui.submit{
bsw@1045: text = _'activate account'
bsw@1045: }
bsw@1045: slot.put(" ")
bsw@1045: ui.link{
bsw@1045: content = _"one step back",
bsw@286: module = "index",
bsw@286: view = "register",
bsw@286: params = {
bsw@286: code = code,
bsw@286: notify_email = notify_email,
bsw@286: name = name,
bsw@286: login = login,
bsw@286: step = 1
bsw@286: }
bsw@286: }
bsw@1045: slot.put(" ")
bsw@742: ui.link{
bsw@1045: content = _"cancel registration",
bsw@742: module = "index",
bsw@1071: action = "cancel_register",
bsw@1071: routing = { default = {
bsw@1071: mode = "redirect", module = "index", view = "index"
bsw@1071: } }
bsw@742: }
bsw@1045: end )
bsw@286: end
bsw/jbe@5: end
bsw/jbe@5: end
bsw/jbe@5: }
bsw/jbe@5:
bsw/jbe@5: