mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-09 09:56:56 +01:00
* [MOD] Html select building is removed from Html class. Now is built in template file
This commit is contained in:
@@ -32,54 +32,6 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*/
|
||||
class Html
|
||||
{
|
||||
/**
|
||||
* Crear un elemento del tipo SELECT.
|
||||
* Esta función genera un elemento SELECT con las propiedades y valores pasados.
|
||||
*
|
||||
* @param array $values con los valores del select
|
||||
* @param array $properties con las propiedades del select
|
||||
* @param bool $useValue para usar el Id como valor
|
||||
*/
|
||||
public static function printSelect($values, $properties, $useValue = true)
|
||||
{
|
||||
|
||||
if (!is_array($properties)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attribs = (is_array($properties['attribs'])) ? implode(' ', $properties['attribs']) : '';
|
||||
$cssClass = ($properties['class']) ? 'class="' . $properties['class'] . '"' : '';
|
||||
|
||||
if (!is_array($values)) {
|
||||
echo '<label for=' . $properties['id'] . '">' . $properties['label'] . '</label>';
|
||||
echo '<select name="' . $properties['name'] . '" id="' . $properties['id'] . '" ' . $cssClass . ' size="' . $properties['size'] . '" ' . $properties['js'] . ' ' . $attribs . ' >';
|
||||
echo '<option value="0">' . $properties['default'] . '</option>';
|
||||
echo '</select>';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($properties['label']) {
|
||||
echo '<label for=' . $properties['id'] . '">' . $properties['label'] . '</label>';
|
||||
}
|
||||
|
||||
echo '<select name="' . $properties['name'] . '" id="' . $properties['id'] . '" ' . $cssClass . ' size="' . $properties['size'] . '" ' . $properties['js'] . ' ' . $attribs . ' >';
|
||||
echo '<option value="0">' . $properties['default'] . '</option>';
|
||||
|
||||
$selectedId = (isset($properties['selected'])) ? $properties['selected'] : "";
|
||||
|
||||
foreach ($values as $valueId => $valueName) {
|
||||
if ($useValue) {
|
||||
$selected = ($valueId == $selectedId) ? 'SELECTED' : '';
|
||||
echo '<option value="' . $valueId . '" ' . $selected . '>' . $valueName . '</option>';
|
||||
} else {
|
||||
$selected = ($valueName == $selectedId) ? 'SELECTED' : '';
|
||||
echo '<option ' . $selected . '>' . $valueName . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Limpia los datos recibidos de un formulario.
|
||||
*
|
||||
|
||||
@@ -249,7 +249,12 @@
|
||||
<?php echo SP\Common::printHelpButton("config", 27); ?>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php SP\Html::printSelect($groupsSelData, $groupsSelProp); ?>
|
||||
<select id="ldap_defaultgroup" name="ldap_defaultgroup" class="select-box" <?php echo $isDisabled; ?> required>
|
||||
<option value="0"></option>
|
||||
<?php foreach ($groups as $id => $name): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo ($id === $ldapDefaultGroup) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -258,7 +263,12 @@
|
||||
<?php echo SP\Common::printHelpButton("config", 28); ?>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php SP\Html::printSelect($profilesSelData, $profilesSelProp); ?>
|
||||
<select id="ldap_defaultprofile" name="profileid" class="select-box" <?php echo $isDisabled; ?> required>
|
||||
<option value="0"></option>
|
||||
<?php foreach ($profiles as $id => $name): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo ($id === $ldapDefaultProfile) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2 class="midround"><?php use SP\Html;
|
||||
use SP\Session;
|
||||
|
||||
echo $header; ?></h2>
|
||||
<h2 class="midround"><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="frmUsers" id="frmUsers">
|
||||
<table class="fancydata">
|
||||
@@ -39,14 +36,24 @@
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Perfil'); ?></td>
|
||||
<td class="valField">
|
||||
<?php \SP\Html::printSelect(\SP\DB::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'), $profilesSelProp); ?>
|
||||
<select id="selProfile" name="profileid" class="select-box" <?php echo $isDisabled; ?> required>
|
||||
<option value="0"></option>
|
||||
<?php foreach ($profiles as $id => $name): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo ($id == $user['user_profileId']) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Grupo'); ?></td>
|
||||
<td class="valField">
|
||||
<?php \SP\Html::printSelect(\SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'), $groupsSelProp); ?>
|
||||
<select id="selGroup" name="groupid" class="select-box" <?php echo $isDisabled; ?> required>
|
||||
<option value="0"></option>
|
||||
<?php foreach ($groups as $id => $name): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo ($id == $user['user_groupId']) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -94,7 +101,7 @@
|
||||
<td class="descField"><?php echo _('Opciones'); ?></td>
|
||||
<td class="valField checkbox">
|
||||
<div id="btnUserOptions" class="btn-checks round5">
|
||||
<?php if (Session::getUserIsAdminApp() || $isDemo): ?>
|
||||
<?php if (\SP\Session::getUserIsAdminApp() || $isDemo): ?>
|
||||
<label for="usradminapp"
|
||||
title="<?php echo _('Administrador de la aplicación'); ?>"><?php echo _('Admin. Aplicación'); ?></label>
|
||||
<input type="checkbox" id="usradminapp"
|
||||
|
||||
@@ -92,30 +92,10 @@ class ConfigC extends Controller implements ActionsInterface
|
||||
|
||||
$this->view->assign('filesAllowedExts', \SP\Config::getValue('files_allowed_exts'));
|
||||
$this->view->assign('filesAllowedSize', \SP\Config::getValue('files_allowed_size'));
|
||||
$this->view->assign('groupsSelData', \SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->view->assign('groupsSelProp',
|
||||
array('name' => 'ldap_defaultgroup',
|
||||
'id' => 'ldap_defaultgroup',
|
||||
'class' => '',
|
||||
'size' => 1,
|
||||
'label' => '',
|
||||
'selected' => \SP\Config::getValue('ldap_defaultgroup'),
|
||||
'default' => '',
|
||||
'js' => '',
|
||||
'attribs' => array('required', $this->view->isDisabled))
|
||||
);
|
||||
$this->view->assign('profilesSelData', \SP\DB::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
||||
$this->view->assign('profilesSelProp',
|
||||
array('name' => 'ldap_defaultprofile',
|
||||
'id' => 'ldap_defaultprofile',
|
||||
'class' => '',
|
||||
'size' => 1,
|
||||
'label' => '',
|
||||
'selected' => \SP\Config::getValue('ldap_defaultprofile'),
|
||||
'default' => '',
|
||||
'js' => '',
|
||||
'attribs' => array('required', $this->view->isDisabled))
|
||||
);
|
||||
$this->view->assign('groups', \SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->view->assign('profiles', \SP\DB::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
||||
$this->view->assign('ldapDefaultGroup', \SP\Config::getValue('ldap_defaultgroup'));
|
||||
$this->view->assign('ldapDefaultProfile', \SP\Config::getValue('ldap_defaultprofile'));
|
||||
$this->view->assign('currentLang', \SP\Config::getValue('sitelang'));
|
||||
$this->view->assign('sessionTimeout', \SP\Config::getValue('session_timeout'));
|
||||
$this->view->assign('accountCount', \SP\Config::getValue('account_count'));
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
|
||||
namespace SP\Controller;
|
||||
|
||||
use SP\AccountSearch;
|
||||
use SP\Session;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
@@ -59,12 +56,12 @@ class SearchC extends Controller implements ActionsInterface
|
||||
$this->view->assign('globalSearch', \SP\Config::getValue('globalsearch', 0));
|
||||
|
||||
// Comprobar si está creado el objeto de búsqueda en la sesión
|
||||
if (!is_object(Session::getSearchFilters())) {
|
||||
Session::setSearchFilters(new AccountSearch());
|
||||
if (!is_object(\SP\Session::getSearchFilters())) {
|
||||
\SP\Session::setSearchFilters(new \SP\AccountSearch());
|
||||
}
|
||||
|
||||
// Obtener el filtro de búsqueda desde la sesión
|
||||
$filters = Session::getSearchFilters();
|
||||
$filters = \SP\Session::getSearchFilters();
|
||||
|
||||
// Valores POST
|
||||
$this->view->assign('searchKey', \SP\Common::parseParams('p', 'skey', $filters->getSortKey()));
|
||||
@@ -94,7 +91,7 @@ class SearchC extends Controller implements ActionsInterface
|
||||
|
||||
$this->view->assign('queryTimeStart', microtime());
|
||||
|
||||
$search = new AccountSearch();
|
||||
$search = new \SP\AccountSearch();
|
||||
|
||||
$search->setGlobalSearch($this->view->globalSearch);
|
||||
$search->setTxtSearch($this->view->searchTxt);
|
||||
@@ -126,11 +123,11 @@ class SearchC extends Controller implements ActionsInterface
|
||||
|
||||
// Variables para la barra de navegación
|
||||
$this->view->assign('firstPage', ceil(($this->view->limitStart + 1) / $this->view->limitCount));
|
||||
$this->view->assign('lastPage', ceil(AccountSearch::$queryNumRows / $this->view->limitCount));
|
||||
$this->view->assign('totalRows', AccountSearch::$queryNumRows);
|
||||
$this->view->assign('lastPage', ceil(\SP\AccountSearch::$queryNumRows / $this->view->limitCount));
|
||||
$this->view->assign('totalRows', \SP\AccountSearch::$queryNumRows);
|
||||
$this->view->assign('filterOn', ($this->view->searchKey > 1 || $this->view->searchCustomer || $this->view->searchCategory || $this->view->searchTxt) ? true : false);
|
||||
|
||||
$limitLast = ((AccountSearch::$queryNumRows % $this->view->limitCount) == 0) ? AccountSearch::$queryNumRows - $this->view->limitCount : floor(AccountSearch::$queryNumRows / $this->view->limitCount) * $this->view->limitCount;
|
||||
$limitLast = ((\SP\AccountSearch::$queryNumRows % $this->view->limitCount) == 0) ? \SP\AccountSearch::$queryNumRows - $this->view->limitCount : floor(\SP\AccountSearch::$queryNumRows / $this->view->limitCount) * $this->view->limitCount;
|
||||
|
||||
$this->view->assign('pagerOnnClick', array(
|
||||
'first' => 'searchSort(' . $this->view->searchKey . ', 0,1)',
|
||||
@@ -259,34 +256,34 @@ class SearchC extends Controller implements ActionsInterface
|
||||
{
|
||||
$this->view->assign('sortFields', array(
|
||||
array(
|
||||
'key' => AccountSearch::SORT_CUSTOMER,
|
||||
'key' => \SP\AccountSearch::SORT_CUSTOMER,
|
||||
'title' => _('Ordenar por Cliente'),
|
||||
'name' => _('Cliente'),
|
||||
'function' => 'searchSort(' . AccountSearch::SORT_CUSTOMER . ',' . $this->view->limitStart . ')'
|
||||
'function' => 'searchSort(' . \SP\AccountSearch::SORT_CUSTOMER . ',' . $this->view->limitStart . ')'
|
||||
),
|
||||
array(
|
||||
'key' => AccountSearch::SORT_NAME,
|
||||
'key' => \SP\AccountSearch::SORT_NAME,
|
||||
'title' => _('Ordenar por Nombre'),
|
||||
'name' => _('Nombre'),
|
||||
'function' => 'searchSort(' . AccountSearch::SORT_NAME . ',' . $this->view->limitStart . ')'
|
||||
'function' => 'searchSort(' . \SP\AccountSearch::SORT_NAME . ',' . $this->view->limitStart . ')'
|
||||
),
|
||||
array(
|
||||
'key' => AccountSearch::SORT_CATEGORY,
|
||||
'key' => \SP\AccountSearch::SORT_CATEGORY,
|
||||
'title' => _('Ordenar por Categoría'),
|
||||
'name' => _('Categoría'),
|
||||
'function' => 'searchSort(' . AccountSearch::SORT_CATEGORY . ',' . $this->view->limitStart . ')'
|
||||
'function' => 'searchSort(' . \SP\AccountSearch::SORT_CATEGORY . ',' . $this->view->limitStart . ')'
|
||||
),
|
||||
array(
|
||||
'key' => AccountSearch::SORT_LOGIN,
|
||||
'key' => \SP\AccountSearch::SORT_LOGIN,
|
||||
'title' => _('Ordenar por Usuario'),
|
||||
'name' => _('Usuario'),
|
||||
'function' => 'searchSort(' . AccountSearch::SORT_LOGIN . ',' . $this->view->limitStart . ')'
|
||||
'function' => 'searchSort(' . \SP\AccountSearch::SORT_LOGIN . ',' . $this->view->limitStart . ')'
|
||||
),
|
||||
array(
|
||||
'key' => AccountSearch::SORT_URL,
|
||||
'key' => \SP\AccountSearch::SORT_URL,
|
||||
'title' => _('Ordenar por URL / IP'),
|
||||
'name' => _('URL / IP'),
|
||||
'function' => 'searchSort(' . AccountSearch::SORT_URL . ',' . $this->view->limitStart . ')'
|
||||
'function' => 'searchSort(' . \SP\AccountSearch::SORT_URL . ',' . $this->view->limitStart . ')'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -277,31 +277,8 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$this->view->assign('isDisabled', ($this->view->isDemo || $this->view->actionId === self::ACTION_USR_USERS_VIEW) ? 'disabled' : '');
|
||||
$this->view->assign('user', \SP\Users::getUserData($this->view->itemId));
|
||||
|
||||
$this->view->assign(
|
||||
'profilesSelProp', array('name' => 'profileid',
|
||||
'id' => 'selProfile',
|
||||
'class' => '',
|
||||
'size' => 1,
|
||||
'label' => '',
|
||||
'selected' => $this->view->user['user_profileId'],
|
||||
'default' => '',
|
||||
'js' => '',
|
||||
'attribs' => array('required', $this->view->isDisabled))
|
||||
);
|
||||
|
||||
$this->view->assign(
|
||||
'groupsSelProp', array('name' => 'groupid',
|
||||
'id' => 'selGroup',
|
||||
'class' => '',
|
||||
'size' => 1,
|
||||
'label' => '',
|
||||
'selected' => $this->view->user['user_groupId'],
|
||||
'default' => '',
|
||||
'js' => '',
|
||||
'attribs' => array('required', $this->view->isDisabled))
|
||||
);
|
||||
|
||||
$this->view->assign('groups', \SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->view->assign('profiles', \SP\DB::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
||||
$this->view->assign('ro', ($this->view->user['checks']['user_isLdap']) ? 'READONLY' : '');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user