예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function getDefaultAttributes($forum)
 {
     $attributes = ['title' => Core::config('forum_title'), 'baseUrl' => Core::url(), 'basePath' => parse_url(Core::url(), PHP_URL_PATH) ?: '', 'debug' => Core::inDebugMode(), 'apiUrl' => Core::url('api'), 'welcomeTitle' => Core::config('welcome_title'), 'welcomeMessage' => Core::config('welcome_message'), 'themePrimaryColor' => Core::config('theme_primary_color'), 'canView' => $forum->can($this->actor, 'view'), 'canStartDiscussion' => $forum->can($this->actor, 'startDiscussion'), 'allowSignUp' => (bool) Core::config('allow_sign_up'), 'defaultRoute' => Core::config('default_route')];
     if ($this->actor->isAdmin()) {
         $attributes['adminUrl'] = Core::url('admin');
         $attributes['version'] = Application::VERSION;
     }
     return $attributes;
 }
 public function handle(RequestPasswordResetCommand $command)
 {
     $user = $this->users->findByEmail($command->email);
     if (!$user) {
         throw new ModelNotFoundException();
     }
     $token = PasswordToken::generate($user->id);
     $token->save();
     $data = ['username' => $user->username, 'url' => route('flarum.forum.resetPassword', ['token' => $token->id]), 'forumTitle' => Core::config('forum_title')];
     $this->mailer->send(['text' => 'flarum::emails.resetPassword'], $data, function ($message) use($user) {
         $message->to($user->email);
         $message->subject('Reset Your Password');
     });
     return $user;
 }
예제 #3
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // Extensions will not be registered if Flarum is not installed yet
     if (!Core::isInstalled()) {
         return;
     }
     $extensions = json_decode(Core::config('extensions_enabled'), true);
     $providers = [];
     foreach ($extensions as $extension) {
         if (file_exists($file = base_path() . '/extensions/' . $extension . '/bootstrap.php')) {
             $providers[$extension] = (require $file);
         }
     }
     // @todo store $providers somewhere so that extensions can talk to each other
 }
예제 #4
0
$app->alias('cache', 'Illuminate\\Contracts\\Cache\\Repository');
$serviceProviders = ['Flarum\\Core\\DatabaseServiceProvider', 'Flarum\\Core\\Settings\\SettingsServiceProvider', 'Flarum\\Locale\\LocaleServiceProvider', 'Illuminate\\Bus\\BusServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Illuminate\\Events\\EventServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider'];
foreach ($serviceProviders as $provider) {
    $app->register(new $provider($app));
}
if (Core::isInstalled()) {
    $settings = $app->make('Flarum\\Core\\Settings\\SettingsRepository');
    $app->register(new \Flarum\Core\CoreServiceProvider($app));
    $config->set('mail.driver', Core::config('mail_driver'));
    $config->set('mail.host', Core::config('mail_host'));
    $config->set('mail.port', Core::config('mail_port'));
    $config->set('mail.from.address', Core::config('mail_from'));
    $config->set('mail.from.name', Core::config('forum_title'));
    $config->set('mail.encryption', Core::config('mail_encryption'));
    $config->set('mail.username', Core::config('mail_username'));
    $config->set('mail.password', Core::config('mail_password'));
    // Register extensions and tell them to listen for events
    $app->register(new \Flarum\Support\ExtensionsServiceProvider($app));
}
$app->boot();
// If the version stored in the database doesn't match the version of the
// code, then run the upgrade script (migrations). This is temporary - a
// proper, more secure upgrade method is planned.
if (Core::isInstalled() && $settings->get('version') !== $app::VERSION) {
    $input = new \Symfony\Component\Console\Input\StringInput('');
    $output = new \Symfony\Component\Console\Output\BufferedOutput();
    app('Flarum\\Console\\UpgradeCommand')->run($input, $output);
    $settings->set('version', $app::VERSION);
    app('flarum.formatter')->flush();
    $forum = app('Flarum\\Forum\\Actions\\ClientAction');
    $forum->flushAssets();
예제 #5
0
파일: Forum.php 프로젝트: Qiang1234/core
 public function getTitleAttribute()
 {
     return Core::config('forum_title');
 }
예제 #6
0
파일: User.php 프로젝트: utkarshx/core
 /**
  * Get the user's locale, falling back to the forum's default if they
  * haven't set one.
  *
  * @param string $value
  * @return string
  */
 public function getLocaleAttribute($value)
 {
     return $value ?: Core::config('locale', 'en');
 }
예제 #7
0
 protected function getPayload($user, $email)
 {
     $token = $this->generateToken($user, $email);
     return ['username' => $user->username, 'url' => route('flarum.forum.confirmEmail', ['token' => $token->id]), 'forumTitle' => Core::config('forum_title')];
 }