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
|
// Get params and validate them
|
||||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
$charactergroupname = $this->request->getPostParam('charactergroupname');
|
$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);
|
$validation = $this->Validation->addValidationResult($validation, 'charactergroupname', 'exist', true);
|
||||||
}
|
}
|
||||||
$motto = $this->request->getPostParam('motto');
|
$motto = $this->request->getPostParam('motto');
|
||||||
|
|
@ -615,7 +615,7 @@
|
||||||
// Get params and validate them
|
// Get params and validate them
|
||||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
$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'];
|
$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);
|
$validation = $this->Validation->addValidationResult($validation, 'charactergroupname', 'exist', true);
|
||||||
}
|
}
|
||||||
$motto = $this->request->getPostParam('motto');
|
$motto = $this->request->getPostParam('motto');
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@
|
||||||
// Get params and validate them
|
// Get params and validate them
|
||||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
$title = $this->request->getPostParam('title');
|
$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);
|
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||||
}
|
}
|
||||||
$xps = $this->request->getPostParam('xps');
|
$xps = $this->request->getPostParam('xps');
|
||||||
|
|
@ -453,7 +453,7 @@
|
||||||
// Get params and validate them
|
// Get params and validate them
|
||||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
$title = $this->request->getPostParam('title');
|
$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);
|
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
|
||||||
}
|
}
|
||||||
$xps = $this->request->getPostParam('xps');
|
$xps = $this->request->getPostParam('xps');
|
||||||
|
|
|
||||||
|
|
@ -372,17 +372,19 @@
|
||||||
/**
|
/**
|
||||||
* Check if a Character group name already exists.
|
* Check if a Character group name already exists.
|
||||||
*
|
*
|
||||||
* @param string $name Name to check
|
* @param int $groupsgroupId ID of Character groups-group
|
||||||
* @param int $groupsgroupId Do not check this ID (for editing)
|
* @param string $name Name to check
|
||||||
* @return boolean Whether name exists or not
|
* @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(
|
$data = $this->db->query(
|
||||||
'SELECT id '.
|
'SELECT id '.
|
||||||
'FROM charactergroups '.
|
'FROM charactergroups '.
|
||||||
'WHERE name = ? OR url = ?',
|
'WHERE charactergroupsgroup_id = ? AND (name = ? OR url = ?)',
|
||||||
'ss',
|
'iss',
|
||||||
|
$groupsgroupId,
|
||||||
$name,
|
$name,
|
||||||
\nre\core\Linker::createLinkParam($name)
|
\nre\core\Linker::createLinkParam($name)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -213,17 +213,19 @@
|
||||||
/**
|
/**
|
||||||
* Check if a Character groups Quest title already exists.
|
* Check if a Character groups Quest title already exists.
|
||||||
*
|
*
|
||||||
* @param string $name Character groups Quest title to check
|
* @param int $groupsgroupId ID of Character groups-group
|
||||||
* @param int $questId Do not check this ID (for editing)
|
* @param string $name Character groups Quest title to check
|
||||||
* @return boolean Whether Character groups Quest title exists or not
|
* @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(
|
$data = $this->db->query(
|
||||||
'SELECT id '.
|
'SELECT id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE title = ? OR url = ?',
|
'WHERE charactergroupsgroup_id = ? AND (title = ? OR url = ?)',
|
||||||
'ss',
|
'iss',
|
||||||
|
$groupsgroupId,
|
||||||
$title,
|
$title,
|
||||||
\nre\core\Linker::createLinkParam($title)
|
\nre\core\Linker::createLinkParam($title)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue