mirror of https://github.com/BOINC/boinc.git
web: User SQL View latest_consent to obtain consent information for users.
Web site operations can now use latest_consent View.
This commit is contained in:
parent
1aa90e0a15
commit
7bf7d5c0a0
|
@ -945,6 +945,20 @@ class BoincConsentType {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Class to interface with SQL View latest_consent. Only read
|
||||||
|
// operations permitted.
|
||||||
|
class BoincLatestConsent {
|
||||||
|
static function lookup($clause) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->lookup('latest_consent', 'BoincLatestConsent', $clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function enum($where_clause, $order_clause=null) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DEPRECATED: use BoincDb::escape_string where possible
|
// DEPRECATED: use BoincDb::escape_string where possible
|
||||||
//
|
//
|
||||||
// apply this to any user-supplied strings used in queries
|
// apply this to any user-supplied strings used in queries
|
||||||
|
|
|
@ -40,7 +40,7 @@ function consent_to_a_policy($user, $consent_type_id, $consent_flag, $consent_no
|
||||||
function check_user_consent($user, $consent_name) {
|
function check_user_consent($user, $consent_name) {
|
||||||
list($checkct, $ctid) = check_consent_type($consent_name);
|
list($checkct, $ctid) = check_consent_type($consent_name);
|
||||||
if ($checkct) {
|
if ($checkct) {
|
||||||
$consent_result = BoincConsent::lookup("userid={$user->id} AND consent_type_id=$ctid ORDER BY consent_time DESC LIMIT 1");
|
$consent_result = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id=$ctid");
|
||||||
if ( ($consent_result) and ($consent_result->consent_flag) ) {
|
if ( ($consent_result) and ($consent_result->consent_flag) ) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ class PREF_CONSENT extends PREF {
|
||||||
$this->tooltip_tr();
|
$this->tooltip_tr();
|
||||||
echo "<td class=\"text-right \">$this->desc</td>";
|
echo "<td class=\"text-right \">$this->desc</td>";
|
||||||
$consent_type_id = $this->consent_type_id;
|
$consent_type_id = $this->consent_type_id;
|
||||||
$cr = BoincConsent::lookup("userid={$user->id} AND consent_type_id='{$consent_type_id} ORDER BY consent_time DESC LIMIT 1");
|
$cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$this->show_value($user);
|
$this->show_value($user);
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,7 +207,7 @@ class PREF_CONSENT extends PREF {
|
||||||
$this->tooltip_tr();
|
$this->tooltip_tr();
|
||||||
echo "<td class=\"text-right \">$this->desc</td>";
|
echo "<td class=\"text-right \">$this->desc</td>";
|
||||||
$consent_type_id = $this->consent_type_id;
|
$consent_type_id = $this->consent_type_id;
|
||||||
$cr = BoincConsent::lookup("userid={$user->id} AND consent_type_id='{$consent_type_id}' ORDER BY consent_time DESC LIMIT 1");
|
$cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$this->show_value($user);
|
$this->show_value($user);
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,7 +225,7 @@ class PREF_CONSENT extends PREF {
|
||||||
|
|
||||||
function show_value($user) {
|
function show_value($user) {
|
||||||
$consent_type_id = $this->consent_type_id;
|
$consent_type_id = $this->consent_type_id;
|
||||||
$cr = BoincConsent::lookup("userid={$user->id} AND consent_type_id='{$consent_type_id}' ORDER BY consent_time DESC LIMIT 1");
|
$cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
$value = $cr->consent_flag;
|
$value = $cr->consent_flag;
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,7 +235,7 @@ class PREF_CONSENT extends PREF {
|
||||||
}
|
}
|
||||||
function show_form($user, $error) {
|
function show_form($user, $error) {
|
||||||
$consent_type_id = $this->consent_type_id;
|
$consent_type_id = $this->consent_type_id;
|
||||||
$cr = BoincConsent::lookup("userid={$user->id} AND consent_type_id='{$consent_type_id}' ORDER BY consent_time DESC LIMIT 1");
|
$cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'");
|
||||||
if ($cr) {
|
if ($cr) {
|
||||||
if ($this->invert) {
|
if ($this->invert) {
|
||||||
$checked = !$cr->consent_flag;
|
$checked = !$cr->consent_flag;
|
||||||
|
@ -262,7 +262,7 @@ class PREF_CONSENT extends PREF {
|
||||||
// Check to see if latest consent of this name is already
|
// Check to see if latest consent of this name is already
|
||||||
// given, i.e., consent_flag set to "formget". If not, consent
|
// given, i.e., consent_flag set to "formget". If not, consent
|
||||||
// to this consent type.
|
// to this consent type.
|
||||||
$cr= BoincConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}' ORDER BY consent_time DESC LIMIT 1");
|
$cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'");
|
||||||
|
|
||||||
if ( (($cr) and ($cr->consent_flag!=$flag)) or
|
if ( (($cr) and ($cr->consent_flag!=$flag)) or
|
||||||
(!$cr) ) {
|
(!$cr) ) {
|
||||||
|
|
Loading…
Reference in New Issue