Commit 9a83093b authored by David Metzler's avatar David Metzler
Browse files

Block save functional and trapped.

parent 0b18d94d
......@@ -330,7 +330,6 @@ class FrxFile {
*/
public function save($filename, $data) {
$path = $this->dir . '/' . $filename;
dpm($data, $path);
$this->verifyDirectory($filename);
if (is_writable($path) || (!file_exists($path) && is_writable(dirname($path)))) {
......@@ -368,6 +367,15 @@ class FrxFile {
public function pathinfo($filename, $use_include = TRUE) {
return pathinfo($this->path($filename, $use_include));
}
/**
* Return an indicator as to whether the file is savable.
* New files can be saved if the directory is writabel.
* @param unknown $filename
* @return boolean
*/
public function isWritable($filename) {
return is_writeable($this->dir . "/$filename") || (!file_exists($this->dir . "/$filename") && is_writable('dir'));
}
......
......@@ -160,7 +160,7 @@ function forena_settings() {
$form['forena_last_report_path'] = array(
'#type' => 'value',
'#value' => forena_report_path(),
'#value' => variable_get('forena_report_repos', '')
);
if (module_exists('forena_query')) {
......@@ -176,7 +176,7 @@ function forena_settings() {
$form['forena_last_query_data_path'] = array(
'#type' => 'value',
'#value' => Frx::DataFile()->dir
'#value' => variable_get('forena_query_data_path', '')
);
}
......@@ -203,7 +203,7 @@ function forena_settings_validate($form, &$form_state) {
if (!file_exists($path)) {
try {
if (file_exists($path)) {
drupal_set_message(t('Created directory %s', array($path))) ;
drupal_set_message(t('Created directory %s', array('%s' => $path))) ;
}
mkdir($path);
......@@ -223,7 +223,7 @@ function forena_settings_validate($form, &$form_state) {
mkdir($path);
if (file_exists($path)) {
drupal_set_message(t('Created directory %s', array($path))) ;
drupal_set_message(t('Created directory %s', array('%s' => $path))) ;
}
} catch (Exception $e) {
......@@ -232,7 +232,6 @@ function forena_settings_validate($form, &$form_state) {
}
}
if (!file_exists($path) || !is_writable($path)) {
dpm($path);
form_set_error('forena_query_data_path', 'Data Directory must be writable by the web user');
}
}
......
......@@ -141,7 +141,6 @@ function forena_query_builder_form($formid, &$form_state) {
$form['file'] = array(
'#type' => 'textarea',
'#title' => t('Source'),
'#disabled' => @$block['locked'],
'#default_value' => @$block['file'],
);
......@@ -227,7 +226,8 @@ function forena_query_load_block($form, &$form_state) {
function forena_query_validate_block($form, &$form_state) {
$repos_list = Frx::RepoMan()->repositories;
@list($provider, $block) = @explode('/', $form_state['values']['block'], 2);
$block_name = $form_state['values']['block'];
@list($provider, $block) = @explode('/', $block_name, 2);
if (!isset($repos_list[$provider])) {
form_set_error('block', t('Invalid Data Source'));
}
......@@ -243,10 +243,14 @@ function forena_query_validate_block($form, &$form_state) {
$r = Frx::RepoMan()->repository($provider);
$access = $r->access($form_state['values']['access']);
if (!$access) {
form_set_error('access', 'You must have access to use this right.');
form_set_error('access', t('You must be granted access to use this right.'));
}
}
if (!Frx::DataFile()->isWritable($block_name . '.sql')) {
form_set_error('block', t('Insufficient Permission to save file'));
}
}
......@@ -360,6 +364,7 @@ function forena_query_validate_new_block($form, &$form_state) {
}
function forena_query_save_block($form, &$form_state) {
$form_state['rebuild'] = FALSE;
$block_name = $form_state['storage']['block_name'];
......
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