Пример #1
0
         } else {
             $lead->assigned_user_name = "seed_max";
         }
     }
     $lead->assigned_user_id = $lead->assigned_user_name . "_id";
 }
 // If this is a large scale test, switch to the bulk teams 90% of the time.
 if ($large_scale_test) {
     if (mt_rand(0, 100) < 90) {
         $assigned_team = $team_demo_data->get_random_team();
         $lead->team_id = $assigned_team;
         $lead->assigned_user_id = $account->assigned_user_id;
         $lead->assigned_user_name = $assigned_team;
     } else {
         $teams = $team_demo_data->get_random_teamset();
         $lead->load_relationship('teams');
         $lead->teams->add($teams);
         $lead->assigned_user_id = $account->assigned_user_id;
     }
 } else {
     if (mt_rand(0, 100) < 50) {
         $lead->team_id = $lead->billing_address_state == "CA" ? "West" : "East";
         $teams = $team_demo_data->get_random_teamset();
         $lead->load_relationship('teams');
         $lead->teams->add($teams);
     } else {
         $lead->team_id = $lead->billing_address_state == "CA" ? "West" : "East";
         $lead->team_set_id = $lead->team_id;
     }
 }
 $lead->primary_address_postalcode = mt_rand(10000, 99999);
Пример #2
0
 /**
  * handles linking contacts, accounts, etc. to an email
  *
  * @param object Email bean to be linked against
  * @return string contactAddr is the email address of the sender
  */
 function handleLinking(&$email)
 {
     // link email to an User if emails match TO addr
     if ($userIds = $this->getRelatedId($email->to_addrs, 'users')) {
         $GLOBALS['log']->debug('I-E linking email to User');
         // link the user to the email
         $email->load_relationship('users');
         $email->users->add($userIds);
     }
     // link email to a Contact, Lead, or Account if the emails match
     // give precedence to REPLY-TO above FROM
     if (!empty($email->reply_to_email)) {
         $contactAddr = $email->reply_to_email;
     } else {
         $contactAddr = $email->from_addr;
     }
     // Samir Gandhi : 12/06/07
     // This changes has been done because the linking was done only with the from address and
     // not with to address
     $relationShipAddress = $contactAddr;
     if (empty($relationShipAddress)) {
         $relationShipAddress .= $email->to_addrs;
     } else {
         $relationShipAddress = $relationShipAddress . "," . $email->to_addrs;
     }
     if ($leadIds = $this->getRelatedId($relationShipAddress, 'leads')) {
         $GLOBALS['log']->debug('I-E linking email to Lead');
         $email->load_relationship('leads');
         $email->leads->add($leadIds);
         foreach ($leadIds as $leadId) {
             $lead = new Lead();
             $lead->retrieve($leadId);
             $lead->load_relationship('emails');
             $lead->emails->add($email->id);
         }
     }
     if ($contactIds = $this->getRelatedId($relationShipAddress, 'contacts')) {
         $GLOBALS['log']->debug('I-E linking email to Contact');
         // link the contact to the email
         $email->load_relationship('contacts');
         $email->contacts->add($contactIds);
     }
     if ($accountIds = $this->getRelatedId($relationShipAddress, 'accounts')) {
         $GLOBALS['log']->debug('I-E linking email to Account');
         // link the account to the email
         $email->load_relationship('accounts');
         $email->accounts->add($accountIds);
         /* cn: bug 9171 another cause of dying I-E - bad linking
         			foreach($accountIds as $accountId) {
         				$GLOBALS['log']->debug('I-E reverse-linking Accounts to Emails');
         				$acct = new Account();
         				$acct->retrieve($accountId);
         				$acct->load_relationship('emails');
         				$acct->account_emails->add($email->id);
         			}
         			*/
     }
     return $contactAddr;
 }
 /**
  * handles linking contacts, accounts, etc. to an email
  *
  * @param object Email bean to be linked against
  * @return string contactAddr is the email address of the sender
  */
 function handleLinking(&$email)
 {
     // link email to an User if emails match TO addr
     if ($userIds = $this->getRelatedId($email->to_addrs, 'users')) {
         $GLOBALS['log']->debug('I-E linking email to User');
         // link the user to the email
         $email->load_relationship('users');
         $email->users->add($userIds);
     }
     // link email to a Contact, Lead, or Account if the emails match
     // give precedence to REPLY-TO above FROM
     if (!empty($email->reply_to_email)) {
         $contactAddr = $email->reply_to_email;
     } else {
         $contactAddr = $email->from_addr;
     }
     if ($leadIds = $this->getRelatedId($contactAddr, 'leads')) {
         $GLOBALS['log']->debug('I-E linking email to Lead');
         $email->load_relationship('leads');
         $email->leads->add($leadIds);
         if (!class_exists('Lead')) {
             require_once 'modules/Leads/Lead.php';
         }
         foreach ($leadIds as $leadId) {
             $lead = new Lead();
             $lead->retrieve($leadId);
             $lead->load_relationship('emails');
             $lead->emails->add($email->id);
         }
     }
     if ($contactIds = $this->getRelatedId($contactAddr, 'contacts')) {
         $GLOBALS['log']->debug('I-E linking email to Contact');
         // link the contact to the email
         $email->load_relationship('contacts');
         $email->contacts->add($contactIds);
     }
     if ($accountIds = $this->getRelatedId($contactAddr, 'accounts')) {
         $GLOBALS['log']->debug('I-E linking email to Account');
         // link the account to the email
         $email->load_relationship('accounts');
         $email->accounts->add($accountIds);
         if (!class_exists('Account')) {
             require_once 'modules/Accounts/Account.php';
         }
         /* cn: bug 9171 another cause of dying I-E - bad linking
         			foreach($accountIds as $accountId) {
         				$GLOBALS['log']->debug('I-E reverse-linking Accounts to Emails');
         				$acct = new Account();
         				$acct->retrieve($accountId);
         				$acct->load_relationship('emails');
         				$acct->account_emails->add($email->id);
         			}
         			*/
     }
     return $contactAddr;
 }