[system] / trunk / webwork2 / lib / WeBWorK / DB / Record / User.pm Repository:
ViewVC logotype

Annotation of /trunk/webwork2/lib/WeBWorK/DB/Record/User.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5319 - (view) (download) (as text)

1 : sh002i 783 ################################################################################
2 : sh002i 1663 # WeBWorK Online Homework Delivery System
3 : sh002i 5319 # Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4 :     # $CVSHeader: webwork2/lib/WeBWorK/DB/Record/User.pm,v 1.12 2006/10/02 15:04:27 sh002i Exp $
5 : sh002i 1663 #
6 :     # This program is free software; you can redistribute it and/or modify it under
7 :     # the terms of either: (a) the GNU General Public License as published by the
8 :     # Free Software Foundation; either version 2, or (at your option) any later
9 :     # version, or (b) the "Artistic License" which comes with this package.
10 :     #
11 :     # This program is distributed in the hope that it will be useful, but WITHOUT
12 :     # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 :     # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
14 :     # Artistic License for more details.
15 : sh002i 783 ################################################################################
16 :    
17 :     package WeBWorK::DB::Record::User;
18 :     use base WeBWorK::DB::Record;
19 :    
20 :     =head1 NAME
21 :    
22 :     WeBWorK::DB::Record::User - represent a record from the user table.
23 :    
24 :     =cut
25 :    
26 :     use strict;
27 :     use warnings;
28 :    
29 : sh002i 4522 BEGIN {
30 :     __PACKAGE__->_fields(
31 : sh002i 4541 user_id => { type=>"TINYBLOB NOT NULL", key=>1 },
32 : sh002i 4522 first_name => { type=>"TEXT" },
33 :     last_name => { type=>"TEXT" },
34 :     email_address => { type=>"TEXT" },
35 :     student_id => { type=>"TEXT" },
36 :     status => { type=>"TEXT" },
37 :     section => { type=>"TEXT" },
38 :     recitation => { type=>"TEXT" },
39 :     comment => { type=>"TEXT" },
40 :     );
41 :     }
42 : sh002i 838
43 : sh002i 3699 sub full_name {
44 :     my ($self) = @_;
45 :    
46 :     my $first = $self->first_name;
47 :     my $last = $self->last_name;
48 :    
49 :     if (defined $first and $first ne "" and defined $last and $last ne "") {
50 :     return "$first $last";
51 :     } elsif (defined $first and $first ne "") {
52 :     return $first;
53 :     } elsif (defined $last and $last ne "") {
54 :     return $last;
55 :     } else {
56 :     return "";
57 :     }
58 :     }
59 :    
60 : sh002i 3793 # phrase = 1*word ; Sequence of words
61 :     # word = atom / quoted-string
62 :     # atom = 1*<any CHAR except specials, SPACE and CTLs>
63 :     # specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted-
64 :     # / "," / ";" / ":" / "\" / <"> ; string, to use
65 :     # / "." / "[" / "]" ; within a word.
66 : sh002i 3794 # SPACE = <ASCII SP, space> ; ( 40, 32.)
67 : sh002i 3793 # CTL = <any ASCII control ; ( 0- 37, 0.- 31.)
68 :     # character and DEL> ; ( 177, 127.)
69 :     # quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or
70 :     # ; quoted chars.
71 :     # qtext = <any CHAR excepting <">, ; => may be folded
72 :     # "\" & CR, and including
73 :     # linear-white-space>
74 : sh002i 3794 # CR = <ASCII CR, carriage return> ; ( 15, 13.)
75 : sh002i 3793 # quoted-pair = "\" CHAR ; may quote any char
76 :    
77 : sh002i 3699 sub rfc822_mailbox {
78 :     my ($self) = @_;
79 :    
80 :     my $full_name = $self->full_name;
81 :     my $address = $self->email_address;
82 :    
83 :     if (defined $address and $address ne "") {
84 :     if (defined $full_name and $full_name ne "") {
85 : sh002i 3793 # see if we need to quote the phrase
86 :     # (this regex matches CTL, SPACE, and specials)
87 :     if ($full_name =~ /[\0-\037\177 ()<>@,;:\\".\[\]]/) {
88 :     $full_name =~ s/(["\\\r])/\\$1/g; # escape <">, "\", or CR
89 :     $full_name = "\"$full_name\"";
90 :     }
91 : sh002i 3699 return "$full_name <$address>";
92 :     } else {
93 :     return $address;
94 :     }
95 :     } else {
96 :     return "";
97 :     }
98 :     }
99 :    
100 : sh002i 783 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9