first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* This models supports retrieving lists of contact categories.
*
* @package Joomla.Site
* @subpackage com_contact
* @since 1.6
*/
class ContactModelCategories extends JModelList
{
/**
* Model context string.
*
* @var string
*/
public $_context = 'com_contact.categories';
/**
* The category context (allows other extensions to derived from this model).
*
* @var string
*/
protected $_extension = 'com_contact';
private $_parent = null;
private $_items = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->input->getInt('id');
$this->setState('filter.parentId', $parentId);
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* redefine the function an add some properties to make the styling more easy
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
if (!count($this->_items))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = JCategories::getInstance('Contact', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
if (is_object($this->_parent))
{
$this->_items = $this->_parent->getChildren();
} else {
$this->_items = false;
}
}
return $this->_items;
}
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -0,0 +1,379 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_contact
* @since 1.5
*/
class ContactModelCategory extends JModelList
{
/**
* Category items data
*
* @var array
*/
protected $_item = null;
protected $_articles = null;
protected $_siblings = null;
protected $_children = null;
protected $_parent = null;
/**
* The category that applies.
*
* @access protected
* @var object
*/
protected $_category = null;
/**
* The list of other newfeed categories.
*
* @access protected
* @var array
*/
protected $_categories = null;
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'con_position', 'a.con_position',
'suburb', 'a.suburb',
'state', 'a.state',
'country', 'a.country',
'ordering', 'a.ordering',
'sortname',
'sortname1', 'a.sortname1',
'sortname2', 'a.sortname2',
'sortname3', 'a.sortname3'
);
}
parent::__construct($config);
}
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();
// Convert the params field into an object, saving original in _params
for ($i = 0, $n = count($items); $i < $n; $i++)
{
$item = & $items[$i];
if (!isset($this->_params))
{
$params = new JRegistry;
$params->loadString($item->params);
$item->params = $params;
}
$this->tags = new JHelperTags;
$this->tags->getItemTags('com_contact.contact', $item->id);
}
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the categories.
//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('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('list.select', 'a.*') . ',' . $case_when . ',' . $case_when1)
// TODO: we actually should be doing it but it's wrong this way
// . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
// . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug ');
->from($db->quoteName('#__contact_details') . ' AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('a.access IN (' . $groups . ')');
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
$query->where('a.catid = ' . (int) $categoryId)
->where('c.access IN (' . $groups . ')');
}
// Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state
$state = $this->getState('filter.published');
if (is_numeric($state))
{
$query->where('a.published = ' . (int) $state);
}
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
if ($this->getState('filter.publish_date'))
{
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Filter by search in title
$search = $this->getState('list.filter');
if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.name LIKE ' . $search . ')');
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Set sortname ordering if selected
if ($this->getState('list.ordering') == 'sortname')
{
$query->order($db->escape('a.sortname1') . ' ' . $db->escape($this->getState('list.direction', 'ASC')))
->order($db->escape('a.sortname2') . ' ' . $db->escape($this->getState('list.direction', 'ASC')))
->order($db->escape('a.sortname3') . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
}
else
{
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
}
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_contact');
// List state information
$format = $app->input->getWord('format');
if ($format == 'feed')
{
$limit = $app->getCfg('feed_limit');
}
else
{
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
}
$this->setState('list.limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
// Get list ordering default from the parameters
$menuParams = new JRegistry;
if ($menu = $app->getMenu()->getActive())
{
$menuParams->loadString($menu->params);
}
$mergedParams = clone $params;
$mergedParams->merge($menuParams);
$orderCol = $app->input->get('filter_order', $mergedParams->get('initial_sort', 'ordering'));
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact')))
{
// limit to published for people who can't edit or edit.state.
$this->setState('filter.published', 1);
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get category data for the current category
*
* @param integer An optional ID
*
* @return object
* @since 1.5
*/
public function getCategory()
{
if (!is_object($this->_item))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0);
$categories = JCategories::getInstance('Contact', $options);
$this->_item = $categories->get($this->getState('category.id', 'root'));
if (is_object($this->_item))
{
$this->_children = $this->_item->getChildren();
$this->_parent = false;
if ($this->_item->getParent())
{
$this->_parent = $this->_item->getParent();
}
$this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false);
}
else
{
$this->_children = false;
$this->_parent = false;
}
}
return $this->_item;
}
/**
* Get the parent category.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function getParent()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getChildren()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_children;
}
}

View File

@ -0,0 +1,414 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_contact
* @since 1.5
*/
class ContactModelContact extends JModelForm
{
/**
* @since 1.6
*/
protected $view_item = 'contact';
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.
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('site');
// Load state from the request.
$pk = $app->input->getInt('id');
$this->setState('contact.id', $pk);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$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)
{
// Get the form.
$form = $this->loadForm('com_contact.contact', 'contact', array('control' => 'jform', 'load_data' => true));
if (empty($form))
{
return false;
}
$id = $this->getState('contact.id');
$params = $this->getState('params');
$contact = $this->_item[$id];
$params->merge($contact->params);
if (!$params->get('show_email_copy', 0)){
$form->removeField('contact_email_copy');
}
return $form;
}
protected function loadFormData()
{
$data = (array) JFactory::getApplication()->getUserState('com_contact.contact.data', array());
$this->preprocessData('com_contact.contact', $data);
return $data;
}
/**
* Gets a contact
*
* @param integer $pk Id for the contact
*
* @return mixed Object or null
*/
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);
//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('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'));
}
// Convert parameter fields to objects.
$registry = new JRegistry;
$registry->loadString($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($data->metadata);
$data->metadata = $registry;
$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])
{
if ($extendedData = $this->getContactQuery($pk))
{
$this->_item[$pk]->articles = $extendedData->articles;
$this->_item[$pk]->profile = $extendedData->profile;
}
}
return $this->_item[$pk];
}
protected function getContactQuery($pk = null)
{
// TODO: Cache on the fingerprint of the arguments
$db = $this->getDbo();
$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))
{
throw new Exception(JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
}
// 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'))
{
$registry = new JRegistry;
$registry->loadString($result->params);
$this->getState('params')->merge($registry);
}
}
catch (Exception $e)
{
$this->setError($e);
return false;
}
if ($result)
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
//get the content by the linked user
$query = $db->getQuery(true)
->select('a.id')
->select('a.title')
->select('a.state')
->select('a.access')
->select('a.created');
// 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.state DESC, a.created DESC');
// filter per language if plugin published
if (JLanguageMultilang::isEnabled())
{
$query->where(('a.created_by = ' . (int) $result->user_id) AND ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')));
}
if (is_numeric($published))
{
$query->where('a.state IN (1,2)');
}
$db->setQuery($query, 0, 10);
$articles = $db->loadObjectList();
$result->articles = $articles;
//get the profile information for the linked user
require_once JPATH_ADMINISTRATOR.'/components/com_users/models/user.php';
$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;
}
}
}
/**
* Increment the hit counter for the contact.
*
* @param int $pk Optional primary key of the article 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');
$db = $this->getDbo();
$db->setQuery(
'UPDATE #__contact_details' .
' SET hits = hits + 1' .
' WHERE id = '.(int) $pk
);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,214 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_contact
*/
class ContactModelFeatured extends JModelList
{
/**
* Category items data
*
* @var array
*/
protected $_item = null;
protected $_articles = null;
protected $_siblings = null;
protected $_children = null;
protected $_parent = null;
/**
* The category that applies.
*
* @access protected
* @var object
*/
protected $_category = null;
/**
* The list of other cotnact categories.
*
* @access protected
* @var array
*/
protected $_categories = null;
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'con_position', 'a.con_position',
'suburb', 'a.suburb',
'state', 'a.state',
'country', 'a.country',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();
// Convert the params field into an object, saving original in _params
for ($i = 0, $n = count($items); $i < $n; $i++)
{
$item = & $items[$i];
if (!isset($this->_params))
{
$params = new JRegistry;
$params->loadString($item->params);
$item->params = $params;
}
}
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the categories.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__contact_details') . ' AS a')
->where('a.access IN (' . $groups . ')')
->where('a.featured=1')
->join('INNER', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
$query->where('a.catid = ' . (int) $categoryId);
}
//sqlsrv change... aliased c.published to cat_published
// Join to check for category published state in parent categories up the tree
$query->select('c.published as cat_published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');
$subquery = 'SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
$subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
$subquery .= 'WHERE parent.extension = ' . $db->quote('com_contact');
// Find any up-path categories that are not published
// If all categories are published, badcats.id will be null, and we just use the contact state
$subquery .= ' AND parent.published != 1 GROUP BY cat.id ';
// Select state to unpublished if up-path category is unpublished
$publishedWhere = 'CASE WHEN badcats.id is null THEN a.published ELSE 0 END';
$query->join('LEFT OUTER', '(' . $subquery . ') AS badcats ON badcats.id = c.id');
// Filter by state
$state = $this->getState('filter.published');
if (is_numeric($state))
{
$query->where('a.published = ' . (int) $state);
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$date = JFactory::getDate();
$nowDate = $db->quote($date->toSql());
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')')
->where($publishedWhere . ' = ' . (int) $state);
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_contact');
// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
$this->setState('list.limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
$orderCol = $app->input->get('filter_order', 'ordering');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact')))
{
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.published', 1);
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Load the parameters.
$this->setState('params', $params);
}
}

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset name="contact" addrulepath="components/com_contact/models/rules" label="COM_CONTACT_FORM_LABEL">
<field name="contact_name"
type="text"
id="contact-name"
size="30"
description="COM_CONTACT_CONTACT_EMAIL_NAME_DESC"
label="COM_CONTACT_CONTACT_EMAIL_NAME_LABEL"
filter="string"
required="true"
/>
<field name="contact_email"
type="email"
id="contact-email"
size="30"
description="COM_CONTACT_EMAIL_DESC"
label="COM_CONTACT_EMAIL_LABEL"
filter="string"
validate="contactemail"
required="true"
/>
<field name="contact_subject"
type="text"
id="contact-emailmsg"
size="60"
description="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_DESC"
label="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL"
filter="string"
validate="contactemailsubject"
required="true"
/>
<field name="contact_message"
type="textarea"
cols="50"
rows="10"
id="contact-message"
description="COM_CONTACT_CONTACT_ENTER_MESSAGE_DESC"
label="COM_CONTACT_CONTACT_ENTER_MESSAGE_LABEL"
filter="htmlsafe"
validate="contactemailmessage"
required="true"
/>
<field name="contact_email_copy"
type="checkbox"
id="contact-email-copy"
description="COM_CONTACT_CONTACT_EMAIL_A_COPY_DESC"
label="COM_CONTACT_CONTACT_EMAIL_A_COPY_LABEL"
default="0"
/>
</fieldset>
<fieldset name="captcha">
<field
name="captcha"
type="captcha"
label="COM_CONTACT_CAPTCHA_LABEL"
description="COM_CONTACT_CAPTCHA_DESC"
validate="captcha"
namespace="contact"
/>
</fieldset>
</form>

View File

@ -0,0 +1,565 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset>
<field name="id" type="hidden"
default="0"
label="COM_CONTACT_ID_LABEL"
readonly="true"
required="true"
size="10"
/>
<field name="name" type="text"
description="CONTACT_NAME_DESC"
label="CONTACT_NAME_LABEL"
required="true"
size="30"
/>
<field name="alias" type="text"
description="JFIELD_ALIAS_DESC"
label="JFIELD_ALIAS_LABEL"
size="30"
/>
<field name="user_id" type="user"
description="CONTACT_LINKED_USER_DESC"
label="CONTACT_LINKED_USER_LABEL"
/>
<field name="published" type="list"
default="1"
description="JFIELD_PUBLISHED_DESC"
label="JFIELD_PUBLISHED_LABEL"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-1">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="catid" type="category"
description="JFIELD_CATEGORY_DESC"
extension="com_contact"
label="JCATEGORY"
required="true"
/>
<field name="access" type="accesslevel"
description="JFIELD_ACCESS_DESC"
label="JFIELD_ACCESS_LABEL"
size="1"
/>
<field name="sortname1" type="text"
description="CONTACT_SORTNAME1_DESC"
label="CONTACT_SORTNAME1_LABEL"
size="30"
/>
<field name="sortname2" type="text"
description="CONTACT_SORTNAME3_DESC"
label="CONTACT_SORTNAME2_LABEL"
size="30"
/>
<field name="sortname3" type="text"
description="CONTACT_SORTNAME3_DESC"
label="CONTACT_SORTNAME3_LABEL"
size="30"
/>
<field name="language" type="text"
description="CONTACT_LANGUAGE_DESC"
label="CONTACT_LANGUAGE_LABEL"
size="30"
/>
<field name="con_position" type="text"
description="CONTACT_INFORMATION_POSITION_DESC"
label="CONTACT_INFORMATION_POSITION_LABEL"
size="30"
/>
<field name="email_to" type="email"
description="CONTACT_INFORMATION_EMAIL_DESC"
label="CONTACT_INFORMATION_EMAIL_LABEL"
size="30" validate="email" filter="string"
/>
<field name="address" type="textarea"
cols="30"
description="CONTACT_INFORMATION_ADDRESS_DESC"
label="CONTACT_INFORMATION_ADDRESS_LABEL"
rows="3"
/>
<field name="suburb" type="text"
description="CONTACT_INFORMATION_SUBURB_DESC"
label="CONTACT_INFORMATION_SUBURB_LABEL"
size="30"
/>
<field name="state" type="text"
description="CONTACT_INFORMATION_STATE_DESC"
label="CONTACT_INFORMATION_STATE_LABEL"
size="30"
/>
<field name="postcode" type="text"
description="CONTACT_INFORMATION_POSTCODE_DESC"
label="CONTACT_INFORMATION_POSTCODE_LABEL"
size="30"
/>
<field name="country" type="text"
description="CONTACT_INFORMATION_COUNTRY_DESC"
label="CONTACT_INFORMATION_COUNTRY_LABEL"
size="30"
/>
<field name="telephone" type="text"
description="CONTACT_INFORMATION_TELEPHONE_DESC"
label="CONTACT_INFORMATION_TELEPHONE_LABEL"
size="30"
/>
<field name="mobile" type="text"
description="CONTACT_INFORMATION_MOBILE_DESC"
label="CONTACT_INFORMATION_MOBILE_LABEL"
size="30"
/>
<field name="webpage" type="text"
description="CONTACT_INFORMATION_WEBPAGE_DESC"
label="CONTACT_INFORMATION_WEBPAGE_LABEL"
size="30"
/>
<field name="misc" type="editor"
buttons="true"
hide="pagebreak,readmore"
description="CONTACT_INFORMATION_MISC_DESC"
filter="safehtml"
label="CONTACT_INFORMATION_MISC_LABEL"
size="30"
/>
<field name="checked_out" type="hidden"
filter="unset"
/>
<field name="checked_out_time" type="hidden"
filter="unset"
/>
<field name="ordering" type="ordering"
description="JFIELD_ORDERING_DESC"
label="JFIELD_ORDERING_LABEL"
/>
<field name="metakey" type="textarea"
cols="30"
description="JFIELD_META_KEYWORDS_DESC"
label="JFIELD_META_KEYWORDS_LABEL"
rows="3"
/>
<field name="metadesc" type="textarea"
cols="30"
description="JFIELD_META_DESCRIPTION_DESC"
label="JFIELD_META_DESCRIPTION_LABEL"
rows="3"
/>
<field name="language" type="contentlanguage"
description="JFIELD_CONTACT_LANGUAGE_DESC"
label="JFIELD_LANGUAGE_LABEL"
>
<option value="">JALL</option>
</field>
<field name="contact_icons" type="list"
default="0"
description="PARAMCONTACTICONS"
label="Icons/text"
>
<option value="0">CONTACT_ICONS_OPTIONS_NONE</option>
<option value="1">CONTACT_ICONS_OPTIONS_TEXT</option>
<option value="2">CONTACT_ICONS_OPTIONS_TEXT</option>
</field>
<field name="icon_address" type="imagelist"
description="CONTACT_ICONS_ADDRESS_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_ADDRESS_LABEL"
/>
<field name="icon_email" type="imagelist"
description="CONTACT_ICONS_EMAIL_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_EMAIL_LABEL"
/>
<field name="icon_telephone" type="imagelist"
description="CONTACT_ICONS_TELEPHONE_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_TELEPHONE_LABEL"
/>
<field name="icon_mobile" type="imagelist"
description="CONTACT_ICONS_MOBILE_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_MOBILE_LABEL"
/>
<field name="icon_fax" type="imagelist"
description="CONTACT_ICONS_FAX_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_FAX_LABEL"
/>
<field name="icon_misc" type="imagelist"
description="CONTACT_ICONS_MISC_DESC"
directory="/images"
hide_none="1"
label="CONTACT_ICONS_MISC_LABEL"
/>
</fieldset>
<fields name="metadata">
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
</field>
<field name="rights" type="text"
description="JFIELD_METADATA_RIGHTS_DESC"
label="JFIELD_METADATA_RIGHTS_LABEL"
size="20"
/>
</fieldset>
</fields>
<fields name="params">
<fieldset name="options" label="CONTACT_PARAMETERS">
<field name="show_name" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_NAME_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_position" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_CONTACT_POSITION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_email" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_CONTACT_POSITION_E_MAIL_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_street_address" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_STREET_ADDRESS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_suburb" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_TOWN_SUBURB_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_state" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_STATE_COUNTY_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_postcode" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_POST_ZIP_CODE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_country" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_COUNTRY_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_telephone" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_TELEPHONE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_mobile" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_MOBILE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_fax" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_FAX_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_webpage" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_WEBPAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_misc" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_MISC_INFO_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_image" type="list"
description="CONTACT_PARAMS_NAME_DESC"
label="CONTACT_PARAMS_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="allow_vcard" type="list"
description="CONTACT_PARAMS_VCARD_LABEL"
label="CONTACT_PARAMS_VCARD_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_articles" type="list"
description="CONTACT_SHOW_ARTICLES_DESC"
label="CONTACT_SHOW_ARTICLES_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_profile" type="list"
label="CONTACT_PROFILE_SHOW_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_links" type="list"
description="CONTACT_SHOW_LINKS_DESC"
label="CONTACT_SHOW_LINKS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="linka_name" type="text"
description="CONTACT_LINKA_NAME_DESC"
label="CONTACT_LINKA_NAME_LABEL"
size="30"
/>
<field name="linka" type="text"
description="CONTACT_LINKA_DESC"
label="CONTACT_LINKA_LABEL"
size="30"
/>
<field name="linkb_name" type="text"
description="CONTACT_LINKB_NAME_DESC"
label="CONTACT_LINKB_NAME_LABEL"
size="30"
/>
<field name="linkb" type="text"
description="CONTACT_LINKB_DESC"
label="CONTACT_LINKB_LABEL"
size="30"
/>
<field name="linkc_name" type="text"
description="CONTACT_LINKC_NAME_DESC"
label="CONTACT_LINKC_NAME_LABEL"
size="30"
/>
<field name="linkc" type="text"
description="CONTACT_LINKC_DESC"
label="CONTACT_LINKC_LABEL"
size="30"
/>
<field name="linkd_name" type="text"
description="CONTACT_LINKD_NAME_DESC"
label="CONTACT_LINKD_NAME_LABEL"
size="30"
/>
<field name="linkd" type="text"
description="CONTACT_LINKD_DESC"
label="CONTACT_LINKD_LABEL"
size="30"
/>
<field name="linke_name" type="text"
description="CONTACT_LINKE_NAME_DESC"
label="CONTACT_LINKE_NAME_LABEL"
size="30"
/>
<field name="linke" type="text"
description="CONTACT_LINKE_DESC"
label="CONTACT_LINKE_LABEL"
size="30"
/>
</fieldset>
</fields>
<fields name="email_form">
<fieldset name="email_form" label="CONTACT_EMAIL_FORM_LABEL">
<field name="show_email_form" type="list"
description="CONTACT_EMAIL_SHOW_FORM_DESC"
label="CONTACT_EMAIL_SHOW_FORM_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="email_description" type="text"
description="CONTACT_EMAIL_DESCRIPTION_TEXT_DESC"
label="CONTACT_EMAIL_DESCRIPTION_TEXT_LABEL"
size="30"
/>
<field name="show_email_copy" type="list"
description="CONTACT_EMAIL_EMAIL_COPY_DESC"
label="CONTACT_EMAIL_EMAIL_COPY_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="banned_email" type="textarea"
cols="30"
description="CONTACT_EMAIL_BANNED_EMAIL_DESC"
label="CONTACT_EMAIL_BANNED_EMAIL_LABEL"
rows="3"
/>
<field name="banned_subject" type="textarea"
cols="30"
description="Contact_Email_BANNED_SUBJECT_DESC"
label="Contact_Email_BANNED_SUBJECT_LABEL"
rows="3"
/>
<field name="banned_text" type="textarea"
cols="30"
description="CONTACT_EMAIL_BANNED_TEXT_DESC"
label="CONTACT_EMAIL_BANNED_TEXT_LABEL"
rows="3"
/>
<field name="validate_session" type="list"
description="CONTACT_CONFIG_SESSION_CHECK_DESC"
label="CONTACT_CONFIG_SESSION_CHECK_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="custom_reply" type="list"
description="CONTACT_CONFIG_CUSTOM_REPLY_DESC"
label="CONTACT_CONFIG_CUSTOM_REPLY"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="redirect" type="text"
description="COM_CONTACT_FIELD_CONFIG_REDIRECT_DESC"
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
size="30"
/>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadRuleClass('email');
/**
* JFormRule for com_contact to make sure the E-Mail adress is not blocked.
*
* @package Joomla.Site
* @subpackage com_contact
*/
class JFormRuleContactEmail extends JFormRuleEmail
{
/**
* Method to test for a valid color in hexadecimal.
*
* @param SimpleXMLElement &$element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param object &$input An optional JRegistry object with the entire data set to validate against the entire form.
* @param object &$form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(& $element, $value, $group = null, &$input = null, &$form = null)
{
if (!parent::test($element, $value, $group, $input, $form)){
return false;
}
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_email');
foreach (explode(';', $banned) as $item) {
if (JString::stristr($item, $value) !== false)
return false;
}
return true;
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* JFormRule for com_contact to make sure the message body contains no banned word.
*
* @package Joomla.Site
* @subpackage com_contact
*/
class JFormRuleContactEmailMessage extends JFormRule
{
/**
* Method to test for a valid color in hexadecimal.
*
* @param SimpleXMLElement &$element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param object &$input An optional JRegistry object with the entire data set to validate against the entire form.
* @param object &$form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_text');
foreach (explode(';', $banned) as $item) {
if (JString::stristr($item, $value) !== false)
return false;
}
return true;
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* JFormRule for com_contact to make sure the subject contains no banned word.
*
* @package Joomla.Site
* @subpackage com_contact
*/
class JFormRuleContactEmailSubject extends JFormRule
{
/**
* Method to test for a valid color in hexadecimal.
*
* @param SimpleXMLElement &$element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param object &$input An optional JRegistry object with the entire data set to validate against the entire form.
* @param object &$form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_subject');
foreach (explode(';', $banned) as $item) {
if (JString::stristr($item, $value) !== false)
return false;
}
return true;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>