| @@ 1674-1688 (lines=15) @@ | ||
| 1671 | * |
|
| 1672 | * @return int |
|
| 1673 | */ |
|
| 1674 | public function numParent($parent_id) |
|
| 1675 | { |
|
| 1676 | $query = sprintf(' |
|
| 1677 | SELECT distinct |
|
| 1678 | id |
|
| 1679 | FROM |
|
| 1680 | %sfaqcategories |
|
| 1681 | WHERE |
|
| 1682 | parent_id = %d', |
|
| 1683 | Db::getTablePrefix(), |
|
| 1684 | $parent_id); |
|
| 1685 | $result = $this->config->getDb()->query($query); |
|
| 1686 | ||
| 1687 | return $this->config->getDb()->numRows($result); |
|
| 1688 | } |
|
| 1689 | ||
| 1690 | /** |
|
| 1691 | * Adds the category permissions for users and groups. |
|
| @@ 1315-1331 (lines=17) @@ | ||
| 1312 | * |
|
| 1313 | * @return bool |
|
| 1314 | */ |
|
| 1315 | public function deleteCategoryRelations($recordId, $recordLang) |
|
| 1316 | { |
|
| 1317 | $query = sprintf(" |
|
| 1318 | DELETE FROM |
|
| 1319 | %sfaqcategoryrelations |
|
| 1320 | WHERE |
|
| 1321 | record_id = %d |
|
| 1322 | AND |
|
| 1323 | record_lang = '%s'", |
|
| 1324 | Db::getTablePrefix(), |
|
| 1325 | $recordId, |
|
| 1326 | $recordLang |
|
| 1327 | ); |
|
| 1328 | $this->config->getDb()->query($query); |
|
| 1329 | ||
| 1330 | return true; |
|
| 1331 | } |
|
| 1332 | ||
| 1333 | /** |
|
| 1334 | * Returns an array with all data from a FAQ record. |
|
| @@ 1700-1718 (lines=19) @@ | ||
| 1697 | * |
|
| 1698 | * @return bool |
|
| 1699 | */ |
|
| 1700 | public function addNewRevision($recordId, $recordLang) |
|
| 1701 | { |
|
| 1702 | $query = sprintf(" |
|
| 1703 | INSERT INTO |
|
| 1704 | %sfaqdata_revisions |
|
| 1705 | SELECT * FROM |
|
| 1706 | %sfaqdata |
|
| 1707 | WHERE |
|
| 1708 | id = %d |
|
| 1709 | AND |
|
| 1710 | lang = '%s'", |
|
| 1711 | Db::getTablePrefix(), |
|
| 1712 | Db::getTablePrefix(), |
|
| 1713 | $recordId, |
|
| 1714 | $recordLang); |
|
| 1715 | $this->config->getDb()->query($query); |
|
| 1716 | ||
| 1717 | return true; |
|
| 1718 | } |
|
| 1719 | ||
| 1720 | /** |
|
| 1721 | * Returns the keywords of a FAQ record from the ID and language. |
|
| @@ 2233-2250 (lines=18) @@ | ||
| 2230 | * |
|
| 2231 | * @return bool |
|
| 2232 | */ |
|
| 2233 | public function deleteQuestion($questionId) |
|
| 2234 | { |
|
| 2235 | $delete = sprintf(" |
|
| 2236 | DELETE FROM |
|
| 2237 | %sfaqquestions |
|
| 2238 | WHERE |
|
| 2239 | id = %d |
|
| 2240 | AND |
|
| 2241 | lang = '%s'", |
|
| 2242 | Db::getTablePrefix(), |
|
| 2243 | $questionId, |
|
| 2244 | $this->config->getLanguage()->getLanguage() |
|
| 2245 | ); |
|
| 2246 | ||
| 2247 | $this->config->getDb()->query($delete); |
|
| 2248 | ||
| 2249 | return true; |
|
| 2250 | } |
|
| 2251 | ||
| 2252 | /** |
|
| 2253 | * Returns the visibility of a question. |
|
| @@ 2293-2313 (lines=21) @@ | ||
| 2290 | * |
|
| 2291 | * @return bool |
|
| 2292 | */ |
|
| 2293 | public function setVisibilityOfQuestion($questionId, $isVisible) |
|
| 2294 | { |
|
| 2295 | $query = sprintf(" |
|
| 2296 | UPDATE |
|
| 2297 | %sfaqquestions |
|
| 2298 | SET |
|
| 2299 | is_visible = '%s' |
|
| 2300 | WHERE |
|
| 2301 | id = %d |
|
| 2302 | AND |
|
| 2303 | lang = '%s'", |
|
| 2304 | Db::getTablePrefix(), |
|
| 2305 | $isVisible, |
|
| 2306 | $questionId, |
|
| 2307 | $this->config->getLanguage()->getLanguage() |
|
| 2308 | ); |
|
| 2309 | ||
| 2310 | $this->config->getDb()->query($query); |
|
| 2311 | ||
| 2312 | return true; |
|
| 2313 | } |
|
| 2314 | ||
| 2315 | ||
| 2316 | /** |
|
| @@ 312-329 (lines=18) @@ | ||
| 309 | * |
|
| 310 | * @return bool |
|
| 311 | */ |
|
| 312 | public function deleteGlossaryItem($id) |
|
| 313 | { |
|
| 314 | $query = sprintf(" |
|
| 315 | DELETE FROM |
|
| 316 | %sfaqglossary |
|
| 317 | WHERE |
|
| 318 | id = %d AND lang = '%s'", |
|
| 319 | Db::getTablePrefix(), |
|
| 320 | (int)$id, |
|
| 321 | $this->config->getLanguage()->getLanguage() |
|
| 322 | ); |
|
| 323 | ||
| 324 | if ($this->config->getDb()->query($query)) { |
|
| 325 | return true; |
|
| 326 | } |
|
| 327 | ||
| 328 | return false; |
|
| 329 | } |
|
| 330 | } |
|
| 331 | ||
| @@ 123-133 (lines=11) @@ | ||
| 120 | * |
|
| 121 | * @return array |
|
| 122 | */ |
|
| 123 | public function getAllInstances() |
|
| 124 | { |
|
| 125 | $select = sprintf( |
|
| 126 | 'SELECT * FROM %sfaqinstances ORDER BY id', |
|
| 127 | Db::getTablePrefix() |
|
| 128 | ); |
|
| 129 | ||
| 130 | $result = $this->config->getDb()->query($select); |
|
| 131 | ||
| 132 | return $this->config->getDb()->fetchAll($result); |
|
| 133 | } |
|
| 134 | ||
| 135 | /** |
|
| 136 | * Returns the instance. |
|
| @@ 142-153 (lines=12) @@ | ||
| 139 | * |
|
| 140 | * @return array |
|
| 141 | */ |
|
| 142 | public function getInstanceById($id) |
|
| 143 | { |
|
| 144 | $select = sprintf( |
|
| 145 | 'SELECT * FROM %sfaqinstances WHERE id = %d', |
|
| 146 | Db::getTablePrefix(), |
|
| 147 | (int)$id |
|
| 148 | ); |
|
| 149 | ||
| 150 | $result = $this->config->getDb()->query($select); |
|
| 151 | ||
| 152 | return $this->config->getDb()->fetchObject($result); |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Returns the instance. |
|
| @@ 162-173 (lines=12) @@ | ||
| 159 | * |
|
| 160 | * @return array |
|
| 161 | */ |
|
| 162 | public function getInstanceByUrl($url) |
|
| 163 | { |
|
| 164 | $select = sprintf( |
|
| 165 | "SELECT * FROM %sfaqinstances WHERE url = '%s'", |
|
| 166 | Db::getTablePrefix(), |
|
| 167 | $url |
|
| 168 | ); |
|
| 169 | ||
| 170 | $result = $this->config->getDb()->query($select); |
|
| 171 | ||
| 172 | return $this->config->getDb()->fetchObject($result); |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Returns the configuration of the given instance ID. |
|
| @@ 193-204 (lines=12) @@ | ||
| 190 | * @param $id |
|
| 191 | * @return bool |
|
| 192 | */ |
|
| 193 | public function delete($id) |
|
| 194 | { |
|
| 195 | $query = sprintf( |
|
| 196 | "DELETE FROM %sfaqmeta WHERE lang = '%s' AND id = %d", |
|
| 197 | Db::getTablePrefix(), |
|
| 198 | $this->config->getLanguage()->getLanguage(), |
|
| 199 | $id |
|
| 200 | ); |
|
| 201 | ||
| 202 | return (boolean)$this->config->getDb()->query($query); |
|
| 203 | ||
| 204 | } |
|
| 205 | } |
|
| 206 | ||
| @@ 412-431 (lines=20) @@ | ||
| 409 | * |
|
| 410 | * @return bool |
|
| 411 | */ |
|
| 412 | public function deleteNews($id) |
|
| 413 | { |
|
| 414 | $query = sprintf( |
|
| 415 | "DELETE FROM |
|
| 416 | %sfaqnews |
|
| 417 | WHERE |
|
| 418 | id = %d |
|
| 419 | AND |
|
| 420 | lang = '%s'", |
|
| 421 | Db::getTablePrefix(), |
|
| 422 | $id, |
|
| 423 | $this->_config->getLanguage()->getLanguage() |
|
| 424 | ); |
|
| 425 | ||
| 426 | if (!$this->_config->getDb()->query($query)) { |
|
| 427 | return false; |
|
| 428 | } |
|
| 429 | ||
| 430 | return true; |
|
| 431 | } |
|
| 432 | } |
|
| 433 | ||
| @@ 257-273 (lines=17) @@ | ||
| 254 | * |
|
| 255 | * @return bool |
|
| 256 | */ |
|
| 257 | public function deleteSessions(int $first, int $last): bool |
|
| 258 | { |
|
| 259 | $query = sprintf(' |
|
| 260 | DELETE FROM |
|
| 261 | %sfaqsessions |
|
| 262 | WHERE |
|
| 263 | time >= %d |
|
| 264 | AND |
|
| 265 | time <= %d', |
|
| 266 | Db::getTablePrefix(), |
|
| 267 | $first, |
|
| 268 | $last); |
|
| 269 | ||
| 270 | $this->config->getDb()->query($query); |
|
| 271 | ||
| 272 | return true; |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * Deletes all entries in the table. |
|
| @@ 275-290 (lines=16) @@ | ||
| 272 | * |
|
| 273 | * @return bool |
|
| 274 | */ |
|
| 275 | public function updateTag(EntityTags $entity) |
|
| 276 | { |
|
| 277 | $query = sprintf(" |
|
| 278 | UPDATE |
|
| 279 | %sfaqtags |
|
| 280 | SET |
|
| 281 | tagging_name = '%s' |
|
| 282 | WHERE |
|
| 283 | tagging_id = %d", |
|
| 284 | Db::getTablePrefix(), |
|
| 285 | $entity->getName(), |
|
| 286 | $entity->getId() |
|
| 287 | ); |
|
| 288 | ||
| 289 | return $this->config->getDb()->query($query); |
|
| 290 | } |
|
| 291 | ||
| 292 | /** |
|
| 293 | * Deletes all tags from a given record id. |
|