allow() public method

Allow certain callback.
public allow ( string $callable_name, $permission_required = '' ) : ServerRequest
$callable_name string
return ServerRequest
Esempio n. 1
0
    public function testExecute()
    {
        // test func
        $this->setToken();
        $this->object->allow('min');
        $this->assertEquals(min($this->args), $this->object->execute());

        // test static method
        $sr = new ServerRequest(array('NonConstructorTest', 'staticTic'));
        $sr->allow('NonConstructorTest::staticTic');
        $this->assertEquals('toc', $sr->execute());

        $num = mt_rand();
        $add = mt_rand();
        $sr = new ServerRequest(array('ConstructorTest', 'getNum'), array($num, $add));
        $sr->allow('ConstructorTest::getNum');
        $this->assertEquals($num + $add, $sr->execute());
    }
Esempio n. 2
0
require_once WWW_DIR . '/classes/Extension/WidgetManager.php';
require_once LIBS_DIR . '/ArticleList/ArticleList.php';
require_once LIBS_DIR . '/MediaList/MediaList.php';
require_once LIBS_DIR . '/ImageList/ImageList.php';
require_once WWW_DIR . '/classes/GeoNames.php';
require_once WWW_DIR . '/classes/GeoMap.php';
require_once WWW_DIR . '/classes/Article.php';
require_once WWW_DIR . '/classes/ArticleData.php';

try {
    // init request
    $serverRequest = new ServerRequest($_POST['callback'],
        (array) $_POST['args']);

    // set permissions
    $serverRequest->allow('ping');
    $serverRequest->allow('ArticleList::doAction'); // checked in handler
    $serverRequest->allow('ArticleList::doData');
    $serverRequest->allow('ArticleList::getFilterIssues');
    $serverRequest->allow('ArticleList::getFilterSections');
    $serverRequest->allow('ArticleList::doOrder', 'Publish');
    $serverRequest->allow('WidgetManager::AddWidget');
    $serverRequest->allow('WidgetManagerDecorator::delete');
    $serverRequest->allow('WidgetRendererDecorator::render');
    $serverRequest->allow('WidgetManagerDecorator::getSetting');
    $serverRequest->allow('WidgetContext::setWidgets');
    $serverRequest->allow('WidgetManagerDecorator::update');
    $serverRequest->allow('Topic::UpdateOrder');
    $serverRequest->allow('Geo_Names::FindCitiesByPosition');
    $serverRequest->allow('Geo_Names::FindCitiesByName');
    $serverRequest->allow('Geo_Map::LoadMapData');