Favorite Mailer (mail a list of all your favorites to the admin) for cpg1.5x Favorite Mailer (mail a list of all your favorites to the admin) for cpg1.5x
 

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

Favorite Mailer (mail a list of all your favorites to the admin) for cpg1.5x

Started by Αndré, June 29, 2010, 03:58:01 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Αndré

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.


Turisti

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;
}

?>

Αndré

Just add your link to that line:
$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>';

Turisti

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
?>





Αndré

Quote from: Turisti on October 11, 2010, 07:37:41 AM
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