new UserSet - jcobban/Genealogy GitHub Wiki
new UserSet($parms)
Up: class UserSet
The constructor for an instance of UserSet takes one parameter:
parameter | description |
---|---|
$parms | identifies the database records to be associated with this instance. This is an array. |
$parms
may be:
- an associative array of
fieldname => value pairs
to define the subset of the records in the SQL table that are represented by this instance. - an array of instances of the class User to be converted into a
RecordSet
. - If this parameter is omitted, or is
null
, the object is empty. That is$set->count()
is zero.
The fieldnames which may be specified in this associative array are as follows:
fieldname | description |
---|---|
username | Specifies a pattern which is matched against the table of Users. This may either be a string or an array of strings. If an array of strings is specified then Users who match any of the patterns are included. If the pattern starts with a caret (^) and ends with a dollar sign ($) then the pattern matches the unique username between those marks. Otherwise the pattern matches any user whose username contains the pattern. However if a pattern starts with an exclamation mark (!) then the unique User matching the remainder of the value is excluded from the result. |
auth | specifies a capability. Only those Users who have that capability are included. Specifically the 'pending' capability matches only those Users who have not confirmed their e-mail addresses. Note that administrators have all capabilities except 'pending'. For example 'auth' => 'edit' will return all Users who either have the specific authority 'edit' or are administrators. |
specifies a string which is matched against the e-mail addresses of Users. This partially emulates a regular expression in that the letter '^' if placed at the beginning indicates that the remainder must match at the beginning of the address, and a '$' placed at the end indicates that the preceding must match at the end of the address. If the value starts with '^' and ends with '$' then an exact match to the email address is demanded. | |
options | specifies a number, currently limited to decimal notation, which is used as a bit-wise mask to select Users to include. See the description of options in class User. |
table | specifies the name of an SQL table. This may either be an external table name, such as "Persons", or an internal table name, such as "tblIR". |
recordid | specifies a number in decimal notation, which identifies a specific record in the table identified by the parameter table . Only Users who are authorized to update and access the private information in the specified record are included in the result set. |
offset | set the OFFSET clause |
limit | set the LIMIT clause |
groupby | set the GROUP BY clause |
order | set the ORDER BY clause |
The following examples show ways to obtain a UserSet:
// get all users
$set = new UserSet();
// get all users except the current user
$set = new UserSet(array('username' => '!' . $userid));
// get all users whose name contains 'sam'
$set = new UserSet(array('username' => 'sam'));
// get all users whose name contains 'sam' but excluding the current user
$set = new UserSet(array('username' => array('!' . $userid, 'sam')));
// get all users who are awaiting confirmation
$set = new UserSet(array('auth' => 'pending'));
// get all users who can edit the database
$set = new UserSet(array('auth' => 'edit'));
// get all Users who accept e-mails
$set = new UserSet(array('options' => 1));
// get all administrators
$set = new UserSet(array('auth' => 'all'));
// get all users who can update a specific record
$set = new UserSet(array('table' => 'Persons', 'recordid' => 12345));
// get all users whose e-mail address is from gmail.com
$set = new UserSet(array('email' => '@gmail.com$'));
// get all users whose e-mail address is from Italy
$set = new UserSet(array('email' => '.it$'));
// get all users whose e-mail address begins with "fr", for example "[email protected]"
$set = new UserSet(array('email' => '^fr'));
// get the single user whose email address is "[email protected]"
$set = new UserSet(array('email' => '^[email protected]$'));
The constructor adds error messages to $userset->msg
if it is unable to complete due to bad parameters.
Next: $userSet->getMaillist()