/** * Converts a filter bean to a standard object for insertion * @param MoodletxtInboundFilter $filter Filter to convert * @return object Base-level object for insertion * @version 2012042301 * @since 2001071301 */ private function convertBeanToStandardClass(MoodletxtInboundFilter $filter) { $standardObject = new object(); $standardObject->account = $filter->getAccountId(); $standardObject->type = $filter->getFilterType(); $standardObject->value = (string) $filter->getOperand(); if ($filter->getId() > 0) { $standardObject->id = $filter->getId(); } return $standardObject; }
/** * Build JSON response structure for a filter * @param MoodletxtInboundFilter $filter Filter to build from * @return string Constructed JSON * @version 2012042301 * @since 2011071101 */ private function buildResponse(MoodletxtInboundFilter $filter) { // Copy template down $response = $this->responseTemplate; $response['filterId'] = $filter->getId(); $response['accountId'] = $filter->getAccountId(); $response['type'] = $filter->getFilterType(); $response['operand'] = $filter->getOperand(); foreach ($filter->getDestinationUsers() as $biteSizedUser) { $response['users'][$biteSizedUser->getId()] = array('userId' => $biteSizedUser->getId(), 'firstName' => $biteSizedUser->getFirstName(), 'lastName' => $biteSizedUser->getLastName(), 'username' => $biteSizedUser->getUsername()); } return json_encode($response); }