public static function check_lti_1x_id($linkid, $course, $typeid) {
        global $DB;
        // Check if lti type is zero or not (comes from a backup).
        $sqlparams1 = array();
        $sqlparams1['linkid'] = $linkid;
        $sqlparams1['course'] = $course;
        $ltiactivity = $DB->get_record('lti', array('id' => $linkid, 'course' => $course));
        if ($ltiactivity) {
            if ($ltiactivity->typeid == 0) {
                $tool = lti_get_tool_by_url_match($ltiactivity->toolurl, $course);
                if (!$tool) {
                    $tool = lti_get_tool_by_url_match($ltiactivity->securetoolurl, $course);
                }
                return (($tool) && ($typeid == $tool->id));
            } else {
                $sqlparams2 = array();
                $sqlparams2['linkid'] = $linkid;
                $sqlparams2['course'] = $course;
                $sqlparams2['typeid'] = $typeid;
                $sql = 'SELECT lti.*
                          FROM {lti} lti
                    INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                         WHERE lti.id = ?
                               AND lti.course = ?
                               AND typ.id = ?';
                return $DB->record_exists_sql($sql, $sqlparams2);
            }
        } else {
            return false;
        }
    }
public static function check_lti_1x_id($linkid, $course, $typeid) {
        global $DB;
        // Check if lti type is zero or not (comes from a backup).
        $sqlparams1 = array();
        $sqlparams1['linkid'] = $linkid;
        $sqlparams1['course'] = $course;
        $ltiactivity = $DB->get_record('lti', array('id' => $linkid, 'course' => $course));
        if ($ltiactivity) {
            if ($ltiactivity->typeid == 0) {
                $tool = lti_get_tool_by_url_match($ltiactivity->toolurl, $course);
                if (!$tool) {
                    $tool = lti_get_tool_by_url_match($ltiactivity->securetoolurl, $course);
                }
                return (($tool) && ($typeid == $tool->id));
            } else {
                $sqlparams2 = array();
                $sqlparams2['linkid'] = $linkid;
                $sqlparams2['course'] = $course;
                $sqlparams2['typeid'] = $typeid;
                $sql = 'SELECT lti.*
                          FROM {lti} lti
                    INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                         WHERE lti.id = ?
                               AND lti.course = ?
                               AND typ.id = ?';
                return $DB->record_exists_sql($sql, $sqlparams2);
            }
        } else {
            return false;
        }
    }
public static function check_lti_1x_id ( $ linkid , $ course , $ typeid ) { global $ DB ; // Check if lti type is zero or not (comes from a backup). $ sqlparams1 = array ( ) ; $ sqlparams1 [ 'linkid' ] = $ linkid ; $ sqlparams1 [ 'course' ] = $ course ; $ ltiactivity = $ DB -> get_record ( 'lti' , array ( 'id' => $ linkid , 'course' => $ course ) ) ; if ( $ ltiactivity ) { if ( $ ltiactivity -> typeid == 0 ) { $ tool = lti_get_tool_by_url_match ( $ ltiactivity -> toolurl , $ course ) ; if ( ! $ tool ) { $ tool = lti_get_tool_by_url_match ( $ ltiactivity -> securetoolurl , $ course ) ; } return ( ( $ tool ) && ( $ typeid == $ tool -> id ) ) ; } else { $ sqlparams2 = array ( ) ; $ sqlparams2 [ 'linkid' ] = $ linkid ; $ sqlparams2 [ 'course' ] = $ course ; $ sqlparams2 [ 'typeid' ] = $ typeid ; $ sql = 'SELECT lti.*
                          FROM {lti} lti
                    INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                         WHERE lti.id = ?
                               AND lti.course = ?
                               AND typ.id = ?' ; return $ DB -> record_exists_sql ( $ sql , $ sqlparams2 ) ; } } else { return false ; } }
Check if an LTI id is valid when we are in a LTI 1.x case

@param string $linkid             The lti id
@param string  $course            The course
@param string  $typeid            The lti type id

@return boolean
Check if an LTI id is valid when we are in a LTI 1 . x case