]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5755 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 Feb 2023 14:21:13 +0000 (15:21 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 Feb 2023 14:21:13 +0000 (15:21 +0100)
app/Console/Commands/ToolboxPrecache.php [new file with mode: 0644]
app/Console/Kernel.php
app/Fluidbook/Packager/WindowsZIP.php
app/Jobs/RefreshUsersTree.php [new file with mode: 0644]
app/Jobs/UsersTree.php [deleted file]
app/Models/Base/ToolboxModel.php
app/Models/FluidbookPublication.php
scripts/update

diff --git a/app/Console/Commands/ToolboxPrecache.php b/app/Console/Commands/ToolboxPrecache.php
new file mode 100644 (file)
index 0000000..14016e8
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Fluidbook\Farm;
+use Cubedesigners\UserDatabase\Permissions;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+
+class ToolboxPrecache extends CubistCommand
+{
+    protected $signature = 'toolbox:precache';
+    protected $description = 'Precache Toolbox';
+
+    public function handle()
+    {
+        // Users tree
+        Permissions::_getData(true);
+    }
+}
index 02144204cf93318194643c4a875eb2e7cc8f810c..9697ac3a3944f6c3f729a2ce7119ec6561adb195 100644 (file)
@@ -39,6 +39,7 @@ class Kernel extends \Cubist\Backpack\Console\Kernel
 
         $schedule->command('fluidbook:farm:ping')->everyMinute();
         $schedule->command('cubist:magic:precache')->everyFiveMinutes();
+        $schedule->command('toolbox:precache')->everyThirtyMinutes();
     }
 
     /**
index 726c632ee4ed79cde34f5621097f3cac654e5aff..8cb62ac8a7d392c83a3f0fb30823dc8bdc076836 100644 (file)
@@ -143,7 +143,7 @@ class WindowsZIP extends Packager
             }
 
             $cli = new CommandLine('C:/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64/signtool.exe');
-            $cli->setManualArg("sign /f C:/Users/vince/Documents/Cubedesigners.cer /csp \"eToken Base Cryptographic Provider\" /k \"[SafeNet Token JC 0{{TYWjZacq%hAH98}}]=54C3F1B91759268A\" /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a C:/Sign/$rand");
+            $cli->setManualArg("sign /f C:/Users/vince/Documents/Cubedesigners.cer /csp \"eToken Base Cryptographic Provider\" /k \"[SafeNet Token JC 0{{TYWjZacq%hAH98}}]=54C3F1B91759268A\" /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a $remote");
             $cli->execute($ssh);
             if (!stristr($cli->getOutput(), 'Successfully signed')) {
                 $ssh->unlink($remote);
diff --git a/app/Jobs/RefreshUsersTree.php b/app/Jobs/RefreshUsersTree.php
new file mode 100644 (file)
index 0000000..850ccc1
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Jobs;
+
+use Cubedesigners\UserDatabase\Permissions;
+
+class RefreshUsersTree extends Base
+{
+    public function handle()
+    {
+        Permissions::_getData(true);
+    }
+}
diff --git a/app/Jobs/UsersTree.php b/app/Jobs/UsersTree.php
deleted file mode 100644 (file)
index e5b04ca..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-class UsersTree extends Base
-{
-    protected $jobName = 'userstree';
-
-    protected $users=[];
-    protected $admins=[];
-    protected $grades=[];
-    protected $facturables=[];
-    protected $rights=[];
-    protected $entreprises=[];
-
-    public function handle()
-    {
-
-
-        $this->users = array();
-        $this->admins = array();
-        $this->grades = array();
-        $this->entreprises = array();
-        $this->domains = array();
-
-        $this->rights = array();
-
-        $r = $this->con->select('SELECT * FROM e2_u u LEFT JOIN e2_c e ON u.entreprise=e.entreprise_id WHERE e.ws_grade>0 ORDER BY e.ws_grade ASC');
-        while ($r->fetch()) {
-            $this->entreprises[$r->utilisateur_id] = $r->entreprise_id;
-            $this->users[$r->utilisateur_id] = $r->ws_admin;
-            $this->grades[$r->utilisateur_id] = $r->ws_grade;
-            if (!isset($this->admins[$r->ws_admin])) {
-                $this->admins[$r->ws_admin] = array();
-            }
-            if (!isset($this->admins[$r->utilisateur_id])) {
-                $this->admins[$r->utilisateur_id] = array();
-            }
-            $this->admins[$r->ws_admin][] = $r->utilisateur_id;
-            $d = explode('@', $r->email);
-            $this->domains[$r->utilisateur_id] = mb_strtolower($d[1]);
-        }
-
-        $daoBook = new wsDAOBook($this->con);
-        $books = $daoBook->selectAll();
-        $owners = [];
-        foreach ($books as $book) {
-            if (!isset($owners[$book->proprietaire_id])) {
-                $owners[$book->proprietaire_id] = 0;
-            }
-            $owners[$book->proprietaire_id]++;
-        }
-
-        $this->facturables = $this->getFacturables();
-        // Fabrication de l'arbre
-        $c = $this->con->openCursor('ws_users_tree');
-        $ce = $this->con->openCursor('ws_entreprises_tree');
-
-        $evu = array();
-
-        foreach ($this->users as $utilisateur_id => $admin) {
-            $facturable_id = $administrateur_id = 0;
-            $this->getFacturableOf($utilisateur_id, $facturable_id, $administrateur_id, 1);
-
-            if (!isset($this->entreprises[$facturable_id]) || is_null($this->entreprises[$facturable_id])) {
-                //$this->entreprises[$facturable_id]=$this->entreprises[$utilisateur_id];
-            }
-
-            $c->utilisateur_id = $utilisateur_id;
-            $ce->entreprise_id = $c->entreprise_id = $this->entreprises[$utilisateur_id];
-            $c->facturable_id = $facturable_id;
-            $ce->facturable_entreprise_id = $c->facturable_entreprise_id = $this->entreprises[$facturable_id];
-            $ce->administrateur_id = $c->administrateur_id = $administrateur_id;
-            try {
-                $c->insert();
-            } catch (Exception $e) {
-                fb($e);
-            }
-            if (isset($evu[$c->entreprise_id])) {
-                continue;
-            }
-            try {
-                $ce->insert();
-            } catch (Exception $e) {
-                fb($e);
-            }
-            $evu[$c->entreprise_id] = true;
-        }
-        // Fabrication de la liste des droits à partir de l'arbre
-        $j = 0;
-        for ($i = 1; $i <= 5; $i++) {
-            foreach ($this->admins as $admin_id => $list) {
-                $newlist = $list;
-                foreach ($list as $uid) {
-                    if ($uid != $admin_id && isset($this->admins[$uid])) {
-                        $newlist = array_merge($this->admins[$uid], $newlist);
-                    }
-                }
-                $this->admins[$admin_id] = array_unique($newlist);
-            }
-        }
-        // Ajout des droits personnels
-        foreach ($this->users as $uid => $admin) {
-            $this->admins[$uid][] = $uid;
-        }
-        // Echange des droits entre collègues
-        foreach ($this->admins as $admin_id => $list) {
-            if (!isset($this->entreprises[$admin_id])) {
-                continue;
-            }
-            $e = $this->entreprises[$admin_id];
-            $collegues = array_keys($this->entreprises, $e);
-            $newlist = $this->admins[$admin_id];
-            foreach ($collegues as $c) {
-                $newlist = array_merge($newlist, $this->admins[$c]);
-            }
-            $newlist = array_unique($newlist);
-            $this->admins[$admin_id] = $newlist;
-            foreach ($collegues as $c) {
-                $this->admins[$c] = $newlist;
-            }
-        }
-
-        $adom = array();
-
-        foreach ($this->admins as $admin => $list) {
-            $this->admins[$admin] = array_unique($list);
-            sort($this->admins[$admin]);
-
-            $adom[$admin] = array();
-            foreach ($list as $id) {
-                $adom[$admin][] = $this->domains[$id];
-            }
-            $adom[$admin] = array_unique($adom[$admin]);
-        }
-
-        $c = $this->con->openCursor('extranet_users.user');
-        foreach ($this->admins as $admin => $list) {
-            $wscount = 0;
-            foreach ($list as $item) {
-                $wscount += $owners[$item];
-            }
-            $c->e1_ws_count = $wscount;
-            $c->e1_ws_rights = implode(',', $list);
-            $c->e1_ws_domains = implode(',', $adom[$admin]);
-            $c->update('WHERE id=\'' . $this->con->escape($admin) . '\'');
-        }
-    }
-
-    protected function getFacturableOf($utilisateur_id, &$facturable_id, &$administrateur_id, $level)
-    {
-        if (in_array($utilisateur_id, $this->facturables)) {
-            $facturable_id = $utilisateur_id;
-            $administrateur_id = $this->users[$utilisateur_id];
-            return;
-        }
-        if ($level > 10) {
-            $facturable_id = -1;
-            $administrateur_id = -1;
-            return;
-        }
-        if (!$utilisateur_id || !isset($this->users[$utilisateur_id])) {
-            return;
-        }
-
-        return $this->getFacturableOf($this->users[$utilisateur_id], $facturable_id, $administrateur_id, $level + 1);
-    }
-
-    protected function getFacturables()
-    {
-        $res = array();
-        foreach ($this->users as $utilisateur_id => $admin) {
-            if ($this->grades[$admin] == 5) {
-                $res[] = $utilisateur_id;
-            }
-        }
-        sort($res);
-        return $res;
-    }
-
-}
index 95d81fb84313649eea5259a76aaabb94ef1ecaf2..ac5db553b264d9e46b15bd2702ccad3cca080dc5 100644 (file)
@@ -70,7 +70,7 @@ class ToolboxModel extends CubistMagicAbstractModel
             'column_escape' => false,
             'attribute' => 'companyWithName',
             'default' => Auth::id(),
-            'non_default_tracking' => false,
+            'non_default_tracking' => true,
         ];
 
         $this->addField(array_merge($fieldSettings, $options));
index f8f5ff62d0677be63edda8e6951deb3af3b8fb07..d325cfce0d3a5435ba64e4f76037f93dfd8caaaf 100644 (file)
@@ -67,7 +67,57 @@ class FluidbookPublication extends ToolboxSettingsModel
         parent::setFields();
 
 
-        $this->addOwnerField();
+        $this->addField('hash', Hidden::class);
+        $this->addField('cid', Hidden::class);
+
+        $this->addField('extranet_task', Hidden::class, __('Tâche de l\'extranet'));
+        $this->addField('export_data', Hidden::class, __('Paramètres d\'export'));
+        // Composed fields
+        $composed = [
+            'c_title' => [
+                'label' => __('Titre'),
+                'type' => Hidden::class,
+                'read_only' => true,
+                'column' => true,
+                'column_move_after' => 'id',
+            ],
+            'c_pages' => [
+                'label' => __('Pages'),
+                'column_label' => '<i class="las la-file-alt" title="' . __('') . '"></i>',
+                'read_only' => true,
+                'column' => true,
+                'column_move_after' => 'c_title',
+            ],
+            'admin' => [
+                'label' => __('Administrateur'),
+                'read_only' => true,
+                'type' => User::class,
+                'hidden' => true,
+                'column' => true,
+                'can' => 'fluidbook-publication:admin',
+                'column_attribute' => 'companyWithNameOnTwoLines',
+                'column_move_after' => 'owner',
+                'attribute' => 'companyWithName',
+            ],
+            'super_admin' => __('Super administrateur'),
+            'owner_company_name' => __('Propriétaire'),
+            'owner_name' => __('Propriétaire'),
+            'invoicable' => __('Utilisateur facturable'),
+            'invoicable_company' => __('Facturation'),
+            'extranet_project' => __('Project extranet'),
+        ];
+
+        foreach ($composed as $name => $label) {
+            $defaultAttributes = ['name' => $name, 'type' => Hidden::class, 'read_only' => true];
+            if (is_string($label)) {
+                $attributes = array_merge($defaultAttributes, ['label' => $label]);
+            } else if (is_array($label)) {
+                $attributes = array_merge($defaultAttributes, $label);
+            }
+            $this->addField($attributes);
+        }
+
+        $this->addOwnerField(['column_attribute' => 'allTreeInfos']);
 
         $this->addField('region', SelectFromArray::class, __('Région d\'hébergement des données'), ['options' => ['UE' => __('Union européenne'), 'US' => 'USA'], 'default' => 'UE', 'allows_null' => false, 'databaseDefault' => 'UE']);
 
@@ -105,7 +155,7 @@ class FluidbookPublication extends ToolboxSettingsModel
         $this->addField('section_infos', FormBigSection::class, __('Administration'));
 
 
-        $this->addField('visits_counter', Integer::class, 'Compteur de visites', ['read_only' => true, 'default' => 0, 'column' => true, 'column_label' => '<i class="las la-chart-area" title="Compteur de visites du lien de préview"></i>', 'searchLogic' => false]);
+        $this->addField('visits_counter', Integer::class, 'Compteur de visites', ['read_only' => true, 'default' => 0, 'column' => true, 'column_label' => '<i class="las la-chart-area" title="' . __('Compteur de visites du lien de préview') . '"></i>', 'searchLogic' => false]);
 
         $this->addField(self::CREATED_AT, Datetime::class, __('Crée'), ['column' => true, 'column_type' => 'datetime', 'column_format' => 'YYYY-MM-DD', 'filter' => true, 'read_only' => true, 'searchLogic' => false]);
         $this->addField(self::UPDATED_AT, Datetime::class, __('Mis à jour'), ['column' => true, 'column_format' => 'YYYY-MM-DD', 'filter' => true, 'read_only' => true, 'searchLogic' => false]);
@@ -113,45 +163,7 @@ class FluidbookPublication extends ToolboxSettingsModel
         $this->addField('composition_updated_at', Datetime::class, __('Dernière modification de la composition'), ['read_only' => true]);
         $this->addField('status_date', Datetime::class, __('Date de changement de status'), ['read_only' => true]);
 
-        $this->addField('hash', Hidden::class);
-        $this->addField('cid', Hidden::class);
 
-        $this->addField('extranet_task', Hidden::class, __('Tâche de l\'extranet'));
-        $this->addField('export_data', Hidden::class, __('Paramètres d\'export'));
-        // Composed fields
-        $composed = ['admin' => [
-            'label' => __('Administrateur'),
-            'read_only' => true,
-            'type' => User::class,
-            'column' => true,
-            'can' => 'fluidbook-publication:admin',
-            'column_attribute' => 'companyWithNameOnTwoLines',
-            'column_move_after' => 'owner',
-            'attribute' => 'companyWithName',
-        ],
-            'super_admin' => __('Super administrateur'),
-            'owner_company_name' => __('Propriétaire'),
-            'owner_name' => __('Propriétaire'),
-            'invoicable' => __('Utilisateur facturable'),
-            'invoicable_company' => __('Facturation'),
-            'extranet_project' => __('Project extranet'),
-            'c_title' => [
-                'label' => __('Titre'),
-                'read_only' => true,
-                'column' => true,
-                'column_move_after' => 'id',
-            ]
-        ];
-
-        foreach ($composed as $name => $label) {
-            $defaultAttributes = ['name' => $name, 'type' => Hidden::class];
-            if (is_string($label)) {
-                $attributes = array_merge($defaultAttributes, ['label' => $label]);
-            } else if (is_array($label)) {
-                $attributes = array_merge($defaultAttributes, $label);
-            }
-            $this->addField($attributes);
-        }
     }
 
     public function onSaving(): bool
@@ -205,6 +217,7 @@ class FluidbookPublication extends ToolboxSettingsModel
         $this->invoicable_company = '';
         $this->extranet_project = '';
         $this->c_title = $this->title;
+        $this->c_pages = count($this->composition);
     }
 
     public function __($str)
index bc1164e9124531481051d316290049c0ee0bdc44..cebdac1c4ec6df5a53520985d7291189f81f4973 100644 (file)
@@ -19,6 +19,7 @@ sudo chown -R 1001:33 /application/storage/framework
 sudo chown -R 1001:33 /application/storage/framework
 php artisan optimize:clear
 php artisan cubist:magic:precache
+php artisan toolbox:precache
 sudo chown -R 1001:33 /application/storage/framework
 sudo chown -R 1001:33 /application/vendor
 sudo chown -R 0:0 /etc/sudoers.d/toolbox