/** * Converts a fully fledged data bean into a basic * object for the Moodle DB layer * @param TxttoolsAccount $txttoolsAccount Account to convert * @param object $existingRecord Existing DB record * @return object Converted object * @version 2015062901 * @since 2011042601 */ private function convertBeanToStandardClass(TxttoolsAccount $txttoolsAccount, $existingRecord = null) { if ($existingRecord == null) { $existingRecord = new object(); } // Map fields in $existingRecord->username = $txttoolsAccount->getUsername(); $existingRecord->password = $txttoolsAccount->getEncryptedPassword(); $existingRecord->description = $txttoolsAccount->getDescription(); $existingRecord->defaultuser = $txttoolsAccount->getDefaultUser()->getId(); $existingRecord->creditsused = $txttoolsAccount->getCreditsUsed(); $existingRecord->creditsremaining = $txttoolsAccount->getCreditsRemaining(); $existingRecord->outboundenabled = $txttoolsAccount->isOutboundEnabled() ? 1 : 0; $existingRecord->inboundenabled = $txttoolsAccount->isInboundEnabled() ? 1 : 0; $existingRecord->accounttype = $txttoolsAccount->getBillingType(); $existingRecord->lastupdate = $txttoolsAccount->getLastUpdate(); $existingRecord->url = $txttoolsAccount->getUrl(); $existingRecord->location = $txttoolsAccount->getLocation(); return $existingRecord; }