Commit ff93d2eb authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Mise à jour et factorisation de l'enregistrement des paramètres utilisateur...

Mise à jour et factorisation de l'enregistrement des paramètres utilisateur (Fréquence des notifications et mode de déclaration)
parent e9a9f8a4
Loading
Loading
Loading
Loading
+1
Changes for module/Oscar/config/module.config.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -781,6 +781,7 @@ return array(
            'ShuffleService' => \Oscar\Service\ShuffleDataService::class,
            'MailingService' => \Oscar\Service\MailingService::class,
            'SessionService' => \Oscar\Service\SessionService::class,
            'UserParametersService' => \Oscar\Service\UserParametersService::class,
        ],

        'factories' => array(
+8
Changes for module/Oscar/src/Oscar/Controller/AbstractOscarController.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ use Oscar\Service\ProjectGrantService;
use Oscar\Service\ProjectService;
use Oscar\Service\SearchService;
use Oscar\Service\SessionService;
use Oscar\Service\UserParametersService;
use UnicaenAuth\Service\UserContext;
use Zend\Http\Request;
use Zend\Http\Response;
@@ -54,6 +55,13 @@ class AbstractOscarController extends AbstractActionController
        return $config->getConfiguration($key);
    }

    /**
     * @return UserParametersService
     */
    public function getUserParametersService(){
        return $this->getServiceLocator()->get('UserParametersService');
    }

    /**
     * @return SessionService
     */
+20 −21
Changes for module/Oscar/src/Oscar/Controller/PublicController.php: 20 added lines, 21 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Oscar\Entity\Authentification;
use Oscar\Entity\Organization;
use Oscar\Entity\OrganizationRepository;
use Oscar\Entity\Person;
use Oscar\Exception\OscarException;
use Oscar\Provider\Privileges;
use Oscar\Service\OscarUserContext;
use Oscar\Service\TimesheetService;
@@ -44,34 +45,32 @@ class PublicController extends AbstractOscarController

            switch ($action) {

                // Modification du mode de déclaration
                case 'declaration-mode' :
                    try {
                        $this->getUserParametersService()->performChangeDeclarationMode($this->params()->fromPost('declarationsHours'));
                        return $this->getResponseOk();
                    } catch ( OscarException $e ){
                        return $this->getResponseInternalError(sprintf('%s : %s', _('Impossible de modifier le mode de déclaration'), $e->getMessage()));
                    }
            $declarationsHours = $this->params()->fromPost('declarationsHours');

            if( $declarationsHours !== null ){
                if( !$this->getConfiguration('oscar.declarationsHoursOverwriteByAuth', false) ){
                    return $this->getResponseInternalError("Cette option ne peut pas être modifiée");
                }
                    break;

                $settings = $auth->getSettings() ?: [];
                $declarationsHours = $this->params()->fromPost('declarationsHours') == 'on' ? true : false;
                $settings['declarationsHours'] = $declarationsHours;
                $auth->setSettings($settings);
                $this->getEntityManager()->flush($auth);
                case 'frequency' :
                    try {
                        $this->getUserParametersService()->performChangeFrequency($this->params()->fromPost('frequency', null));
                        return $this->getResponseOk();
                    } catch ( OscarException $e ){
                        return $this->getResponseInternalError(sprintf('%s : %s', _('Impossible de modifier le mode de déclaration'), $e->getMessage()));
                    }
                    break;

            $frequency = $this->params()->fromPost('frequency', null);
            if( $frequency ) {
                $parameters = explode(',', $this->params()->fromPost('frequency'));
                $this->getLogger()->debug("Save for = " . $auth->getDisplayName());
                $settings = $auth->getSettings() ?: [];
                $settings['frequency'] = $parameters;
                $auth->setSettings($settings);
                $this->getEntityManager()->flush($auth);
                return $this->getResponseOk();
                // todo Modification de la fréquence


                // todo Modification des horaires (soumission)
            }

            return $this->getResponseBadRequest("");
            return $this->getResponseBadRequest("Erreur d'usage");
        }

        /** @var TimesheetService $timesheetService */
+1
Changes for module/Oscar/src/Oscar/Service/ActivityLogService.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ class ActivityLogService implements ServiceLocatorAwareInterface, EntityManager

    public function addUserInfo($message, $context = 'Application', $contextId = -1, $level = LogActivity::LEVEL_ADMIN)
    {
        $this->getServiceLocator()->get('Logger')->info($message);
        $person = $this->getCurrentPerson();
        $personText = "Anonymous";
        if( is_string($person) ){
+5 −2
Changes for module/Oscar/src/Oscar/Service/ConfigurationAwareInterface.php: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,10 @@
namespace Oscar\Service;


class ConfigurationAwareInterface
interface ConfigurationAwareInterface
{

    /**
     * @return ConfigurationParser
     */
    public function getConfiguration($key);
}
 No newline at end of file
Loading