remove fanpage
function removefanpageAction(){
$ajax = getgpc('ajax','GPC', 0);
if($this->code > 0){
$get_fanpage = $this->social_model->getFanpageBYIDrow($this->code);
if($get_fanpage->num_rows > 0){
$thisFanpage = $get_fanpage->row;
if($thisFanpage['type'] == 'fanpage') {
//remove menu
$r1 = $this->facebook_model->call_Setting_menu_page(array('token' => $thisFanpage['FanpageToken']), false, array());
//remove button start
$r2 = $this->facebook_model->call_Start_button(array('token' => $thisFanpage['FanpageToken']), false);
//unsubcription
$r3 = $this->facebook_model->unsubcription_fanpage(array('token' => $thisFanpage['FanpageToken'], 'fanpage_id' => $thisFanpage['FanPageID']));
}
$sql = "DELETE FROM rd_social_facebook WHERE SocialID=". (int) $this->code;
query($sql);
//get project
$getProject = $this->project_model->getProjectByToken($thisFanpage['project']);
if($getProject->num_rows > 0){
$thisProject = $getProject->row;
$project_id = $thisProject['projectid'];
$sql_2 = "DELETE FROM rd_user_fanpage WHERE fanpage_id='". $thisFanpage['FanPageID'] ."' AND project_id=". (int) $project_id;
query($sql_2);
}
}
$resultCronjob = $this->RemoveCronjob_getAccessToken($thisFanpage['FanPageID']);
}
if($ajax == 1){
respon_json(array(
'status' => 1,
'msg' => 'Xóa Fanpage thành công!',
'cronjob' => $resultCronjob,
));
} else {
redirect(0);
}
}