/** * 更新用户信息 * * @access public * @param int $userId * @param array $updateInfo */ public function update($userId, $updateInfo) { unset($updateInfo['add']); unset($updateInfo['update']); unset($updateInfo['addParam']); unset($updateInfo['updateParam']); $nickname = $updateInfo['username']; $phoneNum = $updateInfo['phoneNum']; unset($updateInfo['username']); unset($updateInfo['phoneNum']); $updateInfoTmp = array(); foreach ($updateInfo as $key => $value) { $updateInfoTmp[$key] = array($key => $this->tagModel->getUserProfileName($key), 'value' => $value); } F::db()->execute('update account set phone_num = ? where user_id = ?', array($phoneNum, $userId)); F::db()->execute('update user_profile set nickname = ?, user_profile = ?, update_time = ? where user_id = ?', array($nickname, serialize($updateInfoTmp), date('Y-m-d H:i:s'), $userId)); }
/** * 更新联系人信息 * * @access public * @return void */ public function update() { $this->checkAccessToken(); $this->params = $this->require_params(array('id')); $userId = $this->params['id']; unset($this->params['id']); unset($this->params['accessToken']); unset($this->params['r']); $this->returnData = $this->contactModel->getContactProfile($userId); unset($this->returnData['id']); unset($this->returnData['tagList']); unset($this->returnData['acctionList']); $requestTagArray = array(); foreach ($this->params as $key => $value) { if ($key == 'username' && $value != $this->returnData['username']) { if ($this->returnData['username']) { $this->params['update'] = 1; $this->params['updateParam'][] = array('姓名', $value); } else { $this->params['add'] = 1; $this->params['addParam'][] = array('姓名', $value); } } if ($key == 'phoneNum' && $value != $this->returnData['phoneNum']) { if ($this->returnData['username']) { $this->params['update'] = 1; $this->params['updateParam'][] = array('手机号', $value); } else { $this->params['add'] = 1; $this->params['addParam'][] = array('手机号', $value); } } if ($key != 'username' && $key != 'phoneNum') { $requestTagArray[] = $this->tagModel->getUserProfileName($key); } if (!isset($this->returnData['userProfile'][$key]) && $key != 'username' && $key != 'phoneNum') { $this->params['add'] = 1; $this->params['addParam'][] = array($this->tagModel->getUserProfileName($key), $value); } if (isset($this->returnData['userProfile'][$key]['value']) && $value != $this->returnData['userProfile'][$key]['value']) { $this->params['update'] = 1; $this->params['updateParam'][] = array($this->returnData['userProfile'][$key][$key], $value); } } $this->params['add'] = $this->params['add'] ? $this->params['add'] : 0; $this->params['update'] = $this->params['update'] ? $this->params['update'] : 0; $this->contactModel->update($userId, $this->params); if ($this->params['add']) { $addEventContent = '新增信息'; foreach ($this->params['addParam'] as $addIndex) { $addEventContent .= ' ' . '#' . $addIndex[0] . ' ' . $addIndex[1]; } } if ($this->params['update']) { $updateEventContent = '更新信息'; foreach ($this->params['updateParam'] as $updateIndex) { $updateEventContent .= ' ' . '#' . $updateIndex[0] . ' ' . $updateIndex[1]; } } $this->userModel->createEvent($GLOBALS['userId'], $userId, $addEventContent . ' ' . $updateEventContent, '', self::SYSTEM_EVENT); foreach ($requestTagArray as $value) { $this->userModel->bindTag($userId, $value); } $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params)); F::rest()->show_result(); }