コード例 #1
0
ファイル: meeting_class.php プロジェクト: velocat/phpbb3
    public function add_km_to_user($id, $meeting_km = false, $return_form)
    {
        global $user, $db, $config, $meeting_config, $phpbb_root_path, $phpEx;
        if (!$meeting_km || $meeting_km == '') {
            trigger_error($user->lang['Err_kilom_1'] . $return_form);
        } elseif ($meeting_km < 0) {
            trigger_error($user->lang['Err_kilom_2'] . $return_form);
        } else {
            $meeting_km = round($meeting_km);
            // Добавление км участникам
            $sql = "SELECT meeting_km, meeting_by_user, meeting_coorg, meeting_marshrut \n\t\t\t\tFROM " . MEETING_DATA_TABLE . "\n\t\t\t\tWHERE meeting_id = {$id}";
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $meet_tekush_km = $row['meeting_km'];
                $meet_organizator = $row['meeting_by_user'];
                $meeting_coorg = $row['meeting_coorg'];
                $meeting_marshrut = $row['meeting_marshrut'];
            }
            $db->sql_freeresult($result);
            $sql = "SELECT m.*, u1.user_id as user, u1.user_meeting_uchast, u1.user_km, u1.user_reputation, u1.group_id FROM " . MEETING_USER_TABLE . " m, " . USERS_TABLE . " u1\n\t\t\t\tWHERE m.meeting_id = {$id}\n\t\t\t\tAND m.user_id = u1.user_id\n\t\t\t\tORDER BY user_id";
            $result = $db->sql_query($sql);
            $vicherk_rows = $uchast_rows = array();
            while ($row = $db->sql_fetchrow($result)) {
                $vicherk_rows[] = $row;
                if ($row['group_id'] == 1194 || $row['group_id'] == 44) {
                    $uchast_rows[] = $row['user_id'];
                }
            }
            $db->sql_freeresult($result);
            $total_uchast = count($vicherk_rows);
            // Цикл по участникам
            if ($total_uchast != 0) {
                $sql_in = '';
                for ($i = 0; $i < $total_uchast; $i++) {
                    $id_uchastnik = $vicherk_rows[$i]['user_id'];
                    $sql = "SELECT user_id, pf_user_km FROM " . PROFILE_FIELDS_DATA_TABLE . "\n\t\t\t\t\t\tWHERE user_id = {$id_uchastnik}";
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    $user_tekush_km = $row['pf_user_km'];
                    $user_raschet_km = $user_tekush_km + $meeting_km - $meet_tekush_km;
                    $user_raschet_km = $user_raschet_km <= 0 ? 0 : $user_raschet_km;
                    $sql = "SELECT user_id, pf_user_km FROM " . PROFILE_FIELDS_DATA_TABLE . "\n\t\t\t\t\t\tWHERE user_id = {$id_uchastnik}";
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    if (!$row) {
                        $sql = "INSERT INTO " . PROFILE_FIELDS_DATA_TABLE . " (user_id, pf_user_km) VALUES ({$id_uchastnik}, {$meeting_km})";
                        $db->sql_query($sql);
                    } else {
                        $sql = "UPDATE " . PROFILE_FIELDS_DATA_TABLE . "\n\t\t\t\t\t\t\tSET pf_user_km = {$user_raschet_km}\n\t\t\t\t\t\t\tWHERE user_id = {$id_uchastnik}";
                        $db->sql_query($sql);
                    }
                    $sql_in .= ($sql_in != '' ? ', ' : '') . intval($id_uchastnik);
                }
            } else {
                trigger_error($user->lang['NO_KM_NULL_UCHAST'] . $return_form);
            }
            // Проверка групп.
            $group_members = array();
            $sql = "SELECT user_id, group_id FROM " . USER_GROUP_TABLE . "  \n\t\t\t\t\tWHERE group_id = 44 \n\t\t\t\t\tAND user_id IN ({$sql_in})\n\t\t\t\t\tORDER BY user_id";
            $result = $db->sql_query($sql);
            $db->sql_freeresult($result);
            if ($result) {
                do {
                    $group_members[] = $row['user_id'];
                } while ($row = $db->sql_fetchrow($result));
                $members_count = count($group_members);
            } else {
                $members_count = 0;
            }
            if (sizeof($uchast_rows)) {
                $newuser = array_diff($uchast_rows, $group_members);
            }
            // Добавление Участников в группу "участники"
            $users = $uchast_rows;
            if (!function_exists('auto_group')) {
                include $phpbb_root_path . 'includes/functions_autogroup.' . $phpEx;
            }
            auto_group($users);
            $sql_ary = array('meeting_km' => $meeting_km);
            $sql = 'UPDATE ' . MEETING_DATA_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE meeting_id = ' . $id;
            $db->sql_query($sql);
            $total_tekush_km = $meeting_config['total_km'];
            $total_raschet_km = $total_tekush_km + $meeting_km - $meet_tekush_km;
            $sql_ary_t = array('config_value' => $total_raschet_km);
            $sql = 'UPDATE ' . MEETING_CONFIG_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary_t) . '
					WHERE config_name = "total_km"';
            $db->sql_query($sql);
            //Повышение репутации (сделать участников массивом)
            if ($config['rp_enable'] && $meet_tekush_km == 0) {
                include_once $phpbb_root_path . 'includes/functions_reputation.' . $phpEx;
                add_rep_meeting($vicherk_rows, $id, $meet_organizator, $meeting_coorg);
            }
            if ($meeting_marshrut) {
                add_marshrut_km($id, $meeting_km);
            }
        }
    }
コード例 #2
0
ファイル: meeting_detail.php プロジェクト: velocat/phpbb3
			WHERE meeting_id = ' . $id;
        $db->sql_query($sql);
        $total_tekush_km = $meeting_config['total_km'];
        $total_raschet_km = $total_tekush_km + $meeting_km - $meet_tekush_km;
        $sql_ary_t = array('config_value' => $total_raschet_km);
        $sql = 'UPDATE ' . MEETING_CONFIG_TABLE . '
			SET ' . $db->sql_build_array('UPDATE', $sql_ary_t) . '
			WHERE config_name = "total_km"';
        $db->sql_query($sql);
        //Ïîâûøåíèå ðåïóòàöèè (ñäåëàòü ó÷àñòíèêîâ ìàññèâîì)
        if ($config['rp_enable'] && $meet_tekush_km == 0) {
            include_once $phpbb_root_path . 'includes/functions_reputation.' . $phpEx;
            add_rep_meeting($vicherk_rows, $id, $meet_organizator, $meeting_coorg);
        }
        if ($meeting_marshrut) {
            add_marshrut_km($id, $meeting_km);
        }
        include_once $phpbb_root_path . 'informer.' . $phpEx;
        create_informer($id, 'upd');
        $mode = 'detail';
        //$redirect = append_sid("{$phpbb_root_path}reputation.$phpEx", 'm=' . $id . 'a=' . ($vicherk_rows));
        //redirect($redirect);
    }
}
if ($mode == 'sign_off_command' || $sign_off_command) {
    $submit = '';
    $cancel = '';
    $confirm = '';
    $mode = 'sign_off';
}
// ---------------------------------------