correctly use Character groups-group context for checking titles of Character groups and Quests (fixes #96)
This commit is contained in:
parent
45cd7e795d
commit
4b4fa1b5b3
4 changed files with 20 additions and 16 deletions
|
@ -484,7 +484,7 @@
|
|||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$charactergroupname = $this->request->getPostParam('charactergroupname');
|
||||
if($this->Charactergroups->characterGroupNameExists($charactergroupname)) {
|
||||
if($this->Charactergroups->characterGroupNameExists($groupsgroup['id'], $charactergroupname)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactergroupname', 'exist', true);
|
||||
}
|
||||
$motto = $this->request->getPostParam('motto');
|
||||
|
@ -615,7 +615,7 @@
|
|||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$charactergroupname = (count(array_intersect(array('admin','moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) ? $this->request->getPostParam('charactergroupname') : $group['name'];
|
||||
if($this->Charactergroups->characterGroupNameExists($charactergroupname, $group['id'])) {
|
||||
if($this->Charactergroups->characterGroupNameExists($groupsgroup['id'], $charactergroupname, $group['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactergroupname', 'exist', true);
|
||||
}
|
||||
$motto = $this->request->getPostParam('motto');
|
||||
|
|
|
@ -291,7 +291,7 @@
|
|||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$title = $this->request->getPostParam('title');
|
||||
if($this->Charactergroupsquests->characterGroupsQuestTitleExists($title)) {
|
||||
if($this->Charactergroupsquests->characterGroupsQuestTitleExists($groupsgroup['id'], $title)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||
}
|
||||
$xps = $this->request->getPostParam('xps');
|
||||
|
@ -453,7 +453,7 @@
|
|||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$title = $this->request->getPostParam('title');
|
||||
if($this->Charactergroupsquests->characterGroupsQuestTitleExists($title, $quest['id'])) {
|
||||
if($this->Charactergroupsquests->characterGroupsQuestTitleExists($groupsgroup['id'], $title, $quest['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||
}
|
||||
$xps = $this->request->getPostParam('xps');
|
||||
|
|
|
@ -372,17 +372,19 @@
|
|||
/**
|
||||
* Check if a Character 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 $groupsgroupId ID of Character groups-group
|
||||
* @param string $name Name to check
|
||||
* @param int $groupId Do not check this ID (for editing)
|
||||
* @return boolean Whether name exists or not
|
||||
*/
|
||||
public function characterGroupNameExists($name, $groupId=null)
|
||||
public function characterGroupNameExists($groupsgroupId, $name, $groupId=null)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id '.
|
||||
'FROM charactergroups '.
|
||||
'WHERE name = ? OR url = ?',
|
||||
'ss',
|
||||
'WHERE charactergroupsgroup_id = ? AND (name = ? OR url = ?)',
|
||||
'iss',
|
||||
$groupsgroupId,
|
||||
$name,
|
||||
\nre\core\Linker::createLinkParam($name)
|
||||
);
|
||||
|
|
|
@ -213,17 +213,19 @@
|
|||
/**
|
||||
* Check if a Character groups Quest title already exists.
|
||||
*
|
||||
* @param string $name Character groups Quest title to check
|
||||
* @param int $questId Do not check this ID (for editing)
|
||||
* @return boolean Whether Character groups Quest title exists or not
|
||||
* @param int $groupsgroupId ID of Character groups-group
|
||||
* @param string $name Character groups Quest title to check
|
||||
* @param int $questId Do not check this ID (for editing)
|
||||
* @return boolean Whether Character groups Quest title exists or not
|
||||
*/
|
||||
public function characterGroupsQuestTitleExists($title, $questId=null)
|
||||
public function characterGroupsQuestTitleExists($groupsgroupId, $title, $questId=null)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id '.
|
||||
'FROM charactergroupsquests '.
|
||||
'WHERE title = ? OR url = ?',
|
||||
'ss',
|
||||
'WHERE charactergroupsgroup_id = ? AND (title = ? OR url = ?)',
|
||||
'iss',
|
||||
$groupsgroupId,
|
||||
$title,
|
||||
\nre\core\Linker::createLinkParam($title)
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue