Unknown Coward - Page 2 Unknown Coward - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Unknown Coward

Started by klewless, June 19, 2016, 09:22:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

klewless

Working, sort-of, thank you.

All 9 pages of Home/Member Galleries are now full, rather than there being some blank pages at the end. Unfortunately, the active members and former members are mixed upL some of the active users' album cover thumbs are replaced by those empty film cans. The pictures are still inside fortunately, and so are the comments and other file information associated with the images, for everyone -- former members or members.

I will try to see if I missed a bracket or something in the copy-pasting.

:-\ :-\ :-\

klewless

Another odd thing is that "all" the results are showing up on each page of Home>Member Galleries: the same "film cans" , in the same order.
:-\

Αndré

I'll perform some tests on your gallery as soon as possible.

klewless

Still here  :)

I have left the new code in place for now so you can see   ???  :



Thanks again,
L.

Αndré

My last code change was created with totally wrong assumptions. I just updated the code on your website and it seems to work as expected as far as I can tell. I've reverted the first modification and instead I applied this mod.

Open index.php, find
    if (!$rowset) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);

and replace with
    if (!$user_count) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);

    $users_this_page = count($rowset);
    if ($user_count > $users_this_page && $users_this_page < $user_per_page) {
        $sql  = "SELECT {$cpg_udb->field['user_id']} AS user_id FROM {$cpg_udb->usertable}";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_existing[] = $row['user_id'];
        }
        cpg_db_free_result($result);

        $sql  = "SELECT category "
                . "FROM {$CONFIG['TABLE_ALBUMS']} AS p "
                . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pics ON pics.aid = p.aid "
                . "WHERE ( category > " . FIRST_USER_CAT . " $FORBIDDEN_SET) "
                . "GROUP BY category";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_all[] = $row['category'] - FIRST_USER_CAT;
        }
        cpg_db_free_result($result);

        $users_missing = array_diff($user_ids_all, $user_ids_existing);

        $users_w_albums = count(array_intersect($user_ids_all, $user_ids_existing));

        $offset = max(0, ($PAGE - 1) * $user_per_page - $users_w_albums);

        $user_ids = array_slice($users_missing, $offset, $user_per_page - $users_this_page);

        foreach ($user_ids as $user_id) {
            $user_categories[] = $user_id + FIRST_USER_CAT;
        }
        $result = cpg_db_query("
            SELECT p.owner_id, p.aid, COUNT(*) AS pic_count FROM {$CONFIG['TABLE_PICTURES']} AS p
            INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a
            ON a.aid = p.aid
            WHERE a.category IN (".implode(',', $user_categories).")
            GROUP BY p.aid
        ");
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_category_data[$row['owner_id']]['alb_count']++;
            $user_category_data[$row['owner_id']]['pic_count'] += $row['pic_count'];
        }
        foreach ($user_ids as $user_id) {
            $rowset[] = array(
                'user_id' => $user_id,
                'user_name' => 'Former user '.$user_id,
                'alb_count' => $user_category_data[$user_id]['alb_count'],
                'pic_count' => $user_category_data[$user_id]['pic_count'],
            );
        }
    }

klewless

I am happy to confirm it works well. Just one problem, the Former Members galleries are showing up as film cans (when you are looking at an album list page), however all the pictures and their comments are intact.

Perhaps I can go in there and assign a picture to each of these albums.

Thanks VERY much!
:) :) :) :) :) :) :) :)

Αndré

Quote from: klewless on July 19, 2016, 06:11:25 AM
Perhaps I can go in there and assign a picture to each of these albums.

Please don't! They're still set in the database, but I haven't added that part to the code, as it had no priority since now. I'll work further on the code and let you know when it's ready.

Αndré

Updated code:
    if (!$user_count) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);

    $users_this_page = count($rowset);
    if ($user_count > $users_this_page && $users_this_page < $user_per_page) {
        $sql  = "SELECT {$cpg_udb->field['user_id']} AS user_id FROM {$cpg_udb->usertable}";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_existing[] = $row['user_id'];
        }
        cpg_db_free_result($result);

        $sql  = "SELECT category "
                . "FROM {$CONFIG['TABLE_ALBUMS']} AS p "
                . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pics ON pics.aid = p.aid "
                . "WHERE ( category > " . FIRST_USER_CAT . " $FORBIDDEN_SET) "
                . "GROUP BY category";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_all[] = $row['category'] - FIRST_USER_CAT;
        }
        cpg_db_free_result($result);

        $users_missing = array_diff($user_ids_all, $user_ids_existing);

        $users_w_albums = count(array_intersect($user_ids_all, $user_ids_existing));

        $offset = max(0, ($PAGE - 1) * $user_per_page - $users_w_albums);

        $user_ids = array_slice($users_missing, $offset, $user_per_page - $users_this_page);

        foreach ($user_ids as $user_id) {
            $user_categories[] = $user_id + FIRST_USER_CAT;
        }
        $result = cpg_db_query("
            SELECT p.owner_id, p.aid, COUNT(*) AS pic_count, MAX(pid) AS thumb_pid, MAX(galleryicon) AS gallery_pid
            FROM {$CONFIG['TABLE_PICTURES']} AS p
            INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a
            ON a.aid = p.aid
            WHERE a.category IN (".implode(',', $user_categories).")
            GROUP BY p.aid
        ");
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_category_data[$row['owner_id']]['alb_count']++;
            $user_category_data[$row['owner_id']]['pic_count'] += $row['pic_count'];
            $user_category_data[$row['owner_id']]['thumb_pid'] = $row['thumb_pid'];
            $user_category_data[$row['owner_id']]['gallery_pid'] = $row['gallery_pid'];
        }
        foreach ($user_ids as $user_id) {
            $rowset[] = array(
                'user_id' => $user_id,
                'user_name' => 'Former user '.$user_id,
                'alb_count' => $user_category_data[$user_id]['alb_count'],
                'pic_count' => $user_category_data[$user_id]['pic_count'],
                'thumb_pid' => $user_category_data[$user_id]['thumb_pid'],
                'gallery_pid' => $user_category_data[$user_id]['gallery_pid'],
            );
        }
    }


I've already applied it to your gallery, and it seems to work for most user categories. Some have still the trash can icon, but I haven't checked in detail yet why this happens. Maybe you find something obvious.

klewless

I checked those folders with the cans, they have't got any pictures. I guess I just missed a few, some cans also among the sub-albums.


THANK YOU!!!!
Perfect now. Awesome! 
:) :) :)