| @@ 154-181 (lines=28) @@ | ||
| 151 | * |
|
| 152 | * @return int |
|
| 153 | */ |
|
| 154 | public function addSection(Array $sectionData) |
|
| 155 | { |
|
| 156 | // check if section already exists |
|
| 157 | if ($this->getSectionId($sectionData['name']) > 0) { |
|
| 158 | return 0; |
|
| 159 | } |
|
| 160 | ||
| 161 | $nextId = $this->config->getDb()->nextId(Db::getTablePrefix().'faqsections', 'id'); |
|
| 162 | $sectionData = $this->checkSectionData($sectionData); |
|
| 163 | $insert = sprintf(" |
|
| 164 | INSERT INTO |
|
| 165 | %sfaqsections |
|
| 166 | (id, name, description) |
|
| 167 | VALUES |
|
| 168 | (%d, '%s', '%s')", |
|
| 169 | Db::getTablePrefix(), |
|
| 170 | $nextId, |
|
| 171 | $sectionData['name'], |
|
| 172 | $sectionData['description'] |
|
| 173 | ); |
|
| 174 | ||
| 175 | $res = $this->config->getDb()->query($insert); |
|
| 176 | if (!$res) { |
|
| 177 | return 0; |
|
| 178 | } |
|
| 179 | ||
| 180 | return $nextId; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Changes the section data of the given section. |
|
| @@ 271-299 (lines=29) @@ | ||
| 268 | * |
|
| 269 | * @return int |
|
| 270 | */ |
|
| 271 | public function addGroup(Array $groupData) |
|
| 272 | { |
|
| 273 | // check if group already exists |
|
| 274 | if ($this->getGroupId($groupData['name']) > 0) { |
|
| 275 | return 0; |
|
| 276 | } |
|
| 277 | ||
| 278 | $nextId = $this->config->getDb()->nextId(Db::getTablePrefix().'faqgroup', 'group_id'); |
|
| 279 | $groupData = $this->checkGroupData($groupData); |
|
| 280 | $insert = sprintf(" |
|
| 281 | INSERT INTO |
|
| 282 | %sfaqgroup |
|
| 283 | (group_id, name, description, auto_join) |
|
| 284 | VALUES |
|
| 285 | (%d, '%s', '%s', '%s')", |
|
| 286 | Db::getTablePrefix(), |
|
| 287 | $nextId, |
|
| 288 | $groupData['name'], |
|
| 289 | $groupData['description'], |
|
| 290 | (int)$groupData['auto_join'] |
|
| 291 | ); |
|
| 292 | ||
| 293 | $res = $this->config->getDb()->query($insert); |
|
| 294 | if (!$res) { |
|
| 295 | return 0; |
|
| 296 | } |
|
| 297 | ||
| 298 | return $nextId; |
|
| 299 | } |
|
| 300 | ||
| 301 | /** |
|
| 302 | * Changes the group data of the given group. |
|