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: Ecards per album  (Read 9138 times)

0 Members and 1 Guest are viewing this topic.

tomt

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Ecards per album
« on: July 20, 2005, 04:36:42 pm »

It would be great if one could switch Ecards on/off for individual albums.
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Ecards per album
« Reply #1 on: July 22, 2005, 02:23:57 pm »

Ok, here goes just a quick solution that the devs are going to flame me for since it requires a little update to the database that they don't like to see ever happen as it will complicate upgrading to new versions of coppermine so use this at yor own risk and for the devs I know I know I am being a bad boy again. ;-)

The SQL statment you need to run against yor database:

Code: [Select]
ALTER TABLE `cpg133_albums` ADD `ecard_enabled` ENUM( 'NO', 'YES' ) DEFAULT 'YES' NOT NULL ;
The code you need to change:

In displayimage.php look for:
Code: [Select]
    if (USER_CAN_SEND_ECARDS) {
        $ecard_tgt = "ecard.php?album=$album$cat_link&pid=$pid&pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        $ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
        $ecard_title = $lang_img_nav_bar['ecard_disabled'];
    }
Change that to:
Code: [Select]
    $result = db_query("SELECT ecard_enabled from {$CONFIG['TABLE_ALBUMS']} WHERE aid='$album'");
    if (mysql_num_rows($result) == 0) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
    $row = mysql_fetch_array($result);
    $ecard_enabled = $row['ecard_enabled'];

    if (USER_CAN_SEND_ECARDS && $ecard_enabled == 'YES') {
        $ecard_tgt = "ecard.php?album=$album$cat_link&pid=$pid&pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        $ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
        $ecard_title = $lang_img_nav_bar['ecard_disabled'];
    }

Now you are able to set it on a database level all we now need to do is modify the album admin screen and make create an option to enable/disable this in the album admin screen

Well here goes:

In modifyalb.php look for:
Code: [Select]
$captionLabel = $lang_modifyalb_php['alb_desc'];
if ($CONFIG['show_bbcode_help']) {$captionLabel .= '<hr />'.$lang_bbcode_help;}
$data = array($lang_modifyalb_php['general_settings'],
    array($lang_modifyalb_php['alb_title'], 'title', 0),
    array($lang_modifyalb_php['alb_cat'], 'category', 2),
    array($captionLabel, 'description', 3),
    array($lang_modifyalb_php['alb_thumb'], 'thumb', 4),
    $lang_modifyalb_php['alb_perm'],
    array($lang_modifyalb_php['can_view'], 'visibility', 5),
    array($lang_modifyalb_php['can_upload'].$notice1, 'uploads', 1),
    array($lang_modifyalb_php['can_post_comments'].$notice1, 'comments', 1),
    array($lang_modifyalb_php['can_rate'].$notice1, 'votes', 1),
    );

And replace with:
Code: [Select]
$captionLabel = $lang_modifyalb_php['alb_desc'];
if ($CONFIG['show_bbcode_help']) {$captionLabel .= '<hr />'.$lang_bbcode_help;}
$data = array($lang_modifyalb_php['general_settings'],
    array($lang_modifyalb_php['alb_title'], 'title', 0),
    array($lang_modifyalb_php['alb_cat'], 'category', 2),
    array($captionLabel, 'description', 3),
    array($lang_modifyalb_php['alb_thumb'], 'thumb', 4),
    $lang_modifyalb_php['alb_perm'],
    array($lang_modifyalb_php['can_view'], 'visibility', 5),
    array($lang_modifyalb_php['can_upload'].$notice1, 'uploads', 1),
    array($lang_modifyalb_php['can_post_comments'].$notice1, 'comments', 1),
    array($lang_modifyalb_php['can_rate'].$notice1, 'votes', 1),
    array($lang_modifyalb_php['can_ecard'].$notice1, 'ecard_enabled', 1),
    );

Now we need to add the correct text with it for the album admin page:

In the language files that you are using look for the following:
Code: [Select]
  'can_post_comments' => 'Visitors can post comments',
  'can_rate' => 'Visitors can rate files',
and add the following line just below:
Code: [Select]
  'can_ecard' => 'Visitors can send ecards',

The text will of course have to be in the language of the file that your are modifying.

Ok, now last but not least the db_input.php needs a little changing so find the following:
Code: [Select]
    case 'album_update':
        if (!(USER_ADMIN_MODE || GALLERY_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        $aid = (int)$HTTP_POST_VARS['aid'];
        $title = addslashes(trim($HTTP_POST_VARS['title']));
        $category = (int)$HTTP_POST_VARS['category'];
        $description = addslashes(trim($HTTP_POST_VARS['description']));
        $thumb = (int)$HTTP_POST_VARS['thumb'];
        $visibility = (int)$HTTP_POST_VARS['visibility'];
        $uploads = $HTTP_POST_VARS['uploads'] == 'YES' ? 'YES' : 'NO';
        $comments = $HTTP_POST_VARS['comments'] == 'YES' ? 'YES' : 'NO';
        $votes = $HTTP_POST_VARS['votes'] == 'YES' ? 'YES' : 'NO';

        if (!$title) cpg_die(ERROR, $lang_db_input_php['alb_need_title'], __FILE__, __LINE__);

        if (GALLERY_ADMIN_MODE) {
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', category='$category', thumb='$thumb', uploads='$uploads', comments='$comments', votes='$votes', visibility='$visibility' WHERE aid='$aid' LIMIT 1";
        } else {
            $category = FIRST_USER_CAT + USER_ID;
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', thumb='$thumb',  comments='$comments', votes='$votes', visibility='$visibility' WHERE aid='$aid' AND category='$category' LIMIT 1";
        }

And replace with:
Code: [Select]
    case 'album_update':
        if (!(USER_ADMIN_MODE || GALLERY_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        $aid = (int)$HTTP_POST_VARS['aid'];
        $title = addslashes(trim($HTTP_POST_VARS['title']));
        $category = (int)$HTTP_POST_VARS['category'];
        $description = addslashes(trim($HTTP_POST_VARS['description']));
        $thumb = (int)$HTTP_POST_VARS['thumb'];
        $visibility = (int)$HTTP_POST_VARS['visibility'];
        $uploads = $HTTP_POST_VARS['uploads'] == 'YES' ? 'YES' : 'NO';
        $comments = $HTTP_POST_VARS['comments'] == 'YES' ? 'YES' : 'NO';
        $votes = $HTTP_POST_VARS['votes'] == 'YES' ? 'YES' : 'NO';
        $ecard_enabled = $HTTP_POST_VARS['ecard_enabled'] == 'YES' ? 'YES' : 'NO';

        if (!$title) cpg_die(ERROR, $lang_db_input_php['alb_need_title'], __FILE__, __LINE__);

        if (GALLERY_ADMIN_MODE) {
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', category='$category', thumb='$thumb', uploads='$uploads', comments='$comments', votes='$votes', visibility='$visibility', ecard_enabled='$ecard_enabled' WHERE aid='$aid' LIMIT 1";
        } else {
            $category = FIRST_USER_CAT + USER_ID;
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', thumb='$thumb',  comments='$comments', votes='$votes', visibility='$visibility', ecard_enabled='$ecard_enabled' WHERE aid='$aid' AND category='$category' LIMIT 1";
        }

In the end you can select per album if a user that can send out ecards can actualy send them out for this album.
« Last Edit: July 22, 2005, 03:06:13 pm by RatKing »
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Ecards per album
« Reply #2 on: July 22, 2005, 03:29:16 pm »

Should any one want to thank me I am always open for paypay donations (rcoops@gmail.com) ;D

If you would like some help with anything else just PM me and I'll see what I can do no promisses made and usualy no payment required but that will have to be looked at on a case by case request.
« Last Edit: July 22, 2005, 03:57:10 pm by RatKing »
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 19 queries.