diff --git a/html/ops/manage_consent_types.php b/html/ops/manage_consent_types.php index 4f889fb49d..9f92937cc1 100644 --- a/html/ops/manage_consent_types.php +++ b/html/ops/manage_consent_types.php @@ -21,7 +21,7 @@ require_once('../inc/util_ops.inc'); // This function deletes a row from consent_type table. -function mct_update() { +function mct_delete() { $cid = post_int("consent_id"); $consent_type = BoincConsentType::lookup("consent_id = $cid"); if ($consent_type) { @@ -50,6 +50,28 @@ function add_consenttype() { echo "

Consent Type added.

"; } +// Toggles the enable flag +function mct_toggle_field($field) { + $cid = post_int("consent_id"); + $toggle = post_str("toggle" . $field); + if ($toggle == "Click to Enable") { + $state = 1; + $action = "Enabled"; + } + else { + $state = 0; + $action = "Disabled"; + } + + $consent_type = BoincConsentType::lookup("consent_id = $cid"); + if ($consent_type) { + $myname = $consent_type->shortname; + $consent_type->update("$field=$state where consent_id=$cid"); + echo "

Consent Type ${myname} $field changed to $action

"; + } +} + +// Builds the form for managing consent types function mct_show_form() { $_consenttypes = BoincConsentType::enum(null, "ORDER BY protected DESC"); @@ -60,23 +82,56 @@ function mct_show_form() { table_header( "Name", "Description", + "Enabled", "Protected", + "PrivacyPrefs", "" ); foreach ($_consenttypes as $ct) { echo "
\n"; + // Name echo "consent_id>"; echo " $ct->shortname"; + // Description echo " $ct->description"; + // Enabled toggle + if (!in_rops()) { + if (!($ct->enabled)) { + echo " "; + } + else { + echo " "; + } + } + else { + echo " $ct->enabled"; + } + + // Protected echo " $ct->protected"; + // Privacypref toggle + if (!in_rops()) { + if (!($ct->privacypref)) { + echo " "; + } + else { + echo " "; + } + } + else { + echo " $ct->privacypref"; + } + + // Delete (if not protected) if (!in_rops() and !($ct->protected)) { echo ""; - } else { + } + else { echo " "; } @@ -92,6 +147,9 @@ function mct_show_form() { echo"

Add consent type

+

HELP: To add a consent type, provide a name and description. Then you may toggle the Enabled and PrivacyPrefs settings in the table above.

+

For Name, please stick to this convention: an ALLCAPS short name, without any spaces. Example: FORUM

+

For Description: if your consent type will be part of the privacy preferences, it is best to use a full sentence with a question mark at the end. Example: Do you want SPAM, bacon, sausage, and SPAM?

"; @@ -118,7 +176,13 @@ if (post_str("add_consenttype", true)) { add_consenttype(); } else if (post_str("delete", true)) { - mct_update(); + mct_delete(); +} +else if (post_str("toggleenabled", true)) { + mct_toggle_field("enabled"); +} +else if (post_str("toggleprivacypref", true)) { + mct_toggle_field("privacypref"); } // Main display function - shows the form with consent types.