original_string: public static function get_data_requests_count($userid = 0, $statuses = [], $types = [], $creationmethods = []) {
          global $DB, $USER;
          $count = 0;
          $sqlparams = [];
          $sqlconditions = [];
          if (!empty($statuses)) {
              list($statusinsql, $sqlparams) = $DB->get_in_or_equal($statuses, SQL_PARAMS_NAMED);
              $sqlconditions[] = "status $statusinsql";
          }
          if (!empty($types)) {
              list($typeinsql, $typeparams) = $DB->get_in_or_equal($types, SQL_PARAMS_NAMED);
              $sqlconditions[] = "type $typeinsql";
              $sqlparams = array_merge($sqlparams, $typeparams);
          }
          if (!empty($creationmethods)) {
              list($typeinsql, $typeparams) = $DB->get_in_or_equal($creationmethods, SQL_PARAMS_NAMED);
              $sqlconditions[] = "creationmethod $typeinsql";
              $sqlparams = array_merge($sqlparams, $typeparams);
          }
          if ($userid) {
              // Get the data requests for the user or data requests made by the user.
              $sqlconditions[] = "(userid = :userid OR requestedby = :requestedby)";
              $params = [
                  'userid' => $userid,
                  'requestedby' => $userid
              ];
  
              // Build a list of user IDs that the user is allowed to make data requests for.
              // Of course, the user should be included in this list.
              $alloweduserids = [$userid];
              // Get any users that the user can make data requests for.
              if ($children = helper::get_children_of_user($userid)) {
                  // Get the list of user IDs of the children and merge to the allowed user IDs.
                  $alloweduserids = array_merge($alloweduserids, array_keys($children));
              }
              list($insql, $inparams) = $DB->get_in_or_equal($alloweduserids, SQL_PARAMS_NAMED);
              $sqlconditions[] .= "userid $insql";
              $select = implode(' AND ', $sqlconditions);
              $params = array_merge($params, $inparams, $sqlparams);
  
              $count = data_request::count_records_select($select, $params);
          } else {
              // If the current user is one of the site's Data Protection Officers, then fetch all data requests.
              if (self::is_site_dpo($USER->id)) {
                  if (!empty($sqlconditions)) {
                      $select = implode(' AND ', $sqlconditions);
                      $count = data_request::count_records_select($select, $sqlparams);
                  } else {
                      $count = data_request::count_records();
                  }
              }
          }
  
          return $count;
      }
code: public static function get_data_requests_count($userid = 0, $statuses = [], $types = [], $creationmethods = []) {
          global $DB, $USER;
          $count = 0;
          $sqlparams = [];
          $sqlconditions = [];
          if (!empty($statuses)) {
              list($statusinsql, $sqlparams) = $DB->get_in_or_equal($statuses, SQL_PARAMS_NAMED);
              $sqlconditions[] = "status $statusinsql";
          }
          if (!empty($types)) {
              list($typeinsql, $typeparams) = $DB->get_in_or_equal($types, SQL_PARAMS_NAMED);
              $sqlconditions[] = "type $typeinsql";
              $sqlparams = array_merge($sqlparams, $typeparams);
          }
          if (!empty($creationmethods)) {
              list($typeinsql, $typeparams) = $DB->get_in_or_equal($creationmethods, SQL_PARAMS_NAMED);
              $sqlconditions[] = "creationmethod $typeinsql";
              $sqlparams = array_merge($sqlparams, $typeparams);
          }
          if ($userid) {
              // Get the data requests for the user or data requests made by the user.
              $sqlconditions[] = "(userid = :userid OR requestedby = :requestedby)";
              $params = [
                  'userid' => $userid,
                  'requestedby' => $userid
              ];
  
              // Build a list of user IDs that the user is allowed to make data requests for.
              // Of course, the user should be included in this list.
              $alloweduserids = [$userid];
              // Get any users that the user can make data requests for.
              if ($children = helper::get_children_of_user($userid)) {
                  // Get the list of user IDs of the children and merge to the allowed user IDs.
                  $alloweduserids = array_merge($alloweduserids, array_keys($children));
              }
              list($insql, $inparams) = $DB->get_in_or_equal($alloweduserids, SQL_PARAMS_NAMED);
              $sqlconditions[] .= "userid $insql";
              $select = implode(' AND ', $sqlconditions);
              $params = array_merge($params, $inparams, $sqlparams);
  
              $count = data_request::count_records_select($select, $params);
          } else {
              // If the current user is one of the site's Data Protection Officers, then fetch all data requests.
              if (self::is_site_dpo($USER->id)) {
                  if (!empty($sqlconditions)) {
                      $select = implode(' AND ', $sqlconditions);
                      $count = data_request::count_records_select($select, $sqlparams);
                  } else {
                      $count = data_request::count_records();
                  }
              }
          }
  
          return $count;
      }
code_tokens: public static function get_data_requests_count ( $ userid = 0 , $ statuses = [ ] , $ types = [ ] , $ creationmethods = [ ] ) { global $ DB , $ USER ; $ count = 0 ; $ sqlparams = [ ] ; $ sqlconditions = [ ] ; if ( ! empty ( $ statuses ) ) { list ( $ statusinsql , $ sqlparams ) = $ DB -> get_in_or_equal ( $ statuses , SQL_PARAMS_NAMED ) ; $ sqlconditions [ ] = "status $statusinsql" ; } if ( ! empty ( $ types ) ) { list ( $ typeinsql , $ typeparams ) = $ DB -> get_in_or_equal ( $ types , SQL_PARAMS_NAMED ) ; $ sqlconditions [ ] = "type $typeinsql" ; $ sqlparams = array_merge ( $ sqlparams , $ typeparams ) ; } if ( ! empty ( $ creationmethods ) ) { list ( $ typeinsql , $ typeparams ) = $ DB -> get_in_or_equal ( $ creationmethods , SQL_PARAMS_NAMED ) ; $ sqlconditions [ ] = "creationmethod $typeinsql" ; $ sqlparams = array_merge ( $ sqlparams , $ typeparams ) ; } if ( $ userid ) { // Get the data requests for the user or data requests made by the user. $ sqlconditions [ ] = "(userid = :userid OR requestedby = :requestedby)" ; $ params = [ 'userid' => $ userid , 'requestedby' => $ userid ] ; // Build a list of user IDs that the user is allowed to make data requests for. // Of course, the user should be included in this list. $ alloweduserids = [ $ userid ] ; // Get any users that the user can make data requests for. if ( $ children = helper :: get_children_of_user ( $ userid ) ) { // Get the list of user IDs of the children and merge to the allowed user IDs. $ alloweduserids = array_merge ( $ alloweduserids , array_keys ( $ children ) ) ; } list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ alloweduserids , SQL_PARAMS_NAMED ) ; $ sqlconditions [ ] .= "userid $insql" ; $ select = implode ( ' AND ' , $ sqlconditions ) ; $ params = array_merge ( $ params , $ inparams , $ sqlparams ) ; $ count = data_request :: count_records_select ( $ select , $ params ) ; } else { // If the current user is one of the site's Data Protection Officers, then fetch all data requests. if ( self :: is_site_dpo ( $ USER -> id ) ) { if ( ! empty ( $ sqlconditions ) ) { $ select = implode ( ' AND ' , $ sqlconditions ) ; $ count = data_request :: count_records_select ( $ select , $ sqlparams ) ; } else { $ count = data_request :: count_records ( ) ; } } } return $ count ; }
docstring: Fetches the count of data request records based on the given parameters.
  
  @param int $userid The User ID.
  @param int[] $statuses The status filters.
  @param int[] $types The request type filters.
  @param int[] $creationmethods The request creation method filters.
  @return int
  @throws coding_exception
  @throws dml_exception
docstring_tokens: Fetches the count of data request records based on the given parameters .