params->get('category', 0); if (empty($category)) { JError::raiseWarning(41, JText::_('PLG_CONTACTCREATOR_ERR_NO_CATEGORY')); return false; // bail out if we don't have a category } $db = JFactory::getDbo(); // grab the contact ID for this user; note $user_id is cleaned above $db->setQuery('SELECT id FROM #__contact_details WHERE user_id = '. $user_id); $id = $db->loadResult(); JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_contact/tables'); $contact = JTable::getInstance('contact', 'ContactTable'); if (!$contact) { return false; } if ($id) { $contact->load($id); } elseif ($this->params->get('autopublish', 0)) { $contact->published = 1; } $contact->name = $user['name']; $contact->user_id = $user_id; $contact->email_to = $user['email']; $contact->catid = $category; $contact->language = '*'; $autowebpage = $this->params->get('autowebpage', ''); if (!empty($autowebpage)) { // search terms $search_array = array('[name]', '[username]', '[userid]', '[email]'); // replacement terms, urlencoded $replace_array = array_map('urlencode', array($user['name'], $user['username'], $user['id'], $user['email'])); // now replace it in together $contact->webpage = str_replace($search_array, $replace_array, $autowebpage); } if ($contact->check()) { $result = $contact->store(); } if (!(isset($result)) || !$result) { JError::raiseError(42, JText::sprintf('PLG_CONTACTCREATOR_ERR_FAILED_UPDATE', $contact->getError())); } } }