本文整理汇总了PHP中humhub\modules\space\models\Space::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::find方法的具体用法?PHP Space::find怎么用?PHP Space::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\space\models\Space
的用法示例。
在下文中一共展示了Space::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
}
}
}
示例2: 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();
}
}
}
}
示例3: 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));
}
示例4: 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));
}
示例5: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Space::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
$dataProvider->setSort(['attributes' => ['id', 'name', 'visibility', 'join_policy']]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['join_policy' => $this->join_policy]);
$query->andFilterWhere(['visibility' => $this->visibility]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例6: parseRequest
/**
* @inheritdoc
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
if (substr($pathInfo, 0, 2) == "s/") {
$parts = explode('/', $pathInfo, 3);
if (isset($parts[1])) {
$space = Space::find()->where(['guid' => $parts[1]])->orWhere(['url' => $parts[1]])->one();
if ($space !== null) {
if (!isset($parts[2]) || $parts[2] == "") {
$parts[2] = $this->defaultRoute;
}
$params = $request->get();
$params['sguid'] = $space->guid;
return [$parts[2], $params];
}
}
}
return false;
}
示例7: actionInvite
/**
* Invite user
*/
public function actionInvite($space = null)
{
$space = $space == null ? Space::find()->where(['id' => Yii::$app->request->get('spaceId', "")])->one() : $space;
$model = new \humhub\modules\space\models\forms\InviteForm();
$model->space = $space;
$canInviteExternal = Yii::$app->getModule('user')->settings->get('auth.internalUsersCanInvite');
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
// Invite existing members
foreach ($model->getInvites() as $user) {
$space->inviteMember($user->id, Yii::$app->user->id);
}
// Invite non existing members
if ($canInviteExternal) {
foreach ($model->getInvitesExternal() as $email) {
$space->inviteMemberByEMail($email, Yii::$app->user->id);
}
}
return $this->htmlRedirect($space->getUrl());
}
return $this->renderAjax('invite', ['canInviteExternal' => $canInviteExternal, 'model' => $model, 'space' => $space]);
}
示例8: onSampleDataInstall
/**
* Create installer sample data
*
* @param \yii\base\Event $event
*/
public static function onSampleDataInstall($event)
{
$space = Space::find()->where(['id' => 1])->one();
// activate module at space
if (!$space->isModuleEnabled("polls")) {
$space->enableModule("polls");
}
// Switch Identity
$user = User::find()->where(['id' => 1])->one();
Yii::$app->user->switchIdentity($user);
$poll = new Poll();
$poll->question = Yii::t('PollsModule.events', "Right now, we are in the planning stages for our next meetup and we would like to know from you, where you would like to go?");
$poll->answersText = Yii::t('PollsModule.events', "To Daniel\nClub A Steakhouse\nPisillo Italian Panini\n");
$poll->content->container = $space;
$poll->allow_multiple = Yii::$app->request->post('allowMultiple', 0);
$poll->save();
// load users
$user2 = User::find()->where(['id' => 2])->one();
$user3 = User::find()->where(['id' => 3])->one();
// Switch Identity
Yii::$app->user->switchIdentity($user2);
// vote
$poll->vote([2]);
$comment = new \humhub\modules\comment\models\Comment();
$comment->message = Yii::t('PollsModule.events', "Why don't we go to Bemelmans Bar?");
$comment->object_model = $poll->className();
$comment->object_id = $poll->getPrimaryKey();
$comment->save();
// Switch Identity
Yii::$app->user->switchIdentity($user3);
// vote
$poll->vote([3]);
$comment = new \humhub\modules\comment\models\Comment();
$comment->message = Yii::t('PollsModule.events', "Again? ;Weary;");
$comment->object_model = $poll->className();
$comment->object_id = $poll->getPrimaryKey();
$comment->save();
// Switch Identity
Yii::$app->user->switchIdentity($user);
}
示例9: autogenerateUniqueSpaceUrl
/**
* Generate a unique space url
*
* @param string $name
* @return string a unique space url
*/
public static function autogenerateUniqueSpaceUrl($name)
{
$maxUrlLength = 45;
$url = URLify::filter($name, $maxUrlLength - 4);
// Get a list of all similar space urls
$existingSpaceUrls = [];
foreach (Space::find()->where(['LIKE', 'url', $url . '%', false])->all() as $space) {
$existingSpaceUrls[] = $space->url;
}
// Url is free
if (!in_array($url, $existingSpaceUrls)) {
return $url;
}
// Add number to taken url
for ($i = 0; $i <= count($existingSpaceUrls); $i++) {
$tryUrl = $url . ($i + 2);
if (!in_array($tryUrl, $existingSpaceUrls)) {
return $tryUrl;
}
}
// Shouldn't never happen - failed
return "";
}
示例10: buildQuery
protected function buildQuery($keyword, $options)
{
// Allow *Token*
\ZendSearch\Lucene\Search\Query\Wildcard::setMinPrefixLength(0);
$query = new \ZendSearch\Lucene\Search\Query\Boolean();
foreach (explode(" ", $keyword) as $k) {
// Require at least 3 non-wildcard characters
if (strlen($k) > 2) {
$term = new \ZendSearch\Lucene\Index\Term("*" . $k . "*");
$query->addSubquery(new \ZendSearch\Lucene\Search\Query\Wildcard($term), true);
}
}
// Add model filter
if (isset($options['model']) && $options['model'] != "") {
if (is_array($options['model'])) {
$boolQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm();
foreach ($options['model'] as $model) {
$boolQuery->addTerm(new \ZendSearch\Lucene\Index\Term($model, 'model'));
}
$query->addSubquery($boolQuery, true);
} else {
$term = new \ZendSearch\Lucene\Index\Term($options['model'], 'model');
$query->addSubquery(new \ZendSearch\Lucene\Search\Query\Term($term), true);
}
}
// Add type filter
if (isset($options['type']) && $options['type'] != "") {
if (is_array($options['type'])) {
$boolQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm();
foreach ($options['type'] as $model) {
$boolQuery->addTerm(new \ZendSearch\Lucene\Index\Term($type), 'type');
}
$query->addSubquery($boolQuery, true);
} else {
$term = new \ZendSearch\Lucene\Index\Term($options['type'], 'type');
$query->addSubquery(new \ZendSearch\Lucene\Search\Query\Term($term), true);
}
}
// Add custom filters
if (isset($options['filters']) && is_array($options['filters'])) {
foreach ($options['filters'] as $field => $value) {
$term = new \ZendSearch\Lucene\Index\Term($value, $field);
$query->addSubquery(new \ZendSearch\Lucene\Search\Query\Term($term), true);
}
}
if ($options['checkPermissions'] && !Yii::$app->request->isConsoleRequest) {
$permissionQuery = new \ZendSearch\Lucene\Search\Query\Boolean();
if (Yii::$app->user->isGuest) {
// Guest Content
$guestContentQuery = new \ZendSearch\Lucene\Search\Query\Boolean();
$guestContentQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_VISIBILITY_PUBLIC, 'visibility')), true);
$guestContentQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_TYPE_CONTENT, 'type')), true);
$guestContentQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(Space::className(), 'containerModel')), true);
$guestSpaceListQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm();
foreach (Space::find()->where(['visibility' => Space::VISIBILITY_ALL])->all() as $space) {
$guestSpaceListQuery->addTerm(new \ZendSearch\Lucene\Index\Term($space->id, 'containerPk'));
}
$guestContentQuery->addSubquery($guestSpaceListQuery, true);
$permissionQuery->addSubquery($guestContentQuery);
// Guest Spaces
$guestSpacesQuery = new \ZendSearch\Lucene\Search\Query\Boolean();
$guestSpacesQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_TYPE_SPACE, 'type')), true);
$guestSpacesQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_VISIBILITY_PUBLIC, 'visibility')), true);
$permissionQuery->addSubquery($guestSpacesQuery);
$permissionQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_TYPE_USER, 'type')));
} else {
//--- Public Content
$permissionQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_VISIBILITY_PUBLIC, 'visibility')));
//--- Private Space Content
$privateSpaceContentQuery = new \ZendSearch\Lucene\Search\Query\Boolean();
$privateSpaceContentQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(self::DOCUMENT_VISIBILITY_PRIVATE, 'visibility')), true);
$privateSpaceContentQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(Space::className(), 'containerModel')), true);
$privateSpacesListQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm();
foreach (\humhub\modules\space\models\Membership::GetUserSpaces() as $space) {
$privateSpacesListQuery->addTerm(new \ZendSearch\Lucene\Index\Term($space->id, 'containerPk'));
}
$privateSpaceContentQuery->addSubquery($privateSpacesListQuery, true);
$permissionQuery->addSubquery($privateSpaceContentQuery);
}
$query->addSubquery($permissionQuery, true);
}
if (count($options['limitSpaces']) > 0) {
$spaceBaseQuery = new \ZendSearch\Lucene\Search\Query\Boolean();
$spaceBaseQuery->addSubquery(new \ZendSearch\Lucene\Search\Query\Term(new \ZendSearch\Lucene\Index\Term(Space::className(), 'containerModel')), true);
$spaceIdQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm();
foreach ($options['limitSpaces'] as $space) {
$spaceIdQuery->addTerm(new \ZendSearch\Lucene\Index\Term($space->id, 'containerPk'));
}
$spaceBaseQuery->addSubquery($spaceIdQuery, true);
$query->addSubquery($spaceBaseQuery, true);
}
return $query;
}
示例11: actionCancel
/**
* Cancel Space creation
*/
public function actionCancel()
{
$space = Space::find()->where(['id' => Yii::$app->request->get('spaceId', "")])->one();
$space->delete();
}
示例12: handleLdapUser
/**
* Updates or creates user by given ldap node
*
* @param Zend_Ldap_Node $node
* @return User User Object
*/
public function handleLdapUser($node)
{
$usernameAttribute = Setting::Get('usernameAttribute', 'authentication_ldap');
if ($usernameAttribute == '') {
$usernameAttribute = 'sAMAccountName';
}
$emailAttribute = Setting::Get('emailAttribute', 'authentication_ldap');
if ($emailAttribute == '') {
$emailAttribute = 'mail';
}
$username = $node->getAttribute($usernameAttribute, 0);
$email = $node->getAttribute($emailAttribute, 0);
$guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
// Try to load User:
$userChanged = false;
$user = null;
if ($guid != "") {
$user = User::findOne(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
} else {
// Fallback use e-mail
$user = User::findOne(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
}
if ($user === null) {
$user = new User();
if ($guid != "") {
$user->guid = $guid;
}
$user->status = User::STATUS_ENABLED;
$user->auth_mode = User::AUTH_MODE_LDAP;
$user->group_id = 1;
Yii::info('Create ldap user ' . $username . '!');
}
// Update Group Mapping
foreach (Group::find()->andWhere(['!=', 'ldap_dn', ""])->all() as $group) {
if (in_array($group->ldap_dn, $node->getAttribute('memberOf'))) {
if ($user->group_id != $group->id) {
$userChanged = true;
$user->group_id = $group->id;
}
}
}
// Update Users Field
if ($user->username != $username) {
$userChanged = true;
$user->username = $username;
}
if ($user->email != $email) {
$userChanged = true;
$user->email = $email;
}
if ($user->validate()) {
// Only Save user when something is changed
if ($userChanged || $user->isNewRecord) {
$user->save();
}
// Update Profile Fields
foreach (ProfileField::find()->andWhere(['!=', 'ldap_attribute', ''])->all() as $profileField) {
$ldapAttribute = $profileField->ldap_attribute;
$profileFieldName = $profileField->internal_name;
$user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
}
if ($user->profile->validate()) {
$user->profile->save();
// Update Space Mapping
foreach (Space::find()->andWhere(['!=', 'ldap_dn', ''])->all() as $space) {
if (in_array($space->ldap_dn, $node->getAttribute('memberOf')) || strpos($node->getDn(), $space->ldap_dn) !== false) {
$space->addMember($user->id);
}
}
} else {
Yii::error('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")");
}
} else {
Yii::error('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")");
}
return $user;
}
示例13: actionSampleData
/**
* Sample Data
*/
public function actionSampleData()
{
if (Yii::$app->getModule('installer')->settings->get('sampleData') == 1) {
// Sample Data already created
return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
}
$form = new \humhub\modules\installer\forms\SampleDataForm();
$form->sampleData = 1;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
Yii::$app->getModule('installer')->settings->set('sampleData', $form->sampleData);
if (Yii::$app->getModule('installer')->settings->get('sampleData') == 1) {
// Add sample image to admin
$admin = User::find()->where(['id' => 1])->one();
$adminImage = new \humhub\libs\ProfileImage($admin->guid);
$adminImage->setNew(Yii::getAlias("@webroot/resources/installer/user_male_1.jpg"));
// Create second user
$userModel = new User();
$userModel->scenario = 'registration';
$profileModel = $userModel->profile;
$profileModel->scenario = 'registration';
$userModel->status = User::STATUS_ENABLED;
$userModel->username = "david1986";
$userModel->email = "david.roberts@example.com";
$userModel->language = '';
$userModel->tags = "Microsoft Office, Marketing, SEM, Digital Native";
$userModel->last_activity_email = new \yii\db\Expression('NOW()');
$userModel->save();
$profileImage = new \humhub\libs\ProfileImage($userModel->guid);
$profileImage->setNew(Yii::getAlias("@webroot/resources/installer/user_male_2.jpg"));
$profileModel->user_id = $userModel->id;
$profileModel->firstname = "David";
$profileModel->lastname = "Roberts";
$profileModel->title = "Late riser";
$profileModel->street = "2443 Queens Lane";
$profileModel->zip = "24574";
$profileModel->city = "Allwood";
$profileModel->country = "Virginia";
$profileModel->save();
// Create third user
$userModel2 = new User();
$userModel2->scenario = 'registration';
$profileModel2 = $userModel2->profile;
$profileModel2->scenario = 'registration';
$userModel2->status = User::STATUS_ENABLED;
$userModel2->username = "sara1989";
$userModel2->email = "sara.schuster@example.com";
$userModel2->language = '';
$userModel2->tags = "Yoga, Travel, English, German, French";
$userModel2->last_activity_email = new \yii\db\Expression('NOW()');
$userModel2->save();
$profileImage2 = new \humhub\libs\ProfileImage($userModel2->guid);
$profileImage2->setNew(Yii::getAlias("@webroot/resources/installer/user_female_1.jpg"));
$profileModel2->user_id = $userModel2->id;
$profileModel2->firstname = "Sara";
$profileModel2->lastname = "Schuster";
$profileModel2->title = "Do-gooder";
$profileModel2->street = "Schmarjestrasse 51";
$profileModel2->zip = "17095";
$profileModel2->city = "Friedland";
$profileModel2->country = "Niedersachsen";
$profileModel2->save();
// Switch Identity
$user = User::find()->where(['id' => 1])->one();
Yii::$app->user->switchIdentity($user);
$space = Space::find()->where(['id' => 1])->one();
// Create a sample post
$post = new \humhub\modules\post\models\Post();
$post->message = Yii::t("InstallerModule.controllers_ConfigController", "We're looking for great slogans of famous brands. Maybe you can come up with some samples?");
$post->content->container = $space;
$post->content->visibility = \humhub\modules\content\models\Content::VISIBILITY_PRIVATE;
$post->save();
// Switch Identity
Yii::$app->user->switchIdentity($userModel);
$comment = new \humhub\modules\comment\models\Comment();
$comment->message = Yii::t("InstallerModule.controllers_ConfigController", "Nike – Just buy it. ;Wink;");
$comment->object_model = $post->className();
$comment->object_id = $post->getPrimaryKey();
$comment->save();
// Switch Identity
Yii::$app->user->switchIdentity($userModel2);
$comment2 = new \humhub\modules\comment\models\Comment();
$comment2->message = Yii::t("InstallerModule.controllers_ConfigController", "Calvin Klein – Between love and madness lies obsession.");
$comment2->object_model = $post->className();
$comment2->object_id = $post->getPrimaryKey();
$comment2->save();
// Create Like Object
$like = new \humhub\modules\like\models\Like();
$like->object_model = $comment->className();
$like->object_id = $comment->getPrimaryKey();
$like->save();
$like = new \humhub\modules\like\models\Like();
$like->object_model = $post->className();
$like->object_id = $post->getPrimaryKey();
$like->save();
// trigger install sample data event
$this->trigger(self::EVENT_INSTALL_SAMPLE_DATA);
}
//.........这里部分代码省略.........
示例14: getUserSpaceQuery
/**
* Returns Space for user space membership
*
* @since 1.0
* @param \humhub\modules\user\models\User $user
* @param boolean $memberOnly include only member status - no pending/invite states
* @return \yii\db\ActiveQuery for space model
*/
public static function getUserSpaceQuery($user, $memberOnly = true)
{
$query = Space::find();
$query->leftJoin('space_membership', 'space_membership.space_id=space.id and space_membership.user_id=:userId', [':userId' => $user->id]);
if ($memberOnly) {
$query->andWhere(['space_membership.status' => self::STATUS_MEMBER]);
}
$query->orderBy(['name' => SORT_ASC]);
return $query;
}