Stud.IP  5.4
 All Data Structures Namespaces Files Functions Variables Groups
functions.php File Reference

Namespaces

 studip_cores
 

Functions

 get_object_name ($range_id, $object_type)
 
 get_object_by_range_id ($range_id)
 
 checkObject ()
 
 checkObjectModule ($module, $is_plugin_name=false)
 
 closeObject ()
 
 get_object_type ($id, $check_only=[])
 
 select_group ($sem_start_time)
 
 my_substr ($what, $start, $end)
 
 get_fullname ($user_id="", $format="full", $htmlready=false)
 
 get_fullname_from_uname ($uname="", $format="full", $htmlready=false)
 
 get_username ($user_id="")
 
 get_userid ($username="")
 
 get_sem_tree_path ($seminar_id, $depth=false, $delimeter=">")
 
 check_and_set_date ($tag, $monat, $jahr, $stunde, $minute, &$arr, $field)
 
 get_config ($key)
 
 re_sort_dozenten ($s_id, $position)
 
 re_sort_tutoren ($s_id, $position)
 
 get_next_position ($status, $seminar_id)
 
 StringToFloat ($str)
 
 archiv_check_perm ($seminar_id)
 
 get_users_online ($active_time=5, $name_format= 'full_rev')
 
 get_users_online_count ($active_time=10)
 
 get_ticket ()
 
 check_ticket ($studipticket)
 
 search_range ($search_str=false, $search_user=false, $show_sem=true)
 
 format_help_url ($keyword)
 
 words ($what)
 
 legacy_studip_utf8decode ($data)
 
 studip_json_decode ($json, $assoc=true, $depth=512, $options=0)
 
 studip_json_encode ($data, $options=0)
 
 encode_header_parameter ($name, $value)
 
 get_title_for_status ($type, $count, $sem_type=NULL)
 
 is_internal_url ($url)
 
 studygroup_sem_types ()
 
 addHiddenFields ($variable, $data, $parent=[])
 
 array_flatten ($ary)
 
 reltime ($timestamp, $verbose=true, $displayed_levels=1, $tolerance=5)
 
 relsize ($size, $verbose=true, $displayed_levels=1, $glue= ', ', $truncate=false)
 
 get_route ($route= '')
 
 match_route ($requested_route, $current_route= '')
 
 studip_default_exception_handler ($exception)
 
 strtocamelcase ($string, $ucfirst=false)
 
 strtosnakecase ($string)
 
 strtokebabcase ($string)
 
 count_table_rows ($table)
 
 studip_relative_path ($filepath)
 
 array_to_csv ($data, $filename=null, $caption=null, $delimiter= ';', $enclosure= '"', $eol = "\r\n", $add_bom = true )
 
 rmdirr ($dirname)
 
 get_mime_types ()
 
 get_mime_type ($filename)
 
 readfile_chunked ($filename, $start=null, $end=null)
 
 get_default_http_stream_context ($url= '')
 
 encodeURI (string $uri)
 
 randomString (int $length=32)
 

Function Documentation

addHiddenFields (   $variable,
  $data,
  $parent = [] 
)

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
archiv_check_perm (   $seminar_id)

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

array $perm object $auth array $archiv_perms

Parameters
string$seminar_idthe seminar in the archive
Returns
string the perm the user had
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
array_to_csv (   $data,
  $filename = null,
  $caption = null,
  $delimiter = ';',
  $enclosure = '"',
  $eol = "\r\n",
  $add_bom = true 
)

converts a given array to a csv format

Parameters
array$datathe data to convert, each row should be an array
string$filenamefull path to a file to write to, if omitted the csv content is returned
array$captionassoc array with captions, is written to the first line, $data is filtered by keys
string$delimitersets the field delimiter (one character only)
string$enclosuresets the field enclosure (one character only)
string$eolsets the end of line format
Returns
mixed if $filename is given the number of written bytes, else the csv content as string
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 (   $studipticket)

check if the passed ticket is valid

Parameters
string$studipticketthe ticket-id to check
Returns
bool
checkObject ( )

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

Exceptions
CheckObjectException
Returns
void
checkObjectModule (   $module,
  $is_plugin_name = false 
)

This function checks, if given module is allowed for this stud.ip-object.

Exceptions
CheckObjectException
Parameters
string$modulethe module to check for
bool$is_plugin_nameis the module name old style ( "wiki","scm") or new style (the name of the plugin)
Returns
StudipModule
closeObject ( )

This function closes a opened Veranstaltung or Einrichtung

Returns
void
count_table_rows (   $table)

fetch number of rows for a table for innodb this is not exact, but much faster than count(*)

Parameters
string$tablename of database table
Returns
int number of rows
encode_header_parameter (   $name,
  $value 
)

Encode an HTTP header parameter (e.g. filename for 'Content-Disposition').

Parameters
string$nameparameter name
string$valueparameter value
Returns
string encoded header text (using RFC 2616 or 5987 encoding)
encodeURI ( string  $uri)

Encodes an uri just like encodeURI() in Javascript would do.

encodeURI() escapes all characters except:

A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #
Parameters
string$uri
Returns
string
See Also
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
format_help_url (   $keyword)

format_help_url($keyword) returns URL for given help keyword

Parameters
string$keywordthe help-keyword
Returns
string the help-url
get_config (   $key)

gets an entry from the studip configuration table

Parameters
string$keythe key for the config entry
Returns
string the value
get_default_http_stream_context (   $url = '')
Parameters
string$url
Returns
resource
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
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
get_mime_type (   $filename)

Determines an appropriate MIME type for a file based on the extension of the file name.

Parameters
string$filenamefile name to check
get_mime_types ( )

Returns the mapping of extensions to supported MIME types.

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
get_object_by_range_id (   $range_id)

Returns a sorm object for a given range_id

Parameters
stringthe range_id
Returns
bool|SimpleORMap Course/Institute/User/Statusgruppen/
get_object_name (   $range_id,
  $object_type 
)

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

array $SEM_TYPE array $INST_TYPE 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
get_object_type (   $id,
  $check_only = [] 
)

This function determines the type of the passed id

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

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)
get_route (   $route = '')

extracts route

Parameters
string$routeroute (optional, uses REQUEST_URI otherwise)
Returns
string route
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
get_ticket ( )

return a studip-ticket

Returns
string a unique id referring to a newly created ticket
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.

array $SEM_TYPE 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
get_userid (   $username = "")

Retrieves the userid for a given username

uses global $online array if user is online

object $auth array $cache

Parameters
string$usernameif omitted, current user_id will be returned
Returns
string
get_username (   $user_id = "")

Retrieves the username for a given user_id

object $auth array $cache

Parameters
string$user_idif omitted, current username will be returned
Returns
string
get_users_online (   $active_time = 5,
  $name_format = 'full_rev' 
)

retrieve a list of all online users

object $user array $_fullname_sql

Parameters
int$active_timefilter: the time in minutes until last life-sign
string$name_formatformat the fullname shall have
Returns
array
get_users_online_count (   $active_time = 10)

get the number of currently online users

Parameters
int$active_timefilter: the time in minutes until last life-sign
Returns
int
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
legacy_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
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
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 mb_substr function.

Parameters
string$whatthe original string
integer$startstart pos, 0 is the first pos
integer$endend pos
Returns
string
randomString ( int  $length = 32)
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
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
readfile_chunked (   $filename,
  $start = null,
  $end = null 
)
relsize (   $size,
  $verbose = true,
  $displayed_levels = 1,
  $glue = ',
,
  $truncate = false 
)

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.
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
rmdirr (   $dirname)

Delete a file, or a folder and its contents

Author
Aidan Lister aidan.nosp@m.@php.nosp@m..net
Version
1.0
Parameters
string$dirnameThe directory to delete
Returns
bool Returns true on success, false on failure
search_range (   $search_str = false,
  $search_user = false,
  $show_sem = true 
)

searches

array $perm object $user 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
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
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
strtocamelcase (   $string,
  $ucfirst = false 
)

Converts a string to camelCase.

Parameters
String$stringThe string that should be converted
bool$ucfirstUppercase the very first character as well (optional, defaults to false)
Returns
String containing the converted input string
strtokebabcase (   $string)

Converts a string to kebab-case.

Parameters
String$stringThe string that should be converted
Returns
String containing the converted input string
strtosnakecase (   $string)

Converts a string to snake_case.

Parameters
String$stringThe string that should be converted
Returns
String containing the converted input string
studip_default_exception_handler (   $exception)
studip_json_decode (   $json,
  $assoc = true,
  $depth = 512,
  $options = 0 
)

Special stud.ip version of json_decode() that also converts the data from utf8 and creates an associative array by default (this differs from the default behavior of json_decode() !).

Parameters
String$json
bool$assoc
int$depth
int$options
studip_json_encode (   $data,
  $options = 0 
)

Special stud.ip version of json_decode() that also converts the data to utf8.

Parameters
mixed$data
int$options
int$depth
studip_relative_path (   $filepath)

get the file path relative to the STUDIP_BASE_PATH

Parameters
stringpath of the file
Returns
string relative path of the file
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
words (   $what)

Splits a string by space characters and returns these words as an array. If an array is given, returns the array itself.

Parameters
mixed$whatwhat to split
Returns
array the words of the string as array