PHP Functions

  • Overview

    There are a lot of functions provided to developers for use in their modules by the Jamroom core and by other modules that are active.

    We debated listing all functions up here for reference, but decided against it as the functions are constantly changing.

    The location for the docs on the functions is in the code base itself. All the functions are commented on and each has a docblock section to allow quick reference from within any modern IDE.

    The IDE of choice of the Jamroom Network Team is PhpStorm
    With modern IDE's all function information can be retrieved to get info on related to how it works.
  • Examples

    A quick look through the index.php or the include.php files of any module will quickly show many functions that are used over and over in module development.

    In PhpStorm you can get the documentation for that function via the docblock reference lookup feature. Ctrl+q while looking at the function.

    eg: jrCore_checktype()

    jrCore_checktype is a function that is used to verify that the contents of the variable are what is expected.

    The jrCore_checktype function takes the variable as its first parameter and the checktype as its second.

    The types of checktype that are available are:
    * allowed_html - Ensures value is a string and is allowed to contain HTML allowed in the profile's quota
    * core_string - the numbers 0-9, letters a-z and _ (underscore)
    * date - a valid date
    * domain - a valid domain name (no www)
    * email - a valid email address
    * float - a floating point number
    * hex - a hexadecimal value
    * ip_address - a valid IP Address
    * is_true - boolean TRUE or int or string "1"
    * md5 - valid 32 character long MD5 hash
    * multi_word - a string with more than 1 word
    * not_empty - a string of any length
    * number - an integer
    * number_nn - an integer greater than or equal to zero (0)
    * number_nz - an integer greater than or equal to one (1)
    * onoff - either "on" or "off"
    * price - a price in D.CC format
    * printable - UTF-8 characters with HTML stripped
    * sha1 - a 40 character SHA1 hash
    * string - a string that does not contain HTML or hidden characters
    * url - a valid URL
    * url_name - the numbers 0-9, letters a-z, _ and - (dash)
    * user_name - the numbers 0-9, letters a-z, _ (underscore), - (dash) and spaces
    * file_name - string that can contain a . (dot)
    * yesno - "yes" or "no"
    * json - check if a string is json or not

    We can see this too when we use the ctrl+q option on the function
  • screenshot of the ctrl+q feature in phpstorm on the jrCore_checktype() function to show the docblock
  • We think the best place to get up-to-date function information is from the latest codebase as this will always be accurate for whatever version of the software you are using on your site.
  • Commonly used functions

    jrCore_module_is_active()
    jrCore_add_to_cache()
    jrCore_checktype()
    jrCore_create_page_element()
    jrCore_db_create_item()
    jrCore_db_update_item()
    jrCore_db_delete_item()
    jrCore_db_escape()
    jrCore_db_get_item()
    jrCore_db_get_multiple_items()
    jrCore_db_get_prefix()
    jrCore_db_query()
    jrCore_db_search_items()
    jrCore_db_table_name()
    jrCore_db_update_item()
    jrCore_delete_all_cache_entries()
    jrCore_delete_flag()
    jrCore_form_create()
    jrCore_form_field_create()
    jrCore_form_result()
    jrCore_get_flag()
    jrCore_get_form_notice()
    jrCore_get_module_url()
    jrCore_get_temp_value()
    jrCore_json_response()
    jrCore_location()
    jrCore_logger()
    jrCore_notice()
    jrCore_page_admin_tabs()
    jrCore_page_banner()
    jrCore_page_button()
    jrCore_page_cancel_button()
    jrCore_page_custom()
    jrCore_page_display()
    jrCore_page_include_admin_menu()
    jrCore_page_table_header()
    jrCore_page_table_row()
    jrCore_page_table_footer()
    jrCore_parse_email_templates()
    jrCore_parse_template()
    jrCore_set_flag()
    jrCore_set_form_notice()
    jrCore_set_temp_value()
    jrCore_strip_html()
    jrCore_trigger_event()
    jrCore_validate_location_url()
    jrProfile_is_profile_owner()
    jrProfile_reset_cache()
    jrProfile_reset_cache()
    jrProfile_reset_cache()
    jrUser_admin_only()
    jrUser_can_edit_item()
    jrUser_get_profile_home_key()
    jrUser_is_admin()
    jrUser_is_logged_in()
    jrUser_load_lang_strings()
    jrUser_master_only()
  • Finding New Functions

    There is auto complete function in PhpStorm that lets you type the first part of a function and ctrl+space will bring up all the auto complete options.

    This is particularly useful if you suspect a function exists but are not sure of its name.

    eg start with

    jrCore_db(ctrl+space)
  • screenshot of suggested possible functions matching typed function letters
  • The two above features can also be used in conjunction with each other, while scrolling through the list of possible existing functions you can use ctrl+q to retrieve the docblock for each function to find out about it.
  • screenshot of docblock lookup on auto complete function feature

Tags