示例#1
0
 /**
  * Obtener la pestaña de preferencias
  */
 public function getPreferencesTab()
 {
     $this->setAction(self::ACTION_USR_PREFERENCES_GENERAL);
     $this->view->addTemplate('preferences');
     $this->view->assign('userId', $this->_userId);
     $this->view->assign('langsAvailable', Language::getAvailableLanguages());
     $this->view->assign('currentLang', $this->_userPrefs->getLang());
     $this->view->assign('themesAvailable', Themes::getThemesAvailable());
     $this->view->assign('currentTheme', $this->_userPrefs->getTheme() ? $this->_userPrefs->getTheme() : \SP\Config::getValue('sitetheme'));
     $this->view->assign('chkAccountLink', $this->_userPrefs->isAccountLink() ? 'checked="checked"' : '');
     $this->view->assign('resultsPerPage', $this->_userPrefs->getResultsPerPage() ? $this->_userPrefs->getResultsPerPage() : \SP\Config::getValue('account_count'));
     $this->view->assign('chkSortViews', $this->_userPrefs->isSortViews() ? 'checked="checked"' : '');
     $this->view->assign('chkTopNavbar', $this->_userPrefs->isTopNavbar() ? 'checked="checked"' : '');
     $this->view->assign('chkOptionalActions', $this->_userPrefs->isOptionalActions() ? 'checked="checked"' : '');
     $this->view->append('tabs', array('title' => _('Preferencias')));
     $this->view->assign('tabIndex', $this->getTabIndex(), 'preferences');
     $this->view->assign('actionId', $this->getAction(), 'preferences');
 }
示例#2
0
    }
}
// Obtenemos la clave maestra del usuario
if ($User->getUserMPass()) {
    // Actualizar el último login del usuario
    UserUtil::setUserLastLogin($User->getUserId());
    // Cargar las variables de sesión del usuario
    SessionUtil::loadUserSession($User);
    $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
    $Log->addDescription(sprintf('%s: %s', _('Perfil'), SP\Profile::getProfileNameById($User->getUserProfileId())));
    $Log->addDescription(sprintf('%s: %s', _('Grupo'), SP\Groups::getGroupNameById($User->getUserGroupId())));
    $Log->writeLog();
} else {
    SP\Response::printJSON(_('Error interno'));
}
$UserPrefs = \SP\UserPreferences::getPreferences($User->getUserId());
if ($UserPrefs->isUse2Fa()) {
    SP\Session::set2FApassed(false);
    $url = SP\Init::$WEBURI . '/index.php?a=2fa&i=' . $User->getUserId() . '&t=' . time() . '&f=1';
    SP\Response::printJSON($url, 0);
} else {
    SP\Session::set2FApassed(true);
}
SP\Language::setLanguage(true);
SP\Themes::setTheme(true);
SP\Session::setUserPreferences($UserPrefs);
$params = array();
// Comprobar si existen parámetros adicionales en URL via POST para pasarlos por GET
foreach ($_POST as $param => $value) {
    \SP\Html::sanitize($param);
    \SP\Html::sanitize($value);
示例#3
0
    SP\Language::setLanguage(true);
    SP\Themes::setTheme(true);
    // Actualizar las preferencias en la sesión y recargar la página
    SP\Session::setUserPreferences($UserPrefs);
    SP\Util::reload();
    SP\Response::printJSON(_('Preferencias actualizadas'), 0, $doActionOnClose);
} else {
    if ($actionId === SP\Controller\ActionsInterface::ACTION_USR_PREFERENCES_SECURITY) {
        if (SP\Util::demoIsEnabled() && \SP\Session::getUserLogin() === 'demo') {
            SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
        }
        // Variables POST del formulario
        $twoFaEnabled = SP\Request::analyze('security_2faenabled', 0, false, 1);
        $pin = SP\Request::analyze('security_pin', 0);
        $userLogin = UserUtil::getUserLoginById($itemId);
        $twoFa = new \SP\Auth\Auth2FA($itemId, $userLogin);
        if (!$twoFa->verifyKey($pin)) {
            SP\Response::printJSON(_('Código incorrecto'));
        }
        // No se instancia la clase ya que es necesario guardar los atributos ya guardados
        $UserPrefs = \SP\UserPreferences::getPreferences($itemId);
        $UserPrefs->setId($itemId);
        $UserPrefs->setUse2Fa(\SP\Util::boolval($twoFaEnabled));
        if (!$UserPrefs->updatePreferences()) {
            SP\Response::printJSON(_('Error al actualizar preferencias'));
        }
        SP\Response::printJSON(_('Preferencias actualizadas'), 0, $doActionOnClose);
    } else {
        SP\Response::printJSON(_('Acción Inválida'));
    }
}