Skip to content

Commit

Permalink
Merge commit '9be1fb0' into 4.0-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed May 10, 2018
2 parents 1402c50 + 9be1fb0 commit b742fc9
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 61 deletions.
104 changes: 54 additions & 50 deletions components/com_contact/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,68 +175,72 @@ public function submit()
*/
private function _sendEmail($data, $contact, $copy_email_activated)
{
$app = $this->app;
$app = $this->app;

if ($contact->email_to == '' && $contact->user_id != 0)
{
$contact_user = \JUser::getInstance($contact->user_id);
$contact->email_to = $contact_user->get('email');
}
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');
$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'];
$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);
// 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']))
// 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)
{
$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;
}
$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 ($copy_email_activated == 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($contact->email_to);
$mail->addRecipient($email);
$mail->addReplyTo($email, $name);
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($sitename . ': ' . $subject);
$mail->setBody($body);
$mail->setSubject($copysubject);
$mail->setBody($copytext);
$sent = $mail->Send();
}

// If we are supposed to copy the sender, do so.

// Check whether email copy function activated
if ($copy_email_activated == 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;
return $sent;
}
}
5 changes: 5 additions & 0 deletions components/com_contact/Model/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function getItems()
for ($i = 0, $n = count($items); $i < $n; $i++)
{
$item = &$items[$i];

if (!isset($this->_params))
{
$item->params = new Registry($item->params);
Expand Down Expand Up @@ -181,6 +182,7 @@ protected function getListQuery()

// Filter by search in title
$search = $this->getState('list.filter');

if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
Expand Down Expand Up @@ -259,10 +261,12 @@ protected function populateState($ordering = null, $direction = null)
$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');
Expand Down Expand Up @@ -319,6 +323,7 @@ public function getCategory()
$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();
Expand Down
4 changes: 1 addition & 3 deletions components/com_contact/Model/ContactModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function getItem($pk = null)
// 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 . ')')
Expand Down Expand Up @@ -247,7 +248,6 @@ public function getItem($pk = null)
// 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);
}
Expand Down Expand Up @@ -311,7 +311,6 @@ protected function buildContactExtendedData($contact)
// Get the com_content articles by the linked user
if ((int) $contact->user_id && $this->getState('params')->get('show_articles'))
{

$query->select('a.id')
->select('a.title')
->select('a.state')
Expand Down Expand Up @@ -466,7 +465,6 @@ protected function getContactQuery($pk = null)

if ($result)
{

$contactParams = new Registry($result->params);

// If we are showing a contact list, then the contact parameters take priority
Expand Down
7 changes: 7 additions & 0 deletions components/com_contact/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getItems()
for ($i = 0, $n = count($items); $i < $n; $i++)
{
$item = &$items[$i];

if (!isset($this->_params))
{
$item->params = new Registry($item->params);
Expand Down Expand Up @@ -105,6 +106,7 @@ protected function getListQuery()

// Filter by state
$state = $this->getState('filter.published');

if (is_numeric($state))
{
$query->where('a.published = ' . (int) $state);
Expand Down Expand Up @@ -155,20 +157,25 @@ protected function populateState($ordering = null, $direction = null)
$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.
Expand Down
1 change: 1 addition & 0 deletions components/com_contact/View/Contact/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public function display($tpl = null)
}

$this->_prepareDocument();

return parent::display($tpl);
}

Expand Down
3 changes: 2 additions & 1 deletion components/com_contact/View/Contact/VcfView.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ public function display($tpl = null)
// e.g. "de Gaulle, Charles"
$namearray = explode(',', $item->name);

if (count($namearray) > 1 )
if (count($namearray) > 1)
{
$lastname = $namearray[0];
$card_name = $lastname;
$name_and_midname = trim($namearray[1]);

$firstname = '';

if (!empty($name_and_midname))
{
$namearray = explode(' ', $name_and_midname);
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public function save($key = null, $urlVar = 'a_id')
if (Multilanguage::isEnabled())
{
$item = $app->getMenu()->getItem($menuitem);
$lang = !is_null($item) && $item->language != '*' ? '&lang=' . $item->language : '';
$lang = !is_null($item) && $item->language != '*' ? '&lang=' . $item->language : '';
}

// If ok, redirect to the return page.
Expand Down
4 changes: 4 additions & 0 deletions components/com_content/Helper/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created')

case 'vote' :
$orderby = 'a.id DESC ';

if (PluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating_count DESC ';
Expand All @@ -129,6 +130,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created')

case 'rvote' :
$orderby = 'a.id ASC ';

if (PluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating_count ASC ';
Expand All @@ -137,6 +139,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created')

case 'rank' :
$orderby = 'a.id DESC ';

if (PluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating DESC ';
Expand All @@ -145,6 +148,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created')

case 'rrank' :
$orderby = 'a.id ASC ';

if (PluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating ASC ';
Expand Down
1 change: 1 addition & 0 deletions components/com_content/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public function getYears()
->order('1 ASC');

$db->setQuery($query);

return $db->loadColumn();
}

Expand Down
1 change: 1 addition & 0 deletions components/com_content/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ protected function getListQuery()
{
ArrayHelper::toInteger($tagId);
$tagId = implode(',', $tagId);

if (!empty($tagId))
{
$hasTag = true;
Expand Down
1 change: 1 addition & 0 deletions components/com_content/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public function display($tpl = null)
{
$app->enqueueMessage(\JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);

return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/View/Category/FeedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function reconcileNames($item)

if (isset($introImage) && ($introImage != ''))
{
$image = preg_match('/http/', $introImage)? $introImage : \JURI::root() . $introImage;
$image = preg_match('/http/', $introImage) ? $introImage : \JURI::root() . $introImage;
$item->description = '<p><img src="' . $image . '"></p>';
}

Expand Down
2 changes: 1 addition & 1 deletion components/com_content/View/Featured/FeedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function display($tpl = null)

if (isset($introImage) && ($introImage != ''))
{
$image = preg_match('/http/', $introImage)? $introImage : JURI::root() . $introImage;
$image = preg_match('/http/', $introImage) ? $introImage : JURI::root() . $introImage;
$description = '<p><img src="' . $image . '"></p>';
}

Expand Down
2 changes: 1 addition & 1 deletion components/com_content/View/Featured/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class HtmlView extends BaseHtmlView
* @var \JDatabaseDriver
* @since 3.6.3
*/
protected $db;
protected $db;

/**
* The user object
Expand Down
Loading

0 comments on commit b742fc9

Please sign in to comment.