Ejemplo n.º 1
0
/**
 * @deprecated Replaced by {@link phorum_api_error_database()}.
 */
function phorum_database_error($error)
{
    require_once PHORUM_PATH . '/include/api/error/database.php';
    return phorum_api_error_database($error);
}
Ejemplo n.º 2
0
/**
 * Set a Phorum API error.
 *
 * @param integer $errno
 *     The error code for the error that occurred. There are several
 *     errno constants available to indicate the type of error that occurred:
 *
 *     - {@link PHORUM_ERRNO_ERROR}: A generic all-purpose error code
 *     - {@link PHORUM_ERRNO_NOACCESS}: Permission denied
 *     - {@link PHORUM_ERRNO_NOTFOUND}: Resource not found
 *     - {@link PHORUM_ERRNO_INTEGRITY}: Database integrity problem
 *     - {@link PHORUM_ERRNO_INVALIDINPUT}: Data input error
 *     - {@link PHORUM_ERRNO_DATABASE}: A database error occurred
 *
 *     For {@link PHORUM_ERRNO_DATABASE}, the function will pass on the
 *     error to the {@link phorum_api_error_database()} function. For database
 *     errors, some special handling is implemented, to be able to warn the
 *     admin about the error. While code can call the API function
 *     {@link phorum_api_error_database()} directly too, calling this
 *     function using the {@link PHORUM_ERRNO_DATABASE} $errno allows for
 *     a more consistent way to do Phorum error handling.
 *
 * @param string $error
 *     This is the error message, describing the error that occurred.
 *     if this parameter is omitted or NULL, then the message will be
 *     set to a generic message, based on the {@link $errno} that was used.
 *
 * @return bool
 *     This function will always use FALSE as its return value,
 *     so a construction like "return phorum_api_error(...)" can
 *     be used for setting an error and returning FALSE at the same time.
 */
function phorum_api_error($errno, $error = NULL)
{
    global $PHORUM;
    if ($error === NULL) {
        if (isset($PHORUM["API"]["errormessages"][$errno])) {
            $error = $PHORUM["API"]["errormessages"][$errno];
        } else {
            $error = "Unknown errno value ({$errno}).";
        }
    }
    if ($errno == PHORUM_ERRNO_DATABASE) {
        require_once PHORUM_PATH . '/include/api/error/database.php';
        return phorum_api_error_database($error);
    }
    $PHORUM["API"]["errno"] = $errno;
    $PHORUM["API"]["error"] = $error;
    return FALSE;
}