Skip to content

Commit

Permalink
Merge pull request #408 from xibosignage/release18
Browse files Browse the repository at this point in the history
Release 1.8.11
  • Loading branch information
dasgarner authored Aug 21, 2018
2 parents 64be3d6 + 6b2d364 commit a8e1ad7
Show file tree
Hide file tree
Showing 118 changed files with 5,772 additions and 4,531 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PA
# Setup persistent environment variables
ENV CMS_DEV_MODE=false \
XMR_HOST=xmr \
CMS_DB_VERSION=141 \
CMS_DB_VERSION=142 \
CMS_SERVER_NAME=localhost \
MYSQL_HOST=mysql \
MYSQL_USER=cms \
Expand Down Expand Up @@ -155,5 +155,6 @@ VOLUME /var/www/cms/custom
VOLUME /var/www/cms/web/theme/custom
VOLUME /var/www/backup
VOLUME /var/www/cms/web/userscripts
VOLUME /var/www/cms/ca-certs

CMD ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion cypress/integration/unauthed_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Unauthenticated CMS access', function () {

cy.url().should('include', '/login');

cy.contains('Version 1.8.10');
cy.contains('Version 1.8.11');
});

it('should redirect to login when an authenticated page is requested', function() {
Expand Down
6 changes: 6 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ then

SECRET_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)
/bin/sed -i "s/define('SECRET_KEY','');/define('SECRET_KEY','$SECRET_KEY');/" /var/www/cms/web/settings.php

# Import any ca-certificate files that might be needed to use a proxy etc
echo "Importing ca-certs"
cp -v /var/www/cms/ca-certs/*.pem /usr/local/share/ca-certificates
cp -v /var/www/cms/ca-certs/*.crt /var/local/share/ca-certificates
/usr/sbin/update-ca-certificates
fi

if [ "$CMS_DEV_MODE" == "false" ]
Expand Down
19 changes: 18 additions & 1 deletion install/master/constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,21 @@ CREATE INDEX lkdgdg_parentId_childId_depth_index ON lkdgdg (parentId, childId, d

CREATE INDEX lkdgdg_childId_parentId_depth_index ON lkdgdg (childId, parentId, depth);

CREATE INDEX media_editedMediaID_index ON media (editedMediaID);
CREATE INDEX media_editedMediaID_index ON media (editedMediaID);

# Tag foreign keys
ALTER TABLE `lktagcampaign` ADD CONSTRAINT `lktagcampaign_ibfk_1` FOREIGN KEY (`campaignId`) REFERENCES `campaign` (`campaignId`);
ALTER TABLE `lktaglayout` ADD CONSTRAINT `lktaglayout_ibfk_1` FOREIGN KEY (`layoutId`) REFERENCES `layout` (`layoutId`);
ALTER TABLE `lktagmedia` ADD CONSTRAINT `lktagmedia_ibfk_1` FOREIGN KEY (`mediaId`) REFERENCES `media` (`mediaId`);
ALTER TABLE `lktagdisplaygroup` ADD CONSTRAINT `lktagdisplaygroup_ibfk_1` FOREIGN KEY (`displayGroupId`) REFERENCES `displaygroup` (`displayGroupId`);

# Permissions foreign keys and index
CREATE INDEX permission_objectId_index ON permission (objectId);

ALTER TABLE permission
ADD CONSTRAINT permission_group_groupID_fk
FOREIGN KEY (groupId) REFERENCES `group` (groupID);

ALTER TABLE permission
ADD CONSTRAINT permission_permissionentity_entityId_fk
FOREIGN KEY (entityId) REFERENCES permissionentity (entityId);
5 changes: 3 additions & 2 deletions install/master/data.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INSERT INTO `version` (`app_ver`, `XmdsVersion`, `XlfVersion`, `DBVersion`) VALUES
('1.8.10', 5, 2, 141);
('1.8.11', 5, 2, 142);

INSERT INTO `group` (`groupID`, `group`, `IsUserSpecific`, `IsEveryone`, `isSystemNotification`) VALUES
(1, 'Users', 0, 0, 0),
Expand Down Expand Up @@ -238,7 +238,8 @@ INSERT INTO `setting` (`settingid`, `setting`, `value`, `fieldType`, `helptext`,
(99, 'LATEST_NEWS_URL', 'http://xibo.org.uk/feed', 'text', 'RSS/Atom Feed to be displayed on the Status Dashboard', '', 'general', 0, 'Latest News URL', '', 111, '', 0, 'string'),
(100, 'DISPLAY_LOCK_NAME_TO_DEVICENAME', '0', 'checkbox', NULL, NULL, 'displays', 1, 'Lock the Display Name to the device name provided by the Player?', '', 80, '0', 1, 'checkbox'),
(101, 'mail_from_name', '', 'text', 'Mail will be sent under this name', null, 'maintenance', 1, 'Sending email name', '', 45, '', 1, 'string'),
(102, 'SCHEDULE_SHOW_LAYOUT_NAME', '0', 'checkbox', 'If checked then the Schedule will show the Layout for existing events even if the logged in User does not have permission to see that Layout.', null, 'permissions', 1, 'Show event Layout regardless of User permission?', '', 45, '', 1, 'checkbox');
(102, 'SCHEDULE_SHOW_LAYOUT_NAME', '0', 'checkbox', 'If checked then the Schedule will show the Layout for existing events even if the logged in User does not have permission to see that Layout.', null, 'permissions', 1, 'Show event Layout regardless of User permission?', '', 45, '', 1, 'checkbox'),
(103, 'DEFAULT_USERGROUP', '1', 'text', 'The default User Group for new Users', '1', 'users', 1, 'Default User Group', '', 4, '', 1, 'int');

INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES
(1, 'Super Admin'),
Expand Down
15 changes: 15 additions & 0 deletions install/steps/142.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dbVersion": 142,
"appVersion": "1.8.11",
"steps": [
{
"step": "Fix database constraints and indexes",
"type": "php",
"action": "Xibo\\Upgrade\\FixDatabaseIndexesAndContraints"
},
{
"step": "Default User Group Setting",
"action": "INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES ('DEFAULT_USERGROUP', '1', 'text', 'The default User Group for new Users', '1', 'users', 1, 'Default User Group', '', 4, '', 1, 'int'); "
}
]
}
10 changes: 5 additions & 5 deletions lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ public function authoriseForm($displayId)
* Toggle Authorise on this Display
* @param int $displayId
*
* @SWG\Post(
* @SWG\Put(
* path="/display/authorise/{displayId}",
* operationId="displayToggleAuthorise",
* tags={"display"},
Expand Down Expand Up @@ -1477,7 +1477,7 @@ public function toggleAuthorise($displayId)

// Return
$this->getState()->hydrate([
'message' => sprintf(__('Default Layout set for %s'), $display->display),
'message' => sprintf(__('Authorised set to %d for %s'), $display->licensed, $display->display),
'id' => $display->displayId
]);
}
Expand Down Expand Up @@ -1511,12 +1511,12 @@ public function defaultLayoutForm($displayId)
* Set the Default Layout for this Display
* @param int $displayId
*
* @SWG\Post(
* @SWG\Put(
* path="/display/defaultlayout/{displayId}",
* operationId="displayDefaultLayout",
* tags={"display"},
* summary="Set Default Layout",
* description="Sent the default Layout on this Display",
* description="Set the default Layout on this Display",
* @SWG\Parameter(
* name="displayId",
* in="path",
Expand Down Expand Up @@ -1559,7 +1559,7 @@ public function setDefaultLayout($displayId)

// Return
$this->getState()->hydrate([
'message' => sprintf(__('Default Layout set for %s'), $display->display),
'message' => sprintf(__('Default Layout with name %s set for %s'), $layout->layout, $display->display),
'id' => $display->displayId
]);
}
Expand Down
65 changes: 47 additions & 18 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
namespace Xibo\Controller;

use Stash\Interfaces\PoolInterface;
use Stash\Invalidation;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Xibo\Entity\Media;
use Xibo\Entity\Widget;
use Xibo\Exception\AccessDeniedException;
Expand Down Expand Up @@ -66,6 +68,9 @@ class Library extends Base
/** @var PoolInterface */
private $pool;

/** @var EventDispatcherInterface */
private $dispatcher;

/**
* @var UserFactory
*/
Expand Down Expand Up @@ -140,6 +145,7 @@ class Library extends Base
* @param ConfigServiceInterface $config
* @param StorageServiceInterface $store
* @param PoolInterface $pool
* @param EventDispatcherInterface $dispatcher
* @param UserFactory $userFactory
* @param ModuleFactory $moduleFactory
* @param TagFactory $tagFactory
Expand All @@ -156,7 +162,7 @@ class Library extends Base
* @param ScheduleFactory $scheduleFactory
* @param DayPartFactory $dayPartFactory
*/
public function __construct($log, $sanitizerService, $state, $user, $help, $date, $config, $store, $pool, $userFactory, $moduleFactory, $tagFactory, $mediaFactory, $widgetFactory, $permissionFactory, $layoutFactory, $playlistFactory, $userGroupFactory, $displayGroupFactory, $regionFactory, $dataSetFactory, $displayFactory, $scheduleFactory, $dayPartFactory)
public function __construct($log, $sanitizerService, $state, $user, $help, $date, $config, $store, $pool, $dispatcher, $userFactory, $moduleFactory, $tagFactory, $mediaFactory, $widgetFactory, $permissionFactory, $layoutFactory, $playlistFactory, $userGroupFactory, $displayGroupFactory, $regionFactory, $dataSetFactory, $displayFactory, $scheduleFactory, $dayPartFactory)
{
$this->setCommonDependencies($log, $sanitizerService, $state, $user, $help, $date, $config);

Expand All @@ -165,6 +171,7 @@ public function __construct($log, $sanitizerService, $state, $user, $help, $date
$this->mediaFactory = $mediaFactory;
$this->widgetFactory = $widgetFactory;
$this->pool = $pool;
$this->dispatcher = $dispatcher;
$this->userFactory = $userFactory;
$this->tagFactory = $tagFactory;
$this->permissionFactory = $permissionFactory;
Expand All @@ -179,6 +186,15 @@ public function __construct($log, $sanitizerService, $state, $user, $help, $date
$this->dayPartFactory = $dayPartFactory;
}

/**
* Get Dispatcher
* @return EventDispatcherInterface
*/
public function getDispatcher()
{
return $this->dispatcher;
}

/**
* Get Module Factory
* @return ModuleFactory
Expand Down Expand Up @@ -395,6 +411,7 @@ function grid()
$mediaList = $this->mediaFactory->query($this->gridRenderSort(), $this->gridRenderFilter([
'mediaId' => $this->getSanitizer()->getInt('mediaId'),
'name' => $this->getSanitizer()->getString('media'),
'nameExact' => $this->getSanitizer()->getString('nameExact'),
'type' => $this->getSanitizer()->getString('type'),
'tags' => $this->getSanitizer()->getString('tags'),
'exactTags' => $this->getSanitizer()->getCheckbox('exactTags'),
Expand Down Expand Up @@ -442,11 +459,20 @@ function grid()
}

if ($user->checkDeleteable($media)) {
// Delete
// Delete Button
$media->buttons[] = array(
'id' => 'content_button_delete',
'url' => $this->urlFor('library.delete.form', ['id' => $media->mediaId]),
'text' => __('Delete')
'text' => __('Delete'),
'multi-select' => true,
'dataAttributes' => array(
array('name' => 'commit-url', 'value' => $this->urlFor('library.delete', ['id' => $media->mediaId])),
array('name' => 'commit-method', 'value' => 'delete'),
array('name' => 'id', 'value' => 'content_button_delete'),
array('name' => 'text', 'value' => __('Delete')),
array('name' => 'rowtitle', 'value' => $media->name),
['name' => 'form-callback', 'value' => 'setDefaultMultiSelectFormOpen']
)
);
}

Expand Down Expand Up @@ -1088,13 +1114,17 @@ public function installFonts($options = [])
// Each user has their own font cache (due to permissions) and the displays have their own font cache too
// Get the item from the cache
$cssItem = $this->pool->getItem('fontCss/' . $this->getUser()->userId);
$cssItem->setInvalidationMethod(Invalidation::SLEEP, 5000, 15);

// Get the CSS
$cssDetails = $cssItem->get();

if ($options['invalidateCache'] || $cssItem->isMiss()) {
$this->getLog()->debug('Regenerating font cache');

// lock the cache
$cssItem->lock(60);

// Go through all installed fonts each time and regenerate.
$fontTemplate = '@font-face {
font-family: \'[family]\';
Expand Down Expand Up @@ -1155,24 +1185,23 @@ public function installFonts($options = [])
$existingLibraryFontsCss = file_get_contents($libraryLocation . 'fonts.css');
}

// Check to see if the existing file is different from the new one
if (md5($existingLibraryFontsCss) !== md5($css)) {
$this->getLog()->info('Detected change in fonts.css file, saving to the library and notifying displays');
// Put the player CSS into the temporary library location
$tempUrl = $this->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/fonts.css';
file_put_contents($tempUrl, $css);

// Put the player CSS into the temporary library location
$tempUrl = $this->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/fonts.css';
file_put_contents($tempUrl, $css);
// Install it (doesn't expire, isn't a system file, force update)
$media = $this->mediaFactory->createModuleSystemFile('fonts.css', $tempUrl);
$media->expires = 0;
$media->moduleSystemFile = true;
$media->isSaveRequired = true;
$media->save();

// Install it (doesn't expire, isn't a system file, force update)
$media = $this->mediaFactory->createModuleSystemFile('fonts.css', $tempUrl);
$media->expires = 0;
$media->moduleSystemFile = true;
$media->isSaveRequired = true;
$media->save();

// We can remove the temp file
@unlink($tempUrl);
// We can remove the temp file
@unlink($tempUrl);

// Check to see if the existing file is different from the new one
if ($existingLibraryFontsCss == '' || md5($existingLibraryFontsCss) !== $media->md5) {
$this->getLog()->info('Detected change in fonts.css file, dropping the Display cache');
// Clear the display cache
$this->pool->deleteItem('/display');
} else {
Expand Down
17 changes: 13 additions & 4 deletions lib/Controller/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ public function exportForm()

/**
* Backup the Database
* @throws ConfigurationException
* @throws ControllerNotImplemented
*/
public function export()
{
Expand All @@ -377,28 +379,35 @@ public function export()
global $dbpass;
global $dbname;

// split the dbhost for database host name and port
if (strstr($dbhost, ':')) {
$hostParts = explode(':', $dbhost);
$dbhostName = $hostParts[0];
$dbhostPort = $hostParts[1];
}

// get temporary file
$libraryLocation = $this->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/';
$fileNameStructure = $libraryLocation . 'structure.dump';
$fileNameData = $libraryLocation . 'data.dump';
$zipFile = $libraryLocation . 'database.tar.gz';

// Run mysqldump structure to a temporary file
$command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --no-data > ' . escapeshellarg($fileNameStructure) . ' ';
$command = 'mysqldump --opt --host=' . $dbhostName . ' --port=' . $dbhostPort . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --no-data > ' . escapeshellarg($fileNameStructure) . ' ';
exec($command);

// Run mysqldump data to a temporary file
$command = 'mysqldump --opt --host=' . $dbhost . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --ignore-table=' . $dbname . '.log --ignore-table=' . $dbname . '.oauth_log > ' . escapeshellarg($fileNameData) . ' ';
$command = 'mysqldump --opt --host=' . $dbhostName . ' --port=' . $dbhostPort . ' --user=' . $dbuser . ' --password=' . addslashes($dbpass) . ' ' . $dbname . ' --ignore-table=' . $dbname . '.log --ignore-table=' . $dbname . '.oauth_log > ' . escapeshellarg($fileNameData) . ' ';
exec($command);

// Check it worked
if (!file_exists($fileNameStructure) || !file_exists($fileNameData))
if (filesize($fileNameStructure) <= 0 || filesize($fileNameData) <= 0 )
throw new ConfigurationException(__('Database dump failed.'));

// Zippy
$this->getLog()->debug($zipFile);
$zip = new \ZipArchive();
$zip->open($zipFile, \ZipArchive::OVERWRITE);
$zip->open($zipFile, \ZipArchive::CREATE|\ZipArchive::OVERWRITE);
$zip->addFile($fileNameStructure, 'structure.dump');
$zip->addFile($fileNameData, 'data.dump');
$zip->close();
Expand Down
Loading

0 comments on commit a8e1ad7

Please sign in to comment.