Skip to content

Commit

Permalink
Merge branch '5.7.x' of github.com:concrete5/concrete5 into 5.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
aembler committed Dec 6, 2016
2 parents 111b82f + 21bc3c4 commit d16f74f
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 142 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
# 5.7.5.10

* Minor bug fixes
* Fixed insecure use of non-random str_shuffle when creating user tokens
* Improvements to update process for version 8.

# 5.7.5.9

## New Features
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/build-release/download.js
@@ -1,5 +1,5 @@
module.exports = function(grunt, config, parameters, done) {
var zipUrl = parameters.releaseSourceZip || 'https://github.com/concrete5/concrete5/archive/5.7.x.zip';
var zipUrl = parameters.releaseSourceZip || 'https://github.com/concrete5/concrete5/archive/release/5.7.5.10.zip';
var workFolder = parameters.releaseWorkFolder || './release';
function endForError(e) {
process.stderr.write(e.message || e);
Expand Down
4 changes: 2 additions & 2 deletions web/concrete/attributes/select/option.php
Expand Up @@ -113,9 +113,9 @@ public static function exportTranslations()
$r = $db->Execute('select ID from atSelectOptions order by ID asc');
while ($row = $r->FetchRow()) {
$opt = static::getByID($row['ID']);
$translations->insert('SelectAttributeValue', $opt->getSelectAttributeOptionValue());
$translations->insert('SelectAttributeValue', $opt->getSelectAttributeOptionValue(false));
}
return $translations;
}

}
}
4 changes: 4 additions & 0 deletions web/concrete/blocks/core_stack_display/controller.php
Expand Up @@ -78,6 +78,10 @@ public function isValidControllerTask($method, $parameters = array())

public function runAction($action, $parameters = array())
{
if ('on_page_view' === $action) {
$this->on_page_view($parameters[0]);
}

$b = $this->findBlockForAction($action, $parameters);
if (empty($b)) {
return;
Expand Down
8 changes: 4 additions & 4 deletions web/concrete/blocks/share_this_page/controller.php
Expand Up @@ -15,9 +15,9 @@ class Controller extends BlockController
public $helpers = array('form');

protected $btInterfaceWidth = 400;
protected $btCacheBlockOutput = true;
protected $btCacheBlockOutputOnPost = true;
protected $btCacheBlockOutputForRegisteredUsers = true;
protected $btCacheBlockOutput = false;
protected $btCacheBlockOutputOnPost = false;
protected $btCacheBlockOutputForRegisteredUsers = false;
protected $btInterfaceHeight = 400;
protected $btTable = 'btShareThisPage';

Expand Down Expand Up @@ -60,7 +60,7 @@ public function addService($service)

protected function getSelectedServices()
{
$links = array();
$this->services = array();
$db = Database::get();
$services = $db->GetCol('select service from btShareThisPage where bID = ? order by displayOrder asc',
array($this->bID)
Expand Down
12 changes: 7 additions & 5 deletions web/concrete/blocks/switch_language/controller.php
Expand Up @@ -80,18 +80,20 @@ public function view()
$c = \Page::getCurrentPage();
$al = Section::getBySectionOfSite($c);
$languages = array();
$locale = \Localization::activeLocale();
if (is_object($al)) {
$locale = null;
if ($al) {
$locale = $al->getLanguage();
}
if (!$locale) {
$locale = \Localization::activeLocale();
$al = Section::getByLocale($locale);
}
foreach ($ml as $m) {
$languages[$m->getCollectionID()] = $m->getLanguageText($locale);
}
$this->set('languages', $languages);
$this->set('languageSections', $ml);
if (is_object($al)) {
$this->set('activeLanguage', $al->getCollectionID());
}
$this->set('activeLanguage', $al? $al->getCollectionID() : null);
$dl = \Core::make('multilingual/detector');
$this->set('defaultLocale', $dl->getPreferredSection());
$this->set('locale', $locale);
Expand Down
4 changes: 2 additions & 2 deletions web/concrete/config/concrete.php
Expand Up @@ -7,8 +7,8 @@
*
* @var string
*/
'version' => '5.7.5.10b1',
'version_installed' => '5.7.5.10b1',
'version' => '5.7.5.10',
'version_installed' => '5.7.5.10',
'version_db' => '20160615000000', // the key of the latest database migration

/**
Expand Down
5 changes: 4 additions & 1 deletion web/concrete/elements/page_controls_header.php
Expand Up @@ -29,8 +29,11 @@

$editMode = $c->isEditMode();
$tools = REL_DIR_FILES_TOOLS_REQUIRED;
$htmlTagClasses = 'ccm-toolbar-visible';

if ($c->isEditMode()) {
$startEditMode = 'new Concrete.EditMode();';
$htmlTagClasses .= ' ccm-edit-mode';
} else {
$startEditMode = '';
}
Expand All @@ -51,7 +54,7 @@

$js = <<<EOL
<script type="text/javascript">$(function() {
$('html').addClass('ccm-toolbar-visible');
$('html').addClass('$htmlTagClasses');
ConcretePanelManager.register({'identifier': 'dashboard', 'position': 'right', url: '{$panelDashboard}'});
ConcretePanelManager.register({'identifier': 'page', url: '{$panelPage}'});
ConcretePanelManager.register({'identifier': 'sitemap', 'position': 'right', url: '{$panelSitemap}'});
Expand Down
4 changes: 2 additions & 2 deletions web/concrete/src/Application/Application.php
Expand Up @@ -292,6 +292,8 @@ public function setupPackages()
}
$pkg->setupPackageLocalization();
}
$config->set('app.bootstrap.packages_loaded', true);
\Localization::setupSiteLocalization();
foreach($this->packages as $pkg) {
if (method_exists($pkg, 'on_start')) {
$pkg->on_start();
Expand All @@ -300,8 +302,6 @@ public function setupPackages()
$checkAfterStart = true;
}
}
$config->set('app.bootstrap.packages_loaded', true);
\Localization::setupSiteLocalization();

if ($checkAfterStart) {
foreach($this->packages as $pkg) {
Expand Down
6 changes: 5 additions & 1 deletion web/concrete/src/Block/BlockController.php
Expand Up @@ -480,7 +480,11 @@ public function isValidControllerTask($method, $parameters = array())
// how do we get <= 1? If it's 1, that means that the method has one fewer param. That's ok because
// certain older blocks don't know that the last param ought to be a $bID. If they're equal it's zero
// which is best. and if they're greater that's ok too.
return true;
// Now let's see if the action is for this block instance
$bID = array_pop($parameters);
if ((is_string($bID) || is_int($bID)) && $bID == $this->bID) {
return true;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/concrete/src/File/Image/BasicThumbnailer.php
Expand Up @@ -107,7 +107,7 @@ public function getThumbnail($obj, $maxWidth, $maxHeight, $crop = false) {
$src = REL_DIR_FILES_CACHE . '/' . $filename;
$abspath = Config::get('concrete.cache.directory') . '/' . $filename;
$thumb = new \stdClass;
if (isset($abspath) && file_exists($abspath)) {
if (isset($abspath) && is_file($abspath)) {
$thumb->src = $src;
$dimensions = getimagesize($abspath);
$thumb->width = $dimensions[0];
Expand Down
49 changes: 27 additions & 22 deletions web/concrete/src/Foundation/EnvironmentDetector.php
Expand Up @@ -21,14 +21,14 @@ class EnvironmentDetector {
*/
public function detect($environments, $consoleArgs = null)
{
if ($consoleArgs)
{
return $this->detectConsoleEnvironment($environments, $consoleArgs);
}
else
{
return $this->detectVariableEnvironment($environments);
if ($consoleArgs && $env = $this->detectConsoleEnvironment($environments, $consoleArgs)) {
return $env;
} elseif ($env = $this->detectClosureEnvironment($environments)) {
return $env;
} elseif ($env = $this->detectVariableEnvironment($environments)) {
return $env;
}
return $this->detectWebEnvironment($environments);
}

/**
Expand All @@ -39,14 +39,6 @@ public function detect($environments, $consoleArgs = null)
*/
protected function detectWebEnvironment($environments)
{
// If the given environment is just a Closure, we will defer the environment check
// to the Closure the developer has provided, which allows them to totally swap
// the webs environment detection logic with their own custom Closure's code.
if ($environments instanceof Closure)
{
return call_user_func($environments);
}

foreach ($environments as $environment => $hosts)
{
// To determine the current environment, we'll simply iterate through the possible
Expand Down Expand Up @@ -77,10 +69,6 @@ protected function detectConsoleEnvironment($environments, array $args)
{
return head(array_slice(explode('=', $value), 1));
}
else
{
return $this->detectVariableEnvironment($environments);
}
}

/**
Expand All @@ -93,11 +81,28 @@ protected function detectVariableEnvironment($environments)
{
if (($env = $this->getEnvironmentFromVariable()) !== false) {
return $env;
} else {
return $this->detectWebEnvironment($environments);
}
}

/**
* Set the application environment from the passed closure in case a closure
* was passed.
*
* @param mixed $environments
*
* @return string|null
*/
protected function detectClosureEnvironment($environments)
{
// If the given environment is just a Closure, we will defer the environment check
// to the Closure the developer has provided, which allows them to totally swap
// the webs environment detection logic with their own custom Closure's code.
if ($environments instanceof Closure) {
return call_user_func($environments);
}
}


/**
* Get the environment argument from the console.
*
Expand All @@ -114,7 +119,7 @@ protected function getEnvironmentArgument(array $args)

/**
* Gets the environment from the CONCRETE5_ENV environment variable.
*
*
* @return string|bool
*/
protected function getEnvironmentFromVariable()
Expand Down
6 changes: 6 additions & 0 deletions web/concrete/src/Mail/Service.php
Expand Up @@ -395,6 +395,8 @@ public function setAdditionalHeaders($headers)
* @param bool $resetData Whether or not to reset the service to its default values.
*
* @throws \Exception
*
* @return bool
*/
public function sendMail($resetData = true)
{
Expand Down Expand Up @@ -492,10 +494,12 @@ public function sendMail($resetData = true)
}
$mail->setBody($body);

$sent = false;
try {
if (Config::get('concrete.email.enabled')) {
$transport->send($mail);
}
$sent = true;
} catch (Exception $e) {
if ($this->getTesting()) {
throw $e;
Expand Down Expand Up @@ -533,5 +537,7 @@ public function sendMail($resetData = true)
if ($resetData) {
$this->reset();
}

return $sent;
}
}
55 changes: 30 additions & 25 deletions web/concrete/src/Multilingual/Service/Detector.php
Expand Up @@ -71,32 +71,37 @@ public static function getPreferredSection()

public static function setupSiteInterfaceLocalization(Page $c = null)
{
if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
return;
}
if (!$c) {
$c = Page::getCurrentPage();
}
// don't translate dashboard pages
$dh = \Core::make('helper/concrete/dashboard');
if ($dh->inDashboard($c)) {
return;
}

$ms = Section::getBySectionOfSite($c);
if (!is_object($ms)) {
$ms = static::getPreferredSection();
}

if (!$ms) {
return;
}

$locale = $ms->getLocale();

if (strlen($locale)) {
\Localization::changeLocale($locale);
$loc = \Localization::getInstance();
if (!(\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale'))) {
if (!$c) {
$c = Page::getCurrentPage();
}
// don't translate dashboard pages
$dh = \Core::make('helper/concrete/dashboard');
if ($dh->inDashboard($c)) {
return;
}
$locale = null;
$ms = Section::getBySectionOfSite($c);
if ($ms) {
$locale = $ms->getLocale();
}
if (!$locale) {
if (Config::get('concrete.multilingual.use_previous_locale') && Session::has('previous_locale')) {
$locale = Session::get('previous_locale');
}
if (!$locale) {
$ms = static::getPreferredSection();
if ($ms) {
$locale = $ms->getLocale();
}
}
}
if ($locale) {
$loc->setLocale($locale);
}
}
Session::set('previous_locale', $loc->getLocale());
}

public static function isEnabled()
Expand Down
4 changes: 2 additions & 2 deletions web/concrete/src/Page/CustomStyle.php
Expand Up @@ -15,9 +15,9 @@ class CustomStyle
protected $presetHandle;
protected $sccRecordID;

public function setThemeID($ptThemeID)
public function setThemeID($pThemeID)
{
$this->ptThemeID = $ptThemeID;
$this->pThemeID = $pThemeID;
}

public function setValueListID($valueListID)
Expand Down
16 changes: 12 additions & 4 deletions web/concrete/src/Page/Page.php
Expand Up @@ -48,6 +48,9 @@ class Page extends Collection implements \Concrete\Core\Permission\ObjectInterfa
protected $blocksAliasedFromMasterCollection = null;
protected $cIsSystemPage = false;
protected $cPointerOriginalID = null;

public $cParentID;

/**
* @param string $path /path/to/page
* @param string $version ACTIVE or RECENT
Expand Down Expand Up @@ -401,16 +404,21 @@ public function isCheckedOut()
return $this->isCheckedOutCache;
}

$dh = Core::make('helper/date');

$q = 'select cIsCheckedOut, '.$dh->getOverridableNow(true)." - UNIX_TIMESTAMP(cCheckedOutDatetimeLastEdit) as timeout from Pages where cID = '{$this->cID}'";
$q = "select cIsCheckedOut, cCheckedOutDatetimeLastEdit from Pages where cID = '{$this->cID}'";
$r = $db->executeQuery($q);

// If cCheckedOutDatetimeLastEdit is present, get the time span in seconds since it's last edit.
if (! empty($row['cCheckedOutDatetimeLastEdit'])) {
$dh = Core::make('helper/date');
$timeSinceCheckout = ($dh->getOverridableNow(true) - strtotime($row['cCheckedOutDatetimeLastEdit']));
}

if ($r) {
$row = $r->fetchRow();
if ($row['cIsCheckedOut'] == 0) {
return false;
} else {
if ($row['timeout'] > CHECKOUT_TIMEOUT) {
if (isset($timeSinceCheckout) && $timeSinceCheckout > CHECKOUT_TIMEOUT) {
$this->forceCheckIn();
$this->isCheckedOutCache = false;

Expand Down

0 comments on commit d16f74f

Please sign in to comment.