-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #962 from nextcloud/feat/noid/context-sharing
feat(Context): add share logic for contexts
- Loading branch information
Showing
25 changed files
with
1,064 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Tables\Db; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
/** | ||
* @method getShareId(): int | ||
* @method setShareId(int $value): void | ||
* @method getUserId(): string | ||
* @method setUserId(string $value): void | ||
* @method getDisplayMode(): int | ||
* @method setDisplayMode(int $value): void | ||
*/ | ||
class ContextNavigation extends Entity implements \JsonSerializable { | ||
protected ?int $shareId = null; | ||
protected ?string $userId = null; | ||
protected ?int $displayMode = null; | ||
|
||
public function __construct() { | ||
$this->addType('shareId', 'integer'); | ||
$this->addType('displayMode', 'integer'); | ||
} | ||
|
||
public function jsonSerialize(): array { | ||
return [ | ||
'id' => $this->getId(), | ||
'shareId' => $this->getShareId(), | ||
'displayMode' => $this->getDisplayMode(), | ||
'userId' => $this->getUserId(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Tables\Db; | ||
|
||
use OCP\AppFramework\Db\QBMapper; | ||
use OCP\DB\Exception; | ||
use OCP\DB\QueryBuilder\IQueryBuilder; | ||
use OCP\IDBConnection; | ||
|
||
/** @template-extends QBMapper<ContextNavigation> */ | ||
class ContextNavigationMapper extends QBMapper { | ||
protected string $table = 'tables_contexts_navigation'; | ||
|
||
public function __construct(IDBConnection $db) { | ||
parent::__construct($db, $this->table, ContextNavigation::class); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function deleteByShareId(int $shareId): int { | ||
$qb = $this->db->getQueryBuilder(); | ||
$qb->delete($this->table) | ||
->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId, IQueryBuilder::PARAM_INT))); | ||
return $qb->executeStatement(); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function setDisplayModeByShareId(int $shareId, int $displayMode, string $userId): ContextNavigation { | ||
$entity = new ContextNavigation(); | ||
$entity->setShareId($shareId); | ||
$entity->setDisplayMode($displayMode); | ||
$entity->setUserId($userId); | ||
|
||
return $this->insertOrUpdate($entity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.