Commit 1bce3a70 authored by Rajesh Taneja's avatar Rajesh Taneja
Browse files

MDL-44839 admin: Moved all system executable paths to config

AMOS BEGIN
 MOV ['gspath','assignfeedback_editpdf'],['pathtogs','admin']
 MOV ['gspath_help','assignfeedback_editpdf'],['pathtogs_help','admin']
AMOS END
parent 8e478c99
......@@ -11,6 +11,7 @@ $temp = new admin_settingpage('systempaths', new lang_string('systempaths','admi
$temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'), new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
$ADMIN->add('server', $temp);
......
......@@ -711,6 +711,40 @@ $CFG->admin = 'admin';
// generated by this tool, but only in case you want to generate a JMeter test. The value should be a string.
// Example:
// $CFG->tool_generator_users_password = 'examplepassword';
//
//=========================================================================
// 13. SYSTEM PATHS (You need to set following, depending on your system)
//=========================================================================
// Ghostscript path.
// On most Linux installs, this can be left as '/usr/bin/gs'.
// On Windows it will be something like 'c:\gs\bin\gswin32c.exe' (make sure
// there are no spaces in the path - if necessary copy the files 'gswin32c.exe'
// and 'gsdll32.dll' to a new folder without a space in the path)
// $CFG->pathtogs = '/usr/bin/gs';
//
// Clam AV path.
// Probably something like /usr/bin/clamscan or /usr/bin/clamdscan. You need
// this in order for clam AV to run.
// $CFG->pathtoclam = '';
//
// Path to du.
// Probably something like /usr/bin/du. If you enter this, pages that display
// directory contents will run much faster for directories with a lot of files.
// $CFG->pathtodu = '';
//
// Path to aspell.
// To use spell-checking within the editor, you MUST have aspell 0.50 or later
// installed on your server, and you must specify the correct path to access the
// aspell binary. On Unix/Linux systems, this path is usually /usr/bin/aspell,
// but it might be something else.
// $CFG->aspellpath = '';
//
// Path to dot.
// Probably something like /usr/bin/dot. To be able to generate graphics from
// DOT files, you must have installed the dot executable and point to it here.
// Note that, for now, this only used by the profiling features
// (Development->Profiling) built into Moodle.
// $CFG->pathtodot = '';
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
......
......@@ -774,6 +774,8 @@ $string['pathtoclam'] = 'clam AV path';
$string['pathtodot'] = 'Path to dot';
$string['pathtodot_help'] = 'Path to dot. Probably something like /usr/bin/dot. To be able to generate graphics from DOT files, you must have installed the dot executable and point to it here. Note that, for now, this only used by the profiling features (Development->Profiling) built into Moodle.';
$string['pathtodu'] = 'Path to du';
$string['pathtogs'] = 'Path to ghostscript';
$string['pathtogs_help'] = 'On most Linux installs, this can be left as \'/usr/bin/gs\'. On Windows it will be something like \'c:\\gs\\bin\\gswin32c.exe\' (make sure there are no spaces in the path - if necessary copy the files \'gswin32c.exe\' and \'gsdll32.dll\' to a new folder without a space in the path)';
$string['pathtopgdump'] = 'Path to pg_dump';
$string['pathtopgdumpdesc'] = 'This is only necessary to enter if you have more than one pg_dump on your system (for example if you have more than one version of postgresql installed)';
$string['pathtopgdumpinvalid'] = 'Invalid path to pg_dump - either wrong path or not executable';
......
......@@ -155,7 +155,7 @@ function behat_clean_init_config() {
'wwwroot', 'dataroot', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
'umaskpermissions', 'dbtype', 'dblibrary', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'prefix',
'dboptions', 'proxyhost', 'proxyport', 'proxytype', 'proxyuser', 'proxypassword',
'proxybypass', 'theme'
'proxybypass', 'theme', 'pathtogs', 'pathtoclam', 'pathtodu', 'aspellpath', 'pathtodot'
));
// Add extra allowed settings.
......
......@@ -3660,5 +3660,14 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014051200.02);
}
if ($oldversion < 2014060300.00) {
$gspath = get_config('assignfeedback_editpdf', 'gspath');
if ($gspath !== false) {
set_config('pathtogs', $gspath);
unset_config('gspath', 'assignfeedback_editpdf');
}
upgrade_main_savepoint(true, 2014060300.00);
}
return true;
}
......@@ -181,6 +181,7 @@ $CFG->dboptions = isset($CFG->phpunit_dboptions) ? $CFG->phpunit_dboptions : $CF
$allowed = array('wwwroot', 'dataroot', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
'dbtype', 'dblibrary', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'prefix', 'dboptions',
'proxyhost', 'proxyport', 'proxytype', 'proxyuser', 'proxypassword', 'proxybypass', // keep proxy settings from config.php
'pathtogs', 'pathtoclam', 'pathtodu', 'aspellpath', 'pathtodot'
);
$productioncfg = (array)$CFG;
$CFG = new stdClass();
......
......@@ -414,6 +414,8 @@ class pdf extends \FPDI {
* @return string the filename of the generated image
*/
public function get_image($pageno) {
global $CFG;
if (!$this->filename) {
throw new \coding_exception('Attempting to generate a page image without first setting the PDF filename');
}
......@@ -437,7 +439,7 @@ class pdf extends \FPDI {
if ($generate) {
// Use ghostscript to generate an image of the specified page.
$gsexec = \escapeshellarg(\get_config('assignfeedback_editpdf', 'gspath'));
$gsexec = \escapeshellarg($CFG->pathtogs);
$imageres = \escapeshellarg(100);
$imagefilearg = \escapeshellarg($imagefile);
$filename = \escapeshellarg($this->filename);
......@@ -467,6 +469,8 @@ class pdf extends \FPDI {
* @return string path to copy or converted pdf (false == fail)
*/
public static function ensure_pdf_compatible(\stored_file $file) {
global $CFG;
$temparea = \make_temp_directory('assignfeedback_editpdf');
$hash = $file->get_contenthash(); // Use the contenthash to make sure the temp files have unique names.
$tempsrc = $temparea . "/src-$hash.pdf";
......@@ -488,7 +492,7 @@ class pdf extends \FPDI {
}
$gsexec = \escapeshellarg(\get_config('assignfeedback_editpdf', 'gspath'));
$gsexec = \escapeshellarg($CFG->pathtogs);
$tempdstarg = \escapeshellarg($tempdst);
$tempsrcarg = \escapeshellarg($tempsrc);
$command = "$gsexec -q -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=$tempdstarg $tempsrcarg";
......@@ -528,7 +532,7 @@ class pdf extends \FPDI {
'status' => self::GSPATH_OK,
'message' => null,
);
$gspath = \get_config('assignfeedback_editpdf', 'gspath');
$gspath = $CFG->pathtogs;
if (empty($gspath)) {
$ret->status = self::GSPATH_EMPTY;
return $ret;
......
......@@ -51,8 +51,7 @@ $string['filter'] = 'Filter comments...';
$string['generatefeedback'] = 'Generate feedback PDF';
$string['gotopage'] = 'Go to page';
$string['green'] = 'Green';
$string['gspath'] = 'Ghostscript path';
$string['gspath_help'] = 'On most Linux installs, this can be left as \'/usr/bin/gs\'. On Windows it will be something like \'c:\\gs\\bin\\gswin32c.exe\' (make sure there are no spaces in the path - if necessary copy the files \'gswin32c.exe\' and \'gsdll32.dll\' to a new folder without a space in the path)';
$string['pathtogspathdesc'] = 'Please note that annotate PDF requires the path to ghostscript to be set in {$a}.';
$string['highlight'] = 'Highlight';
$string['jsrequired'] = 'JavaScript is required to annotate a PDF. Please enable JavaScript in your browser to use this feature.';
$string['launcheditor'] = 'Launch PDF editor...';
......
......@@ -34,10 +34,10 @@ $setting = new admin_setting_configstoredfile($name, $title, $description, 'stam
$settings->add($setting);
// Ghostscript setting.
$settings->add(new admin_setting_configexecutable('assignfeedback_editpdf/gspath',
get_string('gspath', 'assignfeedback_editpdf'),
get_string('gspath_help', 'assignfeedback_editpdf'),
'/usr/bin/gs'));
$systempathslink = new moodle_url('/admin/settings.php', array('section' => 'systempaths'));
$systempathlink = html_writer::link($systempathslink, get_string('systempaths', 'admin'));
$settings->add(new admin_setting_heading('pathtogs', get_string('pathtogs', 'admin'),
get_string('pathtogspathdesc', 'assignfeedback_editpdf', $systempathlink)));
$url = new moodle_url('/mod/assign/feedback/editpdf/testgs.php');
$link = html_writer::link($url, get_string('testgs', 'assignfeedback_editpdf'));
......
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2014051200.04; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2014060300.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
......
Supports Markdown
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