/lib/functions.inc.php
PHP | 8291 lines | 6676 code | 584 blank | 1031 comment | 727 complexity | 37cd88eba80b3f42df4dfd3434e28e23 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-2.0, BSD-3-Clause, GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- // functions.inc.php - Function library and defines for SiT -Support Incident Tracker
- //
- // SiT (Support Incident Tracker) - Support call tracking system
- // Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
- //
- // This software may be used and distributed according to the terms
- // of the GNU General Public License, incorporated herein by reference.
- //
- // Authors: Ivan Lucas, <ivanlucas[at]users.sourceforge.net>
- // Tom Gerrard, <tomgerrard[at]users.sourceforge.net> - 2001 onwards
- // Martin Kilcoyne - 2000
- // Paul Heaney, <paulheaney[at]users.sourceforge.net>
- // Kieran Hogg, <kieran[at]sitracker.org>
- // Many functions here simply extract various snippets of information from
- // Most are legacy and can replaced by improving the pages that call them to
- // use SQL joins.
- // Prevent script from being run directly (ie. it must always be included
- if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))
- {
- exit;
- }
- include (APPLICATION_LIBPATH . 'classes.inc.php');
- include (APPLICATION_LIBPATH . 'group.class.php');
- include (APPLICATION_LIBPATH . 'user.class.php');
- include (APPLICATION_LIBPATH . 'contact.class.php');
- include (APPLICATION_LIBPATH . 'incident.class.php');
- include (APPLICATION_LIBPATH . 'ldap.inc.php');
- include (APPLICATION_LIBPATH . 'base.inc.php');
- include_once (APPLICATION_LIBPATH . 'billing.inc.php');
- include_once (APPLICATION_LIBPATH . 'user.inc.php');
- include_once (APPLICATION_LIBPATH . 'sla.inc.php');
- include_once (APPLICATION_LIBPATH . 'ftp.inc.php');
- include_once (APPLICATION_LIBPATH . 'tags.inc.php');
- include_once (APPLICATION_LIBPATH . 'string.inc.php');
- include_once (APPLICATION_LIBPATH . 'html.inc.php');
- include_once (APPLICATION_LIBPATH . 'tasks.inc.php');
- include_once (APPLICATION_LIBPATH . 'export.inc.php');
- // function stripslashes_array($data)
- // {
- // if (is_array($data))
- // {
- // foreach ($data as $key => $value)
- // {
- // $data[$key] = stripslashes_array($value);
- // }
- // return $data;
- // }
- // else
- // {
- // return stripslashes($data);
- // }
- // }
- if (version_compare(PHP_VERSION, "5.1.0", ">="))
- {
- date_default_timezone_set($CONFIG['timezone']);
- }
- //Prevent Magic Quotes from affecting scripts, regardless of server settings
- //Make sure when reading file data,
- //PHP doesn't "magically" mangle backslashes!
- set_magic_quotes_runtime(FALSE);
- if (get_magic_quotes_gpc())
- {
- // All these global variables are slash-encoded by default,
- // because magic_quotes_gpc is set by default!
- // (And magic_quotes_gpc affects more than just $_GET, $_POST, and $_COOKIE)
- // We don't strip slashes from $_FILES as of 3.32 as this should be safe without
- // doing and it will break windows file paths if we do
- $_SERVER = stripslashes_array($_SERVER);
- $_GET = stripslashes_array($_GET);
- $_POST = stripslashes_array($_POST);
- $_COOKIE = stripslashes_array($_COOKIE);
- $_ENV = stripslashes_array($_ENV);
- $_REQUEST = stripslashes_array($_REQUEST);
- $HTTP_SERVER_VARS = stripslashes_array($HTTP_SERVER_VARS);
- $HTTP_GET_VARS = stripslashes_array($HTTP_GET_VARS);
- $HTTP_POST_VARS = stripslashes_array($HTTP_POST_VARS);
- $HTTP_COOKIE_VARS = stripslashes_array($HTTP_COOKIE_VARS);
- $HTTP_POST_FILES = stripslashes_array($HTTP_POST_FILES);
- $HTTP_ENV_VARS = stripslashes_array($HTTP_ENV_VARS);
- if (isset($_SESSION))
- {
- #These are unconfirmed (?)
- $_SESSION = stripslashes_array($_SESSION, '');
- $HTTP_SESSION_VARS = stripslashes_array($HTTP_SESSION_VARS, '');
- }
- // The $GLOBALS array is also slash-encoded, but when all the above are
- // changed, $GLOBALS is updated to reflect those changes. (Therefore
- // $GLOBALS should never be modified directly). $GLOBALS also contains
- // infinite recursion, so it's dangerous...
- }
- /**
- * Authenticate a user with a username/password pair
- * @author Ivan Lucas
- * @param string $username. A username
- * @param string $password. A password (non-md5)
- * @return an integer to indicate whether the user authenticated against the database
- * @retval int 0 the credentials were wrong or the user was not found.
- * @retval int 1 to indicate user is authenticated and allowed to continue.
- */
- function authenticateSQL($username, $password)
- {
- global $dbUsers;
- $password = md5($password);
- if ($_SESSION['auth'] == TRUE)
- {
- // Already logged in
- return 1;
- }
- // extract user
- $sql = "SELECT id FROM `{$dbUsers}` ";
- $sql .= "WHERE username = '{$username}' AND password = '{$password}' AND status != 0 ";
- // a status of 0 means the user account is disabled
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- // return appropriate value
- if (mysql_num_rows($result) == 0)
- {
- mysql_free_result($result);
- return 0;
- }
- else
- {
- journal(CFG_LOGGING_MAX,'User Authenticated',"{$username} authenticated from " . getenv('REMOTE_ADDR'),CFG_JOURNAL_LOGIN,0);
- return 1;
- }
- }
- /**
- * Authenticate a user
- * @author Lea Anthony
- * @param string $username. Username
- * @param string $password. Password
- * @return an integer to indicate whether the user authenticated against any authentication backends
- * @retval bool false the credentials were wrong or the user was not found.
- * @retval bool true to indicate user is authenticated and allowed to continue.
- */
- function authenticate($username, $password)
- {
- global $CONFIG;
- $toReturn = false;
- $sql = "SELECT id, password, status, user_source FROM `{$GLOBALS['dbUsers']}` WHERE username = '{$username}'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 1)
- {
- // Exist in SiT DB
- $obj = mysql_fetch_object($result);
- if ($obj->user_source == 'sit')
- {
- if (md5($password) == $obj->password AND $obj->status != 0) $toReturn = true;
- else $toReturn = false;
- }
- elseif ($obj->user_source == 'ldap')
- {
- // Auth against LDAP and sync
- $toReturn = authenticateLDAP($username, $password, $obj->id);
- if ($toReturn === -1)
- {
- // Communication with LDAP server failed
- if ($CONFIG['ldap_allow_cached_password'])
- {
- // Use cached password
- if (md5($password) == $obj->password AND $obj->status != 0) $toReturn = true;
- else $toReturn = false;
- }
- else
- {
- $toReturn = false;
- }
- }
- elseif ($toReturn)
- {
- $toReturn = true;
- }
- else
- {
- $toReturn = false;
- }
- }
- }
- elseif (mysql_num_rows($result) > 1)
- {
- // Multiple this should NEVER happen
- trigger_error("Username not unique", E_USER_ERROR);
- $toReturn = false;
- }
- else
- {
- // Don't exist, check LDAP etc
- if ($CONFIG['use_ldap'])
- {
- $toReturn = authenticateLDAP($username, $password);
- if ($toReturn === -1) $toReturn = false;
- }
- }
- if ($toReturn)
- {
- journal(CFG_LOGGING_MAX,'User Authenticated',"{$username} authenticated from " . getenv('REMOTE_ADDR'),CFG_JOURNAL_LOGIN,0);
- debug_log ("Authenticate: User authenticated",TRUE);
- }
- else
- {
- debug_log ("authenticate: User NOT authenticated",TRUE);
- }
-
- return $toReturn;
- }
- function authenticateContact($username, $password)
- {
- debug_log ("authenticateContact called");
- global $CONFIG;
- $toReturn = false;
- $sql = "SELECT id, password, contact_source, active FROM `{$GLOBALS['dbContacts']}` WHERE username = '{$username}'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 1)
- {
- debug_log ("Authenticate: Just one contact in db");
- // Exists in SiT DB
- $obj = mysql_fetch_object($result);
- if ($obj->contact_source == 'sit')
- {
- if ((md5($password) == $obj->password OR $password == $obj->password) AND $obj->active == 'true') $toReturn = true;
- else $toReturn = false;
- }
- elseif ($obj->contact_source == 'ldap')
- {
- // Auth against LDAP and sync
- $toReturn = authenticateLDAP($username, $password, $obj->id, false);
- if ($toReturn === -1)
- {
- // Communication with LDAP server failed
- if ($CONFIG['ldap_allow_cached_password'])
- {
- debug_log ("LDAP connection failed, using cached password");
- // Use cached password
- if ((md5($password) == $obj->password OR $password == $obj->password) AND $obj->active == 'true') $toReturn = true;
- else $toReturn = false;
- debug_log ("Cached contact {$toReturn} {$password}");
- }
- else
- {
- debug_log ("Cached passwords are not enabled");
- $toReturn = false;
- }
- }
- elseif ($toReturn)
- {
- $toReturn = true;
- }
- else
- {
- $toReturn = false;
- }
- }
- else
- {
- debug_log ("Source SOMETHING ELSE this shouldn't happen'");
- $toReturn = false;
- }
- }
- elseif (mysql_num_rows($result) > 1)
- {
- debug_log ("Multiple");
- // Multiple this should NEVER happen
- trigger_error($GLOBALS['strUsernameNotUnique'], E_USER_ERROR);
- $toReturn = false;
- }
- else
- {
- debug_log ("Authenticate: No matching contact '$username' found in db");
- // Don't exist, check LDAP etc
- if ($CONFIG['use_ldap'] AND !empty($CONFIG['ldap_customer_group']))
- {
- $toReturn = authenticateLDAP($username, $password, 0, false);
- if ($toReturn === -1) $toReturn = false;
- }
- }
- debug_log ("authenticateContact returning {$toReturn}");
- return $toReturn;
- }
- /**
- * See if a customer exists in the database
- * @author Lea Anthony
- * @param string $username. Username of customer
- * @retval bool TRUE exists in db
- * @retval bool FALSE does not exist in db
- */
- function customerExistsInDB($username)
- {
- global $dbContacts;
- $exists = 0;
- $sql = "SELECT id FROM `{$dbContacts}` WHERE username='$username'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_ERROR);
- while( $res = mysql_fetch_array($result) )
- {
- $exists = 1;
- }
- return $exists;
- }
- /**
- * Returns a specified column from a specified table in the database given an ID primary key
- * @author Ivan Lucas
- * @param string $column a database column
- * @param string $table a database table
- * @param int $id the primary key / id column
- * @return A column from the database
- * @note it's not always efficient to read a single column at a time, but when you only need
- * one column, this is handy
- */
- function db_read_column($column, $table, $id)
- {
- $sql = "SELECT `$column` FROM `{$table}` WHERE id ='$id' LIMIT 1";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_WARNING);
- if (mysql_num_rows($result) == 0)
- {
- $column = FALSE;
- }
- else
- {
- list($column) = mysql_fetch_row($result);
- }
- return $column;
- }
- /**
- * @author Ivan Lucas
- */
- function permission_name($permissionid)
- {
- global $dbPermissions;
- $name = db_read_column('name', $dbPermissions, $permissionid);
- if (empty($name)) $name = $GLOBALS['strUnknown'];
- return $name;
- }
- /**
- * Get the name associated with software ID / skill ID
- * @author Ivan Lucas
- * @param int $softwareid
- * @returns string. Skill/Software Name
- * @note Software was renamed skills for v3.30
- */
- function software_name($softwareid)
- {
- global $now, $dbSoftware, $strEOL, $strEndOfLife;
- $sql = "SELECT * FROM `{$dbSoftware}` WHERE id = '{$softwareid}'";
- $result = mysql_query($sql);
- if (mysql_num_rows($result) >= 1)
- {
- $software = mysql_fetch_object($result);
- $lifetime_end = mysql2date($software->lifetime_end);
- if ($lifetime_end > 0 AND $lifetime_end < $now)
- {
- $name = "<span class='deleted'>{$software->name}</span> (<abbr title='{$strEndOfLife}'>{$strEOL}</abbr>)";
- }
- else
- {
- $name = $software->name;
- }
- }
- else
- {
- $name = $GLOBALS['strUnknown'];
- }
- return $name;
- }
- /**
- * Find a contacts real name
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns string. Full name or 'Unknown'
- */
- function contact_realname($id)
- {
- global $dbContacts;
- $sql = "SELECT forenames, surname FROM `{$dbContacts}` WHERE id='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 0)
- {
- mysql_free_result($result);
- return ($GLOBALS['strUnknown']);
- }
- else
- {
- $contact = mysql_fetch_object($result);
- $realname = "{$contact->forenames} {$contact->surname}";
- mysql_free_result($result);
- return $realname;
- }
- }
- /**
- * Return a contacts site name
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns string. Full site name or 'Unknown'
- * @note this returns the site _NAME_ not the siteid for the site id use contact_siteid()
- */
- function contact_site($id)
- {
- global $dbContacts, $dbSites;
- //
- $sql = "SELECT s.name FROM `{$dbContacts}` AS c, `{$dbSites}` AS s WHERE c.siteid = s.id AND c.id = '$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 0)
- {
- mysql_free_result($result);
- return $GLOBALS['strUnknown'];
- }
- else
- {
- list($contactsite) = mysql_fetch_row($result);
- mysql_free_result($result);
- $contactsite = $contactsite;
- return $contactsite;
- }
- }
- /**
- * Return a contacts site ID
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns int. Site ID
- */
- function contact_siteid($id)
- {
- return db_read_column('siteid', $GLOBALS['dbContacts'], $id);
- }
- /**
- * Return a contacts email address
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns string. Email address
- */
- function contact_email($id)
- {
- return db_read_column('email', $GLOBALS['dbContacts'], $id);
- }
- /**
- * Return a contacts phone number
- * @author Ivan Lucas
- * @param integer $id. Contact ID
- * @returns string. Phone number
- */
- function contact_phone($id)
- {
- return db_read_column('phone', $GLOBALS['dbContacts'], $id);
- }
- /**
- * Return a contacts fax number
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns string. Fax number
- */
- function contact_fax($id)
- {
- return db_read_column('fax', $GLOBALS['dbContacts'], $id);
- }
- /**
- * Return the number of incidents ever logged against a contact
- * @author Ivan Lucas
- * @param int $id. Contact ID
- * @returns int.
- */
- function contact_count_incidents($id)
- {
- global $dbIncidents;
- $count = 0;
- $sql = "SELECT COUNT(id) FROM `{$dbIncidents}` WHERE contact='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- else list($count) = mysql_fetch_row($result);
- mysql_free_result($result);
- return $count;
- }
- /**
- * Return the number of incidents ever logged against a site
- * @author Kieran
- * @param int $id. Site ID
- * @returns int.
- */
- function site_count_incidents($id)
- {
- global $dbIncidents, $dbContacts;
- $id = intval($id);
- $count = 0;
- $sql = "SELECT COUNT(i.id) FROM `{$dbIncidents}` AS i, `{$dbContacts}` as c ";
- $sql .= "WHERE i.contact = c.id ";
- $sql .= "AND c.siteid='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- else list($count) = mysql_fetch_row($result);
- mysql_free_result($result);
- return $count;
- }
- /**
- * Return the number of inventory items for a site
- * @author Kieran
- * @param int $id. Site ID
- * @returns int.
- */
- function site_count_inventory_items($id)
- {
- global $dbInventory;
- $count = 0;
- $sql = "SELECT COUNT(id) FROM `{$dbInventory}` WHERE siteid='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- else list($count) = mysql_fetch_row($result);
- mysql_free_result($result);
- return $count;
- }
- /**
- * Return the number of inventory items for a contact
- * @author Kieran
- * @param int $id. Contact ID
- * @returns int.
- */
- function contact_count_inventory_items($id)
- {
- global $dbInventory;
- $count = 0;
- $sql = "SELECT COUNT(id) FROM `{$dbInventory}` WHERE contactid='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- else list($count) = mysql_fetch_row($result);
- mysql_free_result($result);
- return $count;
- }
- /**
- * The number representing the total number of currently OPEN incidents submitted by a given contact.
- * @author Ivan Lucas
- * @param int $id. The Contact ID to check
- * @returns integer. The number of currently OPEN incidents for the given contact
- */
- function contact_count_open_incidents($id)
- {
- global $dbIncidents;
- $sql = "SELECT COUNT(id) FROM `{$dbIncidents}` WHERE contact=$id AND status<>2";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- list($count) = mysql_fetch_row($result);
- mysql_free_result($result);
- return $count;
- }
- /**
- * Creates a vcard electronic business card for the given contact
- * @author Ivan Lucas
- * @param int $id Contact ID
- * @returns string vcard
- */
- function contact_vcard($id)
- {
- global $dbContacts, $dbSites;
- $sql = "SELECT *, s.name AS sitename, s.address1 AS siteaddress1, s.address2 AS siteaddress2, ";
- $sql .= "s.city AS sitecity, s.county AS sitecounty, s.country AS sitecountry, s.postcode AS sitepostcode ";
- $sql .= "FROM `{$dbContacts}` AS c, `{$dbSites}` AS s ";
- $sql .= "WHERE c.siteid = s.id AND c.id = '$id' LIMIT 1";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $contact = mysql_fetch_object($result);
- $vcard = "BEGIN:VCARD\r\n";
- $vcard .= "N:{$contact->surname};{$contact->forenames};{$contact->courtesytitle}\r\n";
- $vcard .= "FN:{$contact->forenames} {$contact->surname}\r\n";
- if (!empty($contact->jobtitle)) $vcard .= "TITLE:{$contact->jobtitle}\r\n";
- if (!empty($contact->sitename)) $vcard .= "ORG:{$contact->sitename}\r\n";
- if ($contact->dataprotection_phone != 'Yes') $vcard .= "TEL;TYPE=WORK:{$contact->phone}\r\n";
- if ($contact->dataprotection_phone != 'Yes' && !empty($contact->fax))
- {
- $vcard .= "TEL;TYPE=WORK;TYPE=FAX:{$contact->fax}\r\n";
- }
- if ($contact->dataprotection_phone != 'Yes' && !empty($contact->mobile))
- {
- $vcard .= "TEL;TYPE=WORK;TYPE=CELL:{$contact->mobile}\r\n";
- }
- if ($contact->dataprotection_email != 'Yes' && !empty($contact->email))
- {
- $vcard .= "EMAIL;TYPE=INTERNET:{$contact->email}\r\n";
- }
- if ($contact->dataprotection_address != 'Yes')
- {
- if ($contact->address1 != '')
- {
- $vcard .= "ADR;WORK:{$contact->address1};{$contact->address2};{$contact->city};{$contact->county};{$contact->postcode};{$contact->country}\r\n";
- }
- else
- {
- $vcard .= "ADR;WORK:{$contact->siteaddress1};{$contact->siteaddress2};{$contact->sitecity};{$contact->sitecounty};{$contact->sitepostcode};{$contact->sitecountry}\r\n";
- }
- }
- if (!empty($contact->notes))
- {
- $vcard .= "NOTE:{$contact->notes}\r\n";
- }
- $vcard .= "REV:".iso_8601_date($contact->timestamp_modified)."\r\n";
- $vcard .= "END:VCARD\r\n";
- return $vcard;
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns integer. UserID of the user that currently owns the incident
- */
- function incident_owner($id)
- {
- return db_read_column('owner', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns integer. UserID of the user that currently temporarily owns the incident
- */
- function incident_towner($id)
- {
- return db_read_column('towner', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns integer. ContactID of the contact this incident is logged against
- */
- function incident_contact($id)
- {
- return db_read_column('contact', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns integer. Contract ID of the maintenance contract this incident is logged against
- */
- function incident_maintid($id)
- {
- $maintid = db_read_column('maintenanceid', $GLOBALS['dbIncidents'], $id);
- if ($maintid == '')
- {
- trigger_error("!Error: No matching record while reading in incident_maintid() Incident ID: {$id}", E_USER_WARNING);
- }
- else
- {
- return ($maintid);
- }
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns string. Title of the incident
- */
- function incident_title($id)
- {
- return db_read_column('title', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns id. Current incident status ID
- */
- function incident_status($id)
- {
- return db_read_column('status', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns id. Current incident Priority ID
- */
- function incident_priority($id)
- {
- return db_read_column('priority', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns id. Current incident external ID
- */
- function incident_externalid($id)
- {
- return db_read_column('externalid', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns string. Current incident external engineer
- */
- function incident_externalengineer($id)
- {
- return db_read_column('externalengineer', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns string. Current incident external email address
- */
- function incident_externalemail($id)
- {
- return db_read_column('externalemail', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns string. Current incident CC email address
- */
- function incident_ccemail($id)
- {
- return db_read_column('ccemail', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * @author Ivan Lucas
- * @param int $id Incident ID
- * @returns int. UNIX Timestamp of the time of the next action for this incident
- */
- function incident_timeofnextaction($id)
- {
- return db_read_column('timeofnextaction', $GLOBALS['dbIncidents'], $id);
- }
- /**
- * Returns a string of HTML nicely formatted for the incident details page containing any additional
- * product info for the given incident.
- * @author Ivan Lucas
- * @param int $incidentid The incident ID
- * @returns string HTML
- */
- function incident_productinfo_html($incidentid)
- {
- global $dbProductInfo, $dbIncidentProductInfo, $strNoProductInfo;
- // TODO extract appropriate product info rather than *
- $sql = "SELECT *, TRIM(incidentproductinfo.information) AS info FROM `{$dbProductInfo}` AS p, {$dbIncidentProductInfo}` ipi ";
- $sql .= "WHERE incidentid = $incidentid AND productinfoid = p.id AND TRIM(p.information) !='' ";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 0)
- {
- return ('<tr><td>{$strNoProductInfo}</td><td>{$strNoProductInfo}</td></tr>');
- }
- else
- {
- // generate HTML
- while ($productinfo = mysql_fetch_object($result))
- {
- if (!empty($productinfo->info))
- {
- $html = "<tr><th>{$productinfo->moreinformation}:</th><td>";
- $html .= urlencode($productinfo->info);
- $html .= "</td></tr>\n";
- }
- }
- echo $html;
- }
- }
- /**
- * prints the HTML for a drop down list of contacts, with the given name
- * and with the given id selected.
- * @author Ivan Lucas
- */
- function contact_drop_down($name, $id, $showsite = FALSE, $required = FALSE)
- {
- global $dbContacts, $dbSites;
- if ($showsite)
- {
- $sql = "SELECT c.id AS contactid, s.id AS siteid, surname, forenames, ";
- $sql .= "s.name AS sitename, s.department AS department ";
- $sql .= "FROM `{$dbContacts}` AS c, `{$dbSites}` AS s WHERE c.siteid = s.id AND c.active = 'true' ";
- $sql .= "AND s.active = 'true' ";
- $sql .= "ORDER BY s.name, s.department, surname ASC, forenames ASC";
- }
- else
- {
- $sql = "SELECT c.id AS contactid, surname, forenames FROM `{$dbContacts}` AS c, `{$dbSites}` AS s ";
- $sql .= "WHERE c.siteid = s.id AND s.active = 'true' AND c.active = 'true' ";
- $sql .= "ORDER BY forenames ASC, surname ASC";
- }
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='$name' id='$name'";
- if ($required)
- {
- $html .= " class='required' ";
- }
- $html .= ">\n";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- $prevsite=0;
- while ($contacts = mysql_fetch_object($result))
- {
- if ($showsite AND $prevsite != $contacts->siteid AND $prevsite != 0)
- {
- $html .= "</optgroup>\n";
- }
- if ($showsite AND $prevsite != $contacts->siteid)
- {
- $html .= "<optgroup label='".htmlentities($contacts->sitename, ENT_COMPAT, 'UTF-8').", ".htmlentities($contacts->department, ENT_COMPAT, $GLOBALS['i18ncharset'])."'>";
- }
- $realname = "{$contacts->forenames} {$contacts->surname}";
- $html .= "<option ";
- if ($contacts->contactid == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$contacts->contactid}'>{$realname}";
- $html .= "</option>\n";
- $prevsite = $contacts->siteid;
- }
- if ($showsite)
- {
- $html.= "</optgroup>";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * prints the HTML for a drop down list of contacts along with their site, with the given name and
- * and with the given id selected.
- * @author Ivan Lucas
- * @param string $name. The name of the field
- * @param int $id. Select this contactID by default
- * @param int $siteid. (optional) Filter list to show contacts from this siteID only
- * @param mixed $exclude int|array (optional) Do not show this contactID in the list, accepts an integer or array of integers
- * @param bool $showsite (optional) Suffix the name with the site name
- * @param bool $allownone (optional) Allow 'none' to be selected (blank value)
- * @returns string. HTML select
- */
- function contact_site_drop_down($name, $id, $siteid='', $exclude='', $showsite=TRUE, $allownone=FALSE)
- {
- global $dbContacts, $dbSites;
- $sql = "SELECT c.id AS contactid, forenames, surname, siteid, s.name AS sitename ";
- $sql .= "FROM `{$dbContacts}` AS c, `{$dbSites}` AS s ";
- $sql .= "WHERE c.siteid = s.id AND c.active = 'true' AND s.active = 'true' ";
- if (!empty($siteid)) $sql .= "AND s.id='$siteid' ";
- if (!empty($exclude))
- {
- if (is_array($exclude))
- {
- foreach ($exclude AS $contactid)
- {
- $sql .= "AND c.id != $contactid ";
- }
- }
- else
- {
- $sql .= "AND c.id != $exclude ";
- }
- }
- $sql .= "ORDER BY surname ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='$name'>";
- if (mysql_num_rows($result) > 0)
- {
- if ($allownone) $html .= "<option value='' selected='selected'>{$GLOBALS['strNone']}</option>";
- while ($contacts = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if ($contacts->contactid == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$contacts->contactid}'>";
- if ($showsite)
- {
- $html .= htmlspecialchars("{$contacts->surname}, {$contacts->forenames} - {$contacts->sitename}");
- }
- else
- {
- $html .= htmlspecialchars("{$contacts->surname}, {$contacts->forenames}");
- }
- $html .= "</option>\n";
- }
- }
- else $html .= "<option value=''>{$GLOBALS['strNone']}</option>";
- $html .= "</select>\n";
- return $html;
- }
- /**
- * HTML for a drop down list of products
- * @author Ivan Lucas
- * @param string $name. name/id to use for the select element
- * @param int $id. Product ID
- * @param bool $required.
- * @returns string. HTML select
- * @note With the given name and with the given id selected.
- */
- function product_drop_down($name, $id, $required = FALSE)
- {
- global $dbProducts;
- // extract products
- $sql = "SELECT id, name FROM `{$dbProducts}` ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='{$name}' id='{$name}'";
- if ($required)
- {
- $html .= " class='required' ";
- }
- $html .= ">";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($products = mysql_fetch_object($result))
- {
- $html .= "<option value='{$products->id}'";
- if ($products->id == $id)
- {
- $html .= " selected='selected'";
- }
- $html .= ">{$products->name}</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * HTML for a drop down list of skills (was called software)
- * @author Ivan Lucas
- * @param string $name. name/id to use for the select element
- * @param int $id. Software ID
- * @returns HTML select
- */
- function skill_drop_down($name, $id)
- {
- global $now, $dbSoftware, $strEOL;
- // extract software
- $sql = "SELECT id, name, lifetime_end FROM `{$dbSoftware}` ";
- $sql .= "ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='{$name}' id='{$name}' >";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'>{$GLOBALS['strNone']}</option>\n";
- }
- while ($software = mysql_fetch_object($result))
- {
- $html .= "<option value='{$software->id}'";
- if ($software->id == $id)
- {
- $html .= " selected='selected'";
- }
- $html .= ">{$software->name}";
- $lifetime_start = mysql2date($software->lifetime_start);
- $lifetime_end = mysql2date($software->lifetime_end);
- if ($lifetime_end > 0 AND $lifetime_end < $now)
- {
- $html .= " ({$strEOL})";
- }
- $html .= "</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Generates a HTML dropdown of software products
- * @author Kieran Hogg
- * @param string $name. name/id to use for the select element
- * @returns HTML select
- */
- function softwareproduct_drop_down($name, $id, $productid, $visibility='internal')
- {
- global $dbSoftware, $dbSoftwareProducts;
- // extract software
- $sql = "SELECT id, name FROM `{$dbSoftware}` AS s, ";
- $sql .= "`{$dbSoftwareProducts}` AS sp WHERE s.id = sp.softwareid ";
- $sql .= "AND productid = '$productid' ";
- $sql .= "ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) >=1)
- {
- $html = "<select name='$name' id='$name'>";
- if ($visibility == 'internal' AND $id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- elseif ($visiblity = 'external' AND $id == 0)
- {
- $html .= "<option selected='selected' value=''>{$GLOBALS['strUnknown']}</option>\n";
- }
- while ($software = mysql_fetch_object($result))
- {
- $html .= "<option";
- if ($software->id == $id)
- {
- $html .= " selected='selected'";
- }
- $html .= " value='{$software->id}'>{$software->name}</option>\n";
- }
- $html .= "</select>\n";
- }
- else
- {
- $html = "-";
- }
- return $html;
- }
- /**
- * A HTML Select listbox for vendors
- * @author Ivan Lucas
- * @param string $name. name/id to use for the select element
- * @param int $id. Vendor ID to preselect
- * @returns HTML select
- */
- function vendor_drop_down($name, $id)
- {
- global $dbVendors;
- $sql = "SELECT id, name FROM `{$dbVendors}` ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='$name'>";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($row = mysql_fetch_object($result))
- {
- $html .= "<option";
- if ($row->id == $id)
- {
- $html .= " selected='selected'";
- }
- $html .= " value='{$row->id}'>{$row->name}</option>\n";
- }
- $html .= "</select>";
- return $html;
- }
- /**
- * A HTML Select listbox for Site Types
- * @author Ivan Lucas
- * @param string $name. name/id to use for the select element
- * @param int $id. Site Type ID to preselect
- * @todo TODO i18n needed site types
- * @returns HTML select
- */
- function sitetype_drop_down($name, $id)
- {
- global $dbSiteTypes;
- $sql = "SELECT typeid, typename FROM `{$dbSiteTypes}` ORDER BY typename ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html .= "<select name='$name'>\n";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($obj = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if ($obj->typeid == $id)
- {
- $html .="selected='selected' ";
- }
- $html .= "value='{$obj->typeid}'>{$obj->typename}</option>\n";
- }
- $html .= "</select>";
- return $html;
- }
- /**
- * Returns the HTML for a drop down list of upported products for the given contact and with the
- * given name and with the given product selected
- * @author Ivan Lucas
- * @todo FIXME this should use the contract and not the contact
- */
- function supported_product_drop_down($name, $contactid, $productid)
- {
- global $CONFIG, $dbSupportContacts, $dbMaintenance, $dbProducts, $strXIncidentsLeft;
- $sql = "SELECT *, p.id AS productid, p.name AS productname FROM `{$dbSupportContacts}` AS sc, `{$dbMaintenance}` AS m, `{$dbProducts}` AS p ";
- $sql .= "WHERE sc.maintenanceid = m.id AND m.product = p.id ";
- $sql .= "AND sc.contactid='$contactid'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if ($CONFIG['debug']) $html .= "<!-- Original product {$productid}-->";
- $html .= "<select name=\"$name\">\n";
- if ($productid == 0)
- {
- $html .= "<option selected='selected' value='0'>No Contract - Not Product Related</option>\n";
- }
- if ($productid == -1)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($products = mysql_fetch_objecy($result))
- {
- $remainingstring = sprintf($strXIncidentsLeft, incidents_remaining($products->incidentpoolid));
- $html .= "<option ";
- if ($productid == $products->productid)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$products->productid}'>";
- $html .= servicelevel_name($products->servicelevelid)." ".$products->productname.", Exp:".date($CONFIG['dateformat_shortdate'], $products->expirydate).", $remainingstring";
- $html .= "</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * A HTML Select listbox for user roles
- * @author Ivan Lucas
- * @param string $name. name to use for the select element
- * @param int $id. Role ID to preselect
- * @returns HTML select
- */
- function role_drop_down($name, $id)
- {
- global $dbRoles;
- $sql = "SELECT id, rolename FROM `{$dbRoles}` ORDER BY rolename ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='{$name}'>";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($role = mysql_fetch_object($result))
- {
- $html .= "<option value='{$role->id}'";
- if ($role->id == $id)
- {
- $html .= " selected='selected'";
- }
- $html .= ">{$role->rolename}</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * A HTML Select listbox for user groups
- * @author Ivan Lucas
- * @param string $name. name attribute to use for the select element
- * @param int $selected. Group ID to preselect
- * @returns HTML select
- */
- function group_drop_down($name, $selected)
- {
- global $grouparr, $numgroups;
- $html = "<select name='$name'>";
- $html .= "<option value='0'>{$GLOBALS['strNone']}</option>\n";
- if ($numgroups >= 1)
- {
- foreach ($grouparr AS $groupid => $groupname)
- {
- $html .= "<option value='$groupid'";
- if ($groupid == $selected)
- {
- $html .= " selected='selected'";
- }
- $html .= ">$groupname</option>\n";
- }
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * A HTML Form and Select listbox for user groups, with javascript to reload page
- * @param int $selected. Group ID to preselect
- * @param string $urlargs. (Optional) text to pass after the '?' in the url (parameters)
- * @returns int Number of groups found
- * @note outputs a HTML form directly
- */
- function group_selector($selected, $urlargs='')
- {
- $gsql = "SELECT * FROM `{$GLOBALS['dbGroups']}` ORDER BY name";
- $gresult = mysql_query($gsql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- while ($group = mysql_fetch_object($gresult))
- {
- $grouparr[$group->id] = $group->name;
- }
- $numgroups = mysql_num_rows($gresult);
- if (!empty($urlargs)) $urlargs = "&{$urlargs}";
- if ($numgroups >= 1)
- {
- echo "<form action='{$_SERVER['PHP_SELF']}?{$urlargs}' class='filterform' method='get'>";
- echo "{$GLOBALS['strGroup']}: <select name='choosegroup' onchange='window.location.href=this.options[this.selectedIndex].value'>";
- echo "<option value='{$_SERVER['PHP_SELF']}?gid=all{$urlargs}'";
- if ($selected == 'all') echo " selected='selected'";
- echo ">{$GLOBALS['strAll']}</option>\n";
- echo "<option value='{$_SERVER['PHP_SELF']}?gid=allonline{$urlargs}'";
- if ($selected == 'allonline') echo " selected='selected'";
- echo ">{$GLOBALS['strAllOnline']}</option>\n";
- foreach ($grouparr AS $groupid => $groupname)
- {
- echo "<option value='{$_SERVER['PHP_SELF']}?gid={$groupid}{$urlargs}'";
- if ($groupid == $selected) echo " selected='selected'";
- echo ">{$groupname}</option>\n";
- }
- echo "<option value='{$_SERVER['PHP_SELF']}?gid=0{$urlargs}'";
- if ($selected === '0') echo " selected='selected'";
- echo ">{$GLOBALS['strUsersNoGroup']}</option>\n";
- echo "</select>\n";
- echo "</form>\n";
- }
- return $numgroups;
- }
- /**
- * Return HTML for a box to select interface style/theme
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. Interface style ID
- * @returns string. HTML
- */
- function interfacestyle_drop_down($name, $id)
- {
- global $dbInterfaceStyles;
- // extract statuses
- $sql = "SELECT id, name FROM `{$dbInterfaceStyles}` ORDER BY name ASC";
- $result = mysql_query($sql);
- $html = "<select name=\"{$name}\">";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($styles = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if ($styles->id == $id)
- {
- $html .= "selected='selected'";
- }
- $html .= " value=\"{$styles->id}\">{$styles->name}</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Retrieve cssurl and headerhtml for given interface style
- * @author Ivan Lucas
- * @param int $id. Interface style ID
- * @returns asoc array.
- */
- function interface_style($id)
- {
- global $CONFIG, $dbInterfaceStyles;
- $sql = "SELECT cssurl, headerhtml FROM `{$dbInterfaceStyles}` WHERE id='$id'";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) == 0)
- {
- mysql_free_result($result);
- $style = (array($CONFIG['default_css_url'],'')); // default style
- }
- else
- {
- $style = mysql_fetch_assoc($result);
- mysql_free_result($result);
- }
- if (empty($style))
- {
- $style = (array($CONFIG['default_css_url'],'')); // default style
- }
- return ($style);
- }
- /**
- * prints the HTML for a drop down list of incident status names (EXCLUDING 'CLOSED'),
- * with the given name and with the given id selected.
- * @author Ivan Lucas
- * @param string $name. Text to use for the HTML select name and id attributes
- * @param int $id. Status ID to preselect
- * @param bool $disabled. Disable the select box when TRUE
- * @returns string. HTML.
- */
- function incidentstatus_drop_down($name, $id, $disabled = FALSE)
- {
- global $dbIncidentStatus;
- // extract statuses
- $sql = "SELECT id, name FROM `{$dbIncidentStatus}` WHERE id<>2 AND id<>7 AND id<>10 ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_num_rows($result) < 1)
- {
- trigger_error("Zero rows returned",E_USER_WARNING);
- }
- $html = "<select id='{$name}' name='{$name}'";
- if ($disabled)
- {
- $html .= " disabled='disabled' ";
- }
- $html .= ">";
- // if ($id == 0) $html .= "<option selected='selected' value='0'></option>\n";
- while ($statuses = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if ($statuses->id == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$statuses->id}'";
- $html .= ">{$GLOBALS[$statuses->name]}</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Return HTML for a select box of closing statuses
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. ID of Closing Status to pre-select. None selected if 0 or blank.
- * @todo Requires database i18n
- * @returns string. HTML
- */
- function closingstatus_drop_down($name, $id, $required = FALSE)
- {
- global $dbClosingStatus;
- // extract statuses
- $sql = "SELECT id, name FROM `{$dbClosingStatus}` ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='{$name}'";
- if ($required)
- {
- $html .= " class='required' ";
- }
- $html .= ">";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($statuses = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if ($statuses->id == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$statuses->id}'>";
- if (isset($GLOBALS[$statuses->name]))
- {
- $html .= $GLOBALS[$statuses->name];
- }
- else
- {
- $html .= $statuses->name;
- }
- $html .= "</option>\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Return HTML for a select box of user statuses
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. ID of User Status to pre-select. None selected if 0 or blank.
- * @param bool $userdisable. (optional). When TRUE an additional option is given to allow disabling of accounts
- * @returns string. HTML
- */
- function userstatus_drop_down($name, $id, $userdisable = FALSE)
- {
- global $dbUserStatus;
- // extract statuses
- $sql = "SELECT id, name FROM `{$dbUserStatus}` ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='$name'>\n";
- if ($userdisable)
- {
- $html .= "<option class='disable' selected='selected' value='0'>ACCOUNT DISABLED</option>\n";
- }
- while ($statuses = mysql_fetch_object($result))
- {
- if ($statuses->id > 0)
- {
- $html .= "<option ";
- if ($statuses->id == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$statuses->id}'>";
- $html .= "{$GLOBALS[$statuses->name]}</option>\n";
- }
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Return HTML for a select box of user statuses with javascript to effect changes immediately
- * Includes two extra options for setting Accepting yes/no
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. ID of User Status to pre-select. None selected if 0 or blank.
- * @returns string. HTML
- */
- function userstatus_bardrop_down($name, $id)
- {
- global $dbUserStatus;
- // extract statuses
- $sql = "SELECT id, name FROM `{$dbUserStatus}` ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name='$name' title='{$GLOBALS['strSetYourStatus']}' onchange=\"if ";
- $html .= "(this.options[this.selectedIndex].value != 'null') { ";
- $html .= "window.open(this.options[this.selectedIndex].value,'_top') }\">";
- $html .= "\n";
- while ($statuses = mysql_fetch_object($result))
- {
- if ($statuses->id > 0)
- {
- $html .= "<option ";
- if ($statuses->id == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='set_user_status.php?mode=setstatus&";
- $html .= "userstatus={$statuses->id}'>";
- $html .= "{$GLOBALS[$statuses->name]}</option>\n";
- }
- }
- $html .= "<option value='set_user_status.php?mode=setaccepting";
- $html .= "&accepting=Yes' class='enable seperator'>";
- $html .= "{$GLOBALS['strAccepting']}</option>\n";
- $html .= "<option value='set_user_status.php?mode=setaccepting&";
- $html .= "accepting=No' class='disable'>{$GLOBALS['strNotAccepting']}";
- $html .= "</option></select>\n";
- return $html;
- }
- /**
- * Return HTML for a select box of user email templates
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. ID of Template to pre-select. None selected if 0 or blank.
- * @param string $type. Type to display.
- * @returns string. HTML
- */
- function emailtemplate_drop_down($name, $id, $type)
- {
- global $dbEmailTemplates;
- // INL 22Apr05 Added a filter to only show user templates
- $sql = "SELECT id, name, description FROM `{$dbEmailTemplates}` WHERE type='{$type}' ORDER BY name ASC";
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- $html = "<select name=\"{$name}\">";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- while ($template = mysql_fetch_object($result))
- {
- $html .= "<option ";
- if (!empty($template->description))
- {
- $html .= "title='{$template->description}' ";
- }
- if ($template->id == $id)
- {
- $html .= "selected='selected' ";
- }
- $html .= "value='{$template->id}'>{$template->name}</option>";
- $html .= "\n";
- }
- $html .= "</select>\n";
- return $html;
- }
- /**
- * Return HTML for a select box of priority names (with icons)
- * @author Ivan Lucas
- * @param string $name. Name attribute
- * @param int $id. ID of priority to pre-select. None selected if 0 or blank.
- * @param int $max. The maximum priority ID to list.
- * @param bool $disable. Disable the control when TRUE.
- * @returns string. HTML
- */
- function priority_drop_down($name, $id, $max=4, $disable = FALSE)
- {
- global $CONFIG, $iconset;
- // INL 8Oct02 - Removed DB Query
- $html = "<select id='priority' name='$name' ";
- if ($disable)
- {
- $html .= "disabled='disabled'";
- }
- $html .= ">";
- if ($id == 0)
- {
- $html .= "<option selected='selected' value='0'></option>\n";
- }
- $html .= "<option style='text-indent: 14px; background-image: url({$CONFIG['application_webpath']}images/low_priority.gif); background-…
Large files files are truncated, but you can click here to view the full file