liquid_feedback_frontend

diff app/main/index/register.lua @ 286:c587d8762e62

Registration process updated for Core 2.0, lockable member fields, notification settings
author bsw
date Sat Feb 25 11:51:37 2012 +0100 (2012-02-25)
parents 26c8177ef348
children 714944bda6a0
line diff
     1.1 --- a/app/main/index/register.lua	Fri Feb 17 15:16:02 2012 +0100
     1.2 +++ b/app/main/index/register.lua	Sat Feb 25 11:51:37 2012 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4  slot.put_into("title", _"Registration")
     1.5  
     1.6 -
     1.7 +local step = param.get("step", atom.integer)
     1.8  local code = param.get("code")
     1.9  local notify_email = param.get("notify_email")
    1.10  local name = param.get("name")
    1.11 @@ -20,191 +20,176 @@
    1.12    content = function()
    1.13  
    1.14      if not code then
    1.15 -      slot.put_into("title", _"Step 1/5: Invite code")
    1.16 +      slot.put_into("title", _"Step 1/3: Invite code")
    1.17 +      ui.field.hidden{ name = "step", value = 1 }
    1.18        ui.tag{
    1.19          tag = "p",
    1.20          content = _"Please enter the invite code you've received."
    1.21        }
    1.22        ui.field.text{
    1.23 -        label     = _'Invite code',
    1.24 -        name = 'code',
    1.25 +        label = _'Invite code',
    1.26 +        name  = 'code',
    1.27          value = param.get("invite")
    1.28        }
    1.29  
    1.30 -    elseif not notify_email then
    1.31 -      slot.put_into("title", _"Step 2/5: Email address")
    1.32 -      slot.select("actions", function()
    1.33 -        ui.link{
    1.34 -          content = function()
    1.35 -              ui.image{ static = "icons/16/resultset_previous.png" }
    1.36 -              slot.put(_"One step back")
    1.37 -          end,
    1.38 -          module = "index",
    1.39 -          view = "register",
    1.40 -          params = {
    1.41 -          }
    1.42 -        }
    1.43 -      end)
    1.44 -      ui.tag{
    1.45 -        tag = "p",
    1.46 -        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."
    1.47 -      }
    1.48 -      ui.field.text{
    1.49 -        label     = _'Email address',
    1.50 -        name      = 'notify_email',
    1.51 -        value     = param.get("notify_email")
    1.52 -      }
    1.53 -
    1.54 -    elseif not name then
    1.55 -      slot.put_into("title", _"Step 3/5: Username")
    1.56 -      slot.select("actions", function()
    1.57 -        ui.link{
    1.58 -          content = function()
    1.59 -              ui.image{ static = "icons/16/resultset_previous.png" }
    1.60 -              slot.put(_"One step back")
    1.61 -          end,
    1.62 -          module = "index",
    1.63 -          view = "register",
    1.64 -          params = {
    1.65 -            code = code
    1.66 -          }
    1.67 -        }
    1.68 -      end)
    1.69 -      ui.tag{
    1.70 -        tag = "p",
    1.71 -        content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
    1.72 -      }
    1.73 -      ui.field.text{
    1.74 -        label     = _'Name',
    1.75 -        name      = 'name',
    1.76 -        value     = param.get("name")
    1.77 -      }
    1.78 -
    1.79 -    elseif not login then
    1.80 -      slot.put_into("title", _"Step 4/5: Login name")
    1.81 -      slot.select("actions", function()
    1.82 -        ui.link{
    1.83 -          content = function()
    1.84 -              ui.image{ static = "icons/16/resultset_previous.png" }
    1.85 -              slot.put(_"One step back")
    1.86 -          end,
    1.87 -          module = "index",
    1.88 -          view = "register",
    1.89 -          params = {
    1.90 -            code = code,
    1.91 -            notify_email = notify_email
    1.92 -          }
    1.93 -        }
    1.94 -      end)
    1.95 -      ui.tag{
    1.96 -        tag = "p",
    1.97 -        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."
    1.98 -      }
    1.99 -      ui.field.text{
   1.100 -        label     = _'Login name',
   1.101 -        name      = 'login',
   1.102 -        value     = param.get("login")
   1.103 -      }
   1.104 -
   1.105      else
   1.106 -      ui.field.hidden{ name = "step", value = "5" }
   1.107 -      slot.put_into("title", _"Step 5/5: Terms of use and password")
   1.108 -      slot.select("actions", function()
   1.109 -        ui.link{
   1.110 -          content = function()
   1.111 -              ui.image{ static = "icons/16/resultset_previous.png" }
   1.112 -              slot.put(_"One step back")
   1.113 -          end,
   1.114 -          module = "index",
   1.115 -          view = "register",
   1.116 -          params = {
   1.117 -            code = code,
   1.118 -            notify_email = notify_email,
   1.119 -            name = name,
   1.120 +      local member = Member:new_selector()
   1.121 +        :add_where{ "invite_code = ?", code }
   1.122 +        :add_where{ "activated ISNULL" }
   1.123 +        :optional_object_mode()
   1.124 +        :for_update()
   1.125 +        :exec()
   1.126 +
   1.127 +      if not member.notify_email and not notify_email or not member.name and not name or not member.login and not login or step == 1 then
   1.128 +        slot.put_into("title", _"Step 2/3: Personal information")
   1.129 +        ui.field.hidden{ name = "step", value = 2 }
   1.130 +        slot.select("actions", function()
   1.131 +          ui.link{
   1.132 +            content = function()
   1.133 +                ui.image{ static = "icons/16/resultset_previous.png" }
   1.134 +                slot.put(_"One step back")
   1.135 +            end,
   1.136 +            module = "index",
   1.137 +            view = "register",
   1.138 +            params = {
   1.139 +            }
   1.140            }
   1.141 +        end)
   1.142 +
   1.143 +        ui.tag{
   1.144 +          tag = "p",
   1.145 +          content = _"This invite key is connected with the following information:"
   1.146          }
   1.147 -      end)
   1.148 -      ui.container{
   1.149 -        attr = { class = "wiki use_terms" },
   1.150 -        content = function()
   1.151 -          if config.use_terms_html then
   1.152 -            slot.put(config.use_terms_html)
   1.153 -          else
   1.154 -            slot.put(format.wiki_text(config.use_terms))
   1.155 -          end
   1.156 -        end
   1.157 -      }
   1.158 +        
   1.159 +        execute.view{ module = "member", view = "_profile", params = { member = member, include_private_data = true } }
   1.160  
   1.161 -      for i, checkbox in ipairs(config.use_terms_checkboxes) do
   1.162 -        slot.put("<br />")
   1.163 -        ui.tag{
   1.164 -          tag = "div",
   1.165 +        if not config.locked_profile_fields.notify_email then
   1.166 +          ui.tag{
   1.167 +            tag = "p",
   1.168 +            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."
   1.169 +          }
   1.170 +          ui.field.text{
   1.171 +            label     = _'Email address',
   1.172 +            name      = 'notify_email',
   1.173 +            value     = param.get("notify_email") or member.notify_email
   1.174 +          }
   1.175 +        end
   1.176 +        if not config.locked_profile_fields.name then
   1.177 +          ui.tag{
   1.178 +            tag = "p",
   1.179 +            content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
   1.180 +          }
   1.181 +          ui.field.text{
   1.182 +            label     = _'Screen name',
   1.183 +            name      = 'name',
   1.184 +            value     = param.get("name") or member.name
   1.185 +          }
   1.186 +        end
   1.187 +        if not config.locked_profile_fields.login then
   1.188 +          ui.tag{
   1.189 +            tag = "p",
   1.190 +            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."
   1.191 +          }
   1.192 +          ui.field.text{
   1.193 +            label     = _'Login name',
   1.194 +            name      = 'login',
   1.195 +            value     = param.get("login") or member.login
   1.196 +          }
   1.197 +        end
   1.198 +      else
   1.199 +
   1.200 +        ui.field.hidden{ name = "step", value = "3" }
   1.201 +        slot.put_into("title", _"Step 3/3: Terms of use and password")
   1.202 +        slot.select("actions", function()
   1.203 +          ui.link{
   1.204 +            content = function()
   1.205 +                ui.image{ static = "icons/16/resultset_previous.png" }
   1.206 +                slot.put(_"One step back")
   1.207 +            end,
   1.208 +            module = "index",
   1.209 +            view = "register",
   1.210 +            params = {
   1.211 +              code = code,
   1.212 +              notify_email = notify_email,
   1.213 +              name = name,
   1.214 +              login = login, 
   1.215 +              step = 1
   1.216 +            }
   1.217 +          }
   1.218 +        end)
   1.219 +        ui.container{
   1.220 +          attr = { class = "wiki use_terms" },
   1.221            content = function()
   1.222 -            ui.tag{
   1.223 -              tag = "input",
   1.224 -              attr = {
   1.225 -                type = "checkbox",
   1.226 -                name = "use_terms_checkbox_" .. checkbox.name,
   1.227 -                value = "1",
   1.228 -                style = "float: left;",
   1.229 -                checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
   1.230 -              }
   1.231 -            }
   1.232 -            slot.put("&nbsp;")
   1.233 -            slot.put(checkbox.html)
   1.234 +            if config.use_terms_html then
   1.235 +              slot.put(config.use_terms_html)
   1.236 +            else
   1.237 +              slot.put(format.wiki_text(config.use_terms))
   1.238 +            end
   1.239            end
   1.240          }
   1.241 -      end
   1.242  
   1.243 -      slot.put("<br />")
   1.244 +        for i, checkbox in ipairs(config.use_terms_checkboxes) do
   1.245 +          slot.put("<br />")
   1.246 +          ui.tag{
   1.247 +            tag = "div",
   1.248 +            content = function()
   1.249 +              ui.tag{
   1.250 +                tag = "input",
   1.251 +                attr = {
   1.252 +                  type = "checkbox",
   1.253 +                  name = "use_terms_checkbox_" .. checkbox.name,
   1.254 +                  value = "1",
   1.255 +                  style = "float: left;",
   1.256 +                  checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
   1.257 +                }
   1.258 +              }
   1.259 +              slot.put("&nbsp;")
   1.260 +              slot.put(checkbox.html)
   1.261 +            end
   1.262 +          }
   1.263 +        end
   1.264  
   1.265 -      ui.field.text{
   1.266 -        label     = _'Email address',
   1.267 -        value     = param.get("notify_email"),
   1.268 -        readonly = true
   1.269 -      }
   1.270 -      ui.field.text{
   1.271 -        label     = _'Name',
   1.272 -        value     = param.get("name"),
   1.273 -        readonly = true
   1.274 -      }
   1.275 -      ui.field.text{
   1.276 -        label     = _'Login name',
   1.277 -        value     = param.get("login"),
   1.278 -        readonly = true
   1.279 -      }
   1.280 +        slot.put("<br />")
   1.281  
   1.282 -      ui.tag{
   1.283 -        tag = "p",
   1.284 -        content = _"Please choose a password and enter it twice. The password is case sensitive."
   1.285 -      }
   1.286 -      ui.field.password{
   1.287 -        label     = _'Password',
   1.288 -        name      = 'password1',
   1.289 -      }
   1.290 -      ui.field.password{
   1.291 -        label     = _'Password (repeat)',
   1.292 -        name      = 'password2',
   1.293 -      }
   1.294 +        member.notify_email = notify_email or member.notify_email
   1.295 +        member.name = name or member.name
   1.296 +        member.login = login or member.login
   1.297 +        
   1.298 +        execute.view{ module = "member", view = "_profile", params = {
   1.299 +          member = member, include_private_data = true
   1.300 +        } }
   1.301 +        
   1.302 +        ui.tag{
   1.303 +          tag = "p",
   1.304 +          content = _"Please choose a password and enter it twice. The password is case sensitive."
   1.305 +        }
   1.306 +        ui.field.password{
   1.307 +          label     = _'Password',
   1.308 +          name      = 'password1',
   1.309 +        }
   1.310 +        ui.field.password{
   1.311 +          label     = _'Password (repeat)',
   1.312 +          name      = 'password2',
   1.313 +        }
   1.314  
   1.315 +      end
   1.316      end
   1.317  
   1.318 -    ui.submit{
   1.319 -      text = _'Register'
   1.320 -    }
   1.321 +        ui.submit{
   1.322 +          text = _'Register'
   1.323 +        }
   1.324  
   1.325 -    slot.put_into("title", ")")
   1.326 -    slot.select("actions", function()
   1.327 -      ui.link{
   1.328 -        content = function()
   1.329 -            ui.image{ static = "icons/16/cancel.png" }
   1.330 -            slot.put(_"Cancel registration")
   1.331 -        end,
   1.332 -        module = "index",
   1.333 -        view = "index"
   1.334 -      }
   1.335 -    end)
   1.336 -
   1.337 +        slot.put_into("title", ")")
   1.338 +        slot.select("actions", function()
   1.339 +          ui.link{
   1.340 +            content = function()
   1.341 +                ui.image{ static = "icons/16/cancel.png" }
   1.342 +                slot.put(_"Cancel registration")
   1.343 +            end,
   1.344 +            module = "index",
   1.345 +            view = "index"
   1.346 +          }
   1.347 +        end)
   1.348    end
   1.349  }
   1.350  

Impressum / About Us