fix check of Character groups-group title by using Seminary-ID (fixes #151)

This commit is contained in:
oliver 2016-04-09 13:06:04 +02:00
parent 4e7fdd973e
commit 67f92d6174
2 changed files with 9 additions and 7 deletions

View file

@ -168,7 +168,7 @@
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$charactergroupsgroupname = $this->request->getPostParam('charactergroupsgroupname');
if($this->Charactergroups->characterGroupsgroupNameExists($charactergroupsgroupname)) {
if($this->Charactergroups->characterGroupsgroupNameExists($seminary['id'], $charactergroupsgroupname)) {
$validation = $this->Validation->addValidationResult($validation, 'charactergroupsgroupname', 'exist', true);
}
$preferred = !is_null($this->request->getPostParam('preferred'));

View file

@ -113,17 +113,19 @@
/**
* Check if a Character groups-group name already exists.
*
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
* @param int $seminaryId ID of Seminary
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
*/
public function characterGroupsgroupNameExists($name, $groupsgroupId=null)
public function characterGroupsgroupNameExists($seminaryId, $name, $groupsgroupId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsgroups '.
'WHERE name = ? OR url = ?',
'ss',
'WHERE seminary_id = ? AND (name = ? OR url = ?)',
'iss',
$seminaryId,
$name,
\nre\core\Linker::createLinkParam($name)
);