本文整理汇总了PHP中ProspectList::load_relationship方法的典型用法代码示例。如果您正苦于以下问题:PHP ProspectList::load_relationship方法的具体用法?PHP ProspectList::load_relationship怎么用?PHP ProspectList::load_relationship使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProspectList
的用法示例。
在下文中一共展示了ProspectList::load_relationship方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_addToProspectList
protected function action_addToProspectList()
{
global $beanList;
require_once 'modules/Relationships/Relationship.php';
require_once 'modules/ProspectLists/ProspectList.php';
$prospectList = new ProspectList();
$prospectList->retrieve($_REQUEST['prospect_id']);
$module = new $beanList[$this->bean->report_module]();
$key = Relationship::retrieve_by_modules($this->bean->report_module, 'ProspectLists', $GLOBALS['db']);
if (!empty($key)) {
$sql = $this->bean->build_report_query();
$result = $this->bean->db->query($sql);
$beans = array();
while ($row = $this->bean->db->fetchByAssoc($result)) {
if (isset($row[$module->table_name . '_id'])) {
$beans[] = $row[$module->table_name . '_id'];
}
}
if (!empty($beans)) {
foreach ($prospectList->field_defs as $field => $def) {
if ($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key) {
$prospectList->load_relationship($field);
$prospectList->{$field}->add($beans);
}
}
}
}
die;
}
示例2: action_add_to_list
public function action_add_to_list()
{
$ids = $_POST['subpanel_id'];
$event_id = $_POST['return_id'];
$type = $_POST['pop_up_type'];
if (!is_array($ids)) {
$ids = array($ids);
}
//Target lists. Can incliude contacts, leads and targets as part of the target list
if ($type = 'target_list') {
foreach ($ids as $list) {
$event = new FP_events();
$event->retrieve($event_id);
$event->load_relationship('fp_events_prospects_1');
$event->load_relationship('fp_events_contacts');
$event->load_relationship('fp_events_leads_1');
$target_list = new ProspectList();
$target_list->retrieve($list);
$target_list->load_relationship('prospects');
$target_list->load_relationship('contacts');
$target_list->load_relationship('leads');
//add prospects/targets
foreach ($target_list->prospects->getBeans() as $contact) {
$contact_id_list = $event->fp_events_prospects_1->get();
if (!in_array($contact->id, $contact_id_list)) {
//check if its already related
$event->fp_events_prospects_1->add($contact->id);
}
}
//add contacts
foreach ($target_list->contacts->getBeans() as $contact) {
$contact_id_list = $event->fp_events_contacts->get();
if (!in_array($contact->id, $contact_id_list)) {
$event->fp_events_contacts->add($contact->id);
}
}
//add leads
foreach ($target_list->leads->getBeans() as $contact) {
$contact_id_list = $event->fp_events_leads_1->get();
if (!in_array($contact->id, $contact_id_list)) {
$event->fp_events_leads_1->add($contact->id);
}
}
}
}
//Targets
if ($type = 'targets') {
foreach ($ids as $target) {
$event = new FP_events();
$event->retrieve($event_id);
$event->load_relationship('fp_events_prospects_1');
$contact_id_list = $event->fp_events_prospects_1->get();
//get array of currently linked targets
if (!in_array($target, $contact_id_list)) {
//check if its already in the array
$event->fp_events_prospects_1->add($target);
//if not add relationship
}
}
}
//leads
if ($type = 'leads') {
foreach ($ids as $lead) {
$event = new FP_events();
$event->retrieve($event_id);
$event->load_relationship('fp_events_leads_1');
$contact_id_list = $event->fp_events_leads_1->get();
//get array of currently linked leads
if (!in_array($lead, $contact_id_list)) {
//check if its already in the array
$event->fp_events_leads_1->add($lead);
//if not add relationship
}
}
}
//contacts
if ($type = 'contacts') {
foreach ($ids as $contact) {
$event = new FP_events();
$event->retrieve($event_id);
$event->load_relationship('fp_events_contacts');
$contact_id_list = $event->fp_events_contacts->get();
//get array of currently linked contacts
if (!in_array($contact, $contact_id_list)) {
$event->fp_events_contacts->add($contact);
}
}
}
die;
}
示例3: unsubscribe
function unsubscribe($campaign, $focus) {
$relationship = strtolower($focus->getObjectName()).'s';
//--grab all the list for this campaign id
$pl_qry ="select id, list_type from prospect_lists where id in (select prospect_list_id from prospect_list_campaigns ";
$pl_qry .= "where campaign_id = '$campaign') and deleted = 0 ";
$pl_qry_result = $focus->db->query($pl_qry);
//build the array with list information
$pl_arr = array();
$GLOBALS['log']->debug("In Campaigns Util, about to run query: ".$pl_qry);
while ($row = $focus->db->fetchByAssoc($pl_qry_result)){$pl_arr[] = $row;}
//retrieve lists that this user belongs to
$curr_pl_qry ="select prospect_list_id, related_id from prospect_lists_prospects ";
$curr_pl_qry .="where related_id = '$focus->id' and deleted = 0 ";
$GLOBALS['log']->debug("In Campaigns Util, unsubscribe function about to run query: ".$curr_pl_qry );
$curr_pl_qry_result = $focus->db->query($curr_pl_qry);
//build the array with current user list information
$curr_pl_arr = array();
while ($row = $focus->db->fetchByAssoc($curr_pl_qry_result)){$curr_pl_arr[] = $row;}
//check to see if user is already there in prospect list
$already_here = 'false';
$exempt_id = '';
foreach($curr_pl_arr as $user_list){
foreach($pl_arr as $v){
//if list is exempt list
if($v['list_type'] == 'exempt'){
//save the exempt list id for later use
$exempt_id = $v['id'];
//check to see if user is already in this exempt list
if(in_array($v['id'], $user_list)){
$already_here = 'true';
}
break 2;
}
}
}
//unsubscribe subscripted newsletter
foreach($pl_arr as $subscription_list){
//create a new instance of the prospect list
$exempt_list = new ProspectList();
$exempt_list->retrieve($subscription_list['id']);
$exempt_list->load_relationship($relationship);
//if list type is default, then delete the relationship
//if list type is exempt, then add the relationship to unsubscription list
if($subscription_list['list_type'] == 'exempt') {
$exempt_list->$relationship->add($focus->id);
}elseif($subscription_list['list_type'] == 'default' || $subscription_list['list_type'] == 'test'){
//if list type is default or test, then delete the relationship
//$exempt_list->$relationship->delete($subscription_list['id'],$focus->id);
}
}
if($already_here =='true'){
//do nothing, user is already exempted
}else{
//user is not exempted yet , so add to unsubscription list
$exempt_result = $exempt_list->retrieve($exempt_id);
if($exempt_result == null)
{//error happened while retrieving this list
return;
}
$GLOBALS['log']->debug("In Campaigns Util, loading relationship: ".$relationship);
$exempt_list->load_relationship($relationship);
$exempt_list->$relationship->add($focus->id);
}
}
示例4: unsubscribe
function unsubscribe($campaign, $focus)
{
$relationship = strtolower($focus->getObjectName()) . 's';
//--grab the exempt list for this campaign id
$pl_qry = "select id from prospect_lists where id in (select prospect_list_id from prospect_list_campaigns ";
$pl_qry .= "where campaign_id = '{$campaign}') and deleted = 0 ";
$pl_qry .= "and list_type like 'exempt%' and deleted = 0 ";
$pl_qry_result = $focus->db->query($pl_qry);
//build the array with list information
$pl_arr = array();
$GLOBALS['log']->debug("In Campaigns Util, about to run query: " . $pl_qry);
$pl_arr = $focus->db->fetchByAssoc($pl_qry_result);
//retrieve lists that this user belongs to
$curr_pl_qry = "select prospect_list_id, related_id from prospect_lists_prospects ";
$curr_pl_qry .= "where related_id = '{$focus->id}' and deleted = 0 ";
$GLOBALS['log']->debug("In Campaigns Util, unsubscribe function about to run query: " . $curr_pl_qry);
$curr_pl_qry_result = $focus->db->query($curr_pl_qry);
//build the array with current user list information
$curr_pl_arr = array();
while ($row = $focus->db->fetchByAssoc($curr_pl_qry_result)) {
$curr_pl_arr[] = $row;
}
//check to see if user is already there in prospect list
$already_here = 'false';
foreach ($curr_pl_arr as $user_list) {
if (in_array($pl_arr['id'], $user_list)) {
$already_here = 'true';
}
}
if ($already_here == 'true') {
//do nothing, user is already exempted
} else {
//user is not exempted yet , so add to unsubscription list
$exempt_list = new ProspectList();
$exempt_result = $exempt_list->retrieve($pl_arr['id']);
if ($exempt_result == null) {
//error happened while retrieving this list
return;
}
$GLOBALS['log']->debug("In Campaigns Util, loading relationship: " . $relationship);
$exempt_list->load_relationship($relationship);
$exempt_list->{$relationship}->add($focus->id);
}
}