/** * Allows a user to update his/her user details * * @param array $params Is expected to have the following parameters: * `array('channelset'=>'name of channelset','details'=>array('k'=>'v pairs'))` * @see InstructionControl_Utils_Controller::restGetChannelsetUserCommunicationkey() * for details about the output document */ public function restPutChannelsetUserMe($params) { $channelsetId = $this->getChannelSetId($params['channelset']); $userRec = $this->getUser($channelsetId); InstructionControl::setUserDetails($userRec['login_key'], $params['details']); $userProperties = InstructionControl::getUser($userRec['login_key']); $communicationKey = $userProperties['communication_key']; $userProperties = array_diff_key($userProperties, $this->getProtectedUserPropertyKeys()); $return = InstructionControl::generateReturnDocument('USER_DETAILS', array(), array(), array(), array(), array('communication_key' => $communicationKey, 'details' => $userProperties)); header('HTTP/1.1 202 Accepted'); echo json_encode($return); if (INSTRUCTIONCONTROL__NOTIFY_OTHER_CLIENTS == 'APE') { InstructionControl::notifyOtherClientsApe($params['channelset'], null, $return); } 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); }