diff --git a/VERSION b/VERSION index 5acfa932..e40c2f0d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.223.1 +2.1.224.1 diff --git a/commands/exreport.php b/commands/exreport.php index 561776c8..7d793ed7 100644 --- a/commands/exreport.php +++ b/commands/exreport.php @@ -31,7 +31,7 @@ WHEN a.cancel = FALSE OR a.raid_done = FALSE THEN ( - a.extra_mystic + a.extra_valor + a.extra_instinct + 1 + a.extra_in_person + a.extra_alien + 1 ) ELSE 0 @@ -45,7 +45,7 @@ WHEN a.cancel = FALSE OR a.raid_done = FALSE THEN ( - a.extra_mystic + a.extra_valor + a.extra_instinct + 1 + a.extra_in_person + a.extra_alien + 1 ) ELSE 0 diff --git a/config/config.json.example b/config/config.json.example index 7cd2120c..5a234949 100644 --- a/config/config.json.example +++ b/config/config.json.example @@ -1,5 +1,5 @@ { - "VERSION":"2.1.223.1", + "VERSION":"2.1.224.1", "DB_HOST":"localhost", "DB_NAME":"your_database_name", "DB_USER":"your_database_user", diff --git a/config/defaults-config.json b/config/defaults-config.json index 5c295663..3acb25df 100644 --- a/config/defaults-config.json +++ b/config/defaults-config.json @@ -85,6 +85,7 @@ "RAID_POLL_SHOW_CREATOR":true, "RAID_POLL_ENABLE_HYPERLINKS_IN_NAMES":true, "RAID_POLL_SHOW_NICK_OVER_NAME":false, + "RAID_POLL_VOTE_ALIEN":false, "RAID_ENDED_HIDE_KEYS":false, "MYSQL_SORT_COLLATE":"", "RAID_EX_GYM_MARKER":"icon", diff --git a/constants.php b/constants.php index a4fd95fe..3e46cc44 100644 --- a/constants.php +++ b/constants.php @@ -35,7 +35,9 @@ defined('EMOJI_NO_ALARM') or define('EMOJI_NO_ALARM',iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F515))); defined('EMOJI_FRIEND') or define('EMOJI_FRIEND', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F91D))); defined('EMOJI_WANT_INVITE')or define('EMOJI_WANT_INVITE', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F4E5))); - +defined('EMOJI_IN_PERSON') or define('EMOJI_IN_PERSON', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F9E1))); +defined('EMOJI_ALIEN') or define('EMOJI_ALIEN', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F47D))); + // Weather Icons. defined('EMOJI_W_SUNNY') or define('EMOJI_W_SUNNY', iconv('UCS-4LE', 'UTF-8', pack('V', 0x2600))); defined('EMOJI_W_CLEAR') or define('EMOJI_W_CLEAR', iconv('UCS-4LE', 'UTF-8', pack('V', 0x2728))); diff --git a/lang/language.json b/lang/language.json index 396982eb..d2de64a9 100644 --- a/lang/language.json +++ b/lang/language.json @@ -2903,6 +2903,18 @@ "PL": "TRANSLATE", "FI": "Uusi osallistuja!" }, + "alert_add_alien_trainer": { + "NL": "TRANSLATE", + "DE": "TRANSLATE", + "EN": "User is inviting a player from outside the group!", + "IT": "TRANSLATE", + "PT-BR": "TRANSLATE", + "RU": "TRANSLATE", + "NO": "TRANSLATE", + "FR": "TRANSLATE", + "PL": "TRANSLATE", + "FI": "Pelaaja kutsuu kaverin ryhmän ulkopuolelta!" + }, "alert_later": { "NL": "Late Speler!", "DE": "Verspäteter Trainer!", diff --git a/logic/alarm.php b/logic/alarm.php index 7491ddc0..47b94ee8 100644 --- a/logic/alarm.php +++ b/logic/alarm.php @@ -69,14 +69,16 @@ function alarm($raid_id_array, $user_id, $action, $info = '') // Adding a guest if($action == "extra") { debug_log('Alarm additional trainer: ' . $info); - $color_old = array('mystic', 'valor', 'instinct'); - $color_new = array (TEAM_B, TEAM_R, TEAM_Y); - $color = str_replace($color_old, $color_new, $info); + $icons = ['alien' => EMOJI_ALIEN, 'in_person' => EMOJI_IN_PERSON]; // Sending message - $msg_text = '' . getTranslation('alert_add_trainer', true, $recipient_language) . '' . CR; + if($info == 'alien') { + $msg_text = '' . getTranslation('alert_add_alien_trainer', true, $recipient_language) . '' . CR; + }else { + $msg_text = '' . getTranslation('alert_add_trainer', true, $recipient_language) . '' . CR; + } $msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR; - $msg_text .= EMOJI_SINGLE . SP . $username . SP . '+' . $color . CR; + $msg_text .= EMOJI_SINGLE . SP . $username . SP . '+' . $icons[$info] . CR; $msg_text .= EMOJI_CLOCK . SP . check_time($attendtime); $msg_text .= create_traincode_msg($trainercode); $tg_json[] = sendMessage($answer['user_id'], $msg_text, true); diff --git a/logic/get_overview.php b/logic/get_overview.php index 74757722..4ae2190c 100644 --- a/logic/get_overview.php +++ b/logic/get_overview.php @@ -64,13 +64,12 @@ function get_overview( $active_raids, $chat_title, $chat_username ) $rs_att = my_query( " SELECT count(attend_time) AS count, - sum(team = 'mystic' && want_invite = 0) + sum(case when want_invite = 0 then attendance.extra_mystic else 0 end) AS count_mystic, - sum(team = 'valor' && want_invite = 0) + sum(case when want_invite = 0 then attendance.extra_valor else 0 end) AS count_valor, - sum(team = 'instinct' && want_invite = 0) + sum(case when want_invite = 0 then attendance.extra_instinct else 0 end) AS count_instinct, - sum(team IS NULL && want_invite = 0) AS count_no_team, - sum(case when want_invite = 1 then 1+attendance.extra_mystic+extra_instinct+extra_valor else 0 end) AS count_want_invite + sum(want_invite = 0 && remote = 0) + sum(case when want_invite = 0 && remote = 0 then attendance.extra_in_person else 0 end) AS count_in_person, + sum(want_invite = 0 && remote = 1) + sum(case when want_invite = 0 && remote = 1 then attendance.extra_in_person else 0 end) AS count_remote, + sum(case when want_invite = 0 then attendance.extra_alien else 0 end) AS extra_alien, + sum(case when want_invite = 1 then 1 + attendance.extra_in_person else 0 end) AS count_want_invite FROM ( - SELECT DISTINCT attend_time, user_id, extra_mystic, extra_valor, extra_instinct, want_invite + SELECT DISTINCT attend_time, user_id, extra_in_person, extra_alien, remote, want_invite FROM attendance WHERE raid_id = {$raid_id} AND attend_time IS NOT NULL @@ -88,11 +87,10 @@ function get_overview( $active_raids, $chat_title, $chat_username ) // Add to message. if ($att['count'] > 0) { - $msg .= EMOJI_GROUP . ' ' . ($att['count_mystic'] + $att['count_valor'] + $att['count_instinct'] + $att['count_no_team'] + $att['count_want_invite']) . ' — '; - $msg .= ((($att['count_mystic']) > 0) ? TEAM_B . ($att['count_mystic']) . ' ' : ''); - $msg .= ((($att['count_valor']) > 0) ? TEAM_R . ($att['count_valor']) . ' ' : ''); - $msg .= ((($att['count_instinct']) > 0) ? TEAM_Y . ($att['count_instinct']) . ' ' : ''); - $msg .= (($att['count_no_team'] > 0) ? TEAM_UNKNOWN . $att['count_no_team'] : ''); + $msg .= EMOJI_GROUP . ' ' . ($att['count_in_person'] + $att['count_remote'] + $att['extra_remote'] + $att['count_want_invite']) . ' — '; + $msg .= ((($att['count_in_person']) > 0) ? EMOJI_IN_PERSON . ($att['count_in_person']) . ' ' : ''); + $msg .= ((($att['count_remote']) > 0) ? EMOJI_REMOTE . ($att['count_remote']) . ' ' : ''); + $msg .= ((($att['extra_alien']) > 0) ? EMOJI_ALIEN . ($att['extra_alien']) . ' ' : ''); $msg .= (($att['count_want_invite'] > 0) ? EMOJI_WANT_INVITE . $att['count_want_invite'] : ''); $msg .= CR; } diff --git a/logic/get_remote_users_count.php b/logic/get_remote_users_count.php index 3df56130..1ab72065 100644 --- a/logic/get_remote_users_count.php +++ b/logic/get_remote_users_count.php @@ -13,12 +13,12 @@ function get_remote_users_count($raid_id, $user_id, $attend_time = false) if(!$attend_time) { // If attend time is not given, get the one user has already voted for from database $att_sql = "( - SELECT attend_time - FROM attendance - WHERE raid_id = {$raid_id} - AND user_id = {$user_id} - LIMIT 1 - )"; + SELECT attend_time + FROM attendance + WHERE raid_id = {$raid_id} + AND user_id = {$user_id} + LIMIT 1 + )"; }else { // Use given attend time (needed when voting for new time) $att_sql = "'{$attend_time}'"; @@ -28,8 +28,8 @@ function get_remote_users_count($raid_id, $user_id, $attend_time = false) // Ignore max limit if attend time is 'Anytime' $rs = my_query( " - SELECT IF(attend_time = '" . ANYTIME . "', 0, sum(1 + extra_mystic + extra_valor + extra_instinct)) AS remote_users - FROM (SELECT DISTINCT user_id, extra_mystic, extra_valor, extra_instinct, remote, attend_time FROM attendance WHERE remote = 1 AND cancel = 0 AND raid_done = 0) as T + SELECT IF(attend_time = '" . ANYTIME . "', 0, sum(1 + extra_in_person)) AS remote_users + FROM (SELECT DISTINCT user_id, extra_in_person, attend_time FROM attendance WHERE remote = 1 AND cancel = 0 AND raid_done = 0) as T WHERE attend_time = {$att_sql} GROUP BY attend_time " diff --git a/logic/keys_vote.php b/logic/keys_vote.php index 9f3c7175..053e337f 100644 --- a/logic/keys_vote.php +++ b/logic/keys_vote.php @@ -44,47 +44,30 @@ function keys_vote($raid) 'callback_data' => $raid['id'] . ':vote_extra:0' ], [ - 'text' => '+ ' . TEAM_B, - 'callback_data' => $raid['id'] . ':vote_extra:mystic' + 'text' => '+ ' . EMOJI_IN_PERSON, + 'callback_data' => $raid['id'] . ':vote_extra:in_person' ], [ - 'text' => '+ ' . TEAM_R, - 'callback_data' => $raid['id'] . ':vote_extra:valor' - ], - [ - 'text' => '+ ' . TEAM_Y, - 'callback_data' => $raid['id'] . ':vote_extra:instinct' + 'text' => '+ ' . EMOJI_ALIEN, + 'callback_data' => $raid['id'] . ':vote_extra:alien' ] ] ]; // Remote Raid Pass key - $button_remote = [ - [ - [ - 'text' => EMOJI_REMOTE, - 'callback_data' => $raid['id'] . ':vote_remote:0' - ] - ] - ]; - - if($config->RAID_REMOTEPASS_USERS && ($raid['event_allow_remote'] == null or $raid['event_allow_remote'] != 0)) { - $buttons_extra[0] = array_merge($buttons_extra[0], $button_remote[0]); + $buttons_extra[0][] = [ + 'text' => EMOJI_REMOTE, + 'callback_data' => $raid['id'] . ':vote_remote:0' + ]; } // Want invite key - $button_want_invite = [ - [ - [ - 'text' => EMOJI_WANT_INVITE, - 'callback_data' => $raid['id'] . ':vote_want_invite:0' - ] - ] - ]; - if($config->RAID_WANT_INVITE && ($raid['event_allow_invite'] == null or $raid['event_allow_invite'] != 0)) { - $buttons_extra[0] = array_merge($buttons_extra[0], $button_want_invite[0]); + $buttons_extra[0][] = [ + 'text' => EMOJI_WANT_INVITE, + 'callback_data' => $raid['id'] . ':vote_want_invite:0' + ]; } // Team and level keys. @@ -176,7 +159,6 @@ function keys_vote($raid) ]; $buttons_status[0] = array_merge($buttons_refresh[0], $buttons_status[0]); } - // Get current pokemon $raid_pokemon_id = $raid['pokemon']; $raid_pokemon_form_id = $raid['pokemon_form']; @@ -587,7 +569,7 @@ function keys_vote($raid) //debug_log($keys_default); // Add Ex-Raid Invite button for raid level X - if ($raid_level == 'X') { + if ($raid['event'] == EVENT_ID_EX) { if($config->RAID_POLL_HIDE_BUTTONS_TEAM_LVL) { $buttons_extra[0] = array_merge($buttons_extra[0], $button_invite[0]); } else { diff --git a/logic/raid_edit_raidlevel_keys.php b/logic/raid_edit_raidlevel_keys.php index 3e5edca8..f06d0cab 100644 --- a/logic/raid_edit_raidlevel_keys.php +++ b/logic/raid_edit_raidlevel_keys.php @@ -43,9 +43,6 @@ function raid_edit_raidlevel_keys($gym_id, $gym_first_letter, $admin_access = [f // Raid level and action $raid_level = $level['raid_level']; - // Continue if user doesn't have permission to create ex-raid and raid_level is X - if($raid_level == 'X' && $admin_access[0] === false) continue; - // Add key for pokemon if we have just 1 pokemon for a level if($level['raid_level_count'] == 1) { $query_mon = my_query(' diff --git a/logic/send_vote_remote_users_limit_reached.php b/logic/send_vote_remote_users_limit_reached.php index 1f960a69..a96ef971 100644 --- a/logic/send_vote_remote_users_limit_reached.php +++ b/logic/send_vote_remote_users_limit_reached.php @@ -6,7 +6,7 @@ function send_vote_remote_users_limit_reached($update) { // Set the message. - $msg = getPublicTranslation('vote_remote_users_limit_reached'); + $msg = getTranslation('vote_remote_users_limit_reached'); // Answer the callback. answerCallbackQuery($update['callback_query']['id'], $msg); diff --git a/logic/show_raid_poll.php b/logic/show_raid_poll.php index 19bbec52..39cfca3b 100644 --- a/logic/show_raid_poll.php +++ b/logic/show_raid_poll.php @@ -149,6 +149,7 @@ function show_raid_poll($raid) $cnt_all = 0; $cnt_remote = 0; $cnt_want_invite = 0; + $cnt_extra_alien = 0; $cnt_latewait = 0; $cnt_cancel = 0; $cnt_done = 0; @@ -161,7 +162,8 @@ function show_raid_poll($raid) $attendance = check_trainername($attendance); // Define variables if necessary - if(!isset($cnt_array[$attendance['attend_time']][$attendance_pokemon]))$cnt_array[$attendance['attend_time']][$attendance_pokemon]['mystic']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['valor']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['instinct']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['noteam']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['late']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['remote']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['want_invite']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['total']=0; + if(!isset($cnt_array[$attendance['attend_time']][$attendance_pokemon])) + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['extra_alien']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['in_person']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['late']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['remote']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['want_invite']=$cnt_array[$attendance['attend_time']][$attendance_pokemon]['total']=0; if(!isset($cnt_array[$attendance['attend_time']]['other_pokemon'])) $cnt_array[$attendance['attend_time']]['other_pokemon'] = $cnt_array[$attendance['attend_time']]['raid_pokemon'] = $cnt_array[$attendance['attend_time']]['any_pokemon'] = 0; if($attendance['cancel'] == 0 && $attendance['raid_done'] == 0) { @@ -175,26 +177,27 @@ function show_raid_poll($raid) } // Adding to total count of specific pokemon at specific time - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['total'] += 1 + $attendance['extra_valor'] + $attendance['extra_instinct'] + $attendance['extra_mystic']; + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['total'] += 1 + $attendance['extra_in_person'] + $attendance['extra_alien']; if($attendance['want_invite'] == 0) { // Fill attendance array with results $att_array[$attendance['attend_time']][$attendance_pokemon][] = $attendance; // Fill counts array - if(!in_array($attendance['team'],["valor","mystic","instinct"])) $user_team = "noteam"; else $user_team = $attendance['team']; - $cnt_array[$attendance['attend_time']][$attendance_pokemon][$user_team] += 1; // Add 1 to user's own team's count - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['valor'] += $attendance['extra_valor']; // Add extras to team counts - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['instinct'] += $attendance['extra_instinct']; - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['mystic'] += $attendance['extra_mystic']; + if($attendance['extra_alien'] == 1) { + $cnt_extra_alien = 1; + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['extra_alien'] += $attendance['extra_alien']; + } if($attendance['late'] == 1) { $cnt_latewait = 1; - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['late'] += 1 + $attendance['extra_valor'] + $attendance['extra_mystic'] + $attendance['extra_instinct']; + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['late'] += 1 + $attendance['extra_in_person'] + $attendance['extra_alien']; } if($attendance['remote'] == 1) { $cnt_remote = 1; - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['remote'] += 1 + $attendance['extra_valor'] + $attendance['extra_mystic'] + $attendance['extra_instinct']; + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['remote'] += 1 + $attendance['extra_in_person']; + }else { + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['in_person'] += 1 + $attendance['extra_in_person']; } }else if($attendance['want_invite'] == 1) { // Create array key for attend time and pokemon to maintain correct sorting order @@ -205,15 +208,15 @@ function show_raid_poll($raid) $att_array[$attendance['attend_time']][$attendance_pokemon] = []; } - $cnt_array[$attendance['attend_time']][$attendance_pokemon]['want_invite'] += 1 + $attendance['extra_valor'] + $attendance['extra_mystic'] + $attendance['extra_instinct']; + $cnt_array[$attendance['attend_time']][$attendance_pokemon]['want_invite'] += 1 + $attendance['extra_in_person']; } }else { if($attendance['raid_done']==1) { - $cnt_done += 1 + $attendance['extra_valor'] + $attendance['extra_instinct'] + $attendance['extra_mystic']; + $cnt_done += 1 + $attendance['extra_in_person'] + $attendance['extra_alien']; $done_array[$attendance['user_id']] = $attendance; // Adding user_id as key to overwrite duplicate entries and thus only display user once even if they made multiple pokemon selections } if($attendance['cancel']==1) { - $cnt_cancel += 1 + $attendance['extra_valor'] + $attendance['extra_instinct'] + $attendance['extra_mystic']; + $cnt_cancel += 1 + $attendance['extra_in_person'] + $attendance['extra_alien']; $cancel_array[$attendance['user_id']] = $attendance; } } @@ -284,7 +287,7 @@ function show_raid_poll($raid) } // Add Ex-Raid Message if Pokemon is in Ex-Raid-List. - if($raid_level == 'X') { + if($raid['event'] == EVENT_ID_EX) { $msg = raid_poll_message($msg, CR . EMOJI_WARN . ' ' . getPublicTranslation('exraid_pass') . ' ' . EMOJI_WARN . CR); } @@ -305,9 +308,9 @@ function show_raid_poll($raid) $previous_pokemon = 'FIRST_RUN'; // Add hint for remote attendances. - if($config->RAID_REMOTEPASS_USERS && $cnt_remote > 0) { + if($config->RAID_REMOTEPASS_USERS && ($cnt_remote > 0 || $cnt_want_invite > 0 || $cnt_extra_alien > 0)) { $remote_max_msg = str_replace('REMOTE_MAX_USERS', $config->RAID_REMOTEPASS_USERS_LIMIT, getPublicTranslation('remote_participants_max')); - $msg = raid_poll_message($msg, CR . EMOJI_REMOTE . SP . getPublicTranslation('remote_participants') . SP . '' . $remote_max_msg . '' . CR); + $msg = raid_poll_message($msg, CR . ($cnt_remote > 0 ? EMOJI_REMOTE : '') . ($cnt_extra_alien > 0 ? EMOJI_ALIEN : '') . ($cnt_want_invite > 0 ? EMOJI_WANT_INVITE : '') . SP . getPublicTranslation('remote_participants') . SP . '' . $remote_max_msg . '' . CR); } // Add start raid message if($cnt_all > 0 && $config->RAID_POLL_SHOW_START_LINK) { @@ -376,10 +379,9 @@ function show_raid_poll($raid) $msg = raid_poll_message($msg, ($att_row['level'] == 0) ? ('00 ') : (($att_row['level'] < 10) ? ('0' . $att_row['level'] . ' ') : ('' . $att_row['level'] . ' '))); $msg = raid_poll_message($msg, $trainername); $msg = raid_poll_message($msg, ($att_row['remote']) ? (EMOJI_REMOTE) : ''); - $msg = raid_poll_message($msg, ($raid_level == 'X' && $att_row['invite']) ? (EMOJI_INVITE . ' ') : ''); - $msg = raid_poll_message($msg, ($att_row['extra_mystic']) ? ('+' . $att_row['extra_mystic'] . TEAM_B . ' ') : ''); - $msg = raid_poll_message($msg, ($att_row['extra_valor']) ? ('+' . $att_row['extra_valor'] . TEAM_R . ' ') : ''); - $msg = raid_poll_message($msg, ($att_row['extra_instinct']) ? ('+' . $att_row['extra_instinct'] . TEAM_Y . ' ') : ''); + $msg = raid_poll_message($msg, ($raid['event'] == EVENT_ID_EX && $att_row['invite']) ? (EMOJI_INVITE . ' ') : ''); + $msg = raid_poll_message($msg, ($att_row['extra_in_person']) ? ('+' . $att_row['extra_in_person'] . EMOJI_IN_PERSON . ' ') : ''); + $msg = raid_poll_message($msg, ($att_row['extra_alien']) ? ('+' . $att_row['extra_alien'] . EMOJI_ALIEN . ' ') : ''); $msg = raid_poll_message($msg, ($att_row['want_invite']) ? (EMOJI_WANT_INVITE) : ''); $msg = raid_poll_message($msg, ($config->RAID_POLL_SHOW_TRAINERCODE && $att_row['want_invite'] && !is_null($att_row['trainercode'])) ? ' ' . $att_row['trainercode'] . ' ': ''); @@ -427,13 +429,12 @@ function show_raid_poll($raid) $msg = raid_poll_message($msg, ($row['team'] === NULL) ? ('└ ' . $GLOBALS['teams']['unknown'] . ' ') : ('└ ' . $GLOBALS['teams'][$row['team']] . ' ')); $msg = raid_poll_message($msg, ($row['level'] == 0) ? ('00 ') : (($row['level'] < 10) ? ('0' . $row['level'] . ' ') : ('' . $row['level'] . ' '))); $msg = raid_poll_message($msg, $trainername); - $msg = raid_poll_message($msg, ($raid_level == 'X' && $row['invite']) ? (EMOJI_INVITE . ' ') : ''); + $msg = raid_poll_message($msg, ($raid['event'] == EVENT_ID_EX && $row['invite']) ? (EMOJI_INVITE . ' ') : ''); if($raid['event_vote_key_mode'] != 1) { $msg = raid_poll_message($msg, ($row['cancel'] == 1 || $row['raid_done'] == 1) ? ('[' . (($row['attend_time'] == ANYTIME) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '] ') : ''); } - $msg = raid_poll_message($msg, ($row['extra_mystic']) ? ('+' . $row['extra_mystic'] . TEAM_B . ' ') : ''); - $msg = raid_poll_message($msg, ($row['extra_valor']) ? ('+' . $row['extra_valor'] . TEAM_R . ' ') : ''); - $msg = raid_poll_message($msg, ($row['extra_instinct']) ? ('+' . $row['extra_instinct'] . TEAM_Y . ' ') : ''); + $msg = raid_poll_message($msg, ($row['extra_in_person']) ? ('+' . $row['extra_in_person'] . EMOJI_IN_PERSON . ' ') : ''); + $msg = raid_poll_message($msg, ($row['extra_alien']) ? ('+' . $row['extra_alien'] . EMOJI_ALIEN . ' ') : ''); $msg = raid_poll_message($msg, CR); } } @@ -473,21 +474,18 @@ function show_raid_poll($raid) */ function raid_poll_print_counts($msg, $cnt_array) { // Attendance counts - $count_mystic = $cnt_array['mystic']; - $count_valor = $cnt_array['valor']; - $count_instinct = $cnt_array['instinct']; + $count_in_person = $cnt_array['in_person']; $count_remote = $cnt_array['remote']; + $count_extra_alien = $cnt_array['extra_alien']; $count_want_invite = $cnt_array['want_invite']; $count_late = $cnt_array['late']; $count_total = (is_numeric($cnt_array['total'])?$cnt_array['total']:0); // Add to message. $msg = raid_poll_message($msg, ' [' . ($count_total) . '] — '); - $msg = raid_poll_message($msg, (($count_mystic > 0) ? TEAM_B . $count_mystic . ' ' : '')); - $msg = raid_poll_message($msg, (($count_valor > 0) ? TEAM_R . $count_valor . ' ' : '')); - $msg = raid_poll_message($msg, (($count_instinct > 0) ? TEAM_Y . $count_instinct . ' ' : '')); - $msg = raid_poll_message($msg, (($cnt_array['noteam'] > 0) ? TEAM_UNKNOWN . $cnt_array['noteam'] . ' ' : '')); + $msg = raid_poll_message($msg, (($count_in_person > 0) ? EMOJI_IN_PERSON . $count_in_person . ' ' : '')); $msg = raid_poll_message($msg, (($count_remote > 0) ? EMOJI_REMOTE . $count_remote . ' ' : '')); + $msg = raid_poll_message($msg, (($count_extra_alien > 0) ? EMOJI_ALIEN . $count_extra_alien . ' ' : '')); $msg = raid_poll_message($msg, (($count_want_invite > 0) ? EMOJI_WANT_INVITE . $count_want_invite . ' ' : '')); $msg = raid_poll_message($msg, (($count_late > 0) ? EMOJI_LATE . $count_late . ' ' : '')); $msg = raid_poll_message($msg, CR); diff --git a/logic/show_raid_poll_small.php b/logic/show_raid_poll_small.php index fdf302cc..a5b0a8e2 100644 --- a/logic/show_raid_poll_small.php +++ b/logic/show_raid_poll_small.php @@ -34,13 +34,9 @@ function show_raid_poll_small($raid, $override_language = false) $rs = my_query( " SELECT count(attend_time) AS count, - sum(team = 'mystic') AS count_mystic, - sum(team = 'valor') AS count_valor, - sum(team = 'instinct') AS count_instinct, - sum(team IS NULL) AS count_no_team, - sum(extra_mystic) AS extra_mystic, - sum(extra_valor) AS extra_valor, - sum(extra_instinct) AS extra_instinct + sum(remote = 0) AS count_in_person, + sum(remote = 1) AS count_remote, + sum(extra_alien) AS extra_alien FROM attendance LEFT JOIN users ON attendance.user_id = users.user_id @@ -56,16 +52,15 @@ function show_raid_poll_small($raid, $override_language = false) // Add to message. if ($row['count'] > 0) { // Count by team. - $count_mystic = $row['count_mystic'] + $row['extra_mystic']; - $count_valor = $row['count_valor'] + $row['extra_valor']; - $count_instinct = $row['count_instinct'] + $row['extra_instinct']; + $count_in_person = $row['count_in_person']; + $count_remote = $row['count_remote']; + $extra_alien = $row['extra_alien']; // Add to message. - $msg .= EMOJI_GROUP . ' ' . ($row['count'] + $row['extra_mystic'] + $row['extra_valor'] + $row['extra_instinct']) . ' — '; - $msg .= (($count_mystic > 0) ? TEAM_B . $count_mystic . ' ' : ''); - $msg .= (($count_valor > 0) ? TEAM_R . $count_valor . ' ' : ''); - $msg .= (($count_instinct > 0) ? TEAM_Y . $count_instinct . ' ' : ''); - $msg .= (($row['count_no_team'] > 0) ? TEAM_UNKNOWN . $row['count_no_team'] : ''); + $msg .= EMOJI_GROUP . ' ' . ($row['count'] + $row['count_in_person'] + $row['count_remote'] + $row['extra_alien']) . ' — '; + $msg .= (($count_in_person > 0) ? EMOJI_IN_PERSON . $count_in_person . ' ' : ''); + $msg .= (($count_remote > 0) ? EMOJI_REMOTE . $count_remote . ' ' : ''); + $msg .= (($extra_alien > 0) ? EMOJI_ALIEN . $extra_alien . ' ' : ''); $msg .= CR; } else { $msg .= getTranslation('no_participants') . CR; diff --git a/mods/edit_starttime.php b/mods/edit_starttime.php index 19ae2df1..f4753f5a 100644 --- a/mods/edit_starttime.php +++ b/mods/edit_starttime.php @@ -189,7 +189,7 @@ // Set the message. if ($arg == 'min') { $msg = getTranslation('raid_starts_when_minutes'); -} else if ($raid_level == 'X') { +} else if ($event_id == EVENT_ID_EX) { $msg = getTranslation('raid_starts_when'); $msg .= CR . CR . getTranslation('raid_select_date'); } else { diff --git a/mods/vote_extra.php b/mods/vote_extra.php index de619622..3a0ae944 100644 --- a/mods/vote_extra.php +++ b/mods/vote_extra.php @@ -9,7 +9,7 @@ // Check if the user has voted for this raid before and check if they are attending remotely. $rs = my_query( " - SELECT user_id, remote, (1 + extra_valor + extra_instinct + extra_mystic) as user_count + SELECT user_id, remote, want_invite, (1 + extra_in_person) as user_count FROM attendance WHERE raid_id = {$data['id']} AND user_id = {$update['callback_query']['from']['id']} @@ -27,27 +27,28 @@ if($data['arg'] == '0') { // Reset team extra people. - alarm($data['id'],$update['callback_query']['from']['id'],'extra_alone',$data['arg']); my_query( " UPDATE attendance - SET extra_mystic = 0, - extra_valor = 0, - extra_instinct = 0 + SET extra_in_person = 0, + extra_remote = 0 WHERE raid_id = {$data['id']} AND user_id = {$update['callback_query']['from']['id']} " ); + alarm($data['id'],$update['callback_query']['from']['id'],'extra_alone',$data['arg']); } else { // Check if max remote users limit is already reached! $remote_users = get_remote_users_count($data['id'], $update['callback_query']['from']['id']); - // Skip remote user limit check if user is not attending remotely. - // If they are, check if attend time already has max number of remote users. + // Skip remote user limit check if user is not attending remotely. + // If they are, check if attend time already has max number of remote users. // Also prevent user from adding more than max number of remote players even if 'Anytime' is selected if ($answer['remote'] == 0 or ($remote_users < $config->RAID_REMOTEPASS_USERS_LIMIT && $answer['user_count'] < $config->RAID_REMOTEPASS_USERS_LIMIT)) { - // Get team. + if($answer['want_invite'] == 1 && $data['arg'] == 'alien') { + // Force invite beggars to user extra_in_person even if they vote +alien + $data['arg'] = 'in_person'; + } $team = 'extra_' . $data['arg']; - alarm($data['id'],$update['callback_query']['from']['id'],'extra',$data['arg']); // Increase team extra people. my_query( " @@ -58,6 +59,7 @@ AND {$team} < 5 " ); + alarm($data['id'],$update['callback_query']['from']['id'],'extra',$data['arg']); } else { // Send max remote users reached. send_vote_remote_users_limit_reached($update); diff --git a/mods/vote_pokemon.php b/mods/vote_pokemon.php index df220bd0..68f1da4f 100644 --- a/mods/vote_pokemon.php +++ b/mods/vote_pokemon.php @@ -116,9 +116,8 @@ user_id, raid_id, attend_time, - extra_mystic, - extra_valor, - extra_instinct, + extra_in_person, + extra_alien, arrived, raid_done, cancel, @@ -127,15 +126,15 @@ invite, pokemon, alarm, - want_invite + want_invite, + can_invite ) VALUES( '{$atts[0]['user_id']}', '{$atts[0]['raid_id']}', '{$atts[0]['attend_time']}', - '{$atts[0]['extra_mystic']}', - '{$atts[0]['extra_valor']}', - '{$atts[0]['extra_instinct']}', + '{$atts[0]['extra_in_person']}', + '{$atts[0]['extra_alien']}', '{$atts[0]['arrived']}', '{$atts[0]['raid_done']}', '{$atts[0]['cancel']}', @@ -144,7 +143,8 @@ '{$atts[0]['invite']}', '{$data['arg']}', '{$atts[0]['alarm']}', - '{$atts[0]['want_invite']}' + '{$atts[0]['want_invite']}', + '{$atts[0]['can_invite']}' ) " ); diff --git a/mods/vote_remote.php b/mods/vote_remote.php index b6366c02..db367c7c 100644 --- a/mods/vote_remote.php +++ b/mods/vote_remote.php @@ -9,7 +9,7 @@ // Get current remote status of user $rs = my_query( " - SELECT remote, (1 + extra_valor + extra_instinct + extra_mystic) as user_count + SELECT remote, (1 + extra_in_person + extra_alien) as user_count FROM attendance WHERE raid_id = {$data['id']} AND user_id = {$update['callback_query']['from']['id']} diff --git a/mods/vote_time.php b/mods/vote_time.php index 615dda34..b0569068 100644 --- a/mods/vote_time.php +++ b/mods/vote_time.php @@ -42,7 +42,7 @@ if($count_att > 0){ $rs = my_query( " - SELECT user_id, remote, (1 + extra_valor + extra_instinct + extra_mystic) as user_count + SELECT user_id, remote, (1 + extra_in_person + extra_alien) as user_count FROM attendance WHERE raid_id = {$data['id']} AND user_id = {$update['callback_query']['from']['id']} diff --git a/mods/vote_want_invite.php b/mods/vote_want_invite.php index 369d59d9..8a86a428 100644 --- a/mods/vote_want_invite.php +++ b/mods/vote_want_invite.php @@ -1 +1,68 @@ -prepare( $query_select ); $statement_select->execute([ 'raid_id' => $data['id'], 'user_id' => $update['callback_query']['from']['id'] ]); $res = $statement_select->fetch(); if($statement_select->rowCount() > 0) { $query = " UPDATE attendance SET want_invite = CASE WHEN want_invite = '0' THEN '1' ELSE '0' END, late = 0, arrived = 0, remote = 0 WHERE raid_id = :raid_id AND user_id = :user_id "; $statement = $dbh->prepare( $query ); $statement->execute([ 'raid_id' => $data['id'], 'user_id' => $update['callback_query']['from']['id'] ]); } } catch (PDOException $exception) { error_log($exception->getMessage()); $dbh = null; exit; } if($statement_select->rowCount() > 0) { if($res['want_invite'] == 0) { alarm($data['id'],$update['callback_query']['from']['id'],'want_invite'); } else { alarm($data['id'],$update['callback_query']['from']['id'],'no_want_invite'); } // Send vote response. if($config->RAID_PICTURE) { send_response_vote($update, $data,false,false); } else { send_response_vote($update, $data); } } else { // Send vote time first. send_vote_time_first($update); } exit(); \ No newline at end of file +prepare( $query_select ); + $statement_select->execute([ + 'raid_id' => $data['id'], + 'user_id' => $update['callback_query']['from']['id'] + ]); + $res = $statement_select->fetch(); + if($statement_select->rowCount() > 0) { + $query = " + UPDATE attendance + SET want_invite = CASE + WHEN want_invite = '0' THEN '1' + ELSE '0' + END, + late = 0, + arrived = 0, + remote = 0, + extra_remote = 0 + WHERE raid_id = :raid_id + AND user_id = :user_id + "; + $statement = $dbh->prepare( $query ); + $statement->execute([ + 'raid_id' => $data['id'], + 'user_id' => $update['callback_query']['from']['id'] + ]); + } +} +catch (PDOException $exception) { + + error_log($exception->getMessage()); + $dbh = null; + exit; +} +if($statement_select->rowCount() > 0) { + if($res['want_invite'] == 0) { + alarm($data['id'],$update['callback_query']['from']['id'],'want_invite'); + } else { + alarm($data['id'],$update['callback_query']['from']['id'],'no_want_invite'); + } + // Send vote response. + if($config->RAID_PICTURE) { + send_response_vote($update, $data,false,false); + } else { + send_response_vote($update, $data); + } +} else { + // Send vote time first. + send_vote_time_first($update); +} + + +exit(); diff --git a/sql/pokemon-raid-bot.sql b/sql/pokemon-raid-bot.sql index 7ea181b2..3d990545 100644 --- a/sql/pokemon-raid-bot.sql +++ b/sql/pokemon-raid-bot.sql @@ -16,9 +16,8 @@ CREATE TABLE `attendance` ( `user_id` bigint(20) DEFAULT NULL, `raid_id` int(10) unsigned DEFAULT NULL, `attend_time` datetime DEFAULT NULL, - `extra_mystic` tinyint(1) unsigned DEFAULT '0', - `extra_valor` tinyint(1) unsigned DEFAULT '0', - `extra_instinct` tinyint(1) unsigned DEFAULT '0', + `extra_in_person` tinyint(1) unsigned DEFAULT '0', + `extra_alien` tinyint(1) unsigned DEFAULT '0', `arrived` tinyint(1) unsigned DEFAULT '0', `raid_done` tinyint(1) unsigned DEFAULT '0', `cancel` tinyint(1) unsigned DEFAULT '0', @@ -28,6 +27,7 @@ CREATE TABLE `attendance` ( `pokemon` varchar(20) DEFAULT '0', `alarm` tinyint(1) unsigned DEFAULT '0', `want_invite` tinyint(1) unsigned DEFAULT '0', + `can_invite` TINYINT UNSIGNED NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `raid_id` (`raid_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/sql/upgrade/2.1.223.2.sql b/sql/upgrade/2.1.223.2.sql new file mode 100644 index 00000000..be6aa6c5 --- /dev/null +++ b/sql/upgrade/2.1.223.2.sql @@ -0,0 +1,5 @@ +ALTER TABLE `attendance` +DROP COLUMN `extra_instinct`, +ADD COLUMN `can_invite` TINYINT UNSIGNED NULL DEFAULT '0' AFTER `want_invite`, +CHANGE COLUMN `extra_mystic` `extra_in_person` TINYINT UNSIGNED NULL DEFAULT '0' , +CHANGE COLUMN `extra_valor` `extra_alien` TINYINT UNSIGNED NULL DEFAULT '0' ; \ No newline at end of file