make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...

This commit is contained in:
Dennis Eichhorn 2023-05-06 11:42:05 +00:00
parent 27daf80740
commit 757930be9c
13 changed files with 46 additions and 46 deletions

View File

@ -150,7 +150,7 @@ final class Installer extends InstallerAbstract
/** @var \Modules\Editor\Models\EditorDocType $type */
$type = $responseData['response'];
$id = $type->getId();
$id = $type->id;
$isFirst = true;
foreach ($data['l11n'] as $l11n) {

View File

@ -280,23 +280,23 @@ final class ApiController extends Controller
$collection = null;
foreach ($uploaded as $media) {
$accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login
$accountPath = '/Accounts/' . $account->id . ' ' . $account->login
. '/Editor/'
. $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m')
. '/' . $doc->getId();
. '/' . $doc->id;
if ($collection === null) {
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
$accountPath,
$request->header->account,
__DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->getId()
__DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->id . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->id
);
}
$this->createModelRelation(
$request->header->account,
$doc->getId(),
$media->getId(),
$doc->id,
$media->id,
EditorDocMapper::class,
'media',
'',
@ -305,7 +305,7 @@ final class ApiController extends Controller
$ref = new Reference();
$ref->name = $media->name;
$ref->source = new NullMedia($media->getId());
$ref->source = new NullMedia($media->id);
$ref->createdBy = new NullAccount($request->header->account);
$ref->setVirtualPath($accountPath);
@ -313,8 +313,8 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
$collection->getId(),
$ref->getId(),
$collection->id,
$ref->id,
CollectionMapper::class,
'sources',
'',
@ -336,7 +336,7 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
$doc->getId(),
$doc->id,
(int) $media,
EditorDocMapper::class,
'media',
@ -355,8 +355,8 @@ final class ApiController extends Controller
$this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin());
$this->createModelRelation(
$request->header->account,
$collection->getId(),
$ref->getId(),
$collection->id,
$ref->id,
CollectionMapper::class,
'sources',
'',
@ -381,7 +381,7 @@ final class ApiController extends Controller
. $doc->createdAt->format('Y') . '/'
. $doc->createdAt->format('m') . '/'
. $doc->createdAt->format('d') . '/'
. $doc->getId();
. $doc->id;
}
/**
@ -586,7 +586,7 @@ final class ApiController extends Controller
foreach ($uploaded as $file) {
$this->createModelRelation(
$request->header->account,
$file->getId(),
$file->id,
$request->getDataInt('type'),
MediaMapper::class,
'types',
@ -599,7 +599,7 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
(int) $request->getData('doc'),
\reset($uploaded)->getId(),
\reset($uploaded)->id,
EditorDocMapper::class, 'media', '', $request->getOrigin()
);

View File

@ -142,9 +142,9 @@ final class BackendController extends Controller
$accountId = $request->header->account;
if ($doc->createdBy->getId() !== $accountId
if ($doc->createdBy->id !== $accountId
&& !$this->app->accountManager->get($accountId)->hasPermission(
PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId())
PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id)
) {
$view->setTemplate('/Web/Backend/Error/403_inline');
$response->header->status = RequestStatusCode::R_403;
@ -162,7 +162,7 @@ final class BackendController extends Controller
$view->addData('tagSelector', $tagSelector);
$view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission(
PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId())
PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id)
);
return $view;
@ -188,9 +188,9 @@ final class BackendController extends Controller
$doc = EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute();
$accountId = $request->header->account;
if ($doc->createdBy->getId() !== $accountId
if ($doc->createdBy->id !== $accountId
&& !$this->app->accountManager->get($accountId)->hasPermission(
PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId())
PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id)
) {
$view->setTemplate('/Web/Backend/Error/403_inline');
$response->header->status = RequestStatusCode::R_403;

View File

@ -35,7 +35,7 @@ class EditorDoc implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Version.

View File

@ -33,7 +33,7 @@ class EditorDocHistory implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Doc ID.
@ -114,7 +114,7 @@ class EditorDocHistory implements \JsonSerializable
public static function createFromDoc(EditorDoc $doc) : self
{
$hist = new self();
$hist->doc = $doc->getId();
$hist->doc = $doc->id;
$hist->createdBy = $doc->createdBy;
$hist->title = $doc->title;
$hist->plain = $doc->plain;

View File

@ -33,7 +33,7 @@ class EditorDocType implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Name.

View File

@ -17,7 +17,7 @@ use phpOMS\Uri\UriFactory;
/** @var \Modules\Editor\Models\EditorDoc $doc */
$doc = $this->getData('doc') ?? new NullEditorDoc();
$isNewDoc = $doc instanceof NullEditorDoc;
$isNewDoc = $doc->id === 0;
/** @var \phpOMS\Views\View $this */
echo $this->getData('nav')->render(); ?>

View File

@ -25,10 +25,10 @@ $collections = $this->getData('collections');
$mediaPath = \urldecode($this->getData('path') ?? '/');
$account = $this->getData('account');
$accountDir = $account->getId() . ' ' . $account->login;
$accountDir = $account->id . ' ' . $account->login;
$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->getId() . '&ptype=p';
$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->getId() . '&ptype=n';
$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->id . '&ptype=p';
$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->id . '&ptype=n';
$docs = $this->getData('docs');
@ -134,11 +134,11 @@ echo $this->getData('nav')->render(); ?>
</label>
<td><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->getId()); ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->id); ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php foreach ($docs as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/editor/single?{?}&id=' . $value->getId()); ?>
$url = UriFactory::build('{/base}/editor/single?{?}&id=' . $value->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><label class="checkbox" for="editorList-<?= $key; ?>">
<input type="checkbox" id="editorList-<?= $key; ?>" name="editorselect">
@ -146,7 +146,7 @@ echo $this->getData('nav')->render(); ?>
</label>
<td><i class="fa fa-file-o"></i>
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->getId()); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>

View File

@ -45,7 +45,7 @@ echo $this->getData('nav')->render(); ?>
</div>
<?php if ($editable) : ?>
<div class="col-xs-6 end-xs plain-grid">
<a tabindex="0" class="button" href="<?= UriFactory::build('{/base}/editor/edit?id=' . $doc->getId()); ?>"><?= $this->getHtml('Edit', '0', '0'); ?></a>
<a tabindex="0" class="button" href="<?= UriFactory::build('{/base}/editor/edit?id=' . $doc->id); ?>"><?= $this->getHtml('Edit', '0', '0'); ?></a>
</div>
<?php endif; ?>
</div>
@ -57,9 +57,9 @@ echo $this->getData('nav')->render(); ?>
<?php foreach ($files as $file) :
$url = $file->extension === 'collection'
? UriFactory::build('{/base}/media/list?path=' . \rtrim($file->getVirtualPath(), '/') . '/' . $file->name)
: UriFactory::build('{/base}/media/single?id=' . $file->getId()
: UriFactory::build('{/base}/media/single?id=' . $file->id
. '&path={?path}' . (
$file->getId() === 0
$file->id === 0
? '/' . $file->name
: ''
)

View File

@ -126,7 +126,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->module->apiEditorCreate($request, $response);
self::assertEquals('Controller Test Title', $response->get('')['response']->title);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -228,7 +228,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
self::assertEquals('Changed Title', $response->get('')['response']->title);
self::assertEquals('Changed Title', EditorDocMapper::get()->where('id', 1)->execute()->title);
self::assertEquals(1, $response->get('')['response']->getId());
self::assertEquals(1, $response->get('')['response']->id);
}
/**
@ -268,7 +268,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->module->apiEditorDelete($request, $response);
self::assertEquals($docId, $response->get('')['response']->getId());
self::assertEquals($docId, $response->get('')['response']->id);
self::assertInstanceOf(NullEditorDoc::class, EditorDocMapper::get()->where('id', $docId)->execute());
}
}

View File

@ -37,17 +37,17 @@ final class EditorDocMapperTest extends \PHPUnit\Framework\TestCase
$doc->setVirtualPath('/some/test/path');
$id = EditorDocMapper::create()->execute($doc);
self::assertGreaterThan(0, $doc->getId());
self::assertEquals($id, $doc->getId());
self::assertGreaterThan(0, $doc->id);
self::assertEquals($id, $doc->id);
$docR = EditorDocMapper::get()->where('id', $doc->getId())->execute();
$docR = EditorDocMapper::get()->where('id', $doc->id)->execute();
self::assertEquals($doc->createdAt->format('Y-m-d'), $docR->createdAt->format('Y-m-d'));
self::assertEquals($doc->createdBy->getId(), $docR->createdBy->getId());
self::assertEquals($doc->createdBy->id, $docR->createdBy->id);
self::assertEquals($doc->content, $docR->content);
self::assertEquals($doc->title, $docR->title);
self::assertEquals($doc->getVirtualPath(), $docR->getVirtualPath());
$docR2 = EditorDocMapper::getByVirtualPath('/some/test/path', 1)->execute();
self::assertEquals($docR->getId(), \reset($docR2)->getId());
self::assertEquals($docR->id, \reset($docR2)->id);
}
}

View File

@ -40,8 +40,8 @@ final class EditorDocTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->doc->getId());
self::assertEquals(0, $this->doc->createdBy->getId());
self::assertEquals(0, $this->doc->id);
self::assertEquals(0, $this->doc->createdBy->id);
self::assertEquals('', $this->doc->title);
self::assertEquals('', $this->doc->content);
self::assertEquals('', $this->doc->plain);
@ -57,7 +57,7 @@ final class EditorDocTest extends \PHPUnit\Framework\TestCase
public function testCreatedByInputOutput() : void
{
$this->doc->createdBy = new NullAccount(1);
self::assertEquals(1, $this->doc->createdBy->getId());
self::assertEquals(1, $this->doc->createdBy->id);
}
/**

View File

@ -37,6 +37,6 @@ final class NullEditorDocTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullEditorDoc(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}