Ejemplo n.º 1
0
 /**
  * doExecute
  *
  * @return  void
  */
 public function doExecute()
 {
     $faker = Factory::create();
     if (WarderHelper::tableExists('users')) {
         $userIds = UserMapper::findAll()->id;
     } else {
         $userIds = range(1, 50);
     }
     $positions = $faker->words(20);
     $types = ModuleHelper::getModuleTypes()->dump();
     foreach (range(1, 75) as $i) {
         $data = new Data();
         /** @var \Lyrasoft\Luna\Module\ModuleType $module */
         $module = $faker->randomElement($types);
         $data['title'] = $faker->sentence(mt_rand(3, 5));
         $data['type'] = $module->type;
         $data['class'] = $module->class;
         $data['position'] = $faker->randomElement($positions);
         $data['note'] = $faker->sentence(5);
         $data['content'] = $faker->paragraph(5);
         $data['state'] = $faker->randomElement(array(1, 1, 1, 1, 0, 0));
         $data['created'] = $faker->dateTime->format(DateTime::getSqlFormat());
         $data['created_by'] = $faker->randomElement($userIds);
         $data['modified'] = $faker->dateTime->format(DateTime::getSqlFormat());
         $data['modified_by'] = $faker->randomElement($userIds);
         $data['ordering'] = $i;
         $data['language'] = 'en-GB';
         $data['params'] = '';
         ModuleMapper::createOne($data);
         $this->outCounting();
     }
 }
Ejemplo n.º 2
0
 /**
  * doExecute
  *
  * @return  void
  */
 public function doExecute()
 {
     $faker = Factory::create();
     $articleIds = ArticleMapper::findAll()->id;
     if (WarderHelper::tableExists('users')) {
         $userIds = UserMapper::findAll()->id;
     } else {
         $userIds = range(1, 50);
     }
     foreach ($articleIds as $articleId) {
         foreach (range(3, mt_rand(5, 7)) as $i) {
             $data = new Data();
             $data['target_id'] = $articleId;
             $data['type'] = 'article';
             $data['user_id'] = $faker->randomElement($userIds);
             $data['title'] = $faker->sentence(mt_rand(3, 5));
             $data['content'] = $faker->paragraph(5);
             $data['reply'] = $faker->paragraph(3);
             $data['reply_user_id'] = $faker->randomElement($userIds);
             $data['created'] = $faker->dateTime->format(DateTime::getSqlFormat());
             $data['created_by'] = $faker->randomElement($userIds);
             $data['modified'] = $faker->dateTime->format(DateTime::getSqlFormat());
             $data['modified_by'] = $faker->randomElement($userIds);
             $data['ordering'] = $i;
             $data['state'] = 1;
             $data['params'] = '';
             CommentMapper::createOne($data);
             $this->outCounting();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $loginName = WarderHelper::getLoginName();
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add($loginName, new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.' . $loginName));
     $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'));
     $form->add('remember', new Field\CheckboxField())->label(Translator::translate($langPrefix . 'user.field.remember'));
 }
Ejemplo n.º 4
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'))->set('placeholder', Translator::translate($langPrefix . 'user.field.password'));
     $form->add('password2', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password.confirm'))->set('placeholder', Translator::translate($langPrefix . 'user.field.password.confirm'));
     $form->add('email', new Field\HiddenField());
     $form->add('token', new Field\HiddenField());
 }
Ejemplo n.º 5
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $warder = WarderHelper::getPackage();
         $this->redirect($this->router->route($warder->get('frontend.redirect.login', 'home')));
         return;
     }
     parent::prepareExecute();
 }
Ejemplo n.º 6
0
 /**
  * buildInput
  *
  * @param array $attrs
  *
  * @return  string
  */
 public function buildInput($attrs)
 {
     $warder = WarderHelper::getPackage();
     $this->package = $this->get('package') ?: WarderHelper::getAdminPackage(true);
     $this->table = $this->get('table') ?: WarderTable::USERS;
     $langPrefix = $this->get('lang_prefix') ?: $warder->get('admin.language.prefix');
     $this->def('buttonText', '<i class="glyphicon glyphicon-user fa fa-user"></i> ' . Translator::translate($langPrefix . 'user.modal.field.button.select'));
     return parent::buildInput($attrs);
 }
Ejemplo n.º 7
0
 /**
  * setTitle
  *
  * @param string $title
  *
  * @return  static
  */
 public function setTitle($title = null)
 {
     $layout = $this->getLayout();
     if ($layout != 'user' && !$title) {
         $langPrefix = WarderHelper::getPackage()->get('admin.language.prefix', 'warder.');
         $title = Translator::translate($langPrefix . $layout . '.title');
     }
     return parent::setTitle($title);
 }
Ejemplo n.º 8
0
 /**
  * goToLogin
  *
  * @param   string  $return
  *
  * @return  void
  */
 public static function goToLogin($return = null)
 {
     $query = array();
     if ($return) {
         $query['return'] = base64_encode($return);
     }
     $package = WarderHelper::getPackage()->getCurrentPackage();
     $url = $package->router->route('login', $query);
     Ioc::getApplication()->redirect($url);
 }
Ejemplo n.º 9
0
 /**
  * getSuccessRedirect
  *
  * @param DataInterface $data
  *
  * @return  string
  */
 protected function getSuccessRedirect(DataInterface $data = null)
 {
     $return = $this->getUserState($this->getContext('return'));
     if ($return) {
         $this->removeUserState($this->getContext('return'));
         return base64_decode($return);
     } else {
         return $this->router->route(WarderHelper::getPackage()->get('frontend.redirect.login', 'home'));
     }
 }
Ejemplo n.º 10
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $warder = WarderHelper::getPackage();
         $this->redirect($this->router->route($warder->get('frontend.redirect.login', 'home')));
         return;
     }
     parent::prepareExecute();
     $this->data['email'] = $this->input->getEmail('email');
     $this->data['token'] = $this->input->get('token');
 }
Ejemplo n.º 11
0
 /**
  * doExecute
  *
  * @return  mixed
  */
 protected function doExecute()
 {
     User::logout();
     $return = $this->input->getBase64($this->package->get('admin.login.return_key', 'return'));
     if ($return) {
         $this->setRedirect(base64_decode($return));
         return true;
     }
     $this->setRedirect($this->router->route(WarderHelper::getPackage()->get('admin.redirect.logout', 'home')));
     return true;
 }
Ejemplo n.º 12
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $loginName = WarderHelper::getLoginName();
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->wrap('basic', null, function (Form $form) use($loginName, $langPrefix) {
         $form->add('name', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.name'))->required();
         if (strtolower($loginName) != 'email') {
             $form->add($loginName, new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.' . $loginName))->setValidator(new UserExistsValidator($loginName))->required();
         }
         $form->add('email', new Field\EmailField())->label(Translator::translate($langPrefix . 'user.field.email'))->setValidator(new UserExistsValidator('email'))->required();
         $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'))->set('autocomplete', 'off');
         $form->add('password2', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password.confirm'))->set('autocomplete', 'off');
     });
 }
Ejemplo n.º 13
0
 /**
  * check
  *
  * @return  static
  */
 public function check()
 {
     $loginName = WarderHelper::getLoginName();
     if (!$this->{$loginName}) {
         throw new \InvalidArgumentException(Translator::translate('warder.user.account.empty'));
     }
     $exists = UserMapper::findOne(array($loginName => $this->{$loginName}));
     if ($exists->notNull() && $this->id != $exists->id) {
         throw new \InvalidArgumentException(Translator::sprintf('warder.user.save.message.exists', $loginName, $this->{$loginName}));
     }
     if ($this->email) {
         $exists = UserMapper::findOne(array('email' => $this->email));
         if ($exists->notNull() && $this->id != $exists->id) {
             throw new \InvalidArgumentException(Translator::sprintf('warder.user.save.message.exists', $loginName, $this->email));
         }
     }
     return $this;
 }
Ejemplo n.º 14
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 protected function doDefine(Form $form)
 {
     $warder = WarderHelper::getPackage();
     $loginName = WarderHelper::getLoginName();
     $langPrefix = $warder->get('admin.language.prefix');
     /*
      * Search Control
      * -------------------------------------------------
      * Add search fields as options, by default, model will search all columns.
      * If you hop that user can choose a field to search, change "display" to true.
      */
     $this->wrap(null, 'search', function (Form $form) use($loginName, $langPrefix) {
         // Search Field
         $fieldField = $this->list('field')->label(Translator::translate('phoenix.grid.search.user.field.label'))->set('display', false)->defaultValue('*')->option(Translator::translate('phoenix.core.all'), '*');
         if ($loginName != 'email') {
             $fieldField->option(Translator::translate($langPrefix . 'user.field.' . $loginName), 'user.' . $loginName);
         }
         $fieldField->option(Translator::translate($langPrefix . 'user.field.name'), 'user.name')->option(Translator::translate($langPrefix . 'user.field.email'), 'user.email')->option(Translator::translate($langPrefix . 'user.field.id'), 'user.id');
         // Search Content
         $this->text('content')->label(Translator::translate('phoenix.grid.search.label'))->set('placeholder', Translator::translate('phoenix.grid.search.label'));
     });
     /*
      * Filter Control
      * -------------------------------------------------
      * Add filter fields to this section.
      * Remember to add onchange event => this.form.submit(); or Phoenix.post();
      *
      * You can override filter actions in UsersModel::configureFilters()
      */
     $this->wrap(null, 'filter', function (Form $form) use($loginName, $langPrefix) {
         // Activated
         $this->list('activation')->label($langPrefix . 'filter.activation.label')->option('', '')->option(Translator::translate($langPrefix . 'filter.activation.select'), '')->option(Translator::translate($langPrefix . 'filter.activation.activated'), '1')->option(Translator::translate($langPrefix . 'filter.activation.unactivated'), '0')->set('onchange', 'this.form.submit()');
         // State
         $this->list('user.blocked')->label($langPrefix . 'filter.block.label')->option('', '')->option(Translator::translate($langPrefix . 'filter.block.select'), '')->option(Translator::translate($langPrefix . 'filter.block.blocked'), '1')->option(Translator::translate($langPrefix . 'filter.block.unblocked'), '0')->set('onchange', 'this.form.submit()');
     });
     /*
      * This is batch form definition.
      * -----------------------------------------------
      * Every field is a table column.
      * For example, you can add a 'category_id' field to update item category.
      */
     $this->wrap(null, 'batch', function (Form $form) {
     });
 }
Ejemplo n.º 15
0
 /**
  * doExecute
  *
  * @return  void
  */
 public function doExecute()
 {
     $faker = Factory::create();
     $languages = LanguageMapper::find(array('state' => 1))->code;
     $languages[] = '*';
     $categories = CategoryMapper::find(array('parent_id != 0', 'type' => 'article'));
     if (WarderHelper::tableExists('users')) {
         $userIds = UserMapper::findAll()->id;
     } else {
         $userIds = range(1, 50);
     }
     $tags = TagMapper::findAll()->dump();
     foreach ($categories as $category) {
         foreach (range(7, 15) as $i) {
             $data = new Data();
             $lang = $faker->randomElement($languages);
             $data['category_id'] = $category->id;
             $data['title'] = '(' . $lang . ') ' . $faker->sentence(mt_rand(3, 5));
             $data['alias'] = OutputFilter::stringURLSafe($data['title']);
             $data['introtext'] = '(' . $lang . ') ' . $faker->paragraph(5);
             $data['fulltext'] = $faker->paragraph(5);
             $data['image'] = UnsplashHelper::getImageUrl();
             $data['state'] = $faker->randomElement(array(1, 1, 1, 1, 0, 0));
             $data['version'] = mt_rand(1, 50);
             $data['created'] = $faker->dateTime->format(DateTime::getSqlFormat());
             $data['created_by'] = $faker->randomElement($userIds);
             $data['modified'] = $faker->dateTime->format(DateTime::getSqlFormat());
             $data['modified_by'] = $faker->randomElement($userIds);
             $data['ordering'] = $i;
             $data['language'] = $lang;
             $data['params'] = '';
             ArticleMapper::createOne($data);
             foreach ($faker->randomElements($tags, mt_rand(5, 7)) as $tag) {
                 $map = new Data();
                 $map->tag_id = $tag->id;
                 $map->target_id = $data->id;
                 $map->type = 'article';
                 TagMapMapper::createOne($map);
             }
             $this->outCounting();
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $warder = WarderHelper::getPackage();
     $loginName = WarderHelper::getLoginName();
     $langPrefix = $warder->get('admin.language.prefix', 'warder.');
     // Basic fieldset
     $form->wrap('basic', null, function (Form $form) use($loginName, $langPrefix) {
         // Name
         $form->add('name', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.name'))->required(true);
         if ($loginName != 'email') {
             // Name
             $form->add($loginName, new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.' . $loginName))->required(true);
         }
         // Email
         $form->add('email', new Field\EmailField())->label(Translator::translate($langPrefix . 'user.field.email'))->required();
         // Password
         $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'));
         // Password
         $form->add('password2', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password.confirm'));
     });
     // Created fieldset
     $form->wrap('created', null, function (Form $form) use($langPrefix) {
         if (class_exists(SingleImageDragField::class)) {
             // Avatar
             $form->add('avatar', new SingleImageDragField())->label(Translator::translate($langPrefix . 'user.field.avatar'))->set('default_image', AvatarUploadHelper::getDefaultImage());
         }
         // Blocked
         $form->add('blocked', new Field\RadioField())->label(Translator::translate($langPrefix . 'user.field.name'))->set('class', 'btn-group')->set('default', 0)->option(Translator::translate($langPrefix . 'user.field.blocked.block'), 1)->option(Translator::translate($langPrefix . 'user.field.blocked.unblock'), 0);
         // ID
         $form->add('id', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.id'))->readonly();
         // Registered
         $form->add('registered', new CalendarField())->label(Translator::translate($langPrefix . 'user.field.registered'))->disabled();
         // Last Login
         $form->add('last_login', new CalendarField())->label(Translator::translate($langPrefix . 'user.field.last.login'))->disabled();
         // Last Reset
         //			$form->add('last_reset', new CalendarField)
         //				->label(Translator::translate($langPrefix . 'user.field.last.reset'))
         //				->set('readonly', true);
     });
 }
Ejemplo n.º 17
0
 /**
  * doExecute
  *
  * @return  void
  */
 public function doExecute()
 {
     $faker = Factory::create();
     $record = new CategoryRecord();
     $languages = LanguageMapper::find(array('state' => 1))->code;
     $languages[] = '*';
     if (WarderHelper::tableExists('users')) {
         $userIds = UserMapper::findAll()->id;
     } else {
         $userIds = range(1, 50);
     }
     $existsRecordIds = array();
     foreach ($this->types as $type) {
         $existsRecordIds[$type] = array(1);
     }
     foreach (range(1, 30) as $i) {
         $record->reset();
         $lang = $faker->randomElement($languages);
         $record['title'] = $faker->sentence(mt_rand(1, 3)) . ' - [' . $lang . ']';
         $record['alias'] = OutputFilter::stringURLSafe($record['title']);
         $record['type'] = $faker->randomElement($this->types);
         $record['description'] = $faker->paragraph(5);
         $record['image'] = UnsplashHelper::getImageUrl();
         $record['state'] = $faker->randomElement(array(1, 1, 1, 1, 0, 0));
         $record['version'] = mt_rand(1, 50);
         $record['created'] = $faker->dateTime->format(DateTime::getSqlFormat());
         $record['created_by'] = $faker->randomElement($userIds);
         $record['modified'] = $faker->dateTime->format(DateTime::getSqlFormat());
         $record['modified_by'] = $faker->randomElement($userIds);
         $record['language'] = $lang;
         $record['params'] = '';
         $record->setLocation($faker->randomElement($existsRecordIds[$record['type']]), $record::LOCATION_LAST_CHILD);
         $record->store();
         $record->rebuildPath();
         $existsRecordIds[$record['type']][] = $record->id;
         $this->outCounting();
     }
 }
Ejemplo n.º 18
0
 /**
  * WarderMethod constructor.
  *
  * @param AbstractPackage $package
  */
 public function __construct(AbstractPackage $package = null)
 {
     $this->package = $package ?: WarderHelper::getPackage();
 }
Ejemplo n.º 19
0
<?php

/**
 * Part of phoenix project.
 *
 * @copyright  Copyright (C) 2016 {ORGANIZATION}. All rights reserved.
 * @license    GNU General Public License version 2 or later.
 */
return ['providers' => [], 'routing' => ['files' => ['main' => PACKAGE_FRONT_ROOT . '/routing.yml', 'warder' => \Lyrasoft\Warder\Helper\WarderHelper::getFrontendRouting(), 'luna' => \Lyrasoft\Luna\Helper\LunaHelper::getFrontendRouting()]], 'middlewares' => [], 'configs' => [], 'listeners' => ['orphans' => \Phoenix\Listener\DumpOrphansListener::class, 'view' => \Front\Listener\ViewListener::class], 'console' => ['commands' => []]];
Ejemplo n.º 20
0
<?php

/**
 * Part of earth project.
 *
 * @copyright  Copyright (C) 2016 {ORGANIZATION}. All rights reserved.
 * @license    GNU General Public License version 2 or later.
 */
namespace Lyrasoft\Warder\Table;

use Lyrasoft\Warder\Helper\WarderHelper;
define('WARDER_TABLE_USERS', WarderHelper::getTable('users'));
define('WARDER_TABLE_USER_SOCIALS', WarderHelper::getTable('user_socials'));
define('WARDER_TABLE_GROUPS', WarderHelper::getTable('groups'));
define('WARDER_TABLE_USER_GROUP_MAPS', WarderHelper::getTable('user_group_maps'));
define('WARDER_TABLE_ACTIONS', WarderHelper::getTable('actions'));
/**
 * The WarderTable class.
 *
 * @since  1.0
 */
class WarderTable
{
    const USERS = WARDER_TABLE_USERS;
    const USER_SOCIALS = WARDER_TABLE_USER_SOCIALS;
    const GROUPS = WARDER_TABLE_GROUPS;
    const USER_GROUP_MAPS = WARDER_TABLE_USER_GROUP_MAPS;
    const ACTIONS = WARDER_TABLE_ACTIONS;
}
Ejemplo n.º 21
0
 /**
  * onViewBeforeRender
  *
  * @param Event $event
  *
  * @return  void
  */
 public function onViewBeforeRender(Event $event)
 {
     $view = $event['view'];
     if (!$view instanceof HtmlView) {
         return;
     }
     /**
      * @var HtmlView $view
      * @var BladeRenderer $renderer
      */
     $name = $view->getName();
     $renderer = $view->getRenderer();
     $app = $view->getPackage()->app;
     // Prepare View data
     if ($this->warder->isFrontend()) {
         // Extends
         $view['warder'] = new Data(['extends' => $this->warder->get('frontend.view.extends', '_global.html'), 'langPrefix' => $this->warder->get('frontend.language.prefix', 'warder.'), 'package' => WarderHelper::getPackage()]);
         // Paths
         $renderer->addPath(WARDER_SOURCE . '/Templates/' . $name . '/' . $app->get('language.locale'), PriorityQueue::LOW - 25);
         $renderer->addPath(WARDER_SOURCE . '/Templates/' . $name . '/' . $app->get('language.default'), PriorityQueue::LOW - 25);
         $renderer->addPath(WARDER_SOURCE . '/Templates/' . $name, PriorityQueue::LOW - 25);
     } elseif ($this->warder->isAdmin()) {
         // Extends
         $view['warder'] = new Data(['extends' => $this->warder->get('admin.view.extends', '_global.html'), 'langPrefix' => $this->warder->get('admin.language.prefix', 'warder.'), 'package' => WarderHelper::getPackage()]);
         // Paths
         $renderer->addPath(WARDER_SOURCE_ADMIN . '/Templates/' . $name . '/' . $app->get('language.locale'), PriorityQueue::LOW - 25);
         $renderer->addPath(WARDER_SOURCE_ADMIN . '/Templates/' . $name . '/' . $app->get('language.default'), PriorityQueue::LOW - 25);
         $renderer->addPath(WARDER_SOURCE_ADMIN . '/Templates/' . $name, PriorityQueue::LOW - 25);
     }
 }
Ejemplo n.º 22
0
 /**
  * onUserAuthorisation
  *
  * @param Event $event
  *
  * @return  void
  */
 public function onUserAuthorisation(Event $event)
 {
     $user = $event['user'];
     $langPrefix = WarderHelper::getPackage()->get('admin.language.prefix', 'warder.');
     if ($user->activation) {
         throw new AuthenticateFailException(Translator::translate($langPrefix . 'login.message.inactivated'));
     }
     if ($user->blocked) {
         throw new AuthenticateFailException(Translator::translate($langPrefix . 'login.message.blocked'));
     }
 }
Ejemplo n.º 23
0
 /**
  * login
  *
  * @param string $account
  * @param string $password
  * @param bool   $remember
  * @param array  $options
  *
  * @return bool
  * @throws ValidateFailException
  */
 public function login($account, $password, $remember = false, $options = array())
 {
     $loginName = WarderHelper::getLoginName();
     $credential = new Credential();
     $credential->{$loginName} = $account;
     $credential->password = $password;
     if (isset($options['provider'])) {
         $credential->_provider = $options['provider'];
     }
     try {
         $result = User::login($credential, (bool) $remember, $options);
     } catch (AuthenticateFailException $e) {
         $langPrefix = WarderHelper::getPackage()->get('admin.language.prefix', 'warder.');
         switch (array_values($e->getMessages())[0]) {
             case Authentication::USER_NOT_FOUND:
                 $message = Translator::translate($langPrefix . 'login.message.user.not.found');
                 break;
             case Authentication::EMPTY_CREDENTIAL:
                 $message = Translator::translate($langPrefix . 'login.message.empty.credential');
                 break;
             case Authentication::INVALID_CREDENTIAL:
                 $message = Translator::translate($langPrefix . 'login.message.invalid.credential');
                 break;
             case Authentication::INVALID_PASSWORD:
                 $message = Translator::translate($langPrefix . 'login.message.invalid.password');
                 break;
             case Authentication::INVALID_USERNAME:
                 $message = Translator::translate($langPrefix . 'login.message.invalid.username');
                 break;
             default:
                 $message = $e->getMessage();
         }
         throw new ValidateFailException($message);
     }
     return $result;
 }
Ejemplo n.º 24
0
 /**
  * WarderPackage constructor.
  */
 public function __construct()
 {
     WarderHelper::setPackage($this);
 }
Ejemplo n.º 25
0
 /**
  * getHomeRedirect
  *
  * @return  string
  */
 protected function getHomeRedirect()
 {
     return $this->router->route(WarderHelper::getPackage()->get('frontend.redirect.login', 'home'));
 }
Ejemplo n.º 26
0
 /**
  * buildInput
  *
  * @param array $attrs
  *
  * @return  mixed|void
  */
 public function buildInput($attrs)
 {
     $warder = WarderHelper::getPackage();
     $this->table = $warder->get('table.users', 'username');
     return parent::buildInput($attrs);
 }
Ejemplo n.º 27
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add('email', new Field\EmailField())->label(Translator::translate($langPrefix . '.user.field.email'))->set('placeholder', Translator::translate($langPrefix . '.user.field.email'))->required();
     $form->add('token', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.token'))->set('placeholder', Translator::translate($langPrefix . 'user.field.token'))->required();
 }
Ejemplo n.º 28
0
 /**
  * validate
  *
  * @param  DataInterface $data
  *
  * @return  void
  *
  * @throws ValidateFailException
  */
 protected function validate(DataInterface $data)
 {
     $validator = new EmailValidator();
     if (!$validator->validate($data->email)) {
         throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.email.invalid'));
     }
     parent::validate($data);
     $loginName = WarderHelper::getLoginName();
     if ($loginName != 'email') {
         $user = User::get(array($loginName => $data->{$loginName}));
         if ($user->notNull() && $user->id != $data->id) {
             throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.user.account.exists'));
         }
     }
     $user = User::get(array('email' => $data->email));
     if ($user->notNull() && $user->id != $data->id) {
         throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.user.email.exists'));
     }
     if ('' !== (string) $data->password) {
         if ($data->password != $data->password2) {
             throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.password.not.match'));
         }
         unset($data->password2);
     } else {
         unset($data->password);
     }
 }
Ejemplo n.º 29
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $warder = WarderHelper::getPackage();
         $this->redirect($this->router->route($warder->get('frontend.redirect.login', 'home')));
         return;
     }
     parent::prepareExecute();
     $this->token = UserHelper::getToken($this->data['email']);
     $this->data['activation'] = UserHelper::hashPassword($this->token);
 }