mirror of https://github.com/BOINC/boinc.git
web: updated preferences for stats exports to use new consent table definitions.
This commit is contained in:
parent
2d4f9e4236
commit
b0557ef161
|
@ -142,7 +142,7 @@ $privacy_consent_descs = array(
|
||||||
tra("Do you consent to %1 exporting your data?", PROJECT),
|
tra("Do you consent to %1 exporting your data?", PROJECT),
|
||||||
tra("Data is exported to BOINC statistics aggregation Web sites."),
|
tra("Data is exported to BOINC statistics aggregation Web sites."),
|
||||||
"consent_data_export",
|
"consent_data_export",
|
||||||
2,
|
"STATSEXPORT",
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// PREF_NUM2: a pair of numbers (e.g. transfer limit)
|
// PREF_NUM2: a pair of numbers (e.g. transfer limit)
|
||||||
// PREF_HOUR_RANGE: a range of hours
|
// PREF_HOUR_RANGE: a range of hours
|
||||||
|
|
||||||
|
require_once("../inc/consent.inc");
|
||||||
|
|
||||||
$venues = array("home", "school", "work");
|
$venues = array("home", "school", "work");
|
||||||
|
|
||||||
function check_venue($x) {
|
function check_venue($x) {
|
||||||
|
@ -170,12 +172,12 @@ class PREF_BOOL extends PREF {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PREF_CONSENT extends PREF {
|
class PREF_CONSENT extends PREF {
|
||||||
public $consent_id; // the consent_id to configure
|
public $consent_name; // the consent_name to configure
|
||||||
public $default;
|
public $default;
|
||||||
public $invert; // show to user in opposite sense
|
public $invert; // show to user in opposite sense
|
||||||
|
|
||||||
function __construct($desc, $tooltip, $tag, $consent_id, $default, $invert=false) {
|
function __construct($desc, $tooltip, $tag, $consent_name, $default, $invert=false) {
|
||||||
$this->consent_id = $consent_id;
|
$this->consent_name = $consent_name;
|
||||||
$this->default = $default;
|
$this->default = $default;
|
||||||
$this->invert = $invert;
|
$this->invert = $invert;
|
||||||
parent::__construct($desc, $tooltip, $tag);
|
parent::__construct($desc, $tooltip, $tag);
|
||||||
|
@ -187,8 +189,8 @@ class PREF_CONSENT extends PREF {
|
||||||
global $venues;
|
global $venues;
|
||||||
$this->tooltip_tr();
|
$this->tooltip_tr();
|
||||||
echo "<td class=\"text-right \">$this->desc</td>";
|
echo "<td class=\"text-right \">$this->desc</td>";
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
$cr = BoincConsent::lookup("userid={$user->id} AND consent_name='{$consent_name} ORDER BY consent_time DESC LIMIT 1");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$this->show_value($user);
|
$this->show_value($user);
|
||||||
} else {
|
} else {
|
||||||
|
@ -202,8 +204,8 @@ class PREF_CONSENT extends PREF {
|
||||||
function consent_show($user) {
|
function consent_show($user) {
|
||||||
$this->tooltip_tr();
|
$this->tooltip_tr();
|
||||||
echo "<td class=\"text-right \">$this->desc</td>";
|
echo "<td class=\"text-right \">$this->desc</td>";
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
$cr = BoincConsent::lookup("userid={$user->id} AND consent_name='{$consent_name}' ORDER BY consent_time DESC LIMIT 1");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$this->show_value($user);
|
$this->show_value($user);
|
||||||
} else {
|
} else {
|
||||||
|
@ -220,8 +222,8 @@ class PREF_CONSENT extends PREF {
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_value($user) {
|
function show_value($user) {
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
$cr = BoincConsent::lookup("userid={$user->id} AND consent_name='{$consent_name}' ORDER BY consent_time DESC LIMIT 1");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$value = $cr->consent_flag;
|
$value = $cr->consent_flag;
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,8 +232,8 @@ class PREF_CONSENT extends PREF {
|
||||||
echo "<td>" . readonly_checkbox($value) . "</td>";
|
echo "<td>" . readonly_checkbox($value) . "</td>";
|
||||||
}
|
}
|
||||||
function show_form($user, $error) {
|
function show_form($user, $error) {
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
$cr = BoincConsent::lookup("userid={$user->id} AND consent_name='{$consent_name}' ORDER BY consent_time DESC LIMIT 1");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
if ($this->invert) {
|
if ($this->invert) {
|
||||||
$checked = !$cr->consent_flag;
|
$checked = !$cr->consent_flag;
|
||||||
|
@ -250,22 +252,14 @@ class PREF_CONSENT extends PREF {
|
||||||
function parse_form(&$user, &$error) {
|
function parse_form(&$user, &$error) {
|
||||||
// This function parses the form AND performs the database update
|
// This function parses the form AND performs the database update
|
||||||
$tag = $this->tag;
|
$tag = $this->tag;
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$formget = array_key_exists($tag, $_GET);
|
$formget = array_key_exists($tag, $_GET);
|
||||||
if ($this->invert) $formget = !$formget;
|
if ($this->invert) $formget = !$formget;
|
||||||
$flag = ($formget ? 1 : 0);
|
$flag = ($formget ? 1 : 0);
|
||||||
|
|
||||||
// if record exists modify it, otherwise create
|
$rc = consent_to_a_policy($user, $consent_name, $flag, 0, 'Webform', time());
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
if (!$rc) {
|
||||||
if ($cr) {
|
error_page(tra("Database error:").BoincDb::error());
|
||||||
$cquery = "consent_flag=$flag WHERE userid = $user->id AND consent_id=$consent_id";
|
|
||||||
$cr->update($cquery);
|
|
||||||
} else {
|
|
||||||
$mytime = time();
|
|
||||||
BoincConsent::insert(
|
|
||||||
"(userid, consent_id, consent_time, consent_flag, consent_not_required, source) " .
|
|
||||||
"values($user->id, $consent_id, $mytime, $flag, 0, 'Webform')"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// xml_string should not be used for this class
|
// xml_string should not be used for this class
|
||||||
|
@ -277,11 +271,11 @@ class PREF_CONSENT extends PREF {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function set_default(&$user) {
|
function set_default(&$user) {
|
||||||
$consent_id = $this->consent_id;
|
$consent_name = $this->consent_name;
|
||||||
$cr = BoincConsent::lookup("userid=$user->id AND consent_id=$consent_id");
|
|
||||||
if ($cr) {
|
$rc = consent_to_a_policy($user, $consent_name, $this->default, 0, 'Webform');
|
||||||
$cquery = "consent_id=$consent_id, consent_flag=$this->default WHERE userid = $user->id AND consent_id=$consent_id";
|
if (!$rc) {
|
||||||
$cr->update($cquery);
|
error_page(tra("Database error:").BoincDb::error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,55 +24,63 @@ require_once('../inc/util_ops.inc');
|
||||||
function mct_update() {
|
function mct_update() {
|
||||||
$cid = post_int("consent_id");
|
$cid = post_int("consent_id");
|
||||||
$consent_type = BoincConsentType::lookup("consent_id = $cid");
|
$consent_type = BoincConsentType::lookup("consent_id = $cid");
|
||||||
$consent_type->delete_aux("consent_id = $cid");
|
if ($consent_type) {
|
||||||
echo "<h2>Consent Type $cid deleted (dry-run).</h2>";
|
$myname = $consent_type->shortname;
|
||||||
|
$consent_type->delete_aux("consent_id = $cid");
|
||||||
|
echo "<h2>Consent Type ${myname} deleted.</h2>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function adds a row to consent_type table.
|
// This function adds a row to consent_type table.
|
||||||
function add_consenttype() {
|
function add_consenttype() {
|
||||||
|
$shortname = BoincDb::escape_string(post_str('add_name'));
|
||||||
$description = BoincDb::escape_string(post_str('add_description'));
|
$description = BoincDb::escape_string(post_str('add_description'));
|
||||||
|
|
||||||
|
if (empty($shortname)) {
|
||||||
|
admin_error_page("The new consent type must contain a short name.</font></p>");
|
||||||
|
}
|
||||||
if (empty($description)) {
|
if (empty($description)) {
|
||||||
admin_error_page("The new consent type must contain a description.</font></p>");
|
admin_error_page("The new consent type must contain a description.</font></p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
BoincConsentType::insert(
|
BoincConsentType::insert(
|
||||||
"(description) VALUES ('$description')"
|
"(shortname, description) VALUES ('$shortname', '$description')"
|
||||||
);
|
);
|
||||||
|
|
||||||
echo "<h2>Consent Type added.</h2>";
|
echo "<h2>Consent Type added.</h2>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function mct_show_form() {
|
function mct_show_form() {
|
||||||
$_consenttypes = BoincConsentType::enum("");
|
$_consenttypes = BoincConsentType::enum(null, "ORDER BY protected DESC");
|
||||||
|
|
||||||
if (!in_rops()) {
|
if (!in_rops()) {
|
||||||
echo "<b>You may not delete the first record (id=1) of the consent_type table.</b>";
|
echo "<b>'Protected' consent types are defined by BOINC. You may add project-specific consent types using this form. (Unprotected consent types are defined here by this project.)</b>";
|
||||||
}
|
}
|
||||||
start_table("");
|
start_table("");
|
||||||
table_header(
|
table_header(
|
||||||
"ID",
|
"Name",
|
||||||
"Description",
|
"Description",
|
||||||
|
"Protected",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
$rowi=1;
|
|
||||||
foreach ($_consenttypes as $ct) {
|
foreach ($_consenttypes as $ct) {
|
||||||
echo "<tr class=row$rowi><form action=manage_consent_types.php method=POST>\n";
|
echo "<tr><form action=manage_consent_types.php method=POST>\n";
|
||||||
|
|
||||||
echo "<input type=hidden name=consent_id value=$ct->consent_id>";
|
echo "<input type=hidden name=consent_id value=$ct->consent_id>";
|
||||||
echo " <td>$ct->consent_id</td>";
|
echo " <td>$ct->shortname</td>";
|
||||||
|
|
||||||
echo " <td>$ct->description</td>";
|
echo " <td>$ct->description</td>";
|
||||||
|
|
||||||
if (!in_rops() and ($rowi!=1)) {
|
echo " <td>$ct->protected</td>";
|
||||||
|
|
||||||
|
if (!in_rops() and !($ct->protected)) {
|
||||||
echo "<td><input class=\"btn btn-default\" name=delete type=submit value=Delete>";
|
echo "<td><input class=\"btn btn-default\" name=delete type=submit value=Delete>";
|
||||||
} else {
|
} else {
|
||||||
echo "<td> </td>";
|
echo "<td> </td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</form></tr>";
|
echo "</form></tr>";
|
||||||
$rowi+=1;
|
|
||||||
}
|
}
|
||||||
end_table();
|
end_table();
|
||||||
|
|
||||||
|
@ -89,11 +97,11 @@ function mct_show_form() {
|
||||||
|
|
||||||
start_table("align='center' ");
|
start_table("align='center' ");
|
||||||
|
|
||||||
table_header("id", "Description", " ");
|
table_header("Name", "Description", " ");
|
||||||
|
|
||||||
echo "<TR>
|
echo "<TR>
|
||||||
<TD>(auto-incremented)</TD>
|
<TD> <input type='text' size='10' name='add_name' value=''> </TD>
|
||||||
<TD> <input type='text' size='35' name='add_description' value=''></TD>
|
<TD> <input type='text' size='35' name='add_description' value=''> </TD>
|
||||||
<TD align='center' >
|
<TD align='center' >
|
||||||
<input type='submit' name='add_consenttype' value='Add Consent Type'></TD>
|
<input type='submit' name='add_consenttype' value='Add Consent Type'></TD>
|
||||||
</TR>\n";
|
</TR>\n";
|
||||||
|
|
Loading…
Reference in New Issue