Delete mail from outbox 6.1

mrpowless posted 25th of August 2008 in Community Voice. 13 comments.

replace one function to get this to work

open mail.php and replace function:

function PageCodeOutbox()
{
global $memberID;
global $site;
global $tmpl;
global $date_format;

if( $_REQUEST['do_delete'] or $_REQUEST['do_mark_new'] or $_REQUEST['do_mark_old'] )
{
if( $_REQUEST['do_delete'] )
$sqlDoQuery = "DELETE FROM `Messages` WHERE";


if( $aMsgs = $_POST['m'] and is_array( $aMsgs ) and !empty( $aMsgs ) )
{
foreach( $aMsgs as $msgID => $on )
{
$msgID = (int)$msgID;
if( !$msgID or $on != 'on' )
continue;

db_res( "$sqlDoQuery `ID`=$msgID AND `Sender` = $memberID" );
}
}
}
//echoDbg( $_POST );



$query = "
SELECT
`Messages`.`ID`,
UNIX_TIMESTAMP( `Date` ) AS `timestamp`,
DATE_FORMAT(`Date`, '$date_format') AS `Date`,
`Recipient`,
`Profiles`.`NickName` AS `SenderNickName`,
`Subject`,
`New`
FROM `Messages`
LEFT JOIN `Profiles` ON
`Profiles`.`ID` = `Recipient`
WHERE `Sender` = $memberID
ORDER BY `Date` DESC
";

$rMsgs = db_res( $query );

if( !mysql_num_rows( $rMsgs ) )
return '<div class="no_result"><div>'._t( "_No messages in Outbox" ).'</div></div>';


// --- get template and replace headers ---
$aReplace = array();

$aReplace['mailbox_header_img'] = '<img src="'.getTemplateIcon( 'inbox.gif' ) .'" class="mailbox_header_img" />';
//$aReplace['summary'] = _t(
$aReplace['flag'] = _t( '_Flag' );
$aReplace['from'] = _t( '_From' );
$aReplace['date'] = _t( '_Date' );
$aReplace['subject'] = _t( '_Subject' );
$aReplace['click_to_sort'] = _t( '_Click to sort' );

$aReplace['actions_l'] = _t( "_Selected messages" ) .':';
$aReplace['actions'] = '
<input type="submit" class="mailbox_submit" name="do_delete" value="'._t('_Delete').'" onclick="return confirm(\''._t('_are you sure?').'\');" />
';

$ret = file_get_contents(BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/mail_box.html");
foreach( $aReplace as $key => $val )
$ret = str_replace( "__{$key}__", $val, $ret );

$aMyTmpl = preg_split( "/\{\/?InsertRows\}/", $ret );
$tmplRow = $aMyTmpl[1];
$ret = "{$aMyTmpl[0]}{InsertRows /}{$aMyTmpl[2]}";

$InsertRows = '';
$tr_class = 'odd';
while( $aMsg = mysql_fetch_assoc( $rMsgs ) )
{
$sSubject = process_line_output( html2txt( $aMsg['Subject'] ));

$aReplace = array();

$aReplace['tr_class'] = $tr_class;
$aReplace['new_add'] = $aMsg['New'] ? 'new' : '';

$aReplace['ID'] = $aMsg['ID'];
$aReplace['CheckBox'] = '<input type="checkbox" class="td_mailbox_checkbox" id="sel_msg_'.$aMsg['ID'].'" name="m['.$aMsg['ID'].']" value="on" />';
$aReplace['Flag'] = '<img class="mailbox_flag_img" src="'.getTemplateIcon( $aMsg['New'] ? 'not_readed.gif' : 'readed.gif' ).'" title="'._t( $aMsg['New'] ? '_New Message' : '_Readed' ).'" />';
$aReplace['From'] = '<center><div style="width:45px;">' . get_member_icon($aMsg['Sender']) . "<div class=\"clear_both\"></div><!--{$aMsg['SenderNickName']}--> <a href=\"".getProfileLink($aMsg['Sender'])."\">{$aMsg['SenderNickName']}</a>" . '</center>';
$aReplace['Date'] = "<!--{$aMsg['timestamp']}--> {$aMsg['Date']}";
$aReplace['Subject'] = "<!--$sSubject--> <a href=\"{$site['url']}messages_outbox.php?message={$aMsg['ID']}\">$sSubject</a>";


$sInsertRow = $tmplRow;
foreach( $aReplace as $key => $val )
$sInsertRow = str_replace( "{{$key}}", $val, $sInsertRow );

$sInsertRows .= $sInsertRow;
$tr_class = ( $tr_class == 'odd' ? 'even' : 'odd' );
}

$ret = str_replace( "{InsertRows /}", $sInsertRows, $ret );

$ret =
'<form name="mailbox_form" action="'.$_SERVER['PHP_SELF'].'?mode=outbox" method="post">'.$ret.'</form>';

return $ret;
}

 
Comments
·Oldest
·Top
Please login to post a comment.
MichelSwiss
Thank you mrpowless :-)

I had to change a line for the function to work properly:

function PageCodeOutbox()
{
global $memberID;
global $dir;
global $site;
global $tmpl;
global $date_format;

if( $_REQUEST['do_delete'] or $_REQUEST['do_mark_new'] or $_REQUEST['do_mark_old'] )
{
if( $_REQUEST['do_delete'] )
$sqlDoQuery = "DELETE FROM `Messages` WHERE";

if( $aMsgs = $_POST['m'] and is_array( $aMsgs ) and !empty( $aMsgs ) )
{
foreach( $aMsgs as $msgID => $on )
{
$msgID see more = (int)$msgID;
if( !$msgID or $on != 'on' )
continue;

db_res( "$sqlDoQuery `ID`=$msgID AND `Sender` = $memberID" );
}
}
}

$query = "
SELECT
`Messages`.`ID`,
UNIX_TIMESTAMP( `Date` ) AS `timestamp`,
DATE_FORMAT(`Date`, '$date_format') AS `Date`,
`Recipient`,
`Profiles`.`NickName` AS `SenderNickName`,
`Subject`,
`New`
FROM `Messages`
LEFT JOIN `Profiles` ON
`Profiles`.`ID` = `Recipient`
WHERE `Sender` = $memberID
ORDER BY `Date` DESC
";

$rMsgs = db_res( $query );

if( !mysql_num_rows( $rMsgs ) )
return '<div class="no_result"><div>'._t( "_No messages in Outbox" ).'</div></div>';


// --- get template and replace headers ---
$aReplace = array();

$aReplace['mailbox_header_img'] = '<img src="'.getTemplateIcon( 'outbox.gif' ) .'" class="mailbox_header_img" />';
//$aReplace['summary'] = _t(
$aReplace['flag'] = _t( '_Flag' );
$aReplace['from'] = _t( '_From' );
$aReplace['date'] = _t( '_Date' );
$aReplace['subject'] = _t( '_Subject' );
$aReplace['click_to_sort'] = _t( '_Click to sort' );

$aReplace['actions_l'] = _t( "_Selected messages" ) .':';
$aReplace['actions'] = '
<input type="submit" class="mailbox_submit" name="do_delete" value="'._t('_Delete').'" onclick="return confirm(\''._t('_are you sure?').'\');" />
';

$ret = file_get_contents(BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/mail_box.html");
foreach( $aReplace as $key => $val )
$ret = str_replace( "__{$key}__", $val, $ret );

$aMyTmpl = preg_split( "/\{\/?InsertRows\}/", $ret );
$tmplRow = $aMyTmpl[1];
$ret = "{$aMyTmpl[0]}{InsertRows /}{$aMyTmpl[2]}";

$InsertRows = '';
$tr_class = 'odd';
while( $aMsg = mysql_fetch_assoc( $rMsgs ) )
{
$sSubject = process_line_output( html2txt( $aMsg['Subject'] ));

$aReplace = array();

$aReplace['tr_class'] = $tr_class;
$aReplace['new_add'] = $aMsg['New'] ? 'new' : '';

$aReplace['ID'] = $aMsg['ID'];
$aReplace['CheckBox'] = '<input type="checkbox" class="td_mailbox_checkbox" id="sel_msg_'.$aMsg['ID'].'" name="m['.$aMsg['ID'].']" value="on" />';
$aReplace['Flag'] = '<img class="mailbox_flag_img" src="'.getTemplateIcon( $aMsg['New'] ? 'not_readed.gif' : 'readed.gif' ).'" title="'._t( $aMsg['New'] ? '_New Message' : '_Readed' ).'" />';


--- here some change -------------

$aReplace['From'] = '<center><div style="width:45px;">' . get_member_icon($aMsg['Recipient']) . "<div class=\"clear_both\"></div><!--{$aMsg['RecipientNickName']}--> <a href=\"".getProfileLink($aMsg['Recipient'])."\">{$aMsg['RecipientNickName']}</a>" . '</center>';

--- end of change ----------------


$aReplace['Date'] = "<!--{$aMsg['timestamp']}--> {$aMsg['Date']}";
$aReplace['Subject'] = "<!--$sSubject--> <a href=\"{$site['url']}messages_outbox.php?message={$aMsg['ID']}\">$sSubject</a>";


$sInsertRow = $tmplRow;
foreach( $aReplace as $key => $val )
$sInsertRow = str_replace( "{{$key}}", $val, $sInsertRow );

$sInsertRows .= $sInsertRow;
$tr_class = ( $tr_class == 'odd' ? 'even' : 'odd' );
}

$ret = str_replace( "{InsertRows /}", $sInsertRows, $ret );

$ret =
'<form name="mailbox_form" action="'.$_SERVER['PHP_SELF'].'?mode=outbox" method="post">'.$ret.'</form>';

return $ret;
}
mrpowless
cool version updates already you dah man swiss
atermaner
mrpowless is next brilliant mod... thanks....
TheGateKeeper
I have read all the posts related to this topic!! It leaves me confused could someone please simplify the procedure for me :>} Thank you all!!
Wow... i am so thankful Thanks to the Pros.. here

God bless you all
micliz
Haven't you guys realized that when you delete a sent message it also deletes the message from the recipient's inbox?

This is probably why you're not allowed to delete sent messages in the first place.

And on the flipside, when you delete messages in your inbox it deletes them from the senders "sent mail".

The messages are linked, and need to be separate. What am I missing here?

6.1.6
micliz
Mrpowless, what do you think about my previous comment? Am I wrong or is there a better solution?
mydatingcommunity
Extremely rude person…I recommend no one to work with this guy!
mydatingcommunity
I SCREEN PEOPLE LIKE YOU...BECAUSE I AM GIVING YOU MONEY!!!!
mydatingcommunity
I DO NOT recommend this guy to NO ONE. He thinks everything is a joke for him. I was planning to give him $1000 worth of work. But His Majesty got distribute for a phone call on Sunday before he starts to work where I was trying to build relationship and make sure my MONEY goes to the right person. He does not like to be called on Sunday and claims my English is not good, but he did not know that i served in the US ARMY in Iraq for 4 years and gave him his freedom to enjoy his Sunday...

As he see more claims he has a blacklist of site owner..It seems he forgot that site owner pay HIM money, and it is the other way around..So, He is on my black list!

He is very rude person!..and has no manners
 
 
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.
PET:0.13190317153931