Commit 211388fe authored by David Metzler's avatar David Metzler
Browse files

Fixed default configuration of forena_query module to work with private file systems.

parent bb811499
...@@ -12,7 +12,11 @@ class FrxDataFile extends FrxFile { ...@@ -12,7 +12,11 @@ class FrxDataFile extends FrxFile {
// Load default directory from configuration. // Load default directory from configuration.
$report_path = variable_get('forena_query_data_path', ''); $report_path = variable_get('forena_query_data_path', '');
if (!$report_path) { if (!$report_path) {
$report_path = variable_get('file_private_path' . '/data', conf_path() . '/data'); $report_path = drupal_realpath('private://data');
if ($report_path) {
if (!file_exists($report_path)) @mkdir($report_path);
}
if (!$report_path) $report_path = conf_path() . '/data';
} }
// Add directories for data repos. // Add directories for data repos.
...@@ -25,11 +29,11 @@ class FrxDataFile extends FrxFile { ...@@ -25,11 +29,11 @@ class FrxDataFile extends FrxFile {
foreach ($directories as $dir) { foreach ($directories as $dir) {
$this->includes[$k] = rtrim($dir, '/'); $this->includes[$k] = rtrim($dir, '/');
} }
// Parent constructor. // Parent constructor.
parent::__construct($default_directory, $directories, array('sql', 'xml', 'inc')); parent::__construct($default_directory, $directories, array('sql', 'xml', 'inc'));
} }
/** /**
* List all the reports for a language. * List all the reports for a language.
* @return unknown * @return unknown
......
...@@ -311,6 +311,7 @@ class FrxFile { ...@@ -311,6 +311,7 @@ class FrxFile {
function verifyDirectory($fullpath, $recursive=FALSE) { function verifyDirectory($fullpath, $recursive=FALSE) {
static $path=''; static $path='';
dpm($fullpath);
$success = TRUE; $success = TRUE;
if (!$recursive) { if (!$recursive) {
$path = $this->dir; $path = $this->dir;
...@@ -346,6 +347,7 @@ class FrxFile { ...@@ -346,6 +347,7 @@ class FrxFile {
*/ */
public function save($filename, $data) { public function save($filename, $data) {
$path = $this->dir . '/' . $filename; $path = $this->dir . '/' . $filename;
$this->verifyDirectory($filename); $this->verifyDirectory($filename);
if (is_writable($path) || (!file_exists($path) && is_writable(dirname($path)))) { if (is_writable($path) || (!file_exists($path) && is_writable(dirname($path)))) {
......
...@@ -157,8 +157,9 @@ function forena_settings($form, &$form_state) { ...@@ -157,8 +157,9 @@ function forena_settings($form, &$form_state) {
'#title' => t('Custom Data Block Repository'), '#title' => t('Custom Data Block Repository'),
'#description' => t('Indicate the directory that you want to use to save custom created data blocks (SQLs or '#description' => t('Indicate the directory that you want to use to save custom created data blocks (SQLs or
XMLs) using the forena query builder tool. These will override any module delivered data blocks. This XMLs) using the forena query builder tool. These will override any module delivered data blocks. This
needs to be a directory that is writable by the web user but should not be browsable by the web.'), needs to be a directory that is writable by the web user but should not be browsable by the web. If you leave this blank
'#default_value' => Frx::DataFile()->dir, Forena will use a data path in your <a href="@file_config">private file system</a>', array('@file_config' => url('admin/config/media/file-system'))),
'#default_value' => variable_get('fornea_query_data_path', ''),
); );
$form['forena_last_query_data_path'] = array( $form['forena_last_query_data_path'] = array(
......
...@@ -37,7 +37,7 @@ function forena_menu() { ...@@ -37,7 +37,7 @@ function forena_menu() {
'title' => 'Forena Reports', 'title' => 'Forena Reports',
'description' => 'Tell Forena where to store report files and how users should access them.', 'description' => 'Tell Forena where to store report files and how users should access them.',
'access arguments' => array('administer forena reports'), 'access arguments' => array('administer forena reports'),
'type' => MENU_CALLBACK, 'type' => MENU_NORMAL_ITEM,
'file' => 'forena.admin.inc', 'file' => 'forena.admin.inc',
); );
...@@ -358,7 +358,7 @@ function forena_menu() { ...@@ -358,7 +358,7 @@ function forena_menu() {
'page arguments' => array(), 'page arguments' => array(),
'title' => 'My Reports', 'title' => 'My Reports',
'access arguments' => array('list reports'), 'access arguments' => array('list reports'),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_CALLBACK,
); );
$items['reports'] = array( $items['reports'] = array(
......
...@@ -100,13 +100,17 @@ function forena_query_requirements($phase) { ...@@ -100,13 +100,17 @@ function forena_query_requirements($phase) {
$writeable = is_writable(Frx::DataFile()->dir); $writeable = is_writable(Frx::DataFile()->dir);
if (!$writeable) { if (!$writeable) {
$requirements['fornea_writable'] = array( $requirements['fornea_writable'] = array(
'title' => 'Forena Data Directory', 'title' => 'Forena Query Data Directory',
'value' => Frx::File()->dir, 'value' => Frx::DataFile()->dir,
'severity' => REQUIREMENT_ERROR, 'severity' => REQUIREMENT_ERROR,
'description' => t('The directory must be writable by the web user in order to create custom SQL data sources. '), 'description' => t('The directory must be writable by the web user in order to create custom SQL data sources.').
t('Configure <a href="@private_path">private file system paths</a> or specificy a differnt <a href="@data_directory">data directory</a>."',
array('@private_path' => url('admin/config/media/file-system'), '@data_directory' => url('admin/config/content/forena')))
) ; ) ;
} }
} }
return $requirements;
} }
function forena_query_forena_query_builders() { function forena_query_forena_query_builders() {
......
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