GitHub PullRequestReviewCommentEvent at 2014-02-14 16:16:07
Repository: Phraseanet
Actor: nlegoff
Payload: {"comment":{"url":"https://api.github.com/repos/alchemy-fr/Phraseanet/pulls/comments/9753361","id":9753361,"diff_hunk":"@@ -459,81 +430,51 @@ public function connect(Application $app)\n \n                 foreach ($templates as $usr => $template_id) {\n                     $user = \\User_Adapter::getInstance($usr, $app);\n+                    $user_template = \\User_Adapter::getInstance($template_id, $app);\n                     $cache_to_update[$usr] = true;\n \n-                    $user_template = \\User_Adapter::getInstance($template_id, $app);\n-                    $base_ids = array_keys($app['acl']->get($user_template)->get_granted_base());\n+                    $baseIds = array_keys($app['acl']->get($user_template)->get_granted_base());\n \n-                    $app['acl']->get($user)->apply_model($user_template, $base_ids);\n+                    $app['acl']->get($user)->apply_model($user_template, $baseIds);\n \n-                    if (!isset($done[$usr])) {\n-                        $done[$usr] = [];\n+                    foreach ($baseIds as $baseId) {\n+                        $done[$usr][$baseId] = true;\n                     }\n \n-                    foreach ($base_ids as $base_id) {\n-                        $done[$usr][$base_id] = true;\n-                    }\n-\n-                    $sql = \"\n-                    DELETE FROM demand\n-                    WHERE usr_id = :usr_id\n-                    AND (base_id = \" . implode(' OR base_id = ', $base_ids) . \")\";\n-\n-                    $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);\n-                    $stmt->execute([':usr_id' => $usr]);\n-                    $stmt->closeCursor();\n+                    $app['manipulator.registration']->deleteUserRegistrations($user, array_map(function ($baseId) use ($app) {\n+                        return \\collection::get_from_base_id($app, $baseId);\n+                    }, $baseIds));\n                 }\n \n-                $sql = \"\n-                UPDATE demand SET en_cours=0, refuser=1, date_modif=now()\n-                WHERE usr_id = :usr_id\n-                AND base_id = :base_id\";\n-\n-                $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);\n-\n                 foreach ($deny as $usr => $bases) {\n+                    $user = \\User_Adapter::getInstance($usr, $app);\n                     $cache_to_update[$usr] = true;\n-                    foreach ($bases as $bas) {\n-                        $stmt->execute([':usr_id'  => $usr, ':base_id' => $bas]);\n-\n-                        if (!isset($done[$usr])) {\n-                            $done[$usr] = [];\n-                        }\n-\n-                        $done[$usr][$bas] = false;\n+                    foreach ($app['manipulator.registration']->getRepository()->getUserRegistrations(","path":"lib/Alchemy/Phrasea/Controller/Admin/Users.php","position":137,"original_position":137,"commit_id":"d20db3d1b7c22bb2f540aab48c077e0a27d70d50","original_commit_id":"d20db3d1b7c22bb2f540aab48c077e0a27d70d50","user":{"login":"nlegoff","id":511494,"avatar_url":"https://gravatar.com/avatar/39eb17a525ef91daf27834b6cea028ba?d=https%3A%2F%2Fidenticons.github.com%2F716eafd621ae9b0a38a24bb1a0edcd28.png&r=x","gravatar_id":"39eb17a525ef91daf27834b6cea028ba","url":"https://api.github.com/users/nlegoff","html_url":"https://github.com/nlegoff","followers_url":"https://api.github.com/users/nlegoff/followers","following_url":"https://api.github.com/users/nlegoff/following{/other_user}","gists_url":"https://api.github.com/users/nlegoff/gists{/gist_id}","starred_url":"https://api.github.com/users/nlegoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlegoff/subscriptions","organizations_url":"https://api.github.com/users/nlegoff/orgs","repos_url":"https://api.github.com/users/nlegoff/repos","events_url":"https://api.github.com/users/nlegoff/events{/privacy}","received_events_url":"https://api.github.com/users/nlegoff/received_events","type":"User","site_admin":false},"body":"I cant here $bases is an array of baseIds provided by the request","created_at":"2014-02-14T16:16:07Z","updated_at":"2014-02-14T16:16:07Z","html_url":"https://github.com/alchemy-fr/Phraseanet/pull/900#discussion_r9753361","pull_request_url":"https://api.github.com/repos/alchemy-fr/Phraseanet/pulls/900","_links":{"self":{"href":"https://api.github.com/repos/alchemy-fr/Phraseanet/pulls/comments/9753361"},"html":{"href":"https://github.com/alchemy-fr/Phraseanet/pull/900#discussion_r9753361"},"pull_request":{"href":"https://api.github.com/repos/alchemy-fr/Phraseanet/pulls/900"}}}}