Zend action() access denied

For programming and general questions on Zend Framework

Zend action() access denied

Postby yaci3189 on Thu Jan 19, 2017 4:25 pm

t's my first time with zend & I work on a project developed by another person.

All works perfectly except an action which return an error 500.

In routes.ini these 3 lines are OK :

Code: Select all
routes.api_list_filter_organisations_tree.route = "api/organisations/list/filter/tree"
routes.api_list_filter_organisations_tree.defaults.controller = "Organisationsapi"
routes.api_list_filter_organisations_tree.defaults.action = "listfiltertree"


In folder Controller there is OrganisationsapiController.php & the following action() :

Code: Select all
public function listfiltertreeAction() {
    $finalData = array();
    $table = new Ruti_Db_Table_Organisations();
    $mapping = self::$JOINED_ALL_MAPPING;
    //Validation of parameters
    $filters = array(
        'organisation_mere_id' => new Ruti_Filter_Id()
    );
    $validators = array(
        'format' => array(
            new Ruti_Validate_Format(array('xml', 'json')),
            'default' => 'json'
        ),
        'sort' => new Ruti_Validate_Sort($mapping),
        'filter' => new Ruti_Validate_Filter($mapping),
        'organisation_mere_id' => array(
            new Ruti_Validate_OrganisationIdExists(),
            'allowEmpty' => true
        )
    );
    $filterInput = new Ruti_Filter_Input($filters, $validators,
            $this->getRequest()->getParams());
    $isValid = $filterInput->isValid();
    if ($isValid) {
        $data = array();
        $filter = $this->deprecatedGetProcessedFilterParameter($filterInput->getUnEscaped('filter'),
                $mapping);
        $sort = $this->deprecatedGetProcessedSortParameter($filterInput->getUnEscaped('sort'),
                $mapping);
        $organisationMereId = $filterInput->getEscaped('organisation_mere_id');
        if ($filter != null) {
            //On recherche dans l'arbre complet, de bas en haut               
            $organisations = $table->getAllJoinAllFilteredSortedPaginated(null,
                    null, $filter, $sort, true);
            $count = $table->getAllJoinAllFilteredCount($filter);
            $cache = $table->getAllJoinAllFilteredSortedPaginated();
            $root = new Ruti_Model_Organisation();
            //On crée un arbre virtuel avec une racine qui contient
            //toutes les organisations qui correspondent aux critères de filtrage
            foreach ($organisations as $organisation) {
                $this->getInvertedOrganisationTree($root, $organisation,
                        $cache);
            }
            //On crée l'arborescence pour pouvoir l'exploiter en sortie (sous forme
            //de json ou d'xml
            $tempData = $this->getTreeFromOrganisationRoot($root, $mapping);
            if (isset($tempData['children'])) {
                $data = $tempData['children'];
            }
        } else {
            //On explore l'arbre à partir du parent passé en paramètre
            $organisations = $table->getAllJoinAllFilteredSortedByParent($organisationMereId,
                    $filter,
                    $this->deprecatedGetProcessedSortParameter($filterInput->getUnEscaped('sort'),
                            $mapping));
            $count = $table->getAllJoinAllFilteredByParentCount($organisationMereId,
                    $filter);
            foreach ($organisations as $organisation) {
                $tempData = $this->deprecatedGetDataRowForColumnMapping($organisation,
                        $mapping);
                $tempData['leaf'] = ($organisation->getChildrenCount() == 0);
                $data[] = $tempData;
            }
        }
        $finalData = array(
            'success' => $isValid,
            'total' => $count,
            'children' => $data
        );
    }
    $this->writeResponse($finalData, $filterInput, $isValid);
}


I still don't understand why I get an error 500.

When I try only with URI : /api/organisations/list/filter/tree

I got this message :

Code: Select all
{"success":false,"total":1,"data":[{"error_code":40101,"error_message":"Acc\u00e8s non autoris\u00e9 \u00e0 cette fonctionnalit\u00e9"}]}


& in ErrorController.php :

Code: Select all
public function accessdeniedAction() {
        $isSuccess = false;
        $trace = array();
        $trace[] = array(
            'error_code' => 40101,
            'error_message' => $this->_translate->_('api_error_code_40101')
        );
        $this->writeJSONResponse(array(
            'success' => $isSuccess,
            'total' => count($trace),
            'data' => $trace
                ), $isSuccess, 401);
    }


Any idea about my problem ?
yaci3189
 
Posts: 1
Joined: Thu Jan 19, 2017 4:23 pm

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 2 guests