Default & Domain Settings: Clicking True/False value in Enabled column toggles status.

This commit is contained in:
Nate Jones 2014-10-28 09:17:58 +00:00
parent 1e5db39496
commit 40366ffd8b
2 changed files with 69 additions and 30 deletions

View File

@ -45,6 +45,19 @@ if (sizeof($_REQUEST) > 0) {
$action = check_str($_REQUEST["action"]); $action = check_str($_REQUEST["action"]);
$default_setting_uuids = $_REQUEST["id"]; $default_setting_uuids = $_REQUEST["id"];
$enabled = check_str($_REQUEST['enabled']);
if (sizeof($default_setting_uuids) == 1 && $enabled != '') {
$sql = "update v_default_settings set ";
$sql .= "default_setting_enabled = '".$enabled."' ";
$sql .= "where default_setting_uuid = '".$default_setting_uuids[0]."'";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-update'];
header("Location: default_settings.php");
exit;
}
if ($action == 'copy' && permission_exists('domain_setting_add')) { if ($action == 'copy' && permission_exists('domain_setting_add')) {
@ -318,6 +331,7 @@ if (permission_exists("domain_select") && permission_exists("domain_setting_add"
foreach($result as $row) { foreach($result as $row) {
if ($previous_category != $row['default_setting_category']) { if ($previous_category != $row['default_setting_category']) {
$c = 0;
echo "<tr>\n"; echo "<tr>\n";
echo " <td colspan='7' align='left'>\n"; echo " <td colspan='7' align='left'>\n";
if ($previous_category != '') { echo " <br /><br />"; } if ($previous_category != '') { echo " <br /><br />"; }
@ -340,7 +354,7 @@ if (permission_exists("domain_select") && permission_exists("domain_setting_add"
(permission_exists("domain_select") && permission_exists("domain_setting_add") && count($_SESSION['domains']) > 1) || (permission_exists("domain_select") && permission_exists("domain_setting_add") && count($_SESSION['domains']) > 1) ||
permission_exists('default_setting_delete') permission_exists('default_setting_delete')
) { ) {
echo "<th style='text-align: center;' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all','".strtolower($row['default_setting_category'])."') : check('none','".strtolower($row['default_setting_category'])."');\"></th>"; echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all','".strtolower($row['default_setting_category'])."') : check('none','".strtolower($row['default_setting_category'])."');\"></th>";
} }
echo "<th>".$text['label-subcategory']."</th>"; echo "<th>".$text['label-subcategory']."</th>";
echo "<th>".$text['label-type']."</th>"; echo "<th>".$text['label-type']."</th>";
@ -404,7 +418,9 @@ if (permission_exists("domain_select") && permission_exists("domain_setting_add"
} }
echo " &nbsp;\n"; echo " &nbsp;\n";
echo " </td>\n"; echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".ucwords($row['default_setting_enabled'])."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center;'>\n";
echo " <a href='?id[]=".$row['default_setting_uuid']."&enabled=".(($row['default_setting_enabled'] == 'true') ? 'false' : 'true')."'>".ucwords($row['default_setting_enabled'])."</a>\n";
echo " </td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['default_setting_description']."&nbsp;</td>\n"; echo " <td valign='top' class='row_stylebg'>".$row['default_setting_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('default_setting_edit')) { if (permission_exists('default_setting_edit')) {

View File

@ -35,17 +35,36 @@ else {
} }
//delete domain settings if (sizeof($_REQUEST) > 1) {
if (sizeof($_REQUEST) > 0) {
$action = check_str($_REQUEST["action"]); $action = check_str($_REQUEST["action"]);
$domain_uuid = check_str($_REQUEST["domain_id"]);
$domain_setting_uuids = $_REQUEST["id"];
$enabled = check_str($_REQUEST['enabled']);
//change enabled value
if ($domain_uuid != '' && sizeof($domain_setting_uuids) == 1 && $enabled != '') {
$sql = "update v_domain_settings set ";
$sql .= "domain_setting_enabled = '".$enabled."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and domain_setting_uuid = '".$domain_setting_uuids[0]."' ";
echo $sql."<br><br>";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-update'];
header("Location: domain_edit.php?id=".$domain_uuid);
exit;
}
//delete domain settings
if ($action == 'delete' && permission_exists('domain_setting_delete')) { if ($action == 'delete' && permission_exists('domain_setting_delete')) {
//add multi-lingual support //add multi-lingual support
require_once "app_languages.php"; require_once "app_languages.php";
foreach($text as $key => $value) { foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']]; $text[$key] = $value[$_SESSION['domain']['language']['code']];
} }
//delete the selected domain settings
$domain_setting_uuids = $_REQUEST["id"];
if (sizeof($domain_setting_uuids) > 0) { if (sizeof($domain_setting_uuids) > 0) {
foreach ($domain_setting_uuids as $domain_setting_uuid) { foreach ($domain_setting_uuids as $domain_setting_uuid) {
$sql = "delete from v_domain_settings "; $sql = "delete from v_domain_settings ";
@ -62,10 +81,11 @@ else {
$_SESSION["message"] = $text['message-delete_failed']; $_SESSION["message"] = $text['message-delete_failed'];
$_SESSION["message_mood"] = "negative"; $_SESSION["message_mood"] = "negative";
} }
//redirect the user
header("Location: domain_edit.php?id=".check_str($_REQUEST["domain_uuid"])); header("Location: domain_edit.php?id=".check_str($_REQUEST["domain_uuid"]));
exit; exit;
} }
} //REQUEST } //REQUEST
//include the paging //include the paging
@ -136,6 +156,7 @@ else {
$previous_category = ''; $previous_category = '';
foreach($result as $row) { foreach($result as $row) {
if ($previous_category != $row['domain_setting_category']) { if ($previous_category != $row['domain_setting_category']) {
$c = 0;
echo "<tr>\n"; echo "<tr>\n";
echo " <td colspan='7' align='left'>\n"; echo " <td colspan='7' align='left'>\n";
echo " <br />\n"; echo " <br />\n";
@ -158,7 +179,7 @@ else {
&& permission_exists("domain_setting_add") && permission_exists("domain_setting_add")
&& count($_SESSION['domains']) > 1) || && count($_SESSION['domains']) > 1) ||
permission_exists('domain_setting_delete')) { permission_exists('domain_setting_delete')) {
echo "<th style='text-align: center;' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all','".strtolower($row['domain_setting_category'])."') : check('none','".strtolower($row['domain_setting_category'])."');\"></th>"; echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all','".strtolower($row['domain_setting_category'])."') : check('none','".strtolower($row['domain_setting_category'])."');\"></th>";
} }
echo "<th>".$text['label-subcategory']."</th>"; echo "<th>".$text['label-subcategory']."</th>";
echo "<th>".$text['label-type']."</th>"; echo "<th>".$text['label-type']."</th>";
@ -221,7 +242,9 @@ else {
} }
echo " &nbsp;\n"; echo " &nbsp;\n";
echo " </td>\n"; echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".ucwords($row['domain_setting_enabled'])."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center;'>\n";
echo " <a href='?domain_id=".$row['domain_uuid']."&id[]=".$row['domain_setting_uuid']."&enabled=".(($row['domain_setting_enabled'] == 'true') ? 'false' : 'true')."'>".ucwords($row['domain_setting_enabled'])."</a>\n";
echo " </td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['domain_setting_description']."&nbsp;</td>\n"; echo " <td valign='top' class='row_stylebg'>".$row['domain_setting_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('domain_setting_edit')) { if (permission_exists('domain_setting_edit')) {