uploadProfileBanner()

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2013-11-26
481995
public function uploadProfileBanner()
    {
        // If no file was uploaded, do nothing
        if (null === $this->getProfileBannerFile())
        {
            return;
        }

        $file = $this->getProfileBannerFile();

        $image = Image::createFromUploadedFile($file);
        $file->move($image->getUploadDir(), $image->getFilename());

        $this->setProfileBanner($image);

        // Clean up $profileBannerFile since we won't need it any more
        $this->profileBannerFile = null;
    }
593011
public function uploadProfilePicture()
    {
        // If no file was uploaded, do nothing
        if (null === $this->getProfilePictureFile())
        {
            return;
        }

        $file = $this->getProfilePictureFile();

        $image = Image::createFromUploadedFile($file);
        $file->move($image->getUploadDir(), $image->getFilename());

        $this->setProfilePicture($image);

        // Clean up $profilePictureFile since we won't need it any more
        $this->profilePictureFile = null;
    }
924301
public function extendLoginBan() :void {
		// log the action
		Log::warning("Account {$this->get('login', true)} got its ban period extended due to wrong password");
		// updathe the account
		$this->set([
			'last_failure_date'		=>time(),
			'last_failure_agent'	=>Sec::getSafeUserAgent()
		])->save();
	}
723336
public void onProfileClick() {
        //crossfade if we are cross faded
        if (mCrossFader != null) {
            if (mCrossFader.isCrossfaded()) {
                mCrossFader.crossfade();
            }
        }

        //update the current profile
        if (mAccountHeader != null) {
            IProfile profile = mAccountHeader.getActiveProfile();
            if (profile instanceof IDrawerItem) {
                mItemAdapter.set(0, generateMiniDrawerItem((IDrawerItem) profile));
            }
        }
    }
1041071
public function renderProfile()
    {
        $this->checkIsLogin();

        $name = $this->di->get('session')->get("user");
        $user = $this->getUserDetails($name);


        $views = [
            ["comment/user/profile/profile", ["user" => $user], "main"]
        ];

        if ($user->authority == "admin") {
            $views = [
                ["comment/admin/navbar", [], "main"],
                ["comment/user/profile/profile", ["user" => $user], "main"]
            ];
        }

        $this->di->get("pageRenderComment")->renderPage([
            "views" =>  $views,
            "title" => "$user->name"
        ]);
    }
671231
public function uploadAction()
    {
        $request = $this
            ->requestStack
            ->getCurrentRequest();

        /**
         * @var UploadedFile $file
         */
        $file = $request
            ->files
            ->get($this->uploadFieldName);

        if (!($file instanceof UploadedFile)) {
            return new JsonResponse([
                'status' => 'ko',
                'response' => [
                    'message' => 'Image not found',
                ],
            ]);
        }

        try {
            $image = $this
                ->imageUploader
                ->uploadImage($file);

            $routes = $this
                ->router
                ->getRouteCollection();

            $response = [
                'status' => 'ok',
                'response' => [
                    'id' => $image->getId(),
                    'extension' => $image->getExtension(),
                    'routes' => [
                        'view' => $routes
                            ->get($this->viewImageRouteName)
                            ->getPath(),
                        'resize' => $routes
                            ->get($this->resizeImageRouteName)
                            ->getPath(),
                    ],
                ],
            ];
        } catch (Exception $exception) {
            $response = [
                'status' => 'ko',
                'response' => [
                    'message' => $exception->getMessage(),
                ],
            ];
        }

        return new JsonResponse($response);
    }
425681
def createProfile(self, profile=None, clearLayout=True):
        
        if profile:
            prof = profile
        elif not self.viewWidget() or clearLayout:
            prof = XViewProfile()
        else:
            prof = self.viewWidget().saveProfile()
        
        blocked = self.signalsBlocked()
        self.blockSignals(False)
        changed = self.editProfile(prof)
        self.blockSignals(blocked)
        
        if not changed:
            return
        
        act = self.addProfile(prof)
        act.setChecked(True)
        
        # update the interface
        if self.viewWidget() and (profile or clearLayout):
            self.viewWidget().restoreProfile(prof)
        
        if not self.signalsBlocked():
            self.profileCreated.emit(prof)
            self.profilesChanged.emit()
621909
protected static function formProfile() {

		check_admin_referer( 'pb-user-catalog' );

		$user_id = isset( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;

		if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
			wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );
		}

		// Set Redirect URL
		if ( get_current_user_id() !== $user_id ) {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog&user_id=' . $user_id );
		} else {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
		}

		/* Go! */

		$catalog = new static( $user_id );
		$catalog->saveProfile( $_POST );
		$catalog->uploadLogo( 'pb_catalog_logo' );

		$catalog->deleteCache();

		// Ok!
		$_SESSION['pb_notices'][] = __( 'Settings saved.' );

		// Redirect back to form
		\Pressbooks\Redirect\location( $redirect_url );
	}
1201239
public function associateAccount(Users $user, \Hybridauth\User\Profile $socialProfile, $socialNetwork)
    {
        //si no esta asociada tu uenta
        if (!$this->existSocialProfile($socialProfile, $socialNetwork)) {
            $source = Sources::findFirst(['title = :title:', 'bind' => ['title' => strtolower($socialNetwork)]]);

            $userLinkedSources = new self();
            $userLinkedSources->users_id = $user->getId();
            $userLinkedSources->source_id = $source->source_id;
            $userLinkedSources->source_users_id = $socialProfile->identifier;
            $userLinkedSources->source_username = $socialProfile->identifier;

            //since the user is registration via a social network and it was sucessful we need to activate its account
            if (!$user->user_active) {
                $user->user_active = 1;
                $user->update();
            }

            if (!$userLinkedSources->save()) {
                throw new \Exception($userLinkedSources->getMessages()[0]);
            }

            return true;
        }

        return false;
    }
475712
public function add()
    {
        $profile = $this->Profiles->newEntity();
        if ($this->request->is('post')) {
            $profile = $this->Profiles->patchEntity($profile, $this->request->data);
            if ($this->Profiles->save($profile)) {
                $this->Flash->success(__('The profile has been saved.'));

                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error(__('The profile could not be saved. Please, try again.'));
        }
        $users = $this->Profiles->Users->find('list', ['limit' => 200]);
        $this->set(compact('profile', 'users'));
        $this->set('_serialize', ['profile']);
    }
1034080
private void saveUserProfile(Session session, UserProfile profile, boolean broadcast) throws RepositoryException,
      Exception
   {
      Node userNode = utils.getUserNode(session, profile.getUserName());
      Node profileNode = getProfileNode(userNode);

      boolean isNewProfile = profileNode.isNew();

      if (broadcast)
      {
         preSave(profile, isNewProfile);
      }

      writeProfile(profile, profileNode);

      session.save();
      putInCache(profile);

      if (broadcast)
      {
         postSave(profile, isNewProfile);
      }
   }
1227520
public function profile()
    {
        $user = $_SESSION['phpci_user'];

        if ($this->request->getMethod() == 'POST') {
            $name = $this->getParam('name', null);
            $email = $this->getParam('email', null);
            $password = $this->getParam('password', null);

            $currentLang = Lang::getLanguage();
            $chosenLang = $this->getParam('language', $currentLang);

            if ($chosenLang !== $currentLang) {
                setcookie('phpcilang', $chosenLang, time() + (10 * 365 * 24 * 60 * 60), '/');
                Lang::setLanguage($chosenLang);
            }

            $_SESSION['phpci_user'] = $this->userService->updateUser($user, $name, $email, $password);
            $user = $_SESSION['phpci_user'];

            $this->view->updated = 1;
        }

        $this->layout->title = $user->getName();
        $this->layout->subtitle = Lang::get('edit_profile');

        $values = $user->getDataArray();

        if (array_key_exists('phpcilang', $_COOKIE)) {
            $values['language'] = $_COOKIE['phpcilang'];
        }

        $form = new Form();
        $form->setAction(PHPCI_URL.'user/profile');
        $form->setMethod('POST');

        $name = new Form\Element\Text('name');
        $name->setClass('form-control');
        $name->setContainerClass('form-group');
        $name->setLabel(Lang::get('name'));
        $name->setRequired(true);
        $form->addField($name);

        $email = new Form\Element\Email('email');
        $email->setClass('form-control');
        $email->setContainerClass('form-group');
        $email->setLabel(Lang::get('email_address'));
        $email->setRequired(true);
        $form->addField($email);

        $password = new Form\Element\Password('password');
        $password->setClass('form-control');
        $password->setContainerClass('form-group');
        $password->setLabel(Lang::get('password_change'));
        $password->setRequired(false);
        $form->addField($password);

        $lang = new Form\Element\Select('language');
        $lang->setClass('form-control');
        $lang->setContainerClass('form-group');
        $lang->setLabel(Lang::get('language'));
        $lang->setRequired(true);
        $lang->setOptions(Lang::getLanguageOptions());
        $lang->setValue(Lang::getLanguage());
        $form->addField($lang);

        $submit = new Form\Element\Submit();
        $submit->setClass('btn btn-success');
        $submit->setValue(Lang::get('save'));
        $form->addField($submit);

        $form->setValues($values);

        $this->view->form = $form;

        return $this->view->render();
    }
1150258
public function UserInfoModule_OnBasicInfo_Handler($Sender) {
      try {
         // Get the custom fields
         $ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.');

         // Import from CustomProfileFields if available
         if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) {
            $ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE);
			   if ($ProfileFields) {
			      // Migrate to UserMeta & delete original
			      Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.');
			      Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE);
			   }
         }
         
         // Send them off for magic formatting
         $ProfileFields = $this->ParseSpecialFields($ProfileFields);
         
         // Get all field data, error check
         $AllFields = $this->GetProfileFields();
         if (!is_array($AllFields) || !is_array($ProfileFields))
            return;

         // Display all non-hidden fields
         $ProfileFields = array_reverse($ProfileFields);
         foreach ($ProfileFields as $Name => $Value) {
            if (!$Value)
               continue;
            if (!GetValue('OnProfile', $AllFields[$Name]))
               continue;
            if (!in_array($Name, $this->MagicLabels))
               $Value = Gdn_Format::Links(htmlspecialchars($Value));
            echo ' <dt class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.Gdn_Format::Text($AllFields[$Name]['Label']).'</dt> ';
            echo ' <dd class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.$Value.'</dd> ';
         }
      } catch (Exception $ex) {
         // No errors
      }
   }
884465
public function actionProfile($update = false)
    {
        /** @var ProfileForm */
        $model = $this->module->createFormModel('ProfileForm');
        $model->setAttributes($model->getIdentity()->getIdentityAttributes());
        $loadedModel = $model->load($_POST);
        /** @var PasswordForm */
        $passwordForm = $this->module->createFormModel('PasswordForm');
        $loadedPassword = isset($_POST[$passwordForm->formName()]) && trim($_POST[$passwordForm->formName()]['newPassword']) !== '' && $passwordForm->load($_POST);
        if ($loadedModel) {
            if ($model->getIdentity() instanceof PictureIdentityInterface && !empty($model->pictureUploadRules)) {
                $model->picture = \yii\web\UploadedFile::getInstance($model, 'picture');
            }
            $passwordForm->password = $model->password;
        }

        if (Yii::$app->request->isAjax) {
            Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
            $models = [];
            if ($loadedModel) {
                $models[] = $model;
            }
            if ($loadedPassword) {
                $models[] = $passwordForm;
            }

            return \yii\widgets\ActiveForm::validateMultiple($models);
        }
        $flashes = ['success' => [], 'error' => []];
        /**
         * Only try to set new password if it has been specified in the form.
         * The current password could have been used to authorize other changes.
         */
        if ($loadedPassword) {
            if ($passwordForm->validate() && $passwordForm->resetPassword($model->getIdentity())) {
                $flashes['success'][] = Yii::t('usr', 'Changes have been saved successfully.');
            } else {
                $flashes['error'][] = Yii::t('usr', 'Failed to change password.');
            }
        }
        if ($loadedModel && empty($flashes['error'])) {
            if ($model->validate()) {
                $oldEmail = $model->getIdentity()->getEmail();
                if ($model->save($this->module->requireVerifiedEmail)) {
                    if ($this->module->requireVerifiedEmail && $oldEmail != $model->email) {
                        if ($this->sendEmail($model, 'verify')) {
                            $flashes['success'][] = Yii::t('usr', 'An email containing further instructions has been sent to provided email address.');
                        } else {
                            $flashes['error'][] = Yii::t('usr', 'Failed to send an email.').' '.Yii::t('usr', 'Try again or contact the site administrator.');
                        }
                    }
                    $flashes['success'][] = Yii::t('usr', 'Changes have been saved successfully.');
                    if (!empty($flashes['success'])) {
                        Yii::$app->session->setFlash('success', implode('<br/>', $flashes['success']));
                    }
                    if (!empty($flashes['error'])) {
                        Yii::$app->session->setFlash('error', implode('<br/>', $flashes['error']));
                    }

                    return $this->redirect(['profile']);
                } else {
                    $flashes['error'][] = Yii::t('usr', 'Failed to update profile.').' '.Yii::t('usr', 'Try again or contact the site administrator.');
                }
            }
        }
        if (!empty($flashes['success'])) {
            Yii::$app->session->setFlash('success', implode('<br/>', $flashes['success']));
        }
        if (!empty($flashes['error'])) {
            Yii::$app->session->setFlash('error', implode('<br/>', $flashes['error']));
        }
        if ($update) {
            return $this->render('updateProfile', ['model' => $model, 'passwordForm' => $passwordForm]);
        } else {
            return $this->render('viewProfile', ['model' => $model]);
        }
    }
809967
public function profile()
    {
        $userId = $this->Auth->user('id');
        if (!$userId) {
            $this->Flash->error(__d('community', 'You are not logged in'));
            $this->redirect($this->Auth->getConfig('loginAction'));
        }

        $this
            ->set('user', $this->Users->get($userId, ['contain' => 'Groups']))
            ->set('page_title', __d('community', 'Edit profile'));
    }
1112885
public function actionProfile()
    {
        /** @var User $user */
        $user = Yii::$app->getUser()->getIdentity();
        $model = new MultiModel([
            'models' => [
                'user' => $user,
                'profile' => $user->profile,
            ],
        ]);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->addFlash('success', Yii::t('maddoger/user', 'Changes have been saved.'));
            return $this->refresh();
        } else {
            return $this->render('profile', [
                'model' => $model,
            ]);
        }
    }
901075
public function uploadAction()
    {
        $authenticationService = $this->getServiceLocator()->get('zfcuser_auth_service');
        if (!$authenticationService->hasIdentity()) {
            return $this->redirect()->toRoute('zfcuser');
        }

        $user = $this->getUser();
        if (!$user) {
            return $this->notFoundAction();
        }
        $options = $this->getOptions();
        $form = $this->getServiceLocator()->get('HtProfileImage\ProfileImageForm');
        /** @var \Zend\Http\Request $request */
        $request = $this->getRequest();
        $imageUploaded = false;
        if ($request->isPost()) {
            $negotiator   = new FormatNegotiator();
            $format = $negotiator->getBest(
                $request->getHeader('Accept')->getFieldValue(),
                ['application/json', 'text/html']
            );
            if ($this->profileImageService->storeImage($user, $request->getFiles()->toArray())) {
                if ($format->getValue() === 'application/json') {
                    return new Model\JsonModel([
                        'uploaded' => true
                    ]);
                } elseif ($options->getPostUploadRoute()) {
                        return call_user_func_array([$this->redirect(), 'toRoute'], (array) $options->getPostUploadRoute());
                }
                $imageUploaded = true;
            } else {
                $response = $this->getResponse();
                /** @var \Zend\Http\Response $response */
                $response->setStatusCode(400);
                if ($format->getValue() === 'application/json') {
                    return new Model\JsonModel([
                        'error' => true,
                        'messages' => $form->getMessages()
                    ]);
                }

            }
        }

        return new Model\ViewModel([
            'form' => $form,
            'imageUploaded' => $imageUploaded,
            'user' => $user
        ]);
    }