Commit 0284a2da authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Bug 1432988: adjusting the required social profile field"

parents 530a10c5 d8eab8a0
...@@ -1172,28 +1172,17 @@ class ArtefactTypeSocialprofile extends ArtefactTypeProfileField { ...@@ -1172,28 +1172,17 @@ class ArtefactTypeSocialprofile extends ArtefactTypeProfileField {
*/ */
public function get_new_profile_elements() { public function get_new_profile_elements() {
$socialnetworkoptions = array();
foreach (ArtefactTypeSocialprofile::$socialnetworks as $socialnetwork) {
$socialnetworkoptions[$socialnetwork] = get_string($socialnetwork . '.input', 'artefact.internal');
}
$items = array( $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( 'socialprofile_profiletype' => array(
'type' => 'select', 'type' => 'select',
'title' => get_string('profiletype', 'artefact.internal'), 'title' => get_string('profiletype', 'artefact.internal'),
'description' => get_string('profiletypedesc', 'artefact.internal'), 'options' => $socialnetworkoptions,
'options' => array( 'allowother' => true,
'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',
'width' => 171, 'width' => 171,
'rules' => array('required' => true), 'rules' => array('required' => true),
), ),
......
...@@ -493,9 +493,8 @@ function plugin_account_prefs_submit(Pieform $form, $values) { ...@@ -493,9 +493,8 @@ function plugin_account_prefs_submit(Pieform $form, $values) {
/** /**
* Save a profile field. * 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_profileurl,
* socialprofile_service,
* socialprofile_profiletype * socialprofile_profiletype
* @param int $userid * @param int $userid
* @param string $field * @param string $field
...@@ -524,11 +523,19 @@ function set_profile_field($userid, $field, $value, $new = FALSE) { ...@@ -524,11 +523,19 @@ function set_profile_field($userid, $field, $value, $new = FALSE) {
$email->commit(); $email->commit();
} }
else if ($field == 'socialprofile') { 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); $classname = generate_artefact_class_name($field);
$profile = new $classname(0, array('owner' => $userid), $new); $profile = new $classname(0, array('owner' => $userid), $new);
$profile->set('title', $value['socialprofile_profileurl']); $profile->set('title', $value['socialprofile_profileurl']);
$profile->set('description', $value['socialprofile_service']); $profile->set('description', $desc);
$profile->set('note', $value['socialprofile_profiletype']); $profile->set('note', $type);
$profile->commit(); $profile->commit();
} }
else { 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