当前位置: 首页>>代码示例>>PHP>>正文


PHP User::find方法代码示例

本文整理汇总了PHP中humhub\modules\user\models\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在humhub\modules\user\models\User的用法示例。


在下文中一共展示了User::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processCron

 /**
  * Processes update e-mails for all users
  */
 public static function processCron($controller)
 {
     // Detect the mailing interval we're in
     $interval = 0;
     if (Yii::$app->controller->action->id == 'hourly') {
         $interval = self::INTERVAL_HOURY;
     } elseif (Yii::$app->controller->action->id == 'daily') {
         $interval = self::INTERVAL_DAILY;
     } else {
         throw new \yii\console\Exception('Invalid mail update interval!');
     }
     // Get users
     $users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['user.status' => User::STATUS_ENABLED]);
     $totalUsers = $users->count();
     $processed = 0;
     Console::startProgress($processed, $totalUsers, 'Sending update e-mails to users... ', false);
     $mailsSent = 0;
     foreach ($users->each() as $user) {
         $mailSender = new self();
         $mailSender->user = $user;
         $mailSender->interval = $interval;
         if ($mailSender->send()) {
             $mailsSent++;
         }
         Console::updateProgress(++$processed, $totalUsers);
     }
     Console::endProgress(true);
     $controller->stdout('done - ' . $mailsSent . ' email(s) sent.' . PHP_EOL, Console::FG_GREEN);
     // Switch back to system language
     self::switchLanguage();
 }
开发者ID:kreativmind,项目名称:humhub,代码行数:34,代码来源:MailUpdateSender.php

示例2: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->joinWith('profile');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['super_admin' => $this->super_admin]);
     $query->andFilterWhere(['like', 'id', $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
     $query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
     if ($this->getAttribute('last_login') != "") {
         try {
             $last_login = Yii::$app->formatter->asDate($this->getAttribute('last_login'), 'php:Y-m-d');
             $query->andWhere(['=', new \yii\db\Expression("DATE(last_login)"), new \yii\db\Expression("DATE(:last_login)", [':last_login' => $last_login])]);
         } catch (InvalidParamException $e) {
             // do not change the query if the date is wrong formatted
         }
     }
     return $dataProvider;
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:34,代码来源:UserSearch.php

示例3: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->joinWith('profile');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     if (strtolower($this->last_login) == 'yes') {
         $query->andWhere(['not', ['last_login' => null]]);
     } else {
         if (strtolower($this->last_login) == 'no') {
             $query->andWhere(['last_login' => null]);
         }
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['super_admin' => $this->super_admin]);
     $query->andFilterWhere(['like', 'id', $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
     $query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
     return $dataProvider;
 }
开发者ID:kirill-g-r,项目名称:humhub,代码行数:33,代码来源:UserSearch.php

示例4: actionSearch

 /**
  * Provides a searchable user list of all workspace members in json.
  *
  */
 public function actionSearch()
 {
     Yii::$app->response->format = 'json';
     $space = $this->getSpace();
     if (!$space->isMember()) {
         throw new HttpException(404, Yii::t('SpaceModule.controllers_SpaceController', 'This action is only available for workspace members!'));
     }
     $results = array();
     $keyword = Yii::$app->request->get('keyword');
     $query = User::find();
     $query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id AND space_membership.status=:member', ['space_id' => $space->id, 'member' => Membership::STATUS_MEMBER]);
     $query->andWhere('space_membership.space_id IS NOT NULL');
     $query->joinWith('profile');
     $query->limit(10);
     // Build Search Condition
     $parts = explode(" ", $keyword);
     $i = 0;
     foreach ($parts as $part) {
         $i++;
         $query->andWhere("(user.email LIKE :match OR " . "user.username LIKE :match OR " . "profile.firstname LIKE :match OR " . "profile.lastname LIKE :match OR " . "profile.title LIKE :match)", ['match' => '%' . $part . '%']);
     }
     foreach ($query->all() as $user) {
         $userInfo['guid'] = $user->guid;
         $userInfo['displayName'] = \yii\helpers\Html::encode($user->displayName);
         $userInfo['email'] = $user->email;
         $userInfo['image'] = $user->getProfileImage()->getUrl();
         $userInfo['link'] = $user->getUrl();
         $results[] = $userInfo;
     }
     return $results;
 }
开发者ID:alefernie,项目名称:intranet,代码行数:35,代码来源:MembershipController.php

示例5: getOnlineUsers

 /**
  * Returns all current logged in users.
  * 
  * @return ActiveQueryUser
  */
 public static function getOnlineUsers()
 {
     $query = \humhub\modules\user\models\User::find();
     $query->leftJoin('user_http_session', 'user_http_session.user_id=user.id');
     $query->andWhere(['IS NOT', 'user_http_session.user_id', new Expression('NULL')]);
     return $query;
 }
开发者ID:honestgorillas,项目名称:humhub,代码行数:12,代码来源:Session.php

示例6: up

 public function up()
 {
     $spaces = Space::find()->all();
     $users = User::find()->all();
     $containers = array_merge($users == null ? [] : $users, $spaces == null ? [] : $spaces);
     foreach ($containers as $container) {
         $created_by = $container instanceof User ? $container->id : $container instanceof Space ? $container->created_by : 1;
         $created_by = $created_by == null ? 1 : $created_by;
         if ($container->isModuleEnabled('cfiles')) {
             $this->insert('cfiles_folder', ['title' => Module::ROOT_TITLE, 'description' => Module::ROOT_DESCRIPTION, 'parent_folder_id' => 0, 'has_wall_entry' => false, 'type' => Folder::TYPE_FOLDER_ROOT]);
             $root_id = Yii::$app->db->getLastInsertID();
             $this->insert('content', ['guid' => \humhub\libs\UUID::v4(), 'object_model' => Folder::className(), 'object_id' => $root_id, 'visibility' => 0, 'sticked' => 0, 'archived' => 0, 'created_at' => new \yii\db\Expression('NOW()'), 'created_by' => $created_by, 'updated_at' => new \yii\db\Expression('NOW()'), 'updated_by' => $created_by, 'contentcontainer_id' => $container->contentcontainer_id]);
             $this->insert('cfiles_folder', ['title' => Module::ALL_POSTED_FILES_TITLE, 'description' => Module::ALL_POSTED_FILES_DESCRIPTION, 'parent_folder_id' => $root_id, 'has_wall_entry' => false, 'type' => Folder::TYPE_FOLDER_POSTED]);
             $allpostedfiles_id = Yii::$app->db->getLastInsertID();
             $this->insert('content', ['guid' => \humhub\libs\UUID::v4(), 'object_model' => Folder::className(), 'object_id' => $allpostedfiles_id, 'visibility' => 0, 'sticked' => 0, 'archived' => 0, 'created_at' => new \yii\db\Expression('NOW()'), 'created_by' => $created_by, 'updated_at' => new \yii\db\Expression('NOW()'), 'updated_by' => $created_by, 'contentcontainer_id' => $container->contentcontainer_id]);
             $posted_content_id = Yii::$app->db->getLastInsertID();
             $filesQuery = File::find()->joinWith('baseFile')->contentContainer($container);
             $foldersQuery = Folder::find()->contentContainer($container);
             $filesQuery->andWhere(['cfiles_file.parent_folder_id' => 0]);
             // user maintained folders
             $foldersQuery->andWhere(['cfiles_folder.parent_folder_id' => 0]);
             // do not return any folders here that are root or allpostedfiles
             $foldersQuery->andWhere(['cfiles_folder.type' => null]);
             $rootsubfiles = $filesQuery->all();
             $rootsubfolders = $foldersQuery->all();
             foreach ($rootsubfiles as $file) {
                 $this->update('cfiles_file', ['cfiles_file.parent_folder_id' => $root_id], ['id' => $file->id]);
             }
             foreach ($rootsubfolders as $folder) {
                 $this->update('cfiles_folder', ['parent_folder_id' => $root_id], ['id' => $folder->id]);
             }
         }
     }
 }
开发者ID:humhub,项目名称:humhub-modules-cfiles,代码行数:34,代码来源:m160831_134312_generate_default_folders.php

示例7: actionJson

 /**
  * JSON Search for Users
  *
  * Returns an array of users with fields:
  *  - guid
  *  - displayName
  *  - image
  *  - profile link
  */
 public function actionJson()
 {
     Yii::$app->response->format = 'json';
     $maxResults = 10;
     $keyword = Yii::$app->request->get('keyword');
     $query = User::find()->limit($maxResults)->joinWith('profile');
     foreach (explode(" ", $keyword) as $part) {
         $query->orFilterWhere(['like', 'user.email', $part]);
         $query->orFilterWhere(['like', 'user.username', $part]);
         $query->orFilterWhere(['like', 'profile.firstname', $part]);
         $query->orFilterWhere(['like', 'profile.lastname', $part]);
         $query->orFilterWhere(['like', 'profile.title', $part]);
     }
     $query->active();
     $results = [];
     foreach ($query->all() as $user) {
         if ($user != null) {
             $userInfo = array();
             $userInfo['guid'] = $user->guid;
             $userInfo['displayName'] = Html::encode($user->displayName);
             $userInfo['image'] = $user->getProfileImage()->getUrl();
             $userInfo['link'] = $user->getUrl();
             $results[] = $userInfo;
         }
     }
     return $results;
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:36,代码来源:SearchController.php

示例8: onCronDailyRun

 /**
  * Check if there is a new Humhub Version available and sends a notification
  * to super admins
  *
  * @param \yii\base\Event $event
  */
 public static function onCronDailyRun($event)
 {
     $controller = $event->sender;
     if (!Yii::$app->getModule('admin')->dailyCheckForNewVersion) {
         return;
     }
     if (!Yii::$app->params['humhub']['apiEnabled']) {
         return;
     }
     $controller->stdout("Checking for new HumHub version... ");
     $latestVersion = libs\HumHubAPI::getLatestHumHubVersion();
     if ($latestVersion != "") {
         $adminUserQuery = User::find()->where(['super_admin' => 1]);
         $latestNotifiedVersion = Setting::Get('lastVersionNotify', 'admin');
         $adminsNotified = !($latestNotifiedVersion == "" || version_compare($latestVersion, $latestNotifiedVersion, ">"));
         $newVersionAvailable = version_compare($latestVersion, Yii::$app->version, ">");
         $updateNotification = new notifications\NewVersionAvailable();
         // Cleanup existing notifications
         if (!$newVersionAvailable || $newVersionAvailable && !$adminsNotified) {
             foreach ($adminUserQuery->all() as $admin) {
                 $updateNotification->delete($admin);
             }
         }
         // Create new notification
         if ($newVersionAvailable && !$adminsNotified) {
             $updateNotification->sendBulk($adminUserQuery);
             Setting::Set('lastVersionNotify', $latestVersion, 'admin');
         }
     }
     $controller->stdout('done. ' . PHP_EOL, \yii\helpers\Console::FG_GREEN);
 }
开发者ID:1resu,项目名称:humhub,代码行数:37,代码来源:Events.php

示例9: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = User::find()->joinWith(['profile', 'group']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $dataProvider->setSort(['attributes' => ['group.id', 'username', 'email', 'super_admin', 'profile.firstname', 'profile.lastname', 'created_at']]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     /**
      * Limit Groups
      */
     $groups = $this->getGroups();
     $groupIds = [];
     foreach ($groups as $group) {
         $groupIds[] = $group->id;
     }
     $query->andWhere(['IN', 'group_id', $groupIds]);
     $query->andWhere(['status' => User::STATUS_NEED_APPROVAL]);
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['group.id' => $this->getAttribute('group.id')]);
     $query->andFilterWhere(['super_admin' => $this->super_admin]);
     $query->andFilterWhere(['like', 'id', $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
     $query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
     return $dataProvider;
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:37,代码来源:UserApprovalSearch.php

示例10: run

 /**
  * Broadcast a message to all users
  */
 public function run()
 {
     //Send GCM notifications
     $model = new $this->modelClass();
     $records = $model->findBySql("SELECT * FROM gcm_relation")->all();
     $params = Yii::$app->getRequest()->getBodyParams();
     $data = array('message' => $params['message'], 'url' => $params['url']);
     $results = array();
     foreach ($records as $record) {
         if ($record->register_key) {
             //Enviar missatge
             $gcm = new GoogleCloudMessage();
             $gcm->apiKey = Setting::Get('gcmAPIKey', 'gcm');
             $gcm->url = Setting::Get('gcmURL', 'gcm');
             $result = $gcm->send($data, array($record->register_key));
             $results[$record->register_key] = $result;
         }
     }
     //Send mail notificacion
     $users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['status' => User::STATUS_ENABLED]);
     Yii::setAlias('@gcmmodule', Yii::$app->getModule('gcm')->getBasePath());
     foreach ($users->each() as $user) {
         $mail = Yii::$app->mailer->compose(['html' => '@gcmmodule/views/emails/NewMessage'], ['message' => $params['message'], 'url' => $params['url']]);
         $mail->setFrom([Setting::Get('systemEmailAddress', 'mailing') => Setting::Get('systemEmailName', 'mailing')]);
         $mail->setTo($user->email);
         $mail->setSubject('Nova notícia al web: ' . $params['message']);
         $mail->send();
     }
     return true;
 }
开发者ID:ravalnet,项目名称:humhub-Gedi,代码行数:33,代码来源:BroadcastAction.php

示例11: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $groups = Group::find()->count();
     $users = User::find()->count();
     $statsAvgMembers = $users / $groups;
     $statsTopGroup = Group::find()->where('id = (SELECT group_id  FROM user GROUP BY group_id ORDER BY count(*) DESC LIMIT 1)')->one();
     // Render widgets view
     return $this->render('groupStats', array('statsTotalGroups' => $groups, 'statsAvgMembers' => round($statsAvgMembers, 1), 'statsTopGroup' => $statsTopGroup, 'statsTotalUsers' => $users));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:12,代码来源:GroupStatistics.php

示例12: auth

 /**
  * @inheritdoc
  */
 public function auth()
 {
     $user = User::find()->where(['username' => $this->login->username])->orWhere(['email' => $this->login->username])->one();
     if ($user !== null && $user->currentPassword !== null && $user->currentPassword->validatePassword($this->login->password)) {
         $this->setUserAttributes(['id' => $user->id]);
         return true;
     }
     return false;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:12,代码来源:Password.php

示例13: actionUserList

 /**
  * Returns a user list which contains all users who likes it
  */
 public function actionUserList()
 {
     $query = \humhub\modules\user\models\User::find();
     $query->leftJoin('like', 'like.created_by=user.id');
     $query->where(['like.object_id' => $this->contentId, 'like.object_model' => $this->contentModel]);
     $query->orderBy('like.created_at DESC');
     $title = Yii::t('LikeModule.controllers_LikeController', "<strong>Users</strong> who like this");
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:12,代码来源:LikeController.php

示例14: run

 /**
  * 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));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:12,代码来源:MemberStatistics.php

示例15: run

 public function run()
 {
     $range = (int) Setting::Get('shownDays', 'birthday');
     $birthdayCondition = "DATE_ADD(profile.birthday, \n                INTERVAL YEAR(CURDATE())-YEAR(profile.birthday)\n                         + IF(DAYOFYEAR(CURDATE()) > DAYOFYEAR(profile.birthday),1,0)\n                YEAR)  \n            BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL " . $range . " DAY);";
     $users = User::find()->joinWith('profile')->where($birthdayCondition)->limit(10)->all();
     if (count($users) == 0) {
         return;
     }
     return $this->render('birthdayPanel', array('users' => $users));
 }
开发者ID:pkdevboxy,项目名称:humhub-modules-birthday,代码行数:10,代码来源:BirthdaySidebarWidget.php


注:本文中的humhub\modules\user\models\User::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。