%s %s

", _c("error-reporter:An error occured:"), getLastError()); } /** * Determine if the specified user exists * @param $strAct (string) Account name of the user * @return (bool / null) If the function fails, it returns null. * @throws Exception */ function erIsAct($strAct) { $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct); if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); return null; } return (pg_num_rows($hQuery) > 0); } /** * Get the real user name for an account name * @param $strAct (string) Account name of the user to look up * @return (string) The real name of the user. If the function fails, it returns null. * @throws Exception */ function erGetRealUserName($strAct) { $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct); if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // User not found in database, return account name } $arResult = pg_fetch_array($hQuery); return user_join_name($arResult); } /** * Determine if a specified group exists * @param $strAct (string) Account name of the group * @return (bool / null) If the function fails, it returns null. * @throws Exception */ function erIsGroup($strAct) { $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); return null; } return (pg_num_rows($hQuery) > 0); } /** * Look up the name of a group * @param $strAct (string) Account name of the group * @return (string) The name of the group. If the function fails, it returns null. * @throws Exception */ function erGetGroupName($strAct) { $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // Group not found in database, return account name } $arResult = pg_fetch_array($hQuery); return $arResult["name"]; } /** * Create a link to write a mail to the specified account name. * This function returns a link if the specified account exists, otherwise it returns the * account name. * @param $strAct (string) Account name * @return string */ function erMailToUserLink($strAct) { if(!erIsAct($strAct)) { return $strAct; } return popup(relroot("msg/write/?to=".user_mail_addr($strAct)), 600, 400, erGetRealUserName($strAct)); } /** * Determine if a specified string is a valid mail address * @param $strAddr string * @return string */ function erIsMailAddress($strAddr) { return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0) and (preg_match("/(\s*,\s*)$/", $strAddr) == 0)); } function erInsertLog($sMsg) { log_insert($sMsg, null, "Error Report Wizard"); } ?>