Common Programming Tasks/Functions

From FMYiRCWiki

Jump to: navigation, search

Freemed-YiRC - Common Programming Tasks/Functions


Contents


Summary

This article describes common programming tasks/functions in Freemed-YiRC.

The listed functions mostly come from the freemed_yirc-funcs.inc and freemed_yirc-funcs2.inc files. For more details on these (and other) functions, please see the Function Reference Guides in the Documentation article, in the For Programmers section.

NOTE: Please reference the Module Programming Guide article first to gain a general understanding of the general flow of Freemed-YiRC PHP scripts. This also serves as an introduction to some of the most basic/common tasks/functions.


Printing To The Screen

With the exception of viewing reports, anything printed to the screen will be done within the Freemed-YiRC window. The Freemed-YiRC window is HTML table-based. Therefore, anything printed within this table must be done within the HTML TR and TD (or TH) tags in order to show up properly.

However, Freemed-YiRC provides several functions to make this simple.

fy_winprn()

Description: Print a line or lines of text to the screen within the Freemed-YiRC window.

Usage: fy_winprn ($align, $colspan, $content)

Where:

  • $align - Alignment
    • (BLANK - NOT GIVEN) - Do not specify alignment
    • CENTER, RIGHT, LEFT
  • $colspan - Column Span
    • (BLANK - NOT GIVEN) - Do not specify column span
    • (A NUMBER) - The number of columns to span
  • $content - The content to be displayed on the screen. This can include HTML text.

Examples:

  • fy_winprn("CENTER","","Hello, World!");
    • Simply prints Hello, World! to the screen on a line.
  • fy_winprn("CENTER","","Some Text: <b>Bold</b>, <i>Italicized</i>, <b><i>Bold/Italicized</i></b>!!!");
  • fy_winprn("CENTER","","Some text on line 1.<br />Some text on line 2.");
  • fy_winprn("RIGHT", 2,"Text covering two columns, right-aligned");

NOTES: For most all FMYiRC pages involving forms, especially those using the fy2_* FMYiRC form functions, column span will be 2, as the first column will be a form field title, and the second column will be the form input. If a column span isn't specified, then text printed using fy_winprn() will only show up in the first column.

fy_winblank()

Description: Prints (or returns) a blank table line (a blank line within a table).

Usage: fy2_html_winblank($fy_use_return=0)

Where:

  • $fy_use_return - Whether to return the code instead of printing it to the screen, defaults to "0" (print, not return).

Examples:

  • fy_winprn();
    • Normal usage, prints a blank table line.
  • $fy_code.=fy_winprn(1);
    • Appends the HTML code for the blank table line to the $fy_code variable. Useful when creating reports whose content comes from a string.

NOTES:

  • The fy_winblank() function should be used instead of using the following:
    • fy_winprn("CENTER", "", "<br />");

fy_winline()

Description: Prints a horizontal row/line (HTML HR element) to the screen (in a table row).

Usage: fy2_html_winline($fy_align, $fy_colspan, $fy_width, $fy_size)

Where:

  • $fy_align - Alignment. Defaults to CENTER.
    • (BLANK - NOT GIVEN) - Do not specify alignment
    • CENTER, RIGHT, LEFT
  • $fy_colspan - Column Span. Defaults to 1.
    • (BLANK - NOT GIVEN) - Do not specify column span
    • (A NUMBER) - The number of columns to span
  • $fy_width - The width of the line, either in pixels or as a percentage. Percentages must include the percent sign (%). Defaults to 100%.
  • $fy_size - The height of the line, in pixels. Defaults to 2.

Examples:

  • fy2_html_winline("", "", "", "");
    • This is equivalent to an HTML HR element having a width of 100% in one table row column.
  • fy2_html_winline("", "2", "33%", "");
    • Prints a line spanning two table columns which is 33% the width of those two table columns.

NOTES: The fy2_html_winline() function should be used instead of directly printing an HTML HR.

Database Functions

Freemed-YiRC contains functions for dealing with Database connections and queries. These functions should be used instead of other functions (i.e., built-in PHP functions, PEAR/PCRE DB functions, etc...). This ensures consistency, and also ensures that if Freemed-YiRC adds/changes support for a given database that all code will work with a minimum number of changes. The Freemed-YiRC DB functions also help protect against SQL Injection attacks.

fy2_sql_exec()

Description: Performs an SQL query and creates variables for the results & rows.

Usage: fy2_sql_exec($sql, $fy_result_set_var, $fy_rows_var)

Where:

  • $sql - The SQL query to execute
  • $fy_result_set_var - Name of result set variable to set. Defaults to result_set.
  • $fy_rows_var - Name of rows variable to set. Defaults to rows.

Examples:

  • This will execute the SQL query SELECT * FROM fy_con. The results pointer is placed in the variable $result_set, and the total number of rows value is placed into the $rows variable.
$sql="SELECT * FROM fy_con";
fy2_sql_exec($sql, "", "");
echo $result_set."<br />\n";
echo $rows."<br />\n";
  • This will execute the SQL query SELECT * FROM fy_con. The results pointer is placed in the variable $result_set_con, and the total number of rows value is placed into the $rows_con variable.
$sql="SELECT * FROM fy_con";
fy2_sql_exec($sql, "result_set_con", "rows_con");
echo $result_set_con."<br />\n";
echo $rows_con."<br />\n";

fy2_sql_univ()

fy2_sql_lookup()

Description: Returns the contents of one DB field from a specified DB table record.

Usage: fy2_sql_lookup($fy_table, $fy_field, $fy_fieldsvalues, $fy_debug=0)

Where:

  • $fy_table - The name of the DB table to retrieve the result from.
  • $fy_field - The name of the DB field to retrieve the result from.
  • $fy_fieldsvalues - A set of fields and values used to specify the DB record wanted.
    • String takes the form of "FIELD=VALUE|FIELD=VALUE...", a series of "FIELD=VALUE" elements separated by a pipe character (|).
  • $fy_debug - OPTIONAL. If set to 1, will print the SQL query executed for debugging purposes.

Examples:

  • Return the lastname field of the DB record with an ID of 1 in fy_con. Places the value into the $fy_lastname variable.
$fy_lastname=fy2_sql_lookup("fy_con", "lastname", "ID=1");
echo $fy_lastname."<br />\n";
  • Returns the perm_helptext field of the DB record where the perm_module field is set to CON and perm_name field is set to con_edit. Places the value into the $fy_helptext variable.
$fy_helptext=fy2_sql_lookup("fy_secdb_perms", "perm_helptext", "perm_module=CON|perm_name=con_edit");
echo $fy_helptext."<br />\n";

fy2_reference_select()

Description: Returns pipe delimted list of options from an SQL table, for use with the fy2_form_select() function.

Usage: fy2_reference_select($fy_table, $fy_display_field, $fy_value_field, $fy_sql_where, $fy_sql_order, $fy_fixvalues, $fy_fdebug)

Where:

  • $fy_table - The name of the field to look up. Uses the format "fy_con_customdb.fX" where X is a number (field ID - fy_con_customdb.ID).
  • $fy_display_field - Name of SQL table field to use as the display description portion of the select option
  • $fy_value_field - Name of SQL table field to use as the value portion of the select option. This may be the same as $fy_display_field.
  • $fy_sql_where - OPTIONAL. If supplied, this will be appended to the SQL query as a "WHERE" argument.
  • $fy_sql_order - OPTIONAL. If supplied, this will be appended to the SQL query as an "ORDER" argument.
  • $fy_fixvalues - OPTIONAL. If set to 1, will use the PHP htmlspecialchars() function on values.
  • $fy_fdebug - OPTIONAL. If set to 1, will echo $SQL

Examples:

  • A list of the salutations from fy_con_salutations.
$fy_sals=fy2_reference_select("fy_con_salutations", "salutation", "salutation", "", "salutation");
echo $fy_sals."<br />\n";
  • A list of the US states from fy_states. Ordered by state name.
$fy_states=fy2_reference_select("fy_states", "abbr", "state", "", "state");
echo $fy_states."<br />\n";

Date/Time Functions

Freemed-YiRC has a variety of functions to deal with dates and times.

fy_putdate()

Description: Returns a date correctly formatted for use in SQL DB queries.

Usage: fy_putdate ($fydb_type, $in_m, $in_d, $in_y)

Where:

  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $in_m - Month (1-12)
  • $in_d - Day (1-31)
  • $in_y - Year (4 digits, i.e., 1997, 2010)

Examples:

$fy_date_db=fy_putdate($fydb_type, 1,2,2003);
echo $fy_date_db."<br />\n";
$fy_sdate_m=01;
$fy_sdate_d=02;
$fy_sdate_y=2003;
$fy_date_db=fy_putdate($fydb_type, $fy_sdate_m, $fy_sdate_d, $fy_sdate_y);
echo $fy_date_db."<br />\n";

fy_getdate()

Description: Returns a Freemed-YiRC internally formatted date (MM/DD/YYYY) from a DB formatted date.

Usage: fy_getdate ($fydb_type, $in_date)

Where:

  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $in_date - A DB formatted date.

Examples:

$fy_date_db=fy_putdate($fydb_type, 1, 1, 2011);
$fy_date_int=fy_getdate($fydb_type, $fy_date_db);
echo $fy_date_int."<br />\n";


fy_curdate()

Description: Returns the current date in MM/DD/YYYY format.

Usage: fy_curdate()

Examples:

echo fy_curdate()."<br />\n";


fy_curdbdate()

Description: Returns the current date in DB format.

Usage: fy_curdbdate()

echo fy_curdbdate()."<br />\n";

fy_getlocdate()

Function: Returns a date formatted according to the Freemed-YiRC system settings specified format.

Usage: fy_getlocdate ($conn, $in_date, $fydb_type, $fydb_name)

Where:

  • $conn - DB connection string variable.
  • $in_date - A DB formatted date.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

$fy_date_db=fy_putdate($fydb_type, 1, 1, 2011);
$fy_date_loc=fy_getlocdate($conn, $fy_date_db, $fydb_type, $fydb_name);
echo $fy_date_loc."<br />\n";
$fy_date_loc=fy_getlocdate($conn, fy_putdate($fydb_type, 1, 1, 2011), $fydb_type, $fydb_name);
echo $fy_date_loc."<br />\n";

fy_puttime()

Description: Returns a time correctly formatted for use in SQL DB queries.

Usage: fy_puttime ($fydb_type, $in_h, $in_m, $in_a)

Where:

  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $in_h - Hour (0-12)
  • $in_m - Day (0-59)
  • $in_a - "AM" or "PM"

Examples:

$fy_time_db=fy_puttime($fydb_type, 11, 30,"AM");
echo $fy_time_db."<br />\n";
$fy_time_db=fy_puttime($fydb_type, 2, 15,"PM");
echo $fy_time_db."<br />\n";
$fy_time_h=3;
$fy_time_m=20;
$fy_time_a="PM";
$fy_time_db=fy_puttime($fydb_type, $fy_time_h, $fy_time_m, $fy_time_a);
echo $fy_time_db."<br />\n";

fy_gettime()

Description: Returns a Freemed-YiRC internally formatted time (HH:MMXM) from a DB formatted time.

Usage: fy_gettime ($in_time)

Where:

  • $in_time - A DB formatted time.

Examples:

$fy_time_db=fy_puttime($fydb_type, 12, 30, "PM");
$fy_time_int=fy_gettime($fy_time_db);
echo $fy_time_int."<br />\n";


fy_curtime()

Description: Returns the current time HH:MM format.

Usage: fy_curtime()

Examples:

echo fy_curtime()."<br />\n";


fy_curdbtime()

Description: Returns the current time HH:MM:SS format.

Usage: fy_curdbtime()

Examples:

echo fy_curdbtime()."<br />\n";

fy_getloctime()

Description: Returns a time formatted according to the Freemed-YiRC system settings specified format.

Usage: fy_getloctime ($conn, $in_time="", $fydb_type, $fydb_name, $fy_seconds="")

Where:

  • $conn - DB connection string variable.
  • $in_time - A DB formatted time. If left blank, current system time will be used.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_addseconds - (OPTIONAL) If set to "X", will also display seconds.


Examples:

$fy_time_db=fy_puttime($fydb_type, 12, 30, "PM");
$fy_time_loc=fy_getloctime($conn, $fy_time_db, $fydb_type, $fydb_name);
echo $fy_time_loc."<br />\n";
$fy_time_loc=fy_getloctime($conn, fy_puttime($fydb_type, 12, 30, "PM"), $fydb_type, $fydb_name);
echo $fy_time_loc."<br />\n";

fy_unitsbetweendates()

Description: Used to return lengths of time between one date/time pair to another. Units can be days, hours, minutes, or seconds

Usage: fy_unitsbetweendates($fy_units, $fy_date1, $fy_time1, $fy_date2, $fy_time2)

Where:

  • $fy_units - The unit of time to return
    • SECONDS
    • MINUTES
    • HOURS
    • DAYS
    • YEARS
  • $fy_date1 - The first date in MM/DD/YYYY format.
  • $fy_time1 - The first time in HH:MM or HH:MM:SS format.
  • $fy_date2 - The second date in MM/DD/YYYY format.
  • $fy_time2 - The second time in HH:MM or HH:MM:SS format.

Examples:

$fy_time=fy_unitsbetweendates("SECONDS", "01/01/2010", "07:15", "01/01/2010", "07:17");
echo $fy_time."<br />\n";
$fy_time=fy_unitsbetweendates("MINUTES", "01/01/2010", "07:15", "01/01/2010", "07:17");
echo $fy_time."<br />\n";
$fy_time=fy_unitsbetweendates("HOURS", "01/01/2010", "07:15", "01/01/2010", "19:15");
echo $fy_time."<br />\n";
$fy_time=fy_unitsbetweendates("DAYS", "01/01/2010", "07:15", "01/03/2010", "19:15");
echo $fy_time."<br />\n";
$fy_time=fy_unitsbetweendates("YEARS", "01/01/2010", "07:15", "01/01/2011", "07:15");
echo $fy_time."<br />\n";


NOTES: Due to the way this function works results may not be exactly what you'd expect. This function works by breaking date/time pairs down into seconds since 1/1/1970 (the computer epoch), then doing conversions that way using subtraction and division between the two figures of seconds. Therefore, use of the round() function may be appropriate! In addition, when returning DAYS, one is added to the returned figure to include the first day so that if both the date/time pairs are on the same day, a non-zero figure is returned in order to make certain functions/comparisons easier (if statements, etc...). Also, while the time portions of the date/time pairs accept (optionally) seconds, those actual second figures are NOT taken into account during calculations.

fy_isfuture()

Description: Returns 1 if a given date is in the future, 0 if it is not.

Usage: fy_isfuture ($fy_m, $fy_d, $fy_y)

Where:

  • $fy_m - Month (1-12)
  • $fy_d - Day (1-31)
  • $fy_y - Year (4 digits, i.e., 1997, 2010)

Examples:

  • if (fy_isfuture(1,1,1956)) {echo "Is in the future!<br />\n";} else {echo "Is not in the future!<br />\n";}
  • if (fy_isfuture(1,1,2099)) {echo "Is in the future!<br />\n";} else {echo "Is not in the future!<br />\n";}


fy_getquarter()

Description: Returns the calendar quarter number for a given month number.

Usage: fy_getquarter($fy_month)

Where:

  • $fy_month - Month (1-12) If left blank, the current month is used.

Examples:

  • echo fy_getquarter(4)."<br />\n";
  • echo fy_getquarter()."<br />\n";
  • echo fy_getquarter(date("m"))."<br />\n";


fy_daysinyear()

Description: Returns the number of days in a given year.

Usage: fy_daysinyear($fy_year)

Where:

  • $fy_year - The year to check (four digits).

Examples:

echo fy_daysinyear(2010)."<br />\n";
echo fy_daysinyear(2012)."<br />\n";
echo fy_daysinyear(date("Y"))."<br />\n";


fy_isholiday()

Description: Returns if a given date is a timecard holiday listed in fy_holidays (managed by the FMYiRC HolidayDB Module). Returns 1 if the specified date is a holiday, 0 if not. NOTE! This only works if the correct data is in the FMYiRC HolidayDB! This must be done for each and every year!

Usage: fy_isholiday($fy_date)

Where:

  • $fy_date - A date formatted as the FMYiRC internal date format (MM/DD/YYYY).

Examples:

echo fy_isholiday("12/25/2010")."<br />\n";
echo fy_isholiday("12/26/2010")."<br />\n";
echo fy_isholiday("1/1/2011")."<br />\n";
echo fy_isholiday(fy_curdate())."<br />\n";

Address Functions

Freemed-YiRC has built-in functions for dealing with addresses, both domestic (USA) and internationally. These functions make it somewhat easy for programmers to add address info to scripts without having to know the current locale. For a better idea of how this works, see a script which makes use of these functions, such as con_addresses_add.php and con_addresses_add2.php (these scripts are used by the Contact Database to add addresses for contacts).


fy_univ_address_data_encoder()

Description: Using this function, you can take all the variables from the output of the fy_univ_address_input_form() function and create an Address Descriptor string which will be stored in the 'Address' field (TEXT or VARCHAR) of an SQL database. This descriptor string can then be read by any Freemed-YiRC Universal Address function.

Usage: fy_univ_address_data_encoder($conn, $fydb_type, $fydb_name, $fy_intype, $fy_data)

Where:

  • $conn - DB connection string variable.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_intype - The Address_Abbr, or address type. These are listed in the address_abbr DB field in the fy_addresses_types DB table;
  • $fy_data - This is an IMPLODED array of the address variables from fy_univ_address_form().

Examples:

  • In the following examples, the Address Description is the FMYiRC encoded address string, to be stored in a TEXT or VARCHAR field. This is then passed through the fy_univ_address_data_decoder() function to produce a human-readable address.
  • In this example, we're processing using data that was passed from an HTML form using the fy_univ_address_input_form. NOTE: This would have been data passed from another script, this example is not a useful stand-alone example!.
$fy_address_type="USSTD";

#--V-- UNIVERSAL ADDRESS ENCODER ---V--
$fy_t="";
if (isset($gr_address_address1)) {$fy_t.="~Address1=".$gr_address_address1;}
if (isset($gr_address_address2)) {$fy_t.="~Address2=".$gr_address_address2;}
if (isset($gr_address_city)) {$fy_t.="~City=".$gr_address_city;}
if (isset($gr_address_state)) {$fy_t.="~State=".$gr_address_state;}
if (isset($gr_address_zip)) {$fy_t.="~Zip=".$gr_address_zip;}
if (isset($gr_address_postcode)) {$fy_t.="~PostCode=".$gr_address_postcode;}
if (isset($gr_address_territory)) {$fy_t.="~Territory=".$gr_address_territory;}
if (isset($gr_address_country)) {$fy_t.="~Country=".$gr_address_country;}
if (isset($gr_address_countrycode)) {$fy_t.="~CountryCode=".$gr_address_countrycode;}
$fy_addr_descr=fy_univ_address_data_encoder($conn, $fydb_type, $fydb_name, $fy_address_type, $fy_t);
$fy_addr=ereg_replace("<BR>","\n",fy_univ_address_data_decoder($conn, $fydb_type, $fydb_name, $fy_addr_descr));
#--^--------------------------------^--

echo "Address Description:<br />\n";
echo $fy_addr_descr."<br />\n<br />\n";
echo "Address:<br />\n";
echo $fy_addr."<br />\n<br />\n";
  • This example uses a hard-coded address. This is not recommended and is only represented here for demonstration purposes.
$fy_t="~Address1=12345 Anywhere Dr.~Address2=ATTN: John Doe~City=Toledo~State=OH~Zip=43605";
$fy_addr_descr=fy_univ_address_data_encoder($conn, $fydb_type, $fydb_name, $fy_address_type, $fy_t);
$fy_addr=ereg_replace("<BR>","\n",fy_univ_address_data_decoder($conn, $fydb_type, $fydb_name, $fy_addr_descr));
echo "Address Description:<br />\n";
echo $fy_addr_descr."<br />\n<br />\n";
echo "Address:<br />\n";
echo $fy_addr."<br />\n<br />\n";


fy_univ_address_data_decoder()

Description: This is the Universal Address Data Decoder function. Using this function, you can decode an encoded address (encoded using the fy_univ_address_data_encoder() function).

Usage: fy_univ_address_data_decoder($conn, $fydb_type, $fydb_name, $fy_data)

Where:

  • $conn - DB connection string variable.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_data - This is a string produced by the fy_univ_address_data_encoder() function (which may have been retrieved from a DB).

Examples:

  • See the above details and examples for the fy_univ_address_data_encoder function for more information.

System Functions

fy_getcompanyinfo()

Description: Returns company/agency info stored in the system as a string of pipe-delimited items. Company/Agency information is set up by logging in as the root user, then clicking the Settings link on the Freemed-YiRC main menu.

Usage: fy_getcompanyinfo()

Examples:

echo fy_getcompanyinfo()."<br />\n";
$fy_compinfo=explode("|", fy_getcompanyinfo());
echo "Company Name: ".$fy_compinfo[0]."<br />\n<br />\n";
echo "Address:<br />\n";
echo $fy_compinfo[1]."<br />\n<br />\n";
echo "Phone: ".$fy_compinfo[2]."<br />\n<br >\n";
echo "Fax: ".$fy_compinfo[3]."<br />\n<br />\n";
echo "Agency Number: ".$fy_compinfo[4]."<br />\n<br />\n";


fy_fiscalinfo()

Description: Returns fiscal information from fy_settings as a string of pipe-delimited items. Company/Agency information is set up by logging in as the root user, then clicking the Settings link on the Freemed-YiRC main menu.

Usage: fy_fiscalinfo()

Examples:

  • NOTE: When using fiscal information, typically only the Start/End Month and Day are necessary. The year returned will always be the CURRENT year (or last/next year depending upon the chronological order of the start/end dates).
echo fy_fiscalinfo()."<br />\n";
$fy_fiscalinfo=fy_fiscalinfo();
$fy_fiscalinfo2=explode("|", $fy_fiscalinfo);
echo "Start Month: ".$fy_fiscalinfo2[0]."<br />\n";
echo "Start Day: ".$fy_fiscalinfo2[1]."<br />\n";
echo "Start Year: ".$fy_fiscalinfo2[2]."<br />\n";
echo "End Month: ".$fy_fiscalinfo2[3]."<br />\n";
echo "End Day: ".$fy_fiscalinfo2[4]."<br />\n";
echo "End Year: ".$fy_fiscalinfo2[5]."<br />\n";

Module Functions

fy_modstat()

Description: Determines if a module is active or not. Returns an "X" if so, BLANK if not. Modules can be enabled/disabled by logging in as the root user, selecting the Settings link from the main Freemed-YiRC window, then clicking on the Edit Module Settings link.

Usage: fy_modstat($conn, $fy_modabbr, $fydb_type, $fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_modabbr - The module abbreviation. This is what is in the mod_abbr DB field in the fy_modules DB table.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.

Examples:

  • if (fy_modstat($conn, "EM", $fydb_type, $fydb_name)=="X") {echo "The E-Mail module is enabled.<br />\n";} else {echo "The E-Mail module is NOT enabled.<br />\n";}
  • if (fy_modstat($conn, "RL", $fydb_type, $fydb_name)=="X") {echo "The Resource Locations module is enabled.<br />\n";} else {echo "The Resource Locations module is NOT enabled.<br />\n";}

fy2_module_setting()

Description: Used to return a module setting. Module settings can be accessed by logging in as the root user, selecting the Settings link from the main Freemed-YiRC window, then clicking on the Edit Module Settings link, then clicking on the Edit Module Settings link next to a module (if a module does not have any settings, a link will not appear next to it).

Usage: fy2_module_setting($fy_mod_abbr, $fy_setting_name)

Where:

  • $fy_mod_abbr - The module abbreviation. This is what is in the mod_abbr DB field in the fy_modules DB table.
  • $fy_setting_name - The setting name for the given module. This is the mod_setting_name DB field in the fy_modules_settings

Examples:

  • echo fy2_module_setting("CON", "display_last_first")."<br />\n";

fy_isgrpmod()

Description: Used to determine if a particular group has permission to use a particular module. Returns an "X" if so, BLANK if not. Groups can be associated with modules by logging in as root, then clicking the Group Database link on the main Freemed-YiRC menu, then clicking the EDIT link (in the ADMIN column) for a given group. Available group modules are then shown in the Permissions section.

Usage: fy_isgrpmod($conn, $fy_grpabbr, $fy_modabbr, $fydb_type, $fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_grpabbr - The group abbreviation. This is what is in the abbr DB field in the fy_groupdb DB table.
  • $fy_modabbr - The module abbreviation. This is what is in the mod_abbr DB field in the fy_modules DB table.
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.

Examples:

  • if (fy_isgrpmod($conn, "OF", "GC2", $fydb_type, $fydb_name)=="X") {echo "The Office Group has access to the Group Calendar 2 module.<br />\n";} else {echo "The Office Group does NOT have access to the Group Calendar 2 module.<br />\n";}
  • if (fy_isgrpmod($conn, "OF", "CCN", $fydb_type, $fydb_name)=="X") {echo "The Office Group has access to the Clinical CaseNotes module.<br />\n";} else {echo "The Office Group does NOT have access to the Clinical CaseNotes module.<br />\n";}

User Info Functions

fy_userprintercheck()

Description: Returns the number of printers a user has access to. Users are given access to printers by clicking on the User Admin link on the Freemed-YiRC main menu (if your user has the correct permissions to access this module), finding a user, then clicking on the Modify link in the Printers column. Before this can be done at least one printer must exist in the Printer Administration module (also available on the Freemed-YiRC main menu for a user with the correct permission).

Usage: fy_userprintercheck($conn, $fy_cid, $fydb_type, $fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_cid - The contact ID of the user in question. (fy_con.ID)
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.

Examples:

  • Determine if a user with an ID of 1 in the fy_con DB table (usually Root Administrator) has access to any printers.
if (fy_userprintercheck($conn, 1, $fydb_type, $fydb_name)>0) {echo "This user has access to printers";} else {echo "This user does not have access to any printers";}
  • Determine if the current user has access to any printers.
$fy_cid=fy_conloginidlookup($conn, $cookie_id, $fydb_type, $fydb_name);
if (fy_userprintercheck($conn, $fy_cid, $fydb_type, $fydb_name)>0) {echo "You have access to printers";} else {echo "You do not have access to any printers";}

fy2_user_setting()

Description: Used to return a user setting. These are the settings available to all users in the My Preferences link from their main Freemed-YiRC menu.

Usage: fy2_user_setting($fy_userid, $fy_setting_name)

Where:

  • $fy_cid - The contact ID of the user in question. (fy_con.ID)
  • $fy_setting_name - The name of the setting. This is setting_name DB field from the fy_users_settings DB table.

Examples:

  • Display the setting value for a user with an ID of 1 in the fy_con DB table (usually Root Administrator) for the main_menu_multi_cols setting.
echo fy2_user_setting(1, "main_menu_multi_cols")."<br />\n";
  • Display the setting value for the current user for the keyboard_shortcuts setting.
$fy_cid=fy_conloginidlookup($conn, $cookie_id, $fydb_type, $fydb_name);
echo fy2_user_setting($fy_cid, "keyboard_shortcuts")."<br />\n";

Freemed-YiRC Internal E-Mail Functions

Freemed-YiRC has a built-in (internal or intranet) E-Mail system/module. This does not make use of the Internet e-mail system, it is internal, and limited to, your Freemed-YiRC system. Freemed-YiRC systems can not send e-mails to other Freemed-YiRC systems nor the Internet.


fy_send_email()

Description: Used to send an e-mail using the FMYiRC internal e-mail system.

Usage: fy_send_email($conn, $fy_fromid, $gr_toid, $fy_subject, $fy_note, $fy_folder_fid, $fydb_type, $fydb_name, $fy_files="")

Where:

  • $conn - DB connection string variable.
  • $fy_fromid - The ConDB ID of the user who the message is from (fy_con.ID)
  • $gr_toid - The ConDB ID(s) of the user(s) who the message is to (fy_con.ID).
    • Can be multiple user IDs, separated by commas.
    • May include SELF, indicating the e-mail should also be sent to the user sending the e-mail ($fy_fromid).
    • May also contain E-Mail Groups (i.e., sending an e-mail to all contacts who are members of a given group). An e-mail group reference should take the form of GXX, with G indicating that it's a group, and XX is the group abbr of the group (from fy_groupdb.group_id).
    • May also contain E-Mail Alises. An e-mail alias reference should take the form of A#, with A indicating that it's an alias, and # is the E-Mail Alias ID number (from fy_email_aliases.ID).
  • $fy_subject - The e-mail subject text. NOTE: Make sure to perform a stripslashes() on the text before passing it on to the function, as this function does not perform it natively!
  • $fy_note - The e-mail body text. NOTE: Make sure to perform a stripslashes() on the text before passing it on to the function, as this function does not perform it natively!
  • $fy_folder_fid - The folder ID the e-mail should be placed in (fy_email_folders.ID). 0 = Inbox (RECOMMENDED USE)
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_files - Files to attach (OPTIONAL - ONLY IN FMYiRC V1.30 AND LATER) - A pipe delimited list of files to attach.
    • Each file should take the form of X^Y, where X is the location of the file (should be placed in the usr/ sub-directory, and indicated as such - usr/xyz.jpg), the carrot symbol (^) is an additional delimitter, and Y is how the file should be named in the system, i.e., how it SHOULD be viewed (some_picture.jpg).


Examples:

  • An example with an e-mail sent to a user with a ContactDB ID of 1 (usually Root Administrator):
fy_send_email($conn, 1, 1, "TEST E-Mail", "A test note for you!", 0, $fydb_type, $fydb_name);
  • An example with an e-mail sent to the OF (Office) group.
fy_send_email($conn, 1, "GOF", "TEST GROUP E-Mail", "A test note for the OFFICE group!", 0, $fydb_type, $fydb_name);
  • An example with one file attached being sent to the OF (Office) group:
fy_send_email($conn, 1, "GOF", "TEST GROUP E-Mail w/file attached", "A test note for the OFFICE group w/a file attached!", 0, $fydb_type, $fydb_name, "usr/xyz.jpg^some_picture.jpg");
  • An example with two files attached sent to a user with a ContactDB ID of 1 (usually Root Administrator):
fy_send_email($conn, 1, 1, "TEST E-Mail w/multiple attachments", "A test note for you!", 0, $fydb_type, $fydb_name, "usr/xyz.jpg^some_picture.jpg|usr/xyz2.jpg^another_picture.jpg");

HTML Form Functions

fy2_form()

Description: Used to display HTML form start element in a table.

Usage: fy2_form($fy_form_action, $fy_form_name, $fy_returnnotecho, $fy_append)

Where:

  • $fy_form_action - The URL to go to when the submit button is pressed.
  • $fy_form_name - The name of the HTML form element. Defaults to "form".
  • $fy_returnnotecho - OPTIONAL. If this is 1 no output will be echoed, it will be returned instead. If 0 (default), contents will be echoed to the screen and 0 will be returned.
  • $fy_append - OPTIONAL. Text to append to the HTML FORM element - Useful for JavaScript additions.

Examples:

# START FORM
$fy2_f_action="index.php?fy_x=X";
$fy2_f_name="form";
$fy2_f_append="";
fy2_form($fy2_f_action, $fy2_f_name, 0, $fy2_f_append);
# START FORM
$fy2_f_action="index.php?fy_x=X";
$fy2_f_name="form";
$fy2_f_append="";
echo fy2_form($fy2_f_action, $fy2_f_name, 1, $fy2_f_append);
  • In this example we're adding a bit to launch a JavaScript function named fy_checkdata() when the form is submitted.
# START FORM
$fy2_f_action="index.php?fy_x=X";
$fy2_f_name="form";
$fy2_f_append="onSubmit=\"return fy_checkdata()\"";
fy2_form($fy2_f_action, $fy2_f_name, 0, $fy2_f_append);

fy2_form_end()

Description: Used to display HTML form submit and form end elements in a table.

Usage: fy2_form_end($fy_colspan, $fy_button_name, $fy_returnnotecho, $fy_input_name)

Where:

  • $fy_colspam - The table column span. Defaults to 1.
  • $fy_button_name - The text value to appear on the submit button. Defaults to "Submit".
  • $fy_returnnotecho - OPTIONAL. If this is 1 no output will be echoed, it will be returned instead. If 0 (default), contents will be echoed to the screen and 0 will be returned.
  • $fy_input_name - OPTIONAL. If used, this can be set to a variable name for the submit input button. This can be used by Javascript to disable the form submit button.

Examples:

# FORM END
$fy2_fe_colspan=1;
$fy2_fe_button="Submit";
fy2_form_end($fy2_fe_colspan, $fy2_fe_button); 
# FORM END
$fy2_fe_colspan=1;
$fy2_fe_button="Submit";
echo fy2_form_end($fy2_fe_colspan, $fy2_fe_button, 1); 


fy2_form_input()

Description: Used to display HTML form input element.

Usage: fy2_form_input($fy_title, $fy_title_split, $fy_title_align, $fy_input_align, $fy_name, $fy_type, $fy_size, $fy_maxlength, $fy_default_value)

Where:

  • $fy_title - Title of form input element (i.e., text to appear to the left of the input box).
  • $fy_title_split - If 0, does not use a separate table cell for title and input box. If 1, does.
  • $fy_title_align - Table cell alignment of input title. If $fy_title_split is 0, this alignment is used for combined title/input contents. "center", "left", or "right". Defaults to "left" if $fy_title_split is 0, "right" if 1.
  • $fy_input_align - Table cell alignment of input box. If $fy_title_split is 0, this alignment is NOT used. "center", "left", or "right". Defaults to "left".
  • $fy_name - The name of the HTML form input element (i.e., the form variable name to pass)
  • $fy_type - Type of html form input element. Defaults to "INPUT". May also be "PASSWORD".
  • $fy_size - Size of the input field. Defaults to 5.
  • $fy_maxlength - The maximum length of characters allowed in the input box. Defaults to $fy_size.
  • $fy_default_value - The default text to appear in the input box.

Examples:

# FORM INPUT
$fy2_fi_title="Name";
$fy2_fi_title_split=1;
$fy2_fi_title_align="RIGHT";
$fy2_fi_input_align="LEFT";
$fy2_fi_name="gr_name";
$fy2_fi_type="INPUT";
$fy2_fi_size=10;
$fy2_fi_maxlength=15;
$fy2_fi_default_value="Joe"
fy2_form_input($fy2_fi_title, $fy2_fi_title_split, $fy2_fi_title_align, $fy2_fi_input_align, $fy2_fi_name, $fy2_fi_type, $fy2_fi_size, $fy2_fi_maxlength, $fy2_fi_default_value);

fy2_form_checkbox()

Description: Used to display HTML form checkbox element.

Usage: fy2_form_checkbox($fy_title, $fy_title_split, $fy_title_align, $fy_input_align, $fy_name, $fy_value, $fy_checked, $fy_append)

Where:

  • $fy_title - Title of form input element (i.e., text to appear to the left of the input box).
  • $fy_title_split - If 0, does not use a separate table cell for title and input box. If 1, does.
  • $fy_title_align - Table cell alignment of input title. If $fy_title_split is 0, this alignment is used for combined title/input contents. "center", "left", or "right". Defaults to "left" if $fy_title_split is 0, "right" if 1.
  • $fy_input_align - Table cell alignment of input box. If $fy_title_split is 0, this alignment is NOT used. "center", "left", or "right". Defaults to "left".
  • $fy_name - The name of the HTML form input element (i.e., the form variable name to pass)
  • $fy_value - The value of the input to be returned ($fy_name) if the checkbox is checked.
  • $fy_checked - "X" if checkbox should be checked by default. Blank if not.
  • $fy_append - OPTIONAL. Text to append to HTML select element (useful for JavaScript additions)


Examples:

# FORM CHECKBOX
$fy2_fc_title="Grand Access?";
$fy2_fc_title_split=1;
$fy2_fc_title_align="RIGHT";
$fy2_fc_input_align="LEFT";
$fy2_fc_name="gr_access";
$fy2_fc_value="X";
$fy2_fc_checked="";
$fy2_fc_append="";
fy2_form_checkbox($fy2_fc_title, $fy2_fc_title_split, $fy2_fc_title_align, $fy2_fc_input_align, $fy2_fc_name, $fy2_fc_value, $fy2_fc_checked, $fy2_fc_append);


fy2_form_textarea()

Description: Used to display HTML form textarea element.

Usage: fy2_form_textarea($fy_title, $fy_title_split, $fy_title_align, $fy_input_align, $fy_name, $fy_rows, $fy_cols, $fy_wrap, $fy_default_value)

Where:

  • $fy_title - Title of form input element (i.e., text to appear to the left of the input box).
  • $fy_title_split - If 0, does not use a separate table cell for title and input box. If 1, does.
  • $fy_title_align - Table cell alignment of input title. If $fy_title_split is 0, this alignment is used for combined title/input contents. "center", "left", or "right". Defaults to "left" if $fy_title_split is 0, "right" if 1.
  • $fy_input_align - Table cell alignment of input box. If $fy_title_split is 0, this alignment is NOT used. "center", "left", or "right". Defaults to "left".
  • $fy_name - The name of the HTML form input element (i.e., the form variable name to pass)
  • $fy_rows - The number of text rows the text area should be (height-wise)
  • $fy_cols - The number of text columns the text area should be (width-wise)
  • $fy_wrap - Specify "hard" or "soft" text wrapping. Defaults to "soft".
  • $fy_default_value - The default text to appear in the textarea input box.

Examples:

# FORM INPUT
$fy2_fi_title="Comments:";
$fy2_fi_title_split=1;
$fy2_fi_title_align="RIGHT";
$fy2_fi_input_align="LEFT";
$fy2_fi_name="gr_comments";
$fy2_fi_rows=5;
$fy2_fi_cols=60;
$fy2_fi_wrap="soft";
$fy2_fi_default_value=;
fy2_form_textarea($fy2_fi_title, $fy2_fi_title_split, $fy2_fi_title_align, $fy2_fi_input_align, $fy2_fi_name, $fy2_fi_rows, $fy2_fi_cols, $fy2_fi_wrap, $fy2_fi_default_value);

String Functions

fy_field2()

Description: Used to format a string for length (with fill options). Useful for applications with fixed-width fields.

Usage: fy_field2($fy_str, $fy_length, $fy_fill, $fy_pos)

Where:

  • $fy_str - The input string to format
  • $fy_length - The desired length of the string.
  • $fy_fill - The fill character (usually a space or 0)
  • $fy_pos - 1=Leading Fill, 0=Following Fill


Examples:

  • echo fy_field2("123.12", 10, "0", 1)."\n";
  • echo fy_field2("123.12", 10, " ", 1)."\n";
  • echo fy_field2("123.12", 10, "0", 0)."\n";
  • echo fy_field2("123.12", 10, " ", 0)."\n";

fy_xorblank()

Description: If the input $txtinp is "x" or "X", returns "X". Otherwise returns a blank HTML character (nbsp). Useful when using HTML tables to either print an "X" or a blank cell.

Usage: fy_xorblank($txtinp)

Where:

  • $txtinp - The input char/text.


Examples:

$fy_text="x";
echo fy_xorblank($fy_text)."\n";
$fy_text="X";
echo fy_xorblank($fy_text)."\n";
$fy_text="";
echo fy_xorblank($fy_text)."\n";

fy_textorblank()

Description: If the input $txtinp is not blank then returns the text as is. Otherwise returns a blank HTML character (nbsp). Useful when using HTML tables to either print text or a blank cell.

Usage: fy_textorblank($txtinp)

Where:

  • $txtinp - The input text.


Examples:

$fy_text="123";
echo fy_textorblank($fy_text)."\n";
$fy_text="";
echo fy_textorblank($fy_text)."\n";


Contact Functions

fy_conidlookup()

Description: Returns the name of a contact. Tries to return nickname+lastname, otherwise returns firstname+lastname.

Usage: fy_conidlookup ($conn,$fy_id,$fydb_type,$fydb_name, $fy_showmidinitial=0)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_showmidinitial - OPTIONAL. IF set to 1, also returns middle initial.

NOTE: Module Setting 'CON:display_last_first' may override the returned format!

Examples:

  • In the following example, we're using an ID of 1, which should be Root Administrator, which likely does not have a middle name. So both of these should return the same thing.
echo fy_conidlookup ($conn,1,$fydb_type,$fydb_name)."\n";
echo fy_conidlookup ($conn,1,$fydb_type,$fydb_name,1)."\n";
  • In the following example, we're using an ID of 984. This will need to be changed to a valid contact from your DB which has a middle name.
echo fy_conidlookup ($conn,984,$fydb_type,$fydb_name)."\n";
echo fy_conidlookup ($conn,984,$fydb_type,$fydb_name,1)."\n";


fy_conidlookup2()

Description: Returns the name (firstname+lastname) of a contact.

Usage: fy_conidlookup2 ($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_showmidinitial - OPTIONAL. IF set to 1, also returns middle initial.


Examples:

  • In the following example, we're using an ID of 1, which should be Root Administrator, but will show up as System Administrator, since we're using the First Name, not Nick Name.
echo fy_conidlookup2($conn,1,$fydb_type,$fydb_name)."\n";

fy_conidlookup2_rev()

Description: Returns the name (lastname, firstname) of a contact.

Usage: fy_conidlookup2_rev ($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.
  • $fy_showmidinitial - OPTIONAL. IF set to 1, also returns middle initial.


Examples:

  • In the following example, we're using an ID of 1, which should be Root Administrator, but will show up as Administrator, System, since we're using the First Name, not Nick Name.
echo fy_conidlookup2_rev($conn,1,$fydb_type,$fydb_name)."\n";

fy_conidragelookup()

Description: Returns the age of a resident.

Usage: fy_conidragelookup ($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Resident Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

  • In the following example, we're using an ID of 984. This will need to be changed to a valid Resident contact from your DB.
echo fy_conidragelookup($conn, 984, $fydb_type, $fydb_name)."\n";


fy_conloginidlookup()

Description: Returns the contact ID (fy_con.ID) for a user id (fy_users.id)

Usage: fy_conloginidlookup ($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Users ID (fy_users.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

  • In this example, we're using an $fy_id of 1, which should be Root Administrator. The result should also be 1, which is merely a coincidence because Root Administrator will typically be record number 1 in BOTH fy_users AND fy_con.
echo fy_conloginidlookup($conn, 1, $fydb_type, $fydb_name)."\n";


fy2_conlistnames()

Description: Used to return a list of contacts from the Contact DB. Can be used to return a set of options for an HTML form select or as a pipe delimitted reference list for the fy2_form_select() function.

Usage: fy2_conlistnames($fy_gh, $fy_type, $fy_status, $fy_selectid, $fy_returndataas)

Where:

  • $fy_gh - Group, LEAVE BLANK TO SHOW ALL
  • $fy_type - Type of contact:
    • Resident
    • Staff
    • Standard
    • Resource
    • Staff/Standard
    • Staff/Standard/Resource
    • Staff/Resource
  • $fy_status - BLANK, "Active", or "Inactive"
  • $fy_selectid - Contact ID to be autoselected (OR BLANK)
  • $fy_returndataas - How to return the data: (OPTIONAL - Defaults to SELECT)
    • Select - As a set of <option>'s for an HTML form select
    • Reference = As a list of items for a fy2_form_select


Examples:

  • Show all active Staff contacts as a list of HTML OPTIONs, with (if found) staff with a contact ID of 129 as marked SELECTED.
echo fy2_conlistnames("", "Staff", "Active", "129")."\n";
  • Show all active Resident contacts as a list of HTML OPTIONs.
echo fy2_conlistnames("", "Resident", "Active", "")."\n";
  • Show all active Staff contacts for the OF (Office) group as a list of HTML OPTIONs.
echo fy2_conlistnames("OF", "Staff", "Active", "")."\n";
  • Same as above, but show with the Reference format option instead. This is quite useful to pass to the fy2_form_select() function as the fy_options_values argument value.
echo fy2_conlistnames("OF", "Staff", "Active", "", "REFERENCE")."\n";

fy_getprimarylocation()

Description: Used to get a contacts primary GH via their ID number. Returns 0 if there is no primary, otherwise returns location (Group 2-letter abbr).

Usage: fy_getprimarylocation($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

  • In this example, we're using an $fy_id of 1, which should be Root Administrator.
echo fy_getprimarylocation($conn, 1, $fydb_type, $fydb_name)."\n";


fy_constatuslookup()

Description: Used to obtain the status (fy_con.status) of a contact from it's ID (fy_con.ID).

Usage: fy_constatuslookup($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

  • In this example, we're using an $fy_id of 1, which should be Root Administrator.
echo fy_constatuslookup($conn, 1, $fydb_type, $fydb_name)."\n";


fy_contypelookup()

Description: Used to obtain the contact type (fy_con.type) from the ConDB ID.

Usage: fy_contypelookup($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $conn - DB connection string variable.
  • $fy_id - The Contact ID (fy_con.ID).
  • $fydb_type - The DB type currently in use. Always directly pass $fydb_type.
  • $fydb_name - The DB name currently in use. Always directly pass $fydb_name.


Examples:

  • In this example, we're using an $fy_id of 1, which should be Root Administrator.
echo fy_contypelookup($conn, 1, $fydb_type, $fydb_name)."\n";


fy2_aliasconidlookup()

Description: Used to obtain the alias firstname + lastname (if applicable) from fy_con via the passed integer (contact ID - fy_con.ID)

Usage: fy_contypelookup($conn,$fy_id,$fydb_type,$fydb_name)

Where:

  • $fy_id - The Contact ID (fy_con.ID).

NOTE: Module setting 'CON:display_last_first' may override the formatting of the name!

Examples:

  • In this example, we're using an $fy_id of 1, which should be Root Administrator.
echo fy2_aliasconidlookup(1)."\n";

Group Security Functions

fy2_authgroup()

Description: Used to determine if the current user is a member of a given group.

Usage: fy2_authgroup($fy_id)

Where:

  • $fy_id - The group abbr (fy_groupdb.abbr)

NOTE: This is most commonly used in group module scripts to determine if a user has access to a given group, and, if not, to kick them out. This helps prevents users from simply changing the $fy_id variable in a URL to access groups they do not have access to.

Examples:

if (fy2_authgroup($fy_id)<1) {fy_autologout($cookie_user);exit;}
Personal tools