CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
UserFactory Class Reference
Inheritance diagram for UserFactory:
[legend]

## Public Member Functions
| __construct ()
| Object constructor. More...
| CreateNewUser ($UserName, $Password, $PasswordAgain, $EMail, $EMailAgain, $IgnoreErrorCodes=NULL)
| Create new user. More...
| TestNewUserValues ($UserName, $Password, $PasswordAgain, $EMail, $EMailAgain)
| Test new user values (usually used before creating new user). More...
| GetUserCount ($Condition=NULL)
| Return number of users in the system. More...
| GetMatchingUserCount ()
| Get total number of user that matched last GetMatchingUsers() call. More...
| GetUserIds ()
| Get IDs for all users. More...
| GetLoggedInUsers ($InactivityTimeout=60)
| Get users who are currently logged in (i.e. More...
| GetRecentlyLoggedInUsers ($Since=NULL, $Limit=10)
| Get users recently logged in. More...
| GetUsersWithPrivileges ()
| Return array of user names who have the specified privileges. More...
| FindUsers ($SearchString, $FieldName="UserName", $SortFieldName="UserName", $Offset=0, $Count=9999999)
| Get users who have values matching specified string in specified field. More...
| FindUserNames ($SearchString, $FieldName="UserName", $SortFieldName="UserName", $Offset=0, $Count=9999999, $IdExclusions=array(), $ValueExclusions=array())
| Get users who have values matching specified string in specified field. More...
| GetMatchingUsers ($SearchString, $FieldName=NULL, $SortFieldName="UserName", $ResultsStartAt=0, $ReturnNumber=NULL)
| Return array of users who have values matching search string (in specific field if requested). More...
| UserExists ($UserId)
| Check whether user currently exists with specified ID. More...
| UserNameExists ($UserName)
| Check whether user name currently exists. More...
| EMailAddressIsInUse ($Address)
| Check whether e-mail address currently has account associated with it. More...
| GetNewestUsers ($Limit=5)
| Get the users sorted by when they signed up, starting with those who signed up most recently. More...

## Protected Attributes
| $DB
| $SortFieldName
| $MatchingUserCount

## Detailed Description

Definition at line 18 of file UserFactory.php.

## Constructor & Destructor Documentation

UserFactory::__construct | ( |  | ) |

Object constructor.

Definition at line 26 of file UserFactory.php.

## Member Function Documentation

UserFactory::CreateNewUser | ( |  | $UserName,
|  |  | $Password,
|  |  | $PasswordAgain,
|  |  | $EMail,
|  |  | $EMailAgain,
|  |  | $IgnoreErrorCodes = `NULL`
| ) |  |

Create new user.

The second password and e-mail address parameters are intended for second copies of each entered by the user.

Parameters

  string | $UserName | Login name for new user.
  string | $Password | Password for new user.
  string | $PasswordAgain | Second copy of password entered by user.
  string | $EMail | E-mail address for new user.
  string | $EMailAgain | Second copy of e-mail address entered by user.
  bool | $IgnoreErrorCodes | Array containing any error codes that should be ignored. (OPTIONAL)

Returns
  User object or array of error codes.

Definition at line 48 of file UserFactory.php.

References TestNewUserValues(), and U_OKAY.

UserFactory::EMailAddressIsInUse | ( |  | $Address | ) |

Check whether e-mail address currently has account associated with it.

Parameters

  string | $Address | Address to check.

Returns
  bool TRUE if address is in use, otherwise FALSE.

Definition at line 568 of file UserFactory.php.

Referenced by TestNewUserValues().

Here is the caller graph for this function:

UserFactory::FindUserNames | ( |  | $SearchString,
|  |  | $FieldName = `"UserName"`,
|  |  | $SortFieldName = `"UserName"`,
|  |  | $Offset = `0`,
|  |  | $Count = `9999999`,
|  |  | $IdExclusions = `array()`,
|  |  | $ValueExclusions = `array()`
| ) |  |

Get users who have values matching specified string in specified field.

Parameters

  string | $SearchString | String to match.
  string | $FieldName | Database column name to search. (OPTIONAL, defaults to "UserName")
  string | $SortFieldName | Database column name to sort results by. (OPTIONAL, defaults to "UserName")
  int | $Offset | Starting index for results. (OPTIONAL)
  int | $Count | Maximum number of results to return. (OPTIONAL)
  array | $IdExclusions | User IDs to exclude. (OPTIONAL)
  array | $ValueExclusions | User names to exclude. (OPTIONAL)

Returns
  array Array with user IDs for the index and user names for the values.

Definition at line 382 of file UserFactory.php.

Referenced by FindUsers().

Here is the caller graph for this function:

UserFactory::FindUsers | ( |  | $SearchString,
|  |  | $FieldName = `"UserName"`,
|  |  | $SortFieldName = `"UserName"`,
|  |  | $Offset = `0`,
|  |  | $Count = `9999999`
| ) |  |

Get users who have values matching specified string in specified field.

Parameters

  string | $SearchString | String to match.
  string | $FieldName | Database column name to search. (OPTIONAL, defaults to "UserName")
  string | $SortFieldName | Database column name to sort results by. (OPTIONAL, defaults to "UserName")
  int | $Offset | Starting index for results. (OPTIONAL)
  int | $Count | Maximum number of results to return. (OPTIONAL)

Returns
  array Array with user IDs for the index and User objects for the values.

Definition at line 350 of file UserFactory.php.

References $SortFieldName, and FindUserNames().

UserFactory::GetLoggedInUsers | ( |  | $InactivityTimeout = `60` | ) |

Get users who are currently logged in (i.e.

recently active and not logged out).

Parameters

  int | $InactivityTimeout | Number of minutes after which an inactive user is considered to be no longer logged in. (OPTIONAL, defaults to 60)

Returns
  Array of User objects.

Definition at line 226 of file UserFactory.php.

UserFactory::GetMatchingUserCount | ( |  | ) |

Get total number of user that matched last GetMatchingUsers() call.

Returns
  int Number of users.

See also
  UserFactory::GetMatchingUser()

Definition at line 205 of file UserFactory.php.

References $MatchingUserCount.

UserFactory::GetMatchingUsers | ( |  | $SearchString,
|  |  | $FieldName = `NULL`,
|  |  | $SortFieldName = `"UserName"`,
|  |  | $ResultsStartAt = `0`,
|  |  | $ReturnNumber = `NULL`
| ) |  |

Return array of users who have values matching search string (in specific field if requested).

(Search string respects POSIX-compatible regular expressions.) Optimization: $SearchString = ".*." and $FieldName = NULL will return all users ordered by $SortFieldName.

Parameters

  string | $SearchString | Search pattern.
  string | $FieldName | Database column name to search. (OPTIONAL)
  string | $SortFieldName | Database column name to sort results by. (OPTIONAL, defaults to "UserName")
  int | $ResultsStartAt | Starting index for results. (OPTIONAL)
  int | $ReturnNumber | Maximum number of results to return. (OPTIONAL)

Returns
  array Array with user IDs for the index and associative arrays of database columns for the values.

See also
  UserFactory::GetMatchingUserCount()

Definition at line 439 of file UserFactory.php.

References $SortFieldName.

UserFactory::GetNewestUsers | ( |  | $Limit = `5` | ) |

Get the users sorted by when they signed up, starting with those who signed up most recently.

By default, the number of users returned is five.

Parameters

  int | $Limit | The maximum number of users to return.

Definition at line 589 of file UserFactory.php.

UserFactory::GetRecentlyLoggedInUsers | ( |  | $Since = `NULL`,
|  |  | $Limit = `10`
| ) |  |

Get users recently logged in.

Parameters

  string | $Since | Used to define "recently". (OPTIONAL, defaults to 24 hours)
  int | $Limit | Maximum number of users to return.

Returns
  array Array of User objects, with IDs for the index.

Definition at line 254 of file UserFactory.php.

UserFactory::GetUserCount | ( |  | $Condition = `NULL` | ) |

Return number of users in the system.

Parameters

  string | $Condition | SQL condition (without "WHERE") to limit user count. (OPTIONAL)

Returns
  int Count of users.

Definition at line 194 of file UserFactory.php.

UserFactory::GetUserIds | ( |  | ) |

Get IDs for all users.

Returns
  array User IDs.

Definition at line 214 of file UserFactory.php.

Referenced by CWUserFactory\FindUsersThatMeetRequirements().

Here is the caller graph for this function:

UserFactory::GetUsersWithPrivileges | ( |  | ) |

Return array of user names who have the specified privileges.

Multiple privileges can be passed in as parameters (rather than in an array), if desired.

Returns
  array User names with user IDs for the array index.

Definition at line 291 of file UserFactory.php.

Referenced by CWUserFactory\FindUsersThatMeetRequirements().

Here is the caller graph for this function:

UserFactory::TestNewUserValues | ( |  | $UserName,
|  |  | $Password,
|  |  | $PasswordAgain,
|  |  | $EMail,
|  |  | $EMailAgain
| ) |  |

Test new user values (usually used before creating new user).

Parameters

  string | $UserName | User name entered.
  string | $Password | Password entered.
  string | $PasswordAgain | Second copy of password entered.
  string | $EMail | Email entered.
  string | $EMailAgain | Second copy of email entered.

Returns
  array Codes (U_* constants) for errors found (if any).

Definition at line 96 of file UserFactory.php.

References EMailAddressIsInUse(), U_DUPLICATEEMAIL, U_DUPLICATEUSERNAME, U_EMAILSDONTMATCH, U_EMPTYEMAIL, U_EMPTYEMAILAGAIN, U_EMPTYPASSWORDAGAIN, U_EMPTYUSERNAME, U_ILLEGALEMAIL, U_ILLEGALEMAILAGAIN, U_ILLEGALUSERNAME, U_PASSWORDSDONTMATCH, and UserNameExists().

Referenced by CreateNewUser().

Here is the caller graph for this function:

UserFactory::UserExists | ( |  | $UserId | ) |

Check whether user currently exists with specified ID.

Parameters

  int | $UserId | ID to check.

Returns
  bool TRUE if user exists with that ID, otherwise FALSE.

Definition at line 531 of file UserFactory.php.

UserFactory::UserNameExists | ( |  | $UserName | ) |

Check whether user name currently exists.

Parameters

  string | $UserName | Name to check.

Returns
  bool TRUE if name is already in use, otherwise FALSE.

Definition at line 547 of file UserFactory.php.

Referenced by TestNewUserValues().

Here is the caller graph for this function:

## Member Data Documentation

UserFactory::$DB
| protected

Definition at line 615 of file UserFactory.php.

UserFactory::$MatchingUserCount
| protected

Definition at line 617 of file UserFactory.php.

Referenced by GetMatchingUserCount().

UserFactory::$SortFieldName
| protected

Definition at line 616 of file UserFactory.php.

Referenced by FindUsers(), and GetMatchingUsers().

The documentation for this class was generated from the following file:

- lib/ScoutLib/UserFactory.php