forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 permissions => Topic started by: The German on January 20, 2013, 05:29:22 pm

Title: Visitor upload not working
Post by: The German on January 20, 2013, 05:29:22 pm
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....
Title: Re: Visitor upload not working
Post by: phill104 on January 20, 2013, 05:44:01 pm
Have you set this in the albums - http://documentation.coppermine-gallery.net/en/albums.htm#album_prop_controls_visitor_upload
Title: Re: Visitor upload not working
Post by: The German on January 20, 2013, 05:49:33 pm
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.
Title: Re: Visitor upload not working
Post by: phill104 on January 20, 2013, 06:40:21 pm
Is it working now? If not please provide all the details from the "troubleshooting the upload process" from the docs.
Title: Re: Visitor upload not working
Post by: Αndré on January 21, 2013, 11:03:28 am
This is maybe related to a recent change in cpg1.5.22:
Unified album drop-down boxes (thread (http://forum.coppermine-gallery.net/index.php/topic,75840.0.html))
Title: Re: Visitor upload not working
Post by: Αndré on January 21, 2013, 11:09:28 am
This seems to fix the issue in my testbed. Please open include/functions.inc.php and replace the whole function album_selection_options with
Code: [Select]
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;
}
Title: Re: Problems uploading pictures.
Post by: The German on January 22, 2013, 03:10:18 am
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
Title: Re: Visitor upload not working
Post by: Αndré on January 22, 2013, 09:29:01 am
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.
Title: Re: Visitor upload not working
Post by: Αndré on January 25, 2013, 02:48:51 pm
Fix confirmed:
Changed code now working

Added to SVN repository in revision 8539.
Title: Re: Visitor upload not working
Post by: mculver on April 08, 2013, 02:23:57 am
I had the same issue -- the fix posted here works like a charm.

Thanks!