Create a public new room with guest access on.

@param string $name
@param integer $owner_user_id
@return stdClass
350579
public function createRoom($name, $owner_user_id = null)
    {
        $i = 1;
        $room_name = $name;

        $owner_user_id = $owner_user_id ?: $this->config->get(
            'hipsupport::config.owner_user_id'
        );

        // Make sure that a room doesn't already exist with this name.
        // If one does exist, add a number to the end of the name.
        while ($this->hipchat->room_exists($room_name)) {
            $room_name = $name . ' ' . $i++;
        }

        // Create room.
        $room = $this->hipchat->create_room(
            $room_name,
            $owner_user_id,
            null,
            null,
            true
        );

        return $room->room;
    }
888427
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON,
        $copyPages = true
    ) {
        /** @var static $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        // if no id, then it has not been save and can be returned
        if (empty($new->siteId)) {
            return $new;
        }

        $new->siteId = null;
        $new->domain = null;

        if ($copyPages) {
            /* Get Cloned Pages */
            $pages = $new->getPages();

            $clonedPages = [];

            /** @var \Rcm\Entity\Page $page */
            foreach ($pages as $page) {
                $pageType = $page->getPageType();

                // Only clone if is supported
                if (!isset($new->supportedPageTypes[$pageType])) {
                    continue;
                }
                // Only clone if is cloneable
                if (!$new->supportedPageTypes[$pageType]['canClone']) {
                    continue;
                }

                $clonedPage = $page->newInstanceIfHasRevision(
                    $createdByUserId,
                    $createdReason
                );

                if (!$clonedPage) {
                    continue;
                }

                $clonedPage->setSite($new);

                $clonedPages[] = $clonedPage;
            }

            $new->pages = new ArrayCollection($clonedPages);
        }

        /* Get Cloned Containers */
        $containers = $this->getContainers();
        $clonedContainers = [];

        /** @var \Rcm\Entity\Container $container */
        foreach ($containers as $container) {
            $clonedContainer = $container->newInstanceIfHasRevision(
                $createdByUserId,
                $createdReason
            );

            if (!$clonedContainer) {
                continue;
            }

            $clonedContainer->setSite($new);

            $clonedContainers[] = $clonedContainer;
        }

        $new->containers = new ArrayCollection($clonedContainers);

        return $new;
    }
26000
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator)
    {
        $this->user          = $user;
        $this->tenantOwner   = $owner;
        $this->tenantCreator = $creator;

        return $this;
    }
1048127
public function add($owner, $repo, $user)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo . '/collaborators/' . $user;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}
765729
public function createAction($workspaceName, Workspace $baseWorkspace, $ownerAccountIdentifier = null)
    {
        $existingWorkspace = $this->workspaceRepository->findByIdentifier($workspaceName);
        if ($existingWorkspace !== null) {
            $this->throwStatus(409, 'Workspace already exists', '');
        }

        if ($ownerAccountIdentifier !== null) {
            $owner = $this->userService->getUser($ownerAccountIdentifier);
            if ($owner === null) {
                $this->throwStatus(422, 'Requested owner account does not exist', '');
            }
        } else {
            $owner = null;
        }

        $workspace = new Workspace($workspaceName, $baseWorkspace, $owner);
        $this->workspaceRepository->add($workspace);
        $this->throwStatus(201, 'Workspace created', '');
    }
976419
public static function find($owner, $ownerId = null)
    {
        // get class
        if ($owner instanceof Pluf_Model) { // Pluf module
            $ownerClass = $owner->getClass();
            $ownerId = $owner->getId();
        } elseif (! is_null($owner)) { // module
            $ownerClass = $owner;
        }

        // get list
        $receipt = new Bank_Receipt();
        $q = new Pluf_SQL('owner_class=%s AND owner_id=%s', array(
            $ownerClass,
            $ownerId
        ));
        $list = $receipt->getList(array(
            'filter' => $q->gen()
        ));
        return $list;
    }
591388
static function construct($name, $id, $aliases = [])
  {
    $user = new NyaaUser();
    $user->name = $name;
    $user->id = $id;
    $user->aliases = $aliases;

    return $user;
  }
1235841
public function lock($name, $seconds = 0, $owner = null)
    {
        return new DynamoDbLock($this, $this->prefix.$name, $seconds, $owner);
    }
566843
public function designAction($owner, $ownerId)
    {
        /** @var BlockManager $blockManager */
        $blockManager = $this->get('opifer.content.block_manager');
        $manager = $this->get('opifer.content.content_manager');

        /** @var AbstractDesignSuite $suite */
        $suite = $this->get(sprintf('opifer.content.%s_design_suite', $owner));
        $suite->load($ownerId);

        $content = $manager->getRepository()->find($ownerId);

        $parameters = [
            'manager' => $blockManager,
            'toolset' => $blockManager->getToolset(),
            'id' => $suite->getSubject()->getId(),
            'owner' => $owner,
            'title' => $suite->getTitle(),
            'caption' => $suite->getCaption(),
            'permalink' => $suite->getPermalink(),
            'defaultDomain' => (($content && $content->getSite()) ? $content->getSite()->getDefaultDomain() : null),
            'url_properties' => $suite->getPropertiesUrl(),
            'url_cancel' => $suite->getCancelUrl(),
            'url' => $suite->getCanvasUrl(),
        ];

        return $this->render($this->getParameter('opifer_content.content_design_view'), $parameters);
    }
395191
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        $new = clone($this);

        $new->setCreatedByUserId(
            $createdByUserId,
            $createdReason
        );

        return $new;
    }
502210
def _get_public_room(self, room_name, invitees: List[User]):
        
        room_name_full = f'#{room_name}:{self._server_name}'
        invitees_uids = [user.user_id for user in invitees]

        for _ in range(JOIN_RETRIES):
            # try joining room
            try:
                room = self._client.join_room(room_name_full)
            except MatrixRequestError as error:
                if error.code == 404:
                    self.log.debug(
                        f'No room for peer, trying to create',
                        room_name=room_name_full,
                        error=error,
                    )
                else:
                    self.log.debug(
                        f'Error joining room',
                        room_name=room_name,
                        error=error.content,
                        error_code=error.code,
                    )
            else:
                # Invite users to existing room
                member_ids = {user.user_id for user in room.get_joined_members(force_resync=True)}
                users_to_invite = set(invitees_uids) - member_ids
                self.log.debug('Inviting users', room=room, invitee_ids=users_to_invite)
                for invitee_id in users_to_invite:
                    room.invite_user(invitee_id)
                self.log.debug('Room joined successfully', room=room)
                break

            # if can't, try creating it
            try:
                room = self._client.create_room(
                    room_name,
                    invitees=invitees_uids,
                    is_public=True,
                )
            except MatrixRequestError as error:
                if error.code == 409:
                    msg = (
                        'Error creating room, '
                        'seems to have been created by peer meanwhile, retrying.'
                    )
                else:
                    msg = 'Error creating room, retrying.'

                self.log.debug(
                    msg,
                    room_name=room_name,
                    error=error.content,
                    error_code=error.code,
                )
            else:
                self.log.debug('Room created successfully', room=room, invitees=invitees)
                break
        else:
            # if can't join nor create, create an unnamed one
            room = self._client.create_room(
                None,
                invitees=invitees_uids,
                is_public=True,
            )
            self.log.warning(
                'Could not create nor join a named room. Successfuly created an unnamed one',
                room=room,
                invitees=invitees,
            )

        return room
1219058
protected function createKey($attributes, $user_id)
    {
        $model = new UserOauthKey;
        $model->provider_id = $attributes['provider_id'];
        $model->provider_user_id = (string) $attributes['provider_user_id'];
        $model->page = (string) $attributes['page'];
        $model->user_id = $user_id;
        return $model->save();
    }
1189638
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var static $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        // if no id, then it has not been save and can be returned
        if (empty($new->containerId)) {
            return $new;
        }

        $new->containerId = null;

        return $new;
    }
237745
function new_instance()
	{
		if(!($tab = $this->table_name()))
			bors_throw("Try to get new db instance with undefined table");

		if(!$this->create_time(true))
			$this->set_create_time(time());

		if(!$this->modify_time(true))
			$this->set_modify_time(time());

//		$this->set_owner_id(bors()->user_id());
		$this->set_last_editor_id(bors()->user_id());

		$this->storage()->create($this);
	}
298551
public static function createDatabase($name, $encoding = null, $owner = null)
    {
        $query = static::getQuery();

        return static::build(
            'CREATE DATABASE',
            $query->quoteName($name),
            $encoding ? 'ENCODING ' . $query->quote($encoding) : null,
            $owner ? 'OWNER ' . $query->quoteName($owner) : null
        );
    }
76479
private function menuBranch($owner = 0, $level = 0)
    {
        $result = array(array(), array());
        $items = Eresus_CMS::getLegacyKernel()->db->select('pages',
            "(`access` >= '" . USER . "') AND (`owner` = '" . $owner . "') AND (`active` = '1')",
            "-position", "`id`,`caption`");
        if (count($items))
        {
            foreach ($items as $item)
            {
                $result[0][] = str_repeat('- ', $level) . $item['caption'];
                $result[1][] = $item['id'];
                $sub = $this->menuBranch($item['id'], $level + 1);
                if (count($sub[0]))
                {
                    $result[0] = array_merge($result[0], $sub[0]);
                    $result[1] = array_merge($result[1], $sub[1]);
                }
            }
        }
        return $result;
    }
342695
private function updateAttendees(string $owner_type, int $owner_id)
    {

        CharacterCalendarEventDetail::where('owner_id', $owner_id)
            ->where('owner_type', $owner_type)
            ->get()->each(function ($event) {

                $attendees = $this->retrieve([
                    'character_id' => $this->getCharacterId(),
                    'event_id'     => $event->event_id,
                ]);

                if ($attendees->isCachedLoad()) return;

                collect($attendees)->each(function ($attendee) use ($event) {

                    CharacterCalendarAttendee::firstOrNew([
                        'character_id' => $attendee->character_id,
                        'event_id'     => $event->event_id,
                    ])->fill([
                        'event_response' => $attendee->event_response,
                    ])->save();

                });

                CharacterCalendarAttendee::where('event_id', $event->event_id)
                    ->whereNotIn('character_id', collect($attendees)
                        ->pluck('character_id')->flatten()->all())
                    ->delete();
            });
    }