Modulos Externos

Versión 7 (Guillermo Zdanowicz, 06/04/2016 20:11)

1 1 Guillermo Zdanowicz
h1. Modulos Externos
2 1 Guillermo Zdanowicz
3 3 Guillermo Zdanowicz
Basandonos en el link
4 3 Guillermo Zdanowicz
5 3 Guillermo Zdanowicz
http://code.tutsplus.com/tutorials/how-to-program-with-yii2-integrating-user-registration--cms-22974
6 3 Guillermo Zdanowicz
7 6 Guillermo Zdanowicz
[[Estructura BD]]
8 6 Guillermo Zdanowicz
9 1 Guillermo Zdanowicz
en el archivo composer.json del raiz se agrego 
10 1 Guillermo Zdanowicz
11 1 Guillermo Zdanowicz
 *"dektrium/yii2-user": "*"*
12 1 Guillermo Zdanowicz
13 1 Guillermo Zdanowicz
<pre>
14 1 Guillermo Zdanowicz
    "require": {
15 1 Guillermo Zdanowicz
        "php": ">=5.4.0",
16 1 Guillermo Zdanowicz
        "yiisoft/yii2": ">=2.0.5",
17 1 Guillermo Zdanowicz
        "yiisoft/yii2-bootstrap": "*",
18 1 Guillermo Zdanowicz
        "yiisoft/yii2-swiftmailer": "*",
19 1 Guillermo Zdanowicz
        "dektrium/yii2-user": "*"
20 1 Guillermo Zdanowicz
    },
21 1 Guillermo Zdanowicz
</pre>
22 2 Guillermo Zdanowicz
23 2 Guillermo Zdanowicz
y se corrio la sentencia
24 2 Guillermo Zdanowicz
25 2 Guillermo Zdanowicz
*./composer.phar update*
26 2 Guillermo Zdanowicz
27 2 Guillermo Zdanowicz
para bajar paquetes de gestion de usuarios
28 4 Guillermo Zdanowicz
29 4 Guillermo Zdanowicz
en /config/web.php
30 4 Guillermo Zdanowicz
31 4 Guillermo Zdanowicz
cambiamos
32 4 Guillermo Zdanowicz
33 4 Guillermo Zdanowicz
<pre>
34 4 Guillermo Zdanowicz
        'user' => [
35 4 Guillermo Zdanowicz
            'identityClass' => 'app\models\User',
36 4 Guillermo Zdanowicz
            'enableAutoLogin' => true,
37 4 Guillermo Zdanowicz
        ],
38 4 Guillermo Zdanowicz
</pre>
39 4 Guillermo Zdanowicz
40 4 Guillermo Zdanowicz
por
41 4 Guillermo Zdanowicz
42 4 Guillermo Zdanowicz
<pre>
43 4 Guillermo Zdanowicz
		'user' => [
44 4 Guillermo Zdanowicz
			'class' => 'dektrium\user\Module',
45 4 Guillermo Zdanowicz
			'enableUnconfirmedLogin' => true,
46 4 Guillermo Zdanowicz
			'confirmWithin' => 21600,
47 4 Guillermo Zdanowicz
			'cost' => 12,
48 4 Guillermo Zdanowicz
			'admins' => ['admin']
49 4 Guillermo Zdanowicz
		],
50 4 Guillermo Zdanowicz
</pre>
51 4 Guillermo Zdanowicz
52 4 Guillermo Zdanowicz
Y para gestion de email
53 4 Guillermo Zdanowicz
54 4 Guillermo Zdanowicz
<pre>
55 4 Guillermo Zdanowicz
        'mailer' => [
56 4 Guillermo Zdanowicz
            'class' => 'yii\swiftmailer\Mailer',
57 4 Guillermo Zdanowicz
            // send all mails to a file by default. You have to set
58 4 Guillermo Zdanowicz
            // 'useFileTransport' to false and configure a transport
59 4 Guillermo Zdanowicz
            // for the mailer to send real emails.
60 4 Guillermo Zdanowicz
            'useFileTransport' => true,
61 4 Guillermo Zdanowicz
        ],
62 4 Guillermo Zdanowicz
</pre>
63 4 Guillermo Zdanowicz
64 4 Guillermo Zdanowicz
por
65 4 Guillermo Zdanowicz
66 4 Guillermo Zdanowicz
<pre>
67 4 Guillermo Zdanowicz
		'mailer' => [
68 4 Guillermo Zdanowicz
        'class' => 'yii\swiftmailer\Mailer',
69 4 Guillermo Zdanowicz
        'viewPath' => '@app/mailer',
70 4 Guillermo Zdanowicz
        'useFileTransport' => false,
71 4 Guillermo Zdanowicz
        'transport' => [
72 4 Guillermo Zdanowicz
            'class' => 'Swift_SmtpTransport',
73 4 Guillermo Zdanowicz
            'host' => 'your-host-domain e.g. smtp.gmail.com',
74 4 Guillermo Zdanowicz
            'username' => 'informatica@ucu.edu.ar',
75 4 Guillermo Zdanowicz
            'password' => 'xxxxxxx',
76 4 Guillermo Zdanowicz
            'port' => '587',
77 4 Guillermo Zdanowicz
            'encryption' => 'tls',
78 4 Guillermo Zdanowicz
                        ],
79 4 Guillermo Zdanowicz
    ],
80 4 Guillermo Zdanowicz
</pre>
81 5 Guillermo Zdanowicz
82 5 Guillermo Zdanowicz
en /views/layouts/main.php
83 5 Guillermo Zdanowicz
84 5 Guillermo Zdanowicz
reemplazar
85 5 Guillermo Zdanowicz
86 5 Guillermo Zdanowicz
<pre>
87 5 Guillermo Zdanowicz
 echo Nav::widget([
88 5 Guillermo Zdanowicz
        'options' => ['class' => 'navbar-nav navbar-right'],
89 5 Guillermo Zdanowicz
        'items' => [
90 5 Guillermo Zdanowicz
            ['label' => 'Home', 'url' => ['/site/index']],
91 5 Guillermo Zdanowicz
            ['label' => 'Proveedores', 'url' => ['/proveedores']],
92 5 Guillermo Zdanowicz
            ['label' => 'Compras', 'url' => ['/compras']],
93 5 Guillermo Zdanowicz
            ['label' => 'Pagos', 'url' => ['/pagos']],
94 5 Guillermo Zdanowicz
            Yii::$app->user->isGuest ? (
95 5 Guillermo Zdanowicz
                ['label' => 'Login', 'url' => ['/site/login']]
96 5 Guillermo Zdanowicz
            ) : (
97 5 Guillermo Zdanowicz
                '<li>'
98 5 Guillermo Zdanowicz
                . Html::beginForm(['/site/logout'], 'post')
99 5 Guillermo Zdanowicz
                . Html::submitButton(
100 5 Guillermo Zdanowicz
                    'Logout (' . Yii::$app->user->identity->username . ')',
101 5 Guillermo Zdanowicz
                    ['class' => 'btn btn-link']
102 5 Guillermo Zdanowicz
                )
103 5 Guillermo Zdanowicz
                . Html::endForm()
104 5 Guillermo Zdanowicz
                . '</li>'
105 5 Guillermo Zdanowicz
            )
106 5 Guillermo Zdanowicz
        ],
107 5 Guillermo Zdanowicz
    ]);
108 5 Guillermo Zdanowicz
</pre>
109 5 Guillermo Zdanowicz
110 5 Guillermo Zdanowicz
por
111 5 Guillermo Zdanowicz
112 5 Guillermo Zdanowicz
<pre>
113 7 Guillermo Zdanowicz
$navItems=[
114 7 Guillermo Zdanowicz
    ['label' => 'Home', 'url' => ['/site/index']],
115 7 Guillermo Zdanowicz
    ['label' => 'Status', 'url' => ['/status/index']],
116 7 Guillermo Zdanowicz
    ['label' => 'About', 'url' => ['/site/about']],
117 7 Guillermo Zdanowicz
    ['label' => 'Contact', 'url' => ['/site/contact']]
118 7 Guillermo Zdanowicz
  ];
119 7 Guillermo Zdanowicz
  if (Yii::$app->user->isGuest) {
120 7 Guillermo Zdanowicz
    array_push($navItems,['label' => 'Sign In', 'url' => ['/user/login']],['label' => 'Sign Up', 'url' => ['/user/register']]);
121 7 Guillermo Zdanowicz
  } else {
122 7 Guillermo Zdanowicz
    array_push($navItems,['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
123 7 Guillermo Zdanowicz
        'url' => ['/site/logout'],
124 7 Guillermo Zdanowicz
        'linkOptions' => ['data-method' => 'post']]
125 7 Guillermo Zdanowicz
    );
126 7 Guillermo Zdanowicz
  }
127 7 Guillermo Zdanowicz
echo Nav::widget([
128 7 Guillermo Zdanowicz
    'options' => ['class' => 'navbar-nav navbar-right'],
129 7 Guillermo Zdanowicz
    'items' => $navItems,
130 7 Guillermo Zdanowicz
]);
131 5 Guillermo Zdanowicz
</pre>
Redmine Appliance - Powered by TurnKey Linux