Stud.IP  jlu_3.3 Revision
functions.php File Reference

Namespaces

namespace  studip_cores
 

Functions

 getHeaderLine ($id, $object_name=null)
 
 get_object_name ($range_id, $object_type)
 
 get_object_by_range_id ($range_id)
 
 selectSem ($sem_id)
 
 selectInst ($inst_id)
 
 openSem ($sem_id)
 
 openInst ($inst_id)
 
 checkObject ()
 
 checkObjectModule ($module)
 
 closeObject ()
 
 get_object_type ($id, $check_only=array())
 
 select_group ($sem_start_time)
 
 my_substr ($what, $start, $end)
 
 get_global_perm ($user_id="")
 
 get_perm ($range_id, $user_id="")
 
 get_fullname ($user_id="", $format="full", $htmlready=false)
 
 get_fullname_from_uname ($uname="", $format="full", $htmlready=false)
 
 get_vorname ($user_id="")
 
 get_nachname ($user_id="")
 
 get_username ($user_id="")
 
 get_userid ($username="")
 
 TrackAccess ($id, $object_type=null)
 
 get_sem_tree_path ($seminar_id, $depth=false, $delimeter=">")
 
 get_range_tree_path ($institut_id, $depth=false, $delimeter=">")
 
 check_and_set_date ($tag, $monat, $jahr, $stunde, $minute, &$arr, $field)
 
 write_config ($key, $val, $arr=null)
 
 get_config ($key)
 
 get_seminar_dozent ($seminar_id)
 
 re_sort_dozenten ($s_id, $position)
 
 re_sort_tutoren ($s_id, $position)
 
 get_next_position ($status, $seminar_id)
 
 get_seminar_tutor ($seminar_id)
 
 get_seminar_sem_tree_entries ($seminar_id)
 
 get_seminars_user ($user_id)
 
 StringToFloat ($str)
 
 archiv_check_perm ($seminar_id)
 
 get_users_online ($active_time=5, $name_format='full_rev')
 
 get_users_online_count ($active_time=5)
 
 get_ticket ()
 
 check_ticket ($studipticket)
 
 search_range ($search_str=false, $search_user=false, $show_sem=true)
 
 format_help_url ($keyword)
 
 remove_magic_quotes ($mixed)
 
 text_excerpt ($text, $phrase, $radius=100, $length=200, $excerpt_string='...')
 
 words ($string)
 
 studip_utf8encode ($data)
 
 studip_utf8decode ($data)
 
 get_title_for_status ($type, $count, $sem_type=NULL)
 
 studip_substr ($string, $offset, $length=false)
 
 studip_strlen ($string)
 
 is_internal_url ($url)
 
 studygroup_sem_types ()
 
 addHiddenFields ($variable, $data, $parent=array())
 
 array_flatten ($ary)
 
 reltime ($timestamp, $verbose=true, $displayed_levels=1, $tolerance=5)
 
 relsize ($size, $verbose=true, $displayed_levels=1, $glue=', ')
 
 get_route ($route='')
 
 match_route ($requested_route, $current_route='')
 
 studip_default_exception_handler ($exception)
 

Function Documentation

◆ addHiddenFields()

addHiddenFields (   $variable,
  $data,
  $parent = array() 
)

generates form fields for the submitted multidimensional array

Parameters
string$variablethe name of the array, which is filled with the data
mixed$datathe data-array
mixed$parentleave this entry as is
Returns
string the inputs of type hidden as html
Here is the call graph for this function:
Here is the caller graph for this function:

◆ archiv_check_perm()

archiv_check_perm (   $seminar_id)

check which perms the currently logged in user had in the passed archived seminar

@global array $perm @global object $auth @staticvar array $archiv_perms

Parameters
string$seminar_idthe seminar in the archive
Returns
string the perm the user had
Here is the call graph for this function:

◆ array_flatten()

array_flatten (   $ary)

Returns a new array that is a one-dimensional flattening of this array (recursively). That is, for every element that is an array, extract its elements into the new array.

Parameters
array$arythe array to be flattened
Returns
array the flattened array
Here is the caller graph for this function:

◆ check_and_set_date()

check_and_set_date (   $tag,
  $monat,
  $jahr,
  $stunde,
  $minute,
$arr,
  $field 
)

check_and_set_date

Checks if given date is valid and sets field in array accordingly. (E.g. $admin_admission_data['admission_enddate'])

Parameters
mixed$tagday or placeholder for day
mixed$monatmonth or placeholder for month
mixed$jahryear or placeholder for year
mixed$stundehours or placeholder for hours
mixed$minuteminutes or placeholder for minutes
array&$arrReference to array to update. If NULL, only check is performed
mixed$fieldName of field in array to be set
Returns
bool true if date was valid, false else

◆ check_ticket()

check_ticket (   $studipticket)

check if the passed ticket is valid

Parameters
string$studipticketthe ticket-id to check
Returns
bool
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkObject()

checkObject ( )

This function checks, if there is an open Veranstaltung or Einrichtung

@global array $SessSemName

Exceptions
CheckObjectException
Returns
void
Here is the caller graph for this function:

◆ checkObjectModule()

checkObjectModule (   $module)

This function checks, if given old style module "wiki","scm" (not "CoreWiki") etc. is allowed in this stud.ip-object.

@global array $SessSemName

Parameters
string$modulethe module to check for
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeObject()

closeObject ( )

This function closes a opened Veranstaltung or Einrichtung

@global string $SessionSeminar @global array $SessSemName @global string $SemSecLevelRead @global string $SemSecLevelWrite @global string $SemUserStatus @global boolean $rechte @global object $sess

Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_help_url()

format_help_url (   $keyword)

format_help_url($keyword) returns URL for given help keyword

Parameters
string$keywordthe help-keyword
Returns
string the help-url
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_config()

get_config (   $key)

gets an entry from the studip configuration table

Parameters
string$keythe key for the config entry
Returns
string the value
Here is the call graph for this function:

◆ get_fullname()

get_fullname (   $user_id = "",
  $format = "full",
  $htmlready = false 
)

Retrieves the fullname for a given user_id

Parameters
string$user_idif omitted, current user_id is used
string$formatoutput format
bool$htmlreadyif true, htmlReady is applied to all output-strings
Returns
string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_fullname_from_uname()

get_fullname_from_uname (   $uname = "",
  $format = "full",
  $htmlready = false 
)

Retrieves the fullname for a given username

Parameters
string$unameif omitted, current user_id is used
string$formatoutput format
bool$htmlreadyif true, htmlReady is applied to all output-strings
Returns
string
Examples
/usr/local/src/studip/jlu_3.3/lib/visual.inc.php.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_global_perm()

get_global_perm (   $user_id = "")

The function gives the global perm of an user

It ist recommended to use $auth->auth["perm"] for this query, but the function is useful, if you want to query an user_id from another user (which ist not the current user)

Deprecated:
use $GLOBALS['perm']->get_perm($user_id)
Parameters
string$user_idif omitted, current user_id is used
Returns
string the perm level or an error msg
Here is the caller graph for this function:

◆ get_nachname()

get_nachname (   $user_id = "")

Retrieves the Nachname for a given user_id

Parameters
string$user_idif omitted, current user_id is used
Returns
string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_next_position()

get_next_position (   $status,
  $seminar_id 
)

return the highest position-number increased by one for the passed user-group in the passed seminar

Parameters
string$statuscan be on of 'tutor', 'dozent', ...
string$seminar_idthe seminar to work on
Returns
int the next available position
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_by_range_id()

get_object_by_range_id (   $range_id)

Returns a sorm object for a given range_id

Parameters
stringthe range_id
Returns
SimpleORMap Course/Institute/User/Statusgruppen/
Here is the call graph for this function:

◆ get_object_name()

get_object_name (   $range_id,
  $object_type 
)

returns an array containing name and type of the passed objeact denoted by $range_id

@global array $SEM_TYPE @global array $INST_TYPE @global array $SEM_TYPE_MISC_NAME

Parameters
string$range_idthe id of the object
string$object_typethe type of the object
Returns
array an array containing name and type of the object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_type()

get_object_type (   $id,
  $check_only = array() 
)

This function determines the type of the passed id

The function recognizes the following types at the moment: Einrichtungen, Veranstaltungen, Statusgruppen and Fakultaeten

@staticvar array $object_type_cache

Parameters
string$idthe id of the object
array$check_onlyan array to narrow the search, may contain 'sem', 'inst', 'fak', 'group' or 'dokument' (optional)
Returns
string return "inst" (Einrichtung), "sem" (Veranstaltung), "fak" (Fakultaeten), "group" (Statusgruppe), "dokument" (Dateien)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_perm()

get_perm (   $range_id,
  $user_id = "" 
)

Returns permission for given range_id and user_id

Function works for Veranstaltungen, Einrichtungen, Fakultaeten. admins get status 'admin' if range_id is a seminar

Deprecated:
use $GLOBALS['perm']->get_studip_perm($range_id, $user_id)
Parameters
string$range_idan id a Veranstaltung, Einrichtung or Fakultaet
string$user_idif omitted,current user_id is used
Returns
string the perm level
Here is the caller graph for this function:

◆ get_range_tree_path()

get_range_tree_path (   $institut_id,
  $depth = false,
  $delimeter = ">" 
)

Return an array containing the nodes of the range-tree-path

Parameters
string$institut_idthe institute to get the path for
int$depththe depth
string$delimetera string to separate the path parts
Returns
array
Here is the call graph for this function:

◆ get_route()

get_route (   $route = '')

extracts route

Parameters
string$routeroute (optional, uses REQUEST_URI otherwise)
Returns
string route
Here is the caller graph for this function:

◆ get_sem_tree_path()

get_sem_tree_path (   $seminar_id,
  $depth = false,
  $delimeter = ">" 
)

Return an array containing the nodes of the sem-tree-path

Parameters
string$seminar_idthe seminar to get the path for
int$depththe depth
string$delimetera string to separate the path parts
Returns
array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_seminar_dozent()

get_seminar_dozent (   $seminar_id)

get the lecturers and their order-positions in the passed seminar

folgende Funktion ist nur notwendig, wenn die zu kopierende Veranstaltung nicht vom Dozenten selbst, sondern vom Admin oder vom root kopiert wird (sonst wird das Dozentenfeld leer gelassen, was ja keiner will...)

Parameters
string$seminar_idthe seminar to get the lecturers from
Returns
array an array containing user_ids as key and positions as value
Here is the call graph for this function:

◆ get_seminar_sem_tree_entries()

get_seminar_sem_tree_entries (   $seminar_id)

return all sem_tree-entries for the passed seminar

Parameters
string$seminar_idthe seminar
Returns
array a list of sem_tree_id's

◆ get_seminar_tutor()

get_seminar_tutor (   $seminar_id)

get the tutors and their order-positions in the passed seminar

Parameters
string$seminar_idthe seminar to get the tutors from
Returns
array an array containing user_ids as key and positions as value
Here is the call graph for this function:

◆ get_seminars_user()

get_seminars_user (   $user_id)

return an array of all seminars for the passed user, containing the name, id, makedate and sem-number.

Parameters
string$user_idthe user's id
Returns
array the user seminars as an array of four fields
Here is the call graph for this function:

◆ get_ticket()

get_ticket ( )

return a studip-ticket

Returns
string a unique id referring to a newly created ticket
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_title_for_status()

get_title_for_status (   $type,
  $count,
  $sem_type = NULL 
)

Get the title used for the given status ('dozent', 'tutor' etc.) for the specified SEM_TYPE. Alternative titles can be defined in the config.inc.php.

@global array $SEM_TYPE @global array $SessSemName @global array $DEFAULT_TITLE_FOR_STATUS

Parameters
string$typestatus ('dozent', 'tutor', 'autor', 'user' or 'accepted')
int$countcount, this determines singular or plural form of title
int$sem_typesem_type of course (defaults to type of current course)
Returns
string translated title for status
Here is the caller graph for this function:

◆ get_userid()

get_userid (   $username = "")

Retrieves the userid for a given username

uses global $online array if user is online

@global object $auth @staticvar array $cache

Parameters
string$usernameif omitted, current user_id will be returned
Returns
string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_username()

get_username (   $user_id = "")

Retrieves the username for a given user_id

@global object $auth @staticvar array $cache

Parameters
string$user_idif omitted, current username will be returned
Returns
string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_users_online()

get_users_online (   $active_time = 5,
  $name_format = 'full_rev' 
)

retrieve a list of all online users

@global object $user @global array $_fullname_sql

Parameters
int$active_timefilter: the time in minutes until last life-sign
string$name_formatformat the fullname shall have
Returns
array
Here is the call graph for this function:

◆ get_users_online_count()

get_users_online_count (   $active_time = 5)

get the number of currently online users

Parameters
int$active_timefilter: the time in minutes until last life-sign
Returns
int
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vorname()

get_vorname (   $user_id = "")

Retrieves the Vorname for a given user_id

Parameters
string$user_idif omitted, current user_id is used
Returns
string
Here is the call graph for this function:

◆ getHeaderLine()

getHeaderLine (   $id,
  $object_name = null 
)

This function creates the header line for studip-objects

you will get a line like this "Veranstaltung: Name..."

Parameters
string$idthe id of the Veranstaltung
string$object_namethe name of the object (optional)
Returns
string the header-line
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_internal_url()

is_internal_url (   $url)

Test whether the given URL refers to some page or resource of this Stud.IP installation.

Parameters
string$urlurl to check
Returns
mixed
Here is the caller graph for this function:

◆ match_route()

match_route (   $requested_route,
  $current_route = '' 
)

compares actual route to requested route

Parameters
string$requested_routerequested route (for help content or tour)
string$current_routecurrent route (optional)
Returns
boolean result
Here is the call graph for this function:
Here is the caller graph for this function:

◆ my_substr()

my_substr (   $what,
  $start,
  $end 
)

The function shortens a string, but it uses the first 2/3 and the last 1/3

The parts will be divided by a "[...]". The functions is to use like php's substr function.

Parameters
string$whatthe original string
integer$startstart pos, 0 is the first pos
integer$endend pos
Returns
string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openInst()

openInst (   $inst_id)

This function "opens" an institute to work with it. Does the same as selectInst() but also sets the visit date.

Parameters
string$inst_idthe id of the institute
Returns
boolean true if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openSem()

openSem (   $sem_id)

This function "opens" a course to work with it. Does the same as selectSem() but also sets the visit date.

Parameters
string$sem_idthe id of the course
Returns
boolean true if successful
Here is the call graph for this function:

◆ re_sort_dozenten()

re_sort_dozenten (   $s_id,
  $position 
)

reset the order-positions for the lecturers in the passed seminar, starting at the passed position

Parameters
string$s_idthe seminar to work on
int$positionthe position to start with
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ re_sort_tutoren()

re_sort_tutoren (   $s_id,
  $position 
)

reset the order-positions for the tutors in the passed seminar, starting at the passed position

Parameters
string$s_idthe seminar to work on
int$positionthe position to start with
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relsize()

relsize (   $size,
  $verbose = true,
  $displayed_levels = 1,
  $glue = ',
 
)

Displays a filesize in a (shortened) human readable form including the according units. For instance, 1234567 would be displayed as "1 MB" or 12345 would be displayed as "12 kB". The function can display the units in a short or a long form ("1 b" vs. "1 Byte"). Optionally, more than one unit part can be displayed. For instance, 1234567 could also be displayed as "1 MB, 234 kB, 567 b".

Parameters
int$sizeThe raw filesize as integer
bool$verboseUse short or long unit names
int$displayed_levelsHow many unit parts should be displayed
String$glueText used to glue the different unit parts together
Returns
String The filesize in human readable form.
Todo:
Allow "1,3 MB"
Here is the caller graph for this function:

◆ reltime()

reltime (   $timestamp,
  $verbose = true,
  $displayed_levels = 1,
  $tolerance = 5 
)

Displays "relative time" - a textual representation between now and a certain timestamp, e.g. "3 hours ago".

Parameters
int$timestampTimestamp to relate to.
bool$verboseDisplay long or short texts (optional)
int$displayed_levelsHow many levels shall be displayed
int$toleranceDefines a tolerance area of seconds around now (How many seconds must have passed until the function won't return "now")
Returns
String Textual representation of the difference between the passed timestamp and now
Here is the caller graph for this function:

◆ remove_magic_quotes()

remove_magic_quotes (   $mixed)

Remove slashes if magic quotes are enabled

Parameters
mixed$mixedstring or array to strip slashes from
Returns
mixed cleaned string or array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_range()

search_range (   $search_str = false,
  $search_user = false,
  $show_sem = true 
)

searches

@global array $perm @global object $user @global array $_fullname_sql

Parameters
string$search_stroptional search-string
string$search_useroptional user to search for
bool$show_semif true, the seminar is added to the result
Returns
array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_group()

select_group (   $sem_start_time)

This function calculates one of the group colors unique for the semester of the passed timestamp

It calculates a unique color number to create the initial entry for a new user in a seminar. It will create a unique number for every semester and will start over, if the max. number (7) is reached.

Parameters
integer$sem_start_timethe timestamp of the start time from the Semester
Returns
integer the color number
Here is the caller graph for this function:

◆ selectInst()

selectInst (   $inst_id)

This function "selects" an Einrichtung to work with it

Note: Stud.IP treats Einrichtungen like Veranstaltungen, yu can see this especially if you look at the variable names....

The following variables will bet set: $SessionSeminar Einrichtung id
$SessSemName[0] Einrichtung name
$SessSemName[1] Einrichtung id
$SessSemName["art"] Einrichtung type in alphanumeric form
$SessSemName["art_num"] Einrichtung type in numeric form
$SessSemName["art_generic"] Einrichtung generic type in alhanumeric form (self description)
$SessSemName["class"] Einrichtung class (sem or inst, in this function always inst)
$SessSemName["header_line"] the header-line to use on every page of the Einrichtung

Parameters
string$inst_idthe id of the Veranstaltung
Returns
boolean true if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectSem()

selectSem (   $sem_id)

This function "selects" a Veranstaltung to work with it

The following variables will bet set: $SessionSeminar Veranstaltung id
$SessSemName[0] Veranstaltung name
$SessSemName[1] Veranstaltung id
$SessSemName[2] Veranstaltung ort (room)
$SessSemName[3] Veranstaltung Untertitel (subtitle)
$SessSemName[4] Veranstaltung start_time (the Semester start_time)
$SessSemName[5] Veranstaltung institut_id (the home-intitute)
$SessSemName["art"] Veranstaltung type in alphanumeric form
$SessSemName["art_num"] Veranstaltung type in numeric form
$SessSemName["art_generic"] Veranstaltung generic type in alhanumeric form (self description)
$SessSemName["class"] Veranstaltung class (sem or inst, in this function always sem)
$SessSemName["header_line"] the header-line to use on every page of the Veranstaltung

Parameters
string$sem_idthe id of the Veranstaltung
Returns
boolean true if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StringToFloat()

StringToFloat (   $str)

converts a string to a float, depending on the locale

Parameters
string$strthe string to convert to float
Returns
float the string casted to float

◆ studip_default_exception_handler()

studip_default_exception_handler (   $exception)
Here is the call graph for this function:

◆ studip_strlen()

studip_strlen (   $string)

Stud.IP encoding aware version of good ol' strlen(), treats numeric HTML-ENTITIES as one character use only if really necessary

Parameters
string$stringthe string to measure
Returns
integer the number of characters in string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ studip_substr()

studip_substr (   $string,
  $offset,
  $length = false 
)

Stud.IP encoding aware version of good ol' substr(), treats numeric HTML-ENTITIES as one character use only if really necessary

Parameters
string$stringstring to shorten
integer$offsetposition to start with
integer$lengthmaximum length
Returns
string the part of the string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ studip_utf8decode()

studip_utf8decode (   $data)

Encodes a string or array from UTF-8 to Stud.IP encoding (WINDOWS-1252/ISO-8859-1 with numeric HTML-ENTITIES)

Parameters
mixed$dataa string in UTF-8 or an array with all strings encoded in utf-8
Returns
string the string in WINDOWS-1252/HTML-ENTITIES
Here is the call graph for this function:
Here is the caller graph for this function:

◆ studip_utf8encode()

studip_utf8encode (   $data)

Encodes a string or array from Stud.IP encoding (WINDOWS-1252/ISO-8859-1 with numeric HTML-ENTITIES) to UTF-8

Parameters
mixed$dataa string or an array with strings to encode in WINDOWS-1252/HTML-ENTITIES
Returns
string the string in UTF-8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ studygroup_sem_types()

studygroup_sem_types ( )

Return the list of SEM_TYPES that represent study groups in this Stud.IP installation.

Returns
array list of SEM_TYPES used for study groups
Here is the caller graph for this function:

◆ text_excerpt()

text_excerpt (   $text,
  $phrase,
  $radius = 100,
  $length = 200,
  $excerpt_string = '...' 
)

Extracts an excerpt from the 'text' surrounding the 'phrase' with a number of characters on each side determined by 'radius'. If the phrase isn't found, null is returned. Ex: text_excerpt("hello my world", "my", 3) => "...lo my wo..."

Parameters
string$textthe text to excerpt
string$phrasethe search phrase
integer$radiusthe radius around the phrase
integer$lengththe maximum length of the excerpt string
string$excerpt_stringthe excerpt string
Returns
string

◆ TrackAccess()

TrackAccess (   $id,
  $object_type = null 
)

This function tracks user acces to several Data (only dokuments by now, to be extended)

Parameters
string$idthe id of the object to track
string$object_typethe object type (optional)
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ words()

words (   $string)

Splits a string by space characters and returns these words as an array.

Parameters
string$stringthe string to split
Returns
array the words of the string as array
Examples
/usr/local/src/studip/jlu_3.3/lib/visual.inc.php.
Here is the caller graph for this function:

◆ write_config()

write_config (   $key,
  $val,
  $arr = null 
)

writes an entry into the studip configuration table

Deprecated:
Parameters
string$keythe key for the config entry
string$valthe value that should be set
array$arran array with key=>value to write into config
Returns
bool true if date was valid, else false
Here is the call graph for this function:
Here is the caller graph for this function: