Provide the user list data via json
@return string|json
@throws Exception
@throws common_exception_InvalidArgumentType
558138
public function data()
    {
        $userService = $this->getServiceLocator()->get(tao_models_classes_UserService::class);
        $userLangService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class);
        $page = $this->getRequestParameter('page');
        $limit = $this->getRequestParameter('rows');
        $sortBy = $this->getRequestParameter('sortby');
        $sortOrder = $this->getRequestParameter('sortorder');
        $filterQuery = $this->getRequestParameter('filterquery');
        $filterColumns = $this->getRequestParameter('filtercolumns');
        $start = $limit * $page - $limit;

        $fieldsMap = [
            'login' => GenerisRdf::PROPERTY_USER_LOGIN,
            'firstname' => GenerisRdf::PROPERTY_USER_FIRSTNAME,
            'lastname' => GenerisRdf::PROPERTY_USER_LASTNAME,
            'email' => GenerisRdf::PROPERTY_USER_MAIL,
            'guiLg' => GenerisRdf::PROPERTY_USER_UILG,
            'roles' => GenerisRdf::PROPERTY_USER_ROLES
        ];
        if ($userLangService->isDataLanguageEnabled()) {
            $fieldsMap['dataLg'] = GenerisRdf::PROPERTY_USER_DEFLG;
        }

        // sorting
        $order = array_key_exists($sortBy, $fieldsMap) ? $fieldsMap[$sortBy] : $fieldsMap['login'];

        // filtering
        $filters = [
            GenerisRdf::PROPERTY_USER_LOGIN => '*',
        ];

        if ($filterQuery) {
            if (!$filterColumns) {
                // if filter columns not set, search by all columns
                $filterColumns = array_keys($fieldsMap);
            }
            $filters = array_flip(array_intersect_key($fieldsMap, array_flip($filterColumns)));
            array_walk($filters, function (&$row, $key) use($filterQuery) {
                $row = $filterQuery;
            });
        }

        $options = array(
            'recursive' => true,
            'like' => true,
            'chaining' => count($filters) > 1 ? 'or' : 'and',
            'order' => $order,
            'orderdir' => strtoupper($sortOrder),
        );

        // get total user count...
        $total = $userService->getCountUsers($options, $filters);

        // get the users using requested paging...
        $users = $userService->getAllUsers(array_merge($options, [
            'offset' => $start,
            'limit' => $limit
        ]), $filters);

        $rolesProperty = $this->getProperty(GenerisRdf::PROPERTY_USER_ROLES);

        $response = new stdClass();
        $readonly = [];
        $index = 0;

        /** @var core_kernel_classes_Resource $user */
        foreach ($users as $user) {

            $propValues = $user->getPropertiesValues(array_values($fieldsMap));

            $roles = $user->getPropertyValues($rolesProperty);
            $labels = [];

            foreach ($roles as $uri) {
                $labels[] = $this->getResource($uri)->getLabel();
            }

            $id = tao_helpers_Uri::encode($user->getUri());
            $login = (string)current($propValues[GenerisRdf::PROPERTY_USER_LOGIN]);
            $firstName = empty($propValues[GenerisRdf::PROPERTY_USER_FIRSTNAME]) ? '' : (string)current($propValues[GenerisRdf::PROPERTY_USER_FIRSTNAME]);
            $lastName = empty($propValues[GenerisRdf::PROPERTY_USER_LASTNAME]) ? '' : (string)current($propValues[GenerisRdf::PROPERTY_USER_LASTNAME]);
            $uiRes = empty($propValues[GenerisRdf::PROPERTY_USER_UILG]) ? null : current($propValues[GenerisRdf::PROPERTY_USER_UILG]);
            if ($userLangService->isDataLanguageEnabled()) {
                $dataRes = empty($propValues[GenerisRdf::PROPERTY_USER_DEFLG]) ? null : current($propValues[GenerisRdf::PROPERTY_USER_DEFLG]);
                $response->data[$index]['dataLg'] = is_null($dataRes) ? '' : $dataRes->getLabel();
            }

            $response->data[$index]['id'] = $id;
            $response->data[$index]['login'] = $login;
            $response->data[$index]['firstname'] = $firstName;
            $response->data[$index]['lastname'] = $lastName;
            $response->data[$index]['email'] = (string)current($propValues[GenerisRdf::PROPERTY_USER_MAIL]);
            $response->data[$index]['roles'] = implode(', ', $labels);
            $response->data[$index]['guiLg'] = is_null($uiRes) ? '' : $uiRes->getLabel();

            $statusInfo = $this->getUserLocksService()->getStatusDetails($login);
            $response->data[$index]['lockable'] = $statusInfo['lockable'];
            $response->data[$index]['locked'] = $statusInfo['locked'];
            $response->data[$index]['status'] = $statusInfo['status'];

            if ($user->getUri() == LOCAL_NAMESPACE . TaoOntology::DEFAULT_USER_URI_SUFFIX) {
                $readonly[$id] = true;
            }

            $index++;
        }

        $response->page = floor($start / $limit) + 1;
        $response->total = ceil($total / $limit);
        $response->records = count($users);
        $response->readonly = $readonly;

        $this->returnJson($response, 200);
    }
276026
public function searchUsersAction()
    {
        if (!$this->getRequest()->isXmlHttpRequest()) {
            throw new \RuntimeException('This action must be called via ajax request');
        }
        
        $model = new JsonModel();
        $query = $this->params()->fromPost('query', false);
        if (!$query) {
            $query = $this->params()->fromQuery('q', false);
        }
        if (false === $query) {
            $result = array();
        } else {
            $repositories = $this->repositories;
            $repository   = $repositories->get('Auth/User');
            
            $users = $repository->findByQuery($query);
        
            $userFilter = $this->filterManager->get('Auth/Entity/UserToSearchResult');
            $filterFunc = function ($user) use ($userFilter) {
                return $userFilter->filter($user);
            };
            $result     = array_values(array_map($filterFunc, $users->toArray()));
        }
        
        //$model->setVariable('users', $result);
        $model->setVariables($result);
        return $model;
    }
1344151
public function getList()
	{
		$this->getResponse()
			->setStatusCode(Response::STATUS_CODE_200);
		
		// 1) getting params
		$page = (int) $this->params()->fromQuery("page", 1);
		$category = $this->params()->fromQuery("category", "usato");
		$purpose = $this->params()->fromQuery("purpose", "compravendita");
		$location = $this->params()->fromQuery("location", "italia");
		$limit = 30;
		$offset = ($page * $limit) - $limit;
		$returnSelect = true;
		
		// 2) Discard useless params and prepare them to be passed to the model
		$params = $this->requestToSearchParams($this->params()->fromQuery());
		$params = is_array($params) ? $params + compact('returnSelect', 'offset', 'limit') : array();
		
		if(empty($params)) {
            return new JsonModel(array());
		}
		
		// 3) get only for current user?
		$onlyCurrentUser = (bool) $this->params()->fromQuery("current", false);
		$k = 0;
		foreach($params['field'] as $f) {
			if('current' == $f || 'user' == $f) {
				unset($params['field'][$k]);
				unset($params['value'][$k]);
			}
			$k++;
		}
		if($onlyCurrentUser) {
			if($this->zfcUserAuthentication()->hasIdentity()) {
				$identity = $this->zfcUserAuthentication()->getIdentity();
// 				$params['field'][] = 'user';
// 				$params['value'][] = sha1('neo' . $identity->getUserId() . 'bazaar');
				$params['field'][] = 'account';
				$params['value'][] = sha1('neo' . $identity->getUserId() . 'bazaar');
			} else {
				// Questo è necessario per non far restituire la lista completa se l'utente non è connesso
				$params['field'][] = 'account';
				$params['value'][] = sha1('usernotconnected');
			}
		}
		
		// 4) all classifieds? This should be requested only by the admin, will not use sphinx
		if((bool) $this->params()->fromQuery("full", false)) {
			if($this->zfcUserAuthentication()->hasIdentity()) {
			    $params = $this->params()->fromQuery();
				$identity = $this->zfcUserAuthentication()->getIdentity();
				$userModel = $this->getServiceLocator()->get('user.model.user');
				$userModel->init($identity, $this->getServiceLocator());
				if(!$userModel->getIsAdmin()) {
				    return new JsonModel(array());
				}
				
				$paginator = $this->getServiceLocator()->get('document.paginator.classifiedFull');
				$paginator->build($params);

				$data = array();
				foreach($paginator as $post) {
            		$file = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
				    $data[] = $file->init($post);
				}

				$routeName = 'DocumentAdminClassified/page';
				$routeParams = array('page' => $this->params()->fromQuery("page", 1));
				$queryParams = array('full' => 1, 'user' => $this->params()->fromQuery("user"));
				$data = $this->getModel()->getPaginationData($this->getServiceLocator(), $paginator, $data, $routeName, $routeParams, $queryParams);

				return new JsonModel($data);
			}
		}
		
		// 5) Pass param to the model and get the data
		$data = $this->getModel()->getList($params, $this->getServiceLocator());
		
		return new JsonModel($data);
	}
1110607
public function jsonSerialize()
    {
        $data = [
            'title' => $this->title,
            'address' => $this->address
        ];


        $data = array_merge($data, $this->buildJsonAttributes([
            'reply_markup' => $this->replyMarkup
        ]));

        return $data;
    }
996485
public function getJson()
    {
        $json = array(
            'urlKeyParam' => $this->getUrlKeyParam(),
            'inputFieldName' => $this->getTokenInputName(),
            'observedCssRules' => $this->getObservedCssRules(),
            'requestUrl' => $this->getTokenUrl(),
            'cookieName' => $this->getCookieName()
        );

        return json_encode($json);
    }
900194
public function getJsonBody() : array
    {
        $json = json_decode($this->getRawBody(), true);

        if ($json === null) {
            throw new RuntimeException('Body could not be decoded as JSON');
        }

        return $json;
    }
39136
public function toString()
    {
        $data = $this->toArray();

        // Root should be JSON object, not array
        if (count($data) === 0) {
            $data = new ArrayObject();
        }

        // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
        $data = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES);

        if (JSON_ERROR_NONE !== json_last_error())
        {
            throw new InvalidArgumentException(
                'Cannot encode data to JSON string: ' . json_last_error_msg()
            );
        }

        return $data;
    }
1115843
public function getChanges()
    {
        $response = $this->client->request('GET', "/{$this->name}/_changes");

        if (200 !== $response->getStatusCode()) {
            throw new Exception('Request wasn\'t successfull');
        }

        return JSONEncoder::decode((string) $response->getBody());
    }
240631
public function toJson()
    {
        $json = array();

        $json['name'] = $this->getName();
        $json['privacy'] = $this->getPrivacy();
        //Parameters for PUT call (Room already exists)
        if ($this->getId()) {
            $json['is_archived'] = $this->isArchived();
            $json['is_guest_accessible'] = $this->isGuestAccessible();
            $json['topic'] = $this->getTopic();
            $json['owner'] = array('id' => $this->getOwner()->getId());
        } else { //Paramters for POST call
            $json['guest_access'] = $this->isGuestAccessible();
            if ($this->getOwner()) {
                $json['owner_user_id'] = $this->getOwner()->getId();
            }
        }
        return $json;
    }
969880
public function jsonDecode()
    {
        $json = json_decode($this->body, true);
        if ($json===null){
            throw new JsonFormatException($this->body);
        }
        return $json;
    }
108155
public function json() {
			$json = parent::json();

			$is_contact_visible = $this->fs->is_page_visible( 'contact' );
			$is_support_visible = $this->fs->is_page_visible( 'support' );

			$json['theme_title'] = $this->fs->get_plugin_name();

			if ( $is_contact_visible && $is_support_visible ) {
				$json['theme_title'] .= ' ' . $this->fs->get_text_inline( 'Support', 'support' );
			}

			if ( $is_contact_visible ) {
				$json['contact'] = array(
					'label' => $this->fs->get_text_inline( 'Contact Us', 'contact-us' ),
					'url'   => $this->fs->contact_url(),
				);
			}

			if ( $is_support_visible ) {
				$json['support'] = array(
					'label' => $this->fs->get_text_inline( 'Support Forum', 'support-forum' ),
					'url'   => $this->fs->get_support_forum_url()
				);
			}

			return $json;
		}
1233098
public function serialize()
    {
        $serialized = new \stdClass();
        $serialized->username = $this->_login;
        $serialized->commonname = trim($this->_firstname . ' ' . $this->_lastname);

        return json_encode($serialized);
    }
68842
public function getPayloadJSON()
    {
        $data = is_string($this->data) ? mb_convert_encoding($this->data, 'UTF-8') : $this->data;
        return json_encode($data);
    }
470158
public function toArrayAll()
    {
        $data = $this->toArray();

        foreach(self::$jsonable as $key){

            if(isset($data[$key]) && Utils::isJson($data[$key])){
                $data[$key] = json_decode($this->{$key});
            }
        }

        return $data;
    }
967134
public function getTranslatedData()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        $data = array();
        if($this->hasRequestParameter('lang')){
            $data = tao_helpers_Uri::encodeArray(
                $this->getClassService()->getTranslatedProperties(
                    $this->getCurrentInstance(),
                    $this->getRequestParameter('lang')
                ),
                tao_helpers_Uri::ENCODE_ARRAY_KEYS);
        }
        $this->returnJson($data);
    }
981361
public function toJson()
    {
        array_walk_recursive($this->params, function (&$value) {
            $value = (string) $value;
        });
        return json_encode($this->params);
    }
914874
public function toJson()
    {
        $array = array();
        foreach ($this->disclose() as $key => $disclosure) {
            $values = $disclosure->toArray();
            foreach ($values as &$value) {
                $value = utf8_encode($value);
            }
            $array[$key] = $values;
        }
        return json_encode($array);
    }