/** * Gets details of one specific user. * * Body of output document takes the form: * * <code> * {"communication_key":"jd3432jssdfi","details":{"known_as":"Fred Basset",...}} * </code> * * @param array $params Should take the form: * `array('channelset'=>'name of channelset','communication_key'=>'of the user')` */ public function restGetChannelsetUserCommunicationkey($params) { $channelsetId = $this->getChannelSetId($params['channelset']); $userProperties = array_diff_key(InstructionControl::getUserByCommunicationKey($channelsetId, $params['communication_key']), $this->getProtectedUserPropertyKeys()); if ($userProperties === null) { throw new Exception('Could not find user'); } header('HTTP/1.1 200 OK'); echo json_encode(InstructionControl::generateReturnDocument('USER_DETAILS', array(), array(), array(), array(), array('communication_key' => $params['communication_key'], 'details' => $userProperties))); return true; }
public function testGetUserByCommunicationKey() { $csid = InstructionControl::getChannelSetId(genSaneGuid()); $u = InstructionControl::getUser(null, $n); $u = InstructionControl::getUser($u['login_key'], $n); InstructionControl::setUserChannelset($u['id'], $csid); $v = InstructionControl::getUserByCommunicationKey($csid, $u['communication_key']); $this->assertEquals($u, $v); $w = InstructionControl::getUserByCommunicationKey($csid, genSaneGuid()); $this->assertNull($w); }