original_string: public static function check_lti_id($linkid, $course, $toolproxy) {
          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->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) && ($toolproxy == $tool->toolproxyid));
          } else {
              $sqlparams2 = array();
              $sqlparams2['linkid'] = $linkid;
              $sqlparams2['course'] = $course;
              $sqlparams2['toolproxy'] = $toolproxy;
              $sql = 'SELECT lti.*
                        FROM {lti} lti
                  INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                       WHERE lti.id = ?
                             AND lti.course = ?
                             AND typ.toolproxyid = ?';
              return $DB->record_exists_sql($sql, $sqlparams2);
          }
      }
code: public static function check_lti_id($linkid, $course, $toolproxy) {
          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->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) && ($toolproxy == $tool->toolproxyid));
          } else {
              $sqlparams2 = array();
              $sqlparams2['linkid'] = $linkid;
              $sqlparams2['course'] = $course;
              $sqlparams2['toolproxy'] = $toolproxy;
              $sql = 'SELECT lti.*
                        FROM {lti} lti
                  INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                       WHERE lti.id = ?
                             AND lti.course = ?
                             AND typ.toolproxyid = ?';
              return $DB->record_exists_sql($sql, $sqlparams2);
          }
      }
code_tokens: public static function check_lti_id ( $ linkid , $ course , $ toolproxy ) { 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 -> 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 ) && ( $ toolproxy == $ tool -> toolproxyid ) ) ; } else { $ sqlparams2 = array ( ) ; $ sqlparams2 [ 'linkid' ] = $ linkid ; $ sqlparams2 [ 'course' ] = $ course ; $ sqlparams2 [ 'toolproxy' ] = $ toolproxy ; $ sql = 'SELECT lti.*
                        FROM {lti} lti
                  INNER JOIN {lti_types} typ ON lti.typeid = typ.id
                       WHERE lti.id = ?
                             AND lti.course = ?
                             AND typ.toolproxyid = ?' ; return $ DB -> record_exists_sql ( $ sql , $ sqlparams2 ) ; } }
docstring: Check if an LTI id is valid.
  
  @param string $linkid             The lti id
  @param string  $course            The course
  @param string  $toolproxy         The tool proxy id
  
  @return boolean
docstring_tokens: Check if an LTI id is valid .