Commit d8eab8a0 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1432988: adjusting the required social profile field



So that it works similar to how the add social profile page works

Change-Id: I55816577ccc7b2b5f242d09408dcc6ebae88a65a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent ce311b0a
......@@ -1172,28 +1172,17 @@ class ArtefactTypeSocialprofile extends ArtefactTypeProfileField {
*/
public function get_new_profile_elements() {
$socialnetworkoptions = array();
foreach (ArtefactTypeSocialprofile::$socialnetworks as $socialnetwork) {
$socialnetworkoptions[$socialnetwork] = get_string($socialnetwork . '.input', 'artefact.internal');
}
$items = array(
'socialprofile_service' => array(
'type' => 'text',
'title' => get_string('service', 'artefact.internal'),
'description' => get_string('servicedesc', 'artefact.internal'),
'defaultvalue' => null,
'size' => 20,
'rules' => array('required' => true),
),
'socialprofile_profiletype' => array(
'type' => 'select',
'title' => get_string('profiletype', 'artefact.internal'),
'description' => get_string('profiletypedesc', 'artefact.internal'),
'options' => array(
'webpage' => get_string('webpage', 'artefact.internal'),
'aim' => get_string('aim', 'artefact.internal'),
'icq' => get_string('icq', 'artefact.internal'),
'jabber' => get_string('jabber', 'artefact.internal'),
'skype' => get_string('skype', 'artefact.internal'),
'yahoo' => get_string('yahoo', 'artefact.internal'),
),
'defaultvalue' => 'webpage',
'options' => $socialnetworkoptions,
'allowother' => true,
'width' => 171,
'rules' => array('required' => true),
),
......
......@@ -493,9 +493,8 @@ function plugin_account_prefs_submit(Pieform $form, $values) {
/**
* Save a profile field.
* Exception is 'socialprofile' field. It is made up of 3 fields:
* Exception is 'socialprofile' field. It is made up of 2 fields:
* socialprofile_profileurl,
* socialprofile_service,
* socialprofile_profiletype
* @param int $userid
* @param string $field
......@@ -524,11 +523,19 @@ function set_profile_field($userid, $field, $value, $new = FALSE) {
$email->commit();
}
else if ($field == 'socialprofile') {
if (in_array($value['socialprofile_profiletype'], ArtefactTypeSocialprofile::$socialnetworks)) {
$desc = get_string($value['socialprofile_profiletype'], 'artefact.internal');
$type = $value['socialprofile_profiletype'];
}
else {
$desc = $value['socialprofile_profiletype'];
$type = 'website';
}
$classname = generate_artefact_class_name($field);
$profile = new $classname(0, array('owner' => $userid), $new);
$profile->set('title', $value['socialprofile_profileurl']);
$profile->set('description', $value['socialprofile_service']);
$profile->set('note', $value['socialprofile_profiletype']);
$profile->set('description', $desc);
$profile->set('note', $type);
$profile->commit();
}
else {
......
Supports Markdown
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