diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc
index b2766de0..579d427d 100644
--- a/lam/lib/baseModule.inc
+++ b/lam/lib/baseModule.inc
@@ -1758,6 +1758,15 @@ abstract class baseModule {
return true;
}
+ /**
+ * Returns a list of jobs that can be run.
+ *
+ * @param LAMConfig $config configuration
+ */
+ public function getSupportedJobs(&$config) {
+ return array();
+ }
+
// helper functions
diff --git a/lam/lib/config.inc b/lam/lib/config.inc
index 7040ba7e..477cb816 100644
--- a/lam/lib/config.inc
+++ b/lam/lib/config.inc
@@ -521,6 +521,10 @@ class LAMConfig {
private $jobsBindPassword = null;
/** database for jobs */
private $jobsDatabase = null;
+ /** random job token */
+ private $jobToken = null;
+ /** job configuration */
+ private $jobSettings = array();
/** List of all settings in config file */
private $settings = array("ServerURL", "useTLS", "followReferrals", 'pagedResults', "Passwd", "Admins", "treesuffix",
@@ -528,7 +532,7 @@ class LAMConfig {
"modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject',
'lamProMailText', 'lamProMailIsHTML', 'lamProMailAllowAlternateAddress', 'httpAuthentication', 'loginSearchDN',
- 'loginSearchPassword', 'timeZone', 'jobsBindUser', 'jobsBindPassword', 'jobsDatabase');
+ 'loginSearchPassword', 'timeZone', 'jobsBindUser', 'jobsBindPassword', 'jobsDatabase', 'jobToken', 'jobs');
/**
@@ -561,7 +565,7 @@ class LAMConfig {
$file = @fopen($conffile, "r");
if (!$file) return false; // abort if file is not readable
while (!feof($file)) {
- $line = fgets($file, 100000);
+ $line = fgets($file, 1000000);
$line = trim($line); // remove spaces at the beginning and end
if (($line == "")||($line[0] == "#")) continue; // ignore comments and empty lines
// search keywords
@@ -587,6 +591,12 @@ class LAMConfig {
$pos = strpos($option, ":");
$this->toolSettings[substr($option, 0, $pos)] = substr($option, $pos + 2);
}
+ // job settings
+ elseif (strtolower(substr($line, 0, $keylen + 2)) == "jobs: ") {
+ $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
+ $pos = strpos($option, ":");
+ $this->jobSettings[substr($option, 0, $pos)] = explode(LAMConfig::LINE_SEPARATOR, substr($option, $pos + 2));
+ }
// general settings
else {
$this->$keyword = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
@@ -638,7 +648,7 @@ class LAMConfig {
$file_array = array();
// read config file
while (!feof($file)) {
- array_push($file_array, fgets($file, 1024));
+ array_push($file_array, fgets($file, 1000000));
}
fclose($file);
// generate new configuration file
@@ -679,6 +689,15 @@ class LAMConfig {
$file_array[$i] = "tools: " . $name . ": " . $this->toolSettings[$name] . "\n";
$mod_saved[] = $name; // mark keyword as saved
}
+ // job settings
+ elseif (strtolower(substr($line, 0, $keylen + 2)) == "jobs: ") {
+ $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
+ $pos = strpos($option, ":");
+ $name = substr($option, 0, $pos);
+ if (!isset($this->jobSettings[$name])) continue;
+ $file_array[$i] = "jobs: " . $name . ": " . implode(LAMConfig::LINE_SEPARATOR, $this->jobSettings[$name]) . "\n";
+ $mod_saved[] = $name; // mark keyword as saved
+ }
// general settings
else {
$file_array[$i] = $keyword . ": " . $this->$keyword . "\n";
@@ -723,6 +742,7 @@ class LAMConfig {
if (!in_array("jobsBindPassword", $saved)) array_push($file_array, "\n" . "jobsBindPassword: " . $this->jobsBindPassword . "\n");
if (!in_array("jobsBindUser", $saved)) array_push($file_array, "\n" . "jobsBindUser: " . $this->jobsBindUser . "\n");
if (!in_array("jobsDatabase", $saved)) array_push($file_array, "\n" . "jobsDatabase: " . $this->jobsDatabase . "\n");
+ if (!in_array("jobToken", $saved)) array_push($file_array, "\n" . "jobToken: " . $this->getJobToken() . "\n");
// check if all module settings were added
$m_settings = array_keys($this->moduleSettings);
for ($i = 0; $i < sizeof($m_settings); $i++) {
@@ -744,6 +764,13 @@ class LAMConfig {
array_push($file_array, "tools: " . $tool_settings[$i] . ": " . $this->toolSettings[$tool_settings[$i]] . "\n");
}
}
+ // check if all job settings were added
+ $jobSettings = array_keys($this->jobSettings);
+ for ($i = 0; $i < sizeof($jobSettings); $i++) {
+ if (!in_array($jobSettings[$i], $mod_saved)) {
+ array_push($file_array, "jobs: " . $jobSettings[$i] . ": " . implode(LAMConfig::LINE_SEPARATOR, $this->jobSettings[$jobSettings[$i]]) . "\n");
+ }
+ }
$file = @fopen($conffile, "w");
$saveResult = LAMConfig::SAVE_OK;
if ($file) {
@@ -1658,6 +1685,41 @@ class LAMConfig {
$this->jobsDatabase = $jobsDatabase;
}
+ /**
+ * Sets the settings for the jobs.
+ *
+ * @param array $settings list of job settings array(name => value)
+ * @return boolean true if $settings has correct format
+ */
+ public function setJobSettings($settings) {
+ if (!is_array($settings)) {
+ return false;
+ }
+ $this->jobSettings = $settings;
+ return true;
+ }
+
+ /**
+ * Returns a list of saved job settings.
+ *
+ * @return array list of settings: array(name => value)
+ */
+ public function getJobSettings() {
+ return $this->jobSettings;
+ }
+
+ /**
+ * Returns the job token.
+ *
+ * @return String job token
+ */
+ public function getJobToken() {
+ if (empty($this->jobToken)) {
+ $this->jobToken = getRandomNumber();
+ }
+ return $this->jobToken;
+ }
+
}
diff --git a/lam/lib/html.inc b/lam/lib/html.inc
index aa9d130f..b77dd78e 100644
--- a/lam/lib/html.inc
+++ b/lam/lib/html.inc
@@ -980,7 +980,7 @@ class htmlButton extends htmlElement {
}
$id = ' id="btn_' . preg_replace('/[^a-zA-Z0-9_-]/', '', $this->name) . '"';
if ($this->isImageButton) {
- echo '';
+ echo '';
}
else {
echo '';
diff --git a/lam/templates/lib/141_jquery-validationEngine-lang.php b/lam/templates/lib/141_jquery-validationEngine-lang.php
index d2428283..db897559 100644
--- a/lam/templates/lib/141_jquery-validationEngine-lang.php
+++ b/lam/templates/lib/141_jquery-validationEngine-lang.php
@@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2010 Cedric Dugas and Olivier Refalo
- 2011 - 2013 Roland Gruber
+ 2011 - 2015 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@ if (strtolower(session_module_name()) == 'files') {
session_save_path(dirname(__FILE__) . '/../../sess');
}
-// start empty session and change ID for security reasons
@session_start();
setlanguage();
diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js
index 5ae0d0de..5e25db95 100644
--- a/lam/templates/lib/500_lam.js
+++ b/lam/templates/lib/500_lam.js
@@ -208,14 +208,16 @@ function profileShowDeleteDialog(title, okText, cancelText, scope, selectFieldNa
* Shows a simple dialog.
*
* @param title dialog title
- * @param okText text for Ok button
+ * @param okText text for Ok button (optional, submits form)
* @param cancelText text for Cancel button
* @param formID form ID
* @param dialogDivID ID of div that contains dialog content
*/
function showSimpleDialog(title, okText, cancelText, formID, dialogDivID) {
var buttonList = {};
- buttonList[okText] = function() { document.forms[formID].submit(); };
+ if (okText) {
+ buttonList[okText] = function() { document.forms[formID].submit(); };
+ }
buttonList[cancelText] = function() { jQuery(this).dialog("close"); };
jQuery('#' + dialogDivID).dialog({
modal: true,
@@ -324,11 +326,7 @@ function showConfirmationDialog(title, okText, cancelText, dialogDiv, formName,
if (resultField) {
jQuery('#' + resultField).val('ok');
};
- var inputs = jQuery('#' + dialogDiv + ' :input');
- inputs.each(function() {
- jQuery(this).appendTo(document.forms[formName]);
- });
- document.forms[formName].submit();
+ appendDialogInputsToFormAndSubmit(dialogDiv, formName);
};
buttonList[cancelText] = function() {
if (resultField) {
@@ -345,6 +343,21 @@ function showConfirmationDialog(title, okText, cancelText, dialogDiv, formName,
});
}
+/**
+ * Appends the input fields of a dialog back to the form and submits it.
+ *
+ * @param dialogDiv ID of dialog div
+ * @param formName name of form
+ */
+function appendDialogInputsToFormAndSubmit(dialogDiv, formName) {
+ var inputs = jQuery('#' + dialogDiv + ' :input');
+ inputs.each(function() {
+ jQuery(this).addClass('hidden');
+ jQuery(this).appendTo(document.forms[formName]);
+ });
+ document.forms[formName].submit();
+}
+
/**
* Shows a simple confirmation dialog.
* If the user presses Cancel then the current action is stopped (event.preventDefault()).