Results 1 to 1 of 1

Thread: save flow

  1. #1
    eardizzo is offline Junior Member
    Join Date
    Apr 2011
    Posts
    4

    Post save flow

    hi
    I have a custom module (a custom version of person module)
    i've added a after_save hook to copy in contacts module the account just created .

    so when you insert first_name,last_name and e_mail and clic save in my module you will find the same information on contacts module.

    it works fine except that the email_address table is filled after the hook ,so i can't duplicate the e-mail address.
    if then I modify the account and save it again my code work correctly(because email_addresses table is already filled) and the e_mail field in contacts is filled right

    here the hook

    function crea(&$bean, $event, $arguments)
    {
    if (empty($bean->fetched_row['id']) )
    {
    //save new contact if this is the first time you save the account
    $query="INSERT INTO contacts (id,last_name,first_name) VALUES ('$bean->id','$bean->last_name','$bean->first_name')";
    $result = $bean->db->query($query);
    }
    //delete old e_mail relation (enable e_mail modification)
    $query="DELETE FROM email_addr_bean_rel WHERE bean_id='$bean->id' AND bean_module='Contacts' AND primary_address=1";
    $result = $bean->db->query($query);
    //find if the person have a mail
    $query="SELECT email_address_id FROM email_addr_bean_rel WHERE bean_id='{$bean->id}' AND bean_module='STU_Persone' AND primary_address=1";
    $result = $bean->db->query($query, true);
    if ($bean->db->getRowCount($result) > 0)
    {
    //create new relation form mail to contacts:
    $row =$bean->db->fetchByAssoc($result);
    $mail=$row['email_address_id'];
    $query="INSERT INTO email_addr_bean_rel (id , email_address_id , bean_id , bean_module , primary_address ) VALUES( UUID(),'$mail','$bean->id','Contacts',1)";
    $result = $bean->db->query($query);
    }

    so the question is :
    how can i execute my hook after the eamil_address isertion?
    Last edited by eardizzo; 2011-04-28 at 07:54 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Flow Diagram
    By aswath28 in forum Developer Help
    Replies: 0
    Last Post: 2008-10-17, 12:15 PM
  2. Replies: 4
    Last Post: 2008-04-10, 09:11 PM
  3. Cant get the flow
    By patrickegan in forum Classifieds
    Replies: 4
    Last Post: 2007-06-11, 04:23 PM
  4. Cant get the flow
    By patrickegan in forum Help
    Replies: 1
    Last Post: 2007-06-08, 10:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •