From 4fde9b79e230835e0907f96d069a1cec6f1c8a47 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 19 May 2014 02:22:15 +0200 Subject: [PATCH] * New switcheable grid visual style for searches. Closes #38 * Fixed wrong height for search results in IE 10. * Fixed not showing accounts field ordering on action switch. * Fixed some visual bugs. * Force page reload on configuration changes. * Copy account password to clipboard is hidden by default on account search list (prevents many ajax queries). * LDAP username is populated from login if it's blank. * Account decrypt counter is updated when password is viewed and not if it's copied to clipboard (working on a better solution). --- ajax/ajax_configSave.php | 5 ++ ajax/ajax_getContent.php | 2 + ajax/ajax_search.php | 69 ++++++++++++++++--------- ajax/ajax_viewpass.php | 18 +++---- css/search-grid.css | 54 ++++++++++++++++++++ css/styles.css | 25 +++++----- inc/common.class.php | 2 + inc/html.class.php | 8 ++- inc/tpl/config.php | 11 ++++ inc/util.class.php | 34 ++++++++++++- js/functions.js | 105 +++++++++++++++++++++++---------------- 11 files changed, 242 insertions(+), 91 deletions(-) create mode 100644 css/search-grid.css diff --git a/ajax/ajax_configSave.php b/ajax/ajax_configSave.php index af049b90..8538fda1 100644 --- a/ajax/ajax_configSave.php +++ b/ajax/ajax_configSave.php @@ -59,6 +59,7 @@ if ($frmAction == "config") { $frmAccountCount = SP_Common::parseParams('p', 'account_count', 10); $frmAllowedSize = SP_Common::parseParams('p', 'files_allowed_size', 1024); $frmAllowedExts = SP_Common::parseParams('p', 'files_allowed_exts'); + $frmResultsAsCards = SP_Common::parseParams('p', 'resultsascards', false, false, true); $frmWiki = SP_Common::parseParams('p', 'wiki_enabled', false, false, true); $frmWikiSearchUrl = SP_Common::parseParams('p', 'wiki_searchurl'); @@ -147,6 +148,7 @@ if ($frmAction == "config") { SP_Config::setValue("maintenance", $frmMaintenance); SP_Config::setValue("checkupdates", $frmCheckUpdates); SP_Config::setValue("files_enabled", $frmFiles); + SP_Config::setValue("resultsascards", $frmResultsAsCards); SP_Config::setValue("globalsearch", $frmGlobalSearch); SP_Config::setValue("files_allowed_size", $frmAllowedSize); @@ -155,6 +157,9 @@ if ($frmAction == "config") { SP_Log::wrLogInfo($message); SP_Common::sendEmail($message); + // Recargar la aplicación completa para establecer nuevos valores + SP_Util::reload(); + SP_Common::printJSON(_('Configuración actualizada'), 0, $doActionOnClose); } elseif ($frmAction == "crypt") { $currentMasterPass = SP_Common::parseParams('p', 'curMasterPwd', '', false, false, false); diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index fbf972de..f8a53d6b 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -32,6 +32,8 @@ if (!SP_Init::isLoggedIn()) { SP_Util::logout(); } +SP_Util::checkReload(); + if (SP_Common::parseParams('p', 'action', '', true)) { $action = $tplvars['action'] = SP_Common::parseParams('p', 'action'); $itemId = $tplvars['id'] = SP_Common::parseParams('p', 'id', 0); diff --git a/ajax/ajax_search.php b/ajax/ajax_search.php index 3f5ff640..2948ec19 100644 --- a/ajax/ajax_search.php +++ b/ajax/ajax_search.php @@ -51,6 +51,7 @@ if ($wikiEnabled) { $wikiPageUrl = SP_Config::getValue('wiki_pageurl'); } $requestEnabled = SP_Util::mailrequestIsEnabled(); +$maxTextLength = (SP_Util::resultsCardsIsEnabled()) ? 30 : 60; // Valores POST $sortKey = SP_Common::parseParams('p', 'skey', 0); @@ -68,6 +69,26 @@ $userId = SP_Common::parseParams('s', 'uid', 0); $filterOn = ($sortKey > 1 || $customerId || $categoryId || $searchTxt) ? true : false; +$colors = array( + 'FF66CC', + 'FF99FF', + 'CC99FF', + '9999FF', + '6699FF', + '3399FF', + '0099FF', + '6699FF', + '3399FF', + '00CC66', + '00CC66', + '00CC99', + '00CCCC', + 'FFCC66', + 'FF9999', + 'FF6699', + 'FF99CC' +); + $objAccount = new SP_Account; $arrSearchFilter = array("txtSearch" => $searchTxt, "userId" => $userId, @@ -133,23 +154,24 @@ foreach ($resQuery as $account) { $show = ($accView || $accViewPass || $accEdit || $accCopy || $accDel); - $randomRGB = array(rand(150, 210), rand(150, 210), rand(150, 210)); - $color = array($account->account_customerId => array(SP_Html::rgb2hex($randomRGB), $randomRGB)); + //$randomRGB = array(rand(150, 210), rand(150, 210), rand(150, 210)); + //$color = array($account->account_customerId => array(SP_Html::rgb2hex($randomRGB), $randomRGB)); + $color = array_rand($colors); if (!isset($customerColor)) { - $customerColor = $color; + $customerColor[$account->account_customerId] = '#'.$colors[$color]; } elseif (isset($customerColor) && !array_key_exists($account->account_customerId, $customerColor)) { - $customerColor = $color; + $customerColor[$account->account_customerId] = '#'.$colors[$color]; } - $hexColor = $customerColor[$account->account_customerId][0]; - //$rgbaColor = implode(',',$customerColor[$account->account_customerId][1]).',0.1'; + //$hexColor = $customerColor[$account->account_customerId][0]; + $hexColor = $customerColor[$account->account_customerId]; if ($wikiEnabled) { $wikiLink = $wikiSearchUrl . $account->customer_name; - $customerName = '' . SP_Html::truncate($account->customer_name, 31) . ''; + $customerName = '' . SP_Html::truncate($account->customer_name, $maxTextLength) . ''; } else { - $customerName = SP_Html::truncate($account->customer_name, 31); + $customerName = SP_Html::truncate($account->customer_name, $maxTextLength); } if ($accountLink && $show) { @@ -163,14 +185,15 @@ foreach ($resQuery as $account) { $accountName = $account->account_name; } + // Obtenemos datos si el usuario tiene acceso a los datos de la cuenta if ($show) { - $vacLogin = (strlen($account->account_login) >= 31) ? SP_Html::truncate($account->account_login, 31) : $account->account_login; + $vacLogin = (strlen($account->account_login) >= $maxTextLength) ? SP_Html::truncate($account->account_login, $maxTextLength) : $account->account_login; $strAccUrl = $account->account_url; $urlIsLink = ($strAccUrl && preg_match("#^https?://.*#i", $strAccUrl)); - if (strlen($strAccUrl) >= 31) { - $strAccUrl_short = SP_Html::truncate($strAccUrl, 31); + if (strlen($strAccUrl) >= $maxTextLength) { + $strAccUrl_short = SP_Html::truncate($strAccUrl, $maxTextLength); $strAccUrl = ($urlIsLink) ? '' . $strAccUrl_short . '' : $strAccUrl_short; } else { @@ -200,28 +223,29 @@ foreach ($resQuery as $account) { //echo '
'; echo '