text:
<?php

namespace AppBundle\EventListener;

use AppBundle\Entity\Adresse;
use AppBundle\Entity\Attribution;
use AppBundle\Entity\Contact;
use AppBundle\Entity\Distinction;
use AppBundle\Entity\Email;
use AppBundle\Entity\Famille;
use AppBundle\Entity\Membre;
use AppBundle\Entity\Mere;
use AppBundle\Entity\ObtentionDistinction;
use AppBundle\Entity\Pere;
use AppBundle\Entity\Telephone;
use Doctrine\ORM\Event\PostFlushEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Interne\HistoryBundle\Entity\MemberHistory;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use AppBundle\Entity\User;

class LogOnChangeListener
{

    private $token_storage;

    /** @var MemberHistory $historyEntry */
    private $historyEntry;

    /** @var Session $session */
    private $session;

    public function __construct(TokenStorageInterface $token_storage, Session $session)
    {
        $this->token_storage = $token_storage;
        $this->session = $session;
    }

    public function preUpdate(PreUpdateEventArgs $eventArgs)
    {
        $uow = $eventArgs->getEntityManager()->getUnitOfWork();

        //without token, the modification come from something else (e.g. console)
        /** @var User $editorUser */
        $editorUser = null;

        //with token, a user is the author of the modification
        if ($this->token_storage->getToken() != NULL) {

            $editorUser = $this->token_storage->getToken()->getUser();
        }

        /* Get all updated entities */
        foreach ($uow->getScheduledEntityUpdates() as $entity) {

            $changeSet = $uow->getEntityChangeSet($entity);

            /* Log members */
            if ($entity instanceof Membre) {
                $modifiedMember = $entity;

                foreach ($changeSet as $property => $values) {

                    //$this->data_logger->member($editorMember, $modifiedMember, $property, $values[0], $values[1]);
                    $this->historyEntry = new MemberHistory($editorUser, $modifiedMember, $property, $values[0], $values[1]);
                }
            }

            /* Log ContactInformation changes */
            if ($entity instanceof Contact) {
                $contactInformation = $entity;

                $modifiedMember = $eventArgs->getEntityManager()->getRepository('AppBundle:Membre')->find($contactInformation->getContact()->getId());

                if ($modifiedMember != NULL) {
                    foreach ($changeSet as $property => $values) {
                        $detailedProperty = $property . ' (' . $contactInformation . ')';
                        //$this->data_logger->member($editorMember, $modifiedMember, $detailedProperty, $values[0], $values[1]);
                        $this->historyEntry = new MemberHistory($editorUser, $modifiedMember, $detailedProperty, $values[0], $values[1]);
                    }
                }
            }

            if ($entity instanceof Attribution) {
                $attribution = $entity;

                $modifiedMember = $attribution->getMembre();

                foreach ($changeSet as $property => $values) {
                    $detailedProperty = $property . ' (' . $attribution . ')';

                    if ($values[0] != NULL && $values[0] instanceof \DateTime)
                        $values[0] = $values[0]->format('d.m.Y'); // TODO: take date format from globals

                    if ($values[1] != NULL && $values[1] instanceof \DateTime)
                        $values[1] = $values[1]->format('d.m.Y'); // TODO: take date format from globals

                    $this->historyEntry = new MemberHistory($editorUser, $modifiedMember, $detailedProperty, $values[0], $values[1]);
                }
            }

            if ($entity instanceof ObtentionDistinction) {
                $obtentionDistinction = $entity;

                $modifiedMember = $obtentionDistinction->getMembre();

                foreach ($changeSet as $property => $values) {
                    $detailedProperty = $property . ' (' . $obtentionDistinction . ')';

                    if ($values[0] != NULL && $values[0] instanceof \DateTime)
                        $values[0] = $values[0]->format('d.m.Y'); // TODO: take date format from globals

                    if ($values[1] != NULL && $values[1] instanceof \DateTime)
                        $values[1] = $values[1]->format('d.m.Y'); // TODO: take date format from globals

                    //$this->data_logger->member($editorMember, $modifiedMember, $detailedProperty, $values[0], $values[1]);
                    $this->historyEntry = new MemberHistory($editorUser, $modifiedMember, $detailedProperty, $values[0], $values[1]);
                }
            }

            /*
             * Gestion des modifications et de la validation des changements effectués sur la base de donnée
             * Tous les changements sur la BDD engendrent la création d'un objet modification, qui servira de contrôle et permettra
             * de retourner à l'état précédent si nécessaire.
             *
             * Cet outil ne s'applique pas aux membres ayant les roles suffisants
             */

            if($editorUser != null)
            {
                if (!$editorUser->hasRole('ROLE_ADMIN')) { //TODO : mettre un role addaptée, le role nécaissaire a avoir pour faire des modif sans création d'historique

                    $path = "";
                    $em = $eventArgs->getEntityManager();
                    $entityFromContact = function ($source, $contact) use ($em) {

                        $potentialMembre = $em->getRepository('AppBundle:Membre')->find($contact->getId());
                        $potentialFamille = $em->getRepository('AppBundle:Famille')->find($contact->getId());
                        $potentialGeniteur = $em->getRepository('AppBundle:Geniteur')->find($contact->getId());

                        if ($potentialMembre != null)
                            return "membre." . $potentialMembre->getId() . "." . $source;
                        elseif ($potentialFamille != null)
                            return "famille." . $potentialFamille->getId() . "." . $source;

                        elseif ($potentialGeniteur != null) {

                            if ($potentialGeniteur instanceof Mere)
                                return "famille." . $potentialGeniteur->getFamille()->getId() . ".mere." . $source;
                            else if ($potentialGeniteur instanceof Pere)
                                return "famille." . $potentialGeniteur->getFamille()->getId() . ".pere." . $source;
                            else
                                return null;

                        } else
                            throw new \Exception("Goddamit Jack, j'ai pas trouvé l'entité yo");
                    };

                    /*
                     * ICI :
                     * On récupère l'entité "racine" de celle qui subit la modification, un membre ou une famille
                     * TODO : Faire un truc mieux si possible

                    if($entity instanceof Membre)
                        $path           = "membre." . $entity->getId();
                    elseif($entity instanceof Famille)
                        $path           = "famille." . $entity->getId();
                    elseif($entity instanceof Pere)
                        $path           = "famille." . $entity->getFamille()->getId() . ".pere";
                    elseif($entity instanceof Mere)
                        $path           = "famille." . $entity->getFamille()->getId() . ".mere";
                    elseif($entity instanceof Attribution)
                        $path           = "membre." . $entity->getMembre()->getId() . ".attributions[" . $entity->getMembre()->getAttributions()->indexOf($entity) . "]";
                    elseif($entity instanceof ObtentionDistinction)
                        $path           = "membre." . $entity->getMembre()->getId() . ".obtentionDistinctions[" . $entity->getMembre()->getDistinctions()->indexOf($entity) . "]";
                    elseif($entity instanceof Contact)
                        $path           = $entityFromContact('contact', $entity);
                    elseif($entity instanceof Telephone)
                        $path           = $entityFromContact('contact.telephones[' . $entity->getContact()->getTelephones()->indexOf($entity) . "]", $entity->getContact());
                    elseif($entity instanceof Email)
                        $path           = $entityFromContact('contact.emails[' . $entity->getContact()->getEmails()->indexOf($entity) . "]", $entity->getContact());
                    elseif($entity instanceof Adresse)
                        $path           = $entityFromContact('contact.adresse', $entity->getContact());

                    // Génération d'un objet Modification dans le cas où c'est nécessaire
                    if($path != null) {

                        foreach($changeSet as $property => $values) {

                            $modification = new Modification();

                            $modification->setOldValue($values[0]);
                            $modification->setNewValue($values[1]);
                            $modification->setAuteur($token->getUser()->getMembre());
                            $modification->setDate(new \DateTime());
                            $modification->setPath($path . '.' . $property);
                            $modification->setStatut(Modification::EN_ATTENTE);

                            $em->persist($modification);
                        }

                        $uow->computeChangeSets();
                    }
                    */

                }
            }

        }
    }

    /**
     * Add the history entry to the DB
     *
     * @param PostFlushEventArgs $args
     */
    public function postFlush(PostFlushEventArgs $args)
    {
        if (!empty($this->historyEntry)) {

            $this->historyEntry->setSession($this->session->getId());

            $em = $args->getEntityManager();
            $em->persist($this->historyEntry);

            /* We must clean entry before flush, else we get infinite recursion */
            $this->historyEntry = NULL;

            $em->flush();
        }

    }

    public function setEntityHelper($entityHelper)
    {
        $this->entityHelper = $entityHelper;

        return $this;
    }

    /**
     * Génère un path lisible pour retracer l'origine de la modification
     * par exemple Membre[1]->famille->pere->adresse->rue
     * @param $linkedEntity
     * @param $entity
     * @param $field
     */
    private function generatePath($linkedEntity, $entity, $field)
    {

    }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.tek.interview.question</groupId>
  <artifactId>OrderCalculation</artifactId>
  <version>1.0.0</version>
  <packaging>jar</packaging>

  <name>OrderCalculation</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <empVersion>1.2.1</empVersion>
    <junitVersion>4.12</junitVersion>
  </properties>

  <build>
   	<plugins>
      <plugin>
  		<groupId>org.codehaus.mojo</groupId>
  		<artifactId>exec-maven-plugin</artifactId>
  		<version>${empVersion}</version>
  		<executions>
    	  <execution>
    	    <id>bugfixes</id>
      		<goals>
        	  <goal>java</goal>
      		</goals>
      		<configuration>
    	  	  <mainClass>com.tek.interview.question.main.Foo</mainClass>
  			</configuration>
    	  </execution>
    	  <execution>
    	    <id>refactored</id>
    	    <goals>
        	  <goal>java</goal>
      		</goals>
      		<configuration>
    	  	  <mainClass>com.tek.interview.question.main.Bar</mainClass>
  			</configuration>
    	  </execution>
  		</executions>
	  </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junitVersion}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

redpajama_set_name: RedPajamaGithub


text:
module ActiveMerchant
  VERSION = "1.40.0.1rc"
end


text:
using Google.Cloud.ClientTesting;
using System.Threading;
using System;
using Xunit;
using System.IO;
using Google.Cloud.Storage.V1.Tests.Conformance;
using System.Net.Http;

namespace Google.Cloud.Storage.V1.RetryConformanceTests;

[CollectionDefinition(nameof(RetryConformanceTestFixture))]
public class RetryConformanceTestFixture : ICollectionFixture<RetryConformanceTestFixture>
{
    internal StorageClient Client { get; }
    internal string ServiceAccountEmail { get; }
    internal string TestTopic { get; } = GetEnvironmentVariableOrDefault("TOPIC", "test-topic");
    internal string SampleObjectContentPath => Path.Combine(StorageConformanceTestData.TestData.DataPath, "test_service_account.not-a-test.json");
    internal string ProjectId { get; } = "test";
    internal HttpClient HttpClient { get; }
    internal static string TestBenchUrl { get; } = GetEnvironmentVariableOrDefault("TEST_BENCH_URL", "http://localhost:9000/");

    public RetryConformanceTestFixture()
    {
        var clientBuilder = new StorageClientBuilder
        {
            BaseUri = TestBenchUrl + "storage/v1/",
            GZipEnabled = false
        };
        HttpClient = new HttpClient
        {
            BaseAddress = new Uri(TestBenchUrl)
        };

        Client = clientBuilder.Build();
        ServiceAccountEmail = Client.GetStorageServiceAccountEmail(ProjectId);
    }

    /// <summary>
    /// Function created to be used for getting environment variables
    /// </summary>
    private static string GetEnvironmentVariableOrDefault(string name, string defaultValue)
    {
        string value = Environment.GetEnvironmentVariable(name);
        return string.IsNullOrEmpty(value) ? defaultValue : value;
    }

    internal static void SleepAfterBucketCreateDelete() => Thread.Sleep(2000);
}


text:
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\modules\Admin\Message\models\Messages */
/* @var $form yii\widgets\ActiveForm */
?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'school_id')->textInput() ?>

    <?= $form->field($model, 'class_id')->textInput() ?>

    <?= $form->field($model, 'contents')->textInput(['maxlength' => 500]) ?>

    <?= $form->field($model, 'ippassed')->textInput() ?>

    <?= $form->field($model, 'isdeleted')->textInput() ?>

    <?= $form->field($model, 'isview')->textInput() ?>

    <?= $form->field($model, 'istimer')->textInput() ?>

    <?= $form->field($model, 'starttime')->textInput() ?>

    <?= $form->field($model, 'endtime')->textInput() ?>

    <?= $form->field($model, 'createtime')->textInput() ?>

    <?= $form->field($model, 'updatetime')->textInput() ?>

        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    <?php ActiveForm::end(); ?>


text:
var Standard = function () {
  var _player;
  var _cursors;
  var _fireButton;
  var _tapData = {
    lastTap : 0
  };

  var _onCursor = function ( item ) {
    var now = +new Date();
    var diff = now - _tapData.lastTap.time;

    if ( diff < 600 && diff > 0 ) {
      if ( item.event.keyIdentifier === 'Left' &&
           _tapData.lastTap.dir === 'Left' ) {
        _player.burstLeft();
      } else if ( item.event.keyIdentifier === 'Right' &&
           _tapData.lastTap.dir === 'Right' ) {
        _player.burstRight();
      } else {
        _tapData.lastTap = { time : +new Date(), dir : 'none'}
      }
    }

    _tapData.lastTap = {
      time: +new Date(),
      dir: item.event.keyIdentifier
    };
  }

  var _onFire = function ( ) {
    _player.fire();
  }

  var _addUpdate = function ( player, game ) {
    var oldUpdate = player.update;

    player.update = function () {
      if ( oldUpdate ) {
        oldUpdate.call( this );
      }

      if ( _cursors.left.isDown ) {
        player.moveLeft();
      }
      else if ( _cursors.right.isDown ) {
        player.moveRight();
      }
      else {
        player.notMoving();
      }
    }
  }

  var _addCursors = function ( player, game ) {
    _cursors = game.input.keyboard.createCursorKeys();
    _cursors.left.onDown.add( _onCursor, this );
    _cursors.right.onDown.add( _onCursor, this );
  };

  var _addFireButton = function ( player, game ){
    _fireButton = game.input.keyboard.addKey( Phaser.Keyboard.SPACEBAR );
    _fireButton.onDown.add( _onFire );
  };

  var decorate = function ( player, game ) {
    _player = player;
    _addUpdate( player, game );
    _addCursors( player, game );
    _addFireButton( player, game );

    return player;
  };

  return {
    decorate: decorate
  };
};

module.exports = Standard;


text:
package com.dmdirc.addons.calc;

/**
 * Describes the arity (number of operands) of a token type.
 */
public enum TokenTypeArity {

    /**
     * A special type which does not have any operands and does not correspond to any input (e.g.
     * the special START and END tokens).
     */
    HIDDEN,
    /** A type which takes no operands. */
    NULLARY,
    /** A type which takes one operand. */
    UNARY,
    /** A type which takes two operands. */
    BINARY

}


text:
<?php

namespace CosyVerif\Server\Routing;

class ProjectMiddleware  extends \Slim\Middleware
{
  public static function register()
  {
    global $app;
    $app->add(new ProjectMiddleware());
  }
  public function call()
  {
    global $app;

    $url = $app->request->getResourceUri();
    $this->app->hook('slim.before.dispatch',  function() use ($app, $url)
    {
      $routeName = $app->router()->getCurrentRoute()->getName();
      if ($routeName == "project")
      {
        $app->resource = ProjectResource::newResource($url);
      }

    });

    // users router
    $app->get('/projects(/)', function() use($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      $data = $app->resource->readList();
      if (is_array($data))
        $app->response->setBody(json_encode($data));
    })->setName("project");

    // user router
    $app->get('/projects/:project(/)', function() use($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if ($app->resource->file_deleted())
        $app->halt(STATUS_GONE);
      else if (!$app->resource->canRead($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = $app->resource->project_read();
      if (is_array($data))
        $app->response->setBody(json_encode($data));
    })->setName("project");
    $app->put('/projects/:project(/)', function() use($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if ($app->resource->file_deleted())
        $app->halt(STATUS_GONE);
      if (!$app->resource->canWrite($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $app->resource->project_write($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->delete('/projects/:project(/)', function() use ($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if ($app->resource->file_deleted())
        $app->halt(STATUS_GONE);
      else if (!$app->resource->canDelete($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $app->resource->project_delete();
    })->setName("project");

    $app->get('/projects/:project/users(/)', function() use($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if (!$app->resource->canRead($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = $app->resource->user_readList();
      if (is_array($data))
        $app->response->setBody(json_encode($data));
    })->setName("project");

    $app->get('/projects/:project/invitations(/)', function() use($app)
    {
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if (!$app->resource->canRead($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = $app->resource->read_invitations();
      if (is_array($data))
        $app->response->setBody(json_encode($data));
    })->setName("project");

    $app->post('/projects/:project/invitations/:user(/)', function($project, $user) use($app){
      if (!file_exists($app->config("base_dir").'/projects/'.$project) ||
          !file_exists($app->config("base_dir").'/users/'.$user))
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canCreate($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $data["project_url"] = "/projects/$project";
      $data["added_user"] = $user;
      $data["requesting_user"] = $app->user["login"];
      $app->resource->invitation_create($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->put('/projects/:project/invitations/:user(/)', function($project, $user) use($app){
      if (!file_exists($app->config("base_dir").'/projects/'.$project) ||
          !file_exists($app->config("base_dir").'/users/'.$user))
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canWrite($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $data["project_url"] = "/projects/$project";
      $data["added_user"] = $user;
      $data["requesting_user"] = $app->user["login"];
      $app->resource->invitation_update($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->delete('/projects/:project/invitations(/)', function($project) use($app){
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canDelete($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $app->resource->invitation_delete();
    })->setName("project");
    $app->post('/users/:user/invitations/:project(/)', function($user, $project) use($app){
      if (!file_exists($app->config("base_dir").'/projects/'.$project) ||
          !file_exists($app->config("base_dir").'/users/'.$user))
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canCreate($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $data["project_url"] = "/projects/$project";
      $data["added_user"] = $user;
      $data["requesting_user"] = $user;
      $app->resource->invitation_create($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->put('/users/:user/invitations/:project(/)', function($user, $project) use($app){
      if (!file_exists($app->config("base_dir").'/projects/'.$project) ||
          !file_exists($app->config("base_dir").'/users/'.$user))
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canWrite($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $data["project_url"] = "/projects/$project";
      $data["added_user"] = $user;
      $data["requesting_user"] = $user;
      $app->resource->invitation_update($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->delete('/users/:user/invitations(/)', function($user) use($app){
      if (!$app->resource->file_exists())
        $app->halt(STATUS_NOT_FOUND);
      if (!$app->resource->canDelete($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $app->resource->invitation_delete();
    })->setName("project");
    $app->put('/projects/:project/users/:user(/)', function($project, $user) use($app){
      if (!$app->resource->link_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if (!$app->resource->canWrite($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $data = json_decode($app->request->getBody(), TRUE);
      if (!is_array($data))
      {
        $app->halt(STATUS_UNPROCESSABLE_ENTITY);
      }
      $app->resource->changePermissions($data);
      $app->response->setBody("{}");
    })->setName("project");
    $app->delete('/projects/:project/users/:user(/)', function($project, $user) use($app){
      if (!$app->resource->link_exists())
        $app->halt(STATUS_NOT_FOUND);
      else if (!$app->resource->canDelete($app->user))
        $app->halt(STATUS_FORBIDDEN);
      $app->resource->user_delete();
    })->setName("project");
    $app->get('/projects/:id/users/:user(/)', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->put('/projects/:id/users/:user(/)', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->delete('/projects/:id/users/:user(/)', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->get('/projects/:id/users/:user/:other+', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->put('/projects/:id/users/:user/:other+', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->patch('/projects/:id/users/:user/:other+', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");
    $app->delete('/projects/:id/users/:user/:other+', function() use($app){
      $parts = explode('/', $app->request->getResourceUri());
      $url = '/'.implode('/', array_slice($parts, 3, count($parts)));
      $app->redirect('/'.$app->config["main"].$url, STATUS_MOVED_TEMPORARILY);
    })->setName("project");

    $this->next->call();
  }
}

class ProjectResource extends BaseResource
{
  public static function newResource($url)
  {
    return new ProjectResource($url);
  }

  public function project_create($data)
  {
    global $app;
    if (!array_key_exists("name", $data))
    {
      $app->response->setStatus(STATUS_BAD_REQUEST);
      return FALSE;
    }
    $auth = array();
    $auth["is_public"] = (array_key_exists("is_public", $data)) ? $data["is_public"] : ($app->config["default_visibility"] === "public");
    unset($data["is_public"]);
    $auth["users"] = array();
    $json_auth = json_encode($auth);
    $json_info = json_encode($data);
    if(!$this->file_exists())
    {
      mkdir($app->config("base_dir").$this->getURL());
    }
    file_put_contents($app->config("base_dir").$this->getURL()."/info.json", $json_info);
    file_put_contents($app->config("base_dir").$this->getURL()."/auth.json", $json_auth);
    mkdir($app->config("base_dir").$this->getURL()."/formalisms");
    $tmp = array();
    $tmp["name"] = "Formalism list";
    file_put_contents($app->config("base_dir").$this->getURL()."/formalisms/info.json", json_encode($tmp));
    mkdir($app->config("base_dir").$this->getURL()."/models");
    $tmp = array();
    $tmp["name"] = "Model list";
    file_put_contents($app->config("base_dir").$this->getURL()."/models/info.json", json_encode($tmp));
    mkdir($app->config("base_dir").$this->getURL()."/scenarios");
    $tmp = array();
    $tmp["name"] = "scenarios list";
    file_put_contents($app->config("base_dir").$this->getURL()."/scenarios/info.json", json_encode($tmp));
    mkdir($app->config("base_dir").$this->getURL()."/services");
    $tmp = array();
    $tmp["name"] = "Service list";
    file_put_contents($app->config("base_dir").$this->getURL()."/services/info.json", json_encode($tmp));
    $tmp = array();
    mkdir($app->config("base_dir").$this->getURL()."/executions");
    $tmp = array();
    $tmp["name"] = "Execution list";
    file_put_contents($app->config("base_dir").$this->getURL()."/executions/info.json", json_encode($tmp));
    mkdir($app->config("base_dir").$this->getURL()."/users");
    $tmp = array();
    $tmp["name"] = "user list";
    file_put_contents($app->config("base_dir").$this->getURL()."/users/info.json", json_encode($tmp));
    mkdir($app->config("base_dir").$this->getURL()."/invitations");
    $tmp = array();
    $tmp["name"] = "Invitation list";
    $tmp["invitations"] = array();
    file_put_contents($app->config("base_dir").$this->getURL()."/invitations/info.json", json_encode($tmp));
    $app->response->setStatus(STATUS_CREATED);
    return TRUE;
  }

  public function project_write($data)
  {
    global $app;
    $info = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/info.json"), TRUE);
    $auth = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/auth.json"), TRUE);
    $auth["is_public"] = (array_key_exists("is_public", $data)) ? $data["is_public"] : $auth["is_public"];
    unset($data["is_public"]);
    foreach ($data as $field => $value)
    {
      $info[$field] = $value;
    }
    file_put_contents($app->config("base_dir").$this->getURL()."/info.json",json_encode($info));
    file_put_contents($app->config("base_dir").$this->getURL()."/auth.json", json_encode($auth));
    $app->response->setStatus(STATUS_OK);
  }

  public function project_read()
  {
    global $app;
    $info = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/info.json"), TRUE);
    if (!is_array($info))
    {
      throw new \Exception("JSON format does not corrects !");
    }
    $auth = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/auth.json"), TRUE);
    if (!is_array($auth))
    {
      throw new \Exception("JSON format does not corrects !");
    }
    $data = $info;
    $data["is_public"] = $auth["is_public"];
    $data["is_create"] = $this->canCreate($app->user);
    $data["is_edit"] = $this->canWrite($app->user);
    $data["is_delete"] = $this->canDelete($app->user);
    $data["is_read"] = $this->canRead($app->user);
    $data["is_copy"] = false;
    $data["is_move"] = false;
    $app->response->headers->set('Content-Type','application/json');
    $app->response->setStatus(STATUS_OK);
    return $data;
  }

  public function readList()
  {
    global $app;
    $data = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/info.json"), TRUE);
    $resourceList = array();
    foreach (glob($app->config("base_dir").$this->getURL().'/*', GLOB_NOESCAPE) as $file)
    {
      if (!is_dir($file))
        continue;
      try
      {
        $tmp = ProjectResource::newResource($this->getURL()."/".basename($file))->project_read();
        $tmp['href'] = $this->getURL()."/".basename($file);
        $resourceList[] = $this->addInformations($tmp);
      }
      catch (\Exception $e){ continue; }
    }
    $data["resource_list"] = $resourceList;
    $data["is_create"] = false;
    $data["is_edit"] = false;
    $data["is_delete"] = false;
    $data["is_read"] = true;
    $app->response->headers->set('Content-Type','application/json');
    $app->response->setStatus(STATUS_OK);
    return $data;
  }

  public function project_delete()
  {
    global $app;
    $project_invitation_info = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/invitations/info.json"), TRUE);
    $project_invitations = $project_invitation_info["invitations"];
    $project_auth = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/auth.json"), TRUE);
    $permissions = $project_auth["users"];
    if (count($permissions) > 0)
    {
      foreach ($permissions as $key => $value)
      {
        unlink($app->config("base_dir")."/users/".$key.$this->getURL());
      }
    }
    foreach ($project_invitations as $key => $value)
    {
      if ($value["status"] == STATUS_SEND || $value["status"] == STATUS_RECEIVED)
      {
        $user_invitation_info = json_decode(file_get_contents($app->config("base_dir")."/users/".$value["added_user"]."/invitations/info.json"), TRUE);
        $user_invitations = $user_invitation_info["invitations"];
        $invitation_data = $user_invitations[$key];
        $invitation_data["status"] = STATUS_DENIED;
        $invitation_data["comment"] = "Project is deleted !";
        $invitation_data["requesting_user"] = $app->user["login"];
        $user_invitations[$key] = $invitation_data;
        $user_invitation_info["invitations"] = $user_invitations;
        file_put_contents($app->config("base_dir")."/users/".$value["added_user"]."/invitations/info.json", json_encode($user_invitation_info));
      }
    }
    $this->delete_dir();
    $app->response->setStatus(STATUS_NO_CONTENT);
  }

  public function user_readList()
  {
    global $app;
    $data = json_decode(file_get_contents($app->config("base_dir").$this->getURL()."/info.json"), TRUE);
    $resourceList = array();
    $parts = explode('/', $this->getURL());
    $projectName = $parts[2];
    $auth = json_decode(file_get_contents($app->config("base_dir")."/projects/".$projectName."/auth.json"), TRUE);
    $users = $auth["users"];
    foreach (glob($app->config("base_dir").$this->getURL().'/*', GLOB_NOESCAPE) as $file)
    {
      if (!is_link($file))
        continue;
      try
      {
        $user_url = readlink($file);
        $tmp = UserResource::newResource($user_url)->user_read();
        if (!is_null($tmp))
        {
          $tmp["href"] = $user_url;
          $projectUser = UserResource::newResource("/projects/".$projectName.$user_url);
          $tmp["is_create"] = $projectUser->canCreate($app->user);
          $tmp["is_edit"] = $projectUser->canWrite($app->user);
          $tmp["is_delete"] = $projectUser->canDelete($app->user);
          $parts = explode('/', $user_url);
          $user = $users[$parts[2]];
          $tmp["is_admin_project"] = $user["is_admin_project"];
          $tmp["is_edit_project"] = $user["is_edit_project"];
          $resourceList[] = $this->addInformations($tmp);
        }
      }
      catch(\Exception $e){ continue; }
    }
    $data["resource_list"] = $resourceList;
    $data["is_create"] = $this->canCreate($app->user);
    $data["is_edit"] = $this->canWrite($app->user);
    $data["is_delete"] = $this->canDelete($app->user);
    $data["is_read"] = $this->canRead($app->user);
    $app->response->headers->set('Content-Type','application/json');
    $app->response->setStatus(STATUS_OK);
    return $data;
  }

  public function invitation_create($data)
  {
    global $app;
    if (ProjectResource::newResource($data["project_url"]."/users/".$data["added_user"])->link_exists())
    {
      $app->response->setStatus(STATUS_CONFLICT);
      return NULL;
    }
    $user_info = json_decode(file_get_contents($app->config("base_dir")."/users/".$data["added_user"]."/invitations/info.json"), TRUE);
    $user_invitations = $user_info["invitations"];
    $project_info = json_decode(file_get_contents($app->config("base_dir").$data["project_url"]."/invitations/info.json"), TRUE);
    $project_invitations = $project_info["invitations"];
    foreach ($user_invitations as $key => $value)
    {
      if ($value["project_url"] === $data["project_url"] && $value["added_user"] === $data["added_user"] &&
        ($value["status"] == STATUS_SEND || $value["status"] == STATUS_RECEIVED))
      {
        $app->response->setStatus(STATUS_CONFLICT);
        return NULL;
      }
    }
    $timestamp = time();
    $data["view"] = false;
    if ($app->user["login"] === $data["added_user"])
    {
      $data["status"] = STATUS_SEND;
      $user_invitations[$timestamp] = $data;
      $data["status"] = STATUS_RECEIVED;
      $project_invitations[$timestamp] = $data;
    }
    else
    {
      $data["status"] = STATUS_RECEIVED;
      $user_invitations[$timestamp] = $data;
      $data["status"] = STATUS_SEND;
      $project_invitations[$timestamp] = $data;
    }
    $user_info["invitations"] = $user_invitations;
    $project_info["invitations"] = $project_invitations;
    file_put_contents($app->config("base_dir")."/users/".$data["added_user"]."/invitations/info.json", json_encode($user_info));
    file_put_contents($app->config("base_dir").$data["project_url"]."/invitations/info.json", json_encode($project_info));
    $app->response->setStatus(STATUS_CREATED);
  }

  public function invitation_update($data)
  {
    global $app;
    $user_info = json_decode(file_get_contents($app->config("base_dir")."/users/".$data["added_user"]."/invitations/info.json"), TRUE);
    $user_invitations = $user_info["invitations"];
    $project_info = json_decode(file_get_contents($app->config("base_dir").$data["project_url"]."/invitations/info.json"), TRUE);
    $project_invitations = $project_info["invitations"];
    $invitation_user_data = $user_invitations[$data["timestamp"]];
    $invitation_project_data = $project_invitations[$data["timestamp"]];
    if ((($invitation_user_data["status"] != STATUS_SEND && $invitation_user_data["status"] != STATUS_RECEIVED) ||
         ($app->user["login"] === $data["added_user"] && $invitation_user_data["status"] != STATUS_RECEIVED) ||
         ($app->user["login"] !== $data["added_user"] && $invitation_user_data["status"] != STATUS_SEND)) &&
        ($data["status"] != STATUS_COMMENT && $data["status"] != STATUS_VIEW))
    {
      $app->response->setStatus(STATUS_FORBIDDEN);
      return NULL;
    }
    if ($data["status"] == STATUS_VIEW)
    {
      $userView = true;
      $projectView = true;
    }
    else if ($app->user["login"] === $data["added_user"] && $data["status"] == STATUS_COMMENT)
    {
      $userView = true;
      $projectView = false;
    }
    else if ($app->user["login"] !== $data["added_user"] && $data["status"] == STATUS_COMMENT)
    {
      $userView = false;
      $projectView = true;
    }
    else if ($app->user["login"] === $data["added_user"])
    {
      $userView = true;
      $projectView = false;
    }
    else
    {
      $userView = false;
      $projectView = true;
    }
    $timestamp = $data["timestamp"];
    unset($data["timestamp"]);
    $data["view"] = $userView;
    $data_status = $data["status"];
    $data["status"] = ($data["status"] == STATUS_COMMENT || $data["status"] == STATUS_VIEW) ? $invitation_user_data["status"] : $data["status"];
    $data["comment"] = ($data["status"] == STATUS_VIEW) ? $invitation_user_data["comment"] : $data["comment"];
    $user_invitations[$timestamp] = $data;
    $user_info["invitations"] = $user_invitations;
    $data["view"] = $projectView;
    $data["status"] = ($data["status"] == STATUS_COMMENT || $data["status"] == STATUS_VIEW) ? $invitation_project_data["status"] : $data["status"];
    $data["comment"] = ($data["status"] == STATUS_VIEW) ? $invitation_project_data["comment"] : $data["comment"];
    $project_invitations[$timestamp] = $data;
    $project_info["invitations"] = $project_invitations;
    file_put_contents($app->config("base_dir")."/users/".$data["added_user"]."/invitations/info.json", json_encode($user_info));
    file_put_contents($app->config("base_dir").$data["project_url"]."/invitations/info.json", json_encode($project_info));
    if ($data_status == STATUS_ACK)
    {
      $project_auth = json_decode(file_get_contents($app->config("base_dir").$data["project_url"]."/auth.json"), TRUE);
      $permissions = $project_auth["users"];
      $permissions[$data["added_user"]] = array('is_admin_project' => ($app->config["default_admin_project_authorization"] === "admin"), 'is_edit_project' => ($app->config["default_edit_project_authorization"] === "edit"));
      $project_auth["users"] = $permissions;
      file_put_contents($app->config("base_dir").$data["project_url"]."/auth.json",json_encode($project_auth));
      symlink("/users/" .$data["added_user"], $app->config("base_dir").$data["project_url"]."/users/".$data["added_user"]);
      symlink($data["project_url"], $app->config("base_dir")."/users/" .$data["added_user"].$data["project_url"]);
    }
    $app->response->setStatus(STATUS_OK);
  }

  public function invitation_delete()
  {
    global $app;
    $info = json_decode(file_get_contents($app->config("base_dir").$app->resource->getURL()."/info.json"), TRUE);
    $info["invitations"] = array();
    file_put_contents($app->config("base_dir").$app->resource->getURL()."/info.json",json_encode($info));
    $app->response->setStatus(STATUS_NO_CONTENT);
  }

  public function changePermissions($data)
  {
    global $app;
    if (!$this->link_exists())
    {
      $app->response->setStatus(STATUS_NOT_FOUND);
      return;
    }
    $parts = explode('/', $this->getURL());
    $project_url = "/projects/".$parts[2];
    $username = $parts[count($parts) - 1];
    $project_auth = json_decode(file_get_contents($app->config("base_dir").$project_url."/auth.json"), TRUE);
    $permissions = $project_auth["users"];
    $user = $permissions[$username];
    $user["is_admin_project"] = (array_key_exists("is_admin_project", $data)) ? $data["is_admin_project"] : $user["is_admin_project"];
    $user["is_edit_project"] = (array_key_exists("is_edit_project", $data)) ? $data["is_edit_project"] : $user["is_edit_project"];
    $permissions[$username] = $user;
    $project_auth["users"] = $permissions;
    file_put_contents($app->config("base_dir").$project_url."/auth.json",json_encode($project_auth));
    $app->response->setStatus(STATUS_OK);
  }

  public function user_delete()
  {
    global $app;
    if (!$this->link_exists())
    {
      $app->response->setStatus(STATUS_NOT_FOUND);
      return;
    }
    $parts = explode('/', $this->getURL());
    $project_url = "/projects/".$parts[2];
    $user_url = "/users/".$parts[count($parts) - 1];
    $project_auth = json_decode(file_get_contents($app->config("base_dir").$project_url."/auth.json"), TRUE);
    $permissions = $project_auth["users"];
    unset($permissions[$parts[count($parts) - 1]]);
    $project_auth["users"] = $permissions;
    unlink($app->config("base_dir").$this->getURL());
    unlink($app->config("base_dir").$user_url.$project_url);
    file_put_contents($app->config("base_dir").$project_url."/auth.json",json_encode($project_auth));
    $app->response->setStatus(STATUS_NO_CONTENT);
  }
}


text:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Robert A Everley | My bits</title>
    <link>http://lpantano.github.io/author/robert-a-everley/</link>
      <atom:link href="http://lpantano.github.io/author/robert-a-everley/index.xml" rel="self" type="application/rss+xml" />
    <description>Robert A Everley</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Sat, 01 Jun 2019 00:00:00 +0000</lastBuildDate>
    <image>
      <url>http://lpantano.github.io/images/icon_hu0b7a4cb9992c9ac0e91bd28ffd38dd00_9727_512x512_fill_lanczos_center_3.png</url>
      <title>Robert A Everley</title>
      <link>http://lpantano.github.io/author/robert-a-everley/</link>
    </image>

    <item>
      <title>Multi omics analysis of fibrotic kidneys in two mouse models.</title>
      <link>http://lpantano.github.io/publication/pavkovic-2019/</link>
      <pubDate>Sat, 01 Jun 2019 00:00:00 +0000</pubDate>
      <guid>http://lpantano.github.io/publication/pavkovic-2019/</guid>
      <description></description>
    </item>

  </channel>
</rss>