Skip to content

Commit

Permalink
Merge branch '4.0-dev' into cleanup-content-banner-toolbar-code
Browse files Browse the repository at this point in the history
  • Loading branch information
bembelimen committed Dec 28, 2018
2 parents 9a9e944 + b73474e commit 0498252
Show file tree
Hide file tree
Showing 68 changed files with 751 additions and 507 deletions.
Expand Up @@ -64,7 +64,7 @@ public static function updateReset()

if ($purchaseType < 0 && $row->cid)
{
/** @var \Joomla\Component\Banners\Administrator\Table\Client $client */
/** @var \Joomla\Component\Banners\Administrator\Table\ClientTable $client */
$client = Table::getInstance('Client', '\\Joomla\\Component\\Banners\\Administrator\\Table\\');
$client->load($row->cid);
$purchaseType = $client->purchase_type;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_banners/Model/BannerModel.php
Expand Up @@ -365,7 +365,7 @@ protected function loadFormData()
/**
* Method to stick records.
*
* @param array &$pks The ids of the items to publish.
* @param array $pks The ids of the items to publish.
* @param integer $value The value of the published state
*
* @return boolean True on success.
Expand Down
Expand Up @@ -78,7 +78,7 @@ public function getForm($data = array(), $loadData = true)
*/
protected function loadFormData()
{
$data = array(
$data = (object) array(
'basename' => $this->getState('basename'),
'compressed' => $this->getState('compressed'),
);
Expand Down
Expand Up @@ -378,7 +378,7 @@ public function getItems()
/**
* Method to load the countItems method from the extensions
*
* @param \stdClass[] &$items The category items
* @param \stdClass[] $items The category items
* @param string $extension The category extension
*
* @return void
Expand Down
Expand Up @@ -381,7 +381,7 @@ protected function loadFormData()
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import.
*
* @return void
* @return mixed
*
* @see \JFormField
* @since 1.6
Expand Down Expand Up @@ -729,7 +729,7 @@ public function save($data)
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param array $pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
Expand Down
Expand Up @@ -1256,7 +1256,7 @@ private function canCreateCategory()
/**
* Delete #__content_frontpage items if the deleted articles was featured
*
* @param object &$pks The primary key related to the contents that was deleted.
* @param object $pks The primary key related to the contents that was deleted.
*
* @return boolean
*
Expand Down
3 changes: 2 additions & 1 deletion administrator/components/com_content/Service/HTML/Icon.php
Expand Up @@ -106,7 +106,8 @@ public function email($article, $params, $attribs = array(), $legacy = false)
$link = $base . Route::_(\ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language), false);
$url = 'index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailtoHelper::addLink($link);

$status = 'width=400,height=350,menubar=yes,resizable=yes';
$height = Factory::getApplication()->get('captcha', '0') === '0' ? 450 : 550;
$status = 'width=400,height=' . $height . ',menubar=yes,resizable=yes';

$text = LayoutHelper::render('joomla.content.icons.email', array('params' => $params, 'legacy' => $legacy));

Expand Down
Expand Up @@ -118,7 +118,7 @@ protected function canDelete($record)
/**
* Method to delete one or more records from content history table.
*
* @param array &$pks An array of record primary keys.
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
Expand Down Expand Up @@ -256,7 +256,7 @@ public function getTable($type = 'ContentHistory', $prefix = 'Joomla\\CMS\\Table
/**
* Method to toggle on and off the keep forever value for one or more records from content history table.
*
* @param array &$pks An array of record primary keys.
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_fields/Model/FieldModel.php
Expand Up @@ -448,7 +448,7 @@ protected function generateNewTitle($category_id, $name, $title)
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_menus/Model/ItemModel.php
Expand Up @@ -636,6 +636,8 @@ protected function loadFormData()
$this->setState('item.menutypeid', $menuTypeId);
}

$data = (object) $data;

$this->preprocessData('com_menus.item', $data);

return $data;
Expand Down
2 changes: 1 addition & 1 deletion administrator/language/en-GB/en-GB.com_contact.ini
Expand Up @@ -74,7 +74,7 @@ COM_CONTACT_FIELD_INFORMATION_MISC_LABEL="Miscellaneous Information"
COM_CONTACT_FIELD_INFORMATION_MOBILE_LABEL="Mobile"
COM_CONTACT_FIELD_INFORMATION_POSITION_LABEL="Position"
COM_CONTACT_FIELD_INFORMATION_POSTCODE_LABEL="Postal/ZIP Code"
COM_CONTACT_FIELD_INFORMATION_STATE_LABEL="State or Province"
COM_CONTACT_FIELD_INFORMATION_STATE_LABEL="State or County"
COM_CONTACT_FIELD_INFORMATION_SUBURB_LABEL="City or Suburb"
COM_CONTACT_FIELD_INFORMATION_TELEPHONE_LABEL="Telephone"
COM_CONTACT_FIELD_INFORMATION_WEBPAGE_LABEL="Website"
Expand Down
22 changes: 0 additions & 22 deletions build/media_src/com_mailto/js/mailto-default.es6.js
Expand Up @@ -10,27 +10,8 @@
}

// Selectors used by this script
const formId = 'mailtoForm';
const closeSelector = '.close-mailto';

/**
* Handle the form submit event
* @param event
*/
const handleFormSubmit = (event) => {
event.preventDefault();
const form = event.target;

// Simple form validation
if (form.mailto.value === '' || form.from.value === '') {
// @todo use the Joomla alerts here
alert(Joomla.JText._('COM_MAILTO_EMAIL_ERR_NOINFO'));
return;
}

form.submit();
};

/**
* Register events
*/
Expand All @@ -43,9 +24,6 @@
* Register events
*/
const registerEvents = () => {
// Register the submit event listener
document.getElementById(formId).addEventListener('submit', handleFormSubmit);

// Register the close click listener
const closeElements = [].slice.call(document.querySelectorAll(closeSelector));

Expand Down
1 change: 1 addition & 0 deletions build/phpcs/Joomla/ruleset.xml
Expand Up @@ -161,6 +161,7 @@
<exclude-pattern type="relative">templates/*</exclude-pattern>
<exclude-pattern type="relative">layouts/*</exclude-pattern>
<exclude-pattern type="relative">tests/*</exclude-pattern>
<exclude-pattern type="relative">administrator/components/*</exclude-pattern>
</rule>

<rule ref="Joomla.Commenting.SingleComment">
Expand Down
93 changes: 51 additions & 42 deletions components/com_mailto/Controller/DisplayController.php
Expand Up @@ -23,9 +23,7 @@
/**
* Mailer Component Controller.
*
* @package Joomla.Site
* @subpackage com_mailto
* @since 1.5
* @since 1.5
*/
class DisplayController extends BaseController
{
Expand All @@ -34,11 +32,10 @@ class DisplayController extends BaseController
*
* @return void
*
* @since 1.5
* @since 1.5
*/
public function mailto()
{
$this->app->getSession()->set('com_mailto.formtime', time());
$this->input->set('view', 'mailto');
$this->display();
}
Expand All @@ -55,24 +52,33 @@ public function send()
// Check for request forgeries
$this->checkToken();

$session = $this->app->getSession();
$timeout = $session->get('com_mailto.formtime', 0);
/** @var \Joomla\Component\Mailto\Site\Model\MailtoModel $model */
$model = $this->getModel('mailto');
$data = $model->getData();

if ($timeout == 0 || time() - $timeout < 20)
{
$this->setMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');
// Validate the posted data.
$form = $model->getForm();

return $this->mailto();
if (!$form)
{
throw new \RuntimeException($model->getError());
}

$SiteName = $this->app->get('sitename');
$link = MailtoHelper::validateHash($this->input->get('link', '', 'post'));

// Verify that this is a local link
if (!$link || !Uri::isInternal($link))
if (!$model->validate($form, $data))
{
// Non-local url...
$this->setMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');
$errors = $model->getErrors();

foreach ($errors as $error)
{
$errorMessage = $error;

if ($error instanceof \Exception)
{
$errorMessage = $error->getMessage();
}

$this->app->enqueueMessage($errorMessage, 'error');
}

return $this->mailto();
}
Expand All @@ -86,24 +92,16 @@ public function send()
'cc:'
);

// An array of the input fields to scan for injected headers
$fields = array(
'mailto',
'sender',
'from',
'subject',
);

/*
* Here is the meat and potatoes of the header injection test. We
* iterate over the array of form input and check for header strings.
* If we find one, send an unauthorized header and die.
*/
foreach ($fields as $field)
foreach ($data as $key => $value)
{
foreach ($headers as $header)
{
if (strpos($this->input->post->getString($field), $header) !== false)
if (strpos($value, $header) !== false)
{
throw new \Exception('', 403);
}
Expand All @@ -115,25 +113,36 @@ public function send()
*/
unset($headers, $fields);

$email = $this->input->post->getString('mailto', '');
$sender = $this->input->post->getString('sender', '');
$from = $this->input->post->getString('from', '');
$subject_default = Text::sprintf('COM_MAILTO_SENT_BY', $sender);
$subject = $this->input->post->getString('subject', '') !== '' ? $this->input->post->getString('subject') : $subject_default;
$siteName = $this->app->get('sitename');
$link = MailtoHelper::validateHash($this->input->post->get('link', '', 'post'));

// Verify that this is a local link
if (!$link || !Uri::isInternal($link))
{
// Non-local url...
$this->app->enqueueMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'));

return $this->mailto();
}

$subject_default = Text::sprintf('COM_MAILTO_SENT_BY', $data['sender']);
$subject = $data['subject'] !== '' ? $data['subject'] : $subject_default;

// Check for a valid to address
$error = false;

if (!$email || !MailHelper::isEmailAddress($email))
if (!$data['emailto'] || !MailHelper::isEmailAddress($data['emailto']))
{
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $email);
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $data['emailto']);

$this->app->enqueueMessage($error, 'warning');
}

// Check for a valid from address
if (!$from || !MailHelper::isEmailAddress($from))
if (!$data['emailfrom'] || !MailHelper::isEmailAddress($data['emailfrom']))
{
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $from);
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $data['emailfrom']);

$this->app->enqueueMessage($error, 'warning');
}

Expand All @@ -144,21 +153,21 @@ public function send()

// Build the message to send
$msg = Text::_('COM_MAILTO_EMAIL_MSG');
$body = sprintf($msg, $SiteName, $sender, $from, $link);
$body = sprintf($msg, $siteName, $data['sender'], $data['emailfrom'], $link);

// Clean the email data
$subject = MailHelper::cleanSubject($subject);
$body = MailHelper::cleanBody($body);

// To send we need to use punycode.
$from = PunycodeHelper::emailToPunycode($from);
$from = MailHelper::cleanAddress($from);
$email = PunycodeHelper::emailToPunycode($email);
$data['emailfrom'] = PunycodeHelper::emailToPunycode($data['emailfrom']);
$data['emailfrom'] = MailHelper::cleanAddress($data['emailfrom']);
$data['emailto'] = PunycodeHelper::emailToPunycode($data['emailto']);

// Try to send the email
try
{
$return = Factory::getMailer()->sendMail($from, $sender, $email, $subject, $body);
$return = Factory::getMailer()->sendMail($data['emailfrom'], $data['sender'], $data['emailto'], $subject, $body);
}
catch (\Exception $exception)
{
Expand Down

0 comments on commit 0498252

Please sign in to comment.