Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 4. Dec 2024, 10:33

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: E-Mail plugin
PostPosted: 12. Jul 2013, 16:58 
Offline

Joined: 12. Jul 2013, 13:46
Posts: 3
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


Last edited by altusio on 15. Jul 2013, 15:17, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 15. Jul 2013, 14:21 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
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


Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 15. Jul 2013, 15:29 
Offline

Joined: 12. Jul 2013, 13:46
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 15. Jul 2013, 17:28 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
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


Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 15. Jul 2013, 19:40 
Offline

Joined: 12. Jul 2013, 13:46
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 15. Jul 2013, 21:07 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
Perfect ;).


Top
 Profile  
 
 Post subject: Re: E-Mail plugin
PostPosted: 9. Apr 2015, 12:43 
Offline

Joined: 9. Apr 2015, 12:38
Posts: 2
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;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy