Exemple #1
0
 /**
  * Registers the preLogin hook to catch wether or not the user accepted the
  * disclaimer
  *
  * @param string $appName   The app's name
  */
 public function register($appName)
 {
     $callback = function ($user, $password) {
         $app = new Application();
         $appName = $app->getAppName();
         $config = $app->getConfig();
         $isDav = strpos($this->request->getScriptName(), '/remote.php') !== false;
         $disclaimerChecked = isset($_POST[$appName . 'Checkbox']);
         if (!$isDav && !$disclaimerChecked) {
             //If the "agree" checkbox wasn't checked, then an throw an
             //exception
             if ($config->getUseCookie()) {
                 //In case that the agree disclaimer cookies was set, expires
                 //it. This means that the user either unchecked the
                 //disclaimer or he hasn't checked it yet
                 $config->expireCheckedCookie();
             }
             $message = $this->l10n->t('Please read and ' . 'agree the disclaimer before proceeding');
             throw new LoginException($message);
         } else {
             if ($config->getUseCookie()) {
                 $config->setLastVisitCookie();
                 $config->setCheckedCookie();
             }
         }
     };
     $this->userManager->listen('\\OC\\User', 'preLogin', $callback);
 }
Exemple #2
0
/**
 * ownCloud - agreedisclaimer
 *
 * This file is licensed under the MIT License. See the LICENSE file.
 *
 * @author Josef Meile <*****@*****.**>
 * @copyright Josef Meile 2015
 */
namespace OCA\AgreeDisclaimer;

use OCP\AppFramework\Http\TemplateResponse;
use OCA\AgreeDisclaimer\AppInfo\Application;
/**
 * Renders the app settings on the admin page
 *
 * @return string   The template rendered as html
 */
$app = new Application();
$appName = $app->getAppName();
$container = $app->getContainer();
$config = $app->getConfig();
$utils = $app->getUtils();
$defaultLang = $config->getDefaultLang();
$localeInfo = $utils->getAvailableLanguages($defaultLang);
//Fix it: I'm not sure if there is a better way of getting l10n from this
//script, ie: something like in the templates: $l->...
$l10n = $app->getContainer()->getServer()->getL10N($appName);
$userLang = $l10n->getLanguageCode();
$data = ['appName' => $appName, 'filePreffix' => $container->query('filePreffix'), 'datepickerAppFormat' => $config->getDatepickerDateFormat(), 'cookieData' => $config->getCookieData(true), 'txtFileData' => $config->getTxtFileData(false, true), 'pdfFileData' => $config->getPdfFileData(false, true), 'disclaimerType' => $config->getDisclaimerType(), 'disclaimerTypes' => $config->getDisclaimerTypes(true), 'disclaimerLayout' => $config->getDisclaimerLayout(), 'disclaimerLayouts' => $config->getDisclaimerLayouts(), 'userLang' => $userLang, 'currentLang' => $localeInfo['activelanguage'], 'commonLanguages' => $localeInfo['commonlanguages'], 'availableLanguages' => $localeInfo['languages']];
$templateResponse = new TemplateResponse($appName, 'admin', $data, 'blank');
return $templateResponse->render();