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: Favorite Mailer (mail a list of all your favorites to the admin) for cpg1.5x  (Read 13370 times)

0 Members and 1 Guest are viewing this topic.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

This plugin adds a small button to the "My Favorites" meta album. If you click on that buttons you'll be redirected to the contact form where your favorite files are pre-populated.

Created by request. See here & here.

There's currently no package available, but you can download the latest svn snapshot here.
« Last Edit: July 08, 2010, 03:20:55 pm by Αndré »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Logged

Turisti

  • Coppermine newbie
  • Offline Offline
  • Posts: 3

Hi,

if I would like to add another link (delete favorites) to this script, how it should be done?

So basicly, I have delfav.php which deletes all favorites (works fine) and I like to have this button, or link, which calls that file.
Now I can make just one link at the time to be shown on the favorites page. If I remove the original button (mail) the delete button works fine, but I can't get both buttons work at the same time. So what's the problem?




My codebase.php looks like this:


<?php
/**************************************************
  Coppermine 1.5.x Plugin - Favorite mailer
  *************************************************
  Copyright (c) 2009 eenemeenemuu
  *************************************************
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.
  ********************************************
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/branches/cpg1.5.x/plugins/favorite_mailer/codebase.php $
  $Revision: 7675 $
  $LastChangedBy: eenemeenemuu $
  $Date: 2010-06-11 14:14:16 +0200 (Fr, 11 Jun 2010) $
**************************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$thisplugin->add_action('page_start', 'favorite_mailer_button');
$thisplugin->add_action('page_start', 'delete_button');
$thisplugin->add_filter('page_html', 'favorite_mailer_form');


function favorite_mailer_button() {
    $superCage = Inspekt::makeSuperCage();

    if ($superCage->get->getAlpha('album') == 'favpics') {
        global $lang_meta_album_names;
        $lang_meta_album_names['favpics'] .= ' <a href="contact.php?fm_mail" title="Tilaa valop&ouml;yd&auml;n tiedostot">'.cpg_fetch_icon('contact', 2).' Tilaa valop&ouml;yd&auml;n tiedostot</a>';
    }
}

function delete_button()
{
echo'<a href="delfav.php" title="Tyhjenn&auml; valop&ouml;yd&auml;n tiedostot"><img src="images/icons/contact.png" border="0">Tyhjenn&auml; valop&ouml;yd&auml;n tiedostot</a>';
}

function favorite_mailer_form($html) {
    $superCage = Inspekt::makeSuperCage();

    if ($superCage->get->keyExists('fm_mail')) {
        global $CONFIG, $FAVPICS;

        foreach ($FAVPICS as $pid) {
            $fav_pics .= $CONFIG['ecards_more_pic_target']."displayimage.php?pid=$pid \n\n";
        }

        if ($fav_pics) {
            $html = str_replace('<textarea name="message" cols="50" rows="10" class="textinput"></textarea>', '<textarea name="message" cols="50" rows="10" class="textinput">'.$fav_pics.'</textarea>', $html);
        }
    }

    return $html;
}

?>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Just add your link to that line:
Code: [Select]
$lang_meta_album_names['favpics'] .= ' <a href="contact.php?fm_mail" title="Tilaa valop&ouml;yd&auml;n tiedostot">'.cpg_fetch_icon('contact', 2).' Tilaa valop&ouml;yd&auml;n tiedostot</a>';
Logged

Turisti

  • Coppermine newbie
  • Offline Offline
  • Posts: 3

Great! Worked just fine!

Now i got  "mail favorites" and "delete favorites" functions workin!

My delfav.php looks like this:

define('IN_COPPERMINE', true);
require('include/init.inc.php');

setcookie($CONFIG['cookie_name'] . '_fav', "", time() + 86400 * 30, $CONFIG['cookie_path']); //The "" bit is what resets the cookie data to nothing

$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'index.php'; //Sets the index page as your previous location if it can't determine where you came from by reading the referer from the browser

pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"3;url=$referer\">"); //Sends you back to the page you came from (or index.php) after 3 secs if you don't click the continue button
msg_box($lang_info, "Valop&ouml;yt&auml; tyhjennetty", $lang_continue, $referer);
pagefooter();
ob_end_flush(); //Sends all this to the browser and flushes the php output buffer
?>




Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

define('IN_COPPERMINE', true);
require('include/init.inc.php');

setcookie($CONFIG['cookie_name'] . '_fav', "", time() + 86400 * 30, $CONFIG['cookie_path']); //The "" bit is what resets the cookie data to nothing

$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'index.php'; //Sets the index page as your previous location if it can't determine where you came from by reading the referer from the browser

pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"3;url=$referer\">"); //Sends you back to the page you came from (or index.php) after 3 secs if you don't click the continue button
msg_box($lang_info, "Valop&ouml;yt&auml; tyhjennetty", $lang_continue, $referer);
pagefooter();
ob_end_flush(); //Sends all this to the browser and flushes the php output buffer

2 issues:
- $_SERVER['HTTP_REFERER'] doesn't exist as it has been unset by Inspekt
- You also need to delete the according database entry if the user is logged in
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.