Edit file File name : GoogleClass.php Content :<?PHP require_once("googlecontacts/GoogleContacts.php") ; require_once("googlecontacts/ContactsClass.php") ; if (file_exists("googlecontacts/GoogleContactsPro.php")){ require_once("googlecontacts/GoogleContactsPro.php") ; class GooCtsExt extends GoogleContactsPro{ } }else{ class GooCtsExt extends GoogleContactsGC{ } } class GooCts extends GooCtsExt{ var $users_array=array(); var $users_contacts=array(); function get_users_array($only_user=false){ global $current_user; if ($only_user==true){ if ($_SESSION['authenticated_user_id']==""){ echo "<br>Login error"; exit; }else{ $cu = $_SESSION['authenticated_user_id']; $sql_user=" 1 and users.id='$cu' "; if ($crdatefilt!=''){ } } } $query= $sql_user; $td = new TimeDate(); require_once("modules/Users/User.php"); $seed = new User(); $response = $seed->get_list($order_by,$query , $offset,10000,10000,false); // print_r($response); for ($tn1=0;$tn1<(count($response['list']));$tn1++){ $a = $response['list'][$tn1]; debugg("<br>".$a->name." ".$a->google_mmail_cts_c." ".$a->google_mpass_cts_c." ".$a->google_mctsreceive_c); $user_data[0] = $a->google_mmail_cts_contacts_c; $user_data[1]=$a->google_mpass_cts_contacts_c; $current_user=new User(); $current_user->retrieve($a->id); // if ($a->google_mmail_cts_contacts_c!="" and $a->google_mpass_cts_contacts_c!=""){ if ($current_user->google_mmail_cts_contacts_c!="" and $current_user->google_mpass_cts_contacts_c!=""){ //$return_array[$a->id]=array("username"=>$a->google_mmail_cts_contacts_c,"password"=>$a->google_mpass_cts_contacts_c); $return_array[$a->id]=array("username"=>$current_user->google_mmail_cts_contacts_c,"password"=>$current_user->google_mpass_cts_contacts_c); } //$user_google_mafterdate_c=$td->swap_formats($a->google_mctsafterdater_c, $td->get_date_format(true, $current_user), "Y-m-d"); } //print_r($return_array); $this->users_array=$return_array; } //get_users_array function get_tokens(){ foreach ($this->users_array as $k=>$v){ $token= $this->getAuthCode($v['username'],$v['password']); $this->users_array[$k]['token']=$token; } } function get_contacts(){ global $current_user,$db; foreach ($this->users_array as $k=>$v){ $current_user=new User(); $current_user->retrieve($k); if ($current_user->google_mcts_sync_type_c!="no_sync"){ // echo "\n<br> user ".$current_user->id." <br>\n"; $ct=new ContactsClass(); if ($current_user->google_mcts_sync_type_c=="sync_user"){ $where_extra=" contacts.assigned_user_id='".$current_user->id."'"; }else{ $where_extra=""; } // echo "<br>\n we ".$where_extra; //ss $ct_list=$ct->get_list("",$where_extra,"",10000,10000,false); // echo "aa23"; // echo "\n<br>list ".print_r($ct_list); // exit; foreach ($ct_list['list'] as $k1=>$v1){ //dmc 021211 off for memory performance // $cc1=new Contact(); // $cc1->retrieve($v1->id); //dmc 021211 off for memory performance $cc1= $ct_list['list'][$k1]; $sq = "select contacts.date_modified,google_contacts_rel.last_google_contacts_upload_c from contacts left join google_contacts_rel on contacts.id=google_contacts_rel.obj_id and google_contacts_rel.user_id='".$current_user->id."' where contacts.id='".$cc1->id."' and contacts.deleted=0 "; // echo "<br>".$sq; $result=$db->query($sq); $row=$db->fetchByAssoc($result); if ($row['last_google_contacts_upload_c']!=$row['date_modified']){ $this->users_array[$k]['contacts'][]=$cc1; } } } } } function get_old_data($id){ global $current_user,$db; $sq="select * from google_contacts_rel where user_id='".$current_user->id."' and obj_id='".$id."'"; $r=$db->query($sq); $row=$db->fetchByAssoc($r); return $row; } function get_deleted_contacts(){ global $db,$current_user; $ct=new ContactsClass(); $ct_list=$ct->get_list("","","",10000,10000,true); // print_r($ct_list); // exit; foreach ($this->users_array as $k=>$v){ $inlist=""; $current_user=new User(); $current_user->retrieve($k); // echo $current_user->google_mcts_sync_type_c; // exit; if ($current_user->google_mcts_sync_type_c!="no_sync"){ $sq = "select contacts.*,google_contacts_rel.old_link_edit_c,google_contacts_rel.old_id_c from contacts left join google_contacts_rel on contacts.id=google_contacts_rel.obj_id where contacts.deleted=1 and (deleted_sent=0 or deleted_sent is null) and google_contacts_rel.user_id='".$current_user->id."'"; // echo "<br>".$sq; $r=$db->query($sq); while ($row=$db->fetchByAssoc($r)){ $this->users_array[$k]['delete_contacts'][]=$row; // print_r($this->users_array[$k]['delete_contacts']); } } } } function send_contacts(){ global $current_user,$max_number_upload; $i=0; foreach ($this->users_array as $k=>$v){ $current_user=new User(); $current_user->retrieve($k); if (is_array($v['contacts'])){ foreach ($v['contacts'] as $k1=>$v1){ // echo "<br>Sync finished".$v1; $bean=$v1; $this->insert_cnt_onl($bean,$v); if ($i>$max_number_upload){ echo "<br>Max number of ".$max_number_upload." records reached."; die; } $i++; } } } } function delete_contacts(){ global $current_user; if (is_array($this->users_array)){ // print_r($this->users_array); foreach ($this->users_array as $k=>$v){ $current_user=new User(); $current_user->retrieve($k); // echo "<br>c user ".$current_user->id; // exit; // print_r($v['delete_contacts'] ); // exit; if (is_array($v['delete_contacts'])){ foreach ($v['delete_contacts'] as $k1=>$v1){ // print_r($v1); // exit; $bean=$v1; $this->delete_contact_onl($bean,$v); } } } } } } ?>Save