Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Fix: Allow sender to remove message from outbox

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
18 years 3 months ago #19689 by slabbi
Well with this fix a sender can remove certain messages from the outbox:

Update your database (you have to add one field):
[code:1]ALTER TABLE `jos_uddeim` ADD `totrashoutbox` INT( 1 ) DEFAULT '0' NOT NULL ;
[/code:1]

In
function showOutbox($myself, $item_id)
change
[code:1]$sql="SELECT count(id) FROM #__uddeim WHERE ((systemmessage IS NULL) OR (systemmessage='')) AND fromid=".$my->id;
[/code:1]
to
[code:1]$sql="SELECT count(id) FROM #__uddeim WHERE totrashoutbox<1 AND ((systemmessage IS NULL) OR (systemmessage='')) AND fromid=".$my->id;
[/code:1]

Change
[code:1]if($config_realnames) {
$sql="SELECT a.*, b.name AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.toid=b.id AND ((a.systemmessage IS NULL) OR (a.systemmessage='')) ORDER BY toread ASC, datum DESC LIMIT ".$limitstart.", ".$limit;
} else {
$sql="SELECT a.*, b.username AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.toid=b.id AND ((a.systemmessage IS NULL) OR (a.systemmessage='')) ORDER BY toread ASC, datum DESC LIMIT ".$limitstart.", ".$limit;
}
[/code:1]
to
[code:1]if($config_realnames) {
$sql="SELECT a.*, b.name AS toname FROM #__uddeim AS a, #__users AS b WHERE a.totrashoutbox<1 AND a.fromid=".$my->id." AND a.toid=b.id AND ((a.systemmessage IS NULL) OR (a.systemmessage='')) ORDER BY toread ASC, datum DESC LIMIT ".$limitstart.", ".$limit;
} else {
$sql="SELECT a.*, b.username AS toname FROM #__uddeim AS a, #__users AS b WHERE a.totrashoutbox<1 AND a.fromid=".$my->id." AND a.toid=b.id AND ((a.systemmessage IS NULL) OR (a.systemmessage='')) ORDER BY toread ASC, datum DESC LIMIT ".$limitstart.", ".$limit;
}
[/code:1]

Change following block:
[code:1] $datumcell=uddeDate($themessage->datum);
if($themessage->toread==0) {
$deletecell="<a href=index.php?option=com_uddeim&task=recall&messageid=".$themessage->id.">"._UDDEIM_RECALL."</a>";
$deletecell.="<br>";
} else {
$deletecell="";
}
$sbsdeletecell="<a href=index.php?option=com_uddeim&task=deletefromoutbox&returnlimit=".$limit."&returnlimitstart=".$limitstart."&messageid=".$themessage->id.">"._UDDEIM_DELETELINK."</a>";

echo "\n\t<tr class='sectiontableentry".$i."'>";
echo "\n\t\t<td valign='middle'>".$readcell."</td>";
echo "\n\t\t<td>".$tocell."</td>";
echo "\n\t\t<td>".$messagecell."</td>";
echo "\n\t\t<td>".$datumcell."</td>";
echo "\n\t\t<td class='pathway'>".$deletecell.$sbsdeletecell."</td>";
echo "</tr>";

[/code:1]

Add following function:

[code:1]function deleteMessageOutbox($myself, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id, $ret) {
## Delete sets outbox trash flag to true (it does not erase the message from the database,
## this is only done by PRUNING the messages. So messages deleted from the inbox will
## be moved to the trash can of the respective user
global $database, $my, $config_allowarchive;

$deletetime=uddetime();

$sql="UPDATE #__uddeim SET totrashoutbox=1 WHERE fromid=".$my->id." AND id=".$messageid;
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to trash a message" . $database->stderr(true));
}

if($ret=='archive' && $config_allowarchive) {
$redirecturl="index.php?option=com_uddeim&task=archive&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl);
} elseif($ret=='top') {
$redirecturl="index.php?option=com_uddeim&task=inbox&Itemid=".$item_id;
mosRedirect($redirecturl);
} else {
$redirecturl="index.php?option=com_uddeim&task=inbox&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl);
}
}
[/code:1]


There is still a small problem:
When the receiver deletes the message and it is purged after e.g. 48hours it is also purged from the senders outbox.

To fix this the purge-function has to check both flags for deleting a message and the showtrash-function must be modified only to display items which purge time is not exceeded. Since these modifications need some more lines of code I keep this for the author. I have tried to reach him but his email address seems to be outdated. :-(

Post edited by: slabbi, at: 2006/08/27 15:37

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
18 years 3 months ago #19762 by slabbi
Ok, you have asked for it.

Here is a better version of the "Allow user to delete msgs from the outbox" feature.

1. Update the table "jos_uddeim":

[code:1]ALTER TABLE `jos_uddeim` ADD `totrashoutbox` INT( 1 ) DEFAULT '0' NOT NULL ;
ALTER TABLE `jos_uddeim` ADD `totrashdateoutbox` INT( 11 ) DEFAULT NULL ;
[/code:1]

2. Replace uddeim.php with the attached file.

Features:
- Deleted msgs from the outbox will be shown in the trashcan
- Deleted msgs can be restored from the trashcan
- Msgs will disappear after n hours from the trashcan

There is still a very small problem:

When the receiver deletes the message and the sender has the message still in his outbox, it is automatically deleted after n hours.

If you don't like this behaviour you can replace
[code:1]$sql="DELETE FROM #__uddeim WHERE totrash>0 AND totrashdate<".$timeframe;
[/code:1]
with
[code:1]$sql="DELETE FROM #__uddeim WHERE totrashoutbox>0 AND totrash>0 AND totrashdate<".$timeframe." AND totrashdateoutbox<".$timeframe;
[/code:1]

If you have problems, or fixes for this fix, please report here.

Attachment uddeim.zip not found



Post edited by: slabbi, at: 2006/08/28 22:17

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer
Attachments:

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
18 years 3 months ago #19825 by slabbi
Well, thanks for the feedback.

Here is a newer version which also fixes the view of the trashcan.

Update your table:

[code:1]ALTER TABLE `jos_uddeim` ADD `totrashoutbox` INT( 1 ) DEFAULT '0' NOT NULL ;
ALTER TABLE `jos_uddeim` ADD `totrashdateoutbox` INT( 11 ) DEFAULT NULL ;
[/code:1]

and replace uddeim.php with the attached file.

Attachment uddeim-9b0f12a167d6348a6cbc72e95b59b139.zip not found


uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer
Attachments:

Please Log in or Create an account to join the conversation.

  • euro22
  • euro22
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 1
18 years 3 months ago #20132 by euro22
There is a small issue with the navigation which shows more messages as available.

A fixed version is attached.

Attachment uddeim-7c20ff558f924bbb68bd485cbd28db15.zip not found

Attachments:

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
18 years 3 months ago #20478 by slabbi
Thanks, I did some more fixes, so I plan to release an updated uddeIM (maybe called uddeIM+ 0.5 in a few days). The plus should show that it is based on uddeIM 0.5 with extra features.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

  • jgideon
  • jgideon
  • OFFLINE
  • Posts: 12
  • Thanks: 0
  • Karma: 0
18 years 2 months ago #21724 by jgideon
I love the pluggin!

Post edited by: jgideon, at: 2006/09/29 16:44

Please Log in or Create an account to join the conversation.

Moderators: beatnantslabbikrileon
Powered by Kunena Forum