本文整理汇总了PHP中humhub\modules\space\models\Space::className方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::className方法的具体用法?PHP Space::className怎么用?PHP Space::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\space\models\Space
的用法示例。
在下文中一共展示了Space::className方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()]);
}
}
示例2: 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));
}
示例3: 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));
}
示例4: getAvailableModules
/**
* Collects a list of all modules which are available for this space
*
* @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(Space::className())) {
$this->_availableModules[$module->id] = $module;
}
}
return $this->_availableModules;
}
示例5: up
public function up()
{
$this->renameClass('Activity', Activity::className());
// Space Created Activity - object_model/object_id (source fix)
$activities = (new \yii\db\Query())->select("activity.*, content.space_id")->from('activity')->leftJoin('content', 'content.object_model=:activityModel AND content.object_id=activity.id', [':activityModel' => Activity::className()])->where(['class' => 'humhub\\modules\\space\\activities\\Created', 'activity.object_model' => ''])->all();
foreach ($activities as $activity) {
$this->updateSilent('activity', ['object_model' => Space::className(), 'object_id' => $activity['space_id']], ['id' => $activity['id']]);
}
// Space Member added Activity - object_model/object_id (source fix)
$activities = (new \yii\db\Query())->select("activity.*, content.space_id")->from('activity')->leftJoin('content', 'content.object_model=:activityModel AND content.object_id=activity.id', [':activityModel' => Activity::className()])->where(['class' => 'humhub\\modules\\space\\activities\\MemberAdded', 'activity.object_model' => ''])->all();
foreach ($activities as $activity) {
$this->updateSilent('activity', ['object_model' => Space::className(), 'object_id' => $activity['space_id']], ['id' => $activity['id']]);
}
// Space Member removed Activity - object_model/object_id (source fix)
$activities = (new \yii\db\Query())->select("activity.*, content.space_id")->from('activity')->leftJoin('content', 'content.object_model=:activityModel AND content.object_id=activity.id', [':activityModel' => Activity::className()])->where(['class' => 'humhub\\modules\\space\\activities\\MemberRemoved', 'activity.object_model' => ''])->all();
foreach ($activities as $activity) {
$this->updateSilent('activity', ['object_model' => Space::className(), 'object_id' => $activity['space_id']], ['id' => $activity['id']]);
}
}
示例6: actionSearchJson
/**
* Returns a workspace list by json
*
* It can be filtered by by keyword.
*/
public function actionSearchJson()
{
\Yii::$app->response->format = 'json';
$keyword = Yii::$app->request->get('keyword', "");
$page = (int) Yii::$app->request->get('page', 1);
$limit = (int) Yii::$app->request->get('limit', \humhub\models\Setting::Get('paginationSize'));
$searchResultSet = Yii::$app->search->find($keyword, ['model' => \humhub\modules\space\models\Space::className(), 'page' => $page, 'pageSize' => $limit]);
$json = array();
foreach ($searchResultSet->getResultInstances() as $space) {
$spaceInfo = array();
$spaceInfo['guid'] = $space->guid;
$spaceInfo['title'] = Html::encode($space->name);
$spaceInfo['tags'] = Html::encode($space->tags);
$spaceInfo['image'] = Image::widget(['space' => $space, 'width' => 24]);
$spaceInfo['link'] = $space->getUrl();
$json[] = $spaceInfo;
}
return $json;
}
示例7: 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');
}
示例8: count
<div class="pull-left entry">
<span class="count"><?php
echo $user->getFollowerCount();
?>
</span></a>
<br>
<span class="title"><?php
echo Yii::t('UserModule.widgets_views_profileHeader', 'Followers');
?>
</span>
</div>
<div class="pull-left entry">
<span class="count"><?php
echo $user->getFollowingCount(User::className()) + $user->getFollowingCount(Space::className());
?>
</span>
<br>
<span class="title"><?php
echo Yii::t('UserModule.widgets_views_profileHeader', 'Following');
?>
</span>
</div>
<div class="pull-left entry">
<span class="count"><?php
echo count($user->spaces);
?>
</span><br>
<span class="title"><?php
示例9: getSpace
public function getSpace()
{
return $this->hasOne(\humhub\modules\space\models\Space::className(), ['id' => 'space_id']);
}
示例10: validateVisibility
public function validateVisibility()
{
if ($this->object_model == Activity::className() || $this->getPolymorphicRelation()->className() == Activity::className()) {
return;
}
if ($this->container->className() == Space::className()) {
if (!$this->container->canShare() && $this->visibility) {
$this->addError('visibility', Yii::t('base', 'You cannot create public visible content!'));
}
}
}
示例11: create
/**
* Creates the given ContentActiveRecord based on given submitted form information.
*
* - Automatically assigns ContentContainer
* - Access Check
* - User Notification / File Uploads
* - Reloads Wall after successfull creation or returns error json
*
* [See guide section](guide:dev-module-stream.md#CreateContentForm)
*
* @param ContentActiveRecord $record
* @return string json
*/
public static function create(ContentActiveRecord $record)
{
Yii::$app->response->format = 'json';
// Set Content Container
$contentContainer = null;
$containerClass = Yii::$app->request->post('containerClass');
$containerGuid = Yii::$app->request->post('containerGuid', "");
if ($containerClass === User::className()) {
$contentContainer = User::findOne(['guid' => $containerGuid]);
$record->content->visibility = 1;
} elseif ($containerClass === Space::className()) {
$contentContainer = Space::findOne(['guid' => $containerGuid]);
$record->content->visibility = Yii::$app->request->post('visibility');
}
$record->content->container = $contentContainer;
// Handle Notify User Features of ContentFormWidget
// ToDo: Check permissions of user guids
$userGuids = Yii::$app->request->post('notifyUserInput');
if ($userGuids != "") {
foreach (explode(",", $userGuids) as $guid) {
$user = User::findOne(['guid' => trim($guid)]);
if ($user) {
$record->content->notifyUsersOfNewContent[] = $user;
}
}
}
// Store List of attached Files to add them after Save
$record->content->attachFileGuidsAfterSave = Yii::$app->request->post('fileList');
if ($record->validate() && $record->save()) {
return array('wallEntryId' => $record->content->getFirstWallEntryId());
}
return array('errors' => $record->getErrors());
}
示例12: getSpace
public function getSpace()
{
return $this->hasOne(Space::className(), ['id' => 'space_id']);
}
示例13: up
public function up()
{
$this->renameClass('Space', Space::className());
}
示例14: array
$form = humhub\compat\CActiveForm::begin();
?>
<div class="modal-body">
<p>
<?php
echo Yii::t('AdminModule.views_module_setAsDefault', 'Here you can choose whether or not a module should be automatically activated on a space or user profile. If the module should be activated, choose "always activated".');
?>
</p>
<br/>
<div class="row">
<?php
if ($module->hasContentContainerType(Space::className())) {
?>
<div class="col-md-6">
<label for=""><?php
echo Yii::t('AdminModule.views_module_setAsDefault', 'Spaces');
?>
</label>
<div class="radio">
<label>
<?php
echo $form->radioButton($model, 'spaceDefaultState', array('value' => 0, 'uncheckValue' => null, 'id' => 'radioSpaceDeactivated', 'checked' => $model->spaceDefaultState == 0));
?>
<?php
echo Yii::t('AdminModule.views_module_setAsDefault', 'Deactivated');
?>
示例15: getContentContainerTypes
/**
* @inheritdoc
*/
public function getContentContainerTypes()
{
return [Space::className(), User::className()];
}