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
|
||||
//
|
||||
// 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) {
|
||||
list($checkct, $ctid) = check_consent_type($consent_name);
|
||||
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) ) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ class PREF_CONSENT extends PREF {
|
|||
$this->tooltip_tr();
|
||||
echo "<td class=\"text-right \">$this->desc</td>";
|
||||
$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) {
|
||||
$this->show_value($user);
|
||||
} else {
|
||||
|
@ -207,7 +207,7 @@ class PREF_CONSENT extends PREF {
|
|||
$this->tooltip_tr();
|
||||
echo "<td class=\"text-right \">$this->desc</td>";
|
||||
$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) {
|
||||
$this->show_value($user);
|
||||
} else {
|
||||
|
@ -225,7 +225,7 @@ class PREF_CONSENT extends PREF {
|
|||
|
||||
function show_value($user) {
|
||||
$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) {
|
||||
$value = $cr->consent_flag;
|
||||
} else {
|
||||
|
@ -235,7 +235,7 @@ class PREF_CONSENT extends PREF {
|
|||
}
|
||||
function show_form($user, $error) {
|
||||
$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 ($this->invert) {
|
||||
$checked = !$cr->consent_flag;
|
||||
|
@ -262,7 +262,7 @@ class PREF_CONSENT extends PREF {
|
|||
// Check to see if latest consent of this name is already
|
||||
// given, i.e., consent_flag set to "formget". If not, consent
|
||||
// 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
|
||||
(!$cr) ) {
|
||||
|
|
Loading…
Reference in New Issue