| Current Path : /proc/1908984/root/proc/1908984/root/home/digilove/www/41423/ |
| Current File : //proc/1908984/root/proc/1908984/root/home/digilove/www/41423/contact.php.tar |
home/digilove/public_html/components/com_contact/contact.php 0000644 00000001536 15232601366 0020433 0 ustar 00 <?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ContactHelperRoute', JPATH_COMPONENT . '/helpers/route.php');
$input = JFactory::getApplication()->input;
if ($input->get('view') === 'contacts' && $input->get('layout') === 'modal')
{
if (!JFactory::getUser()->authorise('core.create', 'com_contact'))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');
return;
}
JFactory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
}
$controller = JControllerLegacy::getInstance('Contact');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
home/digilove/public_html/plugins/editors-xtd/contact/contact.php 0000644 00000002622 15234621730 0021333 0 ustar 00 <?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.contact
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Contact button
*
* @since 3.7.0
*/
class PlgButtonContact extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.7.0
*/
protected $autoloadLanguage = true;
/**
* Display the button
*
* @param string $name The name of the button to add
*
* @return JObject The button options as JObject
*
* @since 3.7.0
*/
public function onDisplay($name)
{
$user = JFactory::getUser();
if ($user->authorise('core.create', 'com_contact')
|| $user->authorise('core.edit', 'com_contact')
|| $user->authorise('core.edit.own', 'com_contact'))
{
// The URL for the contacts list
$link = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1&editor=' . $name;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORS-XTD_CONTACT_BUTTON_CONTACT');
$button->name = 'address';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
return $button;
}
}
}
home/digilove/public_html/administrator/components/com_contact/contact.php 0000644 00000001126 15235562411 0023306 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_contact'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$controller = JControllerLegacy::getInstance('contact');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
home/digilove/public_html/110/plugins/content/contact/contact.php 0000644 00000006370 15235601211 0021035 0 ustar 00 <?php
/**
* @package Joomla.Plugin
* @subpackage Content.Contact
*
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Contact Plugin
*
* @since 3.2
*/
class PlgContentContact extends JPlugin
{
/**
* Database object
*
* @var JDatabaseDriver
* @since 3.3
*/
protected $db;
/**
* Plugin that retrieves contact information for contact
*
* @param string $context The context of the content being passed to the plugin.
* @param mixed &$row An object with a "text" property
* @param mixed $params Additional parameters. See {@see PlgContentContent()}.
* @param integer $page Optional page number. Unused. Defaults to zero.
*
* @return boolean True on success.
*/
public function onContentPrepare($context, &$row, $params, $page = 0)
{
$allowed_contexts = array('com_content.category', 'com_content.article', 'com_content.featured');
if (!in_array($context, $allowed_contexts))
{
return true;
}
// Return if we don't have valid params or don't link the author
if (!($params instanceof Registry) || !$params->get('link_author'))
{
return true;
}
// Return if an alias is used
if ((int) $this->params->get('link_to_alias', 0) === 0 && $row->created_by_alias != '')
{
return true;
}
// Return if we don't have a valid article id
if (!isset($row->id) || !(int) $row->id)
{
return true;
}
$contact = $this->getContactData($row->created_by);
$row->contactid = $contact->contactid;
$row->webpage = $contact->webpage;
$row->email = $contact->email_to;
$url = $this->params->get('url', 'url');
if ($row->contactid && $url === 'url')
{
JLoader::register('ContactHelperRoute', JPATH_SITE . '/components/com_contact/helpers/route.php');
$row->contact_link = JRoute::_(ContactHelperRoute::getContactRoute($contact->contactid . ':' . $contact->alias, $contact->catid));
}
elseif ($row->webpage && $url === 'webpage')
{
$row->contact_link = $row->webpage;
}
elseif ($row->email && $url === 'email')
{
$row->contact_link = 'mailto:' . $row->email;
}
else
{
$row->contact_link = '';
}
return true;
}
/**
* Retrieve Contact
*
* @param int $userId Id of the user who created the article
*
* @return mixed|null|integer
*/
protected function getContactData($userId)
{
static $contacts = array();
if (isset($contacts[$userId]))
{
return $contacts[$userId];
}
$query = $this->db->getQuery(true);
$query->select('MAX(contact.id) AS contactid, contact.alias, contact.catid, contact.webpage, contact.email_to');
$query->from($this->db->quoteName('#__contact_details', 'contact'));
$query->where('contact.published = 1');
$query->where('contact.user_id = ' . (int) $userId);
if (JLanguageMultilang::isEnabled() === true)
{
$query->where('(contact.language in '
. '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') '
. ' OR contact.language IS NULL)');
}
$this->db->setQuery($query);
$contacts[$userId] = $this->db->loadObject();
return $contacts[$userId];
}
}
home/digilove/public_html/administrator/components/com_contact/controllers/contact.php 0000644 00000005243 15235773067 0025673 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Controller for a single contact
*
* @since 1.6
*/
class ContactControllerContact extends JControllerForm
{
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = array())
{
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
}
if ($allow === null)
{
// In the absence of better information, revert to the component permissions.
return parent::allowAdd($data);
}
return $allow;
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Since there is no asset tracking, fallback to the component permissions.
if (!$recordId)
{
return parent::allowEdit($data, $key);
}
// Get the item.
$item = $this->getModel()->getItem($recordId);
// Since there is no item, return false.
if (empty($item))
{
return false;
}
$user = JFactory::getUser();
// Check if can edit own core.edit.own.
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
// Check the category core.edit permissions.
return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid);
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 2.5
*/
public function batch($model = null)
{
$this->checkToken();
// Set the model
/** @var ContactModelContact $model */
$model = $this->getModel('Contact', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contacts' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
}
home/digilove/public_html/administrator/components/com_contact/models/contact.php 0000644 00000032716 15235773153 0024611 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContactHelper', JPATH_ADMINISTRATOR . '/components/com_contact/helpers/contact.php');
/**
* Item Model for a Contact.
*
* @since 1.6
*/
class ContactModelContact extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_contact.contact';
/**
* The context used for the associations table
*
* @var string
* @since 3.4.4
*/
protected $associationsContext = 'com_contact.item';
/**
* Batch copy/move command. If set to false, the batch copy/move command is not supported
*
* @var string
*/
protected $batch_copymove = 'category_id';
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage',
'tag' => 'batchTag',
'user_id' => 'batchUser',
);
/**
* Batch change a linked user.
*
* @param integer $value The new value matching a User ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 2.5
*/
protected function batchUser($value, $pks, $contexts)
{
foreach ($pks as $pk)
{
if ($this->user->authorise('core.edit', $contexts[$pk]))
{
$this->table->reset();
$this->table->load($pk);
$this->table->user_id = (int) $value;
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->published != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete', 'com_contact.category.' . (int) $record->catid);
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
// Check against the category.
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.edit.state', 'com_contact.category.' . (int) $record->catid);
}
// Default to component settings if category not known.
return parent::canEditState($record);
}
/**
* Returns a Table object, always creating it
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Contact', $prefix = 'ContactTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_users/models/fields');
// Get the form.
$form = $this->loadForm('com_contact.contact', 'contact', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('featured', 'disabled', 'true');
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('published', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('featured', 'filter', 'unset');
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('published', 'filter', 'unset');
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the metadata field to an array.
$registry = new Registry($item->metadata);
$item->metadata = $registry->toArray();
}
// Load associated contact items
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$item->associations = array();
if ($item->id != null)
{
$associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $item->id);
foreach ($associations as $tag => $association)
{
$item->associations[$tag] = $association->id;
}
}
}
// Load item tags
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_contact.contact');
}
return $item;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
$app = JFactory::getApplication();
// Check the session for previously entered form data.
$data = $app->getUserState('com_contact.edit.contact.data', array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('contact.id') == 0)
{
$data->set('catid', $app->input->get('catid', $app->getUserState('com_contact.contacts.filter.category_id'), 'int'));
}
}
$this->preprocessData('com_contact.contact', $data);
return $data;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.0
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
// Create new category, if needed.
$createCategory = true;
// If category ID is provided, check if it's valid.
if (is_numeric($data['catid']) && $data['catid'])
{
$createCategory = !CategoriesHelper::validateCategoryId($data['catid'], 'com_contact');
}
// Save New Category
if ($createCategory && $this->canCreateCategory())
{
$table = array();
// Remove #new# prefix, if exists.
$table['title'] = strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_contact';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
// Alter the name for save as copy
if ($input->get('task') == 'save2copy')
{
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['name'] == $origTable->name)
{
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
$data['name'] = $name;
$data['alias'] = $alias;
}
else
{
if ($data['alias'] == $origTable->alias)
{
$data['alias'] = '';
}
}
$data['published'] = 0;
}
$links = array('linka', 'linkb', 'linkc', 'linkd', 'linke');
foreach ($links as $link)
{
if ($data['params'][$link])
{
$data['params'][$link] = JStringPunycode::urlToPunycode($data['params'][$link]);
}
}
return parent::save($data);
}
/**
* Prepare and sanitise the table prior to saving.
*
* @param JTable $table The JTable object
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate()->toSql();
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
$table->generateAlias();
if (empty($table->id))
{
// Set the values
$table->created = $date;
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__contact_details'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
// Set the values
$table->modified = $date;
$table->modified_by = JFactory::getUser()->id;
}
// Increment the content version number.
$table->version++;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A record object.
*
* @return array An array of conditions to add to add to ordering queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array('catid = ' . (int) $table->catid);
}
/**
* Preprocess the form.
*
* @param JForm $form Form object.
* @param object $data Data object.
* @param string $group Group name.
*
* @return void
*
* @since 3.0.3
*/
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
// Determine correct permissions to check.
if ($this->getState('contact.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
if ($this->canCreateCategory())
{
$form->setFieldAttribute('catid', 'allowAdd', 'true');
// Add a prefix for categories created on the fly.
$form->setFieldAttribute('catid', 'customPrefix', '#new#');
}
// Association contact items
if (JLanguageAssociations::isEnabled())
{
$languages = JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc');
if (count($languages) > 1)
{
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
foreach ($languages as $language)
{
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_contact');
$field->addAttribute('language', $language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$field->addAttribute('propagate', 'true');
}
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
/**
* Method to toggle the featured setting of contacts.
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function featured($pks, $value = 0)
{
// Sanitize the ids.
$pks = ArrayHelper::toInteger((array) $pks);
if (empty($pks))
{
$this->setError(JText::_('COM_CONTACT_NO_ITEM_SELECTED'));
return false;
}
$table = $this->getTable();
try
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->update('#__contact_details');
$query->set('featured = ' . (int) $value);
$query->where('id IN (' . implode(',', $pks) . ')');
$db->setQuery($query);
$db->execute();
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
$table->reorder();
// Clean component's cache
$this->cleanCache();
return true;
}
/**
* Is the user allowed to create an on the fly category?
*
* @return boolean
*
* @since 3.6.1
*/
private function canCreateCategory()
{
return JFactory::getUser()->authorise('core.create', 'com_contact');
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.9.25
*/
public function validate($form, $data, $group = null)
{
// Don't allow to change the users if not allowed to access com_users.
if (!JFactory::getUser()->authorise('core.manage', 'com_users'))
{
if (isset($data['created_by']))
{
unset($data['created_by']);
}
}
return parent::validate($form, $data, $group);
}
}
home/digilove/public_html/administrator/components/com_contact/helpers/contact.php 0000644 00000007262 15235773236 0024770 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contact component helper.
*
* @since 1.6
*/
class ContactHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_CONTACT_SUBMENU_CONTACTS'),
'index.php?option=com_contact&view=contacts',
$vName == 'contacts'
);
JHtmlSidebar::addEntry(
JText::_('COM_CONTACT_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_contact',
$vName == 'categories'
);
if (JComponentHelper::isEnabled('com_fields') && JComponentHelper::getParams('com_contact')->get('custom_fields_enable', '1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_contact.contact',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_contact.contact',
$vName == 'fields.groups'
);
}
}
/**
* Adds Count Items for Category Manager.
*
* @param stdClass[] &$items The category objects
*
* @return stdClass[]
*
* @since 3.5
*/
public static function countItems(&$items)
{
$config = (object) array(
'related_tbl' => 'contact_details',
'state_col' => 'published',
'group_col' => 'catid',
'relation_type' => 'category_or_group',
);
return parent::countRelations($items, $config);
}
/**
* Adds Count Items for Tag Manager.
*
* @param stdClass[] &$items The tag objects
* @param string $extension The name of the active view.
*
* @return stdClass[]
*
* @since 3.6
*/
public static function countTagItems(&$items, $extension)
{
$parts = explode('.', $extension);
$section = count($parts) > 1 ? $parts[1] : null;
$config = (object) array(
'related_tbl' => ($section === 'category' ? 'categories' : 'contact_details'),
'state_col' => 'published',
'group_col' => 'tag_id',
'extension' => $extension,
'relation_type' => 'tag_assigments',
);
return parent::countRelations($items, $config);
}
/**
* Returns a valid section for contacts. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
* @param object $item optional item object
*
* @return string|null The new section
*
* @since 3.7.0
*/
public static function validateSection($section, $item)
{
if (JFactory::getApplication()->isClient('site') && $section == 'contact' && $item instanceof JForm)
{
// The contact form needs to be the mail section
$section = 'mail';
}
if (JFactory::getApplication()->isClient('site') && $section == 'category')
{
// The contact form needs to be the mail section
$section = 'contact';
}
if ($section != 'mail' && $section != 'contact')
{
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
$contexts = array(
'com_contact.contact' => JText::_('COM_CONTACT_FIELDS_CONTEXT_CONTACT'),
'com_contact.mail' => JText::_('COM_CONTACT_FIELDS_CONTEXT_MAIL'),
'com_contact.categories' => JText::_('JCATEGORY')
);
return $contexts;
}
}
home/digilove/public_html/components/com_contact/models/contact.php 0000644 00000045057 15241321327 0021720 0 ustar 00 <?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Single item model for a contact
*
* @package Joomla.Site
* @subpackage com_contact
* @since 1.5
*/
class ContactModelContact extends JModelForm
{
/**
* The name of the view for a single item
*
* @since 1.6
*/
protected $view_item = 'contact';
/**
* A loaded item
*
* @since 1.6
*/
protected $_item = null;
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_contact.contact';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication();
$this->setState('contact.id', $app->input->getInt('id'));
$this->setState('params', $app->getParams());
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact')))
{
$this->setState('filter.published', 1);
$this->setState('filter.archived', 2);
}
}
/**
* Method to get the contact form.
* The base form is loaded from XML and then an event is fired
*
* @param array $data An optional array of data for the form to interrogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_contact.contact', 'contact', array('control' => 'jform', 'load_data' => true));
if (empty($form))
{
return false;
}
$temp = clone $this->getState('params');
$contact = $this->_item[$this->getState('contact.id')];
$active = JFactory::getApplication()->getMenu()->getActive();
if ($active)
{
// If the current view is the active item and a contact view for this contact, then the menu item params take priority
if (strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id))
{
// $contact->params are the contact params, $temp are the menu item params
// Merge so that the menu item params take priority
$contact->params->merge($temp);
}
else
{
// Current view is not a single contact, so the contact params take priority here
// Merge the menu item params with the contact params so that the contact params take priority
$temp->merge($contact->params);
$contact->params = $temp;
}
}
else
{
// Merge so that contact params take priority
$temp->merge($contact->params);
$contact->params = $temp;
}
if (!$contact->params->get('show_email_copy', 0))
{
$form->removeField('contact_email_copy');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 1.6.2
*/
protected function loadFormData()
{
$data = (array) JFactory::getApplication()->getUserState('com_contact.contact.data', array());
if (empty($data['language']) && JLanguageMultilang::isEnabled())
{
$data['language'] = JFactory::getLanguage()->getTag();
}
// Add contact id to contact form data, so fields plugin can work properly
if (empty($data['catid']))
{
$data['catid'] = $this->getItem()->catid;
}
$this->preprocessData('com_contact.contact', $data);
return $data;
}
/**
* Gets a contact
*
* @param integer $pk Id for the contact
*
* @return mixed Object or null
*
* @since 1.6.0
*/
public function &getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('contact.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
try
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Changes for sqlsrv
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select($this->getState('item.select', 'a.*') . ',' . $case_when . ',' . $case_when1)
->from('#__contact_details AS a')
// Join on category table.
->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
->join('LEFT', '#__categories AS c on c.id = a.catid')
// Join over the categories to get parent category titles
->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id')
->where('a.id = ' . (int) $pk);
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
// Filter by published state.
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published))
{
$query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')')
->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
$db->setQuery($query);
$data = $db->loadObject();
if (empty($data))
{
JError::raiseError(404, JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'));
}
// Check for published state if filter set.
if ((is_numeric($published) || is_numeric($archived)) && (($data->published != $published) && ($data->published != $archived)))
{
JError::raiseError(404, JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'));
}
/**
* In case some entity params have been set to "use global", those are
* represented as an empty string and must be "overridden" by merging
* the component and / or menu params here.
*/
$registry = new Registry($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$registry = new Registry($data->metadata);
$data->metadata = $registry;
// Some contexts may not use tags data at all, so we allow callers to disable loading tag data
if ($this->getState('load_tags', true))
{
$data->tags = new JHelperTags;
$data->tags->getItemTags('com_contact.contact', $data->id);
}
// Compute access permissions.
if (($access = $this->getState('filter.access')))
{
// If the access filter has been set, we already know this user can view.
$data->params->set('access-view', true);
}
else
{
// If no access filter is set, the layout takes some responsibility for display of limited information.
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
if ($data->catid == 0 || $data->category_access === null)
{
$data->params->set('access-view', in_array($data->access, $groups));
}
else
{
$data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
}
}
$this->_item[$pk] = $data;
}
catch (Exception $e)
{
$this->setError($e);
$this->_item[$pk] = false;
}
}
if ($this->_item[$pk])
{
$this->buildContactExtendedData($this->_item[$pk]);
}
return $this->_item[$pk];
}
/**
* Load extended data (profile, articles) for a contact
*
* @param object $contact The contact object
*
* @return void
*/
protected function buildContactExtendedData($contact)
{
$db = $this->getDbo();
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$published = $this->getState('filter.published');
// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
if ($this->getState('params')->get('show_contact_list'))
{
$this->getState('params')->merge($contact->params);
}
// Get the com_content articles by the linked user
if ((int) $contact->user_id && $this->getState('params')->get('show_articles'))
{
$query = $db->getQuery(true)
->select('a.id')
->select('a.title')
->select('a.state')
->select('a.access')
->select('a.catid')
->select('a.created')
->select('a.language')
->select('a.publish_up');
// SQL Server changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select($case_when1 . ',' . $case_when)
->from('#__content as a')
->join('LEFT', '#__categories as c on a.catid=c.id')
->where('a.created_by = ' . (int) $contact->user_id)
->where('a.access IN (' . $groups . ')')
->order('a.publish_up DESC');
// Filter per language if plugin published
if (JLanguageMultilang::isEnabled())
{
$query->where('a.language IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
if (is_numeric($published))
{
$query->where('a.state IN (1,2)')
->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Number of articles to display from config/menu params
$articles_display_num = $this->getState('params')->get('articles_display_num', 10);
// Use contact setting?
if ($articles_display_num === 'use_contact')
{
$articles_display_num = $contact->params->get('articles_display_num', 10);
// Use global?
if ((string) $articles_display_num === '')
{
$articles_display_num = JComponentHelper::getParams('com_contact')->get('articles_display_num', 10);
}
}
$db->setQuery($query, 0, (int) $articles_display_num);
$articles = $db->loadObjectList();
$contact->articles = $articles;
}
else
{
$contact->articles = null;
}
// Get the profile information for the linked user
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
$userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
$data = $userModel->getItem((int) $contact->user_id);
JPluginHelper::importPlugin('user');
// Get the form.
JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms');
JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields');
JForm::addFormPath(JPATH_SITE . '/components/com_users/model/form');
JForm::addFieldPath(JPATH_SITE . '/components/com_users/model/field');
$form = JForm::getInstance('com_users.profile', 'profile');
// Get the dispatcher.
$dispatcher = JEventDispatcher::getInstance();
// Trigger the form preparation event.
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
// Load the data into the form after the plugins have operated.
$form->bind($data);
$contact->profile = $form;
}
/**
* Gets the query to load a contact item
*
* @param integer $pk The item to be loaded
*
* @return mixed The contact object on success, false on failure
*
* @throws Exception On database failure
* @deprecated 4.0 Use ContactModelContact::getItem() instead
*/
protected function getContactQuery($pk = null)
{
// @todo Cache on the fingerprint of the arguments
$db = $this->getDbo();
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
$user = JFactory::getUser();
$pk = (!empty($pk)) ? $pk : (int) $this->getState('contact.id');
$query = $db->getQuery(true);
if ($pk)
{
// Sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('cc.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('cc.id');
$case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select(
'a.*, cc.access as category_access, cc.title as category_name, '
. $case_when . ',' . $case_when1
)
->from('#__contact_details AS a')
->join('INNER', '#__categories AS cc on cc.id = a.catid')
->where('a.id = ' . (int) $pk);
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published IN (1,2)')
->where('cc.published IN (1,2)');
}
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
try
{
$db->setQuery($query);
$result = $db->loadObject();
if (empty($result))
{
return false;
}
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
if ($result)
{
$contactParams = new Registry($result->params);
// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
if ($this->getState('params')->get('show_contact_list'))
{
$this->getState('params')->merge($contactParams);
}
// Get the com_content articles by the linked user
if ((int) $result->user_id && $this->getState('params')->get('show_articles'))
{
$query = $db->getQuery(true)
->select('a.id')
->select('a.title')
->select('a.state')
->select('a.access')
->select('a.catid')
->select('a.created')
->select('a.language')
->select('a.publish_up');
// SQL Server changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select($case_when1 . ',' . $case_when)
->from('#__content as a')
->join('LEFT', '#__categories as c on a.catid=c.id')
->where('a.created_by = ' . (int) $result->user_id)
->where('a.access IN (' . $groups . ')')
->order('a.publish_up DESC');
// Filter per language if plugin published
if (JLanguageMultilang::isEnabled())
{
$query->where('a.language IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
if (is_numeric($published))
{
$query->where('a.state IN (1,2)')
->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Number of articles to display from config/menu params
$articles_display_num = $this->getState('params')->get('articles_display_num', 10);
// Use contact setting?
if ($articles_display_num === 'use_contact')
{
$articles_display_num = $contactParams->get('articles_display_num', 10);
// Use global?
if ((string) $articles_display_num === '')
{
$articles_display_num = JComponentHelper::getParams('com_contact')->get('articles_display_num', 10);
}
}
$db->setQuery($query, 0, (int) $articles_display_num);
$articles = $db->loadObjectList();
$result->articles = $articles;
}
else
{
$result->articles = null;
}
// Get the profile information for the linked user
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
$userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
$data = $userModel->getItem((int) $result->user_id);
JPluginHelper::importPlugin('user');
$form = new JForm('com_users.profile');
// Get the dispatcher.
$dispatcher = JEventDispatcher::getInstance();
// Trigger the form preparation event.
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
// Load the data into the form after the plugins have operated.
$form->bind($data);
$result->profile = $form;
$this->contact = $result;
return $result;
}
}
return false;
}
/**
* Increment the hit counter for the contact.
*
* @param integer $pk Optional primary key of the contact to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*
* @since 3.0
*/
public function hit($pk = 0)
{
$input = JFactory::getApplication()->input;
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('contact.id');
$table = JTable::getInstance('Contact', 'ContactTable');
$table->hit($pk);
}
return true;
}
}
home/digilove/public_html/components/com_contact/controllers/contact.php 0000644 00000016561 15242012434 0022776 0 ustar 00 <?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Controller for single contact view
*
* @since 1.5.19
*/
class ContactControllerContact extends JControllerForm
{
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JModelLegacy The model.
*
* @since 1.6.4
*/
public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, array('ignore_request' => false));
}
/**
* Method to submit the contact form and send an email.
*
* @return boolean True on success sending the email. False on failure.
*
* @since 1.5.19
*/
public function submit()
{
// Check for request forgeries.
$this->checkToken();
$app = JFactory::getApplication();
$model = $this->getModel('contact');
$stub = $this->input->getString('id');
$id = (int) $stub;
// Get the data from POST
$data = $this->input->post->get('jform', array(), 'array');
// Get item
$model->setState('filter.published', 1);
$contact = $model->getItem($id);
// Get item params, take menu parameters into account if necessary
$active = $app->getMenu()->getActive();
$stateParams = clone $model->getState()->get('params');
// If the current view is the active item and a contact view for this contact, then the menu item params take priority
if ($active && strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id))
{
// $item->params are the contact params, $temp are the menu item params
// Merge so that the menu item params take priority
$contact->params->merge($stateParams);
}
else
{
// Current view is not a single contact, so the contact params take priority here
$stateParams->merge($contact->params);
$contact->params = $stateParams;
}
// Check if the contact form is enabled
if (!$contact->params->get('show_email_form'))
{
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
return false;
}
// Check for a valid session cookie
if ($contact->params->get('validate_session', 0))
{
if (JFactory::getSession()->getState() !== 'active')
{
JError::raiseWarning(403, JText::_('JLIB_ENVIRONMENT_SESSION_INVALID'));
// Save the data in the session.
$app->setUserState('com_contact.contact.data', $data);
// Redirect back to the contact form.
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
return false;
}
}
// Contact plugins
JPluginHelper::importPlugin('contact');
$dispatcher = JEventDispatcher::getInstance();
// Validate the posted data.
$form = $model->getForm();
if (!$form)
{
JError::raiseError(500, $model->getError());
return false;
}
if (!$model->validate($form, $data))
{
$errors = $model->getErrors();
foreach ($errors as $error)
{
$errorMessage = $error;
if ($error instanceof Exception)
{
$errorMessage = $error->getMessage();
}
$app->enqueueMessage($errorMessage, 'error');
}
$app->setUserState('com_contact.contact.data', $data);
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
return false;
}
// Validation succeeded, continue with custom handlers
$results = $dispatcher->trigger('onValidateContact', array(&$contact, &$data));
foreach ($results as $result)
{
if ($result instanceof Exception)
{
return false;
}
}
// Passed Validation: Process the contact plugins to integrate with other applications
$dispatcher->trigger('onSubmitContact', array(&$contact, &$data));
// Send the email
$sent = false;
if (!$contact->params->get('custom_reply'))
{
$sent = $this->_sendEmail($data, $contact, $contact->params->get('show_email_copy', 0));
}
// Set the success message if it was a success
if (!($sent instanceof Exception))
{
$msg = JText::_('COM_CONTACT_EMAIL_THANKS');
}
else
{
$msg = '';
}
// Flush the data from the session
$app->setUserState('com_contact.contact.data', null);
// Redirect if it is set in the parameters, otherwise redirect back to where we came from
if ($contact->params->get('redirect'))
{
$this->setRedirect($contact->params->get('redirect'), $msg);
}
else
{
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false), $msg);
}
return true;
}
/**
* Method to get a model object, loading it if required.
*
* @param array $data The data to send in the email.
* @param stdClass $contact The user information to send the email to
* @param boolean $emailCopyToSender True to send a copy of the email to the user.
*
* @return boolean True on success sending the email, false on failure.
*
* @since 1.6.4
*/
private function _sendEmail($data, $contact, $emailCopyToSender)
{
$app = JFactory::getApplication();
if ($contact->email_to == '' && $contact->user_id != 0)
{
$contact_user = JUser::getInstance($contact->user_id);
$contact->email_to = $contact_user->get('email');
}
$mailfrom = $app->get('mailfrom');
$fromname = $app->get('fromname');
$sitename = $app->get('sitename');
$name = $data['contact_name'];
$email = JStringPunycode::emailToPunycode($data['contact_email']);
$subject = $data['contact_subject'];
$body = $data['contact_message'];
// Prepare email body
$prefix = JText::sprintf('COM_CONTACT_ENQUIRY_TEXT', JUri::base());
$body = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body);
// Load the custom fields
if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact, true, $data['com_fields']))
{
$output = FieldsHelper::render(
'com_contact.mail',
'fields.render',
array(
'context' => 'com_contact.mail',
'item' => $contact,
'fields' => $fields,
)
);
if ($output)
{
$body .= "\r\n\r\n" . $output;
}
}
$mail = JFactory::getMailer();
$mail->addRecipient($contact->email_to);
$mail->addReplyTo($email, $name);
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($sitename . ': ' . $subject);
$mail->setBody($body);
$sent = $mail->Send();
// If we are supposed to copy the sender, do so.
// Check whether email copy function activated
if ($emailCopyToSender == true && !empty($data['contact_email_copy']))
{
$copytext = JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename);
$copytext .= "\r\n\r\n" . $body;
$copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);
$mail = JFactory::getMailer();
$mail->addRecipient($email);
$mail->addReplyTo($email, $name);
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($copysubject);
$mail->setBody($copytext);
$sent = $mail->Send();
}
return $sent;
}
}
home/digilove/public_html/administrator/components/com_contact/models/fields/modal/contact.php 0000644 00000023366 15242025740 0027142 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\LanguageHelper;
/**
* Supports a modal contact picker.
*
* @since 1.6
*/
class JFormFieldModal_Contact extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Modal_Contact';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$allowNew = ((string) $this->element['new'] == 'true');
$allowEdit = ((string) $this->element['edit'] == 'true');
$allowClear = ((string) $this->element['clear'] != 'false');
$allowSelect = ((string) $this->element['select'] != 'false');
$allowPropagate = ((string) $this->element['propagate'] == 'true');
$languages = LanguageHelper::getContentLanguages(array(0, 1));
// Load language
JFactory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
// The active contact id field.
$value = (int) $this->value > 0 ? (int) $this->value : '';
// Create the modal id.
$modalId = 'Contact_' . $this->id;
// Add the modal field script to the document head.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
{
static $scriptSelect = null;
if (is_null($scriptSelect))
{
$scriptSelect = array();
}
if (!isset($scriptSelect[$this->id]))
{
JFactory::getDocument()->addScriptDeclaration("
function jSelectContact_" . $this->id . "(id, title, object) {
window.processModalSelect('Contact', '" . $this->id . "', id, title, '', object);
}
");
JText::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkContacts = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
$linkContact = 'index.php?option=com_contact&view=contact&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
$modalTitle = JText::_('COM_CONTACT_CHANGE_CONTACT');
if (isset($this->element['language']))
{
$linkContacts .= '&forcedLanguage=' . $this->element['language'];
$linkContact .= '&forcedLanguage=' . $this->element['language'];
$modalTitle .= ' — ' . $this->element['label'];
}
$urlSelect = $linkContacts . '&function=jSelectContact_' . $this->id;
$urlEdit = $linkContact . '&task=contact.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \'';
$urlNew = $linkContact . '&task=contact.add';
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('name'))
->from($db->quoteName('#__contact_details'))
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
}
$title = empty($title) ? JText::_('COM_CONTACT_SELECT_A_CONTACT') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current contact display field.
$html = '<span class="input-append">';
$html .= '<input class="input-medium" id="' . $this->id . '_name" type="text" value="' . $title . '" disabled="disabled" size="35" />';
// Select contact button
if ($allowSelect)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' data-target="#ModalSelect' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_CONTACT_CHANGE_CONTACT') . '">'
. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT')
. '</button>';
}
// New contact button
if ($allowNew)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' data-target="#ModalNew' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_CONTACT_NEW_CONTACT') . '">'
. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE')
. '</button>';
}
// Edit contact button
if ($allowEdit)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' data-target="#ModalEdit' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_CONTACT_EDIT_CONTACT') . '">'
. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT')
. '</button>';
}
// Clear contact button
if ($allowClear)
{
$html .= '<button'
. ' type="button"'
. ' class="btn' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR')
. '</button>';
}
// Propagate contact button
if ($allowPropagate && count($languages) > 2)
{
// Strip off language tag at the end
$tagLength = (int) strlen($this->element['language']);
$callbackFunctionStem = substr("jSelectContact_" . $this->id, 0, -$tagLength);
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_propagate"'
. ' href="#"'
. ' title="' . JHtml::tooltipText('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') . '"'
. ' onclick="Joomla.propagateAssociation(\'' . $this->id . '\', \'' . $callbackFunctionStem . '\');">'
. '<span class="icon-refresh" aria-hidden="true"></span>' . JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
. '</a>';
}
$html .= '</span>';
// Select contact modal
if ($allowSelect)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button" class="btn" data-dismiss="modal">' . JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
)
);
}
// New contact modal
if ($allowNew)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
'title' => JText::_('COM_CONTACT_NEW_CONTACT'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button" class="btn"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\', \'contact\', \'cancel\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
. '<button type="button" class="btn btn-primary"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\', \'contact\', \'save\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn btn-success"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\', \'contact\', \'apply\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Edit contact modal.
if ($allowEdit)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
'title' => JText::_('COM_CONTACT_EDIT_CONTACT'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button" class="btn"'
. ' onclick="window.processModalEdit(this, \'' . $this->id
. '\', \'edit\', \'contact\', \'cancel\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
. '<button type="button" class="btn btn-primary"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'edit\', \'contact\', \'save\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn btn-success"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'edit\', \'contact\', \'apply\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id"' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_CONTACT_SELECT_A_CONTACT', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 3.4
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id', parent::getLabel());
}
}
home/digilove/public_html/administrator/components/com_contact/tables/contact.php 0000644 00000012555 15242446742 0024576 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
/**
* Contact Table class.
*
* @since 1.0
*/
class ContactTableContact extends JTable
{
/**
* Ensure the params and metadata in json encoded in the bind method
*
* @var array
* @since 3.3
*/
protected $_jsonEncode = array('params', 'metadata');
/**
* Constructor
*
* @param JDatabaseDriver $db Database connector object
*
* @since 1.0
*/
public function __construct(&$db)
{
parent::__construct('#__contact_details', 'id', $db);
$this->setColumnAlias('title', 'name');
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_contact.contact'));
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_contact.contact'));
}
/**
* Stores a contact.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (is_array($this->params))
{
$registry = new Registry($this->params);
$this->params = (string) $registry;
}
$date = JFactory::getDate()->toSql();
$userId = JFactory::getUser()->id;
$this->modified = $date;
if ($this->id)
{
// Existing item
$this->modified_by = $userId;
}
else
{
// New contact. A contact created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created)
{
$this->created = $date;
}
if (empty($this->created_by))
{
$this->created_by = $userId;
}
}
// Set publish_up to null date if not set
if (!$this->publish_up)
{
$this->publish_up = $this->_db->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down)
{
$this->publish_down = $this->_db->getNullDate();
}
// Set xreference to empty string if not set
if (!$this->xreference)
{
$this->xreference = '';
}
// Store utf8 email as punycode
$this->email_to = JStringPunycode::emailToPunycode($this->email_to);
// Convert IDN urls to punycode
$this->webpage = JStringPunycode::urlToPunycode($this->webpage);
// Verify that the alias is unique
$table = JTable::getInstance('Contact', 'ContactTable', array('dbo' => $this->_db));
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}
/**
* Overloaded check function
*
* @return boolean True on success, false on failure
*
* @see JTable::check
* @since 1.5
*/
public function check()
{
$this->default_con = (int) $this->default_con;
if (JFilterInput::checkAttribute(array('href', $this->webpage)))
{
$this->setError(JText::_('COM_CONTACT_WARNING_PROVIDE_VALID_URL'));
return false;
}
// Check for valid name
if (trim($this->name) == '')
{
$this->setError(JText::_('COM_CONTACT_WARNING_PROVIDE_VALID_NAME'));
return false;
}
// Generate a valid alias
$this->generateAlias();
// Check for valid category
if (trim($this->catid) == '')
{
$this->setError(JText::_('COM_CONTACT_WARNING_CATEGORY'));
return false;
}
// Sanity check for user_id
if (!$this->user_id)
{
$this->user_id = 0;
}
// Check the publish down date is not earlier than publish up.
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
/*
* Clean up keywords -- eliminate extra spaces between phrases
* and cr (\r) and lf (\n) characters from string.
* Only process if not empty.
*/
if (!empty($this->metakey))
{
// Array of characters to remove.
$badCharacters = array("\n", "\r", "\"", '<', '>');
// Remove bad characters.
$afterClean = StringHelper::str_ireplace($badCharacters, '', $this->metakey);
// Create array using commas as delimiter.
$keys = explode(',', $afterClean);
$cleanKeys = array();
foreach ($keys as $key)
{
// Ignore blank keywords.
if (trim($key))
{
$cleanKeys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(', ', $cleanKeys);
}
// Clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc))
{
// Only process if not empty
$badCharacters = array("\"", '<', '>');
$this->metadesc = StringHelper::str_ireplace($badCharacters, '', $this->metadesc);
}
return true;
}
/**
* Generate a valid alias from title / date.
* Remains public to be able to check for duplicated alias before saving
*
* @return string
*/
public function generateAlias()
{
if (empty($this->alias))
{
$this->alias = $this->name;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
return $this->alias;
}
}