2018-05-04 23:42:05 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2017 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// functions dealing with the consent and consent_type tables.
|
|
|
|
|
|
|
|
include_once("../inc/boinc_db.inc");
|
|
|
|
include_once("../inc/util.inc");
|
|
|
|
|
2018-05-24 17:00:48 +00:00
|
|
|
function consent_to_a_policy($user, $consent_name, $consent_flag, $consent_not_required, $source, $ctime = 0) {
|
|
|
|
$myn = BoincDb::escape_string($consent_name);
|
2018-05-04 23:42:05 +00:00
|
|
|
$mys = BoincDb::escape_string($source);
|
|
|
|
if ($ctime==0) {
|
|
|
|
$mytime = $user->create_time;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$mytime = $ctime;
|
|
|
|
}
|
|
|
|
return BoincConsent::insert(
|
2018-05-24 17:00:48 +00:00
|
|
|
"(id, userid, consent_name, consent_time, consent_flag, consent_not_required, source) " .
|
|
|
|
"values(0, $user->id, '$myn', $mytime, $consent_flag, $consent_not_required, '$mys')"
|
2018-05-04 23:42:05 +00:00
|
|
|
);
|
|
|
|
|
2018-05-08 19:36:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function consent_after_login($user, $perm=true, $next_url = "") {
|
|
|
|
session_start();
|
|
|
|
$_SESSION['user'] = $user;
|
|
|
|
$_SESSION['perm'] = $perm;
|
|
|
|
$save_url = $next_url;
|
2018-05-24 17:00:48 +00:00
|
|
|
$consent_result = BoincConsent::lookup("userid={$user->id} AND consent_name='ENROLL' ORDER BY consent_time DESC LIMIT 1");
|
2018-05-08 19:36:05 +00:00
|
|
|
if ($consent_result) {
|
|
|
|
if ($consent_result->consent_flag != 1) {
|
|
|
|
$next_url = "user_optin.php?next_url=$save_url";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
send_cookie('auth', $user->authenticator, $perm);
|
|
|
|
session_unset();
|
|
|
|
session_destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$next_url = "user_optin.php?next_url=$save_url";
|
|
|
|
}
|
|
|
|
return $next_url;
|
2018-05-22 20:40:18 +00:00
|
|
|
}
|
2018-06-01 20:13:51 +00:00
|
|
|
|
|
|
|
// Checks to see if a particular consent_type name is in available and
|
|
|
|
// enabled.
|
|
|
|
function check_consent_type($name) {
|
|
|
|
$ct = BoincConsentType::lookup("shortname = '{$name}'");
|
|
|
|
if ($ct and ($ct->enabled)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|