function translateJSON($itm) { $controllerAgent = new ControllerAgent(); $agent = $controllerAgent->getAgentByUserId($itm->user_id); $agentJSON = "\"agent_info\" : null"; if ($agent != null) { $agentJSON = "\n \"agent_info\" : {\n \"address\" : \"{$agent->address}\",\n \"agent_id\" : \"{$agent->agent_id}\",\n \"contact_no\" : \"{$agent->contact_no}\",\n \"country\" : \"{$agent->country}\",\n \"created_at\" : \"{$agent->created_at}\",\n \"email\" : \"{$agent->email}\",\n \"name\" : \"{$agent->name}\",\n \"sms\" : \"{$agent->sms}\",\n \"updated_at\" : \"{$agent->updated_at}\",\n \"zipcode\" : \"{$agent->zipcode}\",\n \"photo_url\" : \"{$agent->photo_url}\",\n \"thumb_url\" : \"{$agent->thumb_url}\",\n \"twitter\" : \"{$agent->twitter}\",\n \"fb\" : \"{$agent->fb}\",\n \"linkedin\" : \"{$agent->linkedin}\",\n \"company\" : \"{$agent->company}\",\n \"user_id\" : \"{$itm->user_id}\"\n }\n "; } $json = "{\n \"user_info\" : {\n \"user_id\" : \"{$itm->user_id}\",\n \"username\" : \"{$itm->username}\",\n \"login_hash\" : \"{$itm->login_hash}\",\n \"facebook_id\" : \"{$itm->facebook_id}\",\n \"twitter_id\" : \"{$itm->twitter_id}\",\n \"full_name\" : \"{$itm->full_name}\",\n \"email\" : \"{$itm->email}\",\n },\n {$agentJSON},\n\n \"status\" : {\n \"status_code\" : \"-1\",\n \"status_text\" : \"Success.\"\n }\n }"; return $json; }
$linkedin = trim(strip_tags($_POST['linkedin'])); } $company = ""; if (!empty($_POST['company'])) { $company = trim(strip_tags($_POST['company'])); } $created_at = time(); $updated_at = time(); $photo_url = ""; $thumb_url = ""; if (!empty($name) && !empty($contact_no) && !empty($email) && !empty($sms) && !empty($address) && !empty($login_hash) && !empty($user_id)) { $user = $controllerUser->getUserByUserId($user_id); $login_hash = str_replace(" ", "+", $login_hash); if ($user != null) { if ($user->login_hash == $login_hash) { $agent = $controllerRestAgent->getAgentByUserId($user_id); $itm = new Agent(); $itm->address = $address; $itm->contact_no = $contact_no; $itm->country = $country; $itm->created_at = $created_at; $itm->email = $email; $itm->name = $name; $itm->sms = $sms; $itm->updated_at = $updated_at; $itm->zipcode = $zipcode; $itm->photo_url = $photo_url; $itm->thumb_url = $thumb_url; $itm->twitter = $twitter; $itm->fb = $fb; $itm->linkedin = $linkedin;