Commit dc5e46d0 by Scott

Hide Caching link if directory not defined

parent 61472952
...@@ -34,14 +34,15 @@ class Q2A_Storage_CacheManager ...@@ -34,14 +34,15 @@ class Q2A_Storage_CacheManager
*/ */
private function __construct() private function __construct()
{ {
$optEnabled = qa_opt('caching_enabled') == 1; if (qa_opt('caching_enabled') != 1)
return;
$config = array( $config = array(
'dir' => defined('QA_CACHE_DIRECTORY') ? QA_CACHE_DIRECTORY : null, 'dir' => defined('QA_CACHE_DIRECTORY') ? QA_CACHE_DIRECTORY : null,
); );
$this->cacheDriver = new Q2A_Storage_FileCache($config); $this->cacheDriver = new Q2A_Storage_FileCache($config);
$this->enabled = $optEnabled && $this->cacheDriver->isEnabled(); $this->enabled = $this->cacheDriver->isEnabled();
} }
/** /**
......
...@@ -35,9 +35,7 @@ class Q2A_Storage_FileCache ...@@ -35,9 +35,7 @@ class Q2A_Storage_FileCache
*/ */
public function __construct($config) public function __construct($config)
{ {
if (!isset($config['dir'])) if (isset($config['dir'])) {
return;
$this->cacheDir = realpath($config['dir']); $this->cacheDir = realpath($config['dir']);
if (!is_writable($this->cacheDir)) { if (!is_writable($this->cacheDir)) {
...@@ -46,6 +44,9 @@ class Q2A_Storage_FileCache ...@@ -46,6 +44,9 @@ class Q2A_Storage_FileCache
// check the folder is outside the public root - checks against server root and Q2A root, in order to handle symbolic links // 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); $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); $this->enabled = empty($this->error);
} }
......
...@@ -341,10 +341,12 @@ ...@@ -341,10 +341,12 @@
'url' => qa_path_html('admin/spam'), 'url' => qa_path_html('admin/spam'),
); );
if (defined('QA_CACHE_DIRECTORY')) {
$navigation['admin/caching']=array( $navigation['admin/caching']=array(
'label' => qa_lang_html('admin/caching_title'), 'label' => qa_lang_html('admin/caching_title'),
'url' => qa_path_html('admin/caching'), 'url' => qa_path_html('admin/caching'),
); );
}
$navigation['admin/stats']=array( $navigation['admin/stats']=array(
'label' => qa_lang_html('admin/stats_title'), '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