# Module: Tglogin::Signup

# Public Class Methods

### askaddress1 (val=nil)

Asks user for their address line 1

Show source...

         # File bbs/lib/tglogin/signup.rb, line 126
    126:     def Signup::askaddress1(val=nil)
    127:       if $cfg['signup']['ask_address'] == true
    128:         complete = false
    129:         until complete == true
    130:           address1 = Tgio::question('signup_askaddress1.ftl', 40)
    131:           unless address1.is_blank? || address1.minlength?(5) == false
    132:             complete = true if address1.is_spaced_alphanumeric?
    133:           end #/if
    134:         end #/until
    135:         return address1
    136:       else
    137:         return nil
    138:       end
    139:     end

### askaddress2 (val=nil)

Asks user for their address line 2

Show source...

         # File bbs/lib/tglogin/signup.rb, line 142
    142:     def Signup::askaddress2(val=nil)
    143:       if $cfg['signup']['ask_address'] == true
    144:         complete = false
    145:         until complete == true
    146:           address2 = Tgio::question('signup_askaddress2.ftl', 40)
    147:           if address2.is_blank? || address2.is_spaced_alphanumeric?
    148:             complete = true
    149:           end #/if
    150:         end #/until
    151:         return address2
    152:       else
    153:         return nil
    154:       end
    155:     end

### askbday ()

Asks user for their bday YYYY/MM/DD

Show source...

         # File bbs/lib/tglogin/signup.rb, line 246
    246:     def Signup::askbday
    247:       if $cfg['signup']['ask_bday']    == true
    248:         Tgtemplate::display('signup_askbday.ftl')
    249:         bday = Tgio::Dates::inputdate
    250:
    251:         return bday
    252:       else
    253:         return nil
    254:       end
    255:     end

### askcity (val=nil)

Asks user for their city

Show source...

         # File bbs/lib/tglogin/signup.rb, line 158
    158:     def Signup::askcity(val=nil)
    159:       complete = false
    160:       until complete == true
    161:         city = Tgio::question('signup_askcity.ftl', 30)
    162:         unless city.is_blank? || city.minlength?(3) == false
    163:           complete = true if city.is_spaced_alpha?
    164:         end #/if
    165:       end #/until
    166:       return city.capitalize
    167:     end

### askcountry (val=nil)

Asks user for their country

Show source...

         # File bbs/lib/tglogin/signup.rb, line 198
    198:     def Signup::askcountry(val=nil)
    199:       if $cfg['signup']['ask_country'] == true
    200:         complete = false
    201:         until complete == true
    202:           country = Tgio::question('signup_askcountry.ftl', 5)
    203:           unless country.is_blank?
    204:             complete = true if country.is_alpha?
    205:           end #/if
    206:         end #/until
    207:         return country.upcase
    208:       else
    209:         return nil
    210:       end
    211:     end

### askcustom (num=1,val=nil)

Asks user a operator designated question

Show source...

         # File bbs/lib/tglogin/signup.rb, line 295
    295:     def Signup::askcustom(num=1,val=nil)
    296:       complete = false
    297:       case num
    298:         when 1
    299:           q = {'question' => $cfg['signup']['custom1']}
    300:         when 2
    301:           q = {'question' => $cfg['signup']['custom2']}
    302:         when 3
    303:           q = {'question' => $cfg['signup']['custom3']}
    304:       end
    305:       until complete == true
    306:         Tgtemplate::display('signup_askcustom.ftl', q)
    307:         custom = Tgio::Input::inputform(75)
    308:         unless custom.nil? || custom.is_blank?
    309:           complete = true
    310:         end #/if
    311:       end #/until
    312:       return custom
    313:     end

### askemail (val=nil)

Asks user for their email address

Show source...

         # File bbs/lib/tglogin/signup.rb, line 114
    114:     def Signup::askemail(val=nil)
    115:       complete = false
    116:       until complete == true
    117:         email = Tgio::question('signup_askemail.ftl', 60)
    118:         unless email.is_blank?
    119:           complete = true if email.is_email?
    120:         end #/if
    121:       end #/until
    122:       return email
    123:     end

### askfirstname (val=nil)

Asks user for their first name.

Show source...

        # File bbs/lib/tglogin/signup.rb, line 90
    90:     def Signup::askfirstname(val=nil)
    91:       complete = false
    92:       until complete == true
    93:         firstname = Tgio::question('signup_askfirstname.ftl', 25)
    94:         unless firstname.is_blank? || firstname.minlength?(3) == false
    95:           complete = true if firstname.is_alpha?
    96:         end #/if
    97:       end #/until
    98:       return firstname.capitalize
    99:     end

### askgender ()

Asks user for their gender

Show source...

         # File bbs/lib/tglogin/signup.rb, line 230
    230:     def Signup::askgender
    231:       if $cfg['signup']['ask_gender']  == true
    232:         complete = false
    233:         until complete == true
    234:           gender = Tgio::Input::inputgender('signup_askgender.ftl')
    235:           unless gender.nil?
    236:             complete = true
    237:           end #/if
    238:         end #/until
    239:         return gender
    240:       else
    241:         return nil
    242:       end
    243:     end

### asklastname (val=nil)

Asks user for their last name.

Show source...

         # File bbs/lib/tglogin/signup.rb, line 102
    102:     def Signup::asklastname(val=nil)
    103:       complete = false
    104:       until complete == true
    105:         lastname = Tgio::question('signup_asklastname.ftl', 25)
    106:         unless lastname.is_blank? || lastname.minlength?(2) == false
    107:           complete = true if lastname.is_alpha?
    108:         end #/if
    109:       end #/until
    110:       return lastname.capitalize
    111:     end

### asklogin (val=nil)

Asks user for their login name or Alias.

Show source...

        # File bbs/lib/tglogin/signup.rb, line 67
    67:     def Signup::asklogin(val=nil)
    68:       complete = false
    69:       until complete == true
    70:         login = Tgio::question('signup_asklogin.ftl', 16)
    71:         # Validate Login Name
    72:         unless login.is_blank? || login.minlength?(4) == false
    73:           if User[:login => login.upcase].nil?
    74:             complete = true if login.is_alphanumeric?
    75:           else
    76:             print "\n"
    77:             Tgtemplate::display('signup_login_taken.ftl')
    78:             print "\n\n"
    79:           end #/if
    80:         else
    81:           print "\n"
    82:           Tgtemplate::display('signup_login_invalid.ftl')
    83:           print "\n\n"
    84:         end #/unless
    85:       end #/until
    86:       return login.upcase
    87:     end

### askpassword ()

Asks user for their password.

Show source...

         # File bbs/lib/tglogin/signup.rb, line 258
    258:     def Signup::askpassword
    259:       complete = false
    260:       until complete == true
    261:         Tgtemplate::display('signup_askpassword.ftl')
    262:         password = Tgio::Input::passwordform
    263:         unless password.is_blank? || password.minlength?(6) == false
    264:           complete = true
    265:         end #/if
    266:       end #/until
    267:       return password
    268:     end

### askphone (val=nil)

Asks user for their phone

Show source...

         # File bbs/lib/tglogin/signup.rb, line 214
    214:     def Signup::askphone(val=nil)
    215:       if $cfg['signup']['ask_phone']   == true
    216:         complete = false
    217:         until complete == true
    218:           phone = Tgio::question('signup_askphone.ftl', 18)
    219:           unless phone.is_blank?
    220:             complete = true
    221:           end #/if
    222:         end #/until
    223:         return phone
    224:       else
    225:         return nil
    226:       end
    227:     end

### askpostal (val=nil)

Asks user for their postalcode

Show source...

         # File bbs/lib/tglogin/signup.rb, line 182
    182:     def Signup::askpostal(val=nil)
    183:       if $cfg['signup']['ask_postal']  == true
    184:         complete = false
    185:         until complete == true
    186:           postal = Tgio::question('signup_askpostal.ftl', 10)
    187:           unless postal.is_blank?
    188:             complete = true if postal.is_alphanumeric?
    189:           end #/if
    190:         end #/until
    191:         return postal
    192:       else
    193:         return nil
    194:       end
    195:     end

### askpwhint_answer (val=nil)

Asks user for their pw hint answer

Show source...

         # File bbs/lib/tglogin/signup.rb, line 283
    283:     def Signup::askpwhint_answer(val=nil)
    284:       complete = false
    285:       until complete == true
    286:         pwhinta = Tgio::question('signup_askpwhint_answer.ftl', 75)
    287:         unless pwhinta.nil? || pwhinta.is_blank?
    288:           complete = true
    289:         end #/if
    290:       end #/until
    291:       return pwhinta
    292:     end

### askpwhint_question (val=nil)

Asks user for their pw hint question

Show source...

         # File bbs/lib/tglogin/signup.rb, line 271
    271:     def Signup::askpwhint_question(val=nil)
    272:       complete = false
    273:       until complete == true
    274:         pwhintq = Tgio::question('signup_askpwhint_question.ftl', 75)
    275:         unless pwhintq.nil? || pwhintq.is_blank?
    276:           complete = true
    277:         end #/if
    278:       end #/until
    279:       return pwhintq
    280:     end

### askstate (val=nil)

Asks user for their state

Show source...

         # File bbs/lib/tglogin/signup.rb, line 170
    170:     def Signup::askstate(val=nil)
    171:       complete = false
    172:       until complete == true
    173:         state = Tgio::question('signup_askstate.ftl', 5)
    174:         unless state.is_blank?  || state.minlength?(2) == false
    175:           complete = true if state.is_alpha?
    176:         end #/if
    177:       end #/until
    178:       return state.upcase
    179:     end

### confirm (signupdata)

Displays a confirmation screen and allows the caller to change their account settings before creating the account

Show source...

         # File bbs/lib/tglogin/signup.rb, line 318
    318:     def Signup::confirm(signupdata)
    319:       dosave = false
    320:       #Tgtemplate::display('signup_confirmdata.ftl', signupdata)
    321:       validkeys=['A','B','C','D','E','F','G','L','P','Q','R','S','U','Y','Z','1','2','3','X']
    322:       until dosave == true
    323:         key = Tgio::Input.menuprompt('signup_confirmdata.ftl',validkeys,signupdata)
    324:         print "\n"
    325:         case key
    326:           when 'A' # Hint Answer
    327:             signupdata['pwhint_answer'] = self.askpwhint_answer
    328:           when 'B' # Birthdate
    329:             signupdata['bday'] = self.askbday
    330:           when 'C' # City
    331:             signupdata['city'] = self.askcity
    332:           when 'E' # Email
    333:             signupdata['email'] = self.askemail
    334:           when 'F' # First Name
    335:             signupdata['firstname']=self.askfirstname
    336:           when 'G' # Gender
    337:             signupdata['gender']=self.askgender
    338:           when 'L' # Last Name
    339:             signupdata['firstname']=self.asklastname
    340:           when 'P' # Password
    341:             signupdata['password']=self.askpassword
    342:           when 'Q' # Hint Question
    343:             signupdata['pwhint_question']=self.askpwhint_question
    344:           when 'S' # State
    345:             signupdata['state']=self.askstate
    346:           when 'U' # Login Alias
    347:             signupdata['login']=self.asklogin
    348:           when 'Y' # Country
    349:             signupdata['country']=self.askcountry
    350:           when 'D' # Address Line 1 & 2
    351:             signupdata['address1']=self.askaddress1
    352:             signupdata['address2']=self.askaddress2
    353:           when 'Z' # Zipcode/Postal
    354:             signupdata['postal']=self.askpostal
    355:           when '1' # Custom Question 1
    356:             signupdata['custom1']=self.askcustom(1)
    357:           when '2' # Custom Question 2
    358:             signupdata['custom2']=self.askcustom(2)
    359:           when '3' # Custom Question 3
    360:             signupdata['custom3']=self.askcustom(3)
    361:           when 'X' # Exit & Save
    362:             dosave = true
    363:             gid = Group.find(:name => $cfg['signup']['default_group'].upcase).id
    364:             User.create(
    365:               :login            => signupdata['login'],
    366:               :firstname        => signupdata['firstname'],
    367:               :lastname         => signupdata['lastname'],
    368:               :password         => User.cryptpassword(signupdata['password']),
    369:               :address1         => signupdata['address1'],
    370:               :address2         => signupdata['address2'],
    371:               :city             => signupdata['city'],
    372:               :state            => signupdata['state'],
    373:               :postal           => signupdata['postal'],
    374:               :country          => signupdata['country'],
    375:               :phone            => signupdata['phone'],
    376:               :gender           => signupdata['gender'],
    377:               :email            => signupdata['email'],
    378:               :custom1          => signupdata['custom1'],
    379:               :custom2          => signupdata['custom1'],
    380:               :custom3          => signupdata['custom1'],
    381:               :sysopnote        => nil,
    382:               :pwhint_question  => signupdata['pwhint_question'],
    383:               :pwhint_answer    => signupdata['pwhint_answer'],
    384:               :bday             => signupdata['bday'],
    385:               :pwexpires        => Time.now+90.days,
    386:               :group_id         => gid,
    387:               :timebank         => 0,
    388:               :total_files_up   => 0,
    389:               :total_files_down => 0,
    390:               :total_messages   => 0,
    391:               :login_failures   => 0,
    392:               :login_total      => 1,
    393:               :login_last       => Time.now,
    394:               :created          => Time.now
    395:             ) # /User.create
    396:           # TODO: Catch/throw for Sequel create errors
    397:           Tgtemplate::display('signup_saved.ftl')
    398:         end #/case
    399:       end #/until
    400:       # Create Account
    401:
    402:     end