Files
sysPass/inc/SP/Mgmt/Files/FileSearch.class.php
2016-11-14 15:33:30 +01:00

74 lines
2.3 KiB
PHP

<?php
/**
* sysPass
*
* @author nuxsmin
* @link http://syspass.org
* @copyright 2012-2016 Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace SP\Mgmt\Files;
use SP\DataModel\ItemSearchData;
use SP\Mgmt\ItemSearchInterface;
use SP\Storage\DB;
use SP\Storage\QueryData;
/**
* Class FileSearch
*
* @package SP\Mgmt\Files
*/
class FileSearch extends FileBase implements ItemSearchInterface
{
/**
* @param ItemSearchData $SearchData
* @return mixed
*/
public function getMgmtSearch(ItemSearchData $SearchData)
{
$Data = new QueryData();
$Data->setMapClassName('SP\DataModel\FileExtData');
$Data->setSelect('accfile_id, accfile_name, CONCAT(ROUND(accfile_size/1000, 2), "KB") AS accfile_size, accfile_thumb, accfile_type, account_name, customer_name');
$Data->setFrom('accFiles JOIN accounts ON account_id = accfile_accountId JOIN customers ON customer_id = account_customerId');
$Data->setOrder('accfile_name');
if ($SearchData->getSeachString() !== '') {
$Data->setWhere('accfile_name LIKE ? OR accfile_type LIKE ? OR account_name LIKE ? OR customer_name LIKE ?');
$search = '%' . $SearchData->getSeachString() . '%';
$Data->addParam($search);
$Data->addParam($search);
$Data->addParam($search);
$Data->addParam($search);
}
$Data->setLimit('?,?');
$Data->addParam($SearchData->getLimitStart());
$Data->addParam($SearchData->getLimitCount());
DB::setFullRowCount();
$queryRes = DB::getResultsArray($Data);
$queryRes['count'] = $Data->getQueryNumRows();
return $queryRes;
}
}