Created
April 8, 2016 13:27
-
-
Save Raistlfiren/ec9c011948a2d4e937188f923e56aa9b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
public function initialize() | |
{ | |
if (empty($this->config['encryption'])) { | |
$this->config['encryption'] = "plaintext"; | |
} | |
$this->addTwigFunction('passwordprotect', 'passwordProtect'); | |
$this->addTwigFunction('passwordform', 'passwordForm'); | |
$path = $this->app['config']->get('general/branding/path') . '/generatepasswords'; | |
$this->app->match($path, array($this, "generatepasswords")); | |
$extension = $this; | |
// Register this extension's actions as an early event. | |
$this->app->before(function (Request $request) use ($extension) { | |
return $extension->handleRequest($request); | |
}, SilexApplication::EARLY_EVENT); | |
$this->addMenuOption('Edit Access Code', $this->app['resources']->getUrl('bolt').'generatepasswords', 'fa:pencil-square-o'); | |
} | |
public function handleRequest(Request $request) | |
{ | |
$path = explode("/", $request->getPathInfo()); | |
if (isset($path[1])) { | |
if ($path[1] === $this->config['contentType']) { | |
if ($this->app['session']->get('passwordprotect') == 1) { | |
return true; | |
} else { | |
$redirectto = $this->app['storage']->getContent($this->config['redirect'], array('returnsingle' => true)); | |
$returnto = $this->app['request']->getRequestUri(); | |
return $this->app->redirect($redirectto->link(). "?returnto=" . urlencode($returnto)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment