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


PHP User::className方法代码示例

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


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

示例1: follow

 /**
  * Follows the owner object
  *
  * @param int $userId
  * @return boolean
  */
 public function follow($userId = "", $withNotifications = true)
 {
     if ($userId == "") {
         $userId = Yii::$app->user->id;
     }
     // User cannot follow himself
     if ($this->owner->className() == \humhub\modules\user\models\User::className() && $this->owner->getPrimaryKey() == $userId) {
         return false;
     }
     $follow = $this->getFollowRecord($userId);
     if ($follow === null) {
         $follow = new \humhub\modules\user\models\Follow();
         $follow->user_id = $userId;
         $follow->object_id = $this->owner->getPrimaryKey();
         $follow->object_model = $this->owner->className();
     }
     if ($withNotifications) {
         $follow->send_notifications = 1;
     } else {
         $follow->send_notifications = 0;
     }
     if (!$follow->save()) {
         return false;
     }
     return true;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:32,代码来源:Followable.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $friendshipEnabled = Yii::$app->getModule('friendship')->getIsEnabled();
     if ($this->user == null) {
         /**
          * For guests collect all wall_ids of "guest" public spaces / user profiles.
          * Generally show only public content
          */
         $publicSpacesSql = (new \yii\db\Query())->select(["si.wall_id"])->from('space si')->where('si.visibility=' . \humhub\modules\space\models\Space::VISIBILITY_ALL);
         $union = Yii::$app->db->getQueryBuilder()->build($publicSpacesSql)[0];
         $publicProfilesSql = (new \yii\db\Query())->select("pi.wall_id")->from('user pi')->where('pi.status=1 AND  pi.visibility = ' . \humhub\modules\user\models\User::VISIBILITY_ALL);
         $union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($publicProfilesSql)[0];
         $this->activeQuery->andWhere('wall_entry.wall_id IN (' . $union . ')');
         $this->activeQuery->andWhere(['content.visibility' => \humhub\modules\content\models\Content::VISIBILITY_PUBLIC]);
     } else {
         /**
          * Collect all wall_ids we need to include into dashboard stream
          */
         // User to user follows
         $userFollow = (new \yii\db\Query())->select(["uf.wall_id"])->from('user_follow')->leftJoin('user uf', 'uf.id=user_follow.object_id AND user_follow.object_model=:userClass')->where('user_follow.user_id=' . $this->user->id . ' AND uf.wall_id IS NOT NULL');
         $union = Yii::$app->db->getQueryBuilder()->build($userFollow)[0];
         // User to space follows
         $spaceFollow = (new \yii\db\Query())->select("sf.wall_id")->from('user_follow')->leftJoin('space sf', 'sf.id=user_follow.object_id AND user_follow.object_model=:spaceClass')->where('user_follow.user_id=' . $this->user->id . ' AND sf.wall_id IS NOT NULL');
         $union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($spaceFollow)[0];
         // User to space memberships
         $spaceMemberships = (new \yii\db\Query())->select("sm.wall_id")->from('space_membership')->leftJoin('space sm', 'sm.id=space_membership.space_id')->where('space_membership.user_id=' . $this->user->id . ' AND sm.wall_id IS NOT NULL AND space_membership.show_at_dashboard = 1');
         $union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($spaceMemberships)[0];
         if ($friendshipEnabled) {
             // User to user follows
             $usersFriends = (new \yii\db\Query())->select(["ufr.wall_id"])->from('user ufr')->leftJoin('user_friendship recv', 'ufr.id=recv.friend_user_id AND recv.user_id=' . (int) $this->user->id)->leftJoin('user_friendship snd', 'ufr.id=snd.user_id AND snd.friend_user_id=' . (int) $this->user->id)->where('recv.id IS NOT NULL AND snd.id IS NOT NULL AND ufr.wall_id IS NOT NULL');
             $union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($usersFriends)[0];
         }
         // Glue together also with current users wall
         $wallIdsSql = (new \yii\db\Query())->select('wall_id')->from('user uw')->where('uw.id=' . $this->user->id);
         $union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($wallIdsSql)[0];
         // Manual Union (https://github.com/yiisoft/yii2/issues/7992)
         // Double union query - to avoid MySQL performance problems
         $this->activeQuery->andWhere('wall_entry.wall_id IN (select subselect.wall_id from (' . $union . ') subselect)', [':spaceClass' => \humhub\modules\space\models\Space::className(), ':userClass' => \humhub\modules\user\models\User::className()]);
         /**
          * Begin visibility checks regarding the content container
          */
         $this->activeQuery->leftJoin('wall', 'wall_entry.wall_id=wall.id');
         $this->activeQuery->leftJoin('space_membership', 'wall.object_id=space_membership.space_id AND space_membership.user_id=:userId AND space_membership.status=:status', ['userId' => $this->user->id, ':status' => \humhub\modules\space\models\Membership::STATUS_MEMBER]);
         if ($friendshipEnabled) {
             $this->activeQuery->leftJoin('user_friendship', 'wall.object_id=user_friendship.user_id AND user_friendship.friend_user_id=:userId', ['userId' => $this->user->id]);
         }
         $condition = ' (wall.object_model=:userModel AND content.visibility=0 AND content.created_by = :userId) OR ';
         if ($friendshipEnabled) {
             // In case of friendship we can also display private content
             $condition .= ' (wall.object_model=:userModel AND content.visibility=0 AND user_friendship.id IS NOT NULL) OR ';
         }
         // In case of an space entry, we need to join the space membership to verify the user can see private space content
         $condition .= ' (wall.object_model=:spaceModel AND content.visibility = 0 AND space_membership.status = ' . \humhub\modules\space\models\Membership::STATUS_MEMBER . ') OR ';
         $condition .= ' (content.visibility = 1 OR content.visibility IS NULL) ';
         $this->activeQuery->andWhere($condition, [':userId' => $this->user->id, ':spaceModel' => \humhub\modules\space\models\Space::className(), ':userModel' => \humhub\modules\user\models\User::className()]);
     }
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:61,代码来源:DashboardStream.php

示例3: 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

示例4: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = [['newEmail', 'required'], ['newEmail', 'email'], ['newEmail', 'unique', 'targetAttribute' => 'email', 'targetClass' => User::className(), 'message' => '{attribute} "{value}" is already in use!']];
     if (CheckPasswordValidator::hasPassword()) {
         $rules[] = ['currentPassword', CheckPasswordValidator::className()];
         $rules[] = ['currentPassword', 'required'];
     }
     return $rules;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:12,代码来源:AccountChangeEmail.php

示例5: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $friendshipsEnabled = Yii::$app->getModule('friendship')->getIsEnabled();
     $countFriends = 0;
     if ($friendshipsEnabled) {
         $countFriends = Friendship::getFriendsQuery($this->user)->count();
     }
     $countFollowing = $this->user->getFollowingCount(User::className()) + $this->user->getFollowingCount(Space::className());
     $countUserSpaces = Membership::getUserSpaceQuery($this->user)->andWhere(['!=', 'space.visibility', Space::VISIBILITY_NONE])->andWhere(['space.status' => Space::STATUS_ENABLED])->count();
     return $this->render('profileHeader', array('user' => $this->user, 'isProfileOwner' => $this->isProfileOwner, 'friendshipsEnabled' => $friendshipsEnabled, 'countFriends' => $countFriends, 'countFollowers' => $this->user->getFollowerCount(), 'countFollowing' => $countFollowing, 'countSpaces' => $countUserSpaces));
 }
开发者ID:kreativmind,项目名称:humhub,代码行数:14,代码来源:ProfileHeader.php

示例6: up

 public function up()
 {
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\Text'], ['field_type_class' => 'ProfileFieldTypeText']);
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\Birthday'], ['field_type_class' => 'ProfileFieldTypeBirthday']);
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\DateTime'], ['field_type_class' => 'ProfileFieldTypeDateTime']);
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\Number'], ['field_type_class' => 'ProfileFieldTypeNumber']);
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\Select'], ['field_type_class' => 'ProfileFieldTypeSelect']);
     $this->update('profile_field', ['field_type_class' => 'humhub\\modules\\user\\models\\fieldtype\\TextArea'], ['field_type_class' => 'ProfileFieldTypeTextArea']);
     $this->renameClass('User', User::className());
     $this->renameClass('UserFollow', User::className());
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:11,代码来源:m150704_005504_namespace.php

示例7: beforeDelete

 public function beforeDelete()
 {
     // ToDo: Handle this via event of User Module
     if ($this->object_model == User::className()) {
         $notification = new \humhub\modules\user\notifications\Followed();
         $notification->originator = $this->user;
         $notification->delete($this->getTarget());
         foreach (Activity::findAll(['object_model' => $this->className(), 'object_id' => $this->id]) as $activity) {
             $activity->delete();
         }
     }
     return parent::beforeDelete();
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:13,代码来源:Follow.php

示例8: getAvailableModules

 /**
  * Returns a list of all available user modules
  *
  * @return array
  */
 public function getAvailableModules()
 {
     if ($this->_availableModules !== null) {
         return $this->_availableModules;
     }
     $this->_availableModules = array();
     foreach (Yii::$app->moduleManager->getModules() as $moduleId => $module) {
         if ($module instanceof ContentContainerModule && Yii::$app->hasModule($module->id) && $module->hasContentContainerType(User::className())) {
             $this->_availableModules[$module->id] = $module;
         }
     }
     return $this->_availableModules;
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:18,代码来源:UserModelModules.php

示例9: onUserDelete

 /**
  * On User delete, also delete all posts
  *
  * @param type $event
  */
 public static function onUserDelete($event)
 {
     foreach (Notification::findAll(['user_id' => $event->sender->id]) as $notification) {
         $notification->delete();
     }
     foreach (Notification::findAll(['originator_user_id' => $event->sender->id]) as $notification) {
         $notification->delete();
     }
     foreach (Notification::findAll(['source_class' => \humhub\modules\user\models\User::className(), 'source_pk' => $event->sender->id]) as $notification) {
         $notification->delete();
     }
     return true;
 }
开发者ID:caohui123,项目名称:humhub,代码行数:18,代码来源:Events.php

示例10: actionMembers

 /**
  * Action for the members section of the directory
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionMembers()
 {
     $keyword = Yii::$app->request->get('keyword', "");
     $page = (int) Yii::$app->request->get('page', 1);
     //$_GET['keyword'] = $keyword; // Fix for post var
     $searchResultSet = Yii::$app->search->find($keyword, ['model' => \humhub\modules\user\models\User::className(), 'page' => $page, 'pageSize' => Setting::Get('paginationSize')]);
     $pagination = new \yii\data\Pagination(['totalCount' => $searchResultSet->total, 'pageSize' => $searchResultSet->pageSize]);
     \yii\base\Event::on(Sidebar::className(), Sidebar::EVENT_INIT, function ($event) {
         $event->sender->addWidget(\humhub\modules\directory\widgets\NewMembers::className(), [], ['sortOrder' => 10]);
         $event->sender->addWidget(\humhub\modules\directory\widgets\MemberStatistics::className(), [], ['sortOrder' => 20]);
     });
     return $this->render('members', array('keyword' => $keyword, 'users' => $searchResultSet->getResultInstances(), 'pagination' => $pagination));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:18,代码来源:DirectoryController.php

示例11: up

 public function up()
 {
     $this->createTable('contentcontainer_setting', ['id' => Schema::TYPE_PK, 'module_id' => $this->string(50)->notNull(), 'contentcontainer_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'name' => $this->string(50)->notNull(), 'value' => Schema::TYPE_TEXT . ' NOT NULL']);
     $this->createIndex('settings-unique', 'contentcontainer_setting', ['module_id', 'contentcontainer_id', 'name'], true);
     $this->addForeignKey('fk-contentcontainerx', 'contentcontainer_setting', 'contentcontainer_id', 'contentcontainer', 'id', 'CASCADE', 'CASCADE');
     // Import old user settings
     $rows = (new Query())->select("*, contentcontainer.id as cid")->from('user_setting')->leftJoin('contentcontainer', 'user_setting.user_id = contentcontainer.pk AND contentcontainer.class=:class', [':class' => \humhub\modules\user\models\User::className()])->andWhere('contentcontainer.id IS NOT NULL')->all();
     foreach ($rows as $row) {
         $this->insertSilent('contentcontainer_setting', ['module_id' => $row['module_id'], 'contentcontainer_id' => $row['cid'], 'name' => $row['name'], 'value' => $row['value']]);
     }
     // Import old space settings
     $rows = (new Query())->select("*, contentcontainer.id as cid")->from('space_setting')->leftJoin('contentcontainer', 'space_setting.space_id = contentcontainer.pk AND contentcontainer.class=:class', [':class' => humhub\modules\space\models\Space::className()])->andWhere('contentcontainer.id IS NOT NULL')->all();
     foreach ($rows as $row) {
         $this->insertSilent('contentcontainer_setting', ['module_id' => $row['module_id'], 'contentcontainer_id' => $row['cid'], 'name' => $row['name'], 'value' => $row['value']]);
     }
     $this->dropTable('user_setting');
     $this->dropTable('space_setting');
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:18,代码来源:m160507_202611_settings.php

示例12: beforeDelete

 public function beforeDelete()
 {
     // ToDo: Handle this via event of User Module
     if ($this->object_model == User::className()) {
         /*
          $user = User::model()->findByPk($this->user_id);
          $activity = Activity::model()->contentContainer($user)->findByAttributes(array('type' => "ActivityUserFollowsUser", 'object_id' => $this->object_id));
          if ($activity !== null) {
          $activity->delete();
          }
         *
         */
         $notification = new \humhub\modules\user\notifications\Followed();
         $notification->originator = $this->user;
         $notification->delete($this->getTarget());
     }
     return parent::beforeDelete();
 }
开发者ID:honestgorillas,项目名称:humhub,代码行数:18,代码来源:Follow.php

示例13: up

 public function up()
 {
     $this->createTable('contentcontainer', array('id' => Schema::TYPE_PK, 'guid' => Schema::TYPE_STRING, 'class' => Schema::TYPE_STRING, 'pk' => Schema::TYPE_INTEGER, 'owner_user_id' => Schema::TYPE_INTEGER, 'wall_id' => Schema::TYPE_INTEGER), '');
     $this->createIndex('unique_target', 'contentcontainer', ['class', 'pk'], true);
     $this->createIndex('unique_guid', 'contentcontainer', ['guid'], true);
     $this->addColumn('space', 'contentcontainer_id', Schema::TYPE_INTEGER);
     $this->addColumn('user', 'contentcontainer_id', Schema::TYPE_INTEGER);
     $spaces = (new \yii\db\Query())->select("space.*")->from('space');
     foreach ($spaces->each() as $space) {
         $this->insertSilent('contentcontainer', ['guid' => $space['guid'], 'class' => humhub\modules\space\models\Space::className(), 'pk' => $space['id'], 'owner_user_id' => $space['created_by'], 'wall_id' => $space['wall_id']]);
         $this->updateSilent('space', ['contentcontainer_id' => Yii::$app->db->getLastInsertID()], 'space.id=:spaceId', [':spaceId' => $space['id']]);
     }
     $users = (new \yii\db\Query())->select("user.*")->from('user');
     foreach ($users->each() as $user) {
         $this->insertSilent('contentcontainer', ['guid' => $user['guid'], 'class' => \humhub\modules\user\models\User::className(), 'pk' => $user['id'], 'owner_user_id' => $user['id'], 'wall_id' => $user['wall_id']]);
         $this->updateSilent('user', ['contentcontainer_id' => Yii::$app->db->getLastInsertID()], 'user.id=:userId', [':userId' => $user['id']]);
     }
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:18,代码来源:m150927_190830_create_contentcontainer.php

示例14: up

 public function up()
 {
     // Add contentcontainer_id to content table
     $this->addColumn('content', 'contentcontainer_id', $this->integer());
     // Set content container for space content
     $this->update('content', ['contentcontainer_id' => new Expression('(SELECT id FROM contentcontainer WHERE class=:spaceModel AND pk=space_id)', [':spaceModel' => \humhub\modules\space\models\Space::className()])], ['IS NOT', 'space_id', new Expression('NULL')]);
     // Set content container for user content
     $this->update('content', ['contentcontainer_id' => new Expression('(SELECT id FROM contentcontainer WHERE class=:userModel AND pk=user_id)', [':userModel' => \humhub\modules\user\models\User::className()])], ['IS', 'space_id', new Expression('NULL')]);
     // Ensure created_by is set to user_id
     $this->update('content', ['created_by' => new Expression('user_id')]);
     // Ensure updated_by is set
     $this->update('content', ['updated_by' => new Expression('created_by')], ['IS', 'updated_by', new Expression('NULL')]);
     // Make sure fk dont fail
     Yii::$app->db->createCommand('UPDATE content LEFT JOIN user ON content.updated_by = user.id SET content.updated_by = NULL WHERE user.id IS NULL')->execute();
     Yii::$app->db->createCommand('UPDATE content LEFT JOIN user ON content.created_by = user.id SET content.created_by = NULL WHERE user.id IS NULL')->execute();
     // Add FKs
     $this->addForeignKey('fk-contentcontainer', 'content', 'contentcontainer_id', 'contentcontainer', 'id', 'SET NULL');
     $this->addForeignKey('fk-create-user', 'content', 'created_by', 'user', 'id', 'SET NULL');
     $this->addForeignKey('fk-update-user', 'content', 'updated_by', 'user', 'id', 'SET NULL');
     $this->dropColumn('content', 'space_id');
     $this->dropColumn('content', 'user_id');
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:22,代码来源:m160220_013525_contentcontainer_id.php

示例15: actionMembers

 /**
  * Action for the members section of the directory
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionMembers()
 {
     $keyword = Yii::$app->request->get('keyword', "");
     $page = (int) Yii::$app->request->get('page', 1);
     $groupId = (int) Yii::$app->request->get('groupId', "");
     $group = null;
     if ($groupId) {
         $group = \humhub\modules\user\models\Group::findOne(['id' => $groupId]);
     }
     $searchOptions = ['model' => \humhub\modules\user\models\User::className(), 'page' => $page, 'pageSize' => $this->module->pageSize];
     if ($this->module->memberListSortField != "") {
         $searchOptions['sortField'] = $this->module->memberListSortField;
     }
     if ($group !== null) {
         $searchOptions['filters'] = ['groupId' => $group->id];
     }
     $searchResultSet = Yii::$app->search->find($keyword, $searchOptions);
     $pagination = new \yii\data\Pagination(['totalCount' => $searchResultSet->total, 'pageSize' => $searchResultSet->pageSize]);
     \yii\base\Event::on(Sidebar::className(), Sidebar::EVENT_INIT, function ($event) {
         $event->sender->addWidget(\humhub\modules\directory\widgets\NewMembers::className(), [], ['sortOrder' => 10]);
         $event->sender->addWidget(\humhub\modules\directory\widgets\MemberStatistics::className(), [], ['sortOrder' => 20]);
     });
     return $this->render('members', array('keyword' => $keyword, 'group' => $group, 'users' => $searchResultSet->getResultInstances(), 'pagination' => $pagination));
 }
开发者ID:gautamkrishnar,项目名称:humhub-openshift-quickstart,代码行数:29,代码来源:DirectoryController.php


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