Skip to content

Commit

Permalink
Merge pull request #687 from PeterMis/olbers-2.2.0-alpha2
Browse files Browse the repository at this point in the history
Olbers 2.2.0 alpha2
  • Loading branch information
PeterMis authored Sep 27, 2019
2 parents 0a79bd2 + 18bc0e0 commit 7ec4f8b
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

class AddSettingForTransitionAutoApplyToLayoutMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting for default value of layout->autoApplyTransitions checkbox
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DEFAULT_TRANSITION_AUTO_APPLY\'')) {
$this->table('setting')->insert([
[
'setting' => 'DEFAULT_TRANSITION_AUTO_APPLY',
'value' => 0,
'userSee' => 1,
'userChange' => 1
]
])->save();
}

$layoutTable = $this->table('layout');

// Add a new column to Layout table - autoApplyTransitions
if (!$layoutTable->hasColumn('autoApplyTransitions')) {
$layoutTable
->addColumn('autoApplyTransitions', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

class InstallSavedReportsAndSpacerModulesMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$modules = $this->table('module');

if (!$this->fetchRow('SELECT * FROM module WHERE module = \'savedreport\'')) {
$modules->insert([
'module' => 'savedreport',
'name' => 'Saved Reports',
'enabled' => 1,
'regionSpecific' => 0,
'description' => 'A saved report to be stored in the library',
'schemaVersion' => 1,
'previewEnabled' => 0,
'assignable' => 0,
'render_as' => null,
'class' => 'Xibo\Widget\SavedReport',
'defaultDuration' => 10,
'validExtensions' => 'json',
'installName' => 'savedreport'
])->save();
}

if (!$this->fetchRow('SELECT * FROM module WHERE module = \'spacer\'')) {
$modules->insert([
'module' => 'spacer',
'name' => 'Spacer',
'enabled' => 1,
'regionSpecific' => 1,
'description' => 'A module for making region empty for the duration',
'schemaVersion' => 1,
'previewEnabled' => 0,
'assignable' => 1,
'render_as' => 'hmtl',
'class' => 'Xibo\Widget\Spacer',
'defaultDuration' => 60,
'validExtensions' => null,
'installName' => 'spacer'
])->save();
}
}
}
12 changes: 12 additions & 0 deletions lib/Controller/DisplayProfileConfigFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ public function editConfigFields($displayProfile, $config = null)
$displayProfile->setSetting('xmrNetworkAddress', $this->getSanitizer()->getString('xmrNetworkAddress'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('dayPartId')) {
$displayProfile->setSetting('dayPartId', $this->getSanitizer()->getInt('dayPartId'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('statsEnabled')) {
$displayProfile->setSetting('statsEnabled', $this->getSanitizer()->getCheckbox('statsEnabled'), $ownConfig, $config);
}
Expand Down Expand Up @@ -330,6 +334,10 @@ public function editConfigFields($displayProfile, $config = null)
$displayProfile->setSetting('downloadEndWindow', $this->getSanitizer()->getString('downloadEndWindow'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('dayPartId')) {
$displayProfile->setSetting('dayPartId', $this->getSanitizer()->getInt('dayPartId'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('xmrNetworkAddress')) {
$displayProfile->setSetting('xmrNetworkAddress', $this->getSanitizer()->getString('xmrNetworkAddress'), $ownConfig, $config);
}
Expand Down Expand Up @@ -427,6 +435,10 @@ public function editConfigFields($displayProfile, $config = null)
$displayProfile->setSetting('downloadEndWindow', $this->getSanitizer()->getString('downloadEndWindow'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('dayPartId')) {
$displayProfile->setSetting('dayPartId', $this->getSanitizer()->getInt('dayPartId'), $ownConfig, $config);
}

if ($this->getSanitizer()->hasParam('xmrNetworkAddress')) {
$displayProfile->setSetting('xmrNetworkAddress', $this->getSanitizer()->getString('xmrNetworkAddress'), $ownConfig, $config);
}
Expand Down
24 changes: 24 additions & 0 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ function add()
$templateId = $this->getSanitizer()->getInt('layoutId');
$resolutionId = $this->getSanitizer()->getInt('resolutionId');
$enableStat = $this->getSanitizer()->getCheckbox('enableStat');
$autoApplyTransitions = $this->getSanitizer()->getCheckbox('autoApplyTransitions');

$template = null;

Expand Down Expand Up @@ -315,6 +316,9 @@ function add()
// Set layout enableStat flag
$layout->enableStat = $enableStat;

// Set auto apply transitions flag
$layout->autoApplyTransitions = $autoApplyTransitions;

// Save
$layout->save();

Expand Down Expand Up @@ -556,6 +560,7 @@ function editBackground($layoutId)
$layout->backgroundColor = $this->getSanitizer()->getString('backgroundColor');
$layout->backgroundImageId = $this->getSanitizer()->getInt('backgroundImageId');
$layout->backgroundzIndex = $this->getSanitizer()->getInt('backgroundzIndex');
$layout->autoApplyTransitions = $this->getSanitizer()->getCheckbox('autoApplyTransitions');

// Resolution
$saveRegions = false;
Expand Down Expand Up @@ -1038,6 +1043,24 @@ function grid()
// Add widget module type name
$widget->moduleName = $module->getModuleName();

// apply default transitions to a dynamic parameters on widget object.
if ($layout->autoApplyTransitions == 1) {
$widgetTransIn = $widget->getOptionValue('transIn', $this->getConfig()->getSetting('DEFAULT_TRANSITION_IN'));
$widgetTransOut = $widget->getOptionValue('transOut', $this->getConfig()->getSetting('DEFAULT_TRANSITION_OUT'));
$widgetTransInDuration = $widget->getOptionValue('transInDuration', $this->getConfig()->getSetting('DEFAULT_TRANSITION_DURATION'));
$widgetTransOutDuration = $widget->getOptionValue('transOutDuration', $this->getConfig()->getSetting('DEFAULT_TRANSITION_DURATION'));
} else {
$widgetTransIn = $widget->getOptionValue('transIn', null);
$widgetTransOut = $widget->getOptionValue('transOut', null);
$widgetTransInDuration = $widget->getOptionValue('transInDuration', null);
$widgetTransOutDuration = $widget->getOptionValue('transOutDuration', null);
}

$widget->transitionIn = $widgetTransIn;
$widget->transitionOut = $widgetTransOut;
$widget->transitionDurationIn = $widgetTransInDuration;
$widget->transitionDurationOut = $widgetTransOutDuration;

if (in_array('permissions', $embed)) {
// Augment with editable flag
$widget->isEditable = $this->getUser()->checkEditable($widget);
Expand Down Expand Up @@ -2165,6 +2188,7 @@ public function checkout($layoutId)
$draft->parentId = $layout->layoutId;
$draft->campaignId = $layout->campaignId;
$draft->publishedStatusId = 2; // Draft
$draft->autoApplyTransitions = $layout->autoApplyTransitions;

// Do not copy any of the tags, these will belong on the parent and are not editable from the draft.
$draft->tags = [];
Expand Down
3 changes: 0 additions & 3 deletions lib/Controller/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,6 @@ public function editWidgetTransitionForm($type, $widgetId)
'transitions' => [
'in' => $this->transitionFactory->getEnabledByType('in'),
'out' => $this->transitionFactory->getEnabledByType('out'),
'defaultTransitionDuration' => $this->getConfig()->getSetting('DEFAULT_TRANSITION_DURATION'),
'defaultTransitionIn' => $this->getConfig()->getSetting('DEFAULT_TRANSITION_IN'),
'defaultTransitionOut' => $this->getConfig()->getSetting('DEFAULT_TRANSITION_OUT'),
'compassPoints' => array(
array('id' => 'N', 'name' => __('North')),
array('id' => 'NE', 'name' => __('North East')),
Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ public function update()
$this->getConfig()->changeSetting('DEFAULT_TRANSITION_DURATION', $this->getSanitizer()->getInt('DEFAULT_TRANSITION_DURATION'));
}

if ($this->getConfig()->isSettingEditable('DEFAULT_TRANSITION_AUTO_APPLY')) {
$this->getConfig()->changeSetting('DEFAULT_TRANSITION_AUTO_APPLY', $this->getSanitizer()->getCheckbox('DEFAULT_TRANSITION_AUTO_APPLY'));
}

if ($this->getConfig()->isSettingEditable('DEFAULT_RESIZE_THRESHOLD')) {
$this->getConfig()->changeSetting('DEFAULT_RESIZE_THRESHOLD', $this->getSanitizer()->getInt('DEFAULT_RESIZE_THRESHOLD'));
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1077,14 +1077,15 @@ public function tfaSetup()

$issuerSettings = $this->getConfig()->getSetting('TWOFACTOR_ISSUER');
$appName = $this->getConfig()->getThemeConfig('app_name');
$quickChartUrl = $this->getConfig()->getSetting('QUICK_CHART_URL', 'https://quickchart.io');

if ($issuerSettings !== '') {
$issuer = $issuerSettings;
} else {
$issuer = $appName;
}

$tfa = new TwoFactorAuth($issuer, 6, 30, 'sha1', new QuickChartQRProvider());
$tfa = new TwoFactorAuth($issuer, 6, 30, 'sha1', new QuickChartQRProvider($quickChartUrl));

// create two factor secret and store it in user record
if (!isset($user->twoFactorSecret)) {
Expand Down
38 changes: 33 additions & 5 deletions lib/Entity/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ class Layout implements \JsonSerializable
*/
public $enableStat;

/**
* @var int
* @SWG\Property(
* description="Flag indicating whether the default transitions should be applied to this Layout"
* )
*/
public $autoApplyTransitions;

// Child items
/** @var Region[] */
public $regions = [];
Expand Down Expand Up @@ -966,6 +974,8 @@ public function replaceTags($tags = [])
/**
* Export the Layout as its XLF
* @return string
* @throws InvalidArgumentException
* @throws NotFoundException
* @throws XiboException
*/
public function toXlf()
Expand Down Expand Up @@ -1195,6 +1205,19 @@ public function toXlf()
}
}

// automatically set the transitions on the layout xml, we are not saving widgets here to avoid deadlock issues.
if ($this->autoApplyTransitions == 1) {
$widgetTransIn = $widget->getOptionValue('transIn', $this->config->getSetting('DEFAULT_TRANSITION_IN'));
$widgetTransOut = $widget->getOptionValue('transOut', $this->config->getSetting('DEFAULT_TRANSITION_OUT'));
$widgetTransInDuration = $widget->getOptionValue('transInDuration', $this->config->getSetting('DEFAULT_TRANSITION_DURATION'));
$widgetTransOutDuration = $widget->getOptionValue('transOutDuration', $this->config->getSetting('DEFAULT_TRANSITION_DURATION'));

$widget->setOptionValue('transIn', 'attrib', $widgetTransIn);
$widget->setOptionValue('transInDuration', 'attrib', $widgetTransInDuration);
$widget->setOptionValue('transOut', 'attrib', $widgetTransOut);
$widget->setOptionValue('transOutDuration', 'attrib', $widgetTransOutDuration);
}

// Set enable stat collection flag
$mediaNode->setAttribute('enableStat', $enableStat);

Expand Down Expand Up @@ -1493,6 +1516,8 @@ public function toZip($dataSetFactory, $fileName, $options = [])
* Save the XLF to disk if necessary
* @param array $options
* @return string the path
* @throws InvalidArgumentException
* @throws NotFoundException
* @throws XiboException
*/
public function xlfToDisk($options = [])
Expand Down Expand Up @@ -1738,8 +1763,8 @@ private function add()
{
$this->getLog()->debug('Adding Layout' . $this->layout);

$sql = 'INSERT INTO layout (layout, description, userID, createdDT, modifiedDT, publishedStatusId, status, width, height, schemaVersion, backgroundImageId, backgroundColor, backgroundzIndex, parentId, enableStat, duration)
VALUES (:layout, :description, :userid, :createddt, :modifieddt, :publishedStatusId, :status, :width, :height, 3, :backgroundImageId, :backgroundColor, :backgroundzIndex, :parentId, :enableStat, 0)';
$sql = 'INSERT INTO layout (layout, description, userID, createdDT, modifiedDT, publishedStatusId, status, width, height, schemaVersion, backgroundImageId, backgroundColor, backgroundzIndex, parentId, enableStat, duration, autoApplyTransitions)
VALUES (:layout, :description, :userid, :createddt, :modifieddt, :publishedStatusId, :status, :width, :height, 3, :backgroundImageId, :backgroundColor, :backgroundzIndex, :parentId, :enableStat, 0, :autoApplyTransitions)';

$time = $this->date->getLocalDate();

Expand All @@ -1757,7 +1782,8 @@ private function add()
'backgroundColor' => $this->backgroundColor,
'backgroundzIndex' => $this->backgroundzIndex,
'parentId' => ($this->parentId == null) ? null : $this->parentId,
'enableStat' => $this->enableStat
'enableStat' => $this->enableStat,
'autoApplyTransitions' => ($this->autoApplyTransitions == null) ? 0 : $this->autoApplyTransitions
));

// Add a Campaign
Expand Down Expand Up @@ -1828,7 +1854,8 @@ private function update($options = [])
`userId` = :userId,
`schemaVersion` = :schemaVersion,
`statusMessage` = :statusMessage,
enableStat = :enableStat
enableStat = :enableStat,
autoApplyTransitions = :autoApplyTransitions
WHERE layoutID = :layoutid
';

Expand All @@ -1851,7 +1878,8 @@ private function update($options = [])
'userId' => $this->ownerId,
'schemaVersion' => $this->schemaVersion,
'statusMessage' => (empty($this->statusMessage)) ? null : json_encode($this->statusMessage),
'enableStat' => $this->enableStat
'enableStat' => $this->enableStat,
'autoApplyTransitions' => $this->autoApplyTransitions
));

// Update the Campaign
Expand Down
24 changes: 24 additions & 0 deletions lib/Entity/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ class Widget implements \JsonSerializable
*/
public $toDt;

/**
* @SWG\Property(description="Transition Type In")
* @var int
*/
public $transitionIn;

/**
* @SWG\Property(description="Transition Type out")
* @var int
*/
public $transitionOut;

/**
* @SWG\Property(description="Transition duration in")
* @var int
*/
public $transitionDurationIn;

/**
* @SWG\Property(description="Transition duration out")
* @var int
*/
public $transitionDurationOut;

/**
* @SWG\Property(description="An array of Widget Options")
* @var WidgetOption[]
Expand Down
Loading

0 comments on commit 7ec4f8b

Please sign in to comment.