Commit 94ece55d authored by Thorsten Griebenow's avatar Thorsten Griebenow

Merge branch '53-bootstraping-the-ter-admin-view' into 'develop'

Resolve "Bootstraping the TER admin view"

Closes #53

See merge request !82
parents 8f3707f0 32c618c3
Pipeline #939 canceled with stages
in 7 seconds
plugin.tx_ter_pi1 {
pid =
reviewersFrontendUsergroupUid =
adminFrontendUsergroupUid = 2
mirrorsFrontendUsergroupUid =
}
plugin.tx_ter_pi1 {
pid =
reviewersFrontendUsergroupUid =
adminFrontendUsergroupUid =
mirrorsFrontendUsergroupUid =
}
\ No newline at end of file
pid = {plugin.tx_ter_pi1.pid}
reviewersFrontendUsergroupUid = {plugin.tx_ter_pi1.reviewersFrontendUsergroupUid}
adminFrontendUsergroupUid = {plugin.tx_ter_pi1.adminFrontendUsergroupUid}
mirrorsFrontendUsergroupUid = {plugin.tx_ter_pi1.mirrorsFrontendUsergroupUid}
}
......@@ -56,6 +56,9 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository');
$this->userRepository = $this->objectManager->get(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository::class);
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
$querySettings->setRespectStoragePage(false);
$this->userRepository->setDefaultQuerySettings($querySettings);
}
/**
......@@ -68,9 +71,10 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
public function indexAction($uploaded = FALSE)
{
// get extensions by user if a user is logged in
if (!empty($this->frontendUser)) {
$extensions = $this->extensionRepository->findByFrontendUser($this->frontendUser['username']);
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($this->frontendUser['username']);
if ($GLOBALS['TSFE']->fe_user->user['uid']) {
$this->frontendUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
$extensions = $this->extensionRepository->findByFrontendUser($this->frontendUser->getUsername());
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($this->frontendUser->getUsername());
$this->view->assign('extensions', $extensions);
$this->view->assign('expiringExtensions', $expiringExtensions);
$this->view->assign('uploaded', $uploaded);
......@@ -102,7 +106,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
// Create extension model
$extension = $this->objectManager->get('Tx_TerFe2_Domain_Model_Extension');
$extension->setExtKey($extensionKey);
$extension->setFrontendUser($this->frontendUser['username']);
$extension->setFrontendUser($this->frontendUser->getUsername());
$this->extensionRepository->add($extension);
$this->addFlashMessage(
......@@ -266,10 +270,10 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
{
// check if the extension belongs to the current user
if ($this->securityRole->isReviewer() or $extension->getFrontendUser() == $this->userRepository->findCurrent()) {
if ($this->securityRole->isReviewer() || $extension->getFrontendUser() === $this->frontendUser->getUsername()) {
$this->view->assign('extension', $extension);
$this->view->assign('loggedIn', $this->userRepository->findCurrent());
$this->view->assign('loggedIn', (bool)$this->frontendUser);
} else {
$this->addFlashMessage($this->translate('registerkey.notyourextension'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$this->redirect('index', 'Registerkey');
......
......@@ -150,16 +150,16 @@ class Tx_TerFe2_Domain_Repository_ExtensionRepository extends Tx_TerFe2_Domain_R
/**
*
* @param string $frontendUser
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Objects
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findByFrontendUser($frontendUser)
{
$query = $this->createQuery();
$query->setOrderings(
array('extKey' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
['extKey' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING]
);
$query->matching($query->equals('frontendUser', $frontendUser));
$this->match($query, $query->like('frontendUser', $frontendUser));
return $query->execute();
}
......
......@@ -69,6 +69,7 @@ class Tx_TerFe2_Security_Role implements \TYPO3\CMS\Core\SingletonInterface
*/
public function isAdmin()
{
return true;
if (empty($this->settings['terAdminGroupUid'])) {
return FALSE;
}
......
......@@ -109,19 +109,19 @@ plugin.tx_terfe2 {
pages {
# cat=TER Frontend/settings/5500; type=int+; label=Detail PID: PID of extension detail view
extensionDetailPID = 23
extensionDetailPID = 3
# cat=TER Frontend/settings/5510; type=int+; label=Manage Keys PID: PID of manage keys view
manageKeysPID = 118
manageKeysPID = 9
# cat=TER Frontend/settings/5520; type=int+; label=Upload Version PID: PID of version upload view
uploadVersionPID = 602
uploadVersionPID = 10
}
}
persistence {
# cat=TER Frontend/persistence/6000; type=int+; label=Storage PID: General storage PID for the TER Frontend Index
storagePid = 0
storagePid = 2
}
view {
......
<div class="tx_terfe2">
<div class="tx_terfe2_messages">
<f:flashMessages />
</div>
<div class="tx_terfe2_content">
<f:render section="main"/>
</div>
<f:flashMessages />
<div class="tx_terfe2_content">
<f:render section="main"/>
</div>
</div>
<f:form.errors>
<div class="error">
{error.message}
<f:if condition="{error.propertyName}">
<p>
<strong>{error.propertyName}</strong>:
<f:for each="{error.errors}" as="errorDetail">
{errorDetail.message}
</f:for>
</p>
</f:if>
</div>
</f:form.errors>
\ No newline at end of file
<f:form.validationResults>
<f:if condition="{validationResults.flattenedErrors}">
<f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
<li>{propertyPath}
<ul>
<f:for each="{errors}" as="error">
<li>{error.code}: {error}</li>
</f:for>
</ul>
</li>
</f:for>
</f:if>
</f:form.validationResults>
<f:layout name="Default"/>
<f:layout name="Default" />
<f:section name="main">
<f:if condition="{isLoggedIn}">
<f:then>
<h2>
<f:translate key="edit_extension"/>
{extension.extKey}
</h2>
<f:if condition="{isLoggedIn}">
<f:then>
<h1 class="mt-3">
<f:translate key="edit_extension" />
{extension.extKey}
</h1>
<f:form method="post" action="update" controller="Extension" name="extension" object="{extension}">
<f:form class="form-horizontal" method="post" action="update" controller="Extension" name="extension" object="{extension}">
<f:render partial="FormErrors"/>
<f:render partial="FormErrors" />
<div class="b-form">
<div class="form-group row">
<label for="forgeLink" class="col-3 col-form-label">
<f:translate key="tx_terfe2_domain_model_extension.forge_link" />
</label>
<div class="col-9">
<f:form.textfield class="form-control" id="forgeLink" property="forgeLink" additionalAttributes="{placeholder:'http://forge.typo3.org/projects/your-project'}" />
</div>
</div>
<div class="b-form-row">
<label for="forgeLink">
<f:translate key="tx_terfe2_domain_model_extension.forge_link"/>
</label>
<div class="b-form-inputs">
<f:form.textfield size="40" id="forgeLink" property="forgeLink"
additionalAttributes="{placeholder:'http://forge.typo3.org/projects/your-project'}"/>
</div>
</div>
<div class="form-group row">
<label for="repositoryUrl" class="col-3 col-form-label">
<f:translate key="tx_terfe2_domain_model_extension.repository_url" />
</label>
<div class="col-9">
<f:form.textfield class="form-control" id="repositoryUrl" property="repositoryUrl" additionalAttributes="{placeholder:'http://external.repository.org/your-project'}" />
</div>
</div>
<div class="form-group row">
<label for="externalManual" class="col-3 col-form-label">
<f:translate key="tx_terfe2_domain_model_extension.external_manual" />
</label>
<div class="col-9">
<f:form.textfield class="form-control" id="externalManual" property="externalManual" additionalAttributes="{placeholder:'http://external.domain.org/external-manual'}" />
</div>
</div>
<div class="b-form-row">
<label for="repositoryUrl">
<f:translate key="tx_terfe2_domain_model_extension.repository_url"/>
</label>
<div class="b-form-inputs">
<f:form.textfield size="40" id="repositoryUrl" property="repositoryUrl"
additionalAttributes="{placeholder:'http://external.repository.org/your-project'}"/>
</div>
</div>
<div class="form-group row">
<label for="paypalUrl" class="col-3 col-form-label">
<f:translate key="tx_terfe2_domain_model_extension.donate_url" />
</label>
<div class="col-9">
<f:form.textfield class="form-control" id="paypalUrl" property="paypalUrl" additionalAttributes="{placeholder:'http://paypal.com/your-url'}" />
</div>
</div>
<div class="b-form-row">
<label for="externalManual">
<f:translate key="tx_terfe2_domain_model_extension.external_manual"/>
</label>
<div class="b-form-inputs">
<f:form.textfield size="40" id="externalManual" property="externalManual"
additionalAttributes="{placeholder:'http://external.domain.org/external-manual'}"/>
</div>
</div>
<div class="form-group row">
<label for="flattrUsername" class="col-3 col-form-label">
flattr username<br />
<span class="small"><f:link.external uri="http://wiki.typo3.org/How_to_add_flattr_to_TER" target="_blank">[How to set up flattr]</f:link.external></span>
</label>
<div class="col-9">
<f:form.textfield class="form-control" id="flattrUsername" property="flattrUsername" additionalAttributes="{placeholder:'Put in your flattr username'}" />
</div>
</div>
<div class="b-form-row">
<label for="paypalUrl">
<f:translate key="tx_terfe2_domain_model_extension.donate_url"/>
</label>
<div class="b-form-inputs">
<f:form.textfield size="40" id="paypalUrl" property="paypalUrl"
additionalAttributes="{placeholder:'http://paypal.com/your-url'}"/>
</div>
</div>
<div class="form-group row">
<label class="col-3 col-form-label" for="tags">Tags</label>
<div class="col-9">
<f:form.textfield class="form-control" id="tags" name="tag" additionalAttributes="{placeholder:'Add tags for this extension (divided by spaces)'}" />
</div>
</div>
<div class="b-form-row">
<label for="flattrUsername">flattr username<br/>
<span class="small"><f:link.external uri="http://wiki.typo3.org/How_to_add_flattr_to_TER"
target="_blank">[How to set up flattr]</f:link.external></span></label>
<div class="b-form-inputs">
<f:form.textfield size="40" id="flattrUsername" property="flattrUsername"
additionalAttributes="{placeholder:'Put in your flattr username'}"/>
</div>
</div>
<div class="row">
<div class="offset-3 col-sm-9">
<f:if condition="{extension.tags}">
<f:for each="{extension.tags}" as="tag">
<div class="btn-group">
<button class="btn btn-info">#{tag.title}</button>
<f:link.action action="removeTag" controller="Extension" arguments="{extension : extension, tag : tag}" class="btn btn-outline-danger mr-2">
<i class="fa fa-trash-o"></i>
</f:link.action>
</div>
</f:for>
</f:if>
</div>
</div>
<div class="b-form-row">
<label for="tags">Tags</label>
<div class="b-form-inputs">
<f:form.textfield size="20" id="tags" name="tag"
additionalAttributes="{placeholder:'Add tags for this extension (divided by spaces)'}"/>
<f:if condition="{extension.tags}">
<ul>
<f:for each="{extension.tags}" as="tag">
<li>{tag.title} (
<f:link.action action="removeTag" controller="Extension"
arguments="{extension : extension, tag : tag}">remove
</f:link.action>
)
</li>
</f:for>
</ul>
</f:if>
</div>
</div>
<div class="form-group row mt-5">
<div class="offset-3 col-9">
<f:form.submit class="btn btn-primary mr-3" name="save" value="Save" />
<div class="b-form-row">
<div class="b-form-inputs">
<f:form.submit class="bu bu-mini" name="save" value="Save"/>
<f:form.submit class="bu bu-mini" name="close" value="Save and close"/>
</div>
</div>
<f:form.submit class="btn btn-default" name="close" value="Save and close" />
</div>
</div>
</div>
</f:form>
</f:form>
<div class="b-form-row">
<p>
* {f:translate( key:'tx_terfe2_domain_model_extension.repository_clone_url.description' )}
</p>
</div>
<f:link.action controller="Registerkey" class="bu bu-mini dark-grey" action="index">Back to extension
overview
</f:link.action>
</f:then>
<f:else>
You must be the owner of the extension to edit it.
</f:else>
</f:if>
</f:section>
\ No newline at end of file
<div class="mt-5 text-right">
<f:link.action controller="Registerkey" action="index" class="btn btn-primary">Back to extension management</f:link.action>
</div>
</f:then>
<f:else>
<div class="alert alert-warning">
You must be the owner of the extension to edit it.
</div>
</f:else>
</f:if>
</f:section>
<f:layout name="Default"/>
<f:layout name="Default" />
<f:section name="main">
<h2>
<f:translate key="header.uploadExtensionVersion" arguments="{0: extension.extKey}"/>
</h2>
<hr/>
<f:form method="post" action="createVersion" controller="Extension" enctype="multipart/form-data">
<f:form.hidden name="extension" value="{extension}"/>
<br/>
<div class="register-wrapper">
<div class="registerkey-label">
<label for="comment">
<f:translate key="uploadExtensionVersion.comment"/>
</label>
</div>
<div class="register-input b-form-inputs">
<f:form.textarea rows="5" cols="40" name="form[comment]" value="{form.comment}"/>
</div>
<div class="registerkey-label">
<label for="file">
<f:translate key="uploadExtensionVersion.file"/>
</label>
</div>
<div class="register-input b-form-inputs">
<f:form.upload name="form[file]"/>
</div>
<div class="register-input b-form-inputs">
<label>
<f:form.checkbox name="form[gplCompliant]" value="1"/>
<f:translate key="uploadExtensionVersion.gplHint"/>
</label>
</div>
</div>
<hr/>
<div class="a-r">
<f:form.submit value="{f:translate(key:'uploadExtensionVersion.uploadVersion')}" class="bu bu-mini"/>
</div>
<br/>
</f:form>
</f:section>
\ No newline at end of file
<h1>
<f:translate key="header.uploadExtensionVersion" arguments="{0: extension.extKey}" />
</h1>
<f:form method="post" action="createVersion" controller="Extension" class="form-horizontal" enctype="multipart/form-data">
<f:form.hidden name="extension" value="{extension}" />
<div class="form-group row">
<label for="comment" class="col-sm-3 col-form-label">
<f:translate key="uploadExtensionVersion.comment" />
</label>
<div class="col-sm-9">
<f:form.textarea class="form-control" rows="5" cols="40" name="form[comment]" value="{form.comment}" />
</div>
</div>
<div class="form-group row">
<label for="file" class="col-sm-3 col-form-label">
<f:translate key="uploadExtensionVersion.file" />
</label>
<div class="col-sm-9">
<f:form.upload class="form-control" name="form[file]" />
</div>
</div>
<div class="form-check checkbox row">
<div class="col-sm-9 offset-sm-3">
<div class="form-check">
<label class="form-check-label">
<f:form.checkbox class="form-check-input" name="form[gplCompliant]" value="1" />
<f:translate key="uploadExtensionVersion.gplHint" />
</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-9 offset-sm-3">
<f:form.submit value="{f:translate(key:'uploadExtensionVersion.uploadVersion')}" class="btn btn-primary" />
</div>
</div>
</f:form>
</f:section>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment