configure button in module page

This commit is contained in:
Etienne Roudeix
2013-11-15 12:19:06 +01:00
parent 79120528b5
commit 87b25b922e
2 changed files with 22 additions and 4 deletions

View File

@@ -148,6 +148,23 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
->set("CLASS", $module->getFullNamespace())
->set("POSITION", $module->getPosition());
$hasConfigurationInterface = false;
$routerId = "router." . $module->getBaseDir();
/* first test if module defines it's own config route */
if($this->container->has($routerId)) {
if($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) {
$hasConfigurationInterface = true;
}
}
/* if not ; test if it uses admin inclusion : module_configuration.html */
if(false === $hasConfigurationInterface) {
if(file_exists( sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), "module_configuration"))) {
$hasConfigurationInterface = true;
}
}
$loopResultRow->set("CONFIGURABLE", $hasConfigurationInterface ? 1 : 0);
if (null !== $this->getProfile()) {
$accessValue = $module->getVirtualColumn('access');
$manager = new AccessManager($accessValue);

View File

@@ -41,10 +41,11 @@
{loop type="auth" name="can_change" role="ADMIN" module=$CODE access="VIEW"}
<a class="btn btn-primary btn-xs" title="{intl l='Configure this module'}" href="{url path="/admin/module/$CODE"}">{intl l="Configure"}</a>
{/loop}
{if $CONFIGURABLE == 1}
{loop type="auth" name="can_change" role="ADMIN" module=$CODE access="VIEW"}
<a class="btn btn-primary btn-xs" title="{intl l='Configure this module'}" href="{url path="/admin/module/$CODE"}">{intl l="Configure"}</a>
{/loop}
{/if}
{*loop type="auth" name="can_change" role="ADMIN" resource="admin.modules" access="VIEW"}
<a class="btn btn-default btn-xs" title="{intl l='Read the documentation of this module'}" href="{url path="/admin/module/documentation/$ID"}"><span class="glyphicon glyphicon-book"></span></a>