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 20: Line 20:
 
An FS::access_user object represents an internal access user. FS::access_user inherits from FS::Record. The following fields are currently supported:
 
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'
+
; usernum
 +
:primary key
 +
; username; _password; _password_encoding
 +
:Empty or bcrypt
 +
; last
 +
:Last name
 +
; first
 +
:First name
 +
; user_custnum
 +
:Master customer for this employee (for commissions)
 +
; report_salesnum
 +
:Default sales person for this employee (for reports)
 +
; disabled
 +
:Empty or 'Y'
 +
 
 
==METHODS==
 
==METHODS==
 
; new HASHREF
 
; new HASHREF
Line 60: Line 74:
 
; agentnum
 
; agentnum
 
:Returns true if the user can view the specified agent.
 
:Returns true if the user can view the specified agent.
 +
 +
:Also accepts optional hashref cache, to avoid redundant database calls.
 
; agents [ HASHREF | OPTION => VALUE ... ]
 
; 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.
 
: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
+
; access_users [ HASHREF | OPTION => VALUE ... ]
: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).
+
:Returns an array of FS::access_user objects, one for each non-disabled access_user in the system that shares an agent (via group membership) with the invoking object. Regardless of options and agents, will always at least return the invoking user and any users who have viewall_right.
; 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.
 
  
 +
:Accepts the following options:
 +
:; table
 +
::Only return users who appear in the usernum field of this table
 +
:; disabled
 +
::Include disabled users if true (defaults to false)
 +
:; viewall_right
 +
::All users will be returned if the current user has the provided access right, regardless of agents (other filters still apply.) Defaults to 'View customers of all agents'
 +
:; access_users_hashref [ HASHREF | OPTION => VALUE ... ]
 +
::Accepts same options as [[#access_users|"access_users"]]. Returns a hashref of users, with keys of usernum and values of username.
 +
:; 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 cannot log into the web interface and can't have passwords set.
 +
:; change_password NEW_PASSWORD:; change_password_fields NEW_PASSWORD
 
==BUGS==
 
==BUGS==
 
==SEE ALSO==
 
==SEE ALSO==
 
[[Freeside:3:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.
 
[[Freeside:3:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.
 +
 +
==POD ERRORS==
 +
Hey! '''The above document had some coding errors, which are explained below:'''
 +
 +
; Around line 669:
 +
:You forgot a '=back' before '=head1'

Revision as of 07:27, 24 March 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; _password_encoding
Empty or bcrypt
last
Last name
first
First name
user_custnum
Master customer for this employee (for commissions)
report_salesnum
Default sales person for this employee (for reports)
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.
Also accepts optional hashref cache, to avoid redundant database calls.
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_users [ HASHREF | OPTION => VALUE ... ]
Returns an array of FS::access_user objects, one for each non-disabled access_user in the system that shares an agent (via group membership) with the invoking object. Regardless of options and agents, will always at least return the invoking user and any users who have viewall_right.
Accepts the following options:
table
Only return users who appear in the usernum field of this table
disabled
Include disabled users if true (defaults to false)
viewall_right
All users will be returned if the current user has the provided access right, regardless of agents (other filters still apply.) Defaults to 'View customers of all agents'
access_users_hashref [ HASHREF | OPTION => VALUE ... ]
Accepts same options as "access_users". Returns a hashref of users, with keys of usernum and values of username.
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 cannot log into the web interface and can't have passwords set.
change_password NEW_PASSWORD
; change_password_fields NEW_PASSWORD

BUGS

SEE ALSO

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

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 669:
You forgot a '=back' before '=head1'