src/Controller/ToolUserController.php
public function updateUserAction()
    {
        $response = [];
        $this->getEventManager()->trigger('meliscore_tooluser_save_start', $this, $response);

        $container = new Container('meliscore');

        $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
        $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_edit');
        $appConfigForm = $appConfigForm['elements'];

        $success = 0;
        $errors = [];
        $datas = [];
        $textTitle = 'tr_meliscore_tool_user';
        //$textMessage = '';

        if (!empty($container['action-tool-user-tmp'])) {
            if (!empty($container['action-tool-user-tmp']['success'])) {
                $success = $container['action-tool-user-tmp']['success'];
            }

            if (!empty($container['action-tool-user-tmp']['errors'])) {
                $errors = $container['action-tool-user-tmp']['errors'];
            }

            if (!empty($container['action-tool-user-tmp']['datas'])) {
                $datas = $container['action-tool-user-tmp']['datas'];
            }
        }

        foreach ($errors as $keyError => $valueError) {
            foreach ($appConfigForm as $keyForm => $valueForm) {
                if ($valueForm['spec']['name'] == $keyError &&
                    !empty($valueForm['spec']['options']['label'])) {
                    $errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
                }
            }
        }

        unset($container['action-tool-user-tmp']);
        unset($container['action-tool-user-setrights-tmp']);

        if ($success == 0) {
            $textMessage = 'tr_meliscore_tool_user_update_fail_info';
        } else {
            $textMessage = 'tr_meliscore_tool_user_update_success_info';
        }

        $userId = null;
        $request = $this->getRequest();
        $postData = $request->getPost()->toArray();

        if (!empty($postData['usr_id'])) {
            $userId = $postData['usr_id'];
        }

        $response = [
            'success' => $success,
            'textTitle' => $textTitle,
            'textMessage' => $textMessage,
            'errors' => $errors,
            'datas' => $datas
        ];

        $this->getEventManager()->trigger('meliscore_tooluser_save_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_UPDATE', 'itemId' => $userId]));

        return new JsonModel($response);
    }
public function updateUserAction()
    {
        $response = [];
        $this->getEventManager()->trigger('meliscore_tooluser_save_start', $this, $response);

        $container = new Container('meliscore');

        $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
        $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_edit');
        $appConfigForm = $appConfigForm['elements'];

        $success = 0;
        $errors = [];
        $datas = [];
        $textTitle = 'tr_meliscore_tool_user';
        //$textMessage = '';

        if (!empty($container['action-tool-user-tmp'])) {
            if (!empty($container['action-tool-user-tmp']['success'])) {
                $success = $container['action-tool-user-tmp']['success'];
            }

            if (!empty($container['action-tool-user-tmp']['errors'])) {
                $errors = $container['action-tool-user-tmp']['errors'];
            }

            if (!empty($container['action-tool-user-tmp']['datas'])) {
                $datas = $container['action-tool-user-tmp']['datas'];
            }
        }

        foreach ($errors as $keyError => $valueError) {
            foreach ($appConfigForm as $keyForm => $valueForm) {
                if ($valueForm['spec']['name'] == $keyError &&
                    !empty($valueForm['spec']['options']['label'])) {
                    $errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
                }
            }
        }

        unset($container['action-tool-user-tmp']);
        unset($container['action-tool-user-setrights-tmp']);

        if ($success == 0) {
            $textMessage = 'tr_meliscore_tool_user_update_fail_info';
        } else {
            $textMessage = 'tr_meliscore_tool_user_update_success_info';
        }

        $userId = null;
        $request = $this->getRequest();
        $postData = $request->getPost()->toArray();

        if (!empty($postData['usr_id'])) {
            $userId = $postData['usr_id'];
        }

        $response = [
            'success' => $success,
            'textTitle' => $textTitle,
            'textMessage' => $textMessage,
            'errors' => $errors,
            'datas' => $datas
        ];

        $this->getEventManager()->trigger('meliscore_tooluser_save_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_UPDATE', 'itemId' => $userId]));

        return new JsonModel($response);
    }
public function updateUserAction ( ) { $ response = [ ] ; $ this -> getEventManager ( ) -> trigger ( 'meliscore_tooluser_save_start' , $ this , $ response ) ; $ container = new Container ( 'meliscore' ) ; $ melisMelisCoreConfig = $ this -> serviceLocator -> get ( 'MelisCoreConfig' ) ; $ appConfigForm = $ melisMelisCoreConfig -> getItem ( 'meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_edit' ) ; $ appConfigForm = $ appConfigForm [ 'elements' ] ; $ success = 0 ; $ errors = [ ] ; $ datas = [ ] ; $ textTitle = 'tr_meliscore_tool_user' ; //$textMessage = ''; if ( ! empty ( $ container [ 'action-tool-user-tmp' ] ) ) { if ( ! empty ( $ container [ 'action-tool-user-tmp' ] [ 'success' ] ) ) { $ success = $ container [ 'action-tool-user-tmp' ] [ 'success' ] ; } if ( ! empty ( $ container [ 'action-tool-user-tmp' ] [ 'errors' ] ) ) { $ errors = $ container [ 'action-tool-user-tmp' ] [ 'errors' ] ; } if ( ! empty ( $ container [ 'action-tool-user-tmp' ] [ 'datas' ] ) ) { $ datas = $ container [ 'action-tool-user-tmp' ] [ 'datas' ] ; } } foreach ( $ errors as $ keyError => $ valueError ) { foreach ( $ appConfigForm as $ keyForm => $ valueForm ) { if ( $ valueForm [ 'spec' ] [ 'name' ] == $ keyError && ! empty ( $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ) ) { $ errors [ $ keyError ] [ 'label' ] = $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ; } } } unset ( $ container [ 'action-tool-user-tmp' ] ) ; unset ( $ container [ 'action-tool-user-setrights-tmp' ] ) ; if ( $ success == 0 ) { $ textMessage = 'tr_meliscore_tool_user_update_fail_info' ; } else { $ textMessage = 'tr_meliscore_tool_user_update_success_info' ; } $ userId = null ; $ request = $ this -> getRequest ( ) ; $ postData = $ request -> getPost ( ) -> toArray ( ) ; if ( ! empty ( $ postData [ 'usr_id' ] ) ) { $ userId = $ postData [ 'usr_id' ] ; } $ response = [ 'success' => $ success , 'textTitle' => $ textTitle , 'textMessage' => $ textMessage , 'errors' => $ errors , 'datas' => $ datas ] ; $ this -> getEventManager ( ) -> trigger ( 'meliscore_tooluser_save_end' , $ this , array_merge ( $ response , [ 'typeCode' => 'CORE_USER_UPDATE' , 'itemId' => $ userId ] ) ) ; return new JsonModel ( $ response ) ; }
Saves user account details
@return JsonModel
Saves user account details