コード例 #1
0
$rightPdoManager = new RightPdoManager();
//Chemin des fichiers de test
$path = 'D:\\Cours SUPINFO\\M1\\Projet Fin d\'annee\\Nestbox\\Fichiers de test/';
/**
 *  /Nestbox/
 *          IMG/
 *              Croquis Nesbtox.jpg
 *          code/
 *              js/
 *                 front/
 *                       js.txt
 *              css/
 *                  test.txt
 *
 *          suivi de projet.gdoc
 *          liens upload.gdoc
 *          Explorateur de fichier.gdoc
 *  /Nestbox - test/
 *	carte.gif
 */
//contient 12 éléments
$insert = array(array('_id' => new MongoId('5392061f09413a1021000041'), 'state' => 1, 'name' => 'Nestbox', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/'), array('state' => 1, 'name' => 'Nestbox - test', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000074'), 'serverPath' => '/'), array('state' => 1, 'name' => 'IMG', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'Croquis Nestbox', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb502180800006f'), 'serverPath' => '/Nestbox/IMG/', 'size' => fileSize64($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'hash' => sha1_file($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'downloadLink' => ''), array('state' => 1, 'name' => 'code', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'js', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'front', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/js/'), array('state' => 1, 'name' => 'js', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('539b0c4eedb502ac0d000044'), 'serverPath' => '/Nestbox/code/js/front/', 'size' => fileSize64($path . 'Nestbox/code/js/front/js.txt'), 'hash' => sha1_file($path . 'Nestbox/code/js/front/js.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'css', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'test', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('539b0c4eedb502ac0d000044'), 'serverPath' => '/Nestbox/code/css/', 'size' => fileSize64($path . 'Nestbox/code/css/test.txt'), 'hash' => sha1_file($path . 'Nestbox/code/css/test.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'suivi de projet', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/suivi de projet.doc'), 'hash' => sha1_file($path . 'Nestbox/suivi de projet.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'liens upload', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/liens upload.doc'), 'hash' => sha1_file($path . 'Nestbox/liens upload.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'Explorateur de fichier', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/Explorateur de fichier.doc'), 'hash' => sha1_file($path . 'Nestbox/Explorateur de fichier.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'carte', 'idOwner' => new MongoId('5397628aedb502300d000050'), 'idRefElement' => new MongoId('53639f93edb502180800006b'), 'serverPath' => '/', 'size' => fileSize64($path . 'carte.gif'), 'hash' => sha1_file($path . 'carte.gif'), 'downloadLink' => ''), array('idOwner' => new MongoId("5397628aedb502300d000050"), 'idRefElement' => new MongoId("53639f93edb5021808000074"), 'name' => 'First Share', 'serverPath' => '/', 'state' => new MongoInt32(1)));
foreach ($insert as $element) {
    $elementPdoManager->create($element);
}
$insertRight = array(array('idElement' => new MongoId("53977311edb502b40c000050"), 'idRefRight' => new MongoId("53639f93edb5021808000047"), 'idUser' => new MongoId("536749adedb5025416000029"), 'state' => new MongoInt32(1)), array('idElement' => new MongoId("539761f1edb502300d00004f"), 'idRefRight' => new MongoId("53639f93edb5021808000047"), 'idUser' => new MongoId("536749adedb5025416000029"), 'state' => new MongoInt32(1)));
foreach ($insertRight as $right) {
    $rightPdoManager->create($right);
}
echo 'Insertion OK';
exit;
コード例 #2
0
ファイル: ActionManager.php プロジェクト: at69/beta-nestbox
/**
 * Copie les droits appliqués aux éléments d'une liste source pour les éléments d'une autre liste.
 * Attention: les deux listes doivent être de même taille et l'ordre des éléments car une association des id des éléments
 * sources et ceux de la seconde liste sont associés dans leur ordre de rangement.
 * @author Alban Truc
 * @param array $sourceElementList
 * @param array $pastedElementList
 * @since 07/06/05
 */
function copyRights($sourceElementList, $pastedElementList)
{
    $rightPdoManager = new RightPdoManager();
    $rightCriteria = array('state' => (int) 1);
    $sourceRightList = array();
    $associateIds = array();
    $count = 0;
    foreach ($sourceElementList as $sourceElement) {
        $associateIds[(string) $sourceElement->getId()] = (string) $pastedElementList[$count]->getId();
        $count++;
        $rightCriteria['idElement'] = $sourceElement->getId();
        $rights = $rightPdoManager->find($rightCriteria);
        if (!array_key_exists('error', $rights)) {
            $sourceRightList = array_merge_recursive($sourceRightList, $rights);
        }
    }
    //si on voulait log
    //$rightsToPaste = array();
    //$pastedRights = array();
    //$failedToPaste = array();
    //$count = 0
    foreach ($sourceRightList as $right) {
        $rightCopy = clone $right;
        $rightCopy->setId(new MongoId());
        $rightCopy->setElement(new MongoId($associateIds[(string) $right->getElement()]));
        //$rightsToPaste[] = $rightCopy;
        $insertResult = $rightPdoManager->create($rightCopy);
        //si on voulait log
        /*
        if(!(is_bool($insertResult))) //erreur
        {
            $failedToPaste[$count]['rightToCopy'] = $right;
            $failedToPaste[$count]['rightCopy'] = $rightCopy;
            $failedToPaste[$count]['error'] = $insertResult['error'];
            $count++;
        }
        else $pastedRight[] = $rightCopy;
        */
    }
}