summaryrefslogtreecommitdiffstats
path: root/application/controllers/api
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-09-18 12:13:12 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-09-18 12:13:12 +0200
commitb0e09e9db4cef075491ef683d89390faa2e6b8c3 (patch)
tree32799b1aed99f9e1632569e9b183117fd284e1ca /application/controllers/api
parent7a2ef40a39c3d9f34240453db8305e6607005089 (diff)
Remove unsupported secondary controller
Having more than one controller per request doesn't work with CI3. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/api')
-rw-r--r--application/controllers/api/api_controller.php6
-rw-r--r--application/controllers/api/v2/file.php30
-rw-r--r--application/controllers/api/v2/user.php30
3 files changed, 35 insertions, 31 deletions
diff --git a/application/controllers/api/api_controller.php b/application/controllers/api/api_controller.php
index 2b9054b17..d615d6cec 100644
--- a/application/controllers/api/api_controller.php
+++ b/application/controllers/api/api_controller.php
@@ -9,6 +9,10 @@
namespace controllers\api;
-abstract class api_controller extends \CI_Controller {
+abstract class api_controller {
+ public function __construct() {
+ $this->CI =& get_instance();
+ }
+
}
diff --git a/application/controllers/api/v2/file.php b/application/controllers/api/v2/file.php
index 15a43fc45..3d4103f1c 100644
--- a/application/controllers/api/v2/file.php
+++ b/application/controllers/api/v2/file.php
@@ -13,13 +13,13 @@ class file extends \controllers\api\api_controller {
{
parent::__construct();
- $this->load->model('mfile');
- $this->load->model('mmultipaste');
+ $this->CI->load->model('mfile');
+ $this->CI->load->model('mmultipaste');
}
public function upload()
{
- $this->muser->require_access("basic");
+ $this->CI->muser->require_access("basic");
$files = getNormalizedFILES();
@@ -29,12 +29,12 @@ class file extends \controllers\api\api_controller {
\service\files::verify_uploaded_files($files);
- $limits = $this->muser->get_upload_id_limits();
- $userid = $this->muser->get_userid();
+ $limits = $this->CI->muser->get_upload_id_limits();
+ $userid = $this->CI->muser->get_userid();
$urls = array();
foreach ($files as $file) {
- $id = $this->mfile->new_id($limits[0], $limits[1]);
+ $id = $this->CI->mfile->new_id($limits[0], $limits[1]);
\service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $file["name"]);
$ids[] = $id;
$urls[] = site_url($id).'/';
@@ -49,7 +49,7 @@ class file extends \controllers\api\api_controller {
public function get_config()
{
return array(
- "upload_max_size" => $this->config->item("upload_max_size"),
+ "upload_max_size" => $this->CI->config->item("upload_max_size"),
"max_files_per_request" => intval(ini_get("max_file_uploads")),
"max_input_vars" => intval(ini_get("max_input_vars")),
"request_max_size" => return_bytes(ini_get("post_max_size")),
@@ -58,8 +58,8 @@ class file extends \controllers\api\api_controller {
public function history()
{
- $this->muser->require_access("apikey");
- $history = \service\files::history($this->muser->get_userid());
+ $this->CI->muser->require_access("apikey");
+ $history = \service\files::history($this->CI->muser->get_userid());
foreach ($history['multipaste_items'] as $key => $item) {
foreach ($item['items'] as $inner_key => $item) {
unset($history['multipaste_items'][$key]['items'][$inner_key]['sort_order']);
@@ -73,8 +73,8 @@ class file extends \controllers\api\api_controller {
public function delete()
{
- $this->muser->require_access("apikey");
- $ids = $this->input->post_array("ids");
+ $this->CI->muser->require_access("apikey");
+ $ids = $this->CI->input->post_array("ids");
$ret = \service\files::delete($ids);
$ret = ensure_json_keys_contain_objects($ret, array("errors", "deleted"));
@@ -84,10 +84,10 @@ class file extends \controllers\api\api_controller {
public function create_multipaste()
{
- $this->muser->require_access("basic");
- $ids = $this->input->post_array("ids");
- $userid = $this->muser->get_userid();
- $limits = $this->muser->get_upload_id_limits();
+ $this->CI->muser->require_access("basic");
+ $ids = $this->CI->input->post_array("ids");
+ $userid = $this->CI->muser->get_userid();
+ $limits = $this->CI->muser->get_upload_id_limits();
return \service\files::create_multipaste($ids, $userid, $limits);
}
diff --git a/application/controllers/api/v2/user.php b/application/controllers/api/v2/user.php
index 655dc62f3..3c2eafad0 100644
--- a/application/controllers/api/v2/user.php
+++ b/application/controllers/api/v2/user.php
@@ -13,31 +13,31 @@ class user extends \controllers\api\api_controller {
{
parent::__construct();
- $this->load->model('muser');
+ $this->CI->load->model('muser');
}
public function apikeys()
{
- $this->muser->require_access("full");
- return \service\user::apikeys($this->muser->get_userid());
+ $this->CI->muser->require_access("full");
+ return \service\user::apikeys($this->CI->muser->get_userid());
}
public function create_apikey()
{
- $username = $this->input->post("username");
- $password = $this->input->post("password");
+ $username = $this->CI->input->post("username");
+ $password = $this->CI->input->post("password");
if ($username && $password) {
- if (!$this->muser->login($username, $password)) {
+ if (!$this->CI->muser->login($username, $password)) {
throw new \exceptions\NotAuthenticatedException("user/login-failed", "Login failed");
}
}
- $this->muser->require_access("full");
+ $this->CI->muser->require_access("full");
- $userid = $this->muser->get_userid();
- $comment = $this->input->post("comment");
+ $userid = $this->CI->muser->get_userid();
+ $comment = $this->CI->input->post("comment");
$comment = $comment === false ? "" : $comment;
- $access_level = $this->input->post("access_level");
+ $access_level = $this->CI->input->post("access_level");
$key = \service\user::create_apikey($userid, $comment, $access_level);
@@ -48,16 +48,16 @@ class user extends \controllers\api\api_controller {
public function delete_apikey()
{
- $this->muser->require_access("full");
+ $this->CI->muser->require_access("full");
- $userid = $this->muser->get_userid();
- $key = $this->input->post("delete_key");
+ $userid = $this->CI->muser->get_userid();
+ $key = $this->CI->input->post("delete_key");
- $this->db->where('user', $userid)
+ $this->CI->db->where('user', $userid)
->where('key', $key)
->delete('apikeys');
- $affected = $this->db->affected_rows();
+ $affected = $this->CI->db->affected_rows();
assert($affected >= 0 && $affected <= 1);
if ($affected == 1) {