From a8ae9f36c627e0db82b24a3833fccefa04c215cd Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Sun, 19 Mar 2017 05:31:25 +0100 Subject: Locationinfo: admin-panel: Fixed a Bug where a space in a credentialname caused errors. Changes the checkbox to bs-switch. --- .../locationinfo/inc/coursebackend/coursebackend_dummy.inc.php | 3 ++- modules-available/locationinfo/page.inc.php | 9 ++++++++- modules-available/locationinfo/templates/server-settings.html | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php index e6ba0fe8..725b4436 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php @@ -29,7 +29,8 @@ class Coursebackend_Dummy extends CourseBackend { public function getCredentials(){ $options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"]; - $credentials = ["username" => ["string", "This is a helptext.", false],"password_str"=>["string", "SOME SECRET PW U WILL NEVER KNOW!", true],"password_int"=>["int", "INT PW", true],"option"=>[$options, "OMG WHAT THE", false], "CheckTheBox" => ["bool", "Test with a cb", false]]; + $credentials = ["username" => ["string", "This is a helptext.", false],"password_str"=>["string", "SOME SECRET PW U WILL NEVER KNOW!", true],"password int"=>["int", "INT PW", true],"option"=>[$options, "OMG WHAT THE", false], "CheckTheBox" => ["bool", "Test with a cb", false], + "CB2 t" => ["bool", "Second checkbox test", false]]; return $credentials; } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index dec022b2..ec024f48 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -119,8 +119,10 @@ class Page_LocationInfo extends Page $tmptypeArray = $backend->getCredentials(); $credentialsJson = array(); + $counter = 0; foreach ($tmptypeArray as $key => $value) { - $credentialsJson[$key] = Request::post($key); + $credentialsJson[$key] = Request::post($counter); + $counter++; } if ($serverid == 0) { Database::exec('INSERT INTO `setting_location_info` (servername, serverurl, servertype, credentials) VALUES (:name, :url, :type, :credentials)', @@ -460,7 +462,10 @@ class Page_LocationInfo extends Page $credentials = $backendInstance->getCredentials(); $backend['credentials'] = array(); + + $counter = 0; foreach ($credentials as $key => $value) { + $credential['uid'] = $counter; $credential['name'] = $key; $credential['type'] = $value[0]; $credential['title'] = $value[1]; @@ -496,6 +501,8 @@ class Page_LocationInfo extends Page } $backend['credentials'][] = $credential; + + $counter++; } $serverBackends[] = $backend; } diff --git a/modules-available/locationinfo/templates/server-settings.html b/modules-available/locationinfo/templates/server-settings.html index f7aa2af8..b42f4c15 100644 --- a/modules-available/locationinfo/templates/server-settings.html +++ b/modules-available/locationinfo/templates/server-settings.html @@ -83,25 +83,26 @@ $("#credentials-list").append('
\
\
\ - \ + \
'); } else if ("{{type}}" == "int") { $("#credentials-list").append('
\
\
\ - \ + \
'); } else if ("{{type}}" == "bool") { $("#credentials-list").append('
\
\
\ - \ + \
'); + $('#bs-{{uid}}').bootstrapSwitch(); } else if ("{{type}}" == "array") { $("#credentials-list").append('
\
\
\ - \ {{#array}}\ \ {{/array}}\ -- cgit v1.2.3-55-g7522