Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum http://www.tinywebgallery.com/forum/ |
|
E-Mail plugin http://www.tinywebgallery.com/forum/viewtopic.php?f=13&t=3564 |
Page 1 of 1 |
Author: | altusio [ 12. Jul 2013, 16:58 ] |
Post subject: | E-Mail plugin |
Hello guys, In my JFU configuration the upload is done only by a publisher via the frontend. The publisher sees an upload folder that contains subfolders for each user (labeled with the username). I would like to amend the plugin so that if a new set of files was uploaded by the publisher the correspondent user gets an email notification. I amended the send_email function of the plugin and handed over the additional variable $folder. Then I'm making sure it contains only the actual foldername (without slashes or parent folders). With that string I have the actual username and I'm fetching the JUser object and get the email addresse from it. Then I overwrite the $mail_to variable with this addresse. I spent half the day to get this working but without success. It's not working. Anyone got an idea what I'm doing wrong here? Code: function send_email($mail_from, $mail_to, $subject, $mailtext, $type, $fix_utf8, $folder) { while (strpos($folder, '/') != false) { // remove parent folders and slashes $pos = strpos($folder, "/"); $string = substr($folder, $pos+1); } $user =& JFactory::getUser( $folder );// get the user object that is the owner of the folder (username=foldername) $mail_to = $user->email ; //set mail_to to the users email addresse $submailheaders = "From: $mail_from\n"; $submailheaders .= "Reply-To: $mail_from\n"; $submailheaders .= "Return-Path: $mail_from\n"; if ($fix_utf8 != '') { $submailheaders .= 'Content-Type: '.$type.'; charset=' . $fix_utf8 . "\n"; } else { $submailheaders .= 'Content-Type: '.$type.'; charset=UTF-8' . "\n"; } if ($type=="text/plain") { @mail ($mail_to, html_entity_decode ($subject), html_entity_decode ($mailtext), $submailheaders); } else { $submailheaders .= "MIME-Version: 1.0\n"; @mail ($mail_to, html_entity_decode ($subject), $mailtext, $submailheaders); } } Thanks for your feedback Sebastian |
Author: | TinyWebGallery [ 15. Jul 2013, 14:21 ] |
Post subject: | Re: E-Mail plugin |
Do you get an e-mail? I started doing this a while ago but have not had to thime to finish this. But I don't use the simple directory name as e-mail but checking the configuration which profile would match and extract it the other way. I only have a skeleton with documentation what has to be done. So If you need a custome solution I could continue with this. Of you can try to finish this... Best, Michael |
Author: | altusio [ 15. Jul 2013, 15:29 ] |
Post subject: | Re: E-Mail plugin |
I'm not receiving an email. With these changes to the function the JFU window (server + upload queue) remains empty after the upload has successfully been made. I have the impression that I'm killing the publishers session with the query for the "folder's" email addresse? Sebastian |
Author: | TinyWebGallery [ 15. Jul 2013, 17:28 ] |
Post subject: | Re: E-Mail plugin |
You are not in the Joomla context! This plugin is a plugin of the flash. Not of Joomla. therefore you would have to use sql to get the data. Best, Michael |
Author: | altusio [ 15. Jul 2013, 19:40 ] |
Post subject: | Re: E-Mail plugin |
Thanks for the hint! Got it working now: Code: function get_user_email($folder) { while (strpos($folder, '/') != false) { $pos = strpos($folder, "/"); $folder = substr($folder, $pos+1); } mysql_connect("localhost", "DBUSER", "DBUSERPASSWORD") or die(mysql_error()); mysql_select_db("DATABASE") or die(mysql_error()); $results = mysql_query("SELECT email FROM jos_users WHERE username ='$folder'") or die(mysql_error()); $row = mysql_fetch_array( $results ); $email =$row[email]; return $email; } Sebastian |
Author: | TinyWebGallery [ 15. Jul 2013, 21:07 ] |
Post subject: | Re: E-Mail plugin |
Perfect ![]() |
Author: | josh [ 9. Apr 2015, 12:43 ] |
Post subject: | Re: E-Mail plugin |
altusio wrote: Thanks for the hint! Got it working now: Code: function get_user_email($folder) { while (strpos($folder, '/') != false) { $pos = strpos($folder, "/"); $folder = substr($folder, $pos+1); } mysql_connect("localhost", "DBUSER", "DBUSERPASSWORD") or die(mysql_error()); mysql_select_db("DATABASE") or die(mysql_error()); $results = mysql_query("SELECT email FROM jos_users WHERE username ='$folder'") or die(mysql_error()); $row = mysql_fetch_array( $results ); $email =$row[email]; return $email; } Sebastian I just use this when I need the active users email: $formuser=JFactory::getUser(); return $formuser->email; |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |