Show more info about users and the ability to view users details without editing.
This commit is contained in:
nuxsmin
2013-11-07 23:00:25 +01:00
parent 5b1cb5d0ab
commit b8f4668959
9 changed files with 167 additions and 94 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
/config/config.php
/nbproject/
/res/
/backup/
/backup/
/patches/

View File

@@ -101,33 +101,34 @@ switch ($action) {
if (SP_Users::checkUserAccess("users")) {
$arrUsersTableProp = array(
"tblId" => "tblUsers",
"header" => '',
"tblHeaders" => array(
_('Nombre')
, _('Login')
, _('Perfil')
, _('Grupo')
, _('Propiedades')
, ''),
"tblRowSrc" => array(
"user_name"
, "user_login"
, "userprofile_name"
, "usergroup_name"
, array(
"user_isAdminApp" => array('img_file' => "check_blue.png", 'img_title' => _('Admin Aplicación'))
, "user_isAdminAcc" => array('img_file' => "check_orange.png", 'img_title' => _('Admin Cuentas'))
, "user_isLdap" => array('img_file' => "ldap.png", 'img_title' => _('Usuario de LDAP'))
, "user_isDisabled" => array('img_file' => "disabled.png", 'img_title' => _('Deshabilitado'))
'itemName' => _('Usuario'),
'tblId' => 'tblUsers',
'header' => '',
'tblHeaders' => array(
_('Nombre'),
_('Login'),
_('Perfil'),
_('Grupo'),
_('Propiedades'),
''),
'tblRowSrc' => array(
'user_name',
'user_login',
'userprofile_name',
'usergroup_name',
array(
'user_isAdminApp' => array('img_file' => 'check_blue.png', 'img_title' => _('Admin Aplicación')),
'user_isAdminAcc' => array('img_file' => 'check_orange.png', 'img_title' => _('Admin Cuentas')),
'user_isLdap' => array('img_file' => 'ldap.png', 'img_title' => _('Usuario de LDAP')),
'user_isDisabled' => array('img_file' => 'disabled.png', 'img_title' => _('Deshabilitado'))
)
),
"tblRowSrcId" => "user_id",
"frmId" => "frm_tblusers",
"actionId" => 1,
"newActionId" => 2,
"active" => $tplvars['active']++,
"actions" => array("edit", "del", "pass"));
'tblRowSrcId' => 'user_id',
'frmId' => 'frm_tblusers',
'actionId' => 1,
'newActionId' => 2,
'active' => $tplvars['active']++,
'actions' => array('view', 'edit', 'del', 'pass'));
echo '<DIV ID="tabs-1">';
$startTime = microtime();
@@ -141,16 +142,18 @@ switch ($action) {
}
if (SP_Users::checkUserAccess("groups")) {
$arrGroupsTableProp = array("tblId" => "tblGroups",
"header" => '',
"tblHeaders" => array(_('Nombre'), _('Descripción'), ''),
"tblRowSrc" => array("usergroup_name", "usergroup_description"),
"tblRowSrcId" => "usergroup_id",
"frmId" => "frm_tblgroups",
"actionId" => 3,
"newActionId" => 4,
"active" => $tplvars['active']++,
"actions" => array("edit", "del"));
$arrGroupsTableProp = array(
'itemName' => _('Grupo'),
'tblId' => 'tblGroups',
'header' => '',
'tblHeaders' => array(_('Nombre'), _('Descripción'), ''),
'tblRowSrc' => array('usergroup_name', 'usergroup_description'),
'tblRowSrcId' => 'usergroup_id',
'frmId' => 'frm_tblgroups',
'actionId' => 3,
'newActionId' => 4,
'active' => $tplvars['active']++,
'actions' => array('edit', 'del'));
echo '<DIV ID="tabs-2">';
@@ -166,16 +169,18 @@ switch ($action) {
}
if (SP_Users::checkUserAccess("profiles")) {
$arrProfilesTableProp = array("tblId" => "tblProfiles",
"header" => '',
"tblHeaders" => array(_('Nombre'), ''),
"tblRowSrc" => array("userprofile_name"),
"tblRowSrcId" => "userprofile_id",
"frmId" => "frm_tblprofiles",
"actionId" => 5,
"newActionId" => 6,
"active" => $tplvars['active']++,
"actions" => array("edit", "del"));
$arrProfilesTableProp = array(
'itemName' => _('Perfil'),
'tblId' => 'tblProfiles',
'header' => '',
'tblHeaders' => array(_('Nombre'), ''),
'tblRowSrc' => array('userprofile_name'),
'tblRowSrcId' => 'userprofile_id',
'frmId' => 'frm_tblprofiles',
'actionId' => 5,
'newActionId' => 6,
'active' => $tplvars['active']++,
'actions' => array('edit', 'del'));
echo '<DIV ID="tabs-3">';

View File

@@ -36,6 +36,7 @@ if ( SP_Common::parseParams('p', 'id', FALSE, TRUE) && SP_Common::parseParams('p
$tplvars['itemid'] = SP_Common::parseParams('p', 'id', 0);
$itemType = $tplvars['itemtype'] = SP_Common::parseParams('p', 'type', 0);
$tplvars['active'] = SP_Common::parseParams('p', 'active', 0);
$tplvars['view'] = SP_Common::parseParams('p', 'view', 0);
} else {
return;
}
@@ -43,30 +44,30 @@ if ( SP_Common::parseParams('p', 'id', FALSE, TRUE) && SP_Common::parseParams('p
switch ($itemType) {
case 1:
$tplvars['header'] = _('Editar Usuario');
$template = 'users';
break;
case 2:
$tplvars['header'] = _('Nuevo Usuario');
$template = 'users';
break;
case 3:
$tplvars['header'] = _('Editar Grupo');
$template = 'groups';
break;
case 4:
$tplvars['header'] = _('Nuevo Grupo');
$template = 'groups';
break;
case 5:
$tplvars['header'] = _('Editar Perfil');
$template = 'profiles';
break;
case 6:
$tplvars['header'] = _('Nuevo Perfil');
$template = 'profiles';
break;
default :
break;
}
if ($itemType == 1 || $itemType == 2) {
SP_Html::getTemplate('users', $tplvars);
} elseif ($itemType == 3 || $itemType == 4) {
SP_Html::getTemplate('groups', $tplvars);
} elseif ($itemType == 5 || $itemType == 6) {
SP_Html::getTemplate('profiles', $tplvars);
}
SP_Html::getTemplate($template, $tplvars);

View File

@@ -281,7 +281,7 @@ $maxFileSize = round(SP_Config::getValue('allowed_size') / 1024, 1);
<form method="post" enctypr="multipart/form-data" name="upload_form" id="fileUpload">
<input type="file" id="inFile" name="inFile" />
</form>
<div id="dropzone" class="round" title="<? echo _('Soltar archivos aquí (max. 5) o click para seleccionar').'<br><br>'._('Tamaño máximo de archivo').' '.$maxFileSize.' MB'; ?>">
<div id="dropzone" class="round" data-files-ext="<? echo SP_Config::getValue('allowed_exts'); ?>" title="<? echo _('Soltar archivos aquí (max. 5) o click para seleccionar').'<br><br>'._('Tamaño máximo de archivo').' '.$maxFileSize.' MB'; ?>">
<img src="imgs/upload.png" alt="upload" class="opacity50"/>
</div>
<script> dropFile(<? echo $account->accountId; ?>, '<? echo $skey; ?>', <? echo $maxFileSize; ?>); </script>

View File

@@ -87,7 +87,7 @@ $numRows = $resQueryNumRows[0]->numRows;
$description = ( $isDemoMode === 0 ) ? utf8_decode($log->log_description) : preg_replace("/\d+\.\d+\.\d+\.\d+/", "*.*.*.*", utf8_decode($log->log_description));
?>
<tr class="<? echo $rowClass ?>">
<tr class="<? echo $rowClass; ?>">
<td class="cell">
<? echo $log->log_id; ?>
</td>

View File

@@ -26,11 +26,12 @@
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
$activeTab = $data['active'];
$isView = $data['view'];
$user = SP_Users::getUserData($data['itemid']);
$isDemo = SP_Config::getValue('demoenabled', 0);
$isDisabled = ( $isDemo ) ? 'disabled' : '';
$isDisabled = ( $isDemo || $isView ) ? 'disabled' : '';
$profilesSelProp = array('name' => 'profileid',
'id' => 'selProfile',
@@ -40,7 +41,7 @@ $profilesSelProp = array('name' => 'profileid',
'selected' => $user['user_profileId'],
'default' => '',
'js' => '',
'attribs' => array('required'));
'attribs' => array('required',$isDisabled));
$groupsSelProp = array('name' => 'groupid',
'id' => 'selGroup',
@@ -50,7 +51,7 @@ $groupsSelProp = array('name' => 'groupid',
'selected' => $user['user_groupId'],
'default' => '',
'js' => '',
'attribs' => array('required'));
'attribs' => array('required',$isDisabled));
$ro = ( $user['checks']['user_isLdap'] ) ? "READONLY" : "";
?>
@@ -63,16 +64,28 @@ $ro = ( $user['checks']['user_isLdap'] ) ? "READONLY" : "";
<tr>
<td class="descField"><? echo _('Nombre') ?></td>
<td class="valField">
<input type="text" id="usrname" name="name" title="<? echo _('Nombre de usuario completo'); ?>" class="txtuser" maxlength="80" value="<? echo $user['user_name']; ?>" />
<? if ( ! $isView ): ?>
<input type="text" id="usrname" name="name" title="<? echo _('Nombre de usuario completo'); ?>" class="txtuser" maxlength="80" value="<? echo $user['user_name']; ?>" />
<?
else:
echo $user['user_name'];
endif;
?>
</td>
</tr>
<tr>
<td class="descField"><? echo _('Login'); ?></td><td class="valField">
<input type="text" id="usrlogin" name="login" title="<? echo _('Login de inicio de sesión'); ?>" class="txtlogin" maxlength="30" value="<? echo $user['user_login'] ?>" <? echo $ro; ?> />
<? if ($ro): ?>
<img src="imgs/ldap.png" title="<? echo _('Usuario de LDAP'); ?>" class="iconMini" />
<? endif; ?>
<? if ( ! $isView ): ?>
<input type="text" id="usrlogin" name="login" title="<? echo _('Login de inicio de sesión'); ?>" class="txtlogin" maxlength="30" value="<? echo $user['user_login'] ?>" <? echo $ro; ?> />
<? if ($ro): ?>
<img src="imgs/ldap.png" title="<? echo _('Usuario de LDAP'); ?>" class="iconMini" />
<? endif; ?>
<?
else:
echo $user['user_login'];
endif;
?>
</td>
</tr>
@@ -93,12 +106,18 @@ $ro = ( $user['checks']['user_isLdap'] ) ? "READONLY" : "";
<tr>
<td class="descField"><? echo _('Email'); ?></td>
<td class="valField">
<input type="text" id="usremail" name="email" title="<? echo _('Dirección de correo'); ?>" class="txtemail" maxlength="50" value="<? echo $user['user_email']; ?>" />
<? if ( ! $isView ): ?>
<input type="text" id="usremail" name="email" title="<? echo _('Dirección de correo'); ?>" class="txtemail" maxlength="50" value="<? echo $user['user_email']; ?>" />
<?
else:
echo $user['user_email'];
endif;
?>
</td>
</tr>
<? if ( $user['action'] === 1): ?>
<? if ( $user['action'] === 1 && ! $isView ): ?>
<tr>
<td class="descField"><? echo _('Clave'); ?></td>
<td class="valField">
@@ -136,26 +155,52 @@ $ro = ( $user['checks']['user_isLdap'] ) ? "READONLY" : "";
<input type="checkbox" id="usradminacc" name="adminacc" <? echo $user['checks']['user_isAdminAcc'] . ' ' . $isDisabled; ?> />
<? endif; ?>
<label for="usrdisabled" title="<? echo _('Deshabilitado'); ?>"><? echo _('Deshabilitado'); ?></label>
<input type="checkbox" id="usrdisabled" name="disabled" <? echo $user['checks']['user_isDisabled']; ?>/>
<input type="checkbox" id="usrdisabled" name="disabled" <? echo $user['checks']['user_isDisabled'] . ' ' . $isDisabled; ?>/>
</div>
</td>
</tr>
<? if ( $isView ): ?>
<tr>
<td class="descField"><? echo _('Entradas'); ?></td>
<td class="valField"> <? echo $user['user_count']; ?></td>
</tr>
<tr>
<td class="descField"><? echo _('Último Acceso'); ?></td>
<td class="valField"> <? echo $user['user_lastLogin']; ?></td>
</tr>
<tr>
<td class="descField"><? echo _('Última Modificación'); ?></td>
<td class="valField"> <? echo $user['user_lastUpdate']; ?></td>
</tr>
<tr>
<td class="descField"><? echo _('Fecha Clave Maestra'); ?></td>
<td class="valField"> <? echo $user['user_lastUpdateMPass']; ?></td>
</tr>
<? endif; ?>
</tbody>
</table>
<input type="hidden" name="active" value="<? echo $activeTab ?>" />
<input type="hidden" name="ldap" value="<? echo $user['user_isLdap']; ?>" />
<input type="hidden" name="id" value="<? echo $user['user_id']; ?>" />
<input type="hidden" name="action" value="<? echo $user['action']; ?>" />
<input type="hidden" name="type" value="<?php echo $data['itemtype']; ?>" />
<input type="hidden" name="sk" value="<? echo SP_Common::getSessionKey(TRUE) ?>">
<input type="hidden" name="is_ajax" value="1">
<? if ( ! $isView ): ?>
<input type="hidden" name="active" value="<? echo $activeTab ?>" />
<input type="hidden" name="ldap" value="<? echo $user['user_isLdap']; ?>" />
<input type="hidden" name="id" value="<? echo $user['user_id']; ?>" />
<input type="hidden" name="action" value="<? echo $user['action']; ?>" />
<input type="hidden" name="type" value="<?php echo $data['itemtype']; ?>" />
<input type="hidden" name="sk" value="<? echo SP_Common::getSessionKey(TRUE) ?>">
<input type="hidden" name="is_ajax" value="1">
<? endif; ?>
</form>
<div id="resCheck"><span id="resFancyAccion"></span></div>
<div class="action-in-box">
<ul>
<li><img src="imgs/check.png" title="<?php echo _('Guardar'); ?>" class="inputImg" OnClick="usersMgmt('frmUsers');" /></li>
</ul>
</div>
<? if ( ! $isView ): ?>
<div id="resCheck"><span id="resFancyAccion"></span></div>
<div class="action-in-box">
<ul>
<li><img src="imgs/check.png" title="<?php echo _('Guardar'); ?>" class="inputImg" OnClick="usersMgmt('frmUsers');" /></li>
</ul>
</div>
<? endif; ?>
</div>
<script>
$("#btnUserOptions").buttonset();

View File

@@ -133,7 +133,8 @@ class SP_Users {
public static function setQueryUsers($itemId = NULL) {
if (!is_null($itemId)) {
self::$querySelect = "SELECT user_id, user_name, user_login, user_profileId, user_groupId, user_email, user_notes,
user_isAdminApp, user_isAdminAcc, user_isLdap, user_isDisabled";
user_isAdminApp, user_isAdminAcc, user_isLdap, user_isDisabled, user_count, user_lastLogin,
user_lastUpdate, FROM_UNIXTIME(user_lastUpdateMPass) as user_lastUpdateMPass";
self::$queryWhere = "WHERE user_id = " . (int) $itemId . " LIMIT 1";
} else {
self::$querySelect = "SELECT user_id, user_name, user_login, userprofile_name, usergroup_name, user_isAdminApp,
@@ -224,7 +225,7 @@ class SP_Users {
echo '<div class="action fullWidth">';
echo '<ul>';
echo '<LI><img src="imgs/add.png" title="' . _('Nuevo') . '" class="inputImg" OnClick="usrgrpDetail(0,' . $arrUsersTableProp["newActionId"] . ',\'' . $sk . '\',' . $arrUsersTableProp["active"] . ');" /></LI>';
echo '<LI><img src="imgs/add.png" title="' . _('Nuevo') . ' ' . $arrUsersTableProp['itemName'] . '" class="inputImg" OnClick="usersData(0,' . $arrUsersTableProp["newActionId"] . ',\'' . $sk . '\',' . $arrUsersTableProp["active"] . ');" /></LI>';
echo '</ul>';
echo '</div>';
@@ -255,8 +256,9 @@ class SP_Users {
$intId = $item->$arrUsersTableProp["tblRowSrcId"];
$action_check = array();
$lnkEdit = '<img src="imgs/edit.png" title="' . _('Editar') . '" class="inputImg" Onclick="return usrgrpDetail(' . $intId . ',' . $arrUsersTableProp["actionId"] . ',\'' . $sk . '\', ' . $arrUsersTableProp["active"] . ');" />';
$lnkDel = '<img src="imgs/delete.png" title="' . _('Eliminar') . '" class="inputImg" Onclick="return usersMgmt(' . $arrUsersTableProp["active"] . ', 1,' . $intId . ',' . $arrUsersTableProp["actionId"] . ',\'' . $sk . '\', ' . $arrUsersTableProp["active"] . ');" />';
$lnkView = '<img src="imgs/view.png" title="' . _('Ver Detalles') . '" class="inputImg" Onclick="return usersData(' . $intId . ',' . $arrUsersTableProp["actionId"] . ',\'' . $sk . '\', ' . $arrUsersTableProp["active"] . ',1);" />';
$lnkEdit = '<img src="imgs/edit.png" title="' . _('Editar') . ' ' . $arrUsersTableProp['itemName'] . '" class="inputImg" Onclick="return usersData(' . $intId . ',' . $arrUsersTableProp["actionId"] . ',\'' . $sk . '\', ' . $arrUsersTableProp["active"] . ');" />';
$lnkDel = '<img src="imgs/delete.png" title="' . _('Eliminar') . ' ' . $arrUsersTableProp['itemName'] . '" class="inputImg" Onclick="return usersMgmt(' . $arrUsersTableProp["active"] . ', 1,' . $intId . ',' . $arrUsersTableProp["actionId"] . ',\'' . $sk . '\', ' . $arrUsersTableProp["active"] . ');" />';
$lnkPass = '<img src="imgs/key.png" title="' . _('Cambiar clave') . '" class="inputImg" Onclick="return usrUpdPass(' . $intId . ');" />';
echo '<ul>';
@@ -282,6 +284,9 @@ class SP_Users {
echo '<li class="cell-actions round" style="width: ' . $cellWidth . '%;">';
foreach ($arrUsersTableProp["actions"] as $action) {
switch ($action) {
case "view":
echo $lnkView;
break;
case "edit":
echo $lnkEdit;
break;
@@ -317,6 +322,10 @@ class SP_Users {
'user_isAdminAcc' => 0,
'user_isLdap' => 0,
'user_isDisabled' => 0,
'user_count' => 0,
'user_lastLogin' => '',
'user_lastUpdate' => '',
'user_lastUpdateMPass' => 0,
'action' => 1);
if ($id > 0) {
@@ -331,7 +340,11 @@ class SP_Users {
if (preg_match('/^.*_is[A-Z].*$/', $name)) {
$user['checks'][$name] = ( (int) $value === 1 ) ? 'CHECKED' : '';
}
if ( $value === '0000-00-00 00:00:00' || $value === '1970-01-01 01:00:00' ){
$value = _('N/D');
}
$user[$name] = $value;
}
}
@@ -961,9 +974,10 @@ class SP_Users {
* @return bool
*/
private function setUserLastLogin() {
$query = "UPDATE usrData SET "
. "user_lastLogin = NOW() "
. "WHERE user_id = " . (int) $this->userId . " LIMIT 1";
$query = 'UPDATE usrData SET '
. 'user_lastLogin = NOW(), '
. 'user_count = (user_count + 1) '
. 'WHERE user_id = ' . (int) $this->userId . ' LIMIT 1';
if (DB::doQuery($query, __FUNCTION__) === FALSE) {
return FALSE;

View File

@@ -507,13 +507,15 @@ function delFile(id, sk, accid){
}
function dropFile(accountId, sk, maxsize){
var dropbox = $('#dropzone');
dropbox.filedrop({
var dropfiles = $('#dropzone');
var file_exts_ok = dropfiles.attr('data-files-ext').toLowerCase().split(',');
dropfiles.filedrop({
fallback_id: 'inFile',
paramname: 'inFile', // $_FILES name
maxfiles: 5,
maxfilesize: maxsize, // in mb
allowedfileextensions: file_exts_ok,
url: APP_ROOT + '/ajax/ajax_files.php',
data: {
sk: sk,
@@ -540,6 +542,9 @@ function dropFile(accountId, sk, maxsize){
case 'FileTooLarge':
resMsg("error", LANG[27] + ' ' + maxsize + ' MB' + '<br>' + file.name);
break;
case 'FileExtensionNotAllowed':
resMsg("error", LANG[28]);
break;
default:
break;
}
@@ -552,8 +557,8 @@ function dropFile(accountId, sk, maxsize){
// Función para mostrar los registros de usuarios y grupos
function usrgrpDetail(id, type, sk, active){
var data = {'id' : id, 'type' : type, 'sk' : sk, 'active' : active};
function usersData(id, type, sk, active, view){
var data = {'id' : id, 'type' : type, 'sk' : sk, 'active' : active, 'view' : view};
var url = APP_ROOT + '/ajax/ajax_usersMgmt.php';
$.fancybox.showLoading();

View File

@@ -62,7 +62,8 @@ $locale= array(
'Eliminar archivo?',
'Su navegador no soporta subir archivos con HTML5',
'Demasiados archivos',
'No es posible guardar el archivo.<br>Tamaño máximo:'),
'No es posible guardar el archivo.<br>Tamaño máximo:',
'Extensión no permitida'),
"en_us" => array('Query error',
'There was an error',
'Session ended',
@@ -90,7 +91,8 @@ $locale= array(
'Delete file?',
'Your browser does not support HTML5 file uploads.',
'Too many files',
'Unable to save file.<br>Max file size:'));
'Unable to save file.<br>Max file size:',
'Extension not allowed'));
$arrJsLang = array();