|
Stud.IP
trunk Revision
|

Public Member Functions | |
| __construct ($reset_settings=false) | |
| storeSettings () | |
| restoreSettings () | |
| resetSettings () | |
| initSettings () | |
| filterBySemester ($semester_id) | |
| filterByType ($type) | |
| filterByInstitute ($institut_ids) | |
| filterByDozent ($user_ids) | |
| filterBySearchstring ($text) | |
| orderBy ($attribute, $flag='ASC') | |
| where ($where, $parameter=[], $id=null) | |
| getCourses ($grouped=true) | |
| countCourses () | |
| getCoursesForAdminWidget () | |
| createQuery ($only_count=false) | |
Static Public Member Functions | |
| static | get ($reset_settings=false) |
Data Fields | |
| $max_show_courses = 500 | |
| $settings = [] | |
Static Protected Attributes | |
| static | $instance = null |
Class AdminCourseFilter
The main class to filter all courses for admins. It's a singleton class, so you better call it with AdminCourseFilter::get(). The whole class is created to provide a nice hook for plugins to add special filters into the admin-area of Stud.IP.
To add a filter with a plugin, listen to the notification "AdminCourseFilterWillQuery" like this:
NotificationCenter::addObserver($this, "addMyFilter", "AdminCourseFilterWillQuery");
Where $this is an object and "addMyFilter" a method. Such a method might look like this:
public function addLectureshipFilter($event, $filter)
{
if ($GLOBALS['user']->cfg->getValue("LECTURESHIP_FILTER")) {
$filter->settings['query']['joins']['lehrauftrag'] = array(
'join' => "INNER JOIN",
'on' => "seminare.Seminar_id = lehrauftrag.seminar_id"
);
}
}
Within this method you alter the public $filter->settings array, because this array describes entirely the big query for the admin-search. In our example above we simple add an INNER JOIN to filter for the course having an entry in the lehrauftrag table.
Description of this array is as follows:
$filter->settings['query'] : The main sql query as a prepared statement. $filter->settings['query']['select'] : An assoc array. $filter->settings['query']['select']['Number_of_teachers'] = "COUNT(DISTINCT dozenten.user_id)" will select the result of COUNT as the variable Number_of_teachers. $filter->settings['query']['joins'] : Example $filter->settings['query']['joins']['dozenten'] = array( 'join' => "INNER JOIN", //default value, else use "LEFT JOIN" 'table' => "seminar_user", //can me omitted if you don't want to use a table-alias 'on' => "dozenten.Seminar_id = seminare.Seminar_id AND dozenten.status = 'dozent'" ) if 'table' differs from the index, the index will be the alias of the table. So normally you don't need to name a table if you don't want it to be aliased. $filter->settings['query']['where'] : You might want to use the method $filter->where($sql, $parameter) instead. $filter->settings['query']['orderby'] : You might want to use $filter->orderBy($attribute, $flag = "ASC") instead. $filter->settings['parameter'] : An assoc array of parameter that will be passed to the prepared statement.
| __construct | ( | $reset_settings = false | ) |
Constructor of the singleton-object. The settings might come from the session if $reset_settings is false.
| bool | $reset_settings | : should the session settings of the singleton be reset? |

| countCourses | ( | ) |


| createQuery | ( | $only_count = false | ) |
Creates the sql-query from the $this->settings['query'] @only_count : boolean

| filterByDozent | ( | $user_ids | ) |
| filterByInstitute | ( | $institut_ids | ) |
Adds a filter for an institut_id or many institut_ids if the parameter is an array.
| array | integer | $institut_ids | : id or ids of institutes |
| filterBySearchstring | ( | $text | ) |
Adds a filter for a textstring, that can be the coursenumber, the name of the course or the last name of one of the dozenten.
| string | $text | : the searchstring |
| filterBySemester | ( | $semester_id | ) |
Adds a filter for all courses of the given semester.
| string | $semester_id | : ID of the given semester. |
| Exception | if semester_id does not exist |

| filterByType | ( | $type | ) |
Adds a filter for a sem_type or many sem_types if the parameter is an array.
| array | integer | $type | : id or ids of sem_types |
|
static |
returns an AdminCourseFilter singleton object

| getCourses | ( | $grouped = true | ) |
Returns the data of the resultset of the AdminCourseFilter. Also saves the settings in the session. Note that a notification AdminCourseFilterWillQuery will be posted, before the result is computed. Plugins may register at this event to fully alter this AdminCourseFilter-object and so the resultset.


| getCoursesForAdminWidget | ( | ) |
Returns the data of the resultset of the AdminCourseFilter.
Note that a notification AdminCourseFilterWillQuery will be posted, before the result is computed. Plugins may register at this event to fully alter this AdminCourseFilter-object and so the resultset.

| initSettings | ( | ) |
initialize settings


| orderBy | ( | $attribute, | |
$flag = 'ASC' |
|||
| ) |
| string | $attribute | : column, name of the column, yb whcih we should order the results |
| string | $flag | : "ASC" or "DESC for ascending order or descending order, |
| Exception | if $flag does not exist |

| resetSettings | ( | ) |
reset settings


| restoreSettings | ( | ) |
restore settings from session

| storeSettings | ( | ) |
store settings in session
| where | ( | $where, | |
$parameter = [], |
|||
$id = null |
|||
| ) |
Adds a where filter.
| string | $where | : any where condition like "sem_classes.overview = 'CoreOverview'" |
| array | $parameter | : an array of parameter that appear in the $where query. |
| null | string | $id | : an id of the where-query. Use this to possibly avoid double where conditions or allow deleting the condition by plugins if necessary. Can be omitted. |
|
staticprotected |
| $max_show_courses = 500 |
| $settings = [] |