Difference between revisions of "Freeside:3:Documentation:Developer/FS/access user"

From Freeside
Jump to: navigation, search
m (Edit via perl MediaWiki framework (1.13))
m (Edit via perl MediaWiki framework (1.13))
Line 1: Line 1:
 +
==NAME==
 +
FS::access_user - Object methods for access_user records
  
 +
==SYNOPSIS==
 +
<code>
 +
  use FS::access_user;
 +
 +
  $record = new FS::access_user \%hash;
 +
  $record = new FS::access_user { 'column' => 'value' };
 +
 +
  $error = $record->insert;
 +
 +
  $error = $new_record->replace($old_record);
 +
 +
  $error = $record->delete;
 +
 +
  $error = $record->check;
 +
</code>
 +
==DESCRIPTION==
 +
An FS::access_user object represents an internal access user. FS::access_user inherits from FS::Record. The following fields are currently supported:
 +
 +
; usernum - primary key; username -; _password -; last -; first -; disabled - empty or 'Y'
 +
==METHODS==
 +
; new HASHREF
 +
:Creates a new internal access user. To add the user to the database, see [[#insert|"insert"]].
 +
 +
:Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the ''hash'' method.
 +
; insert
 +
:Adds this record to the database. If there is an error, returns the error, otherwise returns false.
 +
; delete
 +
:Delete this record from the database.
 +
; replace OLD_RECORD
 +
:Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
 +
; check
 +
:Checks all fields to make sure this is a valid internal access user. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
 +
; name
 +
:Returns a name string for this user: "Last, First".
 +
; user_cust_main
 +
:Returns the FS::cust_main object (see [[Freeside:3:Documentation:Developer/FS/cust main|FS::cust_main]]), if any, for this user.
 +
; report_sales
 +
:Returns the FS::sales object (see [[Freeside:3:Documentation:Developer/FS/sales|FS::sales]]), if any, for this user.
 +
; access_usergroup
 +
:Returns links to the the groups this user is a part of, as FS::access_usergroup objects (see [[Freeside:3:Documentation:Developer/FS/access usergroup|FS::access_usergroup]]).
 +
; agentnums
 +
:Returns a list of agentnums this user can view (via group membership).
 +
; agentnums_href
 +
:Returns a hashref of agentnums this user can view.
 +
; agentnums_sql [ HASHREF | OPTION => VALUE ... ]
 +
:Returns an sql fragement to select only agentnums this user can view.
 +
 +
:Options are passed as a hashref or a list. Available options are:
 +
:; null
 +
::The frament will also allow the selection of null agentnums.
 +
:; null_right
 +
::The fragment will also allow the selection of null agentnums if the current user has the provided access right
 +
:; table
 +
::Optional table name in which agentnum is being checked. Sometimes required to resolve 'column reference "agentnum" is ambiguous' errors.
 +
:; viewall_right
 +
::All agents will be viewable if the current user has the provided access right. Defaults to 'View customers of all agents'.
 +
; agentnum
 +
:Returns true if the user can view the specified agent.
 +
; agents [ HASHREF | OPTION => VALUE ... ]
 +
:Returns the list of agents this user can view (via group membership), as FS::agent objects. Accepts the same options as the agentnums_sql method.
 +
; access_right RIGHTNAME | LISTREF
 +
:Given a right name or a list reference of right names, returns true if this user has this right, or, for a list, one of the rights (currently via group membership, eventually also via user overrides).
 +
; default_customer_view
 +
:Returns the default customer view for this user, from the "default_customer_view" user preference, the "cust_main-default_view" config, or the hardcoded default, "basics" (formerly "jumbo" prior to 3.0).
 +
; spreadsheet_format [ OVERRIDE ]
 +
:Returns a hashref of this user's Excel spreadsheet download settings: 'extension' (xls or xlsx), 'class' (Spreadsheet::WriteExcel or Excel::Writer::XLSX), and 'mime_type'. If OVERRIDE is 'XLS' or 'XLSX', use that instead of the user's setting.
 +
; is_system_user
 +
:Returns true if this user has the name of a known system account. These users will not appear in the htpasswd file and can't have passwords set.
 +
 +
==BUGS==
 +
==SEE ALSO==
 +
[[Freeside:3:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.

Revision as of 06:28, 10 February 2015

NAME

FS::access_user - Object methods for access_user records

SYNOPSIS

 use FS::access_user;

 $record = new FS::access_user \%hash;
 $record = new FS::access_user { 'column' => 'value' };

 $error = $record->insert;

 $error = $new_record->replace($old_record);

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::access_user object represents an internal access user. FS::access_user inherits from FS::Record. The following fields are currently supported:

usernum - primary key; username -; _password -; last -; first -; disabled - empty or 'Y'

METHODS

new HASHREF
Creates a new internal access user. To add the user to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
insert
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
delete
Delete this record from the database.
replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
check
Checks all fields to make sure this is a valid internal access user. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
name
Returns a name string for this user: "Last, First".
user_cust_main
Returns the FS::cust_main object (see FS::cust_main), if any, for this user.
report_sales
Returns the FS::sales object (see FS::sales), if any, for this user.
access_usergroup
Returns links to the the groups this user is a part of, as FS::access_usergroup objects (see FS::access_usergroup).
agentnums
Returns a list of agentnums this user can view (via group membership).
agentnums_href
Returns a hashref of agentnums this user can view.
agentnums_sql [ HASHREF | OPTION => VALUE ... ]
Returns an sql fragement to select only agentnums this user can view.
Options are passed as a hashref or a list. Available options are:
null
The frament will also allow the selection of null agentnums.
null_right
The fragment will also allow the selection of null agentnums if the current user has the provided access right
table
Optional table name in which agentnum is being checked. Sometimes required to resolve 'column reference "agentnum" is ambiguous' errors.
viewall_right
All agents will be viewable if the current user has the provided access right. Defaults to 'View customers of all agents'.
agentnum
Returns true if the user can view the specified agent.
agents [ HASHREF | OPTION => VALUE ... ]
Returns the list of agents this user can view (via group membership), as FS::agent objects. Accepts the same options as the agentnums_sql method.
access_right RIGHTNAME | LISTREF
Given a right name or a list reference of right names, returns true if this user has this right, or, for a list, one of the rights (currently via group membership, eventually also via user overrides).
default_customer_view
Returns the default customer view for this user, from the "default_customer_view" user preference, the "cust_main-default_view" config, or the hardcoded default, "basics" (formerly "jumbo" prior to 3.0).
spreadsheet_format [ OVERRIDE ]
Returns a hashref of this user's Excel spreadsheet download settings: 'extension' (xls or xlsx), 'class' (Spreadsheet::WriteExcel or Excel::Writer::XLSX), and 'mime_type'. If OVERRIDE is 'XLS' or 'XLSX', use that instead of the user's setting.
is_system_user
Returns true if this user has the name of a known system account. These users will not appear in the htpasswd file and can't have passwords set.

BUGS

SEE ALSO

FS::Record, schema.html from the base documentation.