/**
  * Do something after resolving is done
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     // TODO: Deactivated license check for now. Implement new behavior.
     return true;
     global $plainCmd, $objDatabase, $_CORELANG, $_LANGID, $section;
     $license = \Cx\Core_Modules\License\License::getCached(\Env::get('config'), $objDatabase);
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             if (!$license->isInLegalComponents('fulllanguage') && $_LANGID != \FWLanguage::getDefaultLangId()) {
                 $_LANGID = \FWLanguage::getDefaultLangId();
                 \Env::get('Resolver')->redirectToCorrectLanguageDir();
             }
             if (!empty($section) && !$license->isInLegalFrontendComponents($section)) {
                 if ($section == 'Error') {
                     // If the error module is not installed, show this
                     die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
                 } else {
                     //page not found, redirect to error page.
                     \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
                     exit;
                 }
             }
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             // check if the requested module is active:
             if (!in_array($plainCmd, array('Login', 'noaccess', ''))) {
                 $query = '
                             SELECT
                                 modules.is_licensed
                             FROM
                                 ' . DBPREFIX . 'modules AS modules,
                                 ' . DBPREFIX . 'backend_areas AS areas
                             WHERE
                                 areas.module_id = modules.id
                                 AND (
                                     areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '&%"
                                     OR areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '"
                                 )
                         ';
                 $res = $objDatabase->Execute($query);
                 if (!$res->fields['is_licensed']) {
                     $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home';
                 }
             }
             // If logged in
             if (\Env::get('cx')->getUser()->objUser->login(true)) {
                 $license->check();
                 if ($license->getState() == \Cx\Core_Modules\License\License::LICENSE_NOK) {
                     $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home';
                     $license->save($objDatabase);
                 }
                 $lc = \Cx\Core_Modules\License\LicenseCommunicator::getInstance(\Env::get('config'));
                 $lc->addJsUpdateCode($_CORELANG, $license, $plainCmd == 'License');
             }
             break;
         default:
             break;
     }
 }
Esempio n. 2
0
// Init user
if (empty($sessionObj)) {
    $sessionObj = \cmsSession::getInstance();
}
if (!isset($objUser)) {
    $objUser = $cx->getUser()->objUser;
}
$objUser->login();
if (!isset($objDatabase)) {
    $objDatabase = $cx->getDb()->getAdoDb();
}
// update license, return "false" if no connection to license server could be established
if (!isset($license)) {
    $license = $cx->getLicense();
}
$licenseCommunicator = \Cx\Core_Modules\License\LicenseCommunicator::getInstance($_CONFIG);
try {
    $licenseCommunicator->update($license, $_CONFIG, isset($_GET['force']) && $_GET['force'] == 'true', false, $_CORELANG, isset($_POST['response']) && $objUser->getAdminStatus() ? contrexx_input2raw($_POST['response']) : '');
} catch (\Exception $e) {
    $license->check();
    if (!isset($_GET['nosave']) || $_GET['nosave'] != 'true') {
        $license->save($objDatabase);
    }
    if (!isset($_GET['silent']) || $_GET['silent'] != 'true') {
        echo "false";
    }
    return;
}
$license->check();
if (!isset($_GET['nosave']) || $_GET['nosave'] != 'true') {
    $license->save($objDatabase);