Email alerts

My system doesn't seem to be sending email alerts when someone received a private message, the way Boonex does.  I have the box checked on the email templates for them to go out, but I don't receive an email alert when someone sends me a message.  I believe my chrons are set up correctly - is there something else I should be looking at.

Rob

Quote · 9 Sep 2008

Mine was working before I got email notifier....here is my old list-pop.php file( was working).....

 

You know the drill....back up your file and upload mine and see....

<?

/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -----------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2006 BoonEx Group
*     website              : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/

require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );

$_page['name_index'] = 44;

$logged['member'] = member_auth(0);

$sourceID = (int)$_COOKIE['memberID'];
$targetID = (int)$_GET['ID'];
$action = $_GET['action'];

$_ni = $_page['name_index'];

    switch ($action)
    {
        case 'block':
            $_page['header'] = _t( "_Block list" );
            $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( _t('_Block list'), PageListBlock($sourceID, $targetID), $oTemplConfig -> PageListPop_db_num );
        break;
        case 'hot':
            $_page['header'] = _t('_Hot list');
            $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( _t('_Hot list'),  PageListHot($sourceID, $targetID), $oTemplConfig -> PageListPop_db_num );
        break;
        case 'friend':
            $_page['header'] = _t('_Friend list');
            $_page_cont[$_ni]['page_main_code'] = DesignBoxContent(_t('_Friend list'), PageListFriend($sourceID, $targetID), $oTemplConfig -> PageListPop_db_num );
        break;
        case 'spam':
            $_page['header'] = _t('_Spam report');
            $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( _t('_Spam report'), PageListSpam($sourceID, $targetID), $oTemplConfig -> PageListPop_db_num);
        break;
    }

PageCode();

function PageListBlock( $sourceID, $targetID )
{
    $ret = '';
    $query = "REPLACE INTO `BlockList` SET `ID` = '$sourceID', `Profile` = '$targetID';";
    if( db_res($query, 0) )
    {
        $ret = _t_action('_User was added to block list');
    }
    else
    {
        $ret = _t_err('_Failed to apply changes');
    }

    return $ret;
}

function PageListHot($sourceID, $targetID)
{
    $ret = '';

    $query = "REPLACE INTO `HotList` SET `ID` = '$sourceID', `Profile` = '$targetID';";
    if( db_res($query, 0) )
    {
        $ret = _t_action('_User was added to hot list');
    }
    else
    {
        $ret = _t_err('_Failed to apply changes');
    }

    return $ret;
}

function PageListFriend($sourceID, $targetID)
{
    // scc MOD: begin
    // make site wide vars available to this function
    global $site;
    // scc MOD: end

    $ret = '';
    $query = "SELECT * FROM `FriendList` WHERE (`ID` = '$sourceID' and `Profile` = '$targetID') or ( `ID` = '$targetID' and `Profile` = '$sourceID')";
    $temp = db_assoc_arr($query);

    if( $sourceID == $temp['ID'] || $temp['Check'] == 1 )
    {
        $ret = _t_action('_already_in_friend_list');
    }
    elseif( $targetID == $temp['ID'] && 0 == $temp['Check'] )
    {
        $query = "UPDATE `FriendList` SET `Check` = '1' WHERE `ID` = '$targetID' AND `Profile` = '$sourceID';";
        if( db_res($query) )
        {
            $ret = _t_action('_User was added to friend list');
        }
        else
        {
            $ret = _t_err('_Failed to apply changes');
        }
    }
    else
    {
        $query = "INSERT INTO `FriendList` SET `ID` = '$sourceID', `Profile` = '$targetID', `Check` = '0';";
        if( db_res( $query ) )
        {
            $ret = _t_action('_User was invited to friend list');


            // scc MOD: begin
            // send email to invited member regarding invitation
            $recipient = getProfileInfo( $targetID );
            $aReporter = getProfileInfo( $sourceID );
            $nickname = $aReporter['NickName'];
            $message ="
Hi, {$nickname} would like to add you as a friend.


You may login to your account at

{$site['url']}/member.php

and approve or reject this friend request.
--
{$site['title']} mail delivery system
<Auto-generated e-mail, please, do not reply>
";
               $subject = "You Have A New Friend Request!";
               sendMail( $recipient['Email'], $subject, $message );
            // scc MOD: end


        }
        else
        {
            $ret = _t_err('_Failed to apply changes');
        }

    }


    return $ret;
}

function PageListSpam($sourceID, $targetID)
{
    global $site;

    $reporterID = $sourceID;
    $spamerID = $targetID;

    $aReporter = getProfileInfo( $reporterID );// db_arr("SELECT `NickName` FROM `Profiles` WHERE `ID` = '$reporterID';", 0);
    $aSpamer   = getProfileInfo( $spamerID );//db_arr("SELECT `NickName` FROM `Profiles` WHERE `ID` = '$spamerID';", 0);

    $message = getParam( "t_SpamReport" );
    $subject = getParam('t_SpamReport_subject');


    $aPlus = array();
    $aPlus['reporterID'] = $reporterID;
    $aPlus['reporterNick'] = $aReporter['NickName'];

    $aPlus['spamerID'] = $spamerID;
    $aPlus['spamerNick'] = $aSpamer['NickName'];


    $mail_result = sendMail( $site['email'], $subject, $message, '', $aPlus );

    if ( $mail_result )
        $ret = _t_action('_Report about spam was sent');
    else
        $ret = _t_err('_Report about spam failed to sent');

    return $ret;
}

?>

Quote · 9 Sep 2008

I don't understand.  I haven't made any mods or changes to this function, or loaded anything called "email notifier".  Why should I upload this file?  What does it do?  I don't like making changes to my configuration unless I understand why.  Isn't Dolphin designed to send out alerts when private messages are sent?

Rob

Quote · 9 Sep 2008

Let me hold yor hand while we cross the street....

 

 

This file calls for email functions....you do not need to upload it, just compare it with your list_pop.php located in the root....

 

I just checked my dolphin....if Isend mail and check the box to send on both emails( real and site mail) I do get the note in my real mail account with the whole message...but if I click on site email only....it sends mail to site only but Im unable to click on notify box....?So the user doesnt get the notifying mail that there is an email in their site profile....

 

Does anyone know how to enable site email only and notify by regular mail?

 

Quote · 9 Sep 2008

Thank you Nurke,  I have no reason to believe anything is wrong with my list_pop.php file, as I haven't touched it.

-

There are two checkboxes at the top of the email templates page

-

1. Enable new message notifications
2. Enable message destination user choice

-

I had checked the first box only, and assumed this would mean the members would get the new message notification no matter what, but this does not seem to be the case.  When I check both boxes, or the second box only, I get the radio box with three choices for sending the message: to personal email, to site email, both; plus a check box for "notify by email".  What I want (I think) is to have all private messages send a notification email, or perhaps have only the "notify by email" checkbox with it checked by default.  I think this is what should happen when someone selects number 1 above.  Has someone made a mod for this?

-

Rob

Quote · 9 Sep 2008

Cal,

Select "both" at the bottom of the message when sending  .....

Quote · 9 Sep 2008

I understand - I didn't want them to be there at all.  I just wanted people to get the alerts.

Rob

Quote · 9 Sep 2008

OK, now no matter what I do, I can't check the "notify by email" box.  It is greyed out.  What is this about?

 

Rob

Quote · 9 Sep 2008

1. Enable new message notifications
2. Enable message destination user choice

Quote · 9 Sep 2008

I did!!!  Please do a search of the forums.  Oh wait, you don't have to- just read the previous post.  Does anyone know?  Could this have something to do with anomyous mode being checked?

 

Rob

 

 

Quote · 9 Sep 2008

This is driving me nuts.  Does anyone have any theories why my "notify by email" is not clickable, when I have selected both "enable new message notification" and "enable message destination user choice"; and disabled anonymous mode?  Is there some setting somewhere that I am overlooking?

Rob

Quote · 9 Sep 2008

Does anyone have any theories why my "notify by email" is not clickable, when I have selected both "enable new message notification" and "enable message destination user choice"; and disabled anonymous mode?

Uncheck Admin > Settings > Email Templates > Enable new message notifications  ..... 

check to site e-mail -  Notify by e-mail

I figured this out the same way as YOU can  .....  process of elimination  ..... 
.

Quote · 9 Sep 2008

Thank you RampyBampy, works like a charm. It annoyed me when I was able to read the whole message in regular mail...this way I have tyo come back to the site...

Thanks again.

Quote · 9 Sep 2008

OK, I got the "notify by email" checkbox back when I unchecked "enable new message notifications" in admin.  That was the one option I hadn't tried, but you do have to admit it is pretty counterintuitive- telling the system you don't want new message notifications when you do want new message notifications!  I'd rather not have the option for regular email at all.  Like Nurke, I would rather they have to log into the site to get their message.  Maybe some creative person here could help develop a simple mod that would let us comment out those radion buttons, and maybe keep the "notify by email" check box, with it checked by default.

Rob

Quote · 10 Sep 2008

Ok, how about this.  Is there a way to at least get the defaults set correctly?  At the bottom of the private message, I would like the radio button for send "to site email" to be selected, and the "notify by email" box to be preselected.  Could someone help with this?

-

Rob

Quote · 10 Sep 2008

I don't know if you are talking about sending mail through your site to other members. If so you could probably change the ones that are selected in compose.php You could potentially hide an option in this file if that is what you are seeking.

DialMe.com - Your One and Only Source For Boonex Dolphin Tutorials and Resources
Quote · 10 Sep 2008

I'm just talking about the private message function, that's all.   When you send a private message, I would just want a single checkbox at the bottom - checked by default, that says "notify by email".  It should be possible because everything is there already - I would just want to get rid of the radio button options to sent the message to email, etc.

Rob

Quote · 10 Sep 2008

Why not just let it go and let the members decide what to check?

Quote · 10 Sep 2008

Well you could say that about almost everything here.  Why don't you just ignor threads where you don't want to help?  I really don't have time for a long discussion about why I want this- my reasoning is similar to Nurke's.  If anyone knows how and where to comment out those radio buttons please let me know.

RG

Quote · 10 Sep 2008

I think it's a bug some place, I will look at it...

Quote · 10 Sep 2008

Why don't you just ignor threads where you don't want to help?


That won't be very hard at all  .....  you can bank on it now  .....
rotsAruck RG  .....
.

Quote · 10 Sep 2008

Hi Rob

What I have found out is when you uncheck 'Enable message destination user choice' no email alert is sent,

I don't know way, I have changed some code on compose.php so it will work.

Some code is new and some is moved so I paste a complete compose.php file you can copy here and try.

Back up your old file before...

 

- I have also added some code, so when you click on Reply in Inbox,

it will show up the email you hit replay on when you compose a new.

- Users will have a email alert when they receive new message on your site.

 

AND both have to be checked in admin/Settings/Email Templates

Enable new message notifications

Enable message destination user choice

 

Ottar.

 

compose.php

 

<?php

/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -----------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2006 BoonEx Group
*     website              : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/

require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'members.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

// --------------- page variables and login

 

$logged['member'] = member_auth( 0 );

$_page['name_index'] = 19;
$_page['header'] = _t( "_COMPOSE_H" );
$_page['header_text'] = _t( "_COMPOSE_H1" );
$_page['css_name'] = 'compose.css';

$_page['extra_js'] = $oTemplConfig -> sTinyMceEditorCompactJS;

// --------------- page components

$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = DesignBoxContent( '', PageCompPageMainCode(), $oTemplConfig -> PageCompose_db_num );

// --------------- [END] page components

PageCode();

// --------------- page components functions

/**
* page code function
*/
function PageCompPageMainCode()
{
 global $site;

 $ret = '';
 $en_inbox_notify = getParam("enable_inbox_notify");
 $en_dest_choice = getParam("enable_msg_dest_choice");
 $free_mode = getParam( "free_mode" );

 $member['ID'] = (int)$_COOKIE['memberID'];
 $member['Password'] = $_COOKIE['memberPassword'];
 $recipientID = getID( $_REQUEST['ID'], 0 );

 $messageID = (int)$_GET[messageID];  //Added code

 $recipient = getProfileInfo( $recipientID );
 
 $contact_allowed = contact_allowed($member['ID'], $recipientID);

 // Check if member can send messages
 $check_res = checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE );
 if ( $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED
  && !$contact_allowed )
 {
  $ret = '
   <table width="100%" cellpadding="4" cellspacing="4" border="0">
    <tr>
     <td align="center">' . $check_res[CHECK_ACTION_MESSAGE] . '</td>
    </tr>
   </table>';
  return $ret;
 }

 //ob_start();

 $ret = '';

 if ( $_POST['action'] == "send" && strlen($_POST['text']) )
 {
  $action_result = "";

  // Check if recipient found
  if( !$recipient )
  {
   $ret = "
    <table width=\"100%\" cellpadding=\"4\" cellspacing=\"4\" align=\"center\">
     <tr>
      <td align=center>". _t("_COMPOSE_REJECT_MEMBER_NOT_FOUND") ."</td>
     </tr>
    </table>\n";
   return $ret;
  }

  // Perform sending
  $send_result = MemberSendMessage( $member, $recipient );
  
  switch ( $send_result )
  {
   case 1:
    $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE" );
    $hide_form = '0';
    break;
   case 3:
    $action_result .= _t_err( "_You have to wait for PERIOD minutes before you can write another message!", 1 );
    $hide_form = '1';
    break;
   case 5:
    $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_BLOCK" );
    $hide_form = '0';
    break;
   case 10:
    $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_NOT_ACTIVE" );
    $hide_form = '0';
    break;
   default:
    $action_result .= _t_action( "_MESSAGE_SENT" );
    $hide_form = '1';
    break;
  }
    }
 $ret .= '<div class="com_box"">';


 if ( strlen($action_result) )
 {
  $ret .= $action_result;
 }

 

//Added code start -  Check if messageID found
 if( $messageID )
 {
 $message_sql= "SELECT `Text`, `Subject`, `Date` FROM `Messages` WHERE `ID` = '$messageID'";

 $message_arr= db_arr($message_sql);

 $ret = '';

 $ret .= '<div class="m_block">';
  $ret .= '<div class="m_subject_date">';
   $ret .= '<div class="name">';
    $ret .= _t('_Date').':';
   $ret .= '</div>';

   $ret .= '<div class="value">';
    $ret .= $message_arr['Date'];
   $ret .= '</div>';

   $ret .= '<div class="name">';
    $ret .= _t('_Subject').':';
   $ret .= '</div>';

   $ret .= '<div class="value">';
   $ret .= process_smiles( process_line_output($message_arr['Subject']) );
   $ret .= '</div>';

  $ret .= '</div>';
//Added code end
 

  $ret .= '<div class="m_text">';
   $ret .= process_html_output($message_arr['Text'], 150);
  $ret .= '</div>';
  $ret .= '<div class="clear_both"></div>';
 $ret .= '</div>';
        $ret .= '<br /><br />';
 }


 if ( $recipient &&  $hide_form != '1' )
 {
  $ret .= '<div class="clear_both"></div>';
  $ret .= ProfileDetails( $recipient['ID'] );
  $ret .= '<div class="clear_both"></div>';
 }

 if( '1' != $hide_form )
 {
  $sSubject = (isset($_REQUEST['subject'])) ? 'Re: '.process_pass_data($_REQUEST['subject']) : '';
  ob_start()
  
  ?>
  <script type="text/javascript">
   <!--
   function changeDest(control)
   {
    if ( control.value == 'lovemail' )
    {
     z = document.getElementById("id0004");
     z.disabled = false;
    }
    else
    {
     xxx = document.getElementById("id0004");
     xxx.disabled = true;
    }
   }
   
   function checkForm()
   {
    var el;
    var hasErr = false;
    var fild = "";
    el = document.getElementById("inpSubj");
    if( el.value.length < 3 )
    {
     el.style.backgroundColor = "pink";
     el.style.border = "1px solid silver";
     hasErr = true;
     fild += " <?= _t('_Subject') ?>";
    }
    else
     el.style.backgroundColor = "#fff";
    
    if (hasErr)
    {
     alert( "<?= _t('_please_fill_next_fields_first') ?>!" + fild )
     return false;
    }
    else
    {
     return true;
    }
    return false;
   }
   //-->
  </script>
  
<center>
  <form name="compose_form" method="post"
    action="<?= $_SERVER['PHP_SELF'] . ( $recipient ? "?ID={$recipient['ID']}" : "" ) ?>" onsubmit="return checkForm();">
   <table class="composeTable">
    <tr>
  <?
  if ( !$recipient )
  {
   ?>
     <td class="form_label"><?= _t( "_SEND_MSG_TO" )?></td>
     <td class="form_value">
      <input class="inpMessageTo" type="text" name="ID" />
     </td>
    </tr>
    <tr>
   <?
  }
  ?>
     <td class="form_label"><?= _t('_Subject') ?>:</td>
     <td class="form_value">
      <input class="inpSubj" id="inpSubj" name="mes_subject" type="text" value="<?= $sSubject; ?>" />
     </td>
    </tr>
    <tr>
     <td class="form_label"><?= _t( "_Message text" ) ?>:</td>
     <td class="form_value">
      <textarea class="blogText" id="blogText" name="text"></textarea>
     </td>
    </tr>
  <?
  
  if ( $_POST['notify'] == 'on' )
   $notify_sel = "checked";
  else
   $notify_sel = "";

  switch( $_POST['sendto'] )
  {
   case 'email':
    $email_sel = ' checked="checked" ';
    $lovemail_sel = "";
    $both_sel = "";
    break;
   case 'lovemail':
    $email_sel = "";
    $lovemail_sel = ' checked="checked"';
    $both_sel = "";
    break;
   default:
    $email_sel = "";
    $lovemail_sel = "";
    $both_sel = ' checked="checked"';
    break;
  }

 

  if ( 'on' == $en_dest_choice )
  {
   $javascript = ( $en_inbox_notify ? "" : "onClick=\"javascript: changeDest(this);\"" );
   
   $notify_dis = "";
   if ( !$lovemail_sel && $en_dest_choice )
   {
    $notify_sel = "";
    $notify_dis = ' disabled="disabled"';
   }
   
   ?>
    <!-- <tr>
     <td>&nbsp;</td>
     <td nowrap="nowrap">
      <input type="radio" id="id0001" name="sendto" value="email"  <?= $javascript . $email_sel ?> />
      <label for="id0001"><?= _t( "_Send to e-mail" )?></label>
            </td>
    </tr>
    <tr>
     <td>&nbsp;</td>
     <td>
      <input type="radio" id="id0002" name="sendto" value="lovemail" <?= $javascript . $lovemail_sel ?> />
      <label for="id0002"><?= _t( "_Send to communicator" ) ?></label>
      
      <input type="checkbox" id="id0004" name="notify" <?= $notify_sel . $notify_dis ?> />
      <label for="id0004"><?=  _t( "_Notify by e-mail" ) ?></label>
     </td>
    </tr> -->
    <tr>
     <td>&nbsp;</td>
     <td nowrap="nowrap" colspan="3" align="left" style="padding-left:5px;">
      <input type="radio" id="id0003" name="sendto" value="both" <?= $javascript .  $both_sel ?> />
                                 <label for=id0003><?=  _t( "_Notify by e-mail" ) ?> and sent <?= _t( "_Send to communicator" ) ?></label>
     </td>
    </tr>
   <?
  }
  else
  {
   ?>
    <input type="hidden" name="sendto" value="lovemail" />
   <?
  }
  ?>
    <tr>
     <td colspan="2" class="form_colspan">
      <input class="button" type="submit" value=" <?=_t( "_Send" ) ?>" />
     </td>
    </tr>
   </table>
   <input type="hidden" name="action" value="send" />
  </form>
  
</center>
  <?
  $ret .= ob_get_clean();
 }
 else
 {
  $ret .= '<div style="margin:15px 0px; text-align:center;">' . _t('_to_compose_new_message', $recipient['NickName'], $recipient['ID'], $site['url'] ) . '</div>';
 }
 $ret .= '</div>';


 return $ret;
}

/**
 * Send message
 */
function MemberSendMessage( $member, $recipient )
{
 global $site;

 $en_dest_choice  = getParam( "enable_msg_dest_choice" );
 $max_message_size   = getParam( "max_inbox_message_size" );
 $max_messages    = getParam( "max_inbox_messages" );


 // Check if recipient is active
 if( 'Active' != $recipient['Status'] )
 {
  return 10;
 }

 // Check if member is blocked
 if ( db_arr( "SELECT `ID`, `Profile` FROM `BlockList` WHERE `Profile` = {$member['ID']} AND `ID` = '{$recipient['ID']}';" ) )
 {
  return 5;
 }

// antispam ))
 if ( db_arr("SELECT `ID` FROM `Messages` WHERE `Sender` = {$member[ID]} AND date_add(`Date`, INTERVAL 1 MINUTE) > Now()") )
 {
  return 3;
 }


 // Get sender info
 $sender = getProfileInfo( $member['ID'] );

 $aPlus = array();
 $aPlus['ProfileReference'] = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . $sender['NickName'] . '</a> (' . getProfileLink($member['ID']) . ') ' : '<b>'. _t("_Visitor") .'</b>';

 // Don't send notification if message is sending to email
 if ( $_POST['notify'] && !($_POST['sendto'] == "email" || $_POST['sendto'] == "both") )
 {
  $message_text = getParam("t_Compose");
  $subject = getParam('t_Compose_subject');

  $aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor");

  $notify_res = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus );

  if ( !$notify_res )
   echo "<div class=\"err\">". _t("_Notification send failed") ."</div><br />\n";
 }

 // Send message to email
 if ( $en_dest_choice && ($_POST['sendto'] == "email" || $_POST['sendto'] == "both") )
 {
  $message_text = getParam("t_Compose");
  $subject = getParam('t_Compose_subject');

  $aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor");

  $result = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus );
 }

 // Send message to communicator
 if ( $_POST['sendto'] == "lovemail" || $_POST['sendto'] == "both" )
 {

                $message_text = getParam("t_Message");
  $subject   = process_pass_data( $_POST['mes_subject'] );
  $aPlus['MessageText'] = strmaxtextlen( clear_xss( replace_full_uris( process_pass_data( $_POST['text'] ) ) ), $max_message_size);

  // Restrict with total messages count
  $messages_count = db_arr( "SELECT COUNT(*) AS `mess_count` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}'" );
  $messages_count = $messages_count['mess_count'];
  if ( ($messages_count - 1) > $max_messages )
  {
   $del_res = db_res( "SELECT `ID` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}' ORDER BY `Date` ASC LIMIT ". ($messages_count - $max_messages + 1) );
   while ( $del_arr = mysql_fetch_array($del_res) )
    db_res( "DELETE FROM `Messages` WHERE `ID` = {$del_arr['ID']}" );
  }

  // Insert message into database
  $message_text    = strmaxtextlen( addslashes( clear_xss( process_pass_data( $_POST['text'] ) ) ), $max_message_size );
  $message_subject = strmaxwordlen( process_db_input( $_POST['mes_subject'] ), 30);
  $result = db_res( "INSERT INTO `Messages` ( `Date`, `Sender`, `Recipient`, `Text`, `Subject`, `New` ) VALUES ( NOW(), {$member['ID']}, {$recipient['ID']}, '$message_text', '$message_subject', '1' )" );
 }

 // If sending successful then mark as performed action
 if ( $result )
 {
  checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE, true );
 }
 else
  return 1;

 return 0;

}
?>

Quote · 13 Sep 2008

Ottar (aka okweb) thanks for doing this- somehow I missed this and didn't see it until last night.  I have tried your modification and found that it behaves in the following way:

-
1. Enable new message notification checked, Enable message destination user choice unchecked.
nothing at botton of compose message page.  Unfortunately, no email alert received.
*
2.  Enable new message notification, Enable message destination user choice both checked.
A radio button is at the bottom of the page that says "Notify by e-mail and sent to site e-mail".  It cannot be unselected.  An alert message was received.
*
3. Enable new message notification unchecked, Enable message destination user choice checked.
A radio button is at the bottom of the page that says "Notify by e-mail and sent to site e-mail".  It cannot be unselected.  An alert message was received.
-
This last one is the closest to what I want, however it is still backwards on the admin panel.  Since my users can't see that, I will likely keep it and try to comment out the radio button.  What I would rather have, however, is to check the "enable new message notification" in the admin panel (and uncheck the destination choice) and then have a single checkbox at the bottom of the message that says, "notify by email" with it checked by default.
-
Thanks
-
Rob
-
p.s.  Don't you just love these testing and code development operations we are doing for Boonex!

Quote · 19 Sep 2008

toggling moderation setting ...send confirm email trick still works i think...thats what i always do

I have video tutorials to help you mrpowless.com
Quote · 19 Sep 2008

Mrpowless, just to clarify, the testing I did refers to okweb's modification of the compose.php file, which I am now using.  I've got it doing what I wanted it to do-  more of less (send an alert without the destination choice) and will continue to use it, but it could be improved a bit still.  Like making a checkbox in the compose message screen to let a user select whether to send the alert or not, and for the admin controls to be a bit more logical.

-

Rob

Quote · 20 Sep 2008

Hi Rob


I do some modification on compose.php, I think this is what you would have...

 

- single checkbox at the bottom of the message that says, "notify by email" with it checked by default

- admin controls more logical

 

Ottar.

 

compos.php

 

 

<?php

/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -----------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2006 BoonEx Group
*     website              : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/

require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'members.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

// --------------- page variables and login

 

$logged['member'] = member_auth( 0 );

$_page['name_index']  = 19;
$_page['header']   = _t( "_COMPOSE_H" );
$_page['header_text']  = _t( "_COMPOSE_H1" );
$_page['css_name']  = 'compose.css';

$_page['extra_js'] = $oTemplConfig -> sTinyMceEditorCompactJS;

// --------------- page components

$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = DesignBoxContent( '', PageCompPageMainCode(), $oTemplConfig -> PageCompose_db_num );

// --------------- [END] page components

PageCode();

// --------------- page components functions

/**
* page code function
*/
function PageCompPageMainCode()
{
 global $site;

 $ret = '';
$en_inbox_notify = getParam("enable_inbox_notify");
$en_dest_choice = getParam("enable_msg_dest_choice");
$free_mode = getParam( "free_mode" );

$member['ID'] = (int)$_COOKIE['memberID'];
$member['Password'] = $_COOKIE['memberPassword'];
$recipientID = getID( $_REQUEST['ID'], 0 );

$messageID = (int)$_GET[messageID];  //Added code

$recipient = getProfileInfo( $recipientID );
 
$contact_allowed = contact_allowed($member['ID'], $recipientID);

 // Check if member can send messages
$check_res = checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE );
if ( $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED
  && !$contact_allowed )
 {
  $ret = '
 <table width="100%" cellpadding="4" cellspacing="4" border="0">
 <tr>
 <td align="center">' . $check_res[CHECK_ACTION_MESSAGE] . '</td>
 </tr>
 </table>';
  return $ret;
 }

 //ob_start();

 $ret = '';

 if ( $_POST['action'] == "send" && strlen($_POST['text']) )
 {
  $action_result = "";

  // Check if recipient found
  if( !$recipient )
  {
   $ret = "
<table width=\"100%\" cellpadding=\"4\" cellspacing=\"4\" align=\"center\">
 <tr>
<td align=center>". _t("_COMPOSE_REJECT_MEMBER_NOT_FOUND") ."</td>
 </tr>
 </table>\n";
                return $ret;
  }

  // Perform sending
 $send_result = MemberSendMessage( $member, $recipient );
  
  switch ( $send_result )
  {
   case 1:
  $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE" );
    $hide_form = '0';
    break;
   case 3:
 $action_result .= _t_err( "_You have to wait for PERIOD minutes before you can write another message!", 1 );
    $hide_form = '1';
    break;
   case 5:
 $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_BLOCK" );
    $hide_form = '0';
    break;
   case 10:
$action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_NOT_ACTIVE" );
    $hide_form = '0';
    break;
   default:
  $action_result .= _t_action( "_MESSAGE_SENT" );
    $hide_form = '1';
    break;
  }
    }
 $ret .= '<div class="com_box"">';
 if ( strlen($action_result) )
 {
  $ret .= $action_result;
 }

 

//Added code start -  Check if messageID found
 if( $messageID )
 {
 $message_sql= "SELECT `Text`, `Subject`, `Date` FROM `Messages` WHERE `ID` = '$messageID'";

 $message_arr= db_arr($message_sql);

 $ret = '';

 $ret .= '<div class="m_block">';
  $ret .= '<div class="m_subject_date">';
   $ret .= '<div class="name">';
    $ret .= _t('_Date').':';
   $ret .= '</div>';

   $ret .= '<div class="value">';
    $ret .= $message_arr['Date'];
   $ret .= '</div>';

   $ret .= '<div class="name">';
    $ret .= _t('_Subject').':';
   $ret .= '</div>';

   $ret .= '<div class="value">';
$ret .= process_smiles( process_line_output($message_arr['Subject']) );
   $ret .= '</div>';
  $ret .= '</div>';

  $ret .= '<div class="m_text">';
  $ret .= process_html_output($message_arr['Text'], 150);
  $ret .= '</div>';
  $ret .= '<div class="clear_both"></div>';
 $ret .= '</div>';
        $ret .= '<br /><br />';
 }
//Added code end


 if ( $recipient &&  $hide_form != '1' )
 {
  $ret .= '<div class="clear_both"></div>';
  $ret .= ProfileDetails( $recipient['ID'] );
  $ret .= '<div class="clear_both"></div>';
 }

 if( '1' != $hide_form )
 {
  $sSubject = (isset($_REQUEST['subject'])) ? 'Re: '.process_pass_data($_REQUEST['subject']) : '';
  ob_start()
  
  ?>
  <script type="text/javascript">
   <!--
   function changeDest(control)
   {
    if ( control.value == 'lovemail' )
    {
   z = document.getElementById("id0004");
     z.disabled = false;
    }
    else
    {
   xxx = document.getElementById("id0004");
     xxx.disabled = true;
    }
   }
   
   function checkForm()
   {
    var el;
    var hasErr = false;
    var fild = "";
   el = document.getElementById("inpSubj");
    if( el.value.length < 3 )
    {
   el.style.backgroundColor = "pink";
   el.style.border = "1px solid silver";
   hasErr = true;
   fild += " <?= _t('_Subject') ?>";
    }
    else
   el.style.backgroundColor = "#fff";
    
    if (hasErr)
    {
  alert( "<?= _t('_please_fill_next_fields_first') ?>!" + fild )
     return false;
    }
    else
    {
     return true;
    }
    return false;
   }
   //-->
  </script>
<center>
  <form name="compose_form" method="post"
    action="<?= $_SERVER['PHP_SELF'] . ( $recipient ? "?ID={$recipient['ID']}" : "" ) ?>" onsubmit="return checkForm();">
   <table class="composeTable">
    <tr>
  <?
  if ( !$recipient )
  {
   ?>
 <td class="form_label"><?= _t( "_SEND_MSG_TO" )?></td>
  <td class="form_value">
  <input class="inpMessageTo" type="text" name="ID" />
     </td>
    </tr>
    <tr>
   <?
  }
  ?>
 <td class="form_label"><?= _t('_Subject') ?>:</td>
  <td class="form_value">
 <input class="inpSubj" id="inpSubj" name="mes_subject" type="text" value="<?= $sSubject; ?>" />
  </td>
    </tr>
    <tr>
 <td class="form_label"><?= _t( "_Message text" ) ?>:</td>
 <td class="form_value">
 <textarea class="blogText" id="blogText" name="text"></textarea>
  </td>
    </tr>
  <?
  
  if ( $_POST['notify'] == 'on' )
   $notify_sel = "checked";
  else
   $notify_sel = "";

  switch( $_POST['sendto'] )
  {
   case 'email':
    $email_sel = ' checked="checked" ';
    $lovemail_sel = "";
    $both_sel = "";
    break;
   case 'both':
    $email_sel = "";
    $lovemail_sel = "";
    $both_sel = ' checked="checked"';
    break;
   default:
                                                                $email_sel = "";
    $lovemail_sel = ' checked="checked"';
    $both_sel = "";
    break;
  }

 

  if ( 'on' == $en_dest_choice )
  {
$javascript = ( $en_inbox_notify ? "" : "onClick=\"javascript: changeDest(this);\"" );
   
   $notify_sel = ' checked="checked"';
   if ( !$lovemail_sel && $en_dest_choice )
   {
    $notify_sel = "";
    $notify_dis = ' checked="checked"';
   }
   ?>
                                               <tr>
  <td>&nbsp;</td>
<td nowrap="nowrap" colspan="3" align="left" style="padding-left:5px;">
 <input type="radio" id="id0003" name="sendto" value="both" <?= $javascript .  $both_sel ?> />
  <label for=id0003> <?= _t( "_both2" ) ?></label>
  </td>
    </tr>
    <tr>
  <td>&nbsp;</td>
  <td nowrap="nowrap">
 <input type="radio" id="id0001" name="sendto" value="email"  <?= $javascript . $email_sel ?> />
 <label for="id0001"><?= _t( "_Send to e-mail" )?></label>
  </td>
  </tr>
  <tr>
  <td>&nbsp;</td>
  <td>
 <input type="radio" id="id0002" name="sendto" value="lovemail" <?= $javascript . $lovemail_sel ?> />
 <label for="id0002"><?= _t( "_Send to communicator" ) ?></label>
      
<input type="checkbox" id="id0004" name="notify" <?= $notify_sel . $notify_dis ?> />
 <label for="id0004"><?=  _t( "_Notify by e-mail" ) ?></label>
  </td>
 </tr>
    
   <?
  }
  else
  {
if ( 'on' == $en_inbox_notify )
  {
  ?>
<tr>
<td>&nbsp;</td>
<td nowrap="nowrap" colspan="3" align="left" style="padding-left:5px;">
<input type="checkbox" name="notify" checked="checked" />
<?=  _t( "_Notify by e-mail" ) ?>
</td>
</tr>

<?
}
         ?>
             <input type="hidden" name="sendto" value="lovemail" />
 <?
  }
  ?>
    <tr>
  <td colspan="2" class="form_colspan">
 <input class="button" type="submit" value=" <?=_t( "_Send" ) ?>" />
     </td>
    </tr>
   </table>
 <input type="hidden" name="action" value="send" />
  </form>
</center>
  <?
  $ret .= ob_get_clean();
 }
 else
 {
  $ret .= '<div style="margin:15px 0px; text-align:center;">' . _t('_to_compose_new_message', $recipient['NickName'], $recipient['ID'], $site['url'] ) . '</div>';
 }
 $ret .= '</div>';


 return $ret;
}

/**
 * Send message
 */
function MemberSendMessage( $member, $recipient )
{
 global $site;

 $en_dest_choice  = getParam( "enable_msg_dest_choice" );
 $max_message_size   = getParam( "max_inbox_message_size" );
 $max_messages    = getParam( "max_inbox_messages" );

 // Check if recipient is active
 if( 'Active' != $recipient['Status'] )
 {
  return 10;
 }

 // Check if member is blocked
 if ( db_arr( "SELECT `ID`, `Profile` FROM `BlockList` WHERE `Profile` = {$member['ID']} AND `ID` = '{$recipient['ID']}';" ) )
 {
  return 5;
 }

// antispam ))
 if ( db_arr("SELECT `ID` FROM `Messages` WHERE `Sender` = {$member[ID]} AND date_add(`Date`, INTERVAL 1 MINUTE) > Now()") )
 {
  return 3;
 }


 // Get sender info
 $sender = getProfileInfo( $member['ID'] );

 $aPlus = array();
 $aPlus['ProfileReference'] = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . $sender['NickName'] . '</a> (' . getProfileLink($member['ID']) . ') ' : '<b>'. _t("_Visitor") .'</b>';

 // Don't send notification if message is sending to email
 if ( $_POST['notify'] && !($_POST['sendto'] == "email" || $_POST['sendto'] == "both") )
 {
  $message_text = getParam("t_Compose");
  $subject = getParam('t_Compose_subject');

$aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor");

$notify_res = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus );

  if ( !$notify_res )
echo "<div class=\"err\">". _t("_Notification send failed") ."</div><br />\n";
 }

 // Send message to email
 if ( $en_dest_choice && ($_POST['sendto'] == "email" || $_POST['sendto'] == "both") )
 {
  $message_text = getParam("t_Message");
  $subject   = process_pass_data( $_POST['mes_subject'] );

$aPlus['MessageText'] = strmaxtextlen( clear_xss( replace_full_uris( process_pass_data( $_POST['text'] ) ) ), $max_message_size);
  
$result = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus );
 }

 // Send message to communicator
 if ( $_POST['sendto'] == "lovemail" || $_POST['sendto'] == "both" )
 {
  // Restrict with total messages count
  $messages_count = db_arr( "SELECT COUNT(*) AS `mess_count` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}'" );
  $messages_count = $messages_count['mess_count'];
  if ( ($messages_count - 1) > $max_messages )
  {
   $del_res = db_res( "SELECT `ID` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}' ORDER BY `Date` ASC LIMIT ". ($messages_count - $max_messages + 1) );
 while ( $del_arr = mysql_fetch_array($del_res) )
 db_res( "DELETE FROM `Messages` WHERE `ID` = {$del_arr['ID']}" );
  }

  // Insert message into database
  $message_text    = strmaxtextlen( addslashes( clear_xss( process_pass_data( $_POST['text'] ) ) ), $max_message_size );
  $message_subject = strmaxwordlen( process_db_input( $_POST['mes_subject'] ), 30);
  $result = db_res( "INSERT INTO `Messages` ( `Date`, `Sender`, `Recipient`, `Text`, `Subject`, `New` ) VALUES ( NOW(), {$member['ID']}, {$recipient['ID']}, '$message_text', '$message_subject', '1' )" );
 }

 // If sending successful then mark as performed action
 if ( $result )
 {
checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE, true );
 }
 else
  return 1;

 return 0;

}
?>

Quote · 22 Sep 2008

Follow up.  I am now using the mod the Ottar (aka okweb) developed, and it works perfectly.  It requires that you replace your entire compose.php file with what he has posted here and it will make your selections on your email alerts page work properly.

-

Rob

-

p.s.  Boonex take note - this is a fix of a function that didn't really work in the shipped version- you might as well use this code.

Quote · 22 Sep 2008

Just installed okweb's updated compose.php file, it's looking good. Just going to test it!.

Many thanks guy's - Stuart

There are none so blind as those that will not see.
Quote · 22 Sep 2008

Notify by e-mail link does not seem to be working....

Stuart

Follow up.  I am now using the mod the Ottar (aka okweb) developed, and it works perfectly.  It requires that you replace your entire compose.php file with what he has posted here and it will make your selections on your email alerts page work properly.

-

Rob

-

p.s.  Boonex take note - this is a fix of a function that didn't really work in the shipped version- you might as well use this code.

There are none so blind as those that will not see.
Quote · 23 Sep 2008

Ok, now its working, I don't know why it was not working earlier?? - Stuart

There are none so blind as those that will not see.
Quote · 23 Sep 2008

Question on this mod - is there a way that the members can choose for themselves whether they want to receive emails at their personal email box.  I know other social networks give you the ability to switch off notifications - it is not a choice for the person sending the mail but the recipient.  Right now, it is an admin selection not an individual choice.

Thanks

Quote · 12 Oct 2008

This has been a super useful thread... thx to the contributors... I am also trying to figure out how to give users the choice to switch notifications on and off, depending on their preference.

There is a Block for EmailNotify located in ProfileFields table in the database, and if you edit it in phpmyadmin, you can change it from system to select_one... so it does show up in the user fields and the members can select it.. but as per my recent tests, the members still get emails... still testing all scenarios, and scanning code for the EmailNotify functions.

Anyone else get user-controlled notification settings working? I noticed even the mods section has lots of notifications, but no way to control them for the user.

Will update here if I figure it out first.

cheerz

Scott

Quote · 14 Oct 2008

WOW you guys did a great job on this. I have one more thing that maybe could be changed?

 

My users are used to being taken directly to that message. The link in the email would directly take you to the PM that was sent to you. Can this be changed? If so how? I would like to have this if all possible.

 

Thanks again and great job on the fixing it!!

Quote · 31 Oct 2008

I can't get my email notifications to work. I followed kinder's instructions to make the option available to a user, enabled it, but the emails did not come through on the test site. Any help appreciated.

Quote · 2 Jan 2009

Hi, it is a old topic, but I found it trying to find a solution to have "Nozify per email" checked as standart, so that my user get automaticaly an email when they get a message in my site.

But:

I can not find compose.php (dolphin 7.0.6)

It is now a different file ( like mail.php) and do somebody have any advice ?

 

Thank you

Quote · 17 Jun 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.