예제 #1
0
        $formValues[$key] = Format::limitLength($formValues[$key], $MAX_LENGTHS[$key]);
    }
    $foundProfile = Doctrine::findMembre($numeroMembre);
    // Don't generate method calls to avoid potential security hole.
    $foundProfile->setStatut($formValues['statut']);
    $foundProfile->setEnfants($formValues['enfants']);
    $foundProfile->setDevise($formValues['devise']);
    $foundProfile->setCoordonnee('email', $formValues['email'], $formValues['emailPrive']);
    $foundProfile->setCoordonnee('phone', $formValues['telephone'], $formValues['telephonePrive']);
    $adresseValue = ['address' => trim("{$formValues['adresse1']}\n{$formValues['adresse2']}\n{$formValues['adresse3']}"), 'code' => $formValues['codePostal'], 'city' => $formValues['ville'], 'country' => $formValues['pays']];
    $foundProfile->setCoordonnee('address', json_encode($adresseValue), $formValues['adressePrivee']);
    $foundProfile->setLangues(getArrayValue($formValues, 'langues'));
    $foundProfile->setCompetences(getArrayValue($formValues, 'competences'));
    $foundProfile->setPassions(getArrayValue($formValues, 'passions'));
    Doctrine::persist($foundProfile);
    Doctrine::flush();
    $ldapResult = LdapSync::updateProfile($numeroMembre, $foundProfile->jsonSerialize());
    if ($ldapResult) {
        // Then it's an error.
        $logger->error("Ldap error updating status for #{$numeroMembre}: {$ldapResult}");
    }
    echo json_encode($foundProfile);
} else {
    $logger->info('Found validation errors: ' . print_r($v->errors(), true));
    $errors = [];
    foreach ($v->errors() as $fieldName => $fieldErrors) {
        foreach ($fieldErrors as $message) {
            $errors[] = $message;
        }
    }
    $logger->info('Found validation errors: ' . print_r($errors, true));
예제 #2
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use MonCompte\LemonLdap;
use MonCompte\Doctrine;
use MonCompte\Logger;
$logger = Logger::getLogger('services/getProfile');
$currentUserId = LemonLdap::getCurrentUserId();
$logger->debug("Found current user id: {$currentUserId}");
$foundProfile = Doctrine::findMembre($currentUserId);
header("Content-type: application/json; charset=utf-8'");
//echo json_encode($sentProfile);
echo json_encode($foundProfile);