/** * Load affiliate detail for affiliate manager * * @service affiliate read * @param $fields */ public function affiliateDetails(Gpf_Rpc_Params $params) { $data = new Gpf_Rpc_Data($params); $search = $data->getFilters()->getFilter("id"); if (sizeof($search) == 1) { $id = $search[0]->getValue(); } $user = new Pap_Affiliates_User(); $user->setId($id); try { $user->load(); } catch (Gpf_DbEngine_NoRowException $e) { return $data; } $data->setValue("id", $user->getId()); $data->setValue("name", $user->getFirstName()." ".$user->getLastName()); $data->setValue("username", $user->getUserName()); $formFields = $this->getUserFormFields(); foreach($formFields as $record) { $code = $record->get('code'); $data->setValue($code, $user->get($code)); } return $data; }
private function fillFromUser(Gpf_Rpc_Form $form, Pap_Affiliates_User $user) { $userData = new Gpf_Data_RecordSet(); $userData->setHeader(array('userid', 'username','firstname', 'lastname')); $data = $userData->createRecord(); $data->add('userid', $user->getId()); $data->add('username', $user->getUserName()); $data->add('firstname', $user->getFirstName()); $data->add('lastname', $user->getLastName()); $userData->add($data); $form->setField('userid', null, $userData->toObject()); }