Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace apathy\UsernameStyles\Pub\Controller;
- class Username extends \XF\Pub\Controller\AbstractController
- {
- public function actionIndex()
- {
- $repo = $this->repository('apathy\UsernameStyles:Styles');
- $finder = $repo->findUsernameStyle();
- $userStyle = $finder->fetch();
- $viewParams = [
- 'style' => $userStyle
- ];
- if ($this->isPost())
- {
- $visitor = \XF::visitor();
- if ($visitor->canEditProfile())
- {
- $this->usernameSettingsSave($visitor->user_id)->run();
- }
- return $this->redirect($this->buildLink('account/username-settings'));
- }
- else
- {
- return $this->view('apathy\UsernameStyles:Username',
- 'ap_username_settings',
- $viewParams);
- }
- }
- protected function usernameSettingsSave($userid)
- {
- $form = $this->formAction();
- $input = $this->filter([
- 'bold' => 'int',
- 'color' => 'str',
- 'glow' => 'str',
- 'sparkle' => 'int'
- ]);
- $entity = $this->finder('apathy\UsernameStyles:Username')
- ->where('user_id', $userid)
- ->fetchOne();
- if(!$entity)
- {
- $input['user_id'] = $userid;
- $entity = $this->em()->create('apathy\UsernameStyles:Username');
- }
- $form->basicEntitySave($entity, $input);
- return $form;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement