Example #1
0
/**
 * Shortcut for calling a controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param bool $disableAdminCheck: disables the check for adminuser rights
 * @param bool $isAjax: if the request is an ajax request
 */
function callController($controllerName, $methodName, $urlParams, $disableAdminCheck = true, $isAjax = false)
{
    $container = createDIContainer();
    // run security checks
    $security = $container['Security'];
    runSecurityChecks($security, $isAjax, $disableAdminCheck);
    // call the controller and render the page
    $controller = $container[$controllerName];
    $response = $controller->{$methodName}($urlParams);
    echo $response->render();
}
Example #2
0
/**
 * Shortcut for calling an ajax controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param Pimple $container: an instance of a pimple container. if not passed, a
 *                           new one will be instantiated. This can be used to
 *                           set different security values prehand or simply
 *                           swap or overwrite objects in the container.
 */
function callAjaxController($controllerName, $methodName, $urlParams, $container = null)
{
    // ajax requests come with csrf checks enabled. If you pass your own container
    // dont forget to enable the csrf check though if you need it. When in doubt
    // enable the csrf check
    if ($container === null) {
        $container = createDIContainer();
        $container['Security']->setCSRFCheck(true);
        $container['Security']->setIsAdminCheck(false);
    }
    callController($controllerName, $methodName, $urlParams, $container);
}
Example #3
0
/**
 * Shortcut for calling a controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param Pimple $container: an instance of a pimple container. if not passed, a
 *                           new one will be instantiated. This can be used to
 *                           set different security values prehand or simply
 *                           swap or overwrite objects in the container.
 */
function callController($controllerName, $methodName, $urlParams, $container = null)
{
    // assume a normal request and disable admin and csrf checks. To specifically
    // enable them, pass a container with changed security object
    if ($container === null) {
        $container = createDIContainer();
    }
    // call the controller
    $controller = $container[$controllerName];
    // run security checks other annotation specific stuff
    handleAnnotations($controller, $methodName, $container);
    // render page
    $response = $controller->{$methodName}($urlParams);
    echo $response->render();
}
Example #4
0
/**
 * Shortcut for calling a controller method and printing the result
 * @param string $controllerName: the name of the controller under which it is
 *                                stored in the DI container
 * @param string $methodName: the method that you want to call
 * @param array $urlParams: an array with variables extracted from the routes
 * @param bool $disableCSRF: disables the csrf check, defaults to false
 * @param bool $disableAdminCheck: disables the check for adminuser rights
 */
function callController($controllerName, $methodName, $urlParams, $disableCSRF = false, $disableAdminCheck = true)
{
    $container = createDIContainer();
    // run security checks
    $security = $container['Security'];
    if ($disableCSRF) {
        $security->setCSRFCheck(false);
    }
    if ($disableAdminCheck) {
        $security->setIsAdminCheck(false);
    }
    $security->runChecks();
    // call the controller and render the page
    $controller = $container[$controllerName];
    $page = $controller->{$methodName}($urlParams);
    $page->printPage();
}
Example #5
0
<?php

/**
* ownCloud - App Template Example
*
* @author Bernhard Posselt
* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com 
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\AppTemplateAdvanced;

require_once \OC_App::getAppPath('apptemplate_advanced') . '/appinfo/bootstrap.php';
$container = createDIContainer();
$security = $container['Security'];
$security->runChecks();
$controller = $container['SettingsController'];
return $controller->index()->render();