/** * Updating the profile details. * @return string|\yii\web\Response */ public function actionDetails() { $model = User::findMe(); if (empty($model)) { return $this->redirect(['account/login']); } $model->scenario = PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT ? 'accountInherit' : 'account'; $model->current_password = null; $previous_new_email = $model->new_email; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { if ($model->saveChanges()) { if ($previous_new_email != $model->new_email) { $forum = Config::getInstance()->get('name'); $email = Content::fill(Content::EMAIL_NEW); if ($email !== false && Email::queue($model->new_email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/new-email', 'token' => $model->email_token], true), Url::to(['account/new-email', 'token' => $model->email_token], true)), $email->content)), !empty($model->id) ? $model->id : null)) { Log::info('New email activation link queued', $model->id, __METHOD__); $this->success(Yii::t('podium/flash', 'Your account has been updated but your new e-mail address is not active yet. Click the activation link that will be sent to your new e-mail address in few minutes.')); } else { Log::error('Error while queuing new email activation link', $model->id, __METHOD__); $this->warning(Yii::t('podium/flash', 'Your account has been updated but your new e-mail address is not active yet. Unfortunately there was some error while sending you the activation link. Contact administrator about this problem.')); } } else { Log::info('Details updated', $model->id, __METHOD__); $this->success(Yii::t('podium/flash', 'Your account has been updated.')); } return $this->refresh(); } } } $model->current_password = null; return $this->render('details', ['model' => $model]); }
/** * @inheritdoc */ public function behaviors() { return ['access' => ['class' => AccessControl::className(), 'denyCallback' => function ($rule, $action) { return $this->redirect(['account/login']); }, 'rules' => [['allow' => false, 'matchCallback' => function ($rule, $action) { return !$this->module->getInstalled(); }, 'denyCallback' => function ($rule, $action) { return $this->redirect(['install/run']); }], ['allow' => true, 'roles' => Config::getInstance()->get('members_visible') ? ['@', '?'] : ['@']]]]]; }
/** * Updating the profile details. * @return string|\yii\web\Response */ public function actionDetails() { if ($this->module->userComponent == PodiumModule::USER_OWN) { $model = User::findOne(Yii::$app->user->id); if (empty($model)) { return $this->redirect(['account/login']); } $model->setScenario('account'); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { if ($model->saveChanges()) { if ($model->new_email) { $email = Content::find()->where(['name' => 'email-new'])->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = 'New e-mail activation link at {forum}'; $content = '<p>{forum} New E-mail Address Activation</p><p>To activate your new e-mail address open the following link in your Internet browser and follow the instructions on screen.</p><p>{link}</p><p>Thank you<br />{forum}</p>'; } $forum = Config::getInstance()->get('name'); if (Email::queue($model->new_email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/new-email', 'token' => $model->email_token], true), Url::to(['account/new-email', 'token' => $model->email_token], true)), $content)), !empty($model->id) ? $model->id : null)) { Log::info('New email activation link queued', !empty($model->id) ? $model->id : '', __METHOD__); $this->success('Your account has been updated but your new e-mail address is not active yet. ' . 'Click the activation link that has been sent to your new e-mail address.'); } else { Log::error('Error while queuing new email activation link', !empty($model->id) ? $model->id : '', __METHOD__); $this->warning('Your account has been updated but your new e-mail address is not active yet. ' . 'Unfortunately there was some error while sending you the activation link. ' . 'Contact administrator about this problem.'); } } else { Log::info('Details updated', !empty($model->id) ? $model->id : '', __METHOD__); $this->success('Your account has been updated.'); } return $this->refresh(); } } else { $model->current_password = null; } } } else { $model = (new PodiumUser())->findOne(Yii::$app->user->id); if (empty($model)) { return $this->module->goPodium(); } } return $this->render('details', ['model' => $model]); }
/** * Adds warning for maintenance mode. * Redirects all users except administrators (if this mode is on). * Adds warning about missing email. */ public function beforeAction($action) { if (parent::beforeAction($action)) { if (Config::getInstance()->get('maintenance_mode') == '1') { if ($action->id !== 'maintenance') { $this->warning(Yii::t('podium/flash', Messages::MAINTENANCE_WARNING, ['maintenancePage' => Html::a(Yii::t('podium/flash', Messages::PAGE_MAINTENANCE), ['default/maintenance']), 'settingsPage' => Html::a(Yii::t('podium/flash', Messages::PAGE_SETTINGS), ['admin/settings'])]), false); if (!User::can(Rbac::ROLE_ADMIN)) { return $this->redirect(['default/maintenance']); } } } else { $user = User::findMe(); if ($user && empty($user->email)) { $this->warning(Yii::t('podium/flash', Messages::NO_EMAIL_SET, ['link' => Html::a(Yii::t('podium/layout', 'Profile') . ' > ' . Yii::t('podium/view', 'Account Details'), ['profile/details'])]), false); } } return true; } return false; }
/** * Adds warning for maintenance mode. * Redirects all users except administrators (if this mode is on). * Adds warning about missing email. */ public function beforeAction($action) { if (parent::beforeAction($action)) { $warnings = Yii::$app->session->getFlash('warning'); if (Config::getInstance()->get('maintenance_mode') == '1') { if ($action->id !== 'maintenance') { if ($warnings) { foreach ($warnings as $warning) { if ($warning == Yii::t('podium/flash', 'Podium is currently in the Maintenance mode. All users without Administrator privileges are redirected to {maintenancePage}. You can switch the mode off at {settingsPage}.', ['maintenancePage' => Html::a(Yii::t('podium/flash', 'Maintenance page'), ['default/maintenance']), 'settingsPage' => Html::a(Yii::t('podium/flash', 'Settings page'), ['admin/settings'])])) { if (!User::can(Rbac::ROLE_ADMIN)) { return $this->redirect(['default/maintenance']); } else { return true; } } } } $this->warning(Yii::t('podium/flash', 'Podium is currently in the Maintenance mode. All users without Administrator privileges are redirected to {maintenancePage}. You can switch the mode off at {settingsPage}.', ['maintenancePage' => Html::a(Yii::t('podium/flash', 'Maintenance page'), ['default/maintenance']), 'settingsPage' => Html::a(Yii::t('podium/flash', 'Settings page'), ['admin/settings'])]), false); if (!User::can(Rbac::ROLE_ADMIN)) { return $this->redirect(['default/maintenance']); } } } else { if ($warnings) { foreach ($warnings as $warning) { if ($warning == Yii::t('podium/flash', 'No e-mail address has been set for your account! Go to {link} to add one.', ['link' => Html::a(Yii::t('podium/view', 'Profile') . ' > ' . Yii::t('podium/view', 'Account Details'), ['profile/details'])])) { return true; } } } $user = User::findMe(); if ($user && empty($user->email)) { $this->warning(Yii::t('podium/flash', 'No e-mail address has been set for your account! Go to {link} to add one.', ['link' => Html::a(Yii::t('podium/view', 'Profile') . ' > ' . Yii::t('podium/view', 'Account Details'), ['profile/details'])]), false); } } return true; } return false; }
/** * @inheritdoc */ public function init() { parent::init(); $this->config = Config::getInstance(); $this->settings = $this->config->all(); }
/** * Prepares notification email. * @param integer $thread */ public static function notify($thread) { if (is_numeric($thread) && $thread > 0) { $email = Content::find()->where(['name' => 'email-sub'])->limit(1)->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = 'New post in subscribed thread at {forum}'; $content = '<p>There has been new post added in the thread you are subscribing. Click the following link to read the thread.</p><p>{link}</p><p>See you soon!<br>{forum}</p>'; } $forum = Config::getInstance()->get('name'); $subs = static::find()->where(['thread_id' => (int) $thread, 'post_seen' => self::POST_SEEN]); foreach ($subs->each() as $sub) { $sub->post_seen = self::POST_NEW; if ($sub->save()) { if (!empty($sub->user->email)) { if (Email::queue($sub->user->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['default/last', 'id' => $sub->thread_id], true), Url::to(['default/last', 'id' => $sub->thread_id], true)), $content)), $sub->user_id)) { Log::info('Subscription notice link queued', $sub->user_id, __METHOD__); } else { Log::error('Error while queuing subscription notice link', $sub->user_id, __METHOD__); } } else { Log::error('Error while queuing subscription notice link - no email set', $sub->user_id, __METHOD__); } } } } }
/** * Runs the queue. * @param integer $limit * @return integer|void */ public function actionRun($limit = 0) { $version = $this->module->version; $this->stdout("\nPodium mail queue v{$version}\n"); $this->stdout("------------------------------\n"); $emails = $this->getNewBatch($limit); if (empty($emails)) { $this->stdout("No pending emails in the queue found.\n\n", Console::FG_GREEN); return self::EXIT_CODE_NORMAL; } $total = count($emails); $this->stdout("\n{$total} pending " . ($total === 1 ? 'email' : 'emails') . " to be sent now:\n", Console::FG_YELLOW); $errors = false; foreach ($emails as $email) { if (!$this->process($email, Config::getInstance()->get('from_name'), Config::getInstance()->get('from_email'), Config::getInstance()->get('max_attempts'))) { $errors = true; } } if ($errors) { $this->stdout("\nBatch sent with errors.\n\n", Console::FG_RED); } else { $this->stdout("\nBatch sent successfully.\n\n", Console::FG_GREEN); } }
/** * Sending the account password reset link. * @return string|\yii\web\Response */ public function actionReset() { if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) { $this->info(Yii::t('podium/flash', 'Please contact the administrator to reset your account password.')); return $this->module->goPodium(); } $model = new ReForm(); if ($model->load(Yii::$app->request->post())) { if ($model->reset()) { $email = Content::find()->where(['name' => 'email-pass'])->limit(1)->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = Messages::EMAIL_PASS_TITLE; $content = Messages::EMAIL_PASS_BODY; } $forum = Config::getInstance()->get('name'); if (!empty($model->email)) { if (Email::queue($model->user->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/password', 'token' => $model->user->password_reset_token], true), Url::to(['account/password', 'token' => $model->user->password_reset_token], true)), $content)), !empty($model->user->id) ? $model->user->id : null)) { Log::info('Password reset link queued', $model->user->id, __METHOD__); $this->success(Yii::t('podium/flash', 'The password reset link has been sent to your e-mail address.')); } else { Log::error('Error while queuing password reset link', $model->user->id, __METHOD__); $this->error(Yii::t('podium/flash', 'Sorry! There was some error while sending you the password reset link. Contact administrator about this problem.')); } } else { Log::error('Error while queuing password reset link - no email set', $model->user->id, __METHOD__); $this->error(Yii::t('podium/flash', 'Sorry! There is no e-mail address saved with your account. Contact administrator about resetting password.')); } return $this->module->goPodium(); } else { $this->error(Yii::t('podium/flash', 'Sorry! We can not find the account with that user name or e-mail address.')); } } return $this->render('reset', ['model' => $model]); }
<?php echo $form->field($model, 'password_repeat')->passwordInput(['placeholder' => Yii::t('podium/view', 'Repeat Password')])->label(false); ?> </div> <div class="form-group"> <?php echo $form->field($model, 'tos')->checkBox()->label('<small>' . Yii::t('podium/view', 'I have read and agree to the Terms and Conditions') . ' <span class="glyphicon glyphicon-circle-arrow-right"></span></small>'); ?> </div> <?php if (Config::getInstance()->get('use_captcha')) { if (Config::getInstance()->get('recaptcha_sitekey') !== '' && Config::getInstance()->get('recaptcha_secretkey') !== '') { ?> <div class="form-group"> <?php echo $form->field($model, 'captcha')->widget(Recaptcha::className(), ['clientOptions' => ['data-sitekey' => Config::getInstance()->get('recaptcha_sitekey')]]); ?> </div> <?php } else { ?> <div class="form-group"> <?php echo $form->field($model, 'captcha')->widget(Captcha::classname(), ['captchaAction' => ['account/captcha'], 'options' => ['class' => 'form-control', 'placeholder' => Yii::t('podium/view', 'Type the CAPTCHA text'), 'data-container' => 'body', 'data-toggle' => 'popover', 'data-placement' => 'right', 'data-content' => Yii::t('podium/view', 'Type the CAPTCHA text displayed above. Click the image to generate another CAPTCHA code.'), 'data-trigger' => 'focus']]); ?> </div> <?php } } ?> <?php
/** * Prepares notification email. * @param integer $thread */ public static function notify($thread) { if (is_numeric($thread) && $thread > 0) { $forum = Config::getInstance()->get('name'); $email = Content::fill(Content::EMAIL_SUBSCRIPTION); $subs = static::find()->where(['thread_id' => $thread, 'post_seen' => self::POST_SEEN]); foreach ($subs->each() as $sub) { $sub->post_seen = self::POST_NEW; if ($sub->save()) { if ($email !== false && !empty($sub->user->email)) { if (Email::queue($sub->user->email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['default/last', 'id' => $sub->thread_id], true), Url::to(['default/last', 'id' => $sub->thread_id], true)), $email->content)), $sub->user_id)) { Log::info('Subscription notice link queued', $sub->user_id, __METHOD__); } else { Log::error('Error while queuing subscription notice link', $sub->user_id, __METHOD__); } } else { Log::error('Error while queuing subscription notice link - no email set', $sub->user_id, __METHOD__); } } } } }
<?php /** * Podium Module * Yii 2 Forum Module * @author Paweł Bizley Brzozowski <*****@*****.**> * @since 0.1 */ use bizley\podium\components\Config; ?> <footer class="footer"> <div class="container"> <p class="pull-left">© <?php echo Config::getInstance()->get('name'); ?> <?php echo date('Y'); ?> </p> <p class="pull-right"><?php echo Yii::powered(); ?> </p> </div> </footer>
/** * Performs upgrade check. * @param array $warnings Flash warnings * @return boolean * @since 0.2 */ public function upgradeCheck($warnings) { if ($warnings) { foreach ($warnings as $warning) { if ($warning == Yii::t('podium/flash', 'It looks like there is a new version of Podium database! {link}', ['link' => Html::a(Yii::t('podium/view', 'Update Podium'), ['install/level-up'])])) { return false; } if ($warning == Yii::t('podium/flash', 'Module version appears to be older than database! Please verify your database.')) { return false; } } } $result = Helper::compareVersions(explode('.', $this->module->version), explode('.', Config::getInstance()->get('version'))); if ($result == '>') { $this->warning(Yii::t('podium/flash', 'It looks like there is a new version of Podium database! {link}', ['link' => Html::a(Yii::t('podium/view', 'Update Podium'), ['install/level-up'])]), false); } elseif ($result == '<') { $this->warning(Yii::t('podium/flash', 'Module version appears to be older than database! Please verify your database.'), false); } return false; }
/** * Adds forum name to view title. * @param string $title * @return string */ public static function title($title) { return $title . ' - ' . Config::getInstance()->get('name'); }
/** * Setting meta tags. * @param string $keywords * @param string $description */ public function setMetaTags($keywords = '', $description = '') { if ($keywords == '') { $keywords = Config::getInstance()->get('meta_keywords'); } if ($keywords) { $this->getView()->registerMetaTag(['name' => 'keywords', 'content' => $keywords]); } if ($description == '') { $description = Config::getInstance()->get('meta_description'); } if ($description) { $this->getView()->registerMetaTag(['name' => 'description', 'content' => $description]); } }
/** * @inheritdoc */ public function scenarios() { $scenarios = ['installation' => [], 'token' => [], 'ban' => [], 'role' => [], 'passwordChange' => ['password', 'password_repeat'], 'register' => ['email', 'password', 'password_repeat'], 'account' => ['username', 'anonymous', 'new_email', 'password', 'password_repeat', 'timezone', 'current_password']]; if (Config::getInstance()->get('use_captcha')) { $scenarios['register'][] = 'captcha'; } return $scenarios; }
<footer class="footer"> <div class="container"> <p class="pull-left">© <?php echo \bizley\podium\components\Config::getInstance()->get('name'); ?> <?php echo date('Y'); ?> </p> <p class="pull-right"><?php echo Yii::powered(); ?> </p> </div> </footer>
/** * Sending the account password reset link. * @return string|\yii\web\Response */ public function actionReset() { $model = new ReForm(); if ($model->load(Yii::$app->request->post())) { if ($model->reset()) { $email = Content::find()->where(['name' => 'email-pass'])->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = Content::PASS_TITLE; $content = Content::PASS_BODY; } $forum = Config::getInstance()->get('name'); if (Email::queue($model->getUser()->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/password', 'token' => $model->getUser()->password_reset_token], true), Url::to(['account/password', 'token' => $model->getUser()->password_reset_token], true)), $content)), !empty($model->getUser()->id) ? $model->getUser()->id : null)) { Log::info('Password reset link queued', !empty($model->getUser()->id) ? $model->getUser()->id : '', __METHOD__); $this->success('The password reset link has been sent to your e-mail address.'); } else { Log::error('Error while queuing password reset link', !empty($model->getUser()->id) ? $model->getUser()->id : '', __METHOD__); $this->error('Sorry! There was some error while sending you the password reset link. Contact administrator about this problem.'); } return $this->module->goPodium(); } else { $this->error('Sorry! We can not find the account with that user name or e-mail address.'); } } return $this->render('reset', ['model' => $model]); }
/** * Returns proper description for thread. * @return string */ public function getDescription() { $description = self::DESC_NO_NEW; $append = false; if ($this->locked) { $description = self::DESC_LOCKED; $append = true; } elseif ($this->pinned) { $description = self::DESC_PINNED; $append = true; } elseif ($this->posts >= Config::getInstance()->get('hot_minimum')) { $description = self::DESC_HOT; $append = true; } if ($this->view) { if ($this->new_post_at > $this->view->new_last_seen) { if (!$append) { $description = self::DESC_NEW; } else { $description .= ' (' . self::DESC_NEW . ')'; } } elseif ($this->edited_post_at > $this->view->edited_last_seen) { if (!$append) { $description = self::DESC_EDITED; } else { $description = ' (' . self::DESC_EDITED . ')'; } } } else { if (!$append) { $description = self::DESC_NEW; } else { $description .= ' (' . self::DESC_NEW . ')'; } } return $description; }
/** * Sending the account password reset link. * @return string|\yii\web\Response */ public function actionReset() { if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) { $this->info(Yii::t('podium/flash', 'Please contact the administrator to reset your account password.')); return $this->module->goPodium(); } $model = new ReForm(); if ($model->load(Yii::$app->request->post())) { if ($model->reset()) { $email = Content::find()->where(['name' => 'email-pass'])->limit(1)->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = '{forum} password reset link'; $content = '<p>{forum} Password Reset</p><p>You are receiving this e-mail because someone has started the process of changing the account password at {forum}.<br>If this person is you open the following link in your Internet browser and follow the instructions on screen.</p><p>{link}</p><p>If it was not you just ignore this e-mail.</p><p>Thank you!<br>{forum}</p>'; } $forum = Config::getInstance()->get('name'); if (!empty($model->email)) { if (Email::queue($model->user->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/password', 'token' => $model->user->password_reset_token], true), Url::to(['account/password', 'token' => $model->user->password_reset_token], true)), $content)), !empty($model->user->id) ? $model->user->id : null)) { Log::info('Password reset link queued', $model->user->id, __METHOD__); $this->success(Yii::t('podium/flash', 'The password reset link has been sent to your e-mail address.')); } else { Log::error('Error while queuing password reset link', $model->user->id, __METHOD__); $this->error(Yii::t('podium/flash', 'Sorry! There was some error while sending you the password reset link. Contact administrator about this problem.')); } } else { Log::error('Error while queuing password reset link - no email set', $model->user->id, __METHOD__); $this->error(Yii::t('podium/flash', 'Sorry! There is no e-mail address saved with your account. Contact administrator about resetting password.')); } return $this->module->goPodium(); } else { $this->error(Yii::t('podium/flash', 'Sorry! We can not find the account with that user name or e-mail address.')); } } return $this->render('reset', ['model' => $model]); }
/** * Prepares notification email. * @param integer $thread */ public static function notify($thread) { if (is_numeric($thread) && $thread > 0) { $email = Content::find()->where(['name' => 'email-sub'])->limit(1)->one(); if ($email) { $topic = $email->topic; $content = $email->content; } else { $topic = Messages::EMAIL_SUB_TITLE; $content = Messages::EMAIL_SUB_BODY; } $forum = Config::getInstance()->get('name'); $subs = static::find()->where(['thread_id' => (int) $thread, 'post_seen' => self::POST_SEEN]); foreach ($subs->each() as $sub) { $sub->post_seen = self::POST_NEW; if ($sub->save()) { if (!empty($sub->user->email)) { if (Email::queue($sub->user->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['default/last', 'id' => $sub->thread_id], true), Url::to(['default/last', 'id' => $sub->thread_id], true)), $content)), $sub->user_id)) { Log::info('Subscription notice link queued', $sub->user_id, __METHOD__); } else { Log::error('Error while queuing subscription notice link', $sub->user_id, __METHOD__); } } else { Log::error('Error while queuing subscription notice link - no email set', $sub->user_id, __METHOD__); } } } } }
/** * Returns proper description for thread. * @return string */ public function getDescription() { $description = Yii::t('podium/view', 'No New Posts'); $append = false; if ($this->locked) { $description = Yii::t('podium/view', 'Locked Thread'); $append = true; } elseif ($this->pinned) { $description = Yii::t('podium/view', 'Pinned Thread'); $append = true; } elseif ($this->posts >= Config::getInstance()->get('hot_minimum')) { $description = Yii::t('podium/view', 'Hot Thread'); $append = true; } if ($this->userView) { if ($this->new_post_at > $this->userView->new_last_seen) { if (!$append) { $description = Yii::t('podium/view', 'New Posts'); } else { $description .= ' (' . Yii::t('podium/view', 'New Posts') . ')'; } } elseif ($this->edited_post_at > $this->userView->edited_last_seen) { if (!$append) { $description = Yii::t('podium/view', 'Edited Posts'); } else { $description = ' (' . Yii::t('podium/view', 'Edited Posts') . ')'; } } } else { if (!$append) { $description = Yii::t('podium/view', 'New Posts'); } else { $description .= ' (' . Yii::t('podium/view', 'New Posts') . ')'; } } return $description; }
/** * Updates database version number. * @param array $data * @return string result message. * @since 0.2 */ protected function _updateVersion($data) { try { if (empty($data['version'])) { throw new Exception(Yii::t('podium/flash', 'Version number missing.')); } Config::getInstance()->set('version', $data['version']); Cache::getInstance()->flush(); return $this->outputSuccess(Yii::t('podium/flash', 'Database version has been updated to {version}.', ['version' => $data['version']])); } catch (Exception $e) { Yii::error([$e->getName(), $e->getMessage()], __METHOD__); $this->setError(true); return $this->outputDanger(Yii::t('podium/flash', 'Error during version updating') . ': ' . Html::tag('pre', $e->getMessage())); } }
/** * Gets Podium configuration instance. * * @return Config configuration instance */ public function getConfig() { if (!$this->_config) { $this->_config = Config::getInstance(); } return $this->_config; }
/** * Finds out if password reset token is valid. * @param string $token password reset token * @return boolean */ public static function isPasswordResetTokenValid($token) { $expire = Config::getInstance()->get('password_reset_token_expire'); if ($expire === null) { $expire = 24 * 60 * 60; } return self::isTokenValid($token, $expire); }
$items = [['label' => Yii::t('podium/layout', 'Home'), 'url' => ['default/index']]]; $podiumModule = PodiumModule::getInstance(); if (Yii::$app->user->isGuest) { if (Config::getInstance()->get('members_visible')) { $items[] = ['label' => Yii::t('podium/layout', 'Members'), 'url' => ['members/index'], 'active' => $this->context->id == 'members']; } if ($podiumModule->userComponent == PodiumModule::USER_OWN) { if (!empty($podiumModule->loginUrl)) { $items[] = ['label' => Yii::t('podium/layout', 'Sign in'), 'url' => $podiumModule->loginUrl]; } if (!empty($podiumModule->registerUrl)) { $items[] = ['label' => Yii::t('podium/layout', 'Register'), 'url' => $podiumModule->registerUrl]; } } } else { $podiumUser = User::findMe(); $messageCount = $podiumUser->newMessagesCount; $subscriptionCount = $podiumUser->subscriptionsCount; if (User::can(Rbac::ROLE_ADMIN)) { $items[] = ['label' => Yii::t('podium/layout', 'Administration'), 'url' => ['admin/index'], 'active' => $this->context->id == 'admin']; } $items[] = ['label' => Yii::t('podium/layout', 'Members'), 'url' => ['members/index'], 'active' => $this->context->id == 'members']; $items[] = ['label' => Yii::t('podium/layout', 'Profile') . ($subscriptionCount ? ' ' . Html::tag('span', $subscriptionCount, ['class' => 'badge']) : ''), 'url' => ['profile/index'], 'items' => [['label' => Yii::t('podium/view', 'My Profile'), 'url' => ['profile/index']], ['label' => Yii::t('podium/view', 'Account Details'), 'url' => ['profile/details']], ['label' => Yii::t('podium/view', 'Forum Details'), 'url' => ['profile/forum']], ['label' => Yii::t('podium/view', 'Subscriptions'), 'url' => ['profile/subscriptions']]]]; $items[] = ['label' => Yii::t('podium/layout', 'Messages') . ($messageCount ? ' ' . Html::tag('span', $messageCount, ['class' => 'badge']) : ''), 'url' => ['messages/inbox'], 'items' => [['label' => Yii::t('podium/view', 'Inbox'), 'url' => ['messages/inbox']], ['label' => Yii::t('podium/view', 'Sent'), 'url' => ['messages/sent']], ['label' => Yii::t('podium/view', 'Deleted'), 'url' => ['messages/deleted']], ['label' => Yii::t('podium/view', 'New Message'), 'url' => ['messages/new']]]]; if ($podiumModule->userComponent == PodiumModule::USER_OWN) { $items[] = ['label' => Yii::t('podium/layout', 'Sign out'), 'url' => ['profile/logout'], 'linkOptions' => ['data-method' => 'post']]; } } NavBar::begin(['brandLabel' => Config::getInstance()->get('name'), 'brandUrl' => ['default/index'], 'options' => ['class' => 'navbar-inverse navbar-default'], 'innerContainerOptions' => ['class' => 'container-fluid']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'encodeLabels' => false, 'activateParents' => true, 'items' => $items]); NavBar::end();