Commit 2983ab81 authored by Penny Leach's avatar Penny Leach
Browse files

fixed typo in get mandatory fields, profile artefact now overrides the

constructor, because profile fields are a bit special since each user
only gets one (except email)
parent 7e7af623
......@@ -80,6 +80,26 @@ class PluginArtefactInternal extends PluginArtefact {
class ArtefactTypeProfile extends ArtefactType {
/**
* overriding this because profile fields
* are unique in that except for email, you only get ONE
* so if we don't get an id, we still need to go look for it
*/
public function __construct($id=0, $data=null) {
$type = $this->get_artefact_type();
if (!empty($id) || $type == 'email') {
return parent::__construct($id, $data);
}
if (!empty($data['owner'])) {
if ($a = get_record('artefact', 'artefacttype', $type, 'owner', $data['owner'])) {
return parent::__construct($a->id, $a);
}
}
$this->ctime = time();
$this->atime = time();
$this->artefacttype = $type;
}
public function commit() {
$this->commit_basic();
}
......@@ -106,7 +126,7 @@ class ArtefactTypeProfile extends ArtefactType {
public static function get_mandatory_fields() {
return array('firstname' => 'text',
'lastname', => 'text',
'lastname' => 'text',
'studentid' => 'text',
'email' => 'text');
}
......
......@@ -162,7 +162,7 @@ function expected_account_preferences() {
function set_profile_field($userid, $field, $value) {
safe_require('artefact', 'internal');
$classname = generate_artefact_class_name($field);
$profile = new $classname();
$profile = new $classname(0, array('owner' => $userid));
$profile->set('owner', $userid);
$profile->set('title', $value);
$profile->commit();
......
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