* @copyright (c), Thread */ class User extends aModule { public $name = 'user'; public $translationsBasePath = __DIR__ . '/messages'; public $configPath = __DIR__ . '/config.php'; // public $itemOnPage = 20; // public $username_attribute = 'username'; // public $password_min_length = 4; public $auto_login_after_register = true; public $time_remember_user_sign_in = 2592000; // 24 * 30 * 3600 // public $passwordResetTokenExpire = 3600; /** * @return string */ public static function getDb() { return Yii::$app->get('db-core'); } /** * @return string */ public static function getRedirectUrlAfterLogin() { return Url::toRoute(['/home/home/index']); } /** * @param ActiveRecord $model * @return string */ public function getAvatarUploadPath(ActiveRecord $model) { return $this->getBaseUploadPath('user', $model) . '/profile'; } /** * @param ActiveRecord $model * @return string */ public function getAvatarUploadUrl(ActiveRecord $model) { return $this->getBaseUploadUrl('user', $model) . '/profile'; } /** * @param $key * @param ActiveRecord $model * @return string */ public function getBaseUploadPath($key, ActiveRecord $model) { $item = [ 'user' => Yii::getAlias('@uploads') . '/user/', ]; return $item[$key] . $this->getBaseDirSuffix($model); } /** * @param $key * @param ActiveRecord $model * @return string */ public function getBaseUploadUrl($key, ActiveRecord $model) { $item = [ 'user' => '/uploads/user/', ]; return $item[$key] . $this->getBaseDirSuffix($model); } /** * @param ActiveRecord $model * @return string */ public function getBaseDirSuffix(ActiveRecord $model) { return date('Y/m/d', $model['created_at']) . '/' . $model['id']; } }