Exemplo n.º 1
0
 /**
  * Executes the widgets
  */
 public function run()
 {
     // Some member stats
     $statsTotalUsers = User::find()->active()->count();
     $statsUserOnline = \humhub\modules\user\components\Session::getOnlineUsers()->count();
     $statsUserFollow = Follow::find()->where(['object_model' => User::className()])->count();
     // Render widgets view
     return $this->render('memberStats', array('statsTotalUsers' => $statsTotalUsers, 'statsUserOnline' => $statsUserOnline, 'statsUserFollow' => $statsUserFollow));
 }
 public function actionUsers()
 {
     $query = \humhub\modules\user\components\Session::getOnlineUsers();
     $response = [];
     foreach ($query->all() as $user) {
         $response[] = ['name' => $user->displayName, 'gravatar' => $user->getProfileImage()->getUrl(), 'profile' => Url::toRoute(['/', 'uguid' => $user->guid])];
     }
     Yii::$app->response->format = 'json';
     return ['online' => Yii::t('Humhub-chatModule.base', count($response) == 1 ? '{count} person online' : '{count} people online', ['{count}' => count($response)]), 'users' => $response];
 }