Support > cpg1.5 email

Email for favorites

<< < (2/2)

Αndré:
Because there aren't appropriate language strings, this is what comes closest to what I had in mind:

--- Code: ---Index: addfav.php
===================================================================
--- addfav.php (revision 8813)
+++ addfav.php (working copy)
@@ -17,6 +17,7 @@
 
 define('IN_COPPERMINE', true);
 define('RATEPIC_PHP', true);
+define('DISPLAYIMAGE_PHP', true);
 
 require('include/init.inc.php');
 
@@ -39,9 +40,13 @@
 // See if this picture is already present in the array
 if (!in_array($pid, $FAVPICS)) {
     $FAVPICS[] = $pid;
+    $message_id = cpgStoreTempMessage($lang_picinfo['addFav']);
+    $message_icon = 'success';
 } else {
     $key = array_search($pid, $FAVPICS);
     unset($FAVPICS[$key]);
+    $message_id = cpgStoreTempMessage($lang_picinfo['remFav']);
+    $message_icon = 'info';
 }
 
 // Adjust redirect for "My Favorites" meta album
@@ -99,6 +104,10 @@
     }
 }
 
+$ref = preg_replace('/#.*/', '', $ref);
+$ref .= strpos($ref, '?') ? '&' : '?';
+$ref .= 'message_id='.$message_id.'&message_icon='.$message_icon.'#cpgMessageBlock';
+
 $header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
 header($header_location . $ref);
 pageheader($lang_common['information'], "<meta http-equiv=\"refresh\" content=\"1;url=$ref\">");
--- End code ---

Of course you could hard-code appropriate language strings, but I think I'll add a new plugin hook and create a plugin which implements the feature properly.

heavensportal:
This -- as you always do-- should work until you hook it into the next update. Thank you

Do I add it to a file or create a new .php for it in root?

Αndré:
Added hidden feature to display confirmation message when adding/removing pictures to/from favorites in SVN revision 8815 (will be part of cpg1.5.40).
Updated hidden features plugin in SVN revision 8816 (version 1.5).

To add the functionality in earlier versions than cpg1.5.40, open addfav.php, find

--- Code: ---$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
--- End code ---
and above, add

--- Code: ---// Prepare message
if (function_exists('hidden_features_page_start')) {
    if (in_array($pid, $FAVPICS)) {
        $message_id = cpgStoreTempMessage($lang_plugin_hidden_features['fav_added']);
        $message_icon = 'success';
    } else {
        $message_id = cpgStoreTempMessage($lang_plugin_hidden_features['fav_removed']);
        $message_icon = 'info';
    }
    $ref .= strpos($ref, '?') !== FALSE ? '&' : '?';
    $ref .= 'message_id='.$message_id.'&message_icon='.$message_icon.'#cpgMessageBlock';
}
--- End code ---

Additionally, you have to install version 1.5 or higher of the hidden features plugin.

heavensportal:

--- Quote from: Αndré on September 16, 2015, 12:20:17 pm ---Added hidden feature to display confirmation message when adding/removing pictures to/from favorites in SVN revision 8815 (will be part of cpg1.5.40).
Updated hidden features plugin in SVN revision 8816 (version 1.5).

To add the functionality in earlier versions than cpg1.5.40, open addfav.php, find

--- Code: ---$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
--- End code ---
and above, add

--- Code: ---// Prepare message
if (function_exists('hidden_features_page_start')) {
    if (in_array($pid, $FAVPICS)) {
        $message_id = cpgStoreTempMessage($lang_plugin_hidden_features['fav_added']);
        $message_icon = 'success';
    } else {
        $message_id = cpgStoreTempMessage($lang_plugin_hidden_features['fav_removed']);
        $message_icon = 'info';
    }
    $ref .= strpos($ref, '?') !== FALSE ? '&' : '?';
    $ref .= 'message_id='.$message_id.'&message_icon='.$message_icon.'#cpgMessageBlock';
}
--- End code ---

Additionally, you have to install version 1.5 or higher of the hidden features plugin.

--- End quote ---

OK have added the code then added the plugin and YAY!!  It shows a notification bar that it was successfully added to favorites  when it pops back to the front page after adding it.

Thank you so very much. And as I said the others are a wish for if/when possible.

Navigation

[0] Message Index

[*] Previous page

Go to full version