Commit dc5e46d0 by Scott

Hide Caching link if directory not defined

parent 61472952
......@@ -34,14 +34,15 @@ class Q2A_Storage_CacheManager
*/
private function __construct()
{
$optEnabled = qa_opt('caching_enabled') == 1;
if (qa_opt('caching_enabled') != 1)
return;
$config = array(
'dir' => defined('QA_CACHE_DIRECTORY') ? QA_CACHE_DIRECTORY : null,
);
$this->cacheDriver = new Q2A_Storage_FileCache($config);
$this->enabled = $optEnabled && $this->cacheDriver->isEnabled();
$this->enabled = $this->cacheDriver->isEnabled();
}
/**
......
......@@ -35,16 +35,17 @@ class Q2A_Storage_FileCache
*/
public function __construct($config)
{
if (!isset($config['dir']))
return;
$this->cacheDir = realpath($config['dir']);
if (!is_writable($this->cacheDir)) {
$this->error = qa_lang_html_sub('admin/caching_dir_error', $this->cacheDir);
} elseif (strpos($this->cacheDir, realpath($_SERVER['DOCUMENT_ROOT'])) === 0 || strpos($this->cacheDir, realpath(QA_BASE_DIR)) === 0) {
// check the folder is outside the public root - checks against server root and Q2A root, in order to handle symbolic links
$this->error = qa_lang_html_sub('admin/caching_dir_public', $this->cacheDir);
if (isset($config['dir'])) {
$this->cacheDir = realpath($config['dir']);
if (!is_writable($this->cacheDir)) {
$this->error = qa_lang_html_sub('admin/caching_dir_error', $this->cacheDir);
} elseif (strpos($this->cacheDir, realpath($_SERVER['DOCUMENT_ROOT'])) === 0 || strpos($this->cacheDir, realpath(QA_BASE_DIR)) === 0) {
// check the folder is outside the public root - checks against server root and Q2A root, in order to handle symbolic links
$this->error = qa_lang_html_sub('admin/caching_dir_public', $this->cacheDir);
}
} else {
$this->error = qa_lang_html('admin/caching_dir_missing');
}
$this->enabled = empty($this->error);
......
......@@ -341,10 +341,12 @@
'url' => qa_path_html('admin/spam'),
);
$navigation['admin/caching']=array(
'label' => qa_lang_html('admin/caching_title'),
'url' => qa_path_html('admin/caching'),
);
if (defined('QA_CACHE_DIRECTORY')) {
$navigation['admin/caching']=array(
'label' => qa_lang_html('admin/caching_title'),
'url' => qa_path_html('admin/caching'),
);
}
$navigation['admin/stats']=array(
'label' => qa_lang_html('admin/stats_title'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment