public function update($userId) { //Verify the user can access this user record - we don't need the record just the auth check $user = User::findWithPermission($userId); $input = \Input::all(); //Clear the profile photo field as this is handled separately below. unset($input['new_profile_photo']); if (empty($input['profile_photo_private'])) { $input['profile_photo_private'] = false; } //Trim all the data so some of the validation doesn't choke on spaces foreach ($input as $key => $value) { if (is_string($value)) { $input[$key] = trim($value); } } $this->profileValidator->validate($input, $userId); $this->profileRepo->update($userId, $input); if (\Input::file('new_profile_photo')) { try { $this->userImage->uploadPhoto($user->hash, \Input::file('new_profile_photo')->getRealPath(), true); $this->profileRepo->update($userId, ['new_profile_photo' => 1]); \Notification::success("Photo uploaded, it will be checked and appear shortly"); } catch (\Exception $e) { \Log::error($e); } } else { \Notification::success("Profile Updated"); } return \Redirect::route('members.show', $userId); }
public function adminUpdate($id) { $user = User::findWithPermission($id); $madeTrusted = false; if (\Input::has('trusted')) { if (!$user->trusted && \Input::get('trusted')) { //User has been made a trusted member $madeTrusted = true; } $user->trusted = \Input::get('trusted'); } if (\Input::has('key_holder')) { $user->key_holder = \Input::get('key_holder'); } if (\Input::has('induction_completed')) { $user->induction_completed = \Input::get('induction_completed'); } if (\Input::has('profile_photo_on_wall')) { $profileData = $user->profile()->first(); $profileData->profile_photo_on_wall = \Input::get('profile_photo_on_wall'); $profileData->save(); } if (\Input::has('photo_approved')) { $profile = $user->profile()->first(); if (\Input::get('photo_approved')) { $this->userImage->approveNewImage($user->hash); $profile->update(['new_profile_photo' => false, 'profile_photo' => true]); } else { $profile->update(['new_profile_photo' => false]); event(new MemberPhotoWasDeclined($user)); } } $user->save(); if (\Input::has('approve_new_address')) { if (\Input::get('approve_new_address') == 'Approve') { $this->addressRepository->approvePendingMemberAddress($id); } elseif (\Input::get('approve_new_address') == 'Decline') { $this->addressRepository->declinePendingMemberAddress($id); } } if ($madeTrusted) { $message = 'You have been made a trusted member at Build Brighton'; $notificationHash = 'trusted_status'; Notification::logNew($user->id, $message, 'trusted_status', $notificationHash); event(new MemberGivenTrustedStatus($user)); } if (\Request::wantsJson()) { return \Response::json('Updated', 200); } else { \Notification::success('Details Updated'); return \Redirect::route('account.show', [$user->id]); } }
public function memberPhoto($profileData, $userHash, $size = 250, $class = 'profilePhoto') { if ($profileData->profile_photo) { if (\Auth::guest() && $profileData->profile_photo_private) { return '<img src="' . \BB\Helpers\UserImage::anonymous() . '" width="' . $size . '" height="' . $size . '" class="' . $class . '" />'; } elseif (!\Auth::guest() && !\Auth::user()->shouldMemberSeeProtectedPhoto() && $profileData->profile_photo_private) { return '<img src="' . \BB\Helpers\UserImage::anonymous() . '" width="' . $size . '" height="' . $size . '" class="' . $class . '" />'; } else { return '<img src="' . \BB\Helpers\UserImage::thumbnailUrl($userHash) . '" width="' . $size . '" height="' . $size . '" class="' . $class . '" />'; } } else { return '<img src="' . \BB\Helpers\UserImage::anonymous() . '" width="' . $size . '" height="' . $size . '" class="' . $class . '" />'; } }