From 67f92d61744e4abc3efc0fc1997a3a2c47f1e9db Mon Sep 17 00:00:00 2001 From: oliver Date: Sat, 9 Apr 2016 13:06:04 +0200 Subject: [PATCH] fix check of Character groups-group title by using Seminary-ID (fixes #151) --- controllers/CharactergroupsController.inc | 2 +- models/CharactergroupsModel.inc | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/controllers/CharactergroupsController.inc b/controllers/CharactergroupsController.inc index 6809cad3..f8307d91 100644 --- a/controllers/CharactergroupsController.inc +++ b/controllers/CharactergroupsController.inc @@ -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')); diff --git a/models/CharactergroupsModel.inc b/models/CharactergroupsModel.inc index 5c237c74..ec69b6ac 100644 --- a/models/CharactergroupsModel.inc +++ b/models/CharactergroupsModel.inc @@ -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) );