Commit 7aeadfcc authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add method to request institution membership

parent 5af7bb0b
......@@ -346,13 +346,14 @@ class User {
}
public function join_institution($institution) {
$institutions = $this->get('institutions');
if (!isset($institutions[$institution])) {
if ($institution != 'mahara' && !$this->in_institution($institution)) {
// @todo: set expiry, studentid, ctime
insert_record('usr_institution', (object) array(
'usr' => $this->get('id'),
'institution' => $institution
));
delete_records('usr_institution_request', 'usr', $this->get('id'), 'institution', $institution);
// Send confirmation
}
}
......@@ -374,6 +375,28 @@ class User {
$this->set('admininstitutions', array_combine($institutions, $institutions));
}
public function add_institution_request($institution) {
if (empty($institution) || $institution == 'mahara') {
return;
}
$request = get_record('usr_institution_request', 'usr', $this->get('id'), 'institution', $institution);
if (!$request) {
$request = (object) array(
'usr' => $this->get('id'),
'institution' => $institution,
'confirmedusr' => 1,
'studentid' => $this->get('studentid'),
'ctime' => db_format_timestamp(time())
);
insert_record('usr_institution_request', $request);
// Send request notification
} else if ($request->confirmedinstitution) {
$this->join_institution($institution);
delete_records('usr_institution_request', 'usr', $this->get('id'), 'institution', $institution);
// Send confirmation
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment