Stud.IP  2.4 Revision 48548
 All Data Structures Namespaces Files Functions Variables Groups Pages
UserLookup Class Reference
Collaboration diagram for UserLookup:
Collaboration graph

Public Member Functions

 setFilter ($type, $value)
 execute ($flags=null)
 clearFilters ()

Static Public Member Functions

static addType ($name, $values_callback, $filter_callback)
static getValuesForType ($type)

Data Fields

const USE_CACHE = false
const CACHE_DURATION = 3600
const FLAG_SORT_NAME = 1
const FLAG_RETURN_FULL_INFO = 2

Static Protected Member Functions

static arrayQuery ($query, $values)
static fachFilter ($needles)
static fachValues ()
static abschlussFilter ($needles)
static abschlussValues ()
static fachsemesterFilter ($needles)
static fachsemesterValues ()
static institutFilter ($needles)
static institutValues ()
static statusFilter ($needles)
static statusValues ()

Static Protected Attributes

static $types

Detailed Description

UserLookup.class.php provides an easy way to look up user ids by certain filter criteria

Example of use:

# Create a new UserLookup object
$user_lookup = new UserLookup;
# Filter all users in their first to sixth fachsemester
$user_lookup->setFilter('fachsemester', range(1, 6));
# Filter all users that have an 'autor' or 'tutor' permission
$user_lookup->setFilter('status', array('autor', 'tutor'));
# Get a list of all matching user ids (sorted by the user's names)
$user_ids = $user_lookup->execute(UserLookup::FLAG_SORT_NAME);
# Get another list of all matching user ids but this time we want
# the complete unordered dataset
$user_ids = $user_lookup->execute(UserLookup::FLAG_RETURN_FULL_INFO);

Member Function Documentation

static abschlussFilter (   $needles)
staticprotected

Return all user with matching abschluss_id in $needles

Parameters
array$needlesList of abschluss ids to filter against
Returns
array List of user ids matching the given filter

Here is the call graph for this function:

static abschlussValues ( )
staticprotected

Return all studydegrees

Returns
array Associative array of abschluss ids and abschluss names

Here is the call graph for this function:

static addType (   $name,
  $values_callback,
  $filter_callback 
)
static

Adds or updates a filter criterion the global set of criteria.

Parameters
string$nameName of the criterion type
callback$values_callbackCallback for the type's values
callback$filter_callbackActual filter callback for a defined set of needles
static arrayQuery (   $query,
  $values 
)
staticprotected

Convenience method to query over an array via ".. WHERE x IN (<array>)". Any ?? is substituted by the array of values.

Parameters
string$queryThe query to execute
array$valuesArray containing the values to search for
Returns
PDOStatement Result of the query against the db

Here is the call graph for this function:

Here is the caller graph for this function:

clearFilters ( )

Clears all defined filters.

Returns
UserLookup Returns itself to allow chaining
execute (   $flags = null)

Executes the actual lookup by executing all individual filter types and returning the intersection of all according result sets.

Possible flags:

  • FLAG_SORT_NAME Sorts the user ids in the result by the actual user names
  • FLAG_RETURN_FULL_INFO Returns rudimental user info instead of just the ids (as an array with the user id as key and an array containting the info as value)
Parameters
int$flagsOptional set of flags as seen above
Returns
array Either a simple list of user ids or an associative array of user ids and user info if FLAG_RETURN_FULL_INFO is set

Here is the call graph for this function:

static fachFilter (   $needles)
staticprotected

Return all user with matching studiengang_id in $needles

Parameters
array$needlesList of studiengang ids to filter against
Returns
array List of user ids matching the given filter

Here is the call graph for this function:

static fachsemesterFilter (   $needles)
staticprotected

Return all users with a matching fachsemester given in $needles

Parameters
array$needlesList of fachsemesters to filter against
Returns
array List of user ids matching the given filter

Here is the call graph for this function:

static fachsemesterValues ( )
staticprotected

Create a array with all possible values for studysemesters

Returns
array Associative array of fachsemesters and fachsemesters (pretty dull, i know)

Here is the call graph for this function:

static fachValues ( )
staticprotected

Return all studycourses

Returns
array Associative array of studiengang ids and studiengang names

Here is the call graph for this function:

static getValuesForType (   $type)
static

Returns all valid values for a certain criterion type.

Parameters
string$typeName of the criterion type
Returns
array Associative array containing the values as keys and descriptive names as values

Here is the call graph for this function:

Here is the caller graph for this function:

static institutFilter (   $needles)
staticprotected

Return all users with a matching institut_id given in $needles

Parameters
array$needlesList of institut ids to filter against
Returns
array List of user ids matching the given filter

Here is the call graph for this function:

static institutValues ( )
staticprotected

Return all faculty's and instituts

Returns
array Associative array of institut ids and institut data (Be aware that this array is multidimensional)

Here is the call graph for this function:

setFilter (   $type,
  $value 
)

Adds another type filter to the set of current filters.

Multiple filters for the same filter type result in an AND filter within this type while multiple filters across filter types result in an OR filter across these types.

Parameters
string$typeType of filter to add
string$valueValue to filter against
Returns
UserLookup Returns itself to allow chaining
static statusFilter (   $needles)
staticprotected

Return all users with a matching status given in $needles

Parameters
array$needlesList of statusses to filter against
Returns
array List of user ids matching the given filter

Here is the call graph for this function:

static statusValues ( )
staticprotected

Return all valid statusses

Returns
array Associative array of status name and description

Field Documentation

$types
staticprotected
Initial value:
array(
'abschluss' => array(
'filter' => 'UserLookup::abschlussFilter',
'values' => 'UserLookup::abschlussValues',
),
'fach' => array(
'filter' => 'UserLookup::fachFilter',
'values' => 'UserLookup::fachValues',
),
'fachsemester' => array(
'filter' => 'UserLookup::fachsemesterFilter',
'values' => 'UserLookup::fachsemesterValues',
),
'institut' => array(
'filter' => 'UserLookup::institutFilter',
'values' => 'UserLookup::institutValues',
),
'status' => array(
'filter' => 'UserLookup::statusFilter',
'values' => 'UserLookup::statusValues',
),
)
const CACHE_DURATION = 3600
const FLAG_RETURN_FULL_INFO = 2
const FLAG_SORT_NAME = 1
const USE_CACHE = false

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