From 3ad2866e6bb80deb0597d37583060c75d99e9349 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 18 Jan 2017 13:36:05 +0100 Subject: install.js: Fix coloring for an error case --- script/install.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/install.js b/script/install.js index a85f869c..9738f1a2 100644 --- a/script/install.js +++ b/script/install.js @@ -77,7 +77,7 @@ var slxTrigger = function (elem, moduleName) { //alert('always: ' + moduleName + ', status: ' + slxModules[moduleName] + ', current: ' + slxCurrent); if (slxModules[moduleName] === 'WORKING') { slxModules[moduleName] = 'UPDATE_FAILED'; - $('#mod-' + moduleName).text('UPDATE_FAILED (No response from server)'); + $('#mod-' + moduleName).text('UPDATE_FAILED (No response from server)').css('color', '#c00'); } if (slxCurrent === moduleName) { slxCurrent = false; @@ -112,7 +112,9 @@ function slxRunNext(lastModule) { slxRun(next); } else { slxCancelTimer(); - alert('Done.'); + setTimeout(function() { + alert('Done.'); + }, 10); } } -- cgit v1.2.3-55-g7522 From 60b0e82aa64199bbed7a81a71b7cb1cd0ffd819e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 18 Jan 2017 13:37:03 +0100 Subject: [sysconfig] More ad/ldap setup fixes --- modules-available/sysconfig/addmodule_adauth.inc.php | 11 +++++++---- modules-available/sysconfig/inc/ldap.inc.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules-available/sysconfig/addmodule_adauth.inc.php b/modules-available/sysconfig/addmodule_adauth.inc.php index 666c36d1..266327a8 100644 --- a/modules-available/sysconfig/addmodule_adauth.inc.php +++ b/modules-available/sysconfig/addmodule_adauth.inc.php @@ -140,10 +140,12 @@ class AdAuth_SelfSearch extends AddModule_Base } else { $uri = "ldap://$server:3268/"; } + + $selfSearchBase = Ldap::getSelfSearchBase($binddn, $searchbase); // Set up selfSearch task $taskData = array( 'server' => $uri, - 'searchbase' => $searchbase, + 'searchbase' => $selfSearchBase, 'bindpw' => $bindpw, ); if (preg_match(AD_SHORT_REGEX, $binddn, $out) && !empty($out[2])) { @@ -153,12 +155,12 @@ class AdAuth_SelfSearch extends AddModule_Base $this->originalBindDn = $binddn; $taskData['filter'] = 'sAMAccountName=' . $out[1]; } elseif (preg_match('/^cn\=([^\=]+),.*?,dc\=([^\=]+),/i', Ldap::normalizeDn($binddn), $out)) { - if (empty($searchbase)) { + if (empty($selfSearchBase)) { $this->originalBindDn = $out[2] . '\\' . $out[1]; $taskData['filter'] = 'sAMAccountName=' . $out[1]; } else { $this->originalBindDn = $binddn; - $taskData['filter'] = "distinguishedName=$binddn"; + $taskData['filter'] = 'distinguishedName=' . Ldap::normalizeDn($binddn); } } else { Message::addError('could-not-determine-binddn', $binddn); @@ -232,11 +234,12 @@ class AdAuth_HomeAttrCheck extends AddModule_Base } else { $uri = "ldap://$server:$port/"; } + $selfSearchBase = Ldap::getSelfSearchBase($binddn, $searchbase); preg_match('#^(\w+\=[^\=]+),#', $binddn, $out); $filter = $out[1]; $data = array( 'server' => $uri, - 'searchbase' => $searchbase, + 'searchbase' => $selfSearchBase, 'binddn' => $binddn, 'bindpw' => $bindpw, 'filter' => $filter diff --git a/modules-available/sysconfig/inc/ldap.inc.php b/modules-available/sysconfig/inc/ldap.inc.php index ed471f31..23b24885 100644 --- a/modules-available/sysconfig/inc/ldap.inc.php +++ b/modules-available/sysconfig/inc/ldap.inc.php @@ -8,4 +8,18 @@ class Ldap return trim(preg_replace('/[,;]\s*/', ',', $dn)); } + public static function getSelfSearchBase($binddn, $searchbase) + { + // To find ourselves we try to figure out the proper search base, since the given one + // might be just for users, not for functional or utility accounts + if (preg_match('/,(OU=.*DC=.*)$/i', Ldap::normalizeDn($binddn), $out)) { + // Get OU from binddn; works if not given short form of DOMAIN\user or user@domain.fqdn.com + $searchbase = $out[1]; + } elseif (preg_match('/,(DC=.*)$/i', Ldap::normalizeDn($searchbase), $out)) { + // Otherwise, shorten search base enough to only consider the DC=..,DC=.. part at the end + $searchbase = $out[1]; + } + return $searchbase; + } + } -- cgit v1.2.3-55-g7522 From 407866723c28b1248cfe317779ea2760a8683b81 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 18 Jan 2017 15:11:06 +0100 Subject: [render.inc] Add collapse.js --- inc/render.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/render.inc.php b/inc/render.inc.php index 10419d6f..5515c659 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -88,6 +88,7 @@ class Render + '; foreach ($modules as $module) { $file = $module->getDir() . '/clientscript.js'; -- cgit v1.2.3-55-g7522 From 9f04cb08401e10e4a2df5d0a716bde6138949214 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 8 Feb 2017 15:44:28 +0100 Subject: [dozmod] Add options to enable/disable login by default for new users --- .../dozmod/lang/de/template-tags.json | 3 ++ .../dozmod/lang/en/template-tags.json | 3 ++ modules-available/dozmod/page.inc.php | 49 ++++++++++++++-------- .../dozmod/templates/runtimeconfig.html | 35 +++++----------- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/modules-available/dozmod/lang/de/template-tags.json b/modules-available/dozmod/lang/de/template-tags.json index a7a91e11..b980e011 100644 --- a/modules-available/dozmod/lang/de/template-tags.json +++ b/modules-available/dozmod/lang/de/template-tags.json @@ -1,5 +1,7 @@ { "lang_actionTarget": "Aktionsziel", + "lang_allowLoginByDefault": "Login standardm\u00e4\u00dfig erlauben", + "lang_allowLoginDescription": "Wenn diese Option aktiviert ist, k\u00f6nnen sich alle Mitarbeiter der Einrichtung \u00fcber die bwLehrpool-Suite anmelden und VMs\/Veranstaltungen verwalten. Wenn Sie diese Option deaktivieren, m\u00fcssen Sie in der Untersektion \"Benutzer und Berechtigungen\" jeden Benutzer nach dem ersten Loginversuch manuell freischalten.", "lang_asteriskRequired": "Felder mit (*) sind erforderlich", "lang_blockCount": "Anzahl Bl\u00f6cke", "lang_canLogin": "Nutzer dieser Einrichtung k\u00f6nnen sich am Satelliten anmelden", @@ -42,6 +44,7 @@ "lang_maxImageValidity": "G\u00fcltigkeitsdauer neuer VM-Versionen (Tage)", "lang_maxLectureVisibility": "Sp\u00e4testes Enddatum einer Veranstaltung (Tage in der Zukunft)", "lang_maxTransfers": "Maximale Zahl gleichzeitiger Up-\/Downloads pro Benutzer", + "lang_miscOptions": "Verschiedene Einstellungen", "lang_name": "Name", "lang_organization": "Einrichtung", "lang_organizationList": "Liste der Einrichtungen", diff --git a/modules-available/dozmod/lang/en/template-tags.json b/modules-available/dozmod/lang/en/template-tags.json index 6e1a3996..0dfd1825 100644 --- a/modules-available/dozmod/lang/en/template-tags.json +++ b/modules-available/dozmod/lang/en/template-tags.json @@ -1,5 +1,7 @@ { "lang_actionTarget": "Action target", + "lang_allowLoginByDefault": "Allow all staff members to login and use the bwLehrpool-Suite", + "lang_allowLoginDescription": "If this option is enabled, all members of the organization marked as staff or employee are allowed to login to this server and manage VMs\/courses. Otherwise, new users need to be individually allowed access after their first login attempt by visiting the sub page \"users and permissions\" in this web interface.", "lang_asteriskRequired": "Fields marked with (*) are required", "lang_blockCount": "Block count", "lang_canLogin": "Members of this organization can login", @@ -42,6 +44,7 @@ "lang_maxImageValidity": "New VM validity (days)", "lang_maxLectureVisibility": "Max time lecture end date may lie in the future (days)", "lang_maxTransfers": "Max concurrent transfers per user", + "lang_miscOptions": "Misc options", "lang_name": "Name", "lang_organization": "Organization", "lang_organizationList": "List of organizations", diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 6c0c8a6b..7f1e6ee3 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -89,29 +89,32 @@ class Page_DozMod extends Page if ($section === 'runtimeconfig') { // Runtime config $runtimeConf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'runtimelimits')); - if ($runtimeConf != null) { + if ($runtimeConf !== false) { $runtimeConf = json_decode($runtimeConf['value'], true); /* convert some value to corresponding "selected" texts */ if ($runtimeConf['defaultLecturePermissions']['edit']) { - $runtimeConf['defaultLecturePermissions']['edit'] = 'checked="checked"'; + $runtimeConf['defaultLecturePermissions']['edit'] = 'checked'; } if ($runtimeConf['defaultLecturePermissions']['admin']) { - $runtimeConf['defaultLecturePermissions']['admin'] = 'checked="checked"'; + $runtimeConf['defaultLecturePermissions']['admin'] = 'checked'; } if ($runtimeConf['defaultImagePermissions']['edit']) { - $runtimeConf['defaultImagePermissions']['edit'] = 'checked="checked"'; + $runtimeConf['defaultImagePermissions']['edit'] = 'checked'; } if ($runtimeConf['defaultImagePermissions']['admin']) { - $runtimeConf['defaultImagePermissions']['admin'] = 'checked="checked"'; + $runtimeConf['defaultImagePermissions']['admin'] = 'checked'; } if ($runtimeConf['defaultImagePermissions']['link']) { - $runtimeConf['defaultImagePermissions']['link'] = 'checked="checked"'; + $runtimeConf['defaultImagePermissions']['link'] = 'checked'; } if ($runtimeConf['defaultImagePermissions']['download']) { - $runtimeConf['defaultImagePermissions']['download'] = 'checked="checked"'; + $runtimeConf['defaultImagePermissions']['download'] = 'checked'; } + if ($runtimeConf['allowLoginByDefault']) { + $runtimeConf['allowLoginByDefault'] = 'checked'; + } } Render::addTemplate('runtimeconfig', $runtimeConf); } @@ -310,14 +313,29 @@ class Page_DozMod extends Page $data['defaultLecturePermissions'] = Request::post('defaultLecturePermissions', NULL, "array"); $data['defaultImagePermissions'] = Request::post('defaultImagePermissions', NULL, "array"); - $intParams = [ - 'maxImageValidityDays' => array('min' => 7, 'max' => 999), - 'maxLectureValidityDays' => array('min' => 7, 'max' => 999), - 'maxTransfers' => array('min' => 1, 'max' => 10), + $params = [ + 'int' => [ + 'maxImageValidityDays' => array('min' => 7, 'max' => 999), + 'maxLectureValidityDays' => array('min' => 7, 'max' => 999), + 'maxTransfers' => array('min' => 1, 'max' => 10), + ], + 'bool' => [ + 'allowLoginByDefault' => array('default' => true) + ], ]; - foreach($intParams as $field => $limits) { - $value = Request::post($field, 0, 'int'); - $data[$field] = max(min($value, $limits['max']), $limits['min']); + foreach ($params as $type => $list) { + foreach ($list as $field => $limits) { + $default = isset($limits['default']) ? $limits['default'] : false; + $value = Request::post($field, $default); + settype($value, $type); + if (isset($limits['min']) && $value < $limits['min']) { + $value = $limits['min']; + } + if (isset($limits['max']) && $value > $limits['max']) { + $value = $limits['max']; + } + $data[$field] = $value; + } } /* ensure types */ @@ -327,9 +345,6 @@ class Page_DozMod extends Page settype($data['defaultImagePermissions']['admin'], 'boolean'); settype($data['defaultImagePermissions']['link'], 'boolean'); settype($data['defaultImagePermissions']['download'], 'boolean'); - settype($data['maxImageValidityDays'], 'int'); - settype($data['maxLectureValidityDays'], 'int'); - settype($data['maxTransfers'], 'int'); $data = json_encode($data); Database::exec('INSERT INTO sat.configuration (parameter, value)' diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html index e538dee8..9bdc44b0 100644 --- a/modules-available/dozmod/templates/runtimeconfig.html +++ b/modules-available/dozmod/templates/runtimeconfig.html @@ -91,6 +91,17 @@ +