Visitor upload not working Visitor upload not working
 

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

Visitor upload not working

Started by The German, January 20, 2013, 05:29:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

The German

So, I spent several hours on this and can't find a solution :-(
- I allowed the "Guests" group Public album upload without approval
- There is no way to assign a "Guests"  group to a category
- In the album "Visitor can upload files" is activated.

Result
- The album is being displayed to visitors
- There is no album that can be selected for uploading a file

This drives me crazy and was wondering if there is a solution to this....

phill104

It is a mistake to think you can solve any major problems just with potatoes.

The German

Yes, the link that is missing is that "Guests" do not have any album assigned, nor can they pick it when trying to upload.
Also, this is a brand new, out of the box installation without any modifications or plugins.

phill104

Is it working now? If not please provide all the details from the "troubleshooting the upload process" from the docs.
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

This is maybe related to a recent change in cpg1.5.22:
Quote from: Αndré on January 11, 2013, 11:11:34 AM
Unified album drop-down boxes (thread)

Αndré

#5
This seems to fix the issue in my testbed. Please open include/functions.inc.php and replace the whole function album_selection_options with
function album_selection_options($selected = 0)
{
    global $CONFIG, $lang_common, $cpg_udb, $LINEBREAK;
    // html string of options to be returned
    $options = '';
    $albums = array();
    // load all albums

    $uploads_yes = defined('EDITPICS_PHP') || defined('UPLOAD_PHP') ? ' OR uploads = "YES"' : '';

    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY pos");
    } elseif (USER_ID) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (FIRST_USER_CAT + USER_ID) . " OR owner = " . USER_ID . $uploads_yes . " ORDER BY pos");
    } else {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE 0 " . $uploads_yes . " ORDER BY pos");
    }

    while ( ($row = mysql_fetch_assoc($result)) ) {
        $albums[$row['category']][$row['aid']] = $row['title'];
    }
    if (!empty($albums[0])) {
        // Albums in no category
        $options .= '<optgroup label="' . $lang_common['albums_no_category'] . '">';
        foreach ($albums[0] as $aid => $title) {
            $options .= sprintf('<option value="%d"%s>%s</option>'.$LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $title);
        }
        $options .= '</optgroup>';
    }
    // Load all categories
    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT cid, rgt, name FROM {$CONFIG['TABLE_CATEGORIES']} ORDER BY lft");
    } elseif (USER_ID) {
        $result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE c.cid = " . USER_GAL_CAT . " OR a.owner = ". USER_ID . $uploads_yes . " ORDER BY lft");
    } else {
        $result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE 0 " . $uploads_yes . " ORDER BY lft");
    }

    $cats = array();
    // Loop through all categories
    while ( ($row = mysql_fetch_assoc($result))) {
        // Determine category hierarchy
        if (count($cats)) {
            while ($cats && $cats[count($cats)-1]['rgt'] < $row['rgt']) {
                array_pop($cats);
            }
        }
        $cats[] = $row;
        // Add this category to the hierarchy
        if ($row['cid'] == USER_GAL_CAT) {
            // User galleries
            $options .= '<optgroup label="' . $lang_common['personal_albums'] . '">' . $LINEBREAK;

            if (GALLERY_ADMIN_MODE) {
                $result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
                    . "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
                $users = cpg_db_fetch_rowset($result2);
                mysql_free_result($result2);
            } else {
                $users = array(array('user_id' => USER_ID, 'user_name' => USER_NAME));
            }

            foreach ($users as $user) {
                if (!empty($albums[$user['user_id'] + FIRST_USER_CAT])) {
                    $options .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $user['user_name'] . '">' . $LINEBREAK;
                    foreach ($albums[$user['user_id'] + FIRST_USER_CAT] as $aid => $title) {
                        $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', '&nbsp;&nbsp;&nbsp;&nbsp;'.$title);
                    }
                    $options .= '</optgroup>';
                }
            }
            $options .= '</optgroup>';
            unset($users);
            continue;
        }
        // calculate indent for this level
        $indent = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', (count($cats) - 1));
        // albums in the category
        if (!empty($albums[$row['cid']])) {
            // category header
            $options .= '<optgroup label="' . $indent . $row['name'] . '">' . $LINEBREAK;

            foreach ($albums[$row['cid']] as $aid => $title) {
                $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $indent . $title);
            }

            $options .= '</optgroup>';
        }
    }
    mysql_free_result($result);

    return $options;
}


The German

Must be really hard to even read the e-mail before pushing out the standard "RTFM" thing hmm? Read my message again... It is the ANONYMOUS / GUEST that does not need to log on as described in your troubleshooting guide. Registered users can upload just fine.

Well, you know what, simply delete my account here, I already wasted way too much time for something that should work out of the box and does not. There are other solutions that are being tested before released.

Regards,
Thomas

Αndré

Thomas, it's not always obvious how some config options may affect other parts. However, I already provided a fix and ask you to confirm if it also works for you (actually this worked since cpg1.5.20 and have crept in while optimizing something different in cpg1.5.22). If you still want your account to be deleted, let me know.

Αndré

Fix confirmed:
Quote from: Visitor on January 24, 2013, 10:47:26 PM
Changed code now working

Added to SVN repository in revision 8539.

mculver

I had the same issue -- the fix posted here works like a charm.

Thanks!