Commit 1c148e1f authored by metzlerd's avatar metzlerd
Browse files

Implemented new requirements checking.

parent 71ddfecf
......@@ -12,7 +12,7 @@ class FrxPrincePDF extends FrxDocument {
include_once('sites/all/libraries/prince/prince.php');
$this->content_type='application/pdf';
$prince_path = variable_get('forena_pdf_prince_path', '/usr/local/bin/prince');
if (class_exists('Prince') && file_exists($prince_path)) {
if (class_exists('Prince') && forena_library_file('prince')) {
$this->p = new Prince($prince_path);
}
......
......@@ -502,9 +502,9 @@ function theme_forena_data_table($variables) {
'empty' => '',
);
drupal_add_css(drupal_get_path('module', 'forena') . '/forena.css');
if (file_exists('sites/all/libraries/dataTables/media/js/jquery.dataTables.min.js')) {
if (forena_library_file('dataTables')) {
drupal_add_js(drupal_get_path('module', 'forena') . '/forena.admin.js');
drupal_add_js('sites/all/libraries/dataTables/media/js/jquery.dataTables.min.js');
drupal_add_js(forena_library_file('dataTables'));
}
// Default in values that theme_table expects.
$variables['attributes'] = isset($variables['attributes']) ? array_merge($defaults, $variables['attributes']) : $defaults;
......
......@@ -303,6 +303,17 @@ function forena_admin_paths_alter(&$paths) {
}
function forena_library_file($library) {
$libraries = array(
'dataTables' => 'dataTables/media/js/jquery.dataTables.min.js',
'mpdf' => 'mpdf/mpdf.php',
'SVGGraph' => 'SVGGraph/SVGGraph.php',
'prince' => 'prince/prince.php'
);
$path = isset($libraries[$library]) && file_exists('sites/all/libraries/' . $libraries[$library]) ? 'sites/all/libraries/' . $libraries[$library] : '';
return $path;
}
/**
* Implementation of hook_block_info
*/
......@@ -1410,15 +1421,28 @@ function forena_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'runtime':
$writable = is_writable(Frx::File()->dir);
$writeable = is_writable(Frx::File()->dir);
if (!$writeable) {
$requirements['fornea_writable'] = array(
'title' => 'Report File Location',
'title' => 'Forena Report Directory',
'value' => Frx::File()->dir,
'severity' => REQUIREMENT_ERROR,
'description' => t('The directory must be writable by the web user in order to create custom reports. '),
) ;
}
$req = array('severity' => REQUIREMENT_INFO, 'requirement');
$libraries = array('dataTables' ,'mpdf', 'prince', 'SVGGraph' );
foreach ($libraries as $lib) {
$requirements['forena_' . $lib] = $req;
$requirements['forena_' . $lib]['title'] = "Forena $lib support";
$requirements['forena_' . $lib]['value'] = forena_library_file($lib) ? t('Enabled') : t('Not Enabled:');
$requirements['forena_' . $lib]['severity'] = forena_library_file($lib) ? REQUIREMENT_OK : REQUIREMENT_INFO;
}
if (!module_exists('forena_pdf')) {
unset($requirements['forena_prince']);
unset($requirements['forena_mpdf']);
}
break;
}
return $requirements;
......
......@@ -49,14 +49,14 @@ function forena_pdf_configure($formid, &$form_state) {
$pdf_generator = variable_get('forena_pdf_generator', '');
$mpdf_path = t('MDPF Libarary not found. Please install so sites/all/libraries/mpdf/mpdf.php exists.');
if (file_exists('sites/all/libraries/mpdf/mpdf.php')) {
if (forena_library_file('mpdf')) {
$mpdf_path = 'sites/all/libraries/mpdf';
}
else {
unset($pdf_options['FrxMPDF']);
}
$prince_path = t('Prince XML library not found. Please install so sites/all/libraries/prince/prince.php exists.');
if (file_exists('sites/all/libraries/prince/prince.php')) {
if (forena_library_file('prince')) {
$prince_path = 'sites/all/libraries/prince';
}
else {
......
......@@ -83,6 +83,27 @@ function forena_query_permission() {
return $perms;
}
/**
* Implmentation of hook_requirements
* @param unknown $phase
*/
function forena_query_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'runtime':
$writeable = is_writable(Frx::DataFile()->dir);
if (!$writeable) {
$requirements['fornea_writable'] = array(
'title' => 'Forena Data Directory',
'value' => Frx::File()->dir,
'severity' => REQUIREMENT_ERROR,
'description' => t('The directory must be writable by the web user in order to create custom SQL data sources. '),
) ;
}
}
}
/**
* Return permission as to whether the user can save data
* in the repository.
......
......@@ -11,8 +11,7 @@ class FrxSVGGraph extends FrxChart {
private $graph;
private $links;
function __construct() {
$directory = FrxReportGenerator::instance()->configuration('library_path');
$library = rtrim($directory, '/') . '/SVGGraph/SVGGraph.php';
$library = forena_library_file('SVGGraph');
require_once $library;
}
......
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