weight, plan and plandata fields in part_bill_event
[freeside.git] / httemplate / docs / man / FS / svc_acct.html
1 <HTML>
2 <HEAD>
3 <TITLE>FS::svc_acct - Object methods for svc_acct records</TITLE>
4 <LINK REV="made" HREF="mailto:perl@packages.debian.org">
5 </HEAD>
6
7 <BODY>
8
9 <A NAME="__index__"></A>
10 <!-- INDEX BEGIN -->
11
12 <UL>
13
14         <LI><A HREF="#name">NAME</A></LI>
15         <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
16         <LI><A HREF="#description">DESCRIPTION</A></LI>
17         <LI><A HREF="#methods">METHODS</A></LI>
18         <LI><A HREF="#version">VERSION</A></LI>
19         <LI><A HREF="#bugs">BUGS</A></LI>
20         <LI><A HREF="#see also">SEE ALSO</A></LI>
21 </UL>
22 <!-- INDEX END -->
23
24 <HR>
25 <P>
26 <H1><A NAME="name">NAME</A></H1>
27 <P>FS::svc_acct - Object methods for svc_acct records</P>
28 <P>
29 <HR>
30 <H1><A NAME="synopsis">SYNOPSIS</A></H1>
31 <PRE>
32   use FS::svc_acct;</PRE>
33 <PRE>
34   $record = new FS::svc_acct \%hash;
35   $record = new FS::svc_acct { 'column' =&gt; 'value' };</PRE>
36 <PRE>
37   $error = $record-&gt;insert;</PRE>
38 <PRE>
39   $error = $new_record-&gt;replace($old_record);</PRE>
40 <PRE>
41   $error = $record-&gt;delete;</PRE>
42 <PRE>
43   $error = $record-&gt;check;</PRE>
44 <PRE>
45   $error = $record-&gt;suspend;</PRE>
46 <PRE>
47   $error = $record-&gt;unsuspend;</PRE>
48 <PRE>
49   $error = $record-&gt;cancel;</PRE>
50 <PRE>
51   %hash = $record-&gt;radius;</PRE>
52 <PRE>
53   %hash = $record-&gt;radius_reply;</PRE>
54 <PRE>
55   %hash = $record-&gt;radius_check;</PRE>
56 <PRE>
57   $domain = $record-&gt;domain;</PRE>
58 <PRE>
59   $svc_domain = $record-&gt;svc_domain;</PRE>
60 <PRE>
61   $email = $record-&gt;email;</PRE>
62 <PRE>
63   $seconds_since = $record-&gt;seconds_since($timestamp);</PRE>
64 <P>
65 <HR>
66 <H1><A NAME="description">DESCRIPTION</A></H1>
67 <P>An FS::svc_acct object represents an account.  FS::svc_acct inherits from
68 FS::svc_Common.  The following fields are currently supported:</P>
69 <DL>
70 <DT><STRONG><A NAME="item_key">svcnum - primary key (assigned automatcially for new accounts)</A></STRONG><BR>
71 <DD>
72 <DT><STRONG><A NAME="item_username">username</A></STRONG><BR>
73 <DD>
74 <DT><STRONG><A NAME="item__password_%2D_generated_if_blank">_password - generated if blank</A></STRONG><BR>
75 <DD>
76 <DT><STRONG><A NAME="item_presence">popnum - Point of presence (see <A HREF=".././FS/svc_acct_pop.html">the FS::svc_acct_pop manpage</A>)</A></STRONG><BR>
77 <DD>
78 <DT><STRONG><A NAME="item_uid">uid</A></STRONG><BR>
79 <DD>
80 <DT><STRONG><A NAME="item_gid">gid</A></STRONG><BR>
81 <DD>
82 <DT><STRONG><A NAME="item_finger_%2D_GECOS">finger - GECOS</A></STRONG><BR>
83 <DD>
84 <DT><STRONG><A NAME="item_blank">dir - set automatically if blank (and uid is not)</A></STRONG><BR>
85 <DD>
86 <DT><STRONG><A NAME="item_shell">shell</A></STRONG><BR>
87 <DD>
88 <DT><STRONG><A NAME="item_quota_%2D_%28unimplementd%29">quota - (unimplementd)</A></STRONG><BR>
89 <DD>
90 <DT><STRONG><A NAME="item_slipip_%2D_IP_address">slipip - IP address</A></STRONG><BR>
91 <DD>
92 <DT><STRONG><A NAME="item_seconds_%2D">seconds -</A></STRONG><BR>
93 <DD>
94 <DT><STRONG><A NAME="item_domsvc_%2D_svcnum_from_svc_domain">domsvc - svcnum from svc_domain</A></STRONG><BR>
95 <DD>
96 <DT><STRONG><A NAME="item_radius_Radius_Attribute_%2D_Radius%2DAttribute">radius_<EM>Radius_Attribute</EM> - <EM>Radius-Attribute</EM></A></STRONG><BR>
97 <DD>
98 <DT><STRONG><A NAME="item_domsvc_%2D_service_number_of_svc_domain_with_which">domsvc - service number of svc_domain with which to associate</A></STRONG><BR>
99 <DD>
100 </DL>
101 <P>
102 <HR>
103 <H1><A NAME="methods">METHODS</A></H1>
104 <DL>
105 <DT><STRONG><A NAME="item_new">new HASHREF</A></STRONG><BR>
106 <DD>
107 Creates a new account.  To add the account to the database, see <A HREF="#insert">insert</A>.
108 <P></P>
109 <DT><STRONG><A NAME="item_insert">insert</A></STRONG><BR>
110 <DD>
111 Adds this account to the database.  If there is an error, returns the error,
112 otherwise returns false.
113 <P>The additional fields pkgnum and svcpart (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>) should be 
114 defined.  An FS::cust_svc record will be created and inserted.</P>
115 <P>If the configuration value (see <A HREF=".././FS/Conf.html">the FS::Conf manpage</A>) shellmachine exists, and the 
116 username, uid, and dir fields are defined, the <CODE>command(s)</CODE> specified in
117 the shellmachine-useradd configuration are added to the job queue (see
118 <A HREF=".././FS/queue.html">the FS::queue manpage</A> and <A HREF=".././bin/freeside-queued.html">the freeside-queued manpage</A>) to be exectued on shellmachine via ssh.
119 This behaviour can be surpressed by setting $FS::svc_acct::nossh_hack true.
120 If the shellmachine-useradd configuration file does not exist,</P>
121 <PRE>
122   useradd -d $dir -m -s $shell -u $uid $username</PRE>
123 <P>is the default.  If the shellmachine-useradd configuration file exists but
124 it empty,</P>
125 <PRE>
126   cp -pr /etc/skel $dir; chown -R $uid.$gid $dir</PRE>
127 <P>is the default instead.  Otherwise the contents of the file are treated as
128 a double-quoted perl string, with the following variables available:
129 $username, $uid, $gid, $dir, and $shell.</P>
130 <P>(TODOC: cyrus config file, <A HREF=".././FS/queue.html">the FS::queue manpage</A> and <A HREF=".././bin/freeside-queued.html">the freeside-queued manpage</A>)</P>
131 <P></P>
132 <DT><STRONG><A NAME="item_delete">delete</A></STRONG><BR>
133 <DD>
134 Deletes this account from the database.  If there is an error, returns the
135 error, otherwise returns false.
136 <P>The corresponding FS::cust_svc record will be deleted as well.</P>
137 <P>If the configuration value (see <A HREF=".././FS/Conf.html">the FS::Conf manpage</A>) shellmachine exists, the
138 <CODE>command(s)</CODE> specified in the shellmachine-userdel configuration file are
139 added to the job queue (see <A HREF=".././FS/queue.html">the FS::queue manpage</A> and <A HREF=".././bin/freeside-queued.html">the freeside-queued manpage</A>) to be executed
140 on shellmachine via ssh.  This behavior can be surpressed by setting
141 $FS::svc_acct::nossh_hack true.  If the shellmachine-userdel configuration
142 file does not exist,</P>
143 <PRE>
144   userdel $username</PRE>
145 <P>is the default.  If the shellmachine-userdel configuration file exists but
146 is empty,</P>
147 <PRE>
148   rm -rf $dir</PRE>
149 <P>is the default instead.  Otherwise the contents of the file are treated as a
150 double-quoted perl string, with the following variables available:
151 $username and $dir.</P>
152 <P>(TODOC: cyrus config file)</P>
153 <P></P>
154 <DT><STRONG><A NAME="item_replace_OLD_RECORD">replace OLD_RECORD</A></STRONG><BR>
155 <DD>
156 Replaces OLD_RECORD with this one in the database.  If there is an error,
157 returns the error, otherwise returns false.
158 <P>If the configuration value (see <A HREF=".././FS/Conf.html">the FS::Conf manpage</A>) shellmachine exists, and the 
159 dir field has changed, the <CODE>command(s)</CODE> specified in the shellmachine-usermod
160 configuraiton file are added to the job queue (see <A HREF=".././FS/queue.html">the FS::queue manpage</A> and
161 <A HREF=".././bin/freeside-queued.html">the freeside-queued manpage</A>) to be executed on shellmachine via ssh.  This behavior can
162 be surpressed by setting $FS::svc-acct::nossh_hack true.  If the
163 shellmachine-userdel configuration file does not exist or is empty,</P>
164 <PRE>
165   [ -d $old_dir ] &amp;&amp; mv $old_dir $new_dir || (
166     chmod u+t $old_dir;
167     mkdir $new_dir;
168     cd $old_dir;
169     find . -depth -print | cpio -pdm $new_dir;
170     chmod u-t $new_dir;
171     chown -R $uid.$gid $new_dir;
172     rm -rf $old_dir
173   )</PRE>
174 <P>is the default.  This behaviour can be surpressed by setting
175 $FS::svc_acct::nossh_hack true.</P>
176 <P></P>
177 <DT><STRONG><A NAME="item_suspend">suspend</A></STRONG><BR>
178 <DD>
179 Suspends this account by prefixing *SUSPENDED* to the password.  If there is an
180 error, returns the error, otherwise returns false.
181 <P>Called by the suspend method of FS::cust_pkg (see <A HREF=".././FS/cust_pkg.html">the FS::cust_pkg manpage</A>).</P>
182 <P></P>
183 <DT><STRONG><A NAME="item_unsuspend">unsuspend</A></STRONG><BR>
184 <DD>
185 Unsuspends this account by removing *SUSPENDED* from the password.  If there is
186 an error, returns the error, otherwise returns false.
187 <P>Called by the unsuspend method of FS::cust_pkg (see <A HREF=".././FS/cust_pkg.html">the FS::cust_pkg manpage</A>).</P>
188 <P></P>
189 <DT><STRONG><A NAME="item_cancel">cancel</A></STRONG><BR>
190 <DD>
191 Just returns false (no error) for now.
192 <P>Called by the cancel method of FS::cust_pkg (see <A HREF=".././FS/cust_pkg.html">the FS::cust_pkg manpage</A>).</P>
193 <P></P>
194 <DT><STRONG><A NAME="item_check">check</A></STRONG><BR>
195 <DD>
196 Checks all fields to make sure this is a valid service.  If there is an error,
197 returns the error, otherwise returns false.  Called by the insert and replace
198 methods.
199 <P>Sets any fixed values; see <A HREF=".././FS/part_svc.html">the FS::part_svc manpage</A>.</P>
200 <P></P>
201 <DT><STRONG><A NAME="item_radius">radius</A></STRONG><BR>
202 <DD>
203 Depriciated, use radius_reply instead.
204 <P></P>
205 <DT><STRONG><A NAME="item_radius_reply">radius_reply</A></STRONG><BR>
206 <DD>
207 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
208 reply attributes of this record.
209 <P>Note that this is now the preferred method for reading RADIUS attributes - 
210 accessing the columns directly is discouraged, as the column names are
211 expected to change in the future.</P>
212 <P></P>
213 <DT><STRONG><A NAME="item_radius_check">radius_check</A></STRONG><BR>
214 <DD>
215 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
216 check attributes of this record.
217 <P>Accessing RADIUS attributes directly is not supported and will break in the
218 future.</P>
219 <P></P>
220 <DT><STRONG><A NAME="item_domain">domain</A></STRONG><BR>
221 <DD>
222 Returns the domain associated with this account.
223 <P></P>
224 <DT><STRONG><A NAME="item_svc_domain">svc_domain</A></STRONG><BR>
225 <DD>
226 Returns the FS::svc_domain record for this account's domain (see
227 <A HREF=".././FS/svc_domain.html">the FS::svc_domain manpage</A>.
228 <P></P>
229 <DT><STRONG><A NAME="item_cust_svc">cust_svc</A></STRONG><BR>
230 <DD>
231 Returns the FS::cust_svc record for this account (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>).
232 <P>sub cust_svc {
233   my $self = shift;
234   qsearchs( 'cust_svc', { 'svcnum' =&gt; $self-&gt;svcnum } );
235 }</P>
236 <P></P>
237 <DT><STRONG><A NAME="item_email">email</A></STRONG><BR>
238 <DD>
239 Returns an email address associated with the account.
240 <P></P>
241 <DT><STRONG><A NAME="item_seconds_since_TIMESTAMP">seconds_since TIMESTAMP</A></STRONG><BR>
242 <DD>
243 Returns the number of seconds this account has been online since TIMESTAMP.
244 See <A HREF=".././FS/session.html">the FS::session manpage</A>
245 <P>TIMESTAMP is specified as a UNIX timestamp; see <EM>perlfunc/``time''</EM>.  Also see
246 <A HREF="../Time/Local.html">the Time::Local manpage</A> and <A HREF="../Date/Parse.html">the Date::Parse manpage</A> for conversion functions.</P>
247 <P></P>
248 <DT><STRONG><A NAME="item_ssh">ssh</A></STRONG><BR>
249 <DD>
250 </DL>
251 <P>
252 <HR>
253 <H1><A NAME="version">VERSION</A></H1>
254 <P>$Id: svc_acct.html,v 1.3 2002-01-29 17:42:46 ivan Exp $</P>
255 <P>
256 <HR>
257 <H1><A NAME="bugs">BUGS</A></H1>
258 <P>The bits which ssh should fork before doing so (or maybe queue jobs for a
259 daemon).</P>
260 <P>The $recref stuff in sub check should be cleaned up.</P>
261 <P>The suspend, unsuspend and cancel methods update the database, but not the
262 current object.  This is probably a bug as it's unexpected and
263 counterintuitive.</P>
264 <P>
265 <HR>
266 <H1><A NAME="see also">SEE ALSO</A></H1>
267 <P><A HREF=".././FS/svc_Common.html">the FS::svc_Common manpage</A>, edit/part_svc.cgi from an installed web interface,
268 export.html from the base documentation, <A HREF=".././FS/Record.html">the FS::Record manpage</A>, <A HREF=".././FS/Conf.html">the FS::Conf manpage</A>,
269 <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>, <A HREF=".././FS/part_svc.html">the FS::part_svc manpage</A>, <A HREF=".././FS/cust_pkg.html">the FS::cust_pkg manpage</A>, <A HREF=".././FS/queue.html">the FS::queue manpage</A>,
270 <A HREF=".././bin/freeside-queued.html">the freeside-queued manpage</A>), <A HREF="../Net/SSH.html">the Net::SSH manpage</A>, <A HREF="#item_ssh">ssh</A>, <A HREF=".././FS/svc_acct_pop.html">the FS::svc_acct_pop manpage</A>,
271 schema.html from the base documentation.</P>
272
273 </BODY>
274
275 </HTML>