<?php
namespace Claromentis\Projects\Datasource;

$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] ?: array()) + array("project" . "_id" => base64_decode("cHJvamVjd" . "F9pZA=="), "_4d707fab93bebb00bbe69e8159" . "697c90" => base64_decode(""), "_ed453d392e711e668" . "82690e57d93cf78" => base64_decode("QV" . "ND"), "_18c93a32ba5faf9509389a94" . "787e6798" => base64_decode("bW9" . "kaW" . "ZpZ" . "WQ="), "_9468bcca522" . "66e7b5b790ff" . "2da0228de" => base64_decode("bWV" . "udQ" . "=="), "_043583fc" . "6e4063be6" . "ec4a31bf9" . "51616c" => base64_decode("L3Byb2plY3RzLw=" . "="), "_0ea4e32b57963ac0cb305" . "7e03e9aef64" => base64_decode("aW" . "Q="), "_83967f436226989a" . "cd6e5766455a0729" => base64_decode("U0VMRUNUIERJU1RJTkNUIHVzZXJfaWQsIG9iamVjdF" . "9pZCwgdGltZXN0YW1wCgkJCUZST00gZGlzY3Vzc2lv" . "bnMKCQkJV0hFUkUgYWdncmVnYXRpb249aW50OmFnZw" . "oJCQlPUkRFUiBCWSB0aW1lc3RhbXAgREVTQw=="), "_e4543e131c" . "67c631b1475" . "1cc849d1310" => base64_decode("dXNlcn" . "M="), "_f4746c0883a144e" . "cfa8b65f888f47ae" . "8" => base64_decode("cHJvamVjdHMudG9wa" . "WMubGFzdF91cGRhdG" . "Vk"), "_34460bff" . "d3af92da8" . "1e46ee15e" . "9e66e3" => base64_decode("c3" . "Ry"), "_3f8ac7c7cb" . "db4517e6ae7" . "2a22cc9721c" => base64_decode("Y2FuX3" . "Bpbg=="), "_e60e1a002ae182bc58" . "9ef514ef645c10" => base64_decode("Y3J" . "lYX" . "RlZ" . "A=="), "_b40e526492b1bf5e7201303956" . "c1e98a" => base64_decode("cHJvamVjdHMudG9waWMudGl0bGU" . "="), "_48ca4427015380c918e6f6e" . "32ca7bea1" => base64_decode("Y2FuX2" . "VkaXQ="), "_feb9037589181bc30f" . "a0f1cf78b9f056" => base64_decode("dGl0bG" . "U="), "_3a283f70" . "73dba8315" . "18317d2d3" . "91e665" => base64_decode("cGlubm" . "Vk"), "_37c954b254426" . "0120a7645d0a92" . "27b12" => base64_decode("L3RvcGljcy8" . "="), "_7f534cec6dad6d7db424acd4f699" . "43a4" => base64_decode("cHJvamVjdHM" . "udG9waWMudX" . "NlcnM="), "_206f063cdbd5801a283704ef0c88" . "3699" => base64_decode("a2V" . "5d2" . "9yZ" . "HM="), "_8423a12e0b13b9278c89d68d" . "55843a1e" => base64_decode("cHJvamVjdHMudG9w" . "aWMuY3JlYXRlZF9k" . "YXRl"));
use Claromentis\Comments\CommentsRepository;
use Claromentis\Core\DAL;
use Claromentis\Core\DAL\Interfaces\DbInterface;
use Claromentis\Core\DataTable;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\UserRepository;
use Claromentis\People\UrlGenerator;
use Claromentis\Projects\Api\TopicApi;
use Claromentis\Projects\Decorator\TopicPin;
use Claromentis\Projects\Decorator\UserBubbles;
use Claromentis\Projects\Entity\Topic;
use Claromentis\Projects\Exceptions\ProjectException;
use Claromentis\Projects\ProjectApi;
use Claromentis\Projects\Repository\ProjectRepository;
use Claromentis\Projects\Repository\TopicRepository;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;




class TopicDataSource implements DataTable\Contract\DataSource
{
    use DataTable\Shared\ColumnHelper;
    
    
    
    
    protected $lmsg;
    
    
    
    
    protected $project_api;
    
    
    
    
    protected $topic_api;
    
    
    
    
    protected $url_generator;
    
    
    
    
    protected $comments_repository;
    
    
    
    
    protected $db;
    
    
    
    
    protected $user_repository;
    
    
    
    
    protected $people_acl;
    
    
    
    
    protected $people_url_generator;
    public function __construct(Lmsg $lmsg, ProjectApi $project_api, TopicApi $topic_api, UrlGeneratorInterface $url_generator, CommentsRepository $comments_repository, DbInterface $db, UserRepository $user_repository, UrlGenerator $people_url_generator, PeopleAcl $_3d3cf5257abd66970c2706086e13633d)
    {
        $this->lmsg = $lmsg;
        $this->project_api = $project_api;
        $this->topic_api = $topic_api;
        $this->url_generator = $url_generator;
        $this->comments_repository = $comments_repository;
        $this->db = $db;
        $this->user_repository = $user_repository;
        $this->people_acl = $_3d3cf5257abd66970c2706086e13633d;
        $this->people_url_generator = $people_url_generator;
    }
    
    
    
    
    
    
    
    
    
    public function Columns(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915 = null)
    {
        $_a42c86642011ef739b88ee80672c387d = [[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_feb9037589181bc30fa0f1cf78b9" . "f056"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_b40e526492b1" . "bf5e720130395" . "6c1e98a"]), new DataTable\Decorator\Link(), true], [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_e60e1a002ae182bc589ef514ef" . "645c10"], ($this->lmsg)($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_8423a12e" . "0b13b9278" . "c89d68d55" . "843a1e"]), new DataTable\Decorator\Text(), true], [$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_18c93a32ba5faf9509389a9478" . "7e6798"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_f4746c0883a144ecf" . "a8b65f888f47ae8"]), new DataTable\Decorator\Text(), true], [$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_e4543e131c" . "67c631b1475" . "1cc849d1310"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_7f534cec6dad6d7db424ac" . "d4f69943a4"]), new UserBubbles($this->user_repository, $this->people_url_generator, $this->people_acl, $context), false], [$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_9468bcca52266e7b5b7" . "90ff2da0228de"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e815" . "9697c90"], new TopicPin(), false]];
        return $this->CreateWithColumns($_a42c86642011ef739b88ee80672c387d);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function Data(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_03e9164d0a343b742df4793268b80767)
    {
        $project_id = $_4c4d12d3e4f6cac68e3eecffe9887915->GetValue($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["project_i" . "d"]);
        try {
            $project = $this->project_api->GetProject($project_id);
        } catch (ProjectException $_c35473364fa7a050299058f332ec29c1) {
            
            
            return [];
        }
        $permissions_checker = $this->project_api->GetPermissionsChecker($context);
        if (!$project->CanIViewAllTopics($permissions_checker)) {
            return [];
        }
        $_94381291864d0f523f1134e5489cf693 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetSortColumn() ?? $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_feb90375" . "89181bc30" . "fa0f1cf78" . "b9f056"];
        $_0290d5279a73376ebff811c191d735a6 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetSortDir() ?? $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_ed453d392e7" . "11e66882690e" . "57d93cf78"];
        $_1f50e30be8c2fefa6881834e71d504a2 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetOffset() ?? 0;
        $_f11369824f533e8206f9ccc0c9aab3a0 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetLimit() ?? 10;
        $_8504fb9a862cd138672be3d3f0fcca51 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetKeywords();
        if ($_8504fb9a862cd138672be3d3f0fcca51 === null) {
            $_8504fb9a862cd138672be3d3f0fcca51 = [];
        } else {
            $_8504fb9a862cd138672be3d3f0fcca51 = [$_8504fb9a862cd138672be3d3f0fcca51];
        }
        
        
        $_cd719ef6482c26430d646b6ff2207ebd = $this->topic_api->GetTopics($project_id, $_94381291864d0f523f1134e5489cf693, $_0290d5279a73376ebff811c191d735a6, $_f11369824f533e8206f9ccc0c9aab3a0, $_1f50e30be8c2fefa6881834e71d504a2, $_8504fb9a862cd138672be3d3f0fcca51);
        $_a71dc9333bd8ad95d55d6624b477875f = [];
        $_6741cc1325b528bfdb36b3ca28976c4d = [];
        $_7f5aa4e96d4b415a86ed72ebff677cbe = new DAL\Query($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_83967f436226989ac" . "d6e5766455a0729"], Topic::AGGREGATION);
        $_7f5aa4e96d4b415a86ed72ebff677cbe->setLimit(20);
        $_8fa231fbd8b64d38cd32253e053062ea = $this->db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
        
        
        while ([$user_id, $_27ea6380ba99bf298d5d821449632f07] = $_8fa231fbd8b64d38cd32253e053062ea->fetchRow()) {
            $_6741cc1325b528bfdb36b3ca28976c4d[$_27ea6380ba99bf298d5d821449632f07] = $_6741cc1325b528bfdb36b3ca28976c4d[$_27ea6380ba99bf298d5d821449632f07] ?? [];
            $_6741cc1325b528bfdb36b3ca28976c4d[$_27ea6380ba99bf298d5d821449632f07][] = $user_id;
        }
        foreach ($_cd719ef6482c26430d646b6ff2207ebd as $topic) {
            $_e4543e131c67c631b14751cc849d1310 = $_6741cc1325b528bfdb36b3ca28976c4d[$topic->id] ?? [];
            $_b8cfc2e06d9d1fec1893ea4a054002bf = [];
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_feb9037589181bc30fa0f1cf7" . "8b9f056"]] = [$topic->title, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_043583fc6e4" . "063be6ec4a31" . "bf951616c"] . $project_id . $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_37c954b2544260120a7645d0a" . "9227b12"] . $topic->id];
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_e60e1a002ae182bc589ef514ef" . "645c10"]] = $topic->created->getDate(DATE_FORMAT_CLA_LONG_DATE);
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_18c93a32ba5faf950938" . "9a94787e6798"]] = $topic->modified->getDate(DATE_FORMAT_CLA_LONG_DATE);
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_e4543e13" . "1c67c631b" . "14751cc84" . "9d1310"]] = $_e4543e131c67c631b14751cc849d1310;
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_9468bcca5" . "2266e7b5b7" . "90ff2da022" . "8de"]] = [$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_0ea4e32b57963a" . "c0cb3057e03e9ae" . "f64"] => $topic->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["pro" . "jec" . "t_i" . "d"] => $topic->project_id, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_3a283f7073dba831518317d2d391" . "e665"] => $topic->pinned, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_48ca442701" . "5380c918e6f" . "6e32ca7bea1"] => $project->CanIEditTopic($permissions_checker, $topic), $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_3f8ac7c7cb" . "db4517e6ae7" . "2a22cc9721c"] => $project->CanIPinTopic($permissions_checker, $topic)];
            $_a71dc9333bd8ad95d55d6624b477875f[] = $_b8cfc2e06d9d1fec1893ea4a054002bf;
        }
        return $_a71dc9333bd8ad95d55d6624b477875f;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function Count(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_e0bd284b1527841bc9c635873b56303b)
    {
        $project_id = $_4c4d12d3e4f6cac68e3eecffe9887915->GetValue($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["project_i" . "d"]);
        try {
            $project = $this->project_api->GetProject($project_id);
        } catch (ProjectException $_c35473364fa7a050299058f332ec29c1) {
            
            
            return 0;
        }
        $permissions_checker = $this->project_api->GetPermissionsChecker($context);
        $_8504fb9a862cd138672be3d3f0fcca51 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetKeywords();
        if ($_8504fb9a862cd138672be3d3f0fcca51 === null) {
            $_8504fb9a862cd138672be3d3f0fcca51 = [];
        } else {
            $_8504fb9a862cd138672be3d3f0fcca51 = [$_8504fb9a862cd138672be3d3f0fcca51];
        }
        if (!$project->CanIViewAllTopics($permissions_checker)) {
            return 0;
        }
        return $this->topic_api->CountTopics($project_id, $_8504fb9a862cd138672be3d3f0fcca51);
    }
    
    
    
    
    
    
    public function Filters()
    {
        return [$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_206f063cdbd5801a28370" . "4ef0c883699"] => new DataTable\ColumnFilter($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_206f063cdbd5801a283704ef0" . "c883699"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_34460bffd3af92da81e46ee" . "15e9e66e3"])];
    }
}