web-base/core/Api/GetLanguages.class.php

37 lines
818 B
PHP
Raw Normal View History

2020-02-10 00:52:25 +01:00
<?php
namespace Api;
class GetLanguages extends Request {
2020-04-03 15:56:04 +02:00
public function __construct($user, $externalCall = false) {
parent::__construct($user, $externalCall, array());
2020-02-10 00:52:25 +01:00
}
public function execute($values = array()) {
if(!parent::execute($values)) {
return false;
}
2020-04-02 00:02:51 +02:00
$sql = $this->user->getSQL();
$res = $sql->select("uid", "code", "name")
->from("Language")
->execute();
$this->success = ($res !== FALSE);
$this->lastError = $sql->getLastError();
2020-02-10 00:52:25 +01:00
if($this->success) {
$this->result['languages'] = array();
2020-04-02 00:02:51 +02:00
if(empty($res) === 0) {
2020-02-10 00:52:25 +01:00
$this->lastError = L("No languages found");
} else {
2020-04-02 00:02:51 +02:00
foreach($res as $row) {
2020-02-10 00:52:25 +01:00
$this->result['languages'][$row['uid']] = $row;
}
}
}
return $this->success;
}
2020-04-03 15:56:04 +02:00
}