Exemple #1
0
    /**
     * changeproviderareaorder
     * This function changes the order of the providers' areas that are attached to a subscriber
     *
     * @param subscriber string     name of the subscriber
     * @param providerorder array   array of sorted provider ids
     * @return Ajax response
     */
    public function changeproviderareaorder()
    {
        $this->checkAjaxToken();

        // get subscriberarea from POST
        $subscriberarea = $this->request->request->get('subscriberarea','');
        if (empty($subscriberarea)) {
            throw new Zikula_Exception_Fatal($this->__('No subscriber area passed.'));
        }

        // get subscriber module based on area and do some checks
        $subscriber = HookUtil::getOwnerByArea($subscriberarea);
        if (empty($subscriber)) {
            throw new Zikula_Exception_Fatal($this->__f('Module "%s" is not a valid subscriber.', $subscriber));
        }
        if (!ModUtil::available($subscriber)) {
            throw new Zikula_Exception_Fatal($this->__f('Subscriber module "%s" is not available.', $subscriber));
        }
        $this->throwForbiddenUnless(SecurityUtil::checkPermission($subscriber.'::', '::', ACCESS_ADMIN));

        // get providers' areas from POST
        $providerarea = $this->request->request->get('providerarea','');
        if (!(is_array($providerarea) && count($providerarea) > 0)) {
            throw new Zikula_Exception_Fatal($this->__('Providers\' areas order is not an array.'));
        }

        // set sorting
        HookUtil::setBindOrder($subscriberarea, $providerarea);

        $ol_id = $this->request->request->get('ol_id','');

        return new Zikula_Response_Ajax(array('result' => true, 'ol_id' => $ol_id));
    }