* [DEV] Improved search filters

* [DEV] Fixed public links searching
This commit is contained in:
nuxsmin
2016-11-07 18:29:16 +01:00
parent 5a8699fe45
commit ffe2165d3f
8 changed files with 49 additions and 28 deletions

View File

@@ -484,7 +484,7 @@ class AccountSearch
*/
private function analyzeQueryString()
{
preg_match('/(user|group|file|tag|expired):(.*)/i', $this->txtSearch, $filters);
preg_match('/(user|group|file|tag|expired|private|owner|maingroup):(.*)/i', $this->txtSearch, $filters);
if (!is_array($filters) || count($filters) === 0) {
return [];
@@ -497,23 +497,39 @@ class AccountSearch
$UserData = User::getItem()->getByLogin($filters[2])->getItemData();
$filtersData[] = [
'type' => 'user',
'query' => 'account_userId = ? OR accuser_userId ?',
'values' => [$UserData->getUserId(), $UserData->getUserId()]
'query' => 'account_userId = ? OR account_id IN (SELECT accuser_accountId AS accountId FROM accUsers WHERE accuser_accountId = account_id AND accuser_userId = ? UNION ALL SELECT accgroup_accountId AS accountId FROM accGroups WHERE accgroup_accountId = account_id AND accgroup_groupId = ?)',
'values' => [$UserData->getUserId(), $UserData->getUserId(), $UserData->getUserGroupId()]
];
break;
case 'owner':
$UserData = User::getItem()->getByLogin($filters[2])->getItemData();
$filtersData[] = [
'type' => 'user',
'query' => 'account_userId = ?',
'values' => [$UserData->getUserId()]
];
break;
case 'group':
$GroupData = GroupUtil::getGroupIdByName($filters[2]);
$filtersData[] = [
'type' => 'group',
'query' => 'account_userGroupId = ? OR accgroup_groupId ?',
'query' => 'account_userGroupId = ? OR account_id IN (SELECT accgroup_accountId AS accountId FROM accGroups WHERE accgroup_accountId = account_id AND accgroup_groupId = ?)',
'values' => [$GroupData->getUsergroupId(), $GroupData->getUsergroupId()]
];
break;
case 'maingroup':
$GroupData = GroupUtil::getGroupIdByName($filters[2]);
$filtersData[] = [
'type' => 'group',
'query' => 'account_userGroupId = ?',
'values' => [$GroupData->getUsergroupId()]
];
break;
case 'file':
$filtersData[] = [
'type' => 'group',
'query' => 'accfile_name LIKE ?',
'values' => [$filters[2]]
'type' => 'file',
'query' => 'account_id IN (SELECT accfile_accountId FROM accFiles WHERE accfile_name LIKE ?)',
'values' => ['%' . $filters[2] . '%']
];
break;
case 'tag':
@@ -532,6 +548,14 @@ class AccountSearch
'values' => []
];
break;
case 'private':
$filtersData[] =
[
'type' => 'private',
'query' => 'account_isPrivate = 1 AND account_userId = ?',
'values' => [Session::getUserId()]
];
break;
default:
return $filtersData;
}

View File

@@ -739,13 +739,13 @@ class Grids implements ActionsInterface
$GridHeaders->addHeader(_('Visitas'));
$GridData = new DataGridData();
$GridData->setDataRowSourceId('publicLink_id');
$GridData->addDataRowSource('publicLink_account');
$GridData->addDataRowSource('publicLink_dateAdd');
$GridData->addDataRowSource('publicLink_dateExpire');
$GridData->addDataRowSource('publicLink_user');
$GridData->addDataRowSource('publicLink_notify');
$GridData->addDataRowSource('publicLink_views');
$GridData->setDataRowSourceId('publicLink_itemId');
$GridData->addDataRowSource('accountName');
$GridData->addDataRowSource('dateAdd');
$GridData->addDataRowSource('dateExpire');
$GridData->addDataRowSource('userLogin');
$GridData->addDataRowSource('notify');
$GridData->addDataRowSource('countViews');
$Grid = new DataGridTab();
$Grid->setId('tblLinks');

View File

@@ -41,7 +41,7 @@ class AccountSearchData extends AccountExtData
*/
public function getNumFiles()
{
return $this->num_files;
return (int)$this->num_files;
}
/**

View File

@@ -245,8 +245,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
'SELECT publicLink_id,
publicLink_hash,
publicLink_linkData
FROM publicLink
WHERE publicLink_id = ? LIMIT 1';
FROM publicLinks WHERE publicLink_id = ? LIMIT 1';
$Data = new QueryData();
$Data->setMapClassName('SP\DataModel\PublicLinkBaseData');
@@ -352,8 +351,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
'SELECT publicLink_id,
publicLink_hash,
publicLink_linkData
FROM publicLink
WHERE publicLink_hash = ? LIMIT 1';
FROM publicLinks WHERE publicLink_hash = ? LIMIT 1';
$Data = new QueryData();
$Data->setMapClassName('SP\DataModel\PublicLinkBaseData');

View File

@@ -231,18 +231,18 @@ REFERENCES `usrGroups` (`usergroup_id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
CREATE ALGORITHM=UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS select distinct `accounts`.`account_id` AS `account_id`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,`accounts`.`account_otherUserEdit` AS `account_otherUserEdit`,`accounts`.`account_otherGroupEdit` AS `account_otherGroupEdit`,`accounts`.`account_isPrivate` AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`ug`.`usergroup_name` AS `usergroup_name`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,(select count(0) from `accFiles` where (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` from (((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `customers` on((`customers`.`customer_id` = `accounts`.`account_customerId`)));
ALTER TABLE `accounts`
ADD COLUMN `account_isPrivate` BIT(1) NULL DEFAULT b'0'
AFTER `account_otherUserEdit`;
CREATE ALGORITHM=UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS select `accounts`.`account_id` AS `account_id`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,`accounts`.`account_userEditId` AS `account_userEditId`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_countView` AS `account_countView`,`accounts`.`account_countDecrypt` AS `account_countDecrypt`,`accounts`.`account_dateAdd` AS `account_dateAdd`,`accounts`.`account_dateEdit` AS `account_dateEdit`,`accounts`.`account_otherUserEdit` AS `account_otherUserEdit`,`accounts`.`account_otherGroupEdit` AS `account_otherGroupEdit`,`accounts`.`account_isPrivate` AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,`ug`.`usergroup_name` AS `usergroup_name`,`u1`.`user_name` AS `user_name`,`u1`.`user_login` AS `user_login`,`u2`.`user_name` AS `user_editName`,`u2`.`user_login` AS `user_editLogin`,`publicLinks`.`publicLink_hash` AS `publicLink_hash` from ((((((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `usrData` `u1` on((`accounts`.`account_userId` = `u1`.`user_id`))) left join `usrData` `u2` on((`accounts`.`account_userEditId` = `u2`.`user_id`))) left join `customers` on((`accounts`.`account_customerId` = `customers`.`customer_id`))) left join `publicLinks` on((`accounts`.`account_id` = `publicLinks`.`publicLink_itemId`)));
ALTER TABLE `accounts`
ADD COLUMN `account_passDate` INT UNSIGNED NULL AFTER `account_isPrivate`,
ADD COLUMN `account_passDateChange` INT UNSIGNED NULL AFTER `account_passDate`;
ALTER TABLE `accHistory`
ADD COLUMN `accHistory_passDate` INT UNSIGNED NULL AFTER `accHistory_otherGroupEdit`,
ADD COLUMN `accHistory_passDateChange` INT UNSIGNED NULL AFTER `accHistory_passDate`;
ADD COLUMN `accHistory_passDateChange` INT UNSIGNED NULL AFTER `accHistory_passDate`;
CREATE ALGORITHM=UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS select `accounts`.`account_id` AS `account_id`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,`accounts`.`account_userEditId` AS `account_userEditId`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_countView` AS `account_countView`,`accounts`.`account_countDecrypt` AS `account_countDecrypt`,`accounts`.`account_dateAdd` AS `account_dateAdd`,`accounts`.`account_dateEdit` AS `account_dateEdit`,`accounts`.`account_otherUserEdit` AS `account_otherUserEdit`,`accounts`.`account_otherGroupEdit` AS `account_otherGroupEdit`,`accounts`.`account_isPrivate` AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,`ug`.`usergroup_name` AS `usergroup_name`,`u1`.`user_name` AS `user_name`,`u1`.`user_login` AS `user_login`,`u2`.`user_name` AS `user_editName`,`u2`.`user_login` AS `user_editLogin`,`publicLinks`.`publicLink_hash` AS `publicLink_hash` from ((((((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `usrData` `u1` on((`accounts`.`account_userId` = `u1`.`user_id`))) left join `usrData` `u2` on((`accounts`.`account_userEditId` = `u2`.`user_id`))) left join `customers` on((`accounts`.`account_customerId` = `customers`.`customer_id`))) left join `publicLinks` on((`accounts`.`account_id` = `publicLinks`.`publicLink_itemId`)));
CREATE ALGORITHM=UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS select distinct `accounts`.`account_id` AS `account_id`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,`accounts`.`account_otherUserEdit` AS `account_otherUserEdit`,`accounts`.`account_otherGroupEdit` AS `account_otherGroupEdit`,`accounts`.`account_isPrivate` AS `account_isPrivate`,`accounts`.`account_passDate` AS `account_passDate`,`accounts`.`account_passDateChange` AS `account_passDateChange`,`ug`.`usergroup_name` AS `usergroup_name`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,(select count(0) from `accFiles` where (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` from (((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `customers` on((`customers`.`customer_id` = `accounts`.`account_customerId`)));

View File

@@ -1 +1 @@
.dtp{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.2);z-index:2000;font-size:15px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dtp>.dtp-content{background:#fff;max-width:300px;box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);max-height:520px;position:relative;left:50%}.dtp>.dtp-content>.dtp-date-view>header.dtp-header{background:#607d8b;color:#fff;text-align:center;padding:.3em}.dtp div.dtp-date,.dtp div.dtp-time{background:#607d8b;text-align:center;color:#fff;padding:10px}.dtp div.dtp-date>div{padding:0;margin:0}.dtp div.dtp-actual-month{font-size:1.5em}.dtp div.dtp-actual-num{font-size:3em;line-height:.9}.dtp div.dtp-actual-maxtime{font-size:3em;line-height:.9}.dtp div.dtp-actual-year{font-size:1.5em;color:#fff}.dtp div.dtp-picker{padding:1em;text-align:center}.dtp div.dtp-picker-month,.dtp div.dtp-actual-time{font-weight:500;text-align:center}.dtp div.dtp-picker-month{padding-bottom:20px !important;text-transform:uppercase !important}.dtp .dtp-close{position:absolute;top:.5em;right:1em}.dtp .dtp-close>a{color:#fff}.dtp .dtp-close>a>i{font-size:1em}.dtp table.dtp-picker-days{margin:0;min-height:251px}.dtp table.dtp-picker-days,.dtp table.dtp-picker-days tr,.dtp table.dtp-picker-days tr>td{border:0}.dtp table.dtp-picker-days tr>td{font-weight:700;text-align:center;padding:.5em}.dtp table.dtp-picker-days tr>td>span.dtp-select-day{color:#bdbdbd !important;padding:.4em .5em .5em .6em}.dtp table.dtp-picker-days tr>td>a,.dtp .dtp-picker-time>a{color:#212121;text-decoration:none;padding:.4em;border-radius:5px !important}.dtp table.dtp-picker-days tr>td>a.selected{background:#607d8b;color:#fff}.dtp table.dtp-picker-days tr>th{color:#757575;text-align:center;font-weight:700;padding:.4em .3em}.dtp .p10>a{color:#fff;text-decoration:none}.dtp .p10{width:10%;display:inline-block}.dtp .p20{width:20%;display:inline-block}.dtp .p60{width:60%;display:inline-block}.dtp .p80{width:80%;display:inline-block}.dtp a.dtp-meridien-am,.dtp a.dtp-meridien-pm{position:relative;top:10px;color:#212121;font-weight:500;padding:.7em .5em;border-radius:50% !important;text-decoration:none;background:#eee;font-size:1em}.dtp .dtp-actual-meridien a.selected{background:#607d8b;color:#fff}.dtp .dtp-picker-time>.dtp-select-hour{cursor:pointer}.dtp .dtp-picker-time>.dtp-select-minute{cursor:pointer}.dtp .dtp-buttons{padding:0 1em 1em 1em;text-align:right}.dtp.hidden,.dtp .hidden{display:none}.dtp .invisible{visibility:hidden}.dtp .left{float:left}.dtp .right{float:right}.dtp .clearfix{clear:both}.dtp .center{text-align:center}
.dtp{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.2);z-index:2000;font-size:15px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dtp>.dtp-content{background:#fff;max-width:300px;box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);max-height:520px;position:relative;left:50%}.dtp>.dtp-content>.dtp-date-view>header.dtp-header{background:#607d8b;color:#fff;text-align:center;padding:.3em}.dtp div.dtp-date,.dtp div.dtp-time{background:#607d8b;text-align:center;color:#fff;padding:10px}.dtp div.dtp-date>div{padding:0;margin:0}.dtp div.dtp-actual-month{font-size:1.5em}.dtp div.dtp-actual-num{font-size:3em;line-height:.9}.dtp div.dtp-actual-maxtime{font-size:3em;line-height:.9}.dtp div.dtp-actual-year{font-size:1.5em;color:#fff}.dtp div.dtp-picker{padding:1em;text-align:center}.dtp div.dtp-picker-month,.dtp div.dtp-actual-time{font-weight:500;text-align:center}.dtp div.dtp-picker-month{padding-bottom:20px!important;text-transform:uppercase!important}.dtp .dtp-close{position:absolute;top:.5em;right:1em}.dtp .dtp-close>a{color:#fff}.dtp .dtp-close>a>i{font-size:1em}.dtp table.dtp-picker-days{margin:0;min-height:251px}.dtp table.dtp-picker-days,.dtp table.dtp-picker-days tr,.dtp table.dtp-picker-days tr>td{border:0}.dtp table.dtp-picker-days tr>td{font-weight:700;text-align:center;padding:.5em}.dtp table.dtp-picker-days tr>td>span.dtp-select-day{color:#bdbdbd!important;padding:.4em .5em .5em .6em}.dtp table.dtp-picker-days tr>td>a,.dtp .dtp-picker-time>a{color:#212121;text-decoration:none;padding:.4em;border-radius:5px!important}.dtp table.dtp-picker-days tr>td>a.selected{background:#607d8b;color:#fff}.dtp table.dtp-picker-days tr>th{color:#757575;text-align:center;font-weight:700;padding:.4em .3em}.dtp .p10>a{color:#fff;text-decoration:none}.dtp .p10{width:10%;display:inline-block}.dtp .p20{width:20%;display:inline-block}.dtp .p60{width:60%;display:inline-block}.dtp .p80{width:80%;display:inline-block}.dtp a.dtp-meridien-am,.dtp a.dtp-meridien-pm{position:relative;top:10px;color:#212121;font-weight:500;padding:.7em .5em;border-radius:50%!important;text-decoration:none;background:#eee;font-size:1em}.dtp .dtp-actual-meridien a.selected{background:#607d8b;color:#fff}.dtp .dtp-picker-time>.dtp-select-hour{cursor:pointer}.dtp .dtp-picker-time>.dtp-select-minute{cursor:pointer}.dtp .dtp-buttons{padding:0 1em 1em 1em;text-align:right}.dtp.hidden,.dtp .hidden{display:none}.dtp .invisible{visibility:hidden}.dtp .left{float:left}.dtp .right{float:right}.dtp .clearfix{clear:both}.dtp .center{text-align:center}

File diff suppressed because one or more lines are too long

View File

@@ -86,13 +86,12 @@
<div class="label-right">
<?php if ($AccountSearchItem->isShow()): ?>
<div class="account-info">
<?php if ($AccountSearchItem->isPasswordExpired()): ?>
<i class="material-icons <?php echo $icons->getIconWarning()->getClass(); ?>"
title="<?php echo _('Clave Caducada'); ?>"><?php echo $icons->getIconWarning()->getIcon(); ?></i>
<?php endif; ?>
<?php if (!$AccountSearchData->getAccountIsPrivate()): ?>
<?php if ($AccountSearchData->getAccountIsPrivate() === 0): ?>
<i id="accesses-<?php echo $AccountSearchData->getAccountId(); ?>"
class="material-icons">face</i>