public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new Application_Model_Usermeta(); } return self::$_instance; }
public function userProfileAction() { $users = Application_Model_Users::getInstance(); $usermeta = Application_Model_Usermeta::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'userprofileinfo': if ($this->getRequest()->isPost()) { $firstname = $this->getRequest()->getPost('firstname'); if (!empty($firstname)) { $data['first_name'] = $firstname; } $lastname = $this->getRequest()->getPost('lastname'); if (!empty($firstname)) { $data['last_name'] = $lastname; } $phone = $this->getRequest()->getPost('phone'); if (!empty($phone)) { $data['phone'] = $phone; } $city = $this->getRequest()->getPost('city'); if (!empty($city)) { $data['city'] = $city; } $state = $this->getRequest()->getPost('state'); if (!empty($state)) { $data['state'] = $state; } $country = $this->getRequest()->getPost('country'); if (!empty($country)) { $data['country'] = $country; } $contactcountrycode = $this->getRequest()->getPost('contactcountrycode'); if (!empty($contactcountrycode)) { $data['contact_country_code'] = $contactcountrycode; } $userid = $this->getRequest()->getPost('userid'); if (!empty($userid)) { $data['user_id'] = $userid; } $userinfodata = $users->checkUserData($userid); if ($userinfodata == 'update') { if (!empty($userid)) { $usermetaid = $usermeta->updateUserMeta($userid, $data); if ($usermetaid) { $response->message = 'Successfully updated'; $response->code = 200; } else { $response->message = 'Could not Serve the Request'; $response->code = 197; } } else { $response->message = 'Invalid Request'; $response->code = 401; } } else { if ($userinfodata == 'insert') { $userinfo = $usermeta->insertUserMetainfo($data); if ($userinfo) { $response->message = 'Successfully inserted'; $response->code = 200; $response->data = $userinfo; } else { $response->message = 'Could not Serve the Request'; $response->code = 197; } } else { $response->message = $userinfodata; $response->code = 401; } } } else { $response->message = 'Invalid Request'; $response->code = 401; } echo json_encode($response, true); die; break; case 'getuserprofileinfo': if ($this->getRequest()->isPost()) { $userid = $this->getRequest()->getPost('userid'); if (!empty($userid)) { $usermetaid = $usermeta->fetchUserMeta($userid); if ($usermetaid) { $response->message = 'Successfull'; $response->code = 200; $response->data = $usermetaid; } else { $response->message = 'Could not Serve the Request'; $response->code = 197; } } else { $response->message = 'Invalid Request'; $response->code = 401; } } else { $response->message = 'Invalid Request'; $response->code = 401; } echo json_encode($response, true); die; break; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = 'No Method'; echo json_encode($response, true); die; } }