Closed Thread Icon

Topic awaiting preservation: Sorting emails based upon forwarded etc - BUT STUCK !! HEEEELP!!! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30728" title="Pages that link to Topic awaiting preservation: Sorting emails based upon forwarded etc - BUT STUCK !! HEEEELP!!! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Sorting emails based upon forwarded etc - BUT STUCK !! HEEEELP!!! <span class="small">(Page 1 of 1)</span>\

 
paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 12-24-2008 07:27

I've been hacking away at trying to work out a stupid algorithm for the mailing program Im working upon. The thing is that we download emails to our own database and I've fixed it so you can view all downloaded emails on a page. The thing is that from thsi page is the provision to forward and reply emails. Ok I've set it so that when a message is downloaded into our Database its supposed to be listed as follows:

Downloaded Email [has links to reply and forward]
Downloaded Email [has links to reply and forward]
Downloaded Email [has links to reply and forward]
Downloaded Email [has links to reply and forward]

I've set it up so when you reply to an email from this page an entry is made in our email db and the replied email can be viewed as such - HOWEVER the replied email would only have a forward link - makes no sense to reply to yourself now does it.

Downloaded Email [has links to reply and forward]
-->Reply to Downloaded Email [has link to forward]
-->Reply to Downloaded Email [has link to forward]
Downloaded Email [has links to reply and forward]
Downloaded Email [has links to reply and forward]
Downloaded Email [has links to reply and forward]
-->Reply to Downloaded Email [has link to forward]
-->Reply to Downloaded Email [has link to forward]
Downloaded Email [has links to reply and forward]

And I'm trying to set it to work with forwarded emaisl in teh same way however I'm running into some issues here. My algo is kinda like this - whenever an email is sent in reply to or forwarded from another email - the replyto /forward fields of that email are populated with teh respective email to which they were replied to/forwarded from. My current algo is such that:

code:
all_replied_email_ids = get_email_ids_replied_to(all_email ids)
remove_email_ids_replied_to(all_email ids)

foreach(all_email_ids as one_email)
    show email
    if(email was replied to)
      show replied to email from all_replied_email_ids;
Loop



I'm trying to do the same with forwarded emails However theres one little problem here. This is fine in the case where a message is forwarded once and teh forwarded message is itself not again forwarded. However I can forward forwarded messages and would like to display the forwarded messages in their hierarchical sturcture. Kinda like this

Downloaded Email [has links to reply and forward]
-->Reply to Downloaded Email [has link to forward]
-->Reply to Downloaded Email [has link to forward]
----->Forwarded Downloaded Email [has link to forward]
----->Forwarded Downloaded Email [has link to forward]
--------->Forwarded Forwarded Downloaded Email [has link to forward]
----->Forwarded Downloaded Email [has link to forward]
--------->Forwarded Forwarded Downloaded Email [has link to forward]
Downloaded Email [has links to reply and forward]

Right now I just have an array containing data as folows:

Message ID | Message ID Replied To | Message ID Forwarded From

How do I arrange it so the messages are in their proper hierarchy... I really need help on this pronto guys.. times like this I wish I didnt sleep through my data structures classes

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-24-2008 14:20
quote:

paritycheck said:

HOWEVER the replied email would only have a forward link - makes no sense to reply to yourself now does it.


Actually it does - should send the mail to the same people you replied to in the first place - i.e. it's a followup
to your own reply, should quote what you said, but go to the same people.


And you need to sort your message into an array by hand if they come out of a sql database.
Just keep them in an associative array by their message id,
then foreach message,
$array[$forwardedFrom]['child'] => $thisMesage...

so long,

->Tyberius Prime

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 12-24-2008 18:10

Yeah thats fine but in this case the child messages have further child messages and its a bit recursive you know like a forwarded message can be forwarded and so forth. The process is recursive and I have no idea how to do so - really need some ideas here

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 01-02-2009 20:40

Well I figured out how to get this done - I handed it to a co worker and he mixed up a recursive function that does the work wonderfully. Guess if you cant beat it - let someone else do it

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-03-2009 18:38

well, in php 4, the trick will have been

$array[$forwardedFrom]['child'] => &$thisMesage...

this way you could build the whole recursive structure in one loop through.

« BackwardsOnwards »

Show Forum Drop Down Menu