Source for file contact.php
Documentation is available at contact.php
* @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
* @subpackage com_contact
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
// Load state from the request.
$pk =
$app->input->getInt('id');
$params =
$app->getParams();
if ((!$user->authorise('core.edit.state', 'com_contact')) &&
(!$user->authorise('core.edit', 'com_contact'))){
* 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
public function getForm($data =
array(), $loadData =
true)
$form =
$this->loadForm('com_contact.contact', 'contact', array('control' =>
'jform', 'load_data' =>
true));
$contact =
$this->_item[$id];
$params->merge($contact->params);
if (!$params->get('show_email_copy', 0)){
$form->removeField('contact_email_copy');
* @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)
if (!isset
($this->_item[$pk]))
$query =
$db->getQuery(true);
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id.
' END as slug';
$case_when1 =
' CASE WHEN ';
$case_when1 .=
$query->charLength('c.alias', '!=', '0');
$c_id =
$query->castAsChar('c.id');
$case_when1 .=
$query->concatenate(array($c_id, 'c.alias'), ':');
$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());
// Filter by published state.
$published =
$this->getState('filter.published');
$archived =
$this->getState('filter.archived');
$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 .
')');
$data =
$db->loadObject();
// Check for published state if filter set.
if (((is_numeric($published)) ||
(is_numeric($archived))) &&
(($data->published !=
$published) &&
($data->published !=
$archived)))
// Convert parameter fields to objects.
$registry->loadString($data->params);
$data->params =
clone $this->getState('params');
$data->params->merge($registry);
$registry->loadString($data->metadata);
$data->metadata =
$registry;
$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);
// If no access filter is set, the layout takes some responsibility for display of limited information.
$groups =
$user->getAuthorisedViewLevels();
if ($data->catid ==
0 ||
$data->category_access ===
null)
$data->params->set('access-view', in_array($data->access, $groups));
$data->params->set('access-view', in_array($data->access, $groups) &&
in_array($data->category_access, $groups));
$this->_item[$pk] =
$data;
$this->_item[$pk] =
false;
$this->_item[$pk]->articles =
$extendedData->articles;
$this->_item[$pk]->profile =
$extendedData->profile;
return $this->_item[$pk];
// TODO: Cache on the fingerprint of the arguments
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('contact.id');
$query =
$db->getQuery(true);
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id.
' END as slug';
$case_when1 =
' CASE WHEN ';
$case_when1 .=
$query->charLength('cc.alias', '!=', '0');
$c_id =
$query->castAsChar('cc.id');
$case_when1 .=
$query->concatenate(array($c_id, 'cc.alias'), ':');
$case_when1 .=
$c_id.
' END as catslug';
'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');
$query->where('a.published IN (1,2)')
->where('cc.published IN (1,2)');
$groups =
implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN ('.
$groups.
')');
$result =
$db->loadObject();
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->loadString($result->params);
$this->getState('params')->merge($registry);
$groups =
implode(',', $user->getAuthorisedViewLevels());
//get the content by the linked user
$query =
$db->getQuery(true)
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id.
' END as slug';
$case_when1 =
' CASE WHEN ';
$case_when1 .=
$query->charLength('c.alias', '!=', '0');
$c_id =
$query->castAsChar('c.id');
$case_when1 .=
$query->concatenate(array($c_id, 'c.alias'), ':');
$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
$query->where(('a.created_by = ' . (int)
$result->user_id) .
' AND ' .
('a.language=' .
$db->quote(JFactory::getLanguage()->getTag()) .
' OR a.language=' .
$db->quote('*')));
$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
$data =
$userModel->getItem((int)
$result->user_id);
$form =
new JForm('com_users.profile');
// 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.
$result->profile =
$form;
$this->contact =
$result;
* 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.
public function hit($pk =
0)
$hitcount =
$input->getInt('hitcount', 1);
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('contact.id');
Documentation generated on Tue, 19 Nov 2013 14:56:32 +0100 by phpDocumentor 1.4.3