load(); if ($profile && $profile->getType() == 'profile' && $profile->canEdit()) { $input_values = array(); $input_values['firstname'] = $firstname; $input_values['lastname'] = $lastname; $input_values['email'] = $email; $input_values['description'] = $description; $input_values['homepage'] = $homepage; $input_values['twitter'] = $twitter; $input_values['delicious'] = $delicious; $input_values['mendeley'] = $mendeley; $input_values['curriculum'] = $curriculum; $input_values['university'] = $university; $input_values['institute'] = $institute; $input_values['skype'] = $skype; $input_values['msn'] = $msn; $input_values['blogurl'] = $blogurl; $input_values['department'] = $department; $_SESSION['input_values'] = $input_values; if (empty($id) || empty($firstname) || empty($lastname) || empty($email)) { $Dippler->add_system_message(_("At least one of the parameters is empty."), 'error'); forward("profile/view/{$user_id}/edit"); } else if (!User::isEmailAddressValid($email)) { $Dippler->add_system_message(_("Provided email address is invalid."), 'error'); forward("profile/view/{$user_id}/edit"); } else if (($new_password || $repeat_new_password) && !($new_password && $repeat_new_password)) { $Dippler->add_system_message(_("Either new password or new password repeat not provided."), 'error'); forward("profile/view/{$user_id}/edit"); } else if (($new_password || $repeat_new_password) && !($new_password == $repeat_new_password)) { $Dippler->add_system_message(_("Provided passwords do not match."), 'error'); forward("profile/view/{$user_id}/edit"); } else if (($new_password || $repeat_new_password) && !User::isPasswordValid($new_password)) { $Dippler->add_system_message(_("Provided password is too short."), 'error'); forward("profile/view/{$user_id}/edit"); } else { $profile->firstname = $firstname; $profile->lastname = $lastname; $profile->description = $description; $profile->homepage = $homepage; $profile->twitter = $twitter; $profile->delicious = $delicious; $profile->mendeley = $mendeley; $profile->skype = $skype; $profile->msn = $msn; $profile->blogurl = $blogurl; $profile->department = $department; // XXX studygroup is not saved (no handlers available) if (!$profile->save()) { $Dippler->add_system_message(_("Profile could not be saved."), 'error'); forward("profile/view/{$user_id}/edit"); } $Dippler->add_system_message(_("Profile saved.")); // Change password if that is needed if ($new_password && $repeat_new_password && $new_password == $repeat_new_password && User::isPasswordValid($new_password)) { $user = $profile->getOwnerEntity(); if ($user->changePassword($new_password)) { $Dippler->add_system_message(_("Password changed. Please note that this will affect any other connected components as connection is using the old password."), 'warning'); } else { $Dippler->add_system_message(_("Password could not be changed."), 'error'); } } // Change email if that is needed if ($email && $email != $profile->getEmail()) { $user = $profile->getOwnerEntity(); $user->email = $email; if (!$Dippler->backoffice->checkUser($email)) { if ($user->changeEmail()) { $Dippler->add_system_message(_("Email address changed. Please note that this will affect any other connected components as connection is using the old email address."), 'warning'); } else { $Dippler->add_system_message(_("Email address could not be changed."), 'error'); } } else { $Dippler->add_system_message(_("The email address you provided is already taken. Email address could not be changed."), 'error'); } } $Dippler->clearSessionInputValues(); forward($profile->getURL()); } } $Dippler->clearSessionInputValues(); forward("");