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 (http://forum.coppermine-gallery.net/index.php/topic,65410.0.html) & here (http://forum.coppermine-gallery.net/index.php/topic,65437.0.html).
There's currently no package available, but you can download the latest svn snapshot here (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/favorite_mailer.tar.gz?view=tar).
Package download: https://sourceforge.net/projects/coppermine/files/Plugins/1.5.x/cpg1.5.x_plugin_favorite-mailer_v0.2.zip/download
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öydän tiedostot">'.cpg_fetch_icon('contact', 2).' Tilaa valopöydän tiedostot</a>';
}
}
function delete_button()
{
echo'<a href="delfav.php" title="Tyhjennä valopöydän tiedostot"><img src="images/icons/contact.png" border="0">Tyhjennä valopöydä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;
}
?>
Just add your link to that line:
$lang_meta_album_names['favpics'] .= ' <a href="contact.php?fm_mail" title="Tilaa valopöydän tiedostot">'.cpg_fetch_icon('contact', 2).' Tilaa valopöydän tiedostot</a>';
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öytä tyhjennetty", $lang_continue, $referer);
pagefooter();
ob_end_flush(); //Sends all this to the browser and flushes the php output buffer
?>
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öytä 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