Exemplo n.º 1
0
function handle_action($action, $raiders)
{
    global $success, $user, $error;
    $rid = request_var('rid', 0);
    $raid = request_var('raid', '');
    $raid_id = request_var('raid_id', 0);
    $comment = request_var('comment', '');
    if (!$action or !$raid) {
        return;
    }
    $raider = false;
    if ($rid != 0 && $raid && $action) {
        $raider = get_raider_with_id($raiders, $rid);
        if (!$raider && !($rid == 0 && ($action == 'c' || $action == 'x'))) {
            return;
        }
    } else {
        if (!$raid_id || !$action || !$raid) {
            return;
        }
    }
    $day = $raid;
    if (strlen($raid) == 8) {
        $tm = strptime($raid, '%Y%m%d');
        $time = tm2time($tm);
        $day = sprintf($user->lang['DAY_MONTH'], post_num(strftime('%e', $time)), strftime('%B', $time));
    }
    $username = $user->data['username'];
    if ($action == '+') {
        $raider->signon($raid);
    } else {
        if ($action == '-') {
            $raider->signoff($raid, $comment);
        } else {
            if ($action == 'x') {
                $raider->clear_attendance($raid);
            } else {
                if ($action == '!') {
                    $raider->noshow($raid);
                } else {
                    if ($action == '%') {
                        $raider->late($raid);
                    } else {
                        if ($action == 'z') {
                            $raider->substitute($raid);
                        } else {
                            if ($action == '*') {
                                $raider->set_star($raid, 1);
                            } else {
                                if ($action == '!*') {
                                    $raider->set_star($raid, 0);
                                } else {
                                    if ($action == 'cr') {
                                        add_raid_history($raid_id, array('CANCELLED', $raid));
                                        set_raid_status($raid_id, $raid, STATUS_CANCELLED);
                                    } else {
                                        if ($action == 'xr') {
                                            add_raid_history($raid_id, array('CLEAR_RAID', $raid));
                                            set_raid_status($raid_id, $raid, STATUS_CLEAR);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $lang_array = array('+' => 'STATUS_CHANGE_ON', '-' => 'STATUS_CHANGE_OFF', 'x' => 'STATUS_CHANGE_CLEAR', '!' => 'STATUS_CHANGE_NOSHOW', '%' => 'STATUS_CHANGE_LATE', 'z' => 'STATUS_CHANGE_SUBSTITUTE', 'cr' => 'STATUS_CHANGE_CANCELLED', 'xr' => 'STATUS_CHANGE_RAID_CLEAR', '!*' => 'STATUS_CHANGE_STAR_CLEAR', '*' => 'STATUS_CHANGE_STAR_SET');
    $lang_key = $lang_array[$action];
    if ($username && $raider->name && $day && $user->lang[$lang_key]) {
        $success[] = sprintf($user->lang[$lang_key], $username, $raider->name, $day);
    } else {
        if ($username && $day && $user->lang[$lang_key]) {
            $success[] = sprintf($user->lang[$lang_key], $username, $day);
        } else {
            $error[] = "Error! {$username}, {$raider->name}, {$day}, {$lang_key}, " . $user->lang[$lang_key];
        }
    }
}
Exemplo n.º 2
0
function get_raiding_day_name($raid)
{
    $tm = strptime($raid, '%Y%m%d');
    $time = tm2time($tm);
    $day_name = date('D', $time);
    return $day_name;
}