Skip to content

Commit 80b6469

Browse files
committed
Merge branch '4.4' into 4.9
# Conflicts: # installation-bundle/src/Resources/translations/messages.fr.xlf # news-bundle/src/Resources/contao/dca/tl_news.php
2 parents d19cb6c + 24b1d71 commit 80b6469

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

news-bundle/src/Resources/contao/dca/tl_news.php

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,14 +973,47 @@ public function toggleFeatured($intId, $blnVisible, Contao\DataContainer $dc=nul
973973
Contao\Input::setGet('id', $intId);
974974
Contao\Input::setGet('act', 'feature');
975975

976-
$this->checkPermission();
976+
if ($dc)
977+
{
978+
$dc->id = $intId; // see #8043
979+
}
980+
981+
// Trigger the onload_callback
982+
if (is_array($GLOBALS['TL_DCA']['tl_news']['config']['onload_callback']))
983+
{
984+
foreach ($GLOBALS['TL_DCA']['tl_news']['config']['onload_callback'] as $callback)
985+
{
986+
if (is_array($callback))
987+
{
988+
$this->import($callback[0]);
989+
$this->{$callback[0]}->{$callback[1]}($dc);
990+
}
991+
elseif (is_callable($callback))
992+
{
993+
$callback($dc);
994+
}
995+
}
996+
}
977997

978998
// Check permissions to feature
979999
if (!$this->User->hasAccess('tl_news::featured', 'alexf'))
9801000
{
9811001
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to feature/unfeature news item ID ' . $intId . '.');
9821002
}
9831003

1004+
// Set the current record
1005+
if ($dc)
1006+
{
1007+
$objRow = $this->Database->prepare("SELECT * FROM tl_news WHERE id=?")
1008+
->limit(1)
1009+
->execute($intId);
1010+
1011+
if ($objRow->numRows)
1012+
{
1013+
$dc->activeRecord = $objRow;
1014+
}
1015+
}
1016+
9841017
$objVersions = new Contao\Versions('tl_news', $intId);
9851018
$objVersions->initialize();
9861019

@@ -1001,10 +1034,35 @@ public function toggleFeatured($intId, $blnVisible, Contao\DataContainer $dc=nul
10011034
}
10021035
}
10031036

1037+
$time = time();
1038+
10041039
// Update the database
10051040
$this->Database->prepare("UPDATE tl_news SET tstamp=" . time() . ", featured='" . ($blnVisible ? 1 : '') . "' WHERE id=?")
10061041
->execute($intId);
10071042

1043+
if ($dc)
1044+
{
1045+
$dc->activeRecord->tstamp = $time;
1046+
$dc->activeRecord->published = ($blnVisible ? '1' : '');
1047+
}
1048+
1049+
// Trigger the onsubmit_callback
1050+
if (is_array($GLOBALS['TL_DCA']['tl_news']['config']['onsubmit_callback']))
1051+
{
1052+
foreach ($GLOBALS['TL_DCA']['tl_news']['config']['onsubmit_callback'] as $callback)
1053+
{
1054+
if (is_array($callback))
1055+
{
1056+
$this->import($callback[0]);
1057+
$this->{$callback[0]}->{$callback[1]}($dc);
1058+
}
1059+
elseif (is_callable($callback))
1060+
{
1061+
$callback($dc);
1062+
}
1063+
}
1064+
}
1065+
10081066
$objVersions->create();
10091067
}
10101068

0 commit comments

Comments
 (0)