Add apiIsSystemInstalled() to check for signs of Chamilo installation and to return a clean array allowing for decisions to be taken. Use of lower_camel_case should be abandoned progressively anyway, so using upperCamelCase

1.10.x
Yannick Warnier 11 years ago
parent 9856c618b1
commit a29ff92d66
  1. 22
      main/inc/lib/api.lib.php

@ -8004,3 +8004,25 @@ function api_protect_course_group($tool, $showHeader = true)
}
}
}
/**
* Check if Chmailo is installed correctly. If so, return the version
* @return array ('installed' => 0/1, 'message' => error/db version)
*/
function apiIsSystemInstalled ()
{
$root = __DIR__.'/../../../';
$configFile = $root.'main/inc/conf/configuration.php';
if (!is_readable($configFile)) {
return array ('installed' => 0, 'message' => 'No config file');
}
$result = Database::query(
"SELECT selected _value FROM settings_current WHERE variable = 'chamilo_database_version'"
);
if ($result == false) {
return array ('installed' => 0, 'message' => 'No way to recover version');
}
$settingsRow = Database::fetch_assoc($result);
$version = $settingsRow['selected_value'];
return array('installed' => 1, 'message' => $version);
}
Loading…
Cancel
Save