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


PHP models\Space类代码示例

本文整理汇总了PHP中humhub\modules\space\models\Space的典型用法代码示例。如果您正苦于以下问题:PHP Space类的具体用法?PHP Space怎么用?PHP Space使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: init

 public function init()
 {
     if ($this->space === null && Yii::$app->controller instanceof ContentContainerController && Yii::$app->controller->contentContainer instanceof Space) {
         $this->space = Yii::$app->controller->contentContainer;
     }
     if ($this->space === null) {
         throw new \yii\base\Exception("Could not instance space menu without space!");
     }
     $this->addItemGroup(array('id' => 'modules', 'label' => Yii::t('SpaceModule.widgets_SpaceMenuWidget', '<strong>Space</strong> menu'), 'sortOrder' => 100));
     $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMenuWidget', 'Stream'), 'group' => 'modules', 'url' => $this->space->createUrl('/space/space/home'), 'icon' => '<i class="fa fa-bars"></i>', 'sortOrder' => 100, 'isActive' => Yii::$app->controller->id == "space" && (Yii::$app->controller->action->id == "index" || Yii::$app->controller->action->id == 'home') && Yii::$app->controller->module->id == "space"));
     parent::init();
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:12,代码来源:Menu.php

示例2: actionCreate

 /**
  * Creates a new Space
  */
 public function actionCreate()
 {
     if (!Yii::$app->user->getIdentity()->canCreateSpace()) {
         throw new HttpException(400, 'You are not allowed to create spaces!');
     }
     $model = new Space();
     $model->scenario = 'create';
     $model->visibility = Setting::Get('defaultVisibility', 'space');
     $model->join_policy = Setting::Get('defaultJoinPolicy', 'space');
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) {
         Yii::$app->getSession()->setFlash('ws', 'created');
         return $this->htmlRedirect($model->getUrl());
     }
     return $this->renderAjax('create', array('model' => $model));
 }
开发者ID:alefernie,项目名称:intranet,代码行数:18,代码来源:CreateController.php

示例3: onIntegrityCheck

 /**
  * Callback to validate module database records.
  *
  * @param Event $event
  */
 public static function onIntegrityCheck($event)
 {
     $integrityController = $event->sender;
     $integrityController->showTestHeadline("Space Module - Spaces (" . Space::find()->count() . " entries)");
     foreach (Space::find()->all() as $space) {
         foreach ($space->applicants as $applicant) {
             if ($applicant->user == null) {
                 if ($integrityController->showFix("Deleting applicant record id " . $applicant->id . " without existing user!")) {
                     $applicant->delete();
                 }
             }
         }
     }
     $integrityController->showTestHeadline("Space Module - Module (" . models\Module::find()->count() . " entries)");
     foreach (models\Module::find()->joinWith('space')->all() as $module) {
         if ($module->space == null) {
             if ($integrityController->showFix("Deleting space module" . $module->id . " without existing space!")) {
                 $module->delete();
             }
         }
     }
     $integrityController->showTestHeadline("Space Module - Memberships (" . models\Membership::find()->count() . " entries)");
     foreach (models\Membership::find()->joinWith('space')->all() as $membership) {
         if ($membership->space == null) {
             if ($integrityController->showFix("Deleting space membership" . $membership->space_id . " without existing space!")) {
                 $membership->delete();
             }
         }
         if ($membership->user == null) {
             if ($integrityController->showFix("Deleting space membership" . $membership->user_id . " without existing user!")) {
                 $membership->delete();
             }
         }
     }
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:40,代码来源:Events.php

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

示例5: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $statsCountSpaces = Space::find()->count();
     $statsCountSpacesHidden = Space::find()->where(['visibility' => Space::VISIBILITY_NONE])->count();
     $statsSpaceMostMembers = Space::find()->where('id = (SELECT space_id  FROM space_membership GROUP BY space_id ORDER BY count(*) DESC LIMIT 1)')->one();
     // Render widgets view
     return $this->render('spaceStats', array('statsSpaceMostMembers' => $statsSpaceMostMembers, 'statsCountSpaces' => $statsCountSpaces, 'statsCountSpacesHidden' => $statsCountSpacesHidden));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:11,代码来源:SpaceStatistics.php

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

示例7: Get

 /**
  * Gets a space setting
  * 
  * @see \humhub\modules\content\components\ContentContainerSettingsManager::get
  * @param int $spaceId
  * @param string $name
  * @param string $moduleId
  * @param string $defaultValue
  * @return string
  */
 public static function Get($space, $name, $moduleId = "", $defaultValue = "")
 {
     $user = Space::findOne(['id' => $space]);
     $value = self::getModule($moduleId)->settings->contentContainer($user)->get($name);
     if ($value === null) {
         return $defaultValue;
     }
     return $value;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:19,代码来源:Setting.php

示例8: registerUser

 /** 
  * Registers a user
  * @param $data
  * @return Bool
  */
 private function registerUser($data)
 {
     $userModel = new User();
     $userModel->scenario = 'registration';
     $profileModel = $userModel->profile;
     $profileModel->scenario = 'registration';
     // User: Set values
     $userModel->username = $data['username'];
     $userModel->email = $data['email'];
     $userModel->group_id = $data['group_id'];
     $userModel->status = User::STATUS_ENABLED;
     // Profile: Set values
     $profileModel->firstname = $data['firstname'];
     $profileModel->lastname = $data['lastname'];
     // Password: Set values
     $userPasswordModel = new Password();
     $userPasswordModel->setPassword($data['password']);
     if ($userModel->save()) {
         // Save user profile
         $profileModel->user_id = $userModel->id;
         $profileModel->save();
         // Save user password
         $userPasswordModel->user_id = $userModel->id;
         $userPasswordModel->save();
         // Join space / create then join space
         foreach ($data['space_names'] as $key => $space_name) {
             // Find space by name attribute
             $space = Space::findOne(['name' => $space_name]);
             // Create the space if not found
             if ($space == null) {
                 $space = new Space();
                 $space->name = $space_name;
                 $space->save();
             }
             // Add member into space
             $space->addMember($userModel->id);
         }
         return true;
     } else {
         Yii::$app->session->setFlash('error', Html::errorSummary($userModel));
         return false;
     }
 }
开发者ID:ConnectedCommunities,项目名称:humhub-modules-bulk_import,代码行数:48,代码来源:MainController.php

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

示例10: getUrlBySpaceGuid

 /**
  * Gets space url name by given guid
  * 
  * @param string $guid
  * @return string|null the space url part
  */
 public static function getUrlBySpaceGuid($guid)
 {
     if (isset(static::$spaceUrlMap[$guid])) {
         return static::$spaceUrlMap[$guid];
     }
     $space = Space::findOne(['guid' => $guid]);
     if ($space !== null) {
         static::$spaceUrlMap[$space->guid] = $space->url != '' ? $space->url : $space->guid;
         return static::$spaceUrlMap[$space->guid];
     }
     return null;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:18,代码来源:UrlRule.php

示例11: testGetFollowers

 public function testGetFollowers()
 {
     Yii::$app->user->switchIdentity(User::findOne(['id' => 1]));
     $space = Space::findOne(['id' => 3]);
     $space->follow(1);
     $space->follow(2);
     $space->follow(3);
     $users = $space->getFollowers();
     $userIds = array_map(create_function('$user', 'return $user->id;'), $users);
     sort($userIds);
     $this->assertEquals(array(1, 2, 3), $userIds);
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:12,代码来源:FollowableTest.php

示例12: actionSpaces

 /**
  * Space Section of directory
  *
  * Provides a list of all visible spaces.
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionSpaces()
 {
     $keyword = Yii::$app->request->get('keyword', "");
     $page = (int) Yii::$app->request->get('page', 1);
     $searchResultSet = Yii::$app->search->find($keyword, ['model' => \humhub\modules\space\models\Space::className(), 'page' => $page, 'sortField' => $keyword == '' ? 'title' : null, '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\NewSpaces::className(), [], ['sortOrder' => 10]);
         $event->sender->addWidget(\humhub\modules\directory\widgets\SpaceStatistics::className(), [], ['sortOrder' => 20]);
     });
     return $this->render('spaces', array('keyword' => $keyword, 'spaces' => $searchResultSet->getResultInstances(), 'pagination' => $pagination));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:19,代码来源:DirectoryController.php

示例13: testAutoAddSpace

 /**
  * Tests spaces which automatically adds new members
  * Fixture Space 3
  */
 public function testAutoAddSpace()
 {
     $space2 = Space::findOne(['id' => 2]);
     $space3 = Space::findOne(['id' => 3]);
     $user = new User();
     $user->username = "TestSpaceAutoAdd";
     $user->email = "testautoadd@example.com";
     $this->assertTrue($user->save());
     $this->assertFalse($space2->isMember($user->id));
     // not assigned
     $this->assertTrue($space3->isMember($user->id));
     // via global assign
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:17,代码来源:UserTest.php

示例14: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $query = Space::find();
     /**
      * Show private spaces only if user is member
      */
     $query->leftJoin('space_membership', 'space.id=space_membership.space_id AND space_membership.user_id=:userId', [':userId' => \Yii::$app->user->id]);
     $query->andWhere(['!=', 'space.visibility', Space::VISIBILITY_NONE]);
     $query->orWhere(['space_membership.status' => Membership::STATUS_MEMBER]);
     $query->limit(10);
     $query->orderBy('created_at DESC');
     return $this->render('newSpaces', array('newSpaces' => $query->all(), 'showMoreButton' => $this->showMoreButton));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:16,代码来源:NewSpaces.php

示例15: init

 public function init()
 {
     $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Members'), 'url' => $this->space->createUrl('/space/manage/member/index'), 'sortOrder' => 100, 'isActive' => Yii::$app->controller->action->id == 'index' && Yii::$app->controller->id === 'member'));
     $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Invites'), 'url' => $this->space->createUrl('/space/manage/member/pending-invitations'), 'sortOrder' => 200, 'isActive' => Yii::$app->controller->action->id == 'pending-invitations'));
     $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Approvals'), 'url' => $this->space->createUrl('/space/manage/member/pending-approvals'), 'sortOrder' => 300, 'isActive' => Yii::$app->controller->action->id == 'pending-approvals'));
     $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Permissions'), 'url' => $this->space->createUrl('/space/manage/member/permissions'), 'sortOrder' => 400, 'isActive' => Yii::$app->controller->action->id == 'permissions'));
     if ($this->space->isSpaceOwner()) {
         $this->addItem(array('label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Owner'), 'url' => $this->space->createUrl('/space/manage/member/change-owner'), 'sortOrder' => 500, 'isActive' => Yii::$app->controller->action->id == 'change-owner'));
     }
     parent::init();
 }
开发者ID:weison-tech,项目名称:humhub,代码行数:11,代码来源:MemberMenu.php


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