Make disable hub, into enable hub to match the checkbox state.
Implemented write access check HFP-502pull/38/head
parent
ff531a157c
commit
aa861fc8ce
|
@ -386,6 +386,31 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if server setup has write permission to
|
||||
* the required folders
|
||||
*
|
||||
* @return bool True if server has the proper write access
|
||||
*/
|
||||
public function hasWriteAccess() {
|
||||
$dirs = array(
|
||||
'/content',
|
||||
'/libraries',
|
||||
'/cachedassets',
|
||||
'/temp',
|
||||
'/editor',
|
||||
'/exports'
|
||||
);
|
||||
|
||||
// Check that directories are writable
|
||||
$has_write_access = TRUE;
|
||||
foreach ($dirs as $dir) {
|
||||
$has_write_access = $has_write_access && self::dirReady($this->path . $dir);
|
||||
}
|
||||
|
||||
return $has_write_access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function for copying directories.
|
||||
*
|
||||
|
|
|
@ -171,4 +171,12 @@ interface H5PFileStorage {
|
|||
* @param int $contentId
|
||||
*/
|
||||
public function removeContentFile($file, $contentId);
|
||||
|
||||
/**
|
||||
* Check if server setup has write permission to
|
||||
* the required folders
|
||||
*
|
||||
* @return bool True if server has the proper write access
|
||||
*/
|
||||
public function hasWriteAccess();
|
||||
}
|
||||
|
|
|
@ -2783,19 +2783,30 @@ class H5PCore {
|
|||
$this->h5pF->t('Your PHP version is outdated. H5P requires version 5.2 to function properly. Version 5.6 or later is recommended.');
|
||||
}
|
||||
|
||||
$max_upload_size = ini_get('upload_max_filesize');
|
||||
$max_post_size = ini_get('post_max_size');
|
||||
// Check write access
|
||||
if (!$this->fs->hasWriteAccess()) {
|
||||
$errors[] =
|
||||
$this->h5pF->t('A problem with the server write access was detected. Please make sure that your server can write to your data folder.');
|
||||
}
|
||||
|
||||
$max_upload_size = self::returnBytes(ini_get('upload_max_filesize'));
|
||||
$max_post_size = self::returnBytes(ini_get('post_max_size'));
|
||||
$byte_threshold = 5000000; // 5MB
|
||||
if (self::returnBytes($max_upload_size) < $byte_threshold) {
|
||||
if ($max_upload_size < $byte_threshold) {
|
||||
$errors[] =
|
||||
$this->h5pF->t('Your PHP max upload size option is too small. You should consider to increase it to more than 5MB.');
|
||||
}
|
||||
|
||||
if (self::returnBytes($max_post_size) < $byte_threshold) {
|
||||
if ($max_post_size < $byte_threshold) {
|
||||
$errors[] =
|
||||
$this->h5pF->t('Your PHP max post size option is too small. You should consider to increase it to more than 5MB.');
|
||||
}
|
||||
|
||||
if ($max_upload_size > $max_post_size) {
|
||||
$errors[] =
|
||||
$this->h5pF->t('Your PHP max upload size is bigger than your max post size. This is known to cause issues in some installations.');
|
||||
}
|
||||
|
||||
// Check SSL
|
||||
if (!extension_loaded('openssl')) {
|
||||
$errors[] =
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
var disableButton = $(H5PDisableHubData.selector);
|
||||
disableButton.change(function () {
|
||||
if (!$(this).is(':checked')) {
|
||||
if ($(this).is(':checked')) {
|
||||
confirmationDialog.show(disableButton.offset().top);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue