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

195 lines
4.4 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\UserGroup;
use SP\DataModel\GroupData;
use SP\DataModel\ItemSearchData;
use SP\Services\Service;
use SP\Services\ServiceItemInterface;
use SP\Services\ServiceItemTrait;
use SP\Storage\DbWrapper;
use SP\Storage\QueryData;
/**
* Class UserGroupService
*
* @package SP\Services\UserGroup
*/
class UserGroupService 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 usergroup_id,
usergroup_name,
usergroup_description
FROM usrGroups
ORDER BY usergroup_name';
$Data = new QueryData();
$Data->setMapClassName(GroupData::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->setMapClassName(GroupData::class);
$Data->setSelect('usergroup_id, usergroup_name, usergroup_description');
$Data->setFrom('usrGroups');
$Data->setOrder('usergroup_name');
if ($SearchData->getSeachString() !== '') {
$Data->setWhere('usergroup_name LIKE ? OR usergroup_description LIKE ?');
$search = '%' . $SearchData->getSeachString() . '%';
$Data->addParam($search);
$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;
}
}