Files
sysPass/lib/SP/Services/UserProfile/UserProfileService.php
2017-11-27 02:31:34 +01:00

191 lines
4.3 KiB
PHP

<?php
/**
* sysPass
*
* @author nuxsmin
* @link http://syspass.org
* @copyright 2012-2017, 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\Services\UserProfile;
use SP\DataModel\ItemSearchData;
use SP\DataModel\ProfileBaseData;
use SP\Services\Service;
use SP\Services\ServiceItemInterface;
use SP\Services\ServiceItemTrait;
use SP\Storage\DbWrapper;
use SP\Storage\QueryData;
/**
* Class UserProfileService
*
* @package SP\Services\UserProfile
*/
class UserProfileService extends Service implements ServiceItemInterface
{
use ServiceItemTrait;
/**
* Creates an item
*
* @return mixed
*/
public function create()
{
// TODO: Implement create() method.
}
/**
* Updates an item
*
* @param $id
* @return mixed
*/
public function update($id)
{
// TODO: Implement update() method.
}
/**
* Deletes an item
*
* @param $id
* @return mixed
*/
public function delete($id)
{
// TODO: Implement delete() method.
}
/**
* Returns the item for given id
*
* @param int $id
* @return mixed
*/
public function getById($id)
{
// TODO: Implement getById() method.
}
/**
* Returns all the items
*
* @return mixed
*/
public function getAll()
{
$query = /** @lang SQL */
'SELECT userprofile_id, userprofile_name
FROM usrProfiles
ORDER BY userprofile_name';
$Data = new QueryData();
$Data->setMapClassName(ProfileBaseData::class);
$Data->setQuery($query);
return DbWrapper::getResultsArray($Data);
}
/**
* Returns all the items for given ids
*
* @param array $ids
* @return array
*/
public function getByIdBatch(array $ids)
{
// TODO: Implement getByIdBatch() method.
}
/**
* Deletes all the items for given ids
*
* @param array $ids
* @return $this
*/
public function deleteByIdBatch(array $ids)
{
// TODO: Implement deleteByIdBatch() method.
}
/**
* Checks whether the item is in use or not
*
* @param $id int
* @return bool
*/
public function checkInUse($id)
{
// TODO: Implement checkInUse() method.
}
/**
* Checks whether the item is duplicated on updating
*
* @return bool
*/
public function checkDuplicatedOnUpdate()
{
// TODO: Implement checkDuplicatedOnUpdate() method.
}
/**
* Checks whether the item is duplicated on adding
*
* @return bool
*/
public function checkDuplicatedOnAdd()
{
// TODO: Implement checkDuplicatedOnAdd() method.
}
/**
* Searches for items by a given filter
*
* @param ItemSearchData $SearchData
* @return mixed
*/
public function search(ItemSearchData $SearchData)
{
$Data = new QueryData();
$Data->setSelect('userprofile_id, userprofile_name');
$Data->setFrom('usrProfiles');
$Data->setOrder('userprofile_name');
if ($SearchData->getSeachString() !== '') {
$Data->setWhere('userprofile_name LIKE ?');
$search = '%' . $SearchData->getSeachString() . '%';
$Data->addParam($search);
}
$Data->setLimit('?,?');
$Data->addParam($SearchData->getLimitStart());
$Data->addParam($SearchData->getLimitCount());
DbWrapper::setFullRowCount();
$queryRes = DbWrapper::getResultsArray($Data);
$queryRes['count'] = $Data->getQueryNumRows();
return $queryRes;
}
}