networks.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /*
  3. * This file is part of the Dektrium project.
  4. *
  5. * (c) Dektrium project <http://github.com/dektrium>
  6. *
  7. * For the full copyright and license information, please view the LICENSE.md
  8. * file that was distributed with this source code.
  9. */
  10. use dektrium\user\widgets\Connect;
  11. use yii\helpers\Html;
  12. /**
  13. * @var $this yii\web\View
  14. * @var $form yii\widgets\ActiveForm
  15. */
  16. $this->title = Yii::t('user', 'Networks');
  17. $this->params['breadcrumbs'][] = $this->title;
  18. ?>
  19. <?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
  20. <div class="row">
  21. <div class="col-md-3">
  22. <?= $this->render('_menu') ?>
  23. </div>
  24. <div class="col-md-9">
  25. <div class="panel panel-default">
  26. <div class="panel-heading">
  27. <?= Html::encode($this->title) ?>
  28. </div>
  29. <div class="panel-body">
  30. <div class="alert alert-info">
  31. <p><?= Yii::t('user', 'You can connect multiple accounts to be able to log in using them') ?>.</p>
  32. </div>
  33. <?php $auth = Connect::begin([
  34. 'baseAuthUrl' => ['/user/security/auth'],
  35. 'accounts' => $user->accounts,
  36. 'autoRender' => false,
  37. 'popupMode' => false,
  38. ]) ?>
  39. <table class="table">
  40. <?php foreach ($auth->getClients() as $client): ?>
  41. <tr>
  42. <td style="width: 32px; vertical-align: middle">
  43. <?= Html::tag('span', '', ['class' => 'auth-icon ' . $client->getName()]) ?>
  44. </td>
  45. <td style="vertical-align: middle">
  46. <strong><?= $client->getTitle() ?></strong>
  47. </td>
  48. <td style="width: 120px">
  49. <?= $auth->isConnected($client) ?
  50. Html::a(Yii::t('user', 'Disconnect'), $auth->createClientUrl($client), [
  51. 'class' => 'btn btn-danger btn-block',
  52. 'data-method' => 'post',
  53. ]) :
  54. Html::a(Yii::t('user', 'Connect'), $auth->createClientUrl($client), [
  55. 'class' => 'btn btn-success btn-block',
  56. ])
  57. ?>
  58. </td>
  59. </tr>
  60. <?php endforeach; ?>
  61. </table>
  62. <?php Connect::end() ?>
  63. </div>
  64. </div>
  65. </div>
  66. </div>