Infractions::bat_getInfraction PHP Method

bat_getInfraction() public method

Params: $type (string), either ban, kick or mute; $id (int), ID of infraction
public bat_getInfraction ( $type, $id )
    public function bat_getInfraction($type, $id)
    {
        if ($type === "ban" || $type === "temp_ban") {
            $result = $this->_db->get($this->_prefix . 'ban', array("ban_id", "=", $id))->results();
            return $result;
        } else {
            if ($type === "kick") {
                $result = $this->_db->get($this->_prefix . 'kick', array("kick_id", "=", $id))->results();
                return $result;
            } else {
                if ($type === "mute") {
                    $result = $this->_db->get($this->_prefix . 'mute', array("mute_id", "=", $id))->results();
                    return $result;
                }
            }
        }
        return false;
    }

Usage Example

Example #1
0
         break;
     case 'mute':
     case 'temp_mute':
         $action = '<span class="label label-warning">' . $infractions_language['mute'] . '</span>';
         break;
     case 'warning':
         $action = '<span class="label label-info">' . $infractions_language['warning'] . '</span>';
         break;
     case 'kick':
         $action = '<span class="label label-primary">' . $infractions_language['kick'] . '</span>';
         break;
 }
 // Get infraction info, depending on plugin
 switch ($inf_plugin) {
     case 'bat':
         $infraction = $infractions->bat_getInfraction($_GET["type"], $_GET["id"]);
         // Get username from UUID
         // First check if they're registered on the site
         $username = $queries->getWhere('users', array('uuid', '=', $infraction[0]->UUID));
         if (!count($username)) {
             // Couldn't find, check UUID cache
             $username = $queries->getWhere('uuid_cache', array('uuid', '=', $infraction[0]->UUID));
             if (!count($username)) {
                 // Couldn't find, check BAT database
                 $username = $infractions->bat_getUsernameFromUUID($infraction[0]->UUID);
                 if (!count($username)) {
                     // Couldn't find, get and put into cache
                     $profile = ProfileUtils::getProfile($infraction[0]->UUID);
                     if (empty($profile)) {
                         echo 'Could not find that player, please try again later.';
                         die;