public function removePicture($UserReference = '', $Username = '', $tk = '', $deliveryType = '')
{
$this->permission('Garden.SignIn.Allow');
$Session = Gdn::session();
if (!$Session->isValid()) {
$this->Form->addError('You must be authenticated in order to use this form.');
}
// Get user data & another permission check.
$this->getUserInfo($UserReference, $Username, '', true);
if ($Session->validateTransientKey($tk) && is_object($this->User)) {
$HasRemovePermission = checkPermission('Garden.Users.Edit') || checkPermission('Moderation.Profiles.Edit');
if ($this->User->UserID == $Session->UserID || $HasRemovePermission) {
// Do removal, set message, redirect
Gdn::userModel()->removePicture($this->User->UserID);
$this->informMessage(t('Your picture has been removed.'));
}
}
if ($deliveryType === DELIVERY_TYPE_VIEW) {
$redirectUrl = userUrl($this->User);
} else {
$redirectUrl = userUrl($this->User, '', 'picture');
}
redirect($redirectUrl);
}