/** * Method to save the form data. * * @param array $data The form data. * * @return mixed The record id on success, null on failure. * @since 1.6 */ public function save($data) { $userId = Joomla\Utilities\ArrayHelper::getValue($data, 'user_id', 0, 'int'); $phone = JString::trim(Joomla\Utilities\ArrayHelper::getValue($data, 'phone')); $address = JString::trim(Joomla\Utilities\ArrayHelper::getValue($data, 'address')); $website = JString::trim(Joomla\Utilities\ArrayHelper::getValue($data, 'website')); $countryId = Joomla\Utilities\ArrayHelper::getValue($data, 'country_id', 0, 'int'); $locationId = Joomla\Utilities\ArrayHelper::getValue($data, 'location_id', 0, 'int'); $secretKey = JFactory::getApplication()->get('secret'); $db = $this->getDbo(); $phone = !$phone ? 'NULL' : $db->quote(Defuse\Crypto\Crypto::encrypt($phone, $secretKey)); $address = !$address ? 'NULL' : $db->quote(Defuse\Crypto\Crypto::encrypt($address, $secretKey)); $website = !$website ? 'NULL' : $db->quote($website); $query = $db->getQuery(true); $query->update($db->quoteName('#__itpsc_profiles'))->set($db->quoteName('location_id') . '=' . (int) $locationId)->set($db->quoteName('country_id') . '=' . (int) $countryId)->set($db->quoteName('website') . '=' . $website)->set($db->quoteName('phone') . ' = ' . $phone)->set($db->quoteName('address') . ' = ' . $address)->where($db->quoteName('user_id') . ' = ' . (int) $userId); $db->setQuery($query); $db->execute(); return $db->insertid(); }
/** * Prepare and sanitise the table prior to saving. * * @param SocialCommunityTableProfile $table * @param array $data * * @since 1.6 */ protected function prepareContact($table, $data) { $secretKey = JFactory::getApplication()->get('secret'); if (!$data['phone']) { $data['phone'] = null; } else { $data['phone'] = Defuse\Crypto\Crypto::encrypt($data['phone'], $secretKey); } if (!$data['address']) { $data['address'] = null; } else { $data['address'] = Defuse\Crypto\Crypto::encrypt($data['address'], $secretKey); } if (!$data['website']) { $data['website'] = null; } $table->set('phone', $data['phone']); $table->set('address', $data['address']); $table->set('country_id', (int) $data['country_id']); $table->set('location_id', (int) $data['location_id']); $table->set('website', $data['website']); }