forked from deblan/side_menu
sergeng
d8072d8568
Resolve web app BSOD giving the following error due to no proper escaping. "exception":{ + "Exception":"Doctrine\\DBAL\\Exception\\InvalidFieldNameException", + "Message":"" + An exception occurred while executing a query: SQLSTATE[42703]: Undefined column: 7 ERROR: column "lang" does not exist + LINE 1: ...configvalue FROM "oc_preferences" WHERE configkey="lang" and... Signed-off-by: sergeng <sergeng@yahoo.fr>
44 lines
802 B
PHP
44 lines
802 B
PHP
<?php
|
|
|
|
namespace OCA\SideMenu\Service;
|
|
|
|
use OCP\IDBConnection;
|
|
|
|
/**
|
|
* class LangRepository.
|
|
*
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
*/
|
|
class LangRepository
|
|
{
|
|
/**
|
|
* @var IDBConnection
|
|
*/
|
|
protected $db;
|
|
|
|
public function __construct(IDBConnection $db)
|
|
{
|
|
$this->db = $db;
|
|
}
|
|
|
|
public function getUsedLangs(): array
|
|
{
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select($qb->createFunction('DISTINCT configvalue'))
|
|
->where('configkey=\'lang\' and appid=\'core\' and configvalue<>\'en\'')
|
|
->from('preferences')
|
|
;
|
|
|
|
$stmt = $qb->execute();
|
|
|
|
$langs = ['en'];
|
|
|
|
foreach ($stmt->fetchAll() as $result) {
|
|
$langs[] = $result['configvalue'];
|
|
}
|
|
|
|
return $langs;
|
|
}
|
|
}
|