Programming quick-reference

From MGWiki

Jump to: navigation, search

Contents

Functions

recDel($path)
helper for recursive deletion

mgw_genID($seq_string,$limit=0)
Generate a new unique identifier. The $seq_string is the full name of the sequence table (ie, mgw__seq_contacts). $limit specifies the minimum number - id's returned which are less than $limit will have $limit added. Calls $conn->genID.

isModuleInstalled($module)
Check if a module is installed.

isModuleActive($module)
Check if a module is active.

getInstalledModules()
Return an array of modules with module information.

checkLogin()
Redirect to index if the user is not logged in.

queryRights2_bool($id_string)
Return whether or not the user has the specified right, checking by user and groups. $id_string is of the form root_modules_contant_contact_create, as shown in the Rights Manager.

queryRights2($id_string)
Calls queryRights2_bool, and display an error page if it returns false.

query_access_module($module)
Queries the accessmodule right for the given module.

get_user_groups()
Return an array of group id's to which the user belongs.

get_user_groups_names()
Returns an array of group names, lowercased and prefixed with @, to which the user belongs.

getUserSettings()
Get global, module, and user settings.

getDateFormate($fmt, $sep) typo: Formate should be Format
Returns a date format string for time if $fmt is "12h" or "24h". Otherwise, returns a date format string.
This function needs cleanup and commenting. Fixes: make sure $fmt is a string. Use $fmt{$i} instead of $fmt[$i] to access individual characters.

connect_database()
Not needed by individual modules.

showSQLerror($sql, $error = , $where_line = , $where_file = )
Display an error report, including sql statement and resulting error. $where_line and $where_file should be __LINE__ and __FILE__, respectively.

showSystemInfo($where_line = , $where_file = )
Show sytem information screen for diagnostics.

redirect($uri)
Generate a redirect header, to the specified (fully qualified) URL.

createSubmenu($menuarray)

get_user_info($user)
Return information about the user from the user table.

create_user_account_on_login($user)

alphabet_table($args="action=alphab",$linkurl="index.php")
Returns an html table with an alphabet, depending on the user's charset. $args and $link are used to create links for each character: <a href=\"$linkurl?$args&list=".urlencode($at[$i])."&".SID."\">

revisionInit($revision, $file)
Register the revision of the file.

getIconStrings()
Returns an array with image links for new, details, edit, private, prev, next, and space if iconmode is set, text if not.

createCountrySB ($sbname, $selected="")
Create a country select box.

isValidInetAddress($data, $strict = false)
If $data is a valid email address of the form <user>@<domain>, returns a two-element array, the first of which is the username, and the second is the domain. Otherwise, returns false. If $strict is true, the allowed characters are restricted to alphanumeric (0-9, a-z), periods, hyphens, and underscores. Regardless of the strict setting, the tld must be 2-4 characters (currently, this only breaks for the .museum tld).

inList($in_list,$item)
Puts commas around both items, and checks if $item is in $in_list. Useful if $in_list is a comma-separated list.
This possibly should check if strpos() === FALSE instead of strstr

get_definition_data_from_xml($thefile)

get_definition_countries_from_xml($thefile)

execute_xml_schema($thefile,$module,$dbvendor)

indentSubTagsRec($officeBody,$depth=1)

indentSubTags($officeBody)

show_print_r($var)
print_r in <pre> tags.

set_default_rights($parent,$tree)

set_default_rights_admin($parent,$tree)

browser_detect()
Return a string based on the browser useragent.

stripslashes_array($val)
Recursively stripslashes on all elements of an array.

get_remote_addr()
Return client IP.

L_($v)
return Lang::getLanguageString($v);

Constants

  • ROOTPATH - filesystem base path to moregroupware
  • SMARTY_DIR - path to smarty
  • INCLUDE_DIR - ROOTPATH/include/
  • ROOTURL - base url to moregroupware, including trailing slash
  • centralized storage/cache directories (data_store/$module/)
    • STORE_FOLDER
    • STORE_URL
    • CACHE_FOLDER
    • CACHE_URL

Session Variables

  • $_SESSION['lastin'] - last login time before current
  • $_SESSION['checkip'] - (bool)
  • $_SESSION['remoteip'] - user's ip
  • $_SESSION['http_user_agent'] - browser
  • $_SESSION['MGW']->userid
  • $_SESSION['MGW']->username
  • $_SESSION['MGW']->fullusername
  • $_SESSION['MGW']->email
  • $_SESSION['MGW']->groups
  • $_SESSION['MGW']->groups_names
  • $_SESSION['MGW']->spkz - language code
  • $_SESSION['MGW']->charset
  • $_SESSION['MGW']->login
  • $_SESSION['MGW']->password
  • $_SESSION['MGW']->browser
  • $_SESSION['MGW']->modules - mgw installed modules

Smarty Variables

  • rooturl - web root
  • rootpath - document root
  • phpself - name of the current script
  • theme - theme (from setup)
  • skin - current skin (css)
  • username - login name
  • fullusername - full name
  • imgpath - path to media in current template of the current module
  • imgpathgeneral - path to media in current template of the general module
  • imgpathmaster - same as $imgpathgeneral
  • genpath - path to $theme in general module
  • gentemplates - $myEnv["output"] in $genpath
  • show_navi_images
  • modulecss - module.css in media of template
  • actmodule - module name
  • actsubmenu - $myEnv["submenu'] or 0
  • actlabel - $myEnv["label"]
  • showadmin - $myEnv["admin"]
  • gwversion - "[Release $gwversion]"
  • gwtitle - $gwtitle
  • charset - $_SESSION["MGW"]->charset

Smarty Plugins

Smarty Variable Modifiers

mgw_date
Formats the timestamp according to user settings, returning only the date portion

mgw_time
Formats the timestamp according to user settings, returning only the time portion

mgw_datetime
Formats the timestamp according to user settings

mgw_linkalize
Make all URL's into links. If the "use_webmail" setting is set, also turn all email addresses into links to open a new webmail message.

Smarty Functions

datepick
Generates a popup date-picker. Requires datepick.js (included by the default _header.tpl)

  • form = name of the form which values are returned to
  • field = comma-separated list of fields for year, month, and day (eg, StartYear,StartMonth,StartDay)

mgw_select_date
Appears to be the same as the smarty custom function html_select_date.

Smarty Output Filters

smarty_outputfilter_mgw_end_log
Automatically logs "Smarty sending output for module ...". Activated by default.

Personal tools