Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Edit the info displayed under thumbnails  (Read 12079 times)

0 Members and 1 Guest are viewing this topic.

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Edit the info displayed under thumbnails
« on: September 06, 2012, 05:50:49 am »

Hello, I´d like to add some required fields when uploading files. Username, email and country. In the case of country, I´d like to use a drop down list, but I don´t know how to do it. Also when someone registers I want to use the drop down list for the country field (I set up user_profile1 as required). This is because I want to show the country of the uploader next to his name under the thumbnail. So that, when clicking, it displays all the pictures of uploaders from that country. You can call it "sorting by country".
I´d appreciate your help.
My site is www.toptangas.com [NSFW]
« Last Edit: October 25, 2012, 04:53:47 am by Jeff Bailey »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Edit the info displayed under thumbnails
« Reply #1 on: September 06, 2012, 09:37:06 am »

What's the actual question? You already set user_profile1 as required (which contains the user's country), so all relevant data should be already available. I think you now just need the country dropdown box?
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #2 on: September 06, 2012, 03:29:27 pm »

Hi André,
I´m stuck in 4 issues:
1- As you said, the country dropdown box in the register page (like the one used in this site).
2- As I will allow unregistered users to upload files, I want to add 3 required fields in the upload page (in both methods: simple and swfupload). These fields are username, email and country (dropdown).
3- I want to show the country of the uploader under the thumbnails.
4- When I click the country, I want to display all the pictures from that country, no mattering the uploader.
I wish now my doubts are clearer.
Thanks a lot.
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #3 on: September 08, 2012, 06:14:54 pm »

Any clue??
Thnx
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Edit the info displayed under thumbnails
« Reply #4 on: September 11, 2012, 12:38:07 pm »

As I will allow unregistered users to upload files, I want to add 3 required fields in the upload page (in both methods: simple and swfupload). These fields are username, email and country (dropdown).
Why do you want to require username and email address? Where should that data be stored and where should it be displayed?

What do you think about an auto-detection of the country via the users' IP addresses?
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #5 on: September 13, 2012, 07:42:50 pm »

Hello,
Just as when an unregistered user tries to contact through contact.php and has to fill with his name and email, I would like to use this method when unregistered user upload files (if possible).
I think that the best place to store this info is in the "pictures table"
I would like to show the country where "files information" appears and underneath pictures thumbnails.
As seen in the attached file in yellow.

I think that auto-detection of the country via the users' IP addresses should work. But where is it stored and how can I handle to do what I want?

Thanks for your help.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Re: Edit the info displayed under thumbnails
« Reply #6 on: September 14, 2012, 10:04:58 am »

Where should that data (username and email address) be stored and where should it be displayed?

I ask as there's no straightforward solution for the flash uploader. As-is, files will uploaded prior you enter any data. At this point, they already exist in your gallery and you'd have to delete them if the uploader doesn't fill in the required data. So there's currently no way to reject files. Maybe it's possible to add some extra fields to the page where you select the album and just enable the "browse" button if all required data is set. But as such a mod is probably not created in 5 to 10 minutes I want to avoid senseless coding effort.

Instead, appending the users' IP addresses (or country names) to each picture row can be added quite easily. If you want to have valid user data (name and email address) I suggest to disable guest uploads.
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #7 on: September 15, 2012, 02:16:30 am »

Ok I agree with you André. The first option is not done quite easily.

I guess I will only allow upload from registered users.

Perhaps the field "user_profile1" can be used to store the country (using a drop list).
This info could be filled during registration. Actually, now is required but not with drop list.

The other way, as you suggest, would be getting the IP address from the uploader (I don´t know
where to find it) and transforming it to a country name.

And then, when displaying the thumbnails, an extra row with the country name can be added under
 the uploader name. And also as another field in the picture info.

Both methods are good for me. The results I´m looking for are:
- show the country name of the uploader as another info field for each picture
- add one row with the country name under the user name under each thumbnail (as shown in the attached file of the other post)
- when clicking the country name, sort all the pictures from that country, no mattering the user.

Thanks a lot
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #8 on: September 19, 2012, 03:46:33 pm »

Hello guys, any answer about this post?

I´ve been seeking the database and found in the pictures table that both columns, pic_raw_ip and pic_hdr_ip, are empty for every picture. Is that normal??

Thanks.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Edit the info displayed under thumbnails
« Reply #9 on: September 27, 2012, 12:40:29 pm »

I´ve been seeking the database and found in the pictures table that both columns, pic_raw_ip and pic_hdr_ip, are empty for every picture.
Without checking the code nor the docs, those fields will only be set for guest uploads if I remember correctly.


when clicking the country name, sort all the pictures from that country, no mattering the user.
For performance and code simplicity reasons I think we should drop the idea of determining the country automatically via the IP address.


As this is a very individual and time consuming request (if it's a support request at all), I have to enqueue it at the bottom of my to-do list.
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #10 on: October 03, 2012, 03:49:28 pm »

Ok, no problem Andre.
But don´t forget please. LOL

Thanks for your patience and your time.
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #11 on: October 15, 2012, 09:51:05 pm »

Hello again!

I´d like to ask if it´s possible to add the user_profile1 column content from TABLE_USERS underneath thumbnails just under the username.


Thanks in advance.

link: www.toptangas.com [NSFW]
« Last Edit: October 25, 2012, 04:54:02 am by Jeff Bailey »
Logged

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #12 on: October 25, 2012, 12:07:24 am »

I´d like to ask if it´s possible to add the user_profile1 column content from TABLE_USERS underneath thumbnails just under the username.

André, Jeff... any help for this question????

Thanx
Logged

Jeff Bailey

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1322
  • Fishing relaxes me.
    • Bailey Family Co.
Re: Edit the info displayed under thumbnails
« Reply #13 on: October 25, 2012, 04:40:38 am »

Try adding this to your custom theme.php
Code: [Select]
/******************************************************************************
** Section <<<theme_display_thumbnails>>> - START
******************************************************************************/
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb', $date='')
{
    global $CONFIG, $CURRENT_ALBUM_DATA;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $lang_common, $template_tab_display, $template_thumbnail_view, $lang_album_list, $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&amp;cat=' . $cat;
    $date_link = $date=='' ? '' : '&amp;date=' . $date;
    if ($superCage->get->getInt('uid')) {
      $uid_link = '&amp;uid=' . $superCage->get->getInt('uid');
    } else {
      $uid_link = '';
    }

    $album_types = array(
        'albums' => array('lastalb')
    );
    $album_types = CPGPluginAPI::filter('theme_thumbnails_album_types', $album_types);

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => in_array($aid, $album_types['albums']) ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['page_link'] = strtr($theme_thumb_tab_tmpl['page_link'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $date_link . $uid_link . '&amp;page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['page_link'] = strtr($theme_thumb_tab_tmpl['page_link'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';

    if (!GALLERY_ADMIN_MODE && stripos($template_thumb_view_title_row, 'admin_buttons') !== false) {
        template_extract_block($template_thumb_view_title_row, 'admin_buttons');
    }
    // The sort order options are not available for meta albums
    if ($sort_options) {
        if (GALLERY_ADMIN_MODE) {
            $param = array(
                '{ALBUM_ID}'   => $aid,
                '{CAT_ID}'     => ($cat > 0 ? $cat : $CURRENT_ALBUM_DATA['category']),
                '{MODIFY_LNK}'     => $lang_common['album_properties'],
                '{MODIFY_ICO}'     => cpg_fetch_icon('modifyalb', 1),
                '{PARENT_CAT_LNK}' => $lang_common['parent_category'],
                '{PARENT_CAT_ICO}' => cpg_fetch_icon('category', 1),
                '{EDIT_PICS_LNK}'  => $lang_common['edit_files'],
                '{EDIT_PICS_ICO}'  => cpg_fetch_icon('edit', 1),
                '{ALBUM_MGR_LNK}'  => $lang_common['album_manager'],
                '{ALBUM_MGR_ICO}'  => cpg_fetch_icon('alb_mgr', 1),
            );
        } else {
            $param = array();
        }
        $param['{ALBUM_NAME}'] = $album_name;
        // Plugin Filter: allow plugin to modify or add tags to process
        $param = CPGPluginAPI::filter('theme_thumbnails_title', $param);
        $title = template_eval($template_thumb_view_title_row, $param);
    } elseif ($aid == 'favpics' && $CONFIG['enable_zipdownload'] > 0) { //Lots of stuff can be added here later
        $param = array(
            '{ALBUM_ID}'   => $aid,
            '{ALBUM_NAME}' => $album_name,
            '{DOWNLOAD_ZIP}' => cpg_fetch_icon ('zip', 2) . $lang_thumb_view['download_zip'],
        );
        // Plugin Filter: allow plugin to modify or add tags to process
        $param = CPGPluginAPI::filter('theme_thumbnails_title', $param);       
        $title = template_eval($template_fav_thumb_view_title_row, $param);
    } else {
        $title = $album_name;
    }

    CPGPluginAPI::action('theme_thumbnails_wrapper_start', null);

    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    global $thumb;  // make $thumb accessible to plugins
    foreach($thumb_list as $thumb) {
        $i++;
$query_ownerid = "SELECT owner_id FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$thumb['pid']}";
$result_ownerid = cpg_db_query($query_ownerid);
$assoc_ownerid = mysql_fetch_assoc($result_ownerid);
$ownerid_data = $assoc_ownerid['owner_id'];
$query_profile1 = "SELECT user_profile1 FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$ownerid_data}";
$result_profile1 = cpg_db_query($query_profile1);
$assoc_profile1 = mysql_fetch_assoc($result_profile1);
$user_profile1_data = $assoc_profile1['user_profile1'];
        if ($mode == 'thumb') {
            if (in_array($aid, $album_types['albums'])) {
                $params = array(
                    '{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}'   => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}'      => $thumb['image'],
                    '{CAPTION}'    => $thumb['caption'] . $user_profile1_data,
                    '{ADMIN_MENU}' => $thumb['admin_menu'],
                );
            } else {
                // determine if thumbnail link targets should open in a pop-up
                if ($CONFIG['thumbnail_to_fullsize'] == 1) { // code for full-size pop-up
                    if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
                       $target = 'javascript:;" onclick="alert(\''.sprintf($lang_errors['login_needed'],'','','','').'\');';
                    } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
                        $target = 'javascript:;" onclick="alert(\''.sprintf($lang_errors['access_intermediate_only'],'','','','').'\');';
                    } else {
                       $target = 'javascript:;" onclick="MM_openBrWindow(\'displayimage.php?pid=' . $thumb['pid'] . '&fullsize=1\',\'' . uniqid(rand()) . '\',\'scrollbars=yes,toolbar=no,status=no,resizable=yes,width=' . ((int)$thumb['pwidth']+(int)$CONFIG['fullsize_padding_x']) .  ',height=' .   ((int)$thumb['pheight']+(int)$CONFIG['fullsize_padding_y']). '\');';
                    }
                } elseif ($aid == 'random') {
                    $target = "displayimage.php?pid={$thumb['pid']}$uid_link#top_display_media";
                } elseif ($aid == 'lastcom' || $aid == 'lastcomby') {
                    $page = cpg_get_comment_page_number($thumb['msg_id']);
                    $page = (is_numeric($page)) ? "&amp;page=$page" : '';
                    $target = "displayimage.php?album=$aid$cat_link$date_link&amp;pid={$thumb['pid']}$uid_link&amp;msg_id={$thumb['msg_id']}$page#comment{$thumb['msg_id']}";
                } else {
                    $target = "displayimage.php?album=$aid$cat_link$date_link&amp;pid={$thumb['pid']}$uid_link#top_display_media";
                }
                $params = array(
                    '{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}'   => $target,
                    '{THUMB}'      => $thumb['image'],
                    '{CAPTION}'    => $thumb['caption'] . $user_profile1_data,
                    '{ADMIN_MENU}' => $thumb['admin_menu'],
                );
            }

        } else {  // mode != 'thumb'

            // Used for mode = 'user' from list_users() in index.php
            $params = array(
                '{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}'   => "index.php?cat={$thumb['cat']}",
                '{THUMB}'      => $thumb['image'],
                '{CAPTION}'    => $thumb['caption'] . $user_profile1_data,
                '{ADMIN_MENU}' => '',
            );

        }

        // Plugin Filter: allow plugin to modify or add tags to process
        $params = CPGPluginAPI::filter('theme_display_thumbnails_params', $params);
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    } // foreach $thumb

    unset($thumb);  // unset $thumb to avoid conflicting with global

    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    $footer = CPGPluginAPI::filter('theme_thumbnails_footer', $footer);
    echo $footer;

    if ($display_tabs) {
        $params = array(
            '{THUMB_COLS}' => $thumbcols,
            '{TABS}'       => $tabs_html,
        );
        echo template_eval($tabs, $params);
    }

    endtable();
    CPGPluginAPI::action('theme_thumbnails_wrapper_end', null);
    echo $spacer;
}
/******************************************************************************
** Section <<<theme_display_thumbnails>>> - END
******************************************************************************/
Untested
« Last Edit: October 25, 2012, 07:52:40 am by Jeff Bailey »
Logged
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #14 on: October 26, 2012, 02:26:13 am »

It works great!!

I really admire you guys!!!  Solving problems selflessly...

One last thing if possible. Is there a way to sort pictures by "user_profile1" when clicking it??

Thank you very much.

Logged

Jeff Bailey

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1322
  • Fishing relaxes me.
    • Bailey Family Co.
Re: Edit the info displayed under thumbnails
« Reply #15 on: October 26, 2012, 03:13:18 am »

Not possible using the theme or without making some edits to thumbnails.php AFAIK

Maybe you can make meta albums and change the code to be a link to those meta albums.
http://forum.coppermine-gallery.net/index.php/topic,63706.0.html

I don't have the time to look through that right now but maybe when Αndré comes on he can give details for how to do that.
Logged
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

toptangas

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Edit the info displayed under thumbnails
« Reply #16 on: October 27, 2012, 01:47:31 am »

No problem Jeff.  :)
I´m not in a hurry. This can wait. You have already done so much for me....

Thanx again.
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 20 queries.