From f5fcfd66dfdac2b212e05c89625ccfe38923034d Mon Sep 17 00:00:00 2001 From: Vaidas Lungis Date: Wed, 18 Mar 2015 16:24:28 +0200 Subject: [PATCH] refactor $app->getApiAdmin to $this->di['is_admin_logged'] or $this->di['api_admin'] getApiAdmin() is deprecated --- src/bb-di.php | 12 +++++++---- src/bb-modules/Activity/Controller/Admin.php | 2 +- src/bb-modules/Client/Controller/Admin.php | 10 +++++----- src/bb-modules/Currency/Controller/Admin.php | 2 +- src/bb-modules/Email/Controller/Admin.php | 6 +++--- src/bb-modules/Embed/Controller/Admin.php | 2 +- src/bb-modules/Example/Controller/Admin.php | 8 ++++---- src/bb-modules/Extension/Controller/Admin.php | 6 +++--- .../Filemanager/Controller/Admin.php | 8 ++++---- src/bb-modules/Forum/Controller/Admin.php | 8 ++++---- src/bb-modules/Invoice/Controller/Admin.php | 20 +++++++++---------- src/bb-modules/Kb/Controller/Admin.php | 6 +++--- .../Massmailer/Controller/Admin.php | 4 ++-- src/bb-modules/News/Controller/Admin.php | 4 ++-- .../Notification/Controller/Admin.php | 2 +- src/bb-modules/Order/Controller/Admin.php | 6 +++--- src/bb-modules/Product/Controller/Admin.php | 14 ++++++------- .../Servicedomain/Controller/Admin.php | 6 +++--- .../Servicehosting/Controller/Admin.php | 6 +++--- .../Servicesolusvm/Controller/Admin.php | 6 +++--- src/bb-modules/Staff/Controller/Admin.php | 8 ++++---- src/bb-modules/Support/Controller/Admin.php | 18 ++++++++--------- src/bb-modules/System/Controller/Admin.php | 4 ++-- src/bb-modules/Theme/Controller/Admin.php | 4 ++-- .../Activity/Controller/AdminTest.php | 2 -- .../bb-modules/Email/Controller/AdminTest.php | 2 -- .../Example/Controller/AdminTest.php | 6 ------ .../Filemanager/Controller/AdminTest.php | 18 ++++------------- .../bb-modules/Theme/Controller/AdminTest.php | 13 ++++++------ 29 files changed, 99 insertions(+), 114 deletions(-) diff --git a/src/bb-di.php b/src/bb-di.php index aa9c430d7..721140aff 100644 --- a/src/bb-di.php +++ b/src/bb-di.php @@ -163,7 +163,6 @@ $di['twig'] = function () use ($di) { return $twig; }; - $di['is_client_logged'] = function() use($di) { if(!$di['auth']->isClientLoggedIn()) { throw new Exception('Client is not logged in'); @@ -171,6 +170,13 @@ $di['is_client_logged'] = function() use($di) { return true; }; +$di['is_admin_logged'] = function() use($di) { + if(!$di['auth']->isAdminLoggedIn()) { + throw new Exception('Admin is not logged in'); + } + return true; +}; + $di['loggedin_client'] = function() use ($di) { $di['is_client_logged']; $client_id = $di['session']->get('client_id'); @@ -181,9 +187,7 @@ $di['loggedin_admin'] = function() use ($di) { return $di['mod_service']('staff')->getCronAdmin(); } - if(!$di['auth']->isAdminLoggedIn()) { - throw new Exception('Admin is not logged in'); - } + $di['is_admin_logged']; $admin = $di['session']->get('admin'); return $di['db']->getExistingModelById('Admin', $admin['id']); }; diff --git a/src/bb-modules/Activity/Controller/Admin.php b/src/bb-modules/Activity/Controller/Admin.php index ddcb23031..6a61ff934 100644 --- a/src/bb-modules/Activity/Controller/Admin.php +++ b/src/bb-modules/Activity/Controller/Admin.php @@ -61,7 +61,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_activity_index'); } } \ No newline at end of file diff --git a/src/bb-modules/Client/Controller/Admin.php b/src/bb-modules/Client/Controller/Admin.php index 129f72c79..68ca4c359 100644 --- a/src/bb-modules/Client/Controller/Admin.php +++ b/src/bb-modules/Client/Controller/Admin.php @@ -83,33 +83,33 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_client_index'); } public function get_manage(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $client = $api->client_get(array('id'=>$id)); return $app->render('mod_client_manage', array('client'=>$client)); } public function get_group(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $model = $api->client_group_get(array('id'=>$id)); return $app->render('mod_client_group', array('group'=>$model)); } public function get_history(\Box_App $app) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; return $app->render('mod_client_login_history'); } public function get_login(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $api->client_login(array('id'=>$id)); $redirect_to = '/'; diff --git a/src/bb-modules/Currency/Controller/Admin.php b/src/bb-modules/Currency/Controller/Admin.php index ec44eff1f..93a271244 100644 --- a/src/bb-modules/Currency/Controller/Admin.php +++ b/src/bb-modules/Currency/Controller/Admin.php @@ -40,7 +40,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_manage(\Box_App $app, $code) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $guest_api = $this->di['api_guest']; $currency = $guest_api->currency_get(array('code'=>$code)); return $app->render('mod_currency_manage', array('currency'=>$currency)); diff --git a/src/bb-modules/Email/Controller/Admin.php b/src/bb-modules/Email/Controller/Admin.php index fd62fae85..58744961b 100644 --- a/src/bb-modules/Email/Controller/Admin.php +++ b/src/bb-modules/Email/Controller/Admin.php @@ -59,20 +59,20 @@ class Admin implements \Box\InjectionAwareInterface public function get_history(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_email_history'); } public function get_template(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $template = $api->email_template_get(array('id'=>$id)); return $app->render('mod_email_template', array('template'=>$template)); } public function get_email(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $template = $api->email_email_get(array('id'=>$id)); return $app->render('mod_email_details', array('email'=>$template)); } diff --git a/src/bb-modules/Embed/Controller/Admin.php b/src/bb-modules/Embed/Controller/Admin.php index 2ac2c654e..36978d8f0 100644 --- a/src/bb-modules/Embed/Controller/Admin.php +++ b/src/bb-modules/Embed/Controller/Admin.php @@ -54,7 +54,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_embed_index'); } } \ No newline at end of file diff --git a/src/bb-modules/Example/Controller/Admin.php b/src/bb-modules/Example/Controller/Admin.php index 0d90017a9..baca8715a 100644 --- a/src/bb-modules/Example/Controller/Admin.php +++ b/src/bb-modules/Example/Controller/Admin.php @@ -86,14 +86,14 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { // always call this method to validate if admin is logged in - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_example_index'); } public function get_test(\Box_App $app) { // always call this method to validate if admin is logged in - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $params = array(); $params['youparamname'] = 'yourparamvalue'; @@ -104,7 +104,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_user(\Box_App $app, $id) { // always call this method to validate if admin is logged in - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $params = array(); $params['userid'] = $id; @@ -114,7 +114,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_api(\Box_App $app, $id) { // always call this method to validate if admin is logged in - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $list_from_controller = $api->example_get_something(); $params = array(); diff --git a/src/bb-modules/Extension/Controller/Admin.php b/src/bb-modules/Extension/Controller/Admin.php index f8cbb710a..dbacbfd27 100644 --- a/src/bb-modules/Extension/Controller/Admin.php +++ b/src/bb-modules/Extension/Controller/Admin.php @@ -70,19 +70,19 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_extension_index'); } public function get_langs(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_extension_languages'); } public function get_settings(\Box_App $app, $mod) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $file = 'mod_'.$mod.'_settings'; return $app->render($file); } diff --git a/src/bb-modules/Filemanager/Controller/Admin.php b/src/bb-modules/Filemanager/Controller/Admin.php index 699de5330..27d9d3158 100644 --- a/src/bb-modules/Filemanager/Controller/Admin.php +++ b/src/bb-modules/Filemanager/Controller/Admin.php @@ -58,13 +58,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_filemanager_index'); } public function get_ide(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $dir = BB_PATH_ROOT . DIRECTORY_SEPARATOR; $data = array('dir'=>$dir); if(isset($_GET['inline'])) { @@ -78,7 +78,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_editor(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $file = $_GET['file']; if(!$file || !$this->di['tools']->fileExists($file)) { @@ -161,7 +161,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_icons(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $location = BB_PATH_UPLOADS.'/icons/*'; $list = array(); $files = glob($location); diff --git a/src/bb-modules/Forum/Controller/Admin.php b/src/bb-modules/Forum/Controller/Admin.php index 4b86aac37..d9874558f 100644 --- a/src/bb-modules/Forum/Controller/Admin.php +++ b/src/bb-modules/Forum/Controller/Admin.php @@ -58,27 +58,27 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_forum_index'); } public function get_forum(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $forum = $api->forum_get(array('id'=>$id)); return $app->render('mod_forum_forum', array('forum'=>$forum)); } public function get_topic(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $topic = $api->forum_topic_get(array('id'=>$id)); return $app->render('mod_forum_topic', array('topic'=>$topic)); } public function get_profile(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_forum_profile', array('client_id'=>$id)); } } \ No newline at end of file diff --git a/src/bb-modules/Invoice/Controller/Admin.php b/src/bb-modules/Invoice/Controller/Admin.php index 05e26b4cf..ed93d0b80 100644 --- a/src/bb-modules/Invoice/Controller/Admin.php +++ b/src/bb-modules/Invoice/Controller/Admin.php @@ -114,13 +114,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_taxes(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_invoice_tax'); } public function get_tax(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $tax = $api->invoice_tax_get(array('id' => $id)); return $app->render('mod_invoice_taxupdate', array('tax' => $tax)); @@ -128,52 +128,52 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_invoice_index'); } public function get_invoice(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $invoice = $api->invoice_get(array('id'=>$id)); return $app->render('mod_invoice_invoice', array('invoice'=>$invoice)); } public function get_transaction(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $tx = $api->invoice_transaction_get(array('id'=>$id)); return $app->render('mod_invoice_transaction', array('transaction'=>$tx)); } public function get_transactions(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_invoice_transactions'); } public function get_subscriptions(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_invoice_subscriptions'); } public function get_subscription(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $tx = $api->invoice_subscription_get(array('id'=>$id)); return $app->render('mod_invoice_subscription', array('subscription'=>$tx)); } public function get_gateways(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_invoice_gateways'); } public function get_gateway(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $gateway = $api->invoice_gateway_get(array('id'=>$id)); return $app->render('mod_invoice_gateway', array('gateway'=>$gateway)); } diff --git a/src/bb-modules/Kb/Controller/Admin.php b/src/bb-modules/Kb/Controller/Admin.php index d9cb1b8dd..76f78cec9 100644 --- a/src/bb-modules/Kb/Controller/Admin.php +++ b/src/bb-modules/Kb/Controller/Admin.php @@ -64,20 +64,20 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_kb_index'); } public function get_post(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $post = $api->kb_article_get(array('id'=>$id)); return $app->render('mod_kb_article', array('post'=>$post)); } public function get_cat(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $cat = $api->kb_category_get(array('id'=>$id)); return $app->render('mod_kb_category', array('category'=>$cat)); } diff --git a/src/bb-modules/Massmailer/Controller/Admin.php b/src/bb-modules/Massmailer/Controller/Admin.php index 5f4ff8e2f..248a97c87 100644 --- a/src/bb-modules/Massmailer/Controller/Admin.php +++ b/src/bb-modules/Massmailer/Controller/Admin.php @@ -56,13 +56,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_massmailer_index'); } public function get_edit(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $model = $api->massmailer_get(array('id'=>$id)); return $app->render('mod_massmailer_message', array('msg'=>$model)); } diff --git a/src/bb-modules/News/Controller/Admin.php b/src/bb-modules/News/Controller/Admin.php index aeabe9d7a..80a3d2963 100644 --- a/src/bb-modules/News/Controller/Admin.php +++ b/src/bb-modules/News/Controller/Admin.php @@ -59,13 +59,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_news_index'); } public function get_post(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $post = $api->news_get(array('id'=>$id)); return $app->render('mod_news_post', array('post'=>$post)); } diff --git a/src/bb-modules/Notification/Controller/Admin.php b/src/bb-modules/Notification/Controller/Admin.php index b1b297300..b3d7884d5 100644 --- a/src/bb-modules/Notification/Controller/Admin.php +++ b/src/bb-modules/Notification/Controller/Admin.php @@ -40,7 +40,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_notification_index'); } } \ No newline at end of file diff --git a/src/bb-modules/Order/Controller/Admin.php b/src/bb-modules/Order/Controller/Admin.php index f2247c5d8..b372c6f0c 100644 --- a/src/bb-modules/Order/Controller/Admin.php +++ b/src/bb-modules/Order/Controller/Admin.php @@ -73,13 +73,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_order_index'); } public function get_new(\Box_App $app) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $product = $api->product_get(array('id' => $this->di['request']->getPost('product_id'))); $client = $api->client_get(array('id' => $this->di['request']->getPost('client_id'))); return $app->render('mod_order_new', array('product' => $product, 'client' => $client)); @@ -87,7 +87,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_order(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $data = array( 'id' => $id, ); diff --git a/src/bb-modules/Product/Controller/Admin.php b/src/bb-modules/Product/Controller/Admin.php index 92ded2d0d..991efe713 100644 --- a/src/bb-modules/Product/Controller/Admin.php +++ b/src/bb-modules/Product/Controller/Admin.php @@ -82,33 +82,33 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_product_index'); } public function get_addons(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_product_addons'); } public function get_addon_manage(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $addon= $api->product_addon_get(array('id'=>$id)); return $app->render('mod_product_addon_manage', array('addon'=>$addon, 'product'=>$addon)); } public function get_cat_manage(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $cat= $api->product_category_get(array('id'=>$id)); return $app->render('mod_product_category', array('category'=>$cat)); } public function get_manage(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $product= $api->product_get(array('id'=>$id)); $addons = array(); @@ -121,14 +121,14 @@ class Admin implements \Box\InjectionAwareInterface public function get_promo(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $promo= $api->product_promo_get(array('id'=>$id)); return $app->render('mod_product_promo', array('promo'=>$promo)); } public function get_promos(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_product_promos'); } diff --git a/src/bb-modules/Servicedomain/Controller/Admin.php b/src/bb-modules/Servicedomain/Controller/Admin.php index e038baf73..6486c4c1a 100644 --- a/src/bb-modules/Servicedomain/Controller/Admin.php +++ b/src/bb-modules/Servicedomain/Controller/Admin.php @@ -56,20 +56,20 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_servicedomain_index'); } public function get_tld(\Box_App $app, $tld) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $m = $api->servicedomain_tld_get(array('tld'=>$tld)); return $app->render('mod_servicedomain_tld', array('tld'=>$m)); } public function get_registrar(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $registrar = $api->servicedomain_registrar_get(array('id'=>$id)); return $app->render('mod_servicedomain_registrar', array('registrar'=>$registrar)); } diff --git a/src/bb-modules/Servicehosting/Controller/Admin.php b/src/bb-modules/Servicehosting/Controller/Admin.php index eb29132d7..17caf947e 100644 --- a/src/bb-modules/Servicehosting/Controller/Admin.php +++ b/src/bb-modules/Servicehosting/Controller/Admin.php @@ -57,20 +57,20 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_servicehosting_index'); } public function get_plan(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $hp = $api->servicehosting_hp_get(array('id'=>$id)); return $app->render('mod_servicehosting_hp', array('hp'=>$hp)); } public function get_server(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $server = $api->servicehosting_server_get(array('id'=>$id)); return $app->render('mod_servicehosting_server', array('server'=>$server)); } diff --git a/src/bb-modules/Servicesolusvm/Controller/Admin.php b/src/bb-modules/Servicesolusvm/Controller/Admin.php index a1b675ede..ad76064a3 100644 --- a/src/bb-modules/Servicesolusvm/Controller/Admin.php +++ b/src/bb-modules/Servicesolusvm/Controller/Admin.php @@ -41,19 +41,19 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $app->redirect('/extension/settings/servicesolusvm'); } public function get_import_clients(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_servicesolusvm_import_clients'); } public function get_import_servers(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_servicesolusvm_import_servers'); } } \ No newline at end of file diff --git a/src/bb-modules/Staff/Controller/Admin.php b/src/bb-modules/Staff/Controller/Admin.php index 3d8587914..532315e1c 100644 --- a/src/bb-modules/Staff/Controller/Admin.php +++ b/src/bb-modules/Staff/Controller/Admin.php @@ -69,13 +69,13 @@ class Admin implements InjectionAwareInterface public function get_profile(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_staff_profile'); } public function get_manage(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $staff = $api->staff_get(array('id'=>$id)); $extensionService = $this->di['mod_service']("Extension"); @@ -85,7 +85,7 @@ class Admin implements InjectionAwareInterface public function get_group(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $group = $api->staff_group_get(array('id'=>$id)); $extensionService = $this->di['mod_service']("Extension"); @@ -94,7 +94,7 @@ class Admin implements InjectionAwareInterface } public function get_history(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_staff_login_history'); } } \ No newline at end of file diff --git a/src/bb-modules/Support/Controller/Admin.php b/src/bb-modules/Support/Controller/Admin.php index 72dc0f7b4..d58439294 100644 --- a/src/bb-modules/Support/Controller/Admin.php +++ b/src/bb-modules/Support/Controller/Admin.php @@ -93,13 +93,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_support_tickets'); } public function get_ticket(\Box_App $app, $id, $messageid = '') { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $ticket = $api->support_ticket_get(array('id'=>$id)); $cdm = ''; @@ -126,46 +126,46 @@ class Admin implements \Box\InjectionAwareInterface public function get_public_tickets(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_support_public_tickets'); } public function get_public_ticket(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $ticket = $api->support_public_ticket_get(array('id'=>$id)); return $app->render('mod_support_public_ticket', array('ticket'=>$ticket)); } public function get_helpdesk(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $helpdesk = $api->support_helpdesk_get(array('id'=>$id)); return $app->render('mod_support_helpdesk', array('helpdesk'=>$helpdesk)); } public function get_helpdesks(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_support_helpdesks'); } public function get_canned_list(\Box_App $app) { - $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_support_canned_responses'); } public function get_canned(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $c = $api->support_canned_get(array('id'=>$id)); return $app->render('mod_support_canned_response', array('response'=>$c)); } public function get_canned_cat(\Box_App $app, $id) { - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $c = $api->support_canned_category_get(array('id'=>$id)); return $app->render('mod_support_canned_category', array('category'=>$c)); } diff --git a/src/bb-modules/System/Controller/Admin.php b/src/bb-modules/System/Controller/Admin.php index bf0922d03..2d4a07213 100644 --- a/src/bb-modules/System/Controller/Admin.php +++ b/src/bb-modules/System/Controller/Admin.php @@ -64,13 +64,13 @@ class Admin implements \Box\InjectionAwareInterface public function get_index(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_system_index'); } public function get_activity(\Box_App $app) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; return $app->render('mod_system_activity'); } } \ No newline at end of file diff --git a/src/bb-modules/Theme/Controller/Admin.php b/src/bb-modules/Theme/Controller/Admin.php index 39dfe8771..d0e3bb009 100644 --- a/src/bb-modules/Theme/Controller/Admin.php +++ b/src/bb-modules/Theme/Controller/Admin.php @@ -49,7 +49,7 @@ class Admin implements \Box\InjectionAwareInterface { $this->di['events_manager']->fire(array('event' => 'onBeforeThemeSettingsSave', 'params' => $_POST)); - $api = $app->getApiAdmin(); + $api = $this->di['api_admin']; $mod = $this->di['mod']('theme'); $service = $mod->getService(); @@ -97,7 +97,7 @@ class Admin implements \Box\InjectionAwareInterface public function get_theme(\Box_App $app, $theme) { - $api = $app->getApiAdmin(); + $this->di['is_admin_logged']; $mod = $this->di['mod']('theme'); $service = $mod->getService(); diff --git a/tests/bb-modules/Activity/Controller/AdminTest.php b/tests/bb-modules/Activity/Controller/AdminTest.php index 55a781b4a..f83045d43 100644 --- a/tests/bb-modules/Activity/Controller/AdminTest.php +++ b/tests/bb-modules/Activity/Controller/AdminTest.php @@ -51,8 +51,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_index() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_activity_index'); diff --git a/tests/bb-modules/Email/Controller/AdminTest.php b/tests/bb-modules/Email/Controller/AdminTest.php index fcbc0574d..d03093251 100644 --- a/tests/bb-modules/Email/Controller/AdminTest.php +++ b/tests/bb-modules/Email/Controller/AdminTest.php @@ -32,8 +32,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_index() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_email_history'); diff --git a/tests/bb-modules/Example/Controller/AdminTest.php b/tests/bb-modules/Example/Controller/AdminTest.php index 9fa3e5ab3..e30c67560 100644 --- a/tests/bb-modules/Example/Controller/AdminTest.php +++ b/tests/bb-modules/Example/Controller/AdminTest.php @@ -53,8 +53,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_index() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_example_index'); @@ -66,8 +64,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_test() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_example_index'); @@ -79,8 +75,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_user() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_example_index'); diff --git a/tests/bb-modules/Filemanager/Controller/AdminTest.php b/tests/bb-modules/Filemanager/Controller/AdminTest.php index 60f75a270..562bfa606 100644 --- a/tests/bb-modules/Filemanager/Controller/AdminTest.php +++ b/tests/bb-modules/Filemanager/Controller/AdminTest.php @@ -52,8 +52,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_index() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_filemanager_index'); @@ -65,8 +63,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_ide() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_filemanager_ide'); @@ -82,8 +78,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_icons() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_filemanager_icons'); @@ -97,8 +91,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $controller = new \Box\Mod\Filemanager\Controller\Admin(); $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $_GET['file'] = 'notexisting.fl'; @@ -109,6 +101,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $di = new \Box_Di(); $di['tools'] = $toolsMock; + $di['is_admin_logged'] = true; $controller->setDi($di); $this->setExpectedException('\Box_Exception', 'File does not exist', 404); @@ -120,8 +113,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $controller = new \Box\Mod\Filemanager\Controller\Admin(); $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $_GET['file'] = 'index.html'; @@ -132,6 +123,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $di = new \Box_Di(); $di['tools'] = $toolsMock; + $di['is_admin_logged'] = true; $controller->setDi($di); $this->setExpectedException('\Box_Exception', 'File does not exist', 405); @@ -143,8 +135,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $controller = new \Box\Mod\Filemanager\Controller\Admin(); $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_filemanager_editor') @@ -162,6 +152,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $di = new \Box_Di(); $di['tools'] = $toolsMock; + $di['is_admin_logged'] = true; $controller->setDi($di); $result = $controller->get_editor($boxAppMock); @@ -173,8 +164,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $controller = new \Box\Mod\Filemanager\Controller\Admin(); $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->atLeastOnce()) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_filemanager_image') @@ -189,6 +178,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase { $di = new \Box_Di(); $di['tools'] = $toolsMock; + $di['is_admin_logged'] = true; $controller->setDi($di); $result = $controller->get_editor($boxAppMock); diff --git a/tests/bb-modules/Theme/Controller/AdminTest.php b/tests/bb-modules/Theme/Controller/AdminTest.php index 89187337e..e9b8f84be 100644 --- a/tests/bb-modules/Theme/Controller/AdminTest.php +++ b/tests/bb-modules/Theme/Controller/AdminTest.php @@ -32,8 +32,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testget_theme() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->exactly(1)) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('render') ->with('mod_theme_preset') @@ -79,6 +77,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase { return $modMock; } }); + $di['is_admin_logged'] = true; $controller = new \Box\Mod\Theme\Controller\Admin(); $controller->setDi($di); @@ -88,8 +87,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testsave_theme_settings() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->exactly(1)) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('redirect'); @@ -133,6 +130,9 @@ class AdminTest extends \PHPUnit_Framework_TestCase { } }); $di['events_manager'] = $eventMock; + $adminModel = new \Model_Client(); + $adminModel->loadBean(new \RedBeanPHP\OODBBean()); + $di['api_admin'] = new \Api_Handler($adminModel); $controller = new \Box\Mod\Theme\Controller\Admin(); $controller->setDi($di); @@ -146,8 +146,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase { public function testsave_theme_settings_PathIsNotWritable() { $boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock(); - $boxAppMock->expects($this->exactly(1)) - ->method('getApiAdmin'); $boxAppMock->expects($this->atLeastOnce()) ->method('redirect'); @@ -189,6 +187,9 @@ class AdminTest extends \PHPUnit_Framework_TestCase { } }); $di['events_manager'] = $eventMock; + $adminModel = new \Model_Client(); + $adminModel->loadBean(new \RedBeanPHP\OODBBean()); + $di['api_admin'] = new \Api_Handler($adminModel); $controller = new \Box\Mod\Theme\Controller\Admin(); $controller->setDi($di);