Check directories permissions on install

Fixes #76
This commit is contained in:
Dmitriy Simushev 2014-11-07 12:09:18 +00:00
parent 2c0d88c4d5
commit fe0d2f2760

View File

@ -118,12 +118,16 @@ class Installer
if (!$this->checkPhpVersion()) {
return false;
}
$this->log[] = getlocal(
'PHP version {0}',
array(format_version_id($this->getPhpVersionId()))
);
if (!$this->checkFsPermissions()) {
return false;
}
$this->log[] = getlocal('Directories permissions are correct');
return true;
}
@ -472,6 +476,36 @@ class Installer
return true;
}
/**
* Checks if files and directories permissions are correct.
*
* @return boolean True if all permissions are correct and false otherwise.
*/
protected function checkFsPermissions()
{
// Check cache directory
if (!is_writable(MIBEW_FS_ROOT . '/cache')) {
$this->errors[] = getlocal(
'Cache directory "{0}" is not writable.',
array('cache/')
);
return false;
}
// Check avatars directory
if (!is_writable(MIBEW_FS_ROOT . '/files/avatar')) {
$this->errors[] = getlocal(
'Avatars directory "{0}" is not writable.',
array('files/avatar/')
);
return false;
}
return true;
}
/**
* Checks if MySQL version is high enough or not to run Mibew.
*